mirror of
https://github.com/f4exb/sdrangel.git
synced 2026-06-06 16:05:13 -04:00
Main window: implement the logging options dialog. Use it only for log level
This commit is contained in:
@@ -0,0 +1,106 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2017 F4EXB //
|
||||
// written by Edouard Griffiths //
|
||||
// //
|
||||
// This program is free software; you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU General Public License as published by //
|
||||
// the Free Software Foundation as version 3 of the License, or //
|
||||
// //
|
||||
// This program is distributed in the hope that it will be useful, //
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||
// GNU General Public License V3 for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU General Public License //
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <QFileDialog>
|
||||
|
||||
#include "loggingdialog.h"
|
||||
#include "ui_loggingdialog.h"
|
||||
|
||||
LoggingDialog::LoggingDialog(MainSettings& mainSettings, QWidget* parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::LoggingDialog),
|
||||
m_mainSettings(mainSettings)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->level->setCurrentIndex(msgLevelToIndex(m_mainSettings.getMinLogLevel()));
|
||||
ui->logToFile->setChecked(m_mainSettings.getUseLogFile());
|
||||
ui->logFileNameText->setText(m_mainSettings.getLogFileName());
|
||||
m_fileName = m_mainSettings.getLogFileName();
|
||||
}
|
||||
|
||||
LoggingDialog::~LoggingDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void LoggingDialog::accept()
|
||||
{
|
||||
m_mainSettings.setMinLogLevel(msgLevelFromIndex(ui->level->currentIndex()));
|
||||
m_mainSettings.setUseLogFile(ui->logToFile->isChecked());
|
||||
m_mainSettings.setLogFileName(m_fileName);
|
||||
QDialog::accept();
|
||||
}
|
||||
|
||||
void LoggingDialog::on_showFileDialog_clicked(bool checked __attribute__((unused)))
|
||||
{
|
||||
QString fileName = QFileDialog::getSaveFileName(this,
|
||||
tr("Save log file"), ".", tr("Log Files (*.log)"));
|
||||
|
||||
if (fileName != "")
|
||||
{
|
||||
qDebug("LoggingDialog::on_showFileDialog_clicked: selected: %s", qPrintable(fileName));
|
||||
m_fileName = fileName;
|
||||
ui->logFileNameText->setText(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
QtMsgType LoggingDialog::msgLevelFromIndex(int intMsgLevel)
|
||||
{
|
||||
switch (intMsgLevel)
|
||||
{
|
||||
case 0:
|
||||
return QtDebugMsg;
|
||||
break;
|
||||
case 1:
|
||||
return QtInfoMsg;
|
||||
break;
|
||||
case 2:
|
||||
return QtWarningMsg;
|
||||
break;
|
||||
case 3:
|
||||
return QtCriticalMsg;
|
||||
break;
|
||||
default:
|
||||
return QtDebugMsg;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int LoggingDialog::msgLevelToIndex(const QtMsgType& msgLevel)
|
||||
{
|
||||
switch (msgLevel)
|
||||
{
|
||||
case QtDebugMsg:
|
||||
return 0;
|
||||
break;
|
||||
case QtInfoMsg:
|
||||
return 1;
|
||||
break;
|
||||
case QtWarningMsg:
|
||||
return 2;
|
||||
break;
|
||||
case QtCriticalMsg:
|
||||
case QtFatalMsg:
|
||||
return 3;
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2017 F4EXB //
|
||||
// written by Edouard Griffiths //
|
||||
// //
|
||||
// This program is free software; you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU General Public License as published by //
|
||||
// the Free Software Foundation as version 3 of the License, or //
|
||||
// //
|
||||
// This program is distributed in the hope that it will be useful, //
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||
// GNU General Public License V3 for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU General Public License //
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef SDRGUI_GUI_LOGGINGDIALOG_H_
|
||||
#define SDRGUI_GUI_LOGGINGDIALOG_H_
|
||||
|
||||
#include <QDialog>
|
||||
#include "settings/mainsettings.h"
|
||||
|
||||
namespace Ui {
|
||||
class LoggingDialog;
|
||||
}
|
||||
|
||||
class LoggingDialog : public QDialog {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit LoggingDialog(MainSettings& mainSettings, QWidget* parent = 0);
|
||||
~LoggingDialog();
|
||||
|
||||
private:
|
||||
Ui::LoggingDialog* ui;
|
||||
MainSettings& m_mainSettings;
|
||||
QString m_fileName;
|
||||
|
||||
QtMsgType msgLevelFromIndex(int intMsgLevel);
|
||||
int msgLevelToIndex(const QtMsgType& msgLevel);
|
||||
|
||||
private slots:
|
||||
void accept();
|
||||
void on_showFileDialog_clicked(bool checked);
|
||||
};
|
||||
|
||||
#endif /* SDRGUI_GUI_LOGGINGDIALOG_H_ */
|
||||
@@ -0,0 +1,179 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>LoggingDialog</class>
|
||||
<widget class="QDialog" name="LoggingDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>461</width>
|
||||
<height>110</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Sans Serif</family>
|
||||
<pointsize>9</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Logging settings</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="levelLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="levelLabel">
|
||||
<property name="text">
|
||||
<string>Log level</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="level">
|
||||
<property name="toolTip">
|
||||
<string>Choose minimum message severity level for logging</string>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Debug</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Info</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Warning</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Error</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="logFileLayout">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="logToFile">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>85</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Select to activate file logging</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Log to file</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="showFileDialog">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>24</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Choose a log file</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../resources/res.qrc">
|
||||
<normaloff>:/preset-load.png</normaloff>:/preset-load.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="logFileNameText">
|
||||
<property name="toolTip">
|
||||
<string>Log file</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
<property name="centerButtons">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>buttonBox</tabstop>
|
||||
</tabstops>
|
||||
<resources>
|
||||
<include location="../resources/res.qrc"/>
|
||||
</resources>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>LoggingDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>257</x>
|
||||
<y>194</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>203</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>LoggingDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>314</x>
|
||||
<y>194</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>203</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
Reference in New Issue
Block a user