1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-12-23 01:55:48 -05:00

Server: load presets on start and save them on exit

This commit is contained in:
f4exb 2017-12-18 13:56:10 +01:00
parent debdae9529
commit e428f55c82
5 changed files with 44 additions and 6 deletions

View File

@ -526,7 +526,7 @@ void MainWindow::loadSettings()
}
}
setLoggingOpions();
setLoggingOptions();
}
void MainWindow::loadPresetSettings(const Preset* preset, int tabIndex)
@ -987,7 +987,7 @@ void MainWindow::on_action_Logging_triggered()
{
LoggingDialog loggingDialog(m_settings, this);
loggingDialog.exec();
setLoggingOpions();
setLoggingOptions();
}
void MainWindow::on_action_My_Position_triggered()
@ -1290,7 +1290,7 @@ void MainWindow::updateStatus()
m_dateTimeWidget->setText(QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss t"));
}
void MainWindow::setLoggingOpions()
void MainWindow::setLoggingOptions()
{
m_logger->setConsoleMinMessageLevel(m_settings.getConsoleMinLogLevel());

View File

@ -297,7 +297,7 @@ private:
void addSinkDevice();
void removeLastDevice();
void setLoggingOpions();
void setLoggingOptions();
bool handleMessage(const Message& cmd);

View File

@ -184,7 +184,7 @@ int WebAPIAdapterGUI::instanceLoggingPut(
m_mainWindow.m_settings.setLogFileName(*fileName);
}
m_mainWindow.setLoggingOpions();
m_mainWindow.setLoggingOptions();
// build response
response.init();

View File

@ -52,6 +52,8 @@ MainCore::MainCore(qtwebapp::LoggerWithFile *logger, const MainParser& parser, Q
connect(&m_inputMessageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleMessages()), Qt::QueuedConnection);
m_masterTimer.start(50);
loadSettings();
m_apiAdapter = new WebAPIAdapterSrv(*this);
m_requestMapper = new WebAPIRequestMapper(this);
m_requestMapper->setAdapter(m_apiAdapter);
@ -63,7 +65,8 @@ MainCore::MainCore(qtwebapp::LoggerWithFile *logger, const MainParser& parser, Q
MainCore::~MainCore()
{
m_apiServer->stop();
m_apiServer->stop();
m_settings.save();
delete m_apiServer;
delete m_requestMapper;
delete m_apiAdapter;
@ -99,3 +102,35 @@ void MainCore::handleMessages()
}
}
void MainCore::loadSettings()
{
qDebug() << "MainCore::loadSettings";
m_settings.load();
m_settings.sortPresets();
setLoggingOptions();
}
void MainCore::setLoggingOptions()
{
m_logger->setConsoleMinMessageLevel(m_settings.getConsoleMinLogLevel());
if (m_settings.getUseLogFile())
{
qtwebapp::FileLoggerSettings fileLoggerSettings; // default values
if (m_logger->hasFileLogger()) {
fileLoggerSettings = m_logger->getFileLoggerSettings(); // values from file logger if it exists
}
fileLoggerSettings.fileName = m_settings.getLogFileName(); // put new values
m_logger->createOrSetFileLogger(fileLoggerSettings, 2000); // create file logger if it does not exist and apply settings in any case
}
if (m_logger->hasFileLogger()) {
m_logger->setFileMinMessageLevel(m_settings.getFileMinLogLevel());
}
m_logger->setUseFileLogger(m_settings.getUseLogFile());
}

View File

@ -98,6 +98,9 @@ private:
WebAPIServer *m_apiServer;
WebAPIAdapterSrv *m_apiAdapter;
void loadSettings();
void setLoggingOptions();
bool handleMessage(const Message& cmd);
private slots: