mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2024-11-21 19:55:20 -05:00
Read hamlib_settings.json when rig is None to allow PTT only config
This commit is contained in:
parent
a1808c99f7
commit
e3bffc3ece
@ -259,53 +259,53 @@ HamlibTransceiver::HamlibTransceiver (logger_type * logger,
|
|||||||
|
|
||||||
// rig_->state.obj = this;
|
// rig_->state.obj = this;
|
||||||
|
|
||||||
if (!is_dummy_)
|
//
|
||||||
|
// user defined Hamlib settings
|
||||||
|
//
|
||||||
|
auto settings_file_name = QStandardPaths::locate (QStandardPaths::AppConfigLocation
|
||||||
|
, "hamlib_settings.json");
|
||||||
|
if (!settings_file_name.isEmpty ())
|
||||||
{
|
{
|
||||||
//
|
QFile settings_file {settings_file_name};
|
||||||
// user defined Hamlib settings
|
qDebug () << "Using Hamlib settings file:" << settings_file_name;
|
||||||
//
|
if (settings_file.open (QFile::ReadOnly))
|
||||||
auto settings_file_name = QStandardPaths::locate (QStandardPaths::AppConfigLocation
|
|
||||||
, "hamlib_settings.json");
|
|
||||||
if (!settings_file_name.isEmpty ())
|
|
||||||
{
|
{
|
||||||
QFile settings_file {settings_file_name};
|
QJsonParseError status;
|
||||||
qDebug () << "Using Hamlib settings file:" << settings_file_name;
|
auto settings_doc = QJsonDocument::fromJson (settings_file.readAll (), &status);
|
||||||
if (settings_file.open (QFile::ReadOnly))
|
if (status.error)
|
||||||
{
|
{
|
||||||
QJsonParseError status;
|
throw error {tr ("Hamlib settings file error: %1 at character offset %2")
|
||||||
auto settings_doc = QJsonDocument::fromJson (settings_file.readAll (), &status);
|
.arg (status.errorString ()).arg (status.offset)};
|
||||||
if (status.error)
|
}
|
||||||
{
|
qDebug () << "Hamlib settings JSON:" << settings_doc.toJson ();
|
||||||
throw error {tr ("Hamlib settings file error: %1 at character offset %2")
|
if (!settings_doc.isObject ())
|
||||||
.arg (status.errorString ()).arg (status.offset)};
|
{
|
||||||
}
|
throw error {tr ("Hamlib settings file error: top level must be a JSON object")};
|
||||||
qDebug () << "Hamlib settings JSON:" << settings_doc.toJson ();
|
}
|
||||||
if (!settings_doc.isObject ())
|
auto const& settings = settings_doc.object ();
|
||||||
{
|
|
||||||
throw error {tr ("Hamlib settings file error: top level must be a JSON object")};
|
|
||||||
}
|
|
||||||
auto const& settings = settings_doc.object ();
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// configuration settings
|
// configuration settings
|
||||||
//
|
//
|
||||||
auto const& config = settings["config"];
|
auto const& config = settings["config"];
|
||||||
if (!config.isUndefined ())
|
if (!config.isUndefined ())
|
||||||
|
{
|
||||||
|
if (!config.isObject ())
|
||||||
{
|
{
|
||||||
if (!config.isObject ())
|
throw error {tr ("Hamlib settings file error: config must be a JSON object")};
|
||||||
{
|
}
|
||||||
throw error {tr ("Hamlib settings file error: config must be a JSON object")};
|
auto const& config_list = config.toObject ();
|
||||||
}
|
for (auto item = config_list.constBegin (); item != config_list.constEnd (); ++item)
|
||||||
auto const& config_list = config.toObject ();
|
{
|
||||||
for (auto item = config_list.constBegin (); item != config_list.constEnd (); ++item)
|
set_conf (item.key ().toLocal8Bit ().constData ()
|
||||||
{
|
, (*item).toVariant ().toString ().toLocal8Bit ().constData ());
|
||||||
set_conf (item.key ().toLocal8Bit ().constData ()
|
|
||||||
, (*item).toVariant ().toString ().toLocal8Bit ().constData ());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!is_dummy_)
|
||||||
|
{
|
||||||
switch (rig_->caps->port_type)
|
switch (rig_->caps->port_type)
|
||||||
{
|
{
|
||||||
case RIG_PORT_SERIAL:
|
case RIG_PORT_SERIAL:
|
||||||
|
Loading…
Reference in New Issue
Block a user