Changeset View
Changeset View
Standalone View
Standalone View
kcms/runners/kcm.cpp
Show First 20 Lines • Show All 47 Lines • ▼ Show 20 Line(s) | 46 | SearchConfigModule::SearchConfigModule(QWidget* parent, const QVariantList& args) | |||
---|---|---|---|---|---|
48 | , m_config("krunnerrc") | 48 | , m_config("krunnerrc") | ||
49 | { | 49 | { | ||
50 | KAboutData* about = new KAboutData(QStringLiteral("kcm_search"), i18nc("kcm name for About dialog", "Configure Search Bar"), | 50 | KAboutData* about = new KAboutData(QStringLiteral("kcm_search"), i18nc("kcm name for About dialog", "Configure Search Bar"), | ||
51 | QStringLiteral("0.1"), QString(), KAboutLicense::LGPL); | 51 | QStringLiteral("0.1"), QString(), KAboutLicense::LGPL); | ||
52 | about->addAuthor(i18n("Vishesh Handa"), QString(), QStringLiteral("vhanda@kde.org")); | 52 | about->addAuthor(i18n("Vishesh Handa"), QString(), QStringLiteral("vhanda@kde.org")); | ||
53 | setAboutData(about); | 53 | setAboutData(about); | ||
54 | setButtons(Apply | Default); | 54 | setButtons(Apply | Default); | ||
55 | 55 | | |||
56 | if(!args.at(0).toString().isEmpty()) { | ||||
57 | m_pluginID = args.at(0).toString(); | ||||
58 | } | ||||
59 | | ||||
56 | QVBoxLayout* layout = new QVBoxLayout(this); | 60 | QVBoxLayout* layout = new QVBoxLayout(this); | ||
57 | 61 | | |||
58 | QHBoxLayout *headerLayout = new QHBoxLayout(this); | 62 | QHBoxLayout *headerLayout = new QHBoxLayout(this); | ||
59 | 63 | | |||
60 | QLabel *label = new QLabel(i18n("Enable or disable KRunner plugins:")); | 64 | QLabel *label = new QLabel(i18n("Enable or disable KRunner plugins:")); | ||
61 | 65 | | |||
62 | QPushButton *clearHistoryButton = new QPushButton(i18n("Clear History")); | 66 | QPushButton *clearHistoryButton = new QPushButton(i18n("Clear History")); | ||
63 | clearHistoryButton->setIcon(QIcon::fromTheme(isRightToLeft() ? QStringLiteral("edit-clear-locationbar-ltr") | 67 | clearHistoryButton->setIcon(QIcon::fromTheme(isRightToLeft() ? QStringLiteral("edit-clear-locationbar-ltr") | ||
64 | : QStringLiteral("edit-clear-locationbar-rtl"))); | 68 | : QStringLiteral("edit-clear-locationbar-rtl"))); | ||
65 | connect(clearHistoryButton, &QPushButton::clicked, this, [this] { | 69 | connect(clearHistoryButton, &QPushButton::clicked, this, [this] { | ||
66 | KConfigGroup generalConfig(m_config.group("General")); | 70 | KConfigGroup generalConfig(m_config.group("General")); | ||
67 | generalConfig.deleteEntry("history"); | 71 | generalConfig.deleteEntry("history"); | ||
68 | generalConfig.sync(); | 72 | generalConfig.sync(); | ||
69 | }); | 73 | }); | ||
70 | 74 | | |||
71 | headerLayout->addWidget(label); | 75 | headerLayout->addWidget(label); | ||
72 | headerLayout->addStretch(); | 76 | headerLayout->addStretch(); | ||
73 | headerLayout->addWidget(clearHistoryButton); | 77 | headerLayout->addWidget(clearHistoryButton); | ||
74 | 78 | | |||
75 | m_pluginSelector = new KPluginSelector(this); | 79 | m_pluginSelector = new KPluginSelector(this); | ||
76 | 80 | | |||
77 | auto markAsChanged = [this] { | 81 | connect(m_pluginSelector, &KPluginSelector::changed, this, &SearchConfigModule::markAsChanged); | ||
78 | emit changed(); | 82 | connect(m_pluginSelector, &KPluginSelector::configCommitted, this, &SearchConfigModule::markAsChanged); | ||
79 | }; | | |||
80 | connect(m_pluginSelector, &KPluginSelector::changed, this, markAsChanged); | | |||
81 | connect(m_pluginSelector, &KPluginSelector::configCommitted, this, markAsChanged); | | |||
82 | 83 | | |||
83 | #if KCMUTILS_VERSION >= QT_VERSION_CHECK(5, 67, 0) | 84 | #if KCMUTILS_VERSION >= QT_VERSION_CHECK(5, 67, 0) | ||
84 | connect(m_pluginSelector, &KPluginSelector::defaulted, | 85 | connect(m_pluginSelector, &KPluginSelector::defaulted, this, &KCModule::defaulted); | ||
85 | this, &KCModule::defaulted); | | |||
86 | #endif | 86 | #endif | ||
87 | 87 | | |||
88 | layout->addLayout(headerLayout); | 88 | layout->addLayout(headerLayout); | ||
89 | layout->addWidget(m_pluginSelector); | 89 | layout->addWidget(m_pluginSelector); | ||
90 | 90 | | |||
91 | Plasma::RunnerManager *manager = new Plasma::RunnerManager(this); | 91 | Plasma::RunnerManager *manager = new Plasma::RunnerManager(this); | ||
92 | manager->reloadConfiguration(); | 92 | manager->reloadConfiguration(); | ||
93 | } | 93 | } | ||
94 | 94 | | |||
95 | void SearchConfigModule::load() | 95 | void SearchConfigModule::load() | ||
96 | { | 96 | { | ||
97 | // Set focus on the pluginselector to pass focus to search bar. | 97 | // Set focus on the pluginselector to pass focus to search bar. | ||
98 | m_pluginSelector->setFocus(Qt::OtherFocusReason); | 98 | m_pluginSelector->setFocus(Qt::OtherFocusReason); | ||
99 | 99 | | |||
100 | m_pluginSelector->addPlugins(Plasma::RunnerManager::listRunnerInfo(), | 100 | m_pluginSelector->addPlugins(Plasma::RunnerManager::listRunnerInfo(), | ||
101 | KPluginSelector::ReadConfigFile, | 101 | KPluginSelector::ReadConfigFile, | ||
102 | i18n("Available Plugins"), QString(), | 102 | i18n("Available Plugins"), QString(), | ||
103 | KSharedConfig::openConfig(QLatin1String( "krunnerrc" ))); | 103 | KSharedConfig::openConfig(QStringLiteral( "krunnerrc" ))); | ||
104 | m_pluginSelector->load(); | 104 | m_pluginSelector->load(); | ||
105 | | ||||
106 | if(!m_pluginID.isEmpty()){ | ||||
107 | m_pluginSelector->showConfiguration(m_pluginID); | ||||
108 | } | ||||
105 | } | 109 | } | ||
106 | 110 | | |||
107 | 111 | | |||
108 | void SearchConfigModule::save() | 112 | void SearchConfigModule::save() | ||
109 | { | 113 | { | ||
110 | m_pluginSelector->save(); | 114 | m_pluginSelector->save(); | ||
111 | } | 115 | } | ||
112 | 116 | | |||
113 | void SearchConfigModule::defaults() | 117 | void SearchConfigModule::defaults() | ||
114 | { | 118 | { | ||
115 | m_pluginSelector->defaults(); | 119 | m_pluginSelector->defaults(); | ||
116 | } | 120 | } | ||
117 | 121 | | |||
118 | #include "kcm.moc" | 122 | #include "kcm.moc" |