• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

kanagram

  • sources
  • kde-4.14
  • kdeedu
  • kanagram
  • src
mainsettings.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005 by Joshua Keel <joshuakeel@gmail.com> *
3  * (C) 2007 by Jeremy Whiting <jpwhiting@kde.org> *
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; either version 2 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 for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19  ***************************************************************************/
20 
21 #include "mainsettings.h"
22 
23 #include <kdebug.h>
24 #include <kconfig.h>
25 #include <klocale.h>
26 #include <kstandarddirs.h>
27 #include <kconfigdialog.h>
28 #include <kmessagebox.h>
29 
30 #include <sharedkvtmlfiles.h>
31 #include <kanagramsettings.h>
32 
33 MainSettings::MainSettings(QWidget *parent) : QWidget(parent)
34 {
35  setupUi( this );
36  m_parent = (KConfigDialog*)parent;
37  slotToggleAdvancedSettings();
38  connect(parent, SIGNAL(applyClicked()), this, SLOT(slotUpdateLanguage()));
39  connect(parent, SIGNAL(okClicked()), this, SLOT(slotUpdateLanguage()));
40  connect(languageComboBox, SIGNAL(activated(int)), this, SLOT(slotSetDirty()));
41  connect(scoringOptions,SIGNAL(toggled(bool)),this,SLOT(slotToggleAdvancedSettings()));
42  populateLanguageBox();
43 
44  //the language code/name
45  KConfig entry(KStandardDirs::locate("locale", "all_languages"));
46  QString code = KanagramSettings::dataLanguage();
47  KConfigGroup group = entry.group(code);
48  // select the current language
49  languageComboBox->setCurrentIndex(languageComboBox->findText(group.readEntry("Name")));
50 }
51 
52 MainSettings::~MainSettings()
53 {
54 }
55 
56 void MainSettings::slotSetDirty()
57 {
58  m_parent->enableButtonApply(true);
59 }
60 
61 void MainSettings::slotToggleAdvancedSettings()
62 {
63  textCorrectAnswer->setVisible(scoringOptions->isChecked());
64  kcfg_correctAnswerScore->setVisible(scoringOptions->isChecked());
65  textIncorrectAnswer->setVisible(scoringOptions->isChecked());
66  kcfg_incorrectAnswerScore->setVisible(scoringOptions->isChecked());
67  textRevealAnswer->setVisible(scoringOptions->isChecked());
68  kcfg_revealAnswerScore->setVisible(scoringOptions->isChecked());
69  textSkippedWord->setVisible(scoringOptions->isChecked());
70  kcfg_skippedWordScore->setVisible(scoringOptions->isChecked());
71 }
72 
73 void MainSettings::populateLanguageBox()
74 {
75  QStringList languages = SharedKvtmlFiles::languages();
76 
77  //the language code/name
78  KConfig entry(KStandardDirs::locate("locale", "all_languages"));
79  for (int i = 0; i < languages.count(); ++i)
80  {
81  KConfigGroup group = entry.group(languages[i]);
82 
83  // get the language name
84  QString languageName = group.readEntry("Name");
85  if (languageName.isEmpty())
86  {
87  languageName = i18nc("@item:inlistbox no language for that locale", "None");
88  }
89  languageComboBox->addItem(languageName, languages[i]);
90  }
91 }
92 
93 void MainSettings::slotUpdateLanguage()
94 {
95  int index = languageComboBox->currentIndex();
96  QString language = languageComboBox->itemData(index).toString();
97  kDebug() << "Writing new default language: " << language;
98  KanagramSettings::setDataLanguage(language);
99  KanagramSettings::self()->writeConfig();
100 
101  emit settingsChanged();
102 }
103 
104 #include "mainsettings.moc"
QWidget
QWidget::setupUi
void setupUi(QWidget *widget)
MainSettings::slotSetDirty
void slotSetDirty()
enable the apply button on the config dialog because something has been changed
Definition: mainsettings.cpp:56
MainSettings::~MainSettings
~MainSettings()
default destructor
Definition: mainsettings.cpp:52
MainSettings::MainSettings
MainSettings(QWidget *parent)
default constructor
Definition: mainsettings.cpp:33
KanagramSettings::self
static KanagramSettings * self()
Definition: kanagramsettings.cpp:17
kanagramsettings.h
QList::count
int count(const T &value) const
MainSettings::settingsChanged
void settingsChanged()
signifies slotUpdateLanguage has completed, so language setting has been saved
QString::isEmpty
bool isEmpty() const
KanagramSettings::setDataLanguage
static void setDataLanguage(const QString &v)
Set Set the default translation.
Definition: kanagramsettings.h:250
QString
QStringList
MainSettings::slotUpdateLanguage
void slotUpdateLanguage()
save the language setting that has been chosen
Definition: mainsettings.cpp:93
KanagramSettings::dataLanguage
static QString dataLanguage()
Get Set the default translation.
Definition: kanagramsettings.h:260
QObject::connect
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
MainSettings::slotToggleAdvancedSettings
void slotToggleAdvancedSettings()
toggle advanced settings
Definition: mainsettings.cpp:61
mainsettings.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:12:00 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kanagram

Skip menu "kanagram"
  • Main Page
  • Namespace List
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal