File indexing completed on 2024-05-19 13:15:17
0001 /* 0002 * SPDX-License-Identifier: GPL-2.0-or-later 0003 * SPDX-FileCopyrightText: 2010, 2012 Jason A. Donenfeld <Jason@zx2c4.com> 0004 */ 0005 0006 #include "dictionaryrunner_config.h" 0007 #include <KConfigGroup> 0008 #include <KLocalizedString> 0009 #include <KPluginFactory> 0010 #include <KRunner/AbstractRunner> 0011 #include <KSharedConfig> 0012 #include <QFormLayout> 0013 #include <QLineEdit> 0014 0015 K_PLUGIN_FACTORY(DictionaryRunnerConfigFactory, registerPlugin<DictionaryRunnerConfig>();) 0016 0017 DictionaryRunnerConfig::DictionaryRunnerConfig(QWidget *parent, const QVariantList &args) 0018 : KCModule(parent, args) 0019 { 0020 QFormLayout *layout = new QFormLayout; 0021 m_triggerWord = new QLineEdit; 0022 layout->addRow(i18nc("@label:textbox", "Trigger word:"), m_triggerWord); 0023 setLayout(layout); 0024 connect(m_triggerWord, &QLineEdit::textChanged, this, &DictionaryRunnerConfig::markAsChanged); 0025 load(); 0026 } 0027 0028 void DictionaryRunnerConfig::load() 0029 { 0030 KCModule::load(); 0031 KSharedConfig::Ptr cfg = KSharedConfig::openConfig(QLatin1String("krunnerrc")); 0032 KConfigGroup grp = cfg->group("Runners"); 0033 grp = KConfigGroup(&grp, "Dictionary"); 0034 m_triggerWord->setText(grp.readEntry(CONFIG_TRIGGERWORD, i18nc("Trigger word before word to define", "define"))); 0035 Q_EMIT changed(false); 0036 } 0037 0038 void DictionaryRunnerConfig::save() 0039 { 0040 KCModule::save(); 0041 KSharedConfig::Ptr cfg = KSharedConfig::openConfig(QLatin1String("krunnerrc")); 0042 KConfigGroup grp = cfg->group("Runners"); 0043 grp = KConfigGroup(&grp, "Dictionary"); 0044 grp.writeEntry(CONFIG_TRIGGERWORD, m_triggerWord->text()); 0045 grp.sync(); 0046 Q_EMIT changed(false); 0047 } 0048 0049 void DictionaryRunnerConfig::defaults() 0050 { 0051 KCModule::defaults(); 0052 m_triggerWord->setText(i18nc("Trigger word before word to define", "define")); 0053 Q_EMIT changed(true); 0054 } 0055 0056 #include "dictionaryrunner_config.moc"