66#include " EditTableDialog.h"
77#include " ImportCsvDialog.h"
88#include " ExportDataDialog.h"
9+ #include " Settings.h"
910#include " PreferencesDialog.h"
1011#include " EditDialog.h"
1112#include " sqlitetablemodel.h"
5152MainWindow::MainWindow (QWidget* parent)
5253 : QMainWindow(parent),
5354 ui(new Ui::MainWindow),
54- m_browseTableModel(new SqliteTableModel(this , &db, PreferencesDialog ::getSettingsValue(" db" , " prefetchsize" ).toInt())),
55+ m_browseTableModel(new SqliteTableModel(this , &db, Settings ::getSettingsValue(" db" , " prefetchsize" ).toInt())),
5556 m_currentTabTableModel(m_browseTableModel),
5657 editDock(new EditDialog(this )),
5758 gotoValidator(new QIntValidator(0 , 0 , this ))
@@ -105,14 +106,14 @@ void MainWindow::init()
105106 ui->dockEdit ->setWidget (editDock);
106107
107108 // Restore window geometry
108- restoreGeometry (PreferencesDialog ::getSettingsValue (" MainWindow" , " geometry" ).toByteArray ());
109- restoreState (PreferencesDialog ::getSettingsValue (" MainWindow" , " windowState" ).toByteArray ());
109+ restoreGeometry (Settings ::getSettingsValue (" MainWindow" , " geometry" ).toByteArray ());
110+ restoreState (Settings ::getSettingsValue (" MainWindow" , " windowState" ).toByteArray ());
110111
111112 // Restore various dock state settings
112- ui->comboLogSubmittedBy ->setCurrentIndex (ui->comboLogSubmittedBy ->findText (PreferencesDialog ::getSettingsValue (" SQLLogDock" , " Log" ).toString ()));
113- ui->splitterForPlot ->restoreState (PreferencesDialog ::getSettingsValue (" PlotDock" , " splitterSize" ).toByteArray ());
114- ui->comboLineType ->setCurrentIndex (PreferencesDialog ::getSettingsValue (" PlotDock" , " lineType" ).toInt ());
115- ui->comboPointShape ->setCurrentIndex (PreferencesDialog ::getSettingsValue (" PlotDock" , " pointShape" ).toInt ());
113+ ui->comboLogSubmittedBy ->setCurrentIndex (ui->comboLogSubmittedBy ->findText (Settings ::getSettingsValue (" SQLLogDock" , " Log" ).toString ()));
114+ ui->splitterForPlot ->restoreState (Settings ::getSettingsValue (" PlotDock" , " splitterSize" ).toByteArray ());
115+ ui->comboLineType ->setCurrentIndex (Settings ::getSettingsValue (" PlotDock" , " lineType" ).toInt ());
116+ ui->comboPointShape ->setCurrentIndex (Settings ::getSettingsValue (" PlotDock" , " pointShape" ).toInt ());
116117
117118 // Add keyboard shortcuts
118119 QList<QKeySequence> shortcuts = ui->actionExecuteSql ->shortcuts ();
@@ -231,7 +232,7 @@ void MainWindow::init()
231232
232233#ifdef CHECKNEWVERSION
233234 // Check for a new version if automatic update check aren't disabled in the settings dialog
234- if (PreferencesDialog ::getSettingsValue (" checkversion" , " enabled" ).toBool ())
235+ if (Settings ::getSettingsValue (" checkversion" , " enabled" ).toBool ())
235236 {
236237 // Check for a new release version, usually only enabled on windows
237238 m_NetworkManager = new QNetworkAccessManager (this );
@@ -544,12 +545,12 @@ void MainWindow::closeEvent( QCloseEvent* event )
544545{
545546 if (db.close ())
546547 {
547- PreferencesDialog ::setSettingsValue (" MainWindow" , " geometry" , saveGeometry ());
548- PreferencesDialog ::setSettingsValue (" MainWindow" , " windowState" , saveState ());
549- PreferencesDialog ::setSettingsValue (" SQLLogDock" , " Log" , ui->comboLogSubmittedBy ->currentText ());
550- PreferencesDialog ::setSettingsValue (" PlotDock" , " splitterSize" , ui->splitterForPlot ->saveState ());
551- PreferencesDialog ::setSettingsValue (" PlotDock" , " lineType" , ui->comboLineType ->currentIndex ());
552- PreferencesDialog ::setSettingsValue (" PlotDock" , " pointShape" , ui->comboPointShape ->currentIndex ());
548+ Settings ::setSettingsValue (" MainWindow" , " geometry" , saveGeometry ());
549+ Settings ::setSettingsValue (" MainWindow" , " windowState" , saveState ());
550+ Settings ::setSettingsValue (" SQLLogDock" , " Log" , ui->comboLogSubmittedBy ->currentText ());
551+ Settings ::setSettingsValue (" PlotDock" , " splitterSize" , ui->splitterForPlot ->saveState ());
552+ Settings ::setSettingsValue (" PlotDock" , " lineType" , ui->comboLineType ->currentIndex ());
553+ Settings ::setSettingsValue (" PlotDock" , " pointShape" , ui->comboPointShape ->currentIndex ());
553554 QMainWindow::closeEvent (event);
554555 } else {
555556 event->ignore ();
@@ -1258,7 +1259,7 @@ void MainWindow::openRecentFile()
12581259void MainWindow::updateRecentFileActions ()
12591260{
12601261 // Get recent files list from settings
1261- QStringList files = PreferencesDialog ::getSettingsValue (" General" , " recentFileList" ).toStringList ();
1262+ QStringList files = Settings ::getSettingsValue (" General" , " recentFileList" ).toStringList ();
12621263
12631264 // Check if files still exist and remove any non-existant file
12641265 for (int i=0 ;i<files.size ();i++)
@@ -1272,7 +1273,7 @@ void MainWindow::updateRecentFileActions()
12721273 }
12731274
12741275 // Store updated list
1275- PreferencesDialog ::setSettingsValue (" General" , " recentFileList" , files);
1276+ Settings ::setSettingsValue (" General" , " recentFileList" , files);
12761277
12771278 int numRecentFiles = qMin (files.size (), (int )MaxRecentFiles);
12781279
@@ -1302,13 +1303,13 @@ void MainWindow::setCurrentFile(const QString &fileName)
13021303
13031304void MainWindow::addToRecentFilesMenu (const QString& filename)
13041305{
1305- QStringList files = PreferencesDialog ::getSettingsValue (" General" , " recentFileList" ).toStringList ();
1306+ QStringList files = Settings ::getSettingsValue (" General" , " recentFileList" ).toStringList ();
13061307 files.removeAll (filename);
13071308 files.prepend (filename);
13081309 while (files.size () > MaxRecentFiles)
13091310 files.removeLast ();
13101311
1311- PreferencesDialog ::setSettingsValue (" General" , " recentFileList" , files);
1312+ Settings ::setSettingsValue (" General" , " recentFileList" , files);
13121313
13131314 foreach (QWidget *widget, QApplication::topLevelWidgets ()) {
13141315 MainWindow *mainWin = qobject_cast<MainWindow *>(widget);
@@ -1591,7 +1592,7 @@ void MainWindow::loadExtensionsFromSettings()
15911592 if (!db.isOpen ())
15921593 return ;
15931594
1594- QStringList list = PreferencesDialog ::getSettingsValue (" extensions" , " list" ).toStringList ();
1595+ QStringList list = Settings ::getSettingsValue (" extensions" , " list" ).toStringList ();
15951596 foreach (QString ext, list)
15961597 {
15971598 if (db.loadExtension (ext) == false )
@@ -1602,16 +1603,16 @@ void MainWindow::loadExtensionsFromSettings()
16021603void MainWindow::reloadSettings ()
16031604{
16041605 // Read settings
1605- int prefetch_size = PreferencesDialog ::getSettingsValue (" db" , " prefetchsize" ).toInt ();
1606- int log_fontsize = PreferencesDialog ::getSettingsValue (" log" , " fontsize" ).toInt ();
1606+ int prefetch_size = Settings ::getSettingsValue (" db" , " prefetchsize" ).toInt ();
1607+ int log_fontsize = Settings ::getSettingsValue (" log" , " fontsize" ).toInt ();
16071608
16081609 QFont logfont (" Monospace" );
16091610 logfont.setStyleHint (QFont::TypeWriter);
16101611 logfont.setPointSize (log_fontsize);
16111612
16121613 // Set data browser font
1613- QFont dataBrowserFont (PreferencesDialog ::getSettingsValue (" databrowser" , " font" ).toString ());
1614- dataBrowserFont.setPointSize (PreferencesDialog ::getSettingsValue (" databrowser" , " fontsize" ).toInt ());
1614+ QFont dataBrowserFont (Settings ::getSettingsValue (" databrowser" , " font" ).toString ());
1615+ dataBrowserFont.setPointSize (Settings ::getSettingsValue (" databrowser" , " fontsize" ).toInt ());
16151616 ui->dataTable ->setFont (dataBrowserFont);
16161617
16171618 // Set prefetch sizes for lazy population of table models
0 commit comments