Changeset View
Changeset View
Standalone View
Standalone View
kcmkwin/kwindesktop/virtualdesktops.cpp
Show All 16 Lines | |||||
17 | */ | 17 | */ | ||
18 | 18 | | |||
19 | #include "virtualdesktops.h" | 19 | #include "virtualdesktops.h" | ||
20 | #include "animationsmodel.h" | 20 | #include "animationsmodel.h" | ||
21 | #include "desktopsmodel.h" | 21 | #include "desktopsmodel.h" | ||
22 | 22 | | |||
23 | #include <KAboutApplicationDialog> | 23 | #include <KAboutApplicationDialog> | ||
24 | #include <KAboutData> | 24 | #include <KAboutData> | ||
25 | #include <KCModule> | | |||
26 | #include <KConfigGroup> | 25 | #include <KConfigGroup> | ||
27 | #include <KLocalizedString> | 26 | #include <KLocalizedString> | ||
28 | #include <KPluginFactory> | | |||
29 | #include <KPluginTrader> | | |||
30 | | ||||
31 | #include <QDialog> | | |||
32 | #include <QDialogButtonBox> | | |||
33 | #include <QPushButton> | | |||
34 | #include <QVBoxLayout> | | |||
35 | 27 | | |||
36 | K_PLUGIN_FACTORY_WITH_JSON(VirtualDesktopsFactory, "kcm_kwin_virtualdesktops.json", registerPlugin<KWin::VirtualDesktops>();) | 28 | K_PLUGIN_FACTORY_WITH_JSON(VirtualDesktopsFactory, "kcm_kwin_virtualdesktops.json", registerPlugin<KWin::VirtualDesktops>();) | ||
37 | 29 | | |||
38 | namespace KWin | 30 | namespace KWin | ||
39 | { | 31 | { | ||
40 | 32 | | |||
41 | VirtualDesktops::VirtualDesktops(QObject *parent, const QVariantList &args) | 33 | VirtualDesktops::VirtualDesktops(QObject *parent, const QVariantList &args) | ||
42 | : KQuickAddons::ConfigModule(parent, args) | 34 | : KQuickAddons::ConfigModule(parent, args) | ||
▲ Show 20 Lines • Show All 150 Lines • ▼ Show 20 Line(s) | |||||
193 | 185 | | |||
194 | void VirtualDesktops::configureAnimation() | 186 | void VirtualDesktops::configureAnimation() | ||
195 | { | 187 | { | ||
196 | const QModelIndex index = m_animationsModel->index(m_animationsModel->currentIndex(), 0); | 188 | const QModelIndex index = m_animationsModel->index(m_animationsModel->currentIndex(), 0); | ||
197 | if (!index.isValid()) { | 189 | if (!index.isValid()) { | ||
198 | return; | 190 | return; | ||
199 | } | 191 | } | ||
200 | 192 | | |||
201 | const QString name = index.data(AnimationsModel::NameRole).toString(); | 193 | m_animationsModel->requestConfigure(index, nullptr); | ||
202 | const QString serviceName = index.data(AnimationsModel::ServiceNameRole).toString(); | | |||
203 | | ||||
204 | QPointer<QDialog> configDialog = new QDialog(); | | |||
205 | | ||||
206 | KCModule *kcm = KPluginTrader::createInstanceFromQuery<KCModule>( | | |||
207 | QStringLiteral("kwin/effects/configs/"), | | |||
208 | QString(), | | |||
209 | QStringLiteral("'%1' in [X-KDE-ParentComponents]").arg(serviceName), | | |||
210 | configDialog | | |||
211 | ); | | |||
212 | | ||||
213 | if (!kcm) { | | |||
214 | delete configDialog; | | |||
215 | return; | | |||
216 | } | | |||
217 | | ||||
218 | configDialog->setWindowTitle(name); | | |||
219 | configDialog->setLayout(new QVBoxLayout); | | |||
220 | | ||||
221 | auto buttons = new QDialogButtonBox( | | |||
222 | QDialogButtonBox::Ok | | | |||
223 | QDialogButtonBox::Cancel | | | |||
224 | QDialogButtonBox::RestoreDefaults, | | |||
225 | configDialog | | |||
226 | ); | | |||
227 | QObject::connect(buttons, &QDialogButtonBox::accepted, configDialog, &QDialog::accept); | | |||
228 | QObject::connect(buttons, &QDialogButtonBox::rejected, configDialog, &QDialog::reject); | | |||
229 | QObject::connect(buttons->button(QDialogButtonBox::RestoreDefaults), &QPushButton::clicked, kcm, &KCModule::defaults); | | |||
230 | | ||||
231 | auto showWidget = new QWidget(configDialog); | | |||
232 | auto layout = new QVBoxLayout; | | |||
233 | showWidget->setLayout(layout); | | |||
234 | layout->addWidget(kcm); | | |||
235 | configDialog->layout()->addWidget(showWidget); | | |||
236 | configDialog->layout()->addWidget(buttons); | | |||
237 | | ||||
238 | if (configDialog->exec() == QDialog::Accepted) { | | |||
239 | kcm->save(); | | |||
240 | } else if (!configDialog.isNull()) { | | |||
241 | kcm->load(); | | |||
242 | } | | |||
243 | | ||||
244 | delete configDialog; | | |||
245 | } | 194 | } | ||
246 | 195 | | |||
247 | void VirtualDesktops::showAboutAnimation() | 196 | void VirtualDesktops::showAboutAnimation() | ||
248 | { | 197 | { | ||
249 | const QModelIndex index = m_animationsModel->index(m_animationsModel->currentIndex(), 0); | 198 | const QModelIndex index = m_animationsModel->index(m_animationsModel->currentIndex(), 0); | ||
250 | if (!index.isValid()) { | 199 | if (!index.isValid()) { | ||
251 | return; | 200 | return; | ||
252 | } | 201 | } | ||
▲ Show 20 Lines • Show All 83 Lines • Show Last 20 Lines |