Changeset View
Changeset View
Standalone View
Standalone View
src/advanceconfig.cpp
Show All 11 Lines | 1 | /* | |||
---|---|---|---|---|---|
12 | GNU General Public License for more details. | 12 | GNU General Public License for more details. | ||
13 | 13 | | |||
14 | You should have received a copy of the GNU General Public License | 14 | You should have received a copy of the GNU General Public License | ||
15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
16 | */ | 16 | */ | ||
17 | #include "advanceconfig.h" | 17 | #include "advanceconfig.h" | ||
18 | #include "ui_advanceconfig.h" | 18 | #include "ui_advanceconfig.h" | ||
19 | 19 | | |||
20 | #include <QDebug> | ||||
20 | #include <QIntValidator> | 21 | #include <QIntValidator> | ||
22 | #include <QStandardPaths> | ||||
21 | 23 | | |||
22 | #include <QDebug> | 24 | #include <KAuth/KAuthActionReply> | ||
25 | #include <kauthexecutejob.h> | ||||
23 | #include <KConfigGroup> | 26 | #include <KConfigGroup> | ||
27 | #include <KCModule> | ||||
24 | #include <KUser> | 28 | #include <KUser> | ||
25 | 29 | | |||
26 | #include "usersmodel.h" | | |||
27 | #include "sessionmodel.h" | | |||
28 | #include "config.h" | 30 | #include "config.h" | ||
29 | #include "cursortheme/thememodel.h" | | |||
30 | #include "cursortheme/sortproxymodel.h" | | |||
31 | #include "cursortheme/cursortheme.h" | 31 | #include "cursortheme/cursortheme.h" | ||
32 | #include "cursortheme/sortproxymodel.h" | ||||
33 | #include "cursortheme/thememodel.h" | ||||
34 | #include "sessionmodel.h" | ||||
35 | #include "usersmodel.h" | ||||
32 | 36 | | |||
33 | const int MIN_UID = 1000; | 37 | const int MIN_UID = 1000; | ||
34 | const int MAX_UID = 60000; | 38 | const int MAX_UID = 60000; | ||
35 | 39 | | |||
36 | AdvanceConfig::AdvanceConfig(const KSharedConfigPtr &config, QWidget *parent) : | 40 | AdvanceConfig::AdvanceConfig(const KSharedConfigPtr &config, QWidget *parent) : | ||
davidedmundson: we ended up not needing to access KCModule from this class | |||||
37 | QWidget(parent), | 41 | QWidget(parent), | ||
38 | mConfig(config) | 42 | mConfig(config) | ||
43 | | ||||
39 | { | 44 | { | ||
40 | configUi = new Ui::AdvanceConfig(); | 45 | configUi = new Ui::AdvanceConfig(); | ||
41 | configUi->setupUi(this); | 46 | configUi->setupUi(this); | ||
47 | configUi->syncExplanation->setFont(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont)); | ||||
42 | 48 | | |||
43 | load(); | 49 | load(); | ||
44 | 50 | | |||
45 | connect(configUi->userList, SIGNAL(activated(int)), SIGNAL(changed())); | 51 | connect(configUi->userList, SIGNAL(activated(int)), SIGNAL(changed())); | ||
46 | connect(configUi->sessionList, SIGNAL(activated(int)), SIGNAL(changed())); | 52 | connect(configUi->sessionList, SIGNAL(activated(int)), SIGNAL(changed())); | ||
47 | connect(configUi->haltCommand, SIGNAL(textChanged(QString)), SIGNAL(changed())); | 53 | connect(configUi->haltCommand, SIGNAL(textChanged(QString)), SIGNAL(changed())); | ||
48 | connect(configUi->rebootCommand, SIGNAL(textChanged(QString)), SIGNAL(changed())); | 54 | connect(configUi->rebootCommand, SIGNAL(textChanged(QString)), SIGNAL(changed())); | ||
49 | connect(configUi->cursorList, SIGNAL(activated(int)), SIGNAL(changed())); | 55 | connect(configUi->cursorList, SIGNAL(activated(int)), SIGNAL(changed())); | ||
50 | connect(configUi->minimumUid, SIGNAL(textChanged(QString)), SIGNAL(changed())); | 56 | connect(configUi->minimumUid, SIGNAL(textChanged(QString)), SIGNAL(changed())); | ||
51 | connect(configUi->minimumUid, &QLineEdit::textChanged, this, &AdvanceConfig::slotUidRangeChanged); | 57 | connect(configUi->minimumUid, &QLineEdit::textChanged, this, &AdvanceConfig::slotUidRangeChanged); | ||
52 | connect(configUi->maximumUid, SIGNAL(textChanged(QString)), SIGNAL(changed())); | 58 | connect(configUi->maximumUid, SIGNAL(textChanged(QString)), SIGNAL(changed())); | ||
53 | connect(configUi->maximumUid, &QLineEdit::textChanged, this, &AdvanceConfig::slotUidRangeChanged); | 59 | connect(configUi->maximumUid, &QLineEdit::textChanged, this, &AdvanceConfig::slotUidRangeChanged); | ||
54 | 60 | | |||
55 | // manually emit changed signal since QCheckBox::clicked will pass false to changed() when unchecked | 61 | // manually emit changed signal since QCheckBox::clicked will pass false to changed() when unchecked | ||
56 | connect(configUi->autoLogin, &QCheckBox::clicked, this, [this] { emit changed(); }); | 62 | connect(configUi->autoLogin, &QCheckBox::clicked, this, [this] { emit changed(); }); | ||
57 | connect(configUi->reloginAfterQuit, &QAbstractButton::clicked, this, [this] { emit changed(); }); | 63 | connect(configUi->reloginAfterQuit, &QAbstractButton::clicked, this, [this] { emit changed(); }); | ||
64 | | ||||
65 | connect(configUi->syncSettings, &QPushButton::clicked, this, &AdvanceConfig::syncSettingsChanged); | ||||
66 | connect(configUi->resetSettings, &QPushButton::clicked, this, &AdvanceConfig::resetSettingsChanged); | ||||
58 | } | 67 | } | ||
59 | 68 | | |||
60 | AdvanceConfig::~AdvanceConfig() | 69 | AdvanceConfig::~AdvanceConfig() | ||
61 | { | 70 | { | ||
62 | delete configUi; | 71 | delete configUi; | ||
63 | } | 72 | } | ||
64 | 73 | | |||
65 | void AdvanceConfig::load() | 74 | void AdvanceConfig::load() | ||
▲ Show 20 Lines • Show All 90 Lines • ▼ Show 20 Line(s) | |||||
156 | 165 | | |||
157 | bool AdvanceConfig::isUidRangeValid(int minUid, int maxUid) const | 166 | bool AdvanceConfig::isUidRangeValid(int minUid, int maxUid) const | ||
158 | { | 167 | { | ||
159 | if (minUid < 0 || minUid > maxUid) | 168 | if (minUid < 0 || minUid > maxUid) | ||
160 | return false; | 169 | return false; | ||
161 | 170 | | |||
162 | return true; | 171 | return true; | ||
163 | } | 172 | } | ||
173 | | ||||
174 | void AdvanceConfig::syncSettingsChanged() | ||||
175 | { | ||||
176 | const QString fontconfigPath = QStandardPaths::locate(QStandardPaths::GenericConfigLocation, QStringLiteral("fontconfig"), QStandardPaths::LocateDirectory); | ||||
177 | const QString kdeglobalsPath = QStandardPaths::locate(QStandardPaths::GenericConfigLocation, QStringLiteral("kdeglobals")); | ||||
178 | const QString plasmarcPath = QStandardPaths::locate(QStandardPaths::GenericConfigLocation, QStringLiteral("plasmarc")); | ||||
179 | const QString sddmUserConfigPath = KUser("sddm").homeDir() + QStringLiteral("/.config"); | ||||
180 | | ||||
181 | if (fontconfigPath.isEmpty()) { | ||||
If it's empty, you print a message, which is fine, but then we still add an empty entry to our map, and still try to copy the file? davidedmundson: If it's empty, you print a message, which is fine, but then we still add an empty entry to our… | |||||
Should I just bring back the code that only does the copy operation if the entry is not empty or would it also be good to not even add the entry to the map if there is no file/folder? filipf: Should I just bring back the code that only does the copy operation if the entry is not empty… | |||||
filipf: I brought back the old code in sddmauthhelper.cpp | |||||
182 | qDebug() << "fontconfig folder not found"; | ||||
183 | } | ||||
184 | if (kdeglobalsPath.isEmpty()) { | ||||
185 | qDebug() << "kdeglobals file not found"; | ||||
186 | } | ||||
187 | if (plasmarcPath.isEmpty()) { | ||||
188 | qDebug() << "plasmarc file not found"; | ||||
189 | } | ||||
190 | | ||||
191 | QVariantMap args; | ||||
192 | args[QStringLiteral("fontconfig")] = fontconfigPath; | ||||
193 | args[QStringLiteral("kdeglobals")] = kdeglobalsPath; | ||||
194 | args[QStringLiteral("plasmarc")] = plasmarcPath; | ||||
195 | args[QStringLiteral("sddmUserConfig")] = sddmUserConfigPath; | ||||
196 | | ||||
197 | KAuth::Action syncAction(QStringLiteral("org.kde.kcontrol.kcmsddm.sync")); | ||||
198 | syncAction.setHelperId(QStringLiteral("org.kde.kcontrol.kcmsddm")); | ||||
199 | syncAction.setArguments(args); | ||||
200 | | ||||
201 | auto job = syncAction.execute(); | ||||
202 | job->exec(); | ||||
203 | | ||||
204 | if (job->error()){ | ||||
205 | qDebug() << "Synchronization failed"; | ||||
206 | qDebug() << job->errorString(); | ||||
207 | qDebug() << job->errorText(); | ||||
208 | } else { | ||||
"Synchronization failed." is a pretty frustrating error message. The user will wonder, "How did it fail? What happened? How can I fix it?" etc. Since we have the error text, let's show it in the message box, since it could provide some clues. ngraham: "Synchronization failed." is a pretty frustrating error message. The user will wonder, "How did… | |||||
209 | changed(false); | ||||
210 | //syncStatus->setText(i18n("synced")); | ||||
211 | qDebug() << "Synchronization successful"; | ||||
212 | } | ||||
I don't think we need a dialog box for the success case. That'll just annoy people. ngraham: I don't think we need a dialog box for the success case. That'll just annoy people. | |||||
213 | } | ||||
214 | | ||||
215 | void AdvanceConfig::resetSettingsChanged() | ||||
216 | { | ||||
217 | const QString sddmUserConfigPath = KUser("sddm").homeDir() + QStringLiteral("/.config"); | ||||
218 | | ||||
219 | QVariantMap args; | ||||
220 | args[QStringLiteral("sddmUserConfig")] = sddmUserConfigPath; | ||||
221 | | ||||
222 | KAuth::Action resetAction(QStringLiteral("org.kde.kcontrol.kcmsddm.reset")); | ||||
223 | resetAction.setHelperId(QStringLiteral("org.kde.kcontrol.kcmsddm")); | ||||
224 | resetAction.setArguments(args); | ||||
225 | | ||||
226 | auto job = resetAction.execute(); | ||||
227 | job->exec(); | ||||
228 | | ||||
229 | if (job->error()){ | ||||
230 | qDebug() << "Reset failed"; | ||||
231 | qDebug() << job->errorString(); | ||||
232 | qDebug() << job->errorText(); | ||||
233 | } else { | ||||
234 | changed(false); | ||||
235 | qDebug() << "Reset successful"; | ||||
236 | } | ||||
237 | } |
we ended up not needing to access KCModule from this class