SDRAngel  4.11.5
Developer docs for <a href="https://github.com/f4exb/sdrangel">SDRangel<\a>, an Open Source Qt5 / OpenGL 3.0+ SDR and signal analyzer frontend to various hardware.
loggingdialog.cpp
Go to the documentation of this file.
1 // Copyright (C) 2017 F4EXB //
3 // written by Edouard Griffiths //
4 // //
5 // This program is free software; you can redistribute it and/or modify //
6 // it under the terms of the GNU General Public License as published by //
7 // the Free Software Foundation as version 3 of the License, or //
8 // (at your option) any later version. //
9 // //
10 // This program is distributed in the hope that it will be useful, //
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of //
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
13 // GNU General Public License V3 for more details. //
14 // //
15 // You should have received a copy of the GNU General Public License //
16 // along with this program. If not, see <http://www.gnu.org/licenses/>. //
18 
19 #include <QFileDialog>
20 
21 #include "loggingdialog.h"
22 #include "ui_loggingdialog.h"
23 
24 LoggingDialog::LoggingDialog(MainSettings& mainSettings, QWidget* parent) :
25  QDialog(parent),
26  ui(new Ui::LoggingDialog),
27  m_mainSettings(mainSettings)
28 {
29  ui->setupUi(this);
30  ui->consoleLevel->setCurrentIndex(msgLevelToIndex(m_mainSettings.getConsoleMinLogLevel()));
31  ui->fileLevel->setCurrentIndex(msgLevelToIndex(m_mainSettings.getFileMinLogLevel()));
32  ui->logToFile->setChecked(m_mainSettings.getUseLogFile());
33  ui->logFileNameText->setText(m_mainSettings.getLogFileName());
35 }
36 
38 {
39  delete ui;
40 }
41 
43 {
44  m_mainSettings.setConsoleMinLogLevel(msgLevelFromIndex(ui->consoleLevel->currentIndex()));
45  m_mainSettings.setFileMinLogLevel(msgLevelFromIndex(ui->fileLevel->currentIndex()));
46  m_mainSettings.setUseLogFile(ui->logToFile->isChecked());
48  QDialog::accept();
49 }
50 
52 {
53  (void) checked;
54  QString fileName = QFileDialog::getSaveFileName(this,
55  tr("Save log file"), ".", tr("Log Files (*.log)"), 0, QFileDialog::DontUseNativeDialog);
56 
57  if (fileName != "")
58  {
59  qDebug("LoggingDialog::on_showFileDialog_clicked: selected: %s", qPrintable(fileName));
60  m_fileName = fileName;
61  ui->logFileNameText->setText(fileName);
62  }
63 }
64 
65 QtMsgType LoggingDialog::msgLevelFromIndex(int intMsgLevel)
66 {
67  switch (intMsgLevel)
68  {
69  case 0:
70  return QtDebugMsg;
71  break;
72  case 1:
73  return QtInfoMsg;
74  break;
75  case 2:
76  return QtWarningMsg;
77  break;
78  case 3:
79  return QtCriticalMsg;
80  break;
81  default:
82  return QtDebugMsg;
83  break;
84  }
85 }
86 
87 int LoggingDialog::msgLevelToIndex(const QtMsgType& msgLevel)
88 {
89  switch (msgLevel)
90  {
91  case QtDebugMsg:
92  return 0;
93  break;
94  case QtInfoMsg:
95  return 1;
96  break;
97  case QtWarningMsg:
98  return 2;
99  break;
100  case QtCriticalMsg:
101  case QtFatalMsg:
102  return 3;
103  break;
104  default:
105  return 0;
106  break;
107  }
108 }
109 
110 
const QString & getLogFileName() const
Definition: mainsettings.h:65
LoggingDialog(MainSettings &mainSettings, QWidget *parent=0)
bool getUseLogFile() const
Definition: mainsettings.h:64
void setConsoleMinLogLevel(const QtMsgType &minLogLevel)
Definition: mainsettings.h:58
QtMsgType getFileMinLogLevel() const
Definition: mainsettings.h:63
void setFileMinLogLevel(const QtMsgType &minLogLevel)
Definition: mainsettings.h:59
int msgLevelToIndex(const QtMsgType &msgLevel)
QString m_fileName
Definition: loggingdialog.h:39
void on_showFileDialog_clicked(bool checked)
MainSettings & m_mainSettings
Definition: loggingdialog.h:38
void setUseLogFile(bool useLogFile)
Definition: mainsettings.h:60
QtMsgType msgLevelFromIndex(int intMsgLevel)
Ui::LoggingDialog * ui
Definition: loggingdialog.h:37
QtMsgType getConsoleMinLogLevel() const
Definition: mainsettings.h:62
void setLogFileName(const QString &value)
Definition: mainsettings.h:61