[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kanagram] src: Clean up mainsettings code a bit
From:       Jeremy Whiting <jpwhiting () kde ! org>
Date:       2014-08-31 20:13:07
Message-ID: E1XOBUp-00040I-Uf () scm ! kde ! org
[Download RAW message or body]

Git commit 8d79098664f036b65af22052396a6baa12ed57a8 by Jeremy Whiting.
Committed on 31/08/2014 at 20:12.
Pushed by whiting into branch 'master'.

Clean up mainsettings code a bit

M  +14   -11   src/mainsettings.cpp
M  +24   -23   src/mainsettings.h
M  +229  -228  src/mainsettingswidget.ui

http://commits.kde.org/kanagram/8d79098664f036b65af22052396a6baa12ed57a8

diff --git a/src/mainsettings.cpp b/src/mainsettings.cpp
index c6a9b53..e9bcc72 100755
--- a/src/mainsettings.cpp
+++ b/src/mainsettings.cpp
@@ -1,6 +1,6 @@
 /***************************************************************************
  *   Copyright (C) 2005 by Joshua Keel <joshuakeel@gmail.com>              *
- *             (C) 2007 by Jeremy Whiting <jpwhiting@kde.org>              *
+ *             (C) 2007-2014 by Jeremy Whiting <jpwhiting@kde.org>         *
  *                                                                         *
  *   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  *
@@ -36,17 +36,19 @@ MainSettings::MainSettings(QWidget *parent) : QWidget(parent)
 {
     setupUi( this );
     m_parent = (KConfigDialog*)parent;
+
     slotToggleAdvancedSettings();
     connect(parent, SIGNAL(applyClicked()), this, SLOT(slotUpdateLanguage()));
     connect(parent, SIGNAL(okClicked()), this, SLOT(slotUpdateLanguage()));
     connect(languageComboBox, SIGNAL(activated(int)), this, SLOT(slotSetDirty()));
-    connect(scoringOptions,SIGNAL(toggled(bool)),this,SLOT(slotToggleAdvancedSettings()));
 +    connect(scoringPointCheckbox,SIGNAL(toggled(bool)),this,SLOT(slotToggleAdvancedSettings()));
  populateLanguageBox();
 
     //the language code/name
     KConfig entry(QStandardPaths::locate(QStandardPaths::GenericDataLocation, \
QLatin1String("locale/") + "all_languages"));  QString code = \
KanagramSettings::dataLanguage();  KConfigGroup group = entry.group(code);
+
     // select the current language
     languageComboBox->setCurrentIndex(languageComboBox->findText(group.readEntry("Name")));
  }
@@ -62,14 +64,15 @@ void MainSettings::slotSetDirty()
 
 void MainSettings::slotToggleAdvancedSettings()
 {
-    textCorrectAnswer->setVisible(scoringOptions->isChecked());
-    kcfg_correctAnswerScore->setVisible(scoringOptions->isChecked());
-    textIncorrectAnswer->setVisible(scoringOptions->isChecked());
-    kcfg_incorrectAnswerScore->setVisible(scoringOptions->isChecked());
-    textRevealAnswer->setVisible(scoringOptions->isChecked());
-    kcfg_revealAnswerScore->setVisible(scoringOptions->isChecked());
-    textSkippedWord->setVisible(scoringOptions->isChecked());
-    kcfg_skippedWordScore->setVisible(scoringOptions->isChecked());
+    bool enable = scoringPointCheckbox->isChecked();
+    textCorrectAnswer->setVisible(enable);
+    kcfg_correctAnswerScore->setVisible(enable);
+    textIncorrectAnswer->setVisible(enable);
+    kcfg_incorrectAnswerScore->setVisible(enable);
+    textRevealAnswer->setVisible(enable);
+    kcfg_revealAnswerScore->setVisible(enable);
+    textSkippedWord->setVisible(enable);
+    kcfg_skippedWordScore->setVisible(enable);
 }
 
 void MainSettings::populateLanguageBox()
@@ -98,7 +101,7 @@ void MainSettings::slotUpdateLanguage()
     QString language = languageComboBox->itemData(index).toString();
     qDebug() << "Writing new default language: " << language;
     KanagramSettings::setDataLanguage(language);
-    KanagramSettings::self()->writeConfig();
+    KanagramSettings::self()->save();
 
     emit settingsChanged();
 }
diff --git a/src/mainsettings.h b/src/mainsettings.h
index e44cb71..3fd4645 100755
--- a/src/mainsettings.h
+++ b/src/mainsettings.h
@@ -1,5 +1,6 @@
 /***************************************************************************
  *   Copyright (C) 2005 by Joshua Keel <joshuakeel@gmail.com>              *
+ *   Copyright (C) 2014 by Jeremy Whiting <jpwhiting@kde.org>              *
  *                                                                         *
  *   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  *
@@ -31,39 +32,39 @@ class KConfigDialog;
 class MainSettings : public QWidget, Ui::MainSettingsWidget
 {
 Q_OBJECT
-	public:
-		/** default constructor */
-		explicit MainSettings(QWidget *parent);
+public:
+    /** default constructor */
+    explicit MainSettings(QWidget *parent);
 
-		/** default destructor */
-		~MainSettings();
+    /** default destructor */
+    ~MainSettings();
 
-	public slots:
+public slots:
 
-		/** save the language setting that has been chosen */
-		void slotUpdateLanguage();
+    /** save the language setting that has been chosen */
+    void slotUpdateLanguage();
 
-		/** enable the apply button on the config dialog because something has been \
                changed */
-		void slotSetDirty();
+    /** enable the apply button on the config dialog because something has been \
changed */ +    void slotSetDirty();
 
-                /** toggle advanced settings */
-                void slotToggleAdvancedSettings();
+    /** toggle advanced settings */
+    void slotToggleAdvancedSettings();
 
-    signals:
+signals:
 
-        /** signifies slotUpdateLanguage has completed, so language setting has been \
                saved */
-        void settingsChanged();
+    /** signifies slotUpdateLanguage has completed, so language setting has been \
saved */ +    void settingsChanged();
 
-	private:
+private:
 
-		/** get languages from data folders
-		  * populate the language combobox with the names
-		  * also puts the folder name in the userData of the combobox for quick retrieval
-		  */
-		void populateLanguageBox();
+    /** get languages from data folders
+      * populate the language combobox with the names
+      * also puts the folder name in the userData of the combobox for quick \
retrieval +      */
+    void populateLanguageBox();
 
-		/** cache pointer to config dialog so we can enable the apply button in \
                slotSetDirty */
-		KConfigDialog *m_parent;
+    /** cache pointer to config dialog so we can enable the apply button in \
slotSetDirty */ +    KConfigDialog *m_parent;
 };
 
 #endif
diff --git a/src/mainsettingswidget.ui b/src/mainsettingswidget.ui
index 1946358..4e4a260 100755
--- a/src/mainsettingswidget.ui
+++ b/src/mainsettingswidget.ui
@@ -1,94 +1,95 @@
-<ui version="4.0" >
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
  <class>MainSettingsWidget</class>
- <widget class="QWidget" name="MainSettingsWidget" >
-  <property name="geometry" >
+ <widget class="QWidget" name="MainSettingsWidget">
+  <property name="geometry">
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>209</width>
-    <height>227</height>
+    <width>263</width>
+    <height>603</height>
    </rect>
   </property>
-  <property name="windowTitle" >
-   <string comment="@title:group main settings page name" >General</string>
+  <property name="windowTitle">
+   <string comment="@title:group main settings page name">General</string>
   </property>
-  <property name="whatsThis" >
+  <property name="whatsThis">
    <string>This setting allows you to set the length of time Kanagram's hint bubble \
is shown.</string>  </property>
-  <layout class="QVBoxLayout" >
+  <layout class="QVBoxLayout">
    <item>
-    <widget class="QGroupBox" name="groupBox1" >
-     <property name="title" >
+    <widget class="QGroupBox" name="groupBox1">
+     <property name="title">
       <string>Hints</string>
      </property>
-     <layout class="QVBoxLayout" >
+     <layout class="QVBoxLayout">
       <item>
-       <widget class="QLabel" name="textLabel1_2" >
-        <property name="text" >
+       <widget class="QLabel" name="textLabel1_2">
+        <property name="text">
          <string>Auto-hide hints after:</string>
         </property>
        </widget>
       </item>
       <item>
-       <widget class="QComboBox" name="kcfg_hintHideTime" >
+       <widget class="QComboBox" name="kcfg_hintHideTime">
         <item>
-         <property name="text" >
+         <property name="text">
           <string>Do Not Auto-Hide Hints</string>
          </property>
         </item>
         <item>
-         <property name="text" >
+         <property name="text">
           <string>3 Seconds</string>
          </property>
         </item>
         <item>
-         <property name="text" >
+         <property name="text">
           <string>5 Seconds</string>
          </property>
         </item>
         <item>
-         <property name="text" >
+         <property name="text">
           <string>7 Seconds</string>
          </property>
         </item>
         <item>
-         <property name="text" >
+         <property name="text">
           <string>9 Seconds</string>
          </property>
         </item>
        </widget>
       </item>
       <item>
-       <widget class="QLabel" name="textLabelResolveTime" >
-        <property name="text" >
+       <widget class="QLabel" name="textLabelResolveTime">
+        <property name="text">
          <string>Time for resolving the anagram:</string>
         </property>
        </widget>
       </item>
       <item>
-       <widget class="QComboBox" name="kcfg_resolveTime" >
+       <widget class="QComboBox" name="kcfg_resolveTime">
         <item>
-         <property name="text" >
+         <property name="text">
           <string>No time limit</string>
          </property>
         </item>
         <item>
-         <property name="text" >
+         <property name="text">
           <string>15 Seconds</string>
          </property>
         </item>
         <item>
-         <property name="text" >
+         <property name="text">
           <string>30 Seconds</string>
          </property>
         </item>
         <item>
-         <property name="text" >
+         <property name="text">
           <string>45 Seconds</string>
          </property>
         </item>
         <item>
-         <property name="text" >
+         <property name="text">
           <string>60 Seconds</string>
          </property>
         </item>
@@ -98,256 +99,256 @@
     </widget>
    </item>
    <item>
-    <widget class="QGroupBox" name="groupBox3" >
-     <property name="title" >
+    <widget class="QGroupBox" name="groupBox3">
+     <property name="title">
       <string>Vocabulary Options</string>
      </property>
-     <layout class="QVBoxLayout" >
+     <layout class="QVBoxLayout">
       <item>
-       <layout class="QHBoxLayout" >
+       <layout class="QHBoxLayout">
         <item>
-         <widget class="QLabel" name="textLabel1" >
-          <property name="text" >
+         <widget class="QLabel" name="textLabel1">
+          <property name="text">
            <string>Play using:</string>
           </property>
-          <property name="buddy" >
+          <property name="buddy">
            <cstring>languageComboBox</cstring>
           </property>
          </widget>
         </item>
         <item>
-         <widget class="QComboBox" name="languageComboBox" />
+         <widget class="QComboBox" name="languageComboBox"/>
         </item>
        </layout>
       </item>
      </layout>
     </widget>
-   </item>  
+   </item>
    <item>
-    <widget class="QGroupBox" name="groupBox4" >
-     <property name="title" >
+    <widget class="QGroupBox" name="groupBox4">
+     <property name="title">
       <string>Scoring Options</string>
      </property>
-     <layout class="QVBoxLayout" >  
+     <layout class="QVBoxLayout">
       <item>
-       <widget class="QLabel" name="textLabelScoreTime" >
-        <property name="text" >
+       <widget class="QLabel" name="textLabelScoreTime">
+        <property name="text">
          <string>Set timer for scoring purpose:</string>
         </property>
        </widget>
-      </item> 
+      </item>
       <item>
-       <widget class="QComboBox" name="kcfg_scoreTime" >
+       <widget class="QComboBox" name="kcfg_scoreTime">
         <item>
-         <property name="text" >
+         <property name="text">
           <string>15 Seconds</string>
          </property>
         </item>
         <item>
-         <property name="text" >
+         <property name="text">
           <string>30 Seconds</string>
          </property>
         </item>
         <item>
-         <property name="text" >
+         <property name="text">
           <string>45 Seconds</string>
          </property>
         </item>
         <item>
-         <property name="text" >
+         <property name="text">
           <string>60 Seconds</string>
          </property>
         </item>
        </widget>
       </item>
       <item>
-       <widget class="QCheckBox" name="scoringOptions">
+       <widget class="QCheckBox" name="scoringPointCheckbox">
         <property name="text">
-         <string>Advanced Settings</string>
+         <string>Score Point Settings</string>
         </property>
-       </widget>        
-      </item> 
+       </widget>
+      </item>
       <item>
-       <widget class="QLabel" name="textCorrectAnswer" >
-        <property name="text" >
+       <widget class="QLabel" name="textCorrectAnswer">
+        <property name="text">
          <string>Assign score for correct answer : </string>
         </property>
        </widget>
-      </item>     
-     <item>
-      <widget class="QComboBox" name="kcfg_correctAnswerScore" >
-       <item>
-        <property name="text" >
-         <string>+5 points</string>
-        </property>
-       </item>
-       <item>
-        <property name="text" >
-         <string>+10 points</string>
-        </property>
-       </item>
-       <item>
-        <property name="text" >
-         <string>+15 points</string>
-        </property>
-       </item>
-       <item>
-        <property name="text" >
-         <string>+20 points</string>
-        </property>
-       </item>
-      </widget>
-     </item>     
-     <item>
-      <widget class="QLabel" name="textIncorrectAnswer" >
-       <property name="text" >
-        <string>Assign score for incorrect answer : </string>
-       </property>
-      </widget>
-     </item>     
-     <item>
-      <widget class="QComboBox" name="kcfg_incorrectAnswerScore" >
-       <item>
-        <property name="text" >
-         <string>-1 point</string>
-        </property>
-       </item>
-       <item>
-        <property name="text" >
-         <string>-2 points</string>
-        </property>
-       </item>
-       <item>
-        <property name="text" >
-         <string>-3 points</string>         
-        </property>
-       </item>
-       <item>
-        <property name="text" >
-         <string>-4 points</string>
-        </property>
-       </item>
-      </widget>
-     </item>     
-     <item>
-      <widget class="QLabel" name="textRevealAnswer" >
-       <property name="text" >
-        <string>Assign score for reveal answer : </string>
-       </property>
-      </widget>
-     </item>     
-     <item>
-      <widget class="QComboBox" name="kcfg_revealAnswerScore" >
-       <item>
-        <property name="text" >
-         <string>-2 points</string>
-        </property>
-       </item>
-       <item>
-        <property name="text" >
-         <string>-4 points</string>
-        </property>
-       </item>
-       <item>
-        <property name="text" >
-         <string>-6 points</string>
-        </property>
-       </item>
-       <item>
-        <property name="text" >
-         <string>-8 points</string>
-        </property>
-       </item>
-      </widget>
-     </item>     
-     <item>
-      <widget class="QLabel" name="textSkippedWord" >
-       <property name="text" >
-        <string>Assign score for skipped word : </string>
-       </property>
-      </widget>
-     </item>     
-     <item>
-      <widget class="QComboBox" name="kcfg_skippedWordScore" >
-       <item>
-        <property name="text" >
-         <string>-2 points</string>
-        </property>
-       </item>
-       <item>
-        <property name="text" >
-         <string>-4 points</string>
+      </item>
+      <item>
+       <widget class="QComboBox" name="kcfg_correctAnswerScore">
+        <item>
+         <property name="text">
+          <string>+5 points</string>
+         </property>
+        </item>
+        <item>
+         <property name="text">
+          <string>+10 points</string>
+         </property>
+        </item>
+        <item>
+         <property name="text">
+          <string>+15 points</string>
+         </property>
+        </item>
+        <item>
+         <property name="text">
+          <string>+20 points</string>
+         </property>
+        </item>
+       </widget>
+      </item>
+      <item>
+       <widget class="QLabel" name="textIncorrectAnswer">
+        <property name="text">
+         <string>Assign score for incorrect answer : </string>
         </property>
-       </item>
-       <item>
-        <property name="text" >
-         <string>-6 points</string>
+       </widget>
+      </item>
+      <item>
+       <widget class="QComboBox" name="kcfg_incorrectAnswerScore">
+        <item>
+         <property name="text">
+          <string>-1 point</string>
+         </property>
+        </item>
+        <item>
+         <property name="text">
+          <string>-2 points</string>
+         </property>
+        </item>
+        <item>
+         <property name="text">
+          <string>-3 points</string>
+         </property>
+        </item>
+        <item>
+         <property name="text">
+          <string>-4 points</string>
+         </property>
+        </item>
+       </widget>
+      </item>
+      <item>
+       <widget class="QLabel" name="textRevealAnswer">
+        <property name="text">
+         <string>Assign score for reveal answer : </string>
         </property>
-       </item>
-       <item>
-        <property name="text" >
-         <string>-8 points</string>
+       </widget>
+      </item>
+      <item>
+       <widget class="QComboBox" name="kcfg_revealAnswerScore">
+        <item>
+         <property name="text">
+          <string>-2 points</string>
+         </property>
+        </item>
+        <item>
+         <property name="text">
+          <string>-4 points</string>
+         </property>
+        </item>
+        <item>
+         <property name="text">
+          <string>-6 points</string>
+         </property>
+        </item>
+        <item>
+         <property name="text">
+          <string>-8 points</string>
+         </property>
+        </item>
+       </widget>
+      </item>
+      <item>
+       <widget class="QLabel" name="textSkippedWord">
+        <property name="text">
+         <string>Assign score for skipped word : </string>
         </property>
-       </item>
-      </widget>
-     </item>      
-    </layout>
-   </widget>
-  </item>
-  <item>
-   <widget class="QCheckBox" name="kcfg_useSounds" >
-    <property name="whatsThis" >
-     <string>Turns sounds on/off.</string>
-    </property>
-    <property name="text" >
-     <string>Use sou&amp;nds</string>
-    </property>
-   </widget>
-  </item>
-  <item>
-   <widget class="QCheckBox" name="kcfg_uppercaseOnly" >
-    <property name="whatsThis" >
-     <string>Use only uppercase letters.</string>
-    </property>
-    <property name="text" >
-     <string>Only uppercase letters</string>
-    </property>
-   </widget>
-  </item>
-  <item>
-   <widget class="QCheckBox" name="kcfg_enablePronunciation" >
-    <property name="whatsThis" >
-     <string>Turn pronunciations on or off.</string>
-    </property>
-    <property name="text" >
-     <string>Say correct words</string>
-    </property>
-   </widget>
-  </item>
-  <item>
-   <spacer>
-    <property name="orientation" >
-     <enum>Qt::Vertical</enum>
-    </property>
-    <property name="sizeType" >
-     <enum>QSizePolicy::Expanding</enum>
-    </property>
-    <property name="sizeHint" >
-     <size>
-      <width>16</width>
-      <height>16</height>
-     </size>
-    </property>
-   </spacer>
-  </item>
- </layout>
-</widget>
-<tabstops>
- <tabstop>kcfg_hintHideTime</tabstop>
- <tabstop>kcfg_useSounds</tabstop>
- <tabstop>kcfg_uppercaseOnly</tabstop>
- <tabstop>kcfg_enablePronunciation</tabstop>
-</tabstops>
-<resources/>
-<connections/>
+       </widget>
+      </item>
+      <item>
+       <widget class="QComboBox" name="kcfg_skippedWordScore">
+        <item>
+         <property name="text">
+          <string>-2 points</string>
+         </property>
+        </item>
+        <item>
+         <property name="text">
+          <string>-4 points</string>
+         </property>
+        </item>
+        <item>
+         <property name="text">
+          <string>-6 points</string>
+         </property>
+        </item>
+        <item>
+         <property name="text">
+          <string>-8 points</string>
+         </property>
+        </item>
+       </widget>
+      </item>
+     </layout>
+    </widget>
+   </item>
+   <item>
+    <widget class="QCheckBox" name="kcfg_useSounds">
+     <property name="whatsThis">
+      <string>Turns sounds on/off.</string>
+     </property>
+     <property name="text">
+      <string>Use sou&amp;nds</string>
+     </property>
+    </widget>
+   </item>
+   <item>
+    <widget class="QCheckBox" name="kcfg_uppercaseOnly">
+     <property name="whatsThis">
+      <string>Use only uppercase letters.</string>
+     </property>
+     <property name="text">
+      <string>Only uppercase letters</string>
+     </property>
+    </widget>
+   </item>
+   <item>
+    <widget class="QCheckBox" name="kcfg_enablePronunciation">
+     <property name="whatsThis">
+      <string>Turn pronunciations on or off.</string>
+     </property>
+     <property name="text">
+      <string>Say correct words</string>
+     </property>
+    </widget>
+   </item>
+   <item>
+    <spacer>
+     <property name="orientation">
+      <enum>Qt::Vertical</enum>
+     </property>
+     <property name="sizeType">
+      <enum>QSizePolicy::Expanding</enum>
+     </property>
+     <property name="sizeHint" stdset="0">
+      <size>
+       <width>16</width>
+       <height>16</height>
+      </size>
+     </property>
+    </spacer>
+   </item>
+  </layout>
+ </widget>
+ <tabstops>
+  <tabstop>kcfg_hintHideTime</tabstop>
+  <tabstop>kcfg_useSounds</tabstop>
+  <tabstop>kcfg_uppercaseOnly</tabstop>
+  <tabstop>kcfg_enablePronunciation</tabstop>
+ </tabstops>
+ <resources/>
+ <connections/>
 </ui>


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic