[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdebase/workspace/plasma/applets/lock_logout
From: Konstantinos Smanis <kon.smanis () gmail ! com>
Date: 2009-02-09 18:04:41
Message-ID: 1234202681.071803.14623.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 923911 by ksmanis:
FEATURE: 164687
Provide the ability to choose which of the two buttons to show in the Lock/Logout plasmoid.
M +3 -0 CMakeLists.txt
M +92 -6 lockout.cpp
M +23 -0 lockout.h
A lockoutConfig.ui
--- trunk/KDE/kdebase/workspace/plasma/applets/lock_logout/CMakeLists.txt #923910:923911
@@ -9,6 +9,9 @@
set(ksmserver_xml ${KDEBASE_WORKSPACE_SOURCE_DIR}/ksmserver/org.kde.KSMServerInterface.xml)
QT4_ADD_DBUS_INTERFACE(lockout_SRCS ${ksmserver_xml} ksmserver_interface)
+if(NOT WIN32)
+kde4_add_ui_files(lockout_SRCS lockoutConfig.ui)
+endif(NOT WIN32)
kde4_add_plugin(plasma_applet_lockout ${lockout_SRCS})
target_link_libraries(plasma_applet_lockout ${KDE4_PLASMA_LIBS} ${KDE4_KIO_LIBS})
if(NOT WIN32)
--- trunk/KDE/kdebase/workspace/plasma/applets/lock_logout/lockout.cpp #923910:923911
@@ -31,6 +31,8 @@
// KDE
#include <KIcon>
#ifndef Q_OS_WIN
+#include <KConfigDialog>
+#include <KSharedConfig>
#include <kworkspace/kworkspace.h>
#include <screensaver_interface.h>
#endif
@@ -47,6 +49,9 @@
LockOut::LockOut(QObject *parent, const QVariantList &args)
: Plasma::Applet(parent, args)
{
+#ifndef Q_OS_WIN
+ setHasConfigurationInterface(true);
+#endif
resize(MINBUTTONSIZE, MINBUTTONSIZE * 2 + MARGINSIZE);
}
@@ -56,14 +61,19 @@
m_layout->setContentsMargins(0,0,0,0);
m_layout->setSpacing(0);
- Plasma::IconWidget *icon_lock = new Plasma::IconWidget(KIcon("system-lock-screen"), "", this);
- m_layout->addItem(icon_lock);
- connect(icon_lock, SIGNAL(clicked()), this, SLOT(clickLock()));
#ifndef Q_OS_WIN
- Plasma::IconWidget *icon_logout = new Plasma::IconWidget(KIcon("system-shutdown"), "", this);
- m_layout->addItem(icon_logout);
- connect(icon_logout, SIGNAL(clicked()), this, SLOT(clickLogout()));
+ KConfigGroup cg = config();
+ m_showLockButton = cg.readEntry("showLockButton", true);
+ m_showLogoutButton = cg.readEntry("showLogoutButton", true);
#endif
+
+ m_iconLock = new Plasma::IconWidget(KIcon("system-lock-screen"), "", this);
+ connect(m_iconLock, SIGNAL(clicked()), this, SLOT(clickLock()));
+
+ m_iconLogout = new Plasma::IconWidget(KIcon("system-shutdown"), "", this);
+ connect(m_iconLogout, SIGNAL(clicked()), this, SLOT(clickLogout()));
+
+ showButtons();
}
LockOut::~LockOut()
@@ -98,6 +108,12 @@
direction = Qt::Vertical;
}
+#ifndef Q_OS_WIN
+ if (!m_showLockButton || !m_showLogoutButton) {
+ ratioToKeep = 1;
+ }
+#endif
+
if (direction == Qt::Horizontal) {
setMinimumSize(MINBUTTONSIZE * 2 + MARGINSIZE, MINBUTTONSIZE);
} else {
@@ -155,5 +171,75 @@
#endif
}
+void LockOut::configAccepted()
+{
+#ifdef Q_OS_WIN
+ return;
+#endif
+ bool changed = false;
+ KConfigGroup cg = config();
+
+ if (m_showLockButton != ui.checkBox_lock->isChecked()) {
+ m_showLockButton = !m_showLockButton;
+ cg.writeEntry("showLockButton", m_showLockButton);
+ changed = true;
+ }
+
+ if (m_showLogoutButton != ui.checkBox_logout->isChecked()) {
+ m_showLogoutButton = !m_showLogoutButton;
+ cg.writeEntry("showLogoutButton", m_showLogoutButton);
+ changed = true;
+ }
+
+ if (changed) {
+ showButtons();
+ emit configNeedsSaving();
+ }
+}
+
+void LockOut::createConfigurationInterface(KConfigDialog *parent)
+{
+#ifdef Q_OS_WIN
+ return;
+#endif
+
+ QWidget *widget = new QWidget(parent);
+ ui.setupUi(widget);
+ parent->addPage(widget, i18n("General"), Applet::icon());
+ connect(parent, SIGNAL(applyClicked()), this, SLOT(configAccepted()));
+ connect(parent, SIGNAL(okClicked()), this, SLOT(configAccepted()));
+
+ ui.checkBox_lock->setChecked(m_showLockButton);
+ ui.checkBox_logout->setChecked(m_showLogoutButton);
+}
+
+void LockOut::showButtons()
+{
+#ifdef Q_OS_WIN
+ m_layout->addItem(m_iconLock);
+#else
+ //make sure we don't add a button twice in the layout
+ //definitely not the best workaround...
+ m_layout->removeItem(m_iconLock);
+ m_layout->removeItem(m_iconLogout);
+
+ if (m_showLockButton) {
+ m_iconLock->setVisible(true);
+ m_layout->addItem(m_iconLock);
+ } else {
+ m_iconLock->setVisible(false);
+ }
+
+ if (m_showLogoutButton) {
+ m_iconLogout->setVisible(true);
+ m_layout->addItem(m_iconLogout);
+ } else {
+ m_iconLogout->setVisible(false);
+ }
+
+ setConfigurationRequired(!m_showLockButton && !m_showLogoutButton);
+#endif // !Q_OS_WIN
+}
+
#include "lockout.moc"
--- trunk/KDE/kdebase/workspace/plasma/applets/lock_logout/lockout.h #923910:923911
@@ -22,6 +22,15 @@
#include <Plasma/Applet>
+namespace Plasma
+{
+ class IconWidget;
+}
+
+#ifndef Q_OS_WIN
+#include "ui_lockoutConfig.h"
+#endif
+
class QGraphicsLinearLayout;
class LockOut : public Plasma::Applet
@@ -38,9 +47,23 @@
void clickLogout();
void clickLock();
+ protected Q_SLOTS:
+ void configAccepted();
+
+ protected:
+ void createConfigurationInterface(KConfigDialog *parent);
+
private:
+#ifndef Q_OS_WIN
+ Ui::lockoutConfig ui;
+ bool m_showLockButton;
+ bool m_showLogoutButton;
+#endif
+ Plasma::IconWidget *m_iconLock;
+ Plasma::IconWidget *m_iconLogout;
QGraphicsLinearLayout *m_layout;
void checkLayout();
+ void showButtons();
};
K_EXPORT_PLASMA_APPLET(lockout, LockOut)
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic