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

kanagram

mainsettings.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2005 by Joshua Keel <joshuakeel@gmail.com>              *
00003  *             (C) 2007 by Jeremy Whiting <jeremy@scitools.com>            *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU General Public License     *
00016  *   along with this program; if not, write to the                         *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.          *
00019  ***************************************************************************/
00020 
00021 #include "mainsettings.h"
00022 
00023 #include <qdir.h>
00024 #include <qcheckbox.h>
00025 #include <qcombobox.h>
00026 #include <qpushbutton.h>
00027 
00028 #include <kdebug.h>
00029 #include <kconfig.h>
00030 #include <klocale.h>
00031 #include <kstandarddirs.h>
00032 #include <kconfigdialog.h>
00033 #include <kmessagebox.h>
00034 #include <kio/netaccess.h>
00035 
00036 #include <sharedkvtmlfiles.h>
00037 #include "kanagramsettings.h"
00038 
00039 MainSettings::MainSettings(QWidget *parent) : QWidget(parent)
00040 {
00041     setupUi( this );
00042     m_parent = (KConfigDialog*)parent;
00043 
00044     connect(parent, SIGNAL(applyClicked()), this, SLOT(slotUpdateLanguage()));
00045     connect(parent, SIGNAL(okClicked()), this, SLOT(slotUpdateLanguage()));
00046     connect(languageComboBox, SIGNAL(activated(int)), this, SLOT(slotSetDirty()));
00047     
00048     populateLanguageBox();
00049 
00050     //the language code/name
00051     KConfig entry(KStandardDirs::locate("locale", "all_languages"));
00052     QString code = KanagramSettings::dataLanguage();
00053     KConfigGroup group = entry.group(code);
00054     // select the current language
00055     languageComboBox->setCurrentIndex(languageComboBox->findText(group.readEntry("Name")));
00056 }
00057 
00058 MainSettings::~MainSettings()
00059 {
00060 }
00061 
00062 void MainSettings::slotSetDirty()
00063 {
00064     m_parent->enableButtonApply(true);
00065 }
00066 
00067 void MainSettings::populateLanguageBox()
00068 {
00069     QStringList languages = SharedKvtmlFiles::languages();
00070 
00071     //the language code/name
00072     KConfig entry(KStandardDirs::locate("locale", "all_languages"));
00073     for (int i = 0; i < languages.count(); ++i) 
00074     {
00075         KConfigGroup group = entry.group(languages[i]);
00076         
00077         // get the language name
00078         QString languageName = group.readEntry("Name");
00079         if (languageName.isEmpty())
00080         {
00081             languageName = i18nc("@item:inlistbox no language for that locale", "None");
00082         }
00083         languageComboBox->addItem(languageName, languages[i]);
00084     }
00085 }
00086 
00087 void MainSettings::slotUpdateLanguage()
00088 {
00089     int index = languageComboBox->currentIndex();
00090     QString language = languageComboBox->itemData(index).toString();
00091     kDebug() << "Writing new default language: " << language;
00092     KanagramSettings::setDataLanguage(language);
00093     KanagramSettings::self()->writeConfig();
00094     
00095     emit settingsChanged();
00096 }
00097 
00098 #include "mainsettings.moc"

kanagram

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

kdeedu

Skip menu "kdeedu"
  • kalzium
  • kanagram
  • kig
  • klettres
  • kstars
  • libkdeedu
  •   keduvocdocument
  •   docs
  •   src
  • parley
Generated for kdeedu by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal