Changeset View
Changeset View
Standalone View
Standalone View
src/advancedconfig.cpp
Show First 20 Lines • Show All 142 Lines • ▼ Show 20 Line(s) | 142 | { | |||
---|---|---|---|---|---|
143 | if (minUid < 0 || minUid > maxUid) | 143 | if (minUid < 0 || minUid > maxUid) | ||
144 | return false; | 144 | return false; | ||
145 | 145 | | |||
146 | return true; | 146 | return true; | ||
147 | } | 147 | } | ||
148 | 148 | | |||
149 | void AdvancedConfig::syncSettingsChanged() | 149 | void AdvancedConfig::syncSettingsChanged() | ||
150 | { | 150 | { | ||
151 | // initial check for sddm user; abort if user not present | ||||
152 | // we have to check with QString and isEmpty() instead of QDir and exists() because | ||||
153 | // QDir returns "." and true for exists() in the case of a non-existent user; | ||||
154 | QString sddmHomeDirPath = KUser("sddm").homeDir(); | ||||
155 | if (sddmHomeDirPath.isEmpty()) { | ||||
156 | KMessageBox::error(this, QStringLiteral("Cannot proceed, user 'sddm' does not exist. Please check your SDDM install.")); | ||||
157 | return; | ||||
158 | } | ||||
159 | | ||||
151 | // read Plasma values | 160 | // read Plasma values | ||
152 | KConfig cursorConfig(QStringLiteral("kcminputrc")); | 161 | KConfig cursorConfig(QStringLiteral("kcminputrc")); | ||
153 | KConfigGroup cursorConfigGroup(&cursorConfig, "Mouse"); | 162 | KConfigGroup cursorConfigGroup(&cursorConfig, "Mouse"); | ||
154 | QVariant cursorTheme = cursorConfigGroup.readEntry("cursorTheme", QString()); | 163 | QVariant cursorTheme = cursorConfigGroup.readEntry("cursorTheme", QString()); | ||
155 | 164 | | |||
156 | KConfig dpiConfig(QStringLiteral("kcmfonts")); | 165 | KConfig dpiConfig(QStringLiteral("kcmfonts")); | ||
157 | KConfigGroup dpiConfigGroup(&dpiConfig, "General"); | 166 | KConfigGroup dpiConfigGroup(&dpiConfig, "General"); | ||
158 | QString dpiValue = dpiConfigGroup.readEntry("forceFontDPI"); | 167 | QString dpiValue = dpiConfigGroup.readEntry("forceFontDPI"); | ||
159 | QString dpiArgument = QStringLiteral("-dpi ") + dpiValue; | 168 | QString dpiArgument = QStringLiteral("-dpi ") + dpiValue; | ||
160 | 169 | | |||
161 | KConfig numLockConfig(QStringLiteral("kcminputrc")); | 170 | KConfig numLockConfig(QStringLiteral("kcminputrc")); | ||
162 | KConfigGroup numLockConfigGroup(&numLockConfig, "Keyboard"); | 171 | KConfigGroup numLockConfigGroup(&numLockConfig, "Keyboard"); | ||
163 | QString numLock = numLockConfigGroup.readEntry("NumLock"); | 172 | QString numLock = numLockConfigGroup.readEntry("NumLock"); | ||
164 | 173 | | |||
165 | // define paths | 174 | // define paths | ||
166 | const QString fontconfigPath = QStandardPaths::locate(QStandardPaths::GenericConfigLocation, QStringLiteral("fontconfig"), QStandardPaths::LocateDirectory); | 175 | const QString fontconfigPath = QStandardPaths::locate(QStandardPaths::GenericConfigLocation, QStringLiteral("fontconfig"), QStandardPaths::LocateDirectory); | ||
167 | const QString kdeglobalsPath = QStandardPaths::locate(QStandardPaths::GenericConfigLocation, QStringLiteral("kdeglobals")); | 176 | const QString kdeglobalsPath = QStandardPaths::locate(QStandardPaths::GenericConfigLocation, QStringLiteral("kdeglobals")); | ||
168 | const QString plasmarcPath = QStandardPaths::locate(QStandardPaths::GenericConfigLocation, QStringLiteral("plasmarc")); | 177 | const QString plasmarcPath = QStandardPaths::locate(QStandardPaths::GenericConfigLocation, QStringLiteral("plasmarc")); | ||
169 | const QString sddmUserConfigPath = KUser("sddm").homeDir() + QStringLiteral("/.config"); | | |||
170 | 178 | | |||
171 | // send values and paths to helper, debug if it fails | 179 | // send values and paths to helper, debug if it fails | ||
172 | QVariantMap args; | 180 | QVariantMap args; | ||
173 | 181 | | |||
174 | args[QStringLiteral("kde_settings.conf")] = QString {QLatin1String(SDDM_CONFIG_DIR "/") + QStringLiteral("kde_settings.conf")}; | 182 | args[QStringLiteral("kde_settings.conf")] = QString {QLatin1String(SDDM_CONFIG_DIR "/") + QStringLiteral("kde_settings.conf")}; | ||
175 | 183 | | |||
176 | args[QStringLiteral("sddm.conf")] = QLatin1String(SDDM_CONFIG_FILE); | 184 | args[QStringLiteral("sddm.conf")] = QLatin1String(SDDM_CONFIG_FILE); | ||
177 | 185 | | |||
▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Line(s) | |||||
220 | 228 | | |||
221 | if (!plasmarcPath.isEmpty()) { | 229 | if (!plasmarcPath.isEmpty()) { | ||
222 | args[QStringLiteral("plasmarc")] = plasmarcPath; | 230 | args[QStringLiteral("plasmarc")] = plasmarcPath; | ||
223 | } | 231 | } | ||
224 | else { | 232 | else { | ||
225 | qDebug() << "Cannot find plasmarc file."; | 233 | qDebug() << "Cannot find plasmarc file."; | ||
226 | } | 234 | } | ||
227 | 235 | | |||
228 | if (!sddmUserConfigPath.isEmpty()) { | | |||
229 | args[QStringLiteral("sddmUserConfig")] = sddmUserConfigPath; | | |||
230 | } | | |||
231 | else { | | |||
232 | qDebug() << "Cannot find SDDM user directory."; | | |||
233 | } | | |||
234 | | ||||
235 | KAuth::Action syncAction(QStringLiteral("org.kde.kcontrol.kcmsddm.sync")); | 236 | KAuth::Action syncAction(QStringLiteral("org.kde.kcontrol.kcmsddm.sync")); | ||
236 | syncAction.setHelperId(QStringLiteral("org.kde.kcontrol.kcmsddm")); | 237 | syncAction.setHelperId(QStringLiteral("org.kde.kcontrol.kcmsddm")); | ||
237 | syncAction.setArguments(args); | 238 | syncAction.setArguments(args); | ||
238 | 239 | | |||
239 | auto job = syncAction.execute(); | 240 | auto job = syncAction.execute(); | ||
240 | job->exec(); | 241 | job->exec(); | ||
241 | 242 | | |||
242 | if (job->error()){ | 243 | if (job->error()){ | ||
243 | qDebug() << "Synchronization failed"; | 244 | qDebug() << "Synchronization failed"; | ||
244 | qDebug() << job->errorString(); | 245 | qDebug() << job->errorString(); | ||
245 | qDebug() << job->errorText(); | 246 | qDebug() << job->errorText(); | ||
246 | KMessageBox::error(this, job->errorText()); | 247 | KMessageBox::error(this, job->errorText()); | ||
247 | } else { | 248 | } else { | ||
248 | changed(false); | 249 | changed(false); | ||
249 | qDebug() << "Synchronization successful"; | 250 | qDebug() << "Synchronization successful"; | ||
250 | } | 251 | } | ||
251 | } | 252 | } | ||
252 | 253 | | |||
253 | void AdvancedConfig::resetSettingsChanged() | 254 | void AdvancedConfig::resetSettingsChanged() | ||
254 | { | 255 | { | ||
255 | // define paths | 256 | // initial check for sddm user; abort if user not present | ||
256 | const QString sddmUserConfigPath = KUser("sddm").homeDir() + QStringLiteral("/.config"); | 257 | // we have to check with QString and isEmpty() instead of QDir and exists() because | ||
258 | // QDir returns "." and true for exists() in the case of a non-existent user | ||||
259 | QString sddmHomeDirPath = KUser("sddm").homeDir(); | ||||
260 | if (sddmHomeDirPath.isEmpty()) { | ||||
261 | KMessageBox::error(this, QStringLiteral("Cannot proceed, user 'sddm' does not exist. Please check your SDDM install.")); | ||||
262 | return; | ||||
263 | } | ||||
257 | 264 | | |||
258 | // send paths to helper | 265 | // send paths to helper | ||
259 | QVariantMap args; | 266 | QVariantMap args; | ||
260 | 267 | | |||
261 | args[QStringLiteral("sddmUserConfig")] = sddmUserConfigPath; | | |||
262 | | ||||
263 | args[QStringLiteral("kde_settings.conf")] = QString {QLatin1String(SDDM_CONFIG_DIR "/") + QStringLiteral("kde_settings.conf")}; | 268 | args[QStringLiteral("kde_settings.conf")] = QString {QLatin1String(SDDM_CONFIG_DIR "/") + QStringLiteral("kde_settings.conf")}; | ||
264 | 269 | | |||
265 | args[QStringLiteral("sddm.conf")] = QLatin1String(SDDM_CONFIG_FILE); | 270 | args[QStringLiteral("sddm.conf")] = QLatin1String(SDDM_CONFIG_FILE); | ||
266 | 271 | | |||
267 | args[QStringLiteral("sddmUserConfig")] = sddmUserConfigPath; | | |||
268 | | ||||
269 | args[QStringLiteral("kde_settings.conf/Theme/CursorTheme")] = QVariant(); | 272 | args[QStringLiteral("kde_settings.conf/Theme/CursorTheme")] = QVariant(); | ||
270 | 273 | | |||
271 | args[QStringLiteral("kde_settings.conf/X11/ServerArguments")] = QVariant(); | 274 | args[QStringLiteral("kde_settings.conf/X11/ServerArguments")] = QVariant(); | ||
272 | 275 | | |||
273 | args[QStringLiteral("kde_settings.conf/General/Numlock")] = QVariant(); | 276 | args[QStringLiteral("kde_settings.conf/General/Numlock")] = QVariant(); | ||
274 | 277 | | |||
275 | KAuth::Action resetAction(QStringLiteral("org.kde.kcontrol.kcmsddm.reset")); | 278 | KAuth::Action resetAction(QStringLiteral("org.kde.kcontrol.kcmsddm.reset")); | ||
276 | resetAction.setHelperId(QStringLiteral("org.kde.kcontrol.kcmsddm")); | 279 | resetAction.setHelperId(QStringLiteral("org.kde.kcontrol.kcmsddm")); | ||
Show All 15 Lines |