SVN commit 1208946 by nlecureuil: Show indication that Lock/Logout widget settings were not saved BUG: 256879 http://reviewboard.kde.org/r/6041/ M +81 -30 lockout.cpp M +3 -0 lockout.h --- trunk/KDE/kdebase/workspace/plasma/generic/applets/lock_logout/lockout.cpp #1208945:1208946 @@ -53,7 +53,13 @@ static const int MARGINSIZE = 1; LockOut::LockOut(QObject *parent, const QVariantList &args) - : Plasma::Applet(parent, args), m_iconLock(0), m_iconSwitchUser(0), m_iconLogout(0), m_iconSleep(0), m_iconHibernate(0) + : Plasma::Applet(parent, args), + m_iconLock(0), + m_iconSwitchUser(0), + m_iconLogout(0), + m_iconSleep(0), + m_iconHibernate(0), + m_changed(false) { #ifndef Q_OS_WIN setHasConfigurationInterface(true); @@ -92,7 +98,65 @@ } showButtons(); } +void LockOut::buttonChanged() +{ + if (m_showLockButton != ui.checkBox_lock->isChecked()) { + m_showLockButton = !m_showLockButton; + m_changed = true; + } + if (m_showSwitchUserButton != ui.checkBox_switchUser->isChecked()) { + m_showSwitchUserButton = !m_showSwitchUserButton; + m_changed = true; + } + + if (m_showLogoutButton != ui.checkBox_logout->isChecked()) { + m_showLogoutButton = !m_showLogoutButton; + m_changed = true; + } + + if (m_showSleepButton != ui.checkBox_sleep->isChecked()) { + m_showSleepButton = !m_showSleepButton; + m_changed = true; + } + + if (m_showHibernateButton != ui.checkBox_hibernate->isChecked()) { + m_showHibernateButton = !m_showHibernateButton; + m_changed = true; + } + + setCheckable(); +} +void LockOut::setCheckable() +{ + countButtons(); + if (m_visibleButtons == 1) { + if (ui.checkBox_lock->isChecked()) { + ui.checkBox_lock->setEnabled(false); + } + if (ui.checkBox_switchUser->isChecked()) { + ui.checkBox_switchUser->setEnabled(false); + } + if (ui.checkBox_logout->isChecked()) { + ui.checkBox_logout->setEnabled(false); + } + if (ui.checkBox_sleep->isChecked()) { + ui.checkBox_sleep->setEnabled(false); + } + if(ui.checkBox_hibernate->isChecked()) { + ui.checkBox_hibernate->setEnabled(false); + } + } + + if (m_visibleButtons > 1) { + ui.checkBox_lock->setEnabled(true); + ui.checkBox_switchUser->setEnabled(true); + ui.checkBox_logout->setEnabled(true); + ui.checkBox_sleep->setEnabled(true); + ui.checkBox_hibernate->setEnabled(true); + } +} + void LockOut::countButtons() { m_visibleButtons = 0; @@ -270,35 +334,8 @@ void LockOut::configAccepted() { #ifndef Q_OS_WIN - bool changed = false; KConfigGroup cg = config(); - - if (m_showLockButton != ui.checkBox_lock->isChecked()) { - m_showLockButton = !m_showLockButton; - changed = true; - } - - if (m_showSwitchUserButton != ui.checkBox_switchUser->isChecked()) { - m_showSwitchUserButton = !m_showSwitchUserButton; - changed = true; - } - - if (m_showLogoutButton != ui.checkBox_logout->isChecked()) { - m_showLogoutButton = !m_showLogoutButton; - changed = true; - } - - if (m_showSleepButton != ui.checkBox_sleep->isChecked()) { - m_showSleepButton = !m_showSleepButton; - changed = true; - } - - if (m_showHibernateButton != ui.checkBox_hibernate->isChecked()) { - m_showHibernateButton = !m_showHibernateButton; - changed = true; - } - - if (changed) { + if (m_changed) { int oldButtonCount = m_visibleButtons; countButtons(); if(m_visibleButtons == 0) { @@ -326,15 +363,29 @@ #ifndef Q_OS_WIN QWidget *widget = new QWidget(parent); ui.setupUi(widget); - parent->addPage(widget, i18n("Entries"), Applet::icon()); + parent->addPage(widget, i18n("Please select one or more items on the list below"), Applet::icon()); connect(parent, SIGNAL(applyClicked()), this, SLOT(configAccepted())); connect(parent, SIGNAL(okClicked()), this, SLOT(configAccepted())); + countButtons(); + if (m_visibleButtons == 1) { + ui.checkBox_lock->setEnabled(!m_showLockButton); + ui.checkBox_switchUser->setEnabled(!m_showSwitchUserButton); + ui.checkBox_logout->setEnabled(!m_showLogoutButton); + ui.checkBox_sleep->setEnabled(!m_showSleepButton); + ui.checkBox_hibernate->setEnabled(!m_showHibernateButton); + } + ui.checkBox_lock->setChecked(m_showLockButton); + connect(ui.checkBox_lock, SIGNAL(toggled(bool)), this, SLOT(buttonChanged())); ui.checkBox_switchUser->setChecked(m_showSwitchUserButton); + connect(ui.checkBox_switchUser, SIGNAL(toggled(bool)), this, SLOT(buttonChanged())); ui.checkBox_logout->setChecked(m_showLogoutButton); + connect(ui.checkBox_logout, SIGNAL(toggled(bool)), this, SLOT(buttonChanged())); ui.checkBox_sleep->setChecked(m_showSleepButton); + connect(ui.checkBox_sleep, SIGNAL(toggled(bool)), this, SLOT(buttonChanged())); ui.checkBox_hibernate->setChecked(m_showHibernateButton); + connect(ui.checkBox_hibernate, SIGNAL(toggled(bool)), this, SLOT(buttonChanged())); #endif } --- trunk/KDE/kdebase/workspace/plasma/generic/applets/lock_logout/lockout.h #1208945:1208946 @@ -51,6 +51,7 @@ void clickLock(); void clickSleep(); void clickHibernate(); + void buttonChanged(); protected Q_SLOTS: void configAccepted(); @@ -58,6 +59,7 @@ protected: void createConfigurationInterface(KConfigDialog *parent); void countButtons(); + void setCheckable(); private: #ifndef Q_OS_WIN @@ -79,6 +81,7 @@ void showButtons(); int m_visibleButtons; + bool m_changed; }; K_EXPORT_PLASMA_APPLET(lockout, LockOut)