Changeset View
Changeset View
Standalone View
Standalone View
kcm/kcm.cpp
Show All 16 Lines | |||||
17 | You should have received a copy of the GNU General Public License | 17 | You should have received a copy of the GNU General Public License | ||
18 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 18 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
19 | *********************************************************************/ | 19 | *********************************************************************/ | ||
20 | #include "kcm.h" | 20 | #include "kcm.h" | ||
21 | #include "kscreensaversettings.h" | 21 | #include "kscreensaversettings.h" | ||
22 | #include "ui_kcm.h" | 22 | #include "ui_kcm.h" | ||
23 | #include "screenlocker_interface.h" | 23 | #include "screenlocker_interface.h" | ||
24 | #include <config-kscreenlocker.h> | 24 | #include <config-kscreenlocker.h> | ||
25 | #include <KAboutData> | ||||
26 | #include <KAuth> | ||||
25 | #include <KActionCollection> | 27 | #include <KActionCollection> | ||
26 | #include <KGlobalAccel> | 28 | #include <KGlobalAccel> | ||
27 | #include <KCModule> | 29 | #include <KCModule> | ||
28 | #include <KPluginFactory> | 30 | #include <KPluginFactory> | ||
29 | #include <KConfigDialogManager> | 31 | #include <KConfigDialogManager> | ||
30 | #include <QVBoxLayout> | 32 | #include <QVBoxLayout> | ||
31 | #include <QQuickView> | 33 | #include <QQuickView> | ||
32 | #include <QtQml> | 34 | #include <QtQml> | ||
Show All 22 Lines | |||||
55 | 57 | | |||
56 | 58 | | |||
57 | 59 | | |||
58 | ScreenLockerKcm::ScreenLockerKcm(QWidget *parent, const QVariantList &args) | 60 | ScreenLockerKcm::ScreenLockerKcm(QWidget *parent, const QVariantList &args) | ||
59 | : KCModule(parent, args) | 61 | : KCModule(parent, args) | ||
60 | , m_actionCollection(new KActionCollection(this, QStringLiteral("ksmserver"))) | 62 | , m_actionCollection(new KActionCollection(this, QStringLiteral("ksmserver"))) | ||
61 | , m_ui(new ScreenLockerKcmForm(this)) | 63 | , m_ui(new ScreenLockerKcmForm(this)) | ||
62 | { | 64 | { | ||
65 | KAboutData* aboutData = new KAboutData("kscreenlocker", i18n("Lock Screen configuration"), "1.0"); | ||||
66 | setAboutData(aboutData); | ||||
67 | setNeedsAuthorization(true); | ||||
68 | | ||||
63 | qmlRegisterType<QStandardItemModel>(); | 69 | qmlRegisterType<QStandardItemModel>(); | ||
64 | KConfigDialogManager::changedMap()->insert(QStringLiteral("SelectImageButton"), SIGNAL(imagePathChanged(QString))); | 70 | KConfigDialogManager::changedMap()->insert(QStringLiteral("SelectImageButton"), SIGNAL(imagePathChanged(QString))); | ||
65 | 71 | | |||
66 | QVBoxLayout* layout = new QVBoxLayout(this); | 72 | QVBoxLayout* layout = new QVBoxLayout(this); | ||
67 | layout->addWidget(m_ui); | 73 | layout->addWidget(m_ui); | ||
68 | 74 | | |||
69 | addConfig(KScreenSaverSettings::self(), m_ui); | 75 | addConfig(KScreenSaverSettings::self(), m_ui); | ||
70 | 76 | | |||
▲ Show 20 Lines • Show All 129 Lines • ▼ Show 20 Line(s) | |||||
200 | { | 206 | { | ||
201 | if (!shouldSaveShortcut()) { | 207 | if (!shouldSaveShortcut()) { | ||
202 | QMetaObject::invokeMethod(this, "changed", Qt::QueuedConnection); | 208 | QMetaObject::invokeMethod(this, "changed", Qt::QueuedConnection); | ||
203 | return; | 209 | return; | ||
204 | } | 210 | } | ||
205 | KCModule::save(); | 211 | KCModule::save(); | ||
206 | 212 | | |||
207 | KScreenSaverSettings::setTheme(m_selectedPlugin); | 213 | KScreenSaverSettings::setTheme(m_selectedPlugin); | ||
208 | | ||||
209 | KScreenSaverSettings::self()->save(); | | |||
210 | if (m_ui->lockscreenShortcut->property("changed").toBool()) { | 214 | if (m_ui->lockscreenShortcut->property("changed").toBool()) { | ||
211 | if (QAction *a = m_actionCollection->action(s_lockActionName)) { | 215 | if (QAction *a = m_actionCollection->action(s_lockActionName)) { | ||
212 | KGlobalAccel::self()->setShortcut(a, QList<QKeySequence>{m_ui->lockscreenShortcut->keySequence()}, KGlobalAccel::NoAutoloading); | 216 | KGlobalAccel::self()->setShortcut(a, QList<QKeySequence>{m_ui->lockscreenShortcut->keySequence()}, KGlobalAccel::NoAutoloading); | ||
213 | m_actionCollection->writeSettings(); | 217 | m_actionCollection->writeSettings(); | ||
214 | } | 218 | } | ||
215 | m_ui->lockscreenShortcut->setProperty("changed", false); | 219 | m_ui->lockscreenShortcut->setProperty("changed", false); | ||
216 | } | 220 | } | ||
221 | | ||||
222 | KAuth::Action saveAction = authAction(); | ||||
223 | | ||||
224 | auto config = KScreenSaverSettings::self()->sharedConfig(); | ||||
225 | | ||||
226 | QVariantMap args({ | ||||
227 | {QStringLiteral("path"), QVariant(QStandardPaths::writableLocation(config->locationType()))}, | ||||
228 | {QStringLiteral("Autolock"), QVariant(KScreenSaverSettings::self()->autolock())}, | ||||
229 | {QStringLiteral("Timeout"), QVariant(KScreenSaverSettings::self()->timeout())}, | ||||
230 | {QStringLiteral("Lock"), QVariant(KScreenSaverSettings::self()->lock())}, | ||||
231 | {QStringLiteral("LockGrace"), QVariant(KScreenSaverSettings::self()->lockGrace())}, | ||||
232 | {QStringLiteral("LockOnResume"), QVariant(KScreenSaverSettings::self()->lockOnResume())}, | ||||
233 | {QStringLiteral("Theme"), QVariant(KScreenSaverSettings::self()->theme())}, | ||||
234 | {QStringLiteral("ThemeBackground"), QVariant(KScreenSaverSettings::self()->themeBackground())} | ||||
235 | }); | ||||
236 | saveAction.setHelperId("org.kde.kcontrol.kscreenlocker"); | ||||
237 | saveAction.setArguments(args); | ||||
238 | | ||||
239 | auto job = saveAction.execute(); | ||||
240 | job->exec(); | ||||
241 | | ||||
242 | if (job->error()){ | ||||
243 | qDebug() << "Save Failed"; | ||||
244 | qDebug() << job->errorString(); | ||||
245 | qDebug() << job->errorText(); | ||||
246 | } else { | ||||
247 | changed(false); | ||||
248 | qDebug() << "Option saved"; | ||||
249 | } | ||||
250 | | ||||
217 | // reconfigure through DBus | 251 | // reconfigure through DBus | ||
218 | OrgKdeScreensaverInterface interface(QStringLiteral("org.kde.screensaver"), | 252 | OrgKdeScreensaverInterface interface(QStringLiteral("org.kde.screensaver"), | ||
219 | QStringLiteral("/ScreenSaver"), | 253 | QStringLiteral("/ScreenSaver"), | ||
220 | QDBusConnection::sessionBus()); | 254 | QDBusConnection::sessionBus()); | ||
221 | if (interface.isValid()) { | 255 | if (interface.isValid()) { | ||
222 | interface.configure(); | 256 | interface.configure(); | ||
223 | } | 257 | } | ||
224 | } | 258 | } | ||
Show All 29 Lines |