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

kanagram

  • sources
  • kde-4.12
  • kdeedu
  • kanagram
  • src
  • desktop
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 
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 
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::populateLanguageBox()
62 {
63  QStringList languages = SharedKvtmlFiles::languages();
64 
65  //the language code/name
66  KConfig entry(KStandardDirs::locate("locale", "all_languages"));
67  for (int i = 0; i < languages.count(); ++i)
68  {
69  KConfigGroup group = entry.group(languages[i]);
70 
71  // get the language name
72  QString languageName = group.readEntry("Name");
73  if (languageName.isEmpty())
74  {
75  languageName = i18nc("@item:inlistbox no language for that locale", "None");
76  }
77  languageComboBox->addItem(languageName, languages[i]);
78  }
79 }
80 
81 void MainSettings::slotUpdateLanguage()
82 {
83  int index = languageComboBox->currentIndex();
84  QString language = languageComboBox->itemData(index).toString();
85  kDebug() << "Writing new default language: " << language;
86  KanagramSettings::setDataLanguage(language);
87  KanagramSettings::self()->writeConfig();
88 
89  emit settingsChanged();
90 }
91 
92 #include "mainsettings.moc"
MainSettings::slotSetDirty
void slotSetDirty()
enable the apply button on the config dialog because something has been changed
Definition: mainsettings.cpp:56
QWidget
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
MainSettings::settingsChanged
void settingsChanged()
signifies slotUpdateLanguage has completed, so language setting has been saved
KanagramSettings::setDataLanguage
static void setDataLanguage(const QString &v)
Set Set the default translation.
Definition: kanagramsettings.h:117
MainSettings::slotUpdateLanguage
void slotUpdateLanguage()
save the language setting that has been chosen
Definition: mainsettings.cpp:81
KanagramSettings::dataLanguage
static QString dataLanguage()
Get Set the default translation.
Definition: kanagramsettings.h:127
mainsettings.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:35:35 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
  • kstars
  • libkdeedu
  •   keduvocdocument
  • 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