File indexing completed on 2024-04-21 03:51:03
0001 /* 0002 SPDX-FileCopyrightText: 2007 Frederik Gladhorn <frederik.gladhorn@kdemail.net> 0003 SPDX-FileCopyrightText: 2014 Inge Wallin <inge@lysator.liu.se> 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #include "configurepracticedialog.h" 0008 0009 #include "blockoptions.h" 0010 #include "generalpracticeoptions.h" 0011 #include "specificpracticeoptions.h" 0012 #include "thresholdoptions.h" 0013 0014 #include <KLocalizedString> 0015 #include <KWindowConfig> 0016 0017 #include <QPushButton> 0018 0019 ConfigurePracticeDialog::ConfigurePracticeDialog(KEduVocDocument *doc, QWidget *parent, const QString &name, KConfigSkeleton *config) 0020 : KConfigDialog(parent, name, config) 0021 , m_config{config} 0022 { 0023 setWindowTitle(i18nc("@title:window", "Configure Practice")); 0024 button(QDialogButtonBox::Ok)->setDefault(true); 0025 0026 m_generalPracticeOptions = new GeneralPracticeOptions(this); 0027 addPage(m_generalPracticeOptions, 0028 i18nc("@title:group Configure general settings for practicing vocabulary, short title in config dialog.", "General"), 0029 QStringLiteral("general-setup"), 0030 i18nc("Configure general settings for practicing vocabulary.", "General Practice Settings"), 0031 true); 0032 0033 m_blockOptions = new BlockOptions(this); 0034 addPage(m_blockOptions, 0035 i18nc("@title:group vocabulary can be set to be blocked for a certain amount of time", "Blocking"), 0036 QStringLiteral("cards-block"), 0037 i18n("Blocking Settings"), 0038 true); 0039 0040 m_thresholdOptions = new ThresholdOptions(doc, this); 0041 addPage(m_thresholdOptions, 0042 i18nc("@title:group ignore vocabulary based on some properties like word type", "Thresholds"), 0043 QStringLiteral("practice-setup"), 0044 i18n("Threshold Settings"), 0045 true); 0046 0047 m_specificPracticeOptions = new SpecificPracticeOptions(this); 0048 addPage(m_specificPracticeOptions, 0049 i18nc("@title:group Configure specific settings for practicing vocabulary, short title in config dialog.", "Specific"), 0050 QStringLiteral("specific-setup"), 0051 i18nc("Configure specific settings for practicing vocabulary.", "Specific Practice Settings"), 0052 true); 0053 0054 setHelp(QString(), QStringLiteral("parley")); 0055 0056 KConfigGroup cg(KSharedConfig::openConfig(QStringLiteral("parleyrc")), "ConfigurePracticeDialog"); 0057 this->resize(cg.readEntry("width", 100), cg.readEntry("height", 100)); 0058 } 0059 0060 ConfigurePracticeDialog::~ConfigurePracticeDialog() 0061 { 0062 KConfigGroup cg(KSharedConfig::openConfig(QStringLiteral("parleyrc")), "ConfigurePracticeDialog"); 0063 cg.writeEntry("width", this->size().width()); 0064 cg.writeEntry("height", this->size().height()); 0065 } 0066 0067 bool ConfigurePracticeDialog::hasChanged() 0068 { 0069 return m_thresholdOptions->hasChanged() || m_blockOptions->hasChanged(); 0070 } 0071 0072 bool ConfigurePracticeDialog::isDefault() 0073 { 0074 return m_thresholdOptions->isDefault() && m_blockOptions->isDefault(); 0075 } 0076 0077 void ConfigurePracticeDialog::updateSettings() 0078 { 0079 m_thresholdOptions->updateSettings(); 0080 m_blockOptions->updateSettings(); 0081 } 0082 0083 void ConfigurePracticeDialog::updateWidgets() 0084 { 0085 m_thresholdOptions->updateWidgets(); 0086 m_blockOptions->updateWidgets(); 0087 } 0088 0089 void ConfigurePracticeDialog::updateWidgetsDefault() 0090 { 0091 m_config->useDefaults(true); 0092 updateWidgets(); 0093 m_config->useDefaults(false); 0094 } 0095 0096 #include "moc_configurepracticedialog.cpp"