Browse Source

implemented theming setting signal/slot

fiffty-50 4 years ago
parent
commit
4afd328c85
4 changed files with 29 additions and 6 deletions
  1. 1 1
      mainwindow.cpp
  2. 25 4
      settingswidget.cpp
  3. 2 0
      settingswidget.h
  4. 1 1
      settingswidget.ui

+ 1 - 1
mainwindow.cpp

@@ -117,7 +117,7 @@ void MainWindow::on_actionLogbook_triggered()
 
 void MainWindow::on_actionSettings_triggered()
 {
-    nope();
+    //nope();
     auto sw = new settingsWidget(this);
     ui->stackedWidget->addWidget(sw);
     ui->stackedWidget->setCurrentWidget(sw);

+ 25 - 4
settingswidget.cpp

@@ -4,6 +4,7 @@
 #include <QButtonGroup>
 #include <QRegExp>
 #include <QValidator>
+#include <QMessageBox>
 #include <QDebug>
 
 
@@ -18,9 +19,20 @@ settingsWidget::settingsWidget(QWidget *parent) :
      * General Tab
      */
     auto *themeGroup = new QButtonGroup;
-    themeGroup->addButton(ui->systemThemeCheckBox);
-    themeGroup->addButton(ui->lightThemeCheckBox);
-    themeGroup->addButton(ui->darkThemeCheckBox);
+    themeGroup->addButton(ui->systemThemeCheckBox, 0);
+    themeGroup->addButton(ui->lightThemeCheckBox, 1);
+    themeGroup->addButton(ui->darkThemeCheckBox, 2);
+
+    /*connect(themeGroup,
+            SIGNAL(idToggled(int)),
+            this,
+            SLOT(themeGroup_toggled(int)));*/
+
+    /*connect(themeGroup,
+    SIGNAL(idToggled(int)),
+    SLOT(themeGroup_toggled(int)));*/
+
+    connect(themeGroup, SIGNAL(buttonClicked(int)), this, SLOT(themeGroup_toggled(int)));
 
     switch (dbSettings::retreiveSetting(10).toInt()) {
       case 0:
@@ -55,10 +67,19 @@ settingsWidget::~settingsWidget()
 }
 
 /*
- * General Tab
+ * Slots
  */
 
 void settingsWidget::on_flightNumberPrefixLineEdit_textEdited(const QString &arg1)
 {
     dbSettings::storeSetting(50, arg1);
 }
+
+void settingsWidget::themeGroup_toggled(int id)
+{
+    dbSettings::storeSetting(10,QString::number(id));
+
+    QMessageBox *info = new QMessageBox(this);
+    info->setText("Theme change will take effect next time you start the application.");
+    info->exec();
+}

+ 2 - 0
settingswidget.h

@@ -19,6 +19,8 @@ public:
 private slots:
     void on_flightNumberPrefixLineEdit_textEdited(const QString &arg1);
 
+    void themeGroup_toggled(int id);
+
 private:
     Ui::settingsWidget *ui;
 };

+ 1 - 1
settingswidget.ui

@@ -17,7 +17,7 @@
    <item row="0" column="0">
     <widget class="QTabWidget" name="tabWidget">
      <property name="currentIndex">
-      <number>1</number>
+      <number>0</number>
      </property>
      <widget class="QWidget" name="generalTab">
       <attribute name="title">