moved kdeaccessibility kdeaddons kdeadmin kdeartwork kdebindings kdeedu kdegames...
[kdeedu.git] / kvoctrain / kvoctrain / common-dialogs / kvoctrainprefs.cpp
blob23b19500636e434ed6ea4af5f017bf36e67a21fd
1 /***************************************************************************
2 kvoctrainprefs.cpp - KVocTrain configuration dialog
4 -------------------
5 begin : Fri Mar 25 2005
7 copyright : (C) 2005 Peter Hedlund <peter@peterandlinda.com>
8 ***************************************************************************/
10 /***************************************************************************
11 * *
12 * This program is free software; you can redistribute it and/or modify *
13 * it under the terms of the GNU General Public License as published by *
14 * the Free Software Foundation; either version 2 of the License, or *
15 * (at your option) any later version. *
16 * *
17 ***************************************************************************/
19 #include <qwidgetstack.h>
20 #include <qlayout.h>
21 #include <qradiobutton.h>
22 #include <qcheckbox.h>
23 #include <qlistview.h>
24 #include <qlabel.h>
26 #include <klocale.h>
27 #include <kstandarddirs.h>
28 #include <kiconloader.h>
29 #include <krestrictedline.h>
30 #include <kmessagebox.h>
31 #include <kpushbutton.h>
32 #include <kdebug.h>
33 #include <kconfigskeleton.h>
34 #include <kcolorbutton.h>
35 #include <kfontrequester.h>
36 #include <kcombobox.h>
38 #include "kvoctrainprefs.h"
39 #include "kvoctraindoc.h"
40 #include "generaloptions.h"
41 #include "languageoptions.h"
42 #include "viewoptions.h"
43 #include "pasteoptions.h"
44 #include "groupoptions.h"
45 #include "queryoptions.h"
46 #include "thresholdoptions.h"
47 #include "blockoptions.h"
48 #include "langset.h"
49 #include "QueryManager.h"
50 #include "profilesdialog.h"
52 static const char unapplied[] = I18N_NOOP(
53 "You have made changes that are not yet applied.\n"
54 "If you save a profile, those changes will not be included.\n"
55 "Do you wish to continue?");
57 KVocTrainPrefs::KVocTrainPrefs(LangSet & ls, kvoctrainDoc * doc, KComboBox * lessons, QueryManager * m, QWidget *parent,
58 const char *name, KConfigSkeleton *config, DialogType dialogType, int /*dialogButtons*/, ButtonCode /*defaultButton*/,
59 bool /*modal*/)
60 : KConfigDialog(parent, name, config, dialogType, Default|Ok|Apply|Cancel|Help|User1, Ok, true), m_langSet(ls)
62 m_config = config;
63 m_queryManager = m;
65 m_generalOptions = new GeneralOptions(0, "General Settings");
66 addPage(m_generalOptions, i18n("General"), "kvoctrain", i18n("General Settings"), true);
68 m_languageOptions = new LanguageOptions(m_langSet, 0, "Language Settings");
69 addPage(m_languageOptions, i18n("Languages"), "set_language", i18n("Language Settings"), true);
70 connect(m_languageOptions, SIGNAL(widgetModified()), this, SLOT(updateButtons()));
72 m_viewOptions = new ViewOptions(0, "View Settings");
73 addPage(m_viewOptions, i18n("View"), "view_choose", i18n("View Settings"), true);
75 m_pasteOptions = new PasteOptions(m_langSet, doc, 0, "Copy & Paste Settings");
76 addPage(m_pasteOptions, i18n("Copy & Paste"), "editpaste", i18n("Copy & Paste Settings"), true);
77 connect(m_pasteOptions, SIGNAL(widgetModified()), this, SLOT(updateButtons()));
79 m_queryOptions = new QueryOptions(0, "Query Settings");
80 addPage(m_queryOptions, i18n("Query"), "run_query", i18n("Query Settings"), true);
82 m_thresholdOptions = new ThresholdOptions(lessons, m_queryManager, 0, "Threshold Settings");
83 addPage(m_thresholdOptions, i18n("Thresholds"), "configure", i18n("Threshold Settings"), true);
84 connect(m_thresholdOptions, SIGNAL(widgetModified()), this, SLOT(updateButtons()));
86 m_blockOptions = new BlockOptions(0, "Blocking Settings");
87 addPage(m_blockOptions, i18n("Blocking"), "configure", i18n("Blocking Settings"), true);
88 connect(m_blockOptions, SIGNAL(widgetModified()), this, SLOT(updateButtons()));
89 connect(m_blockOptions, SIGNAL(blockExpireChanged(bool, bool)), m_thresholdOptions, SLOT(slotBlockExpire(bool, bool)));
91 setButtonGuiItem(KDialogBase::User1, KGuiItem(i18n("&Profiles...")));
94 void KVocTrainPrefs::selectPage(int index)
96 showPage(index);
99 bool KVocTrainPrefs::hasChanged()
101 return m_pasteOptions->hasChanged() |
102 m_languageOptions->hasChanged() |
103 m_thresholdOptions->hasChanged() |
104 m_blockOptions->hasChanged();
107 bool KVocTrainPrefs::isDefault()
109 return m_pasteOptions->isDefault() &&
110 m_languageOptions->isDefault() &&
111 m_thresholdOptions->isDefault() &&
112 m_blockOptions->isDefault();
115 void KVocTrainPrefs::updateSettings()
117 m_pasteOptions->updateSettings();
118 m_languageOptions->updateSettings();
119 m_thresholdOptions->updateSettings();
120 m_blockOptions->updateSettings();
121 emit settingsChanged();
124 void KVocTrainPrefs::updateWidgetsDefault()
126 bool bUseDefaults = m_config->useDefaults(true);
127 m_pasteOptions->updateWidgets();
128 m_languageOptions->updateWidgets();
129 m_thresholdOptions->updateWidgets();
130 m_blockOptions->updateWidgets();
131 m_config->useDefaults(bUseDefaults);
134 void KVocTrainPrefs::slotUser1()
136 bool showDlg = true;
137 if (hasChanged())
138 if (KMessageBox::Yes != KMessageBox::questionYesNo(this, i18n(unapplied), i18n("Unapplied Changes")))
139 showDlg = false;
141 if (showDlg)
143 ProfilesDialog * dlg = new ProfilesDialog(m_queryManager, this, 0, true);
144 connect(dlg, SIGNAL(profileActivated()), this, SLOT(updateWidgets()));
145 dlg->show();
149 void KVocTrainPrefs::updateWidgets()
151 m_queryOptions->updateWidgets();
152 m_thresholdOptions->updateWidgets();
153 m_blockOptions->updateWidgets();
156 #include "kvoctrainprefs.moc"