diff --git a/src/advanceconfig.cpp b/src/advanceconfig.cpp index 4588e99..e9b9d18 100644 --- a/src/advanceconfig.cpp +++ b/src/advanceconfig.cpp @@ -1,163 +1,163 @@ /* Copyright 2013 by Reza Fatahilah Shah This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ #include "advanceconfig.h" #include "ui_advanceconfig.h" #include #include #include #include #include "usersmodel.h" #include "sessionmodel.h" #include "config.h" #include "cursortheme/thememodel.h" #include "cursortheme/sortproxymodel.h" #include "cursortheme/cursortheme.h" const int MIN_UID = 1000; const int MAX_UID = 60000; AdvanceConfig::AdvanceConfig(const KSharedConfigPtr &config, QWidget *parent) : QWidget(parent), mConfig(config) { configUi = new Ui::AdvanceConfig(); configUi->setupUi(this); load(); connect(configUi->userList, SIGNAL(activated(int)), SIGNAL(changed())); connect(configUi->sessionList, SIGNAL(activated(int)), SIGNAL(changed())); connect(configUi->haltCommand, SIGNAL(textChanged(QString)), SIGNAL(changed())); connect(configUi->rebootCommand, SIGNAL(textChanged(QString)), SIGNAL(changed())); connect(configUi->cursorList, SIGNAL(activated(int)), SIGNAL(changed())); connect(configUi->minimumUid, SIGNAL(textChanged(QString)), SIGNAL(changed())); connect(configUi->minimumUid, &QLineEdit::textChanged, this, &AdvanceConfig::slotUidRangeChanged); connect(configUi->maximumUid, SIGNAL(textChanged(QString)), SIGNAL(changed())); connect(configUi->maximumUid, &QLineEdit::textChanged, this, &AdvanceConfig::slotUidRangeChanged); - // manually emit changed signal since QGroupBox::clicked will pass false to changed() when unchecked - connect(configUi->autoLogin, &QGroupBox::clicked, this, [this] { emit changed(); }); + // manually emit changed signal since QCheckBox::clicked will pass false to changed() when unchecked + connect(configUi->autoLogin, &QCheckBox::clicked, this, [this] { emit changed(); }); connect(configUi->reloginAfterQuit, &QAbstractButton::clicked, this, [this] { emit changed(); }); } AdvanceConfig::~AdvanceConfig() { delete configUi; } void AdvanceConfig::load() { //Cursor themes CursorThemeModel *cursorModel = new CursorThemeModel(this); proxyCursorModel = new SortProxyModel(this); proxyCursorModel->setSourceModel(cursorModel); proxyCursorModel->setFilterCaseSensitivity(Qt::CaseSensitive); proxyCursorModel->sort(Qt::DisplayRole, Qt::AscendingOrder); configUi->cursorList->setModel(proxyCursorModel); QString currentCursor = mConfig->group("Theme").readEntry("CursorTheme", ""); QModelIndex cursorIndex = proxyCursorModel->findIndex(currentCursor); configUi->cursorList->setCurrentIndex(cursorIndex.row() < 0 ? 0 : cursorIndex.row()); //User list int minUid, maxUid; minUid = mConfig->group("Users").readEntry("MinimumUid", MIN_UID); maxUid = mConfig->group("Users").readEntry("MaximumUid", MAX_UID); userModel = new UsersModel(this); configUi->userList->setModel(userModel); userModel->populate( minUid, maxUid ); sessionModel = new SessionModel(this); configUi->sessionList->setModel(sessionModel); const QString currentUser = mConfig->group("Autologin").readEntry("User", ""); configUi->userList->setCurrentIndex(userModel->indexOf(currentUser)); const QString autologinSession = mConfig->group("Autologin").readEntry("Session", ""); configUi->sessionList->setCurrentIndex(sessionModel->indexOf(autologinSession)); configUi->autoLogin->setChecked(!currentUser.isEmpty()); configUi->reloginAfterQuit->setChecked(mConfig->group("Autologin").readEntry("Relogin", false)); QValidator *uidValidator = new QIntValidator(MIN_UID, MAX_UID, configUi->minimumUid); configUi->minimumUid->setValidator(uidValidator); configUi->minimumUid->setText(QString::number(minUid)); configUi->maximumUid->setValidator(uidValidator); configUi->maximumUid->setText(QString::number(maxUid)); //Commands configUi->haltCommand->setUrl(QUrl::fromLocalFile(mConfig->group("General").readEntry("HaltCommand"))); configUi->rebootCommand->setUrl(QUrl::fromLocalFile(mConfig->group("General").readEntry("RebootCommand"))); } QVariantMap AdvanceConfig::save() { QVariantMap args; qDebug() << "idx:" << configUi->cursorList->currentIndex(); QModelIndex cursorIndex = configUi->cursorList->model()->index(configUi->cursorList->currentIndex(),0); if (cursorIndex.isValid()) { const CursorTheme *cursorTheme = proxyCursorModel->theme(cursorIndex); if (cursorTheme) args[QStringLiteral("sddm.conf/Theme/CursorTheme")] = cursorTheme->name(); } args[QStringLiteral("sddm.conf/Autologin/User")] = ( configUi->autoLogin->isChecked() ) ? configUi->userList->currentText() : QString(); args[QStringLiteral("sddm.conf/Autologin/Session")] = ( configUi->autoLogin->isChecked() ) ? configUi->sessionList->currentData() : QString(); args[QStringLiteral("sddm.conf/Autologin/Relogin")] = configUi->reloginAfterQuit->isChecked(); //TODO session int minUid = configUi->minimumUid->text().toInt(); int maxUid = configUi->maximumUid->text().toInt(); if (isUidRangeValid(minUid, maxUid)) { args[QStringLiteral("sddm.conf/Users/MinimumUid")] = configUi->minimumUid->text(); args[QStringLiteral("sddm.conf/Users/MaximumUid")] = configUi->maximumUid->text(); } args[QStringLiteral("sddm.conf/General/HaltCommand")] = configUi->haltCommand->url().toLocalFile(); args[QStringLiteral("sddm.conf/General/RebootCommand")] = configUi->rebootCommand->url().toLocalFile(); return args; } void AdvanceConfig::slotUidRangeChanged() { int minUid = configUi->minimumUid->text().toInt(); int maxUid = configUi->maximumUid->text().toInt(); if (!isUidRangeValid(minUid, maxUid)) { return; } userModel->populate(minUid, maxUid); } bool AdvanceConfig::isUidRangeValid(int minUid, int maxUid) const { if (minUid < 0 || minUid > maxUid) return false; return true; } diff --git a/src/ui/advanceconfig.ui b/src/ui/advanceconfig.ui index 7fe00b1..2007828 100644 --- a/src/ui/advanceconfig.ui +++ b/src/ui/advanceconfig.ui @@ -1,199 +1,294 @@ AdvanceConfig 0 0 - 620 - 452 + 500 + 326 - - - General + + + QFormLayout::FieldsStayAtSizeHint - - - - - Cursor Theme: - - - - - - - - - - - - - Auto &Login - - - true - - - false - - - - QFormLayout::ExpandingFieldsGrow - - - - - User: - - - - - - - - - - Session: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - - Relogin after quit - - - - - - - - - - - - - - 0 - 0 - - - - User - - - - - - Minimum UID: - - - - - - - - 0 - 0 - - - - 6 - - - - - - - Maximum UID: - - - - - - - - 0 - 0 - - - - 6 - - - - - - - - - - - 0 - 0 - - - - Commands - - - - - - Halt Command: - - - - - - - - - - Reboot Command: - - - - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - + + Qt::AlignHCenter|Qt::AlignTop - + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + as user: + + + + + + + false + + + + + + + false + + + with session: + + + + + + + false + + + + + + + + + false + + + + 0 + 0 + + + + Log in again immediately after logging off + + + + + + + Minimum user UID: + + + + + + + + 0 + 0 + + + + 6 + + + + + + + Maximum user UID: + + + + + + + + 0 + 0 + + + + 6 + + + + + + + Halt command: + + + + + + + + 250 + 0 + + + + + + + + Reboot command: + + + + + + + + 250 + 0 + + + + + + + + Automatically log in: + + + + + + + + + + Cursor theme: + + + + + + + Qt::Vertical + + + + 8 + 8 + + + + + + + + Qt::Vertical + + + + 8 + 8 + + + + + + + + Qt::Vertical + + + + 8 + 8 + + + + + KUrlRequester QWidget
kurlrequester.h
1
- + + + autoLogin + toggled(bool) + userList + setEnabled(bool) + + + 212 + 37 + + + 274 + 32 + + + + + autoLogin + toggled(bool) + label_4 + setEnabled(bool) + + + 207 + 22 + + + 363 + 37 + + + + + autoLogin + toggled(bool) + sessionList + setEnabled(bool) + + + 186 + 21 + + + 435 + 25 + + + + + autoLogin + toggled(bool) + reloginAfterQuit + setEnabled(bool) + + + 222 + 22 + + + 214 + 59 + + + +