mirror of
https://github.com/f4exb/sdrangel.git
synced 2026-06-08 00:44:48 -04:00
Main window: implement the logging options dialog. Use it only for log level
This commit is contained in:
@@ -25,6 +25,7 @@ set(sdrgui_SOURCES
|
||||
gui/glspectrumgui.cpp
|
||||
gui/indicator.cpp
|
||||
gui/levelmeter.cpp
|
||||
gui/loggingdialog.cpp
|
||||
gui/mypositiondialog.cpp
|
||||
gui/pluginsdialog.cpp
|
||||
gui/audiodialog.cpp
|
||||
@@ -72,7 +73,8 @@ set(sdrgui_HEADERS
|
||||
gui/glspectrum.h
|
||||
gui/glspectrumgui.h
|
||||
gui/indicator.h
|
||||
gui/levelmeter.h
|
||||
gui/levelmeter.h
|
||||
gui/loggingdialog.h
|
||||
gui/mypositiondialog.h
|
||||
gui/physicalunit.h
|
||||
gui/pluginsdialog.h
|
||||
@@ -121,6 +123,7 @@ set(sdrgui_FORMS
|
||||
gui/samplingdevicedialog.ui
|
||||
gui/myposdialog.ui
|
||||
gui/transverterdialog.ui
|
||||
gui/loggingdialog.ui
|
||||
)
|
||||
|
||||
set(sdrgui_RESOURCES
|
||||
|
||||
@@ -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>
|
||||
@@ -40,6 +40,7 @@
|
||||
#include "gui/rollupwidget.h"
|
||||
#include "gui/channelwindow.h"
|
||||
#include "gui/audiodialog.h"
|
||||
#include "gui/loggingdialog.h"
|
||||
#include "gui/samplingdevicecontrol.h"
|
||||
#include "gui/mypositiondialog.h"
|
||||
#include "dsp/dspengine.h"
|
||||
@@ -493,6 +494,8 @@ void MainWindow::loadSettings()
|
||||
{
|
||||
ui->presetTree->setCurrentItem(addPresetToTree(m_settings.getPreset(i)));
|
||||
}
|
||||
|
||||
setLoggingOpions();
|
||||
}
|
||||
|
||||
void MainWindow::loadPresetSettings(const Preset* preset, int tabIndex)
|
||||
@@ -847,6 +850,13 @@ void MainWindow::on_action_Audio_triggered()
|
||||
m_dspEngine->setAudioOutputDeviceIndex(m_audioDeviceInfo.getOutputDeviceIndex());
|
||||
}
|
||||
|
||||
void MainWindow::on_action_Logging_triggered()
|
||||
{
|
||||
LoggingDialog loggingDialog(m_settings, this);
|
||||
loggingDialog.exec();
|
||||
setLoggingOpions();
|
||||
}
|
||||
|
||||
void MainWindow::on_action_My_Position_triggered()
|
||||
{
|
||||
MyPositionDialog myPositionDialog(m_settings, this);
|
||||
@@ -1144,3 +1154,8 @@ void MainWindow::updateStatus()
|
||||
{
|
||||
m_dateTimeWidget->setText(QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss t"));
|
||||
}
|
||||
|
||||
void MainWindow::setLoggingOpions()
|
||||
{
|
||||
m_logger->setMinMessageLevel(m_settings.getMinLogLevel());
|
||||
}
|
||||
|
||||
@@ -130,6 +130,8 @@ private:
|
||||
void addSinkDevice();
|
||||
void removeLastDevice();
|
||||
|
||||
void setLoggingOpions();
|
||||
|
||||
private slots:
|
||||
void handleMessages();
|
||||
void updateStatus();
|
||||
@@ -144,6 +146,7 @@ private slots:
|
||||
void on_presetTree_currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous);
|
||||
void on_presetTree_itemActivated(QTreeWidgetItem *item, int column);
|
||||
void on_action_Audio_triggered();
|
||||
void on_action_Logging_triggered();
|
||||
void on_action_DV_Serial_triggered(bool checked);
|
||||
void on_action_My_Position_triggered();
|
||||
void on_sampleSource_changed();
|
||||
|
||||
@@ -146,6 +146,7 @@
|
||||
<string>&Preferences</string>
|
||||
</property>
|
||||
<addaction name="action_Audio"/>
|
||||
<addaction name="action_Logging"/>
|
||||
<addaction name="action_DV_Serial"/>
|
||||
<addaction name="action_My_Position"/>
|
||||
</widget>
|
||||
@@ -660,6 +661,9 @@
|
||||
<property name="text">
|
||||
<string>&Audio</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Audio devices setting</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="action_DV_Serial">
|
||||
<property name="checkable">
|
||||
@@ -668,17 +672,31 @@
|
||||
<property name="text">
|
||||
<string>DV Serial</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Toggle AMBE DV serial device usage</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="action_My_Position">
|
||||
<property name="text">
|
||||
<string>My Position</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Set my geo position</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="action_addSinkDevice">
|
||||
<property name="text">
|
||||
<string>Add sink device</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="action_Logging">
|
||||
<property name="text">
|
||||
<string>Logging</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Message logging options</string>
|
||||
</property>
|
||||
</action>
|
||||
<zorder>presetDock</zorder>
|
||||
<zorder>channelDock</zorder>
|
||||
</widget>
|
||||
|
||||
Reference in New Issue
Block a user