summaryrefslogtreecommitdiffstats
path: root/kicker/applets/lockout
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit4aed2c8219774f5d797760606b8489a92ddc5163 (patch)
tree3f8c130f7d269626bf6a9447407ef6c35954426a /kicker/applets/lockout
downloadtdebase-4aed2c8219774f5d797760606b8489a92ddc5163.tar.gz
tdebase-4aed2c8219774f5d797760606b8489a92ddc5163.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebase@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kicker/applets/lockout')
-rw-r--r--kicker/applets/lockout/Makefile.am18
-rw-r--r--kicker/applets/lockout/README4
-rw-r--r--kicker/applets/lockout/lockout.cpp278
-rw-r--r--kicker/applets/lockout/lockout.desktop125
-rw-r--r--kicker/applets/lockout/lockout.h52
5 files changed, 477 insertions, 0 deletions
diff --git a/kicker/applets/lockout/Makefile.am b/kicker/applets/lockout/Makefile.am
new file mode 100644
index 000000000..f9772adf5
--- /dev/null
+++ b/kicker/applets/lockout/Makefile.am
@@ -0,0 +1,18 @@
+INCLUDES = -I$(top_srcdir)/kicker/libkicker $(all_includes)
+METASOURCES = AUTO
+
+kde_module_LTLIBRARIES = lockout_panelapplet.la
+
+lockout_panelapplet_la_SOURCES = lockout.cpp
+lockout_panelapplet_la_LDFLAGS = -module $(KDE_PLUGIN) $(all_libraries)
+lockout_panelapplet_la_LIBADD = ../../libkicker/libkickermain.la $(LIB_KSYCOCA)
+
+noinst_HEADERS = lockout.h
+
+lnkdir = $(kde_datadir)/kicker/applets
+lnk_DATA = lockout.desktop
+
+EXTRA_DIST = $(lnk_DATA)
+
+messages:
+ $(XGETTEXT) *.cpp *.h -o $(podir)/lockout.pot
diff --git a/kicker/applets/lockout/README b/kicker/applets/lockout/README
new file mode 100644
index 000000000..e25954c3d
--- /dev/null
+++ b/kicker/applets/lockout/README
@@ -0,0 +1,4 @@
+A very simple applet that shows two buttons, one for locking the desktop,
+the other to invoke the logout process.
+
+Carsten Pfeiffer <[email protected]>
diff --git a/kicker/applets/lockout/lockout.cpp b/kicker/applets/lockout/lockout.cpp
new file mode 100644
index 000000000..d22e4a8ed
--- /dev/null
+++ b/kicker/applets/lockout/lockout.cpp
@@ -0,0 +1,278 @@
+/*****************************************************************
+
+Copyright (c) 2001 Carsten Pfeiffer <[email protected]>
+ 2001 Matthias Elter <[email protected]>
+ 2001 Martijn Klingens <[email protected]>
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+******************************************************************/
+
+
+#include <qlayout.h>
+#include <qpainter.h>
+#include <qpixmap.h>
+#include <qpopupmenu.h>
+#include <qtoolbutton.h>
+#include <qstyle.h>
+#include <qtooltip.h>
+
+#include <dcopclient.h>
+
+#include <kapplication.h>
+#include <kglobal.h>
+#include <klocale.h>
+#include <kiconloader.h>
+#include <krun.h>
+#include <kdebug.h>
+
+#include <stdlib.h>
+#include "lockout.h"
+
+extern "C"
+{
+ KDE_EXPORT KPanelApplet* init(QWidget *parent, const QString& configFile)
+ {
+ KGlobal::locale()->insertCatalogue("lockout");
+ return new Lockout(configFile, parent, "lockout");
+ }
+}
+
+Lockout::Lockout( const QString& configFile, QWidget *parent, const char *name)
+ : KPanelApplet( configFile, KPanelApplet::Normal, 0, parent, name ), bTransparent( false )
+{
+ KConfig *conf = config();
+ conf->setGroup("lockout");
+
+ //setFrameStyle(Panel | Sunken);
+ setBackgroundOrigin( AncestorOrigin );
+
+ if ( orientation() == Horizontal )
+ layout = new QBoxLayout( this, QBoxLayout::TopToBottom );
+ else
+ layout = new QBoxLayout( this, QBoxLayout::LeftToRight );
+
+ layout->setAutoAdd( true );
+ layout->setMargin( 0 );
+ layout->setSpacing( 0 );
+
+ lockButton = new SimpleButton( this, "lock");
+ logoutButton = new SimpleButton( this, "logout");
+
+ QToolTip::add( lockButton, i18n("Lock the session") );
+ QToolTip::add( logoutButton, i18n("Log out") );
+
+ lockButton->setPixmap( SmallIcon( "lock" ));
+ logoutButton->setPixmap( SmallIcon( "exit" ));
+
+ bTransparent = conf->readBoolEntry( "Transparent", bTransparent );
+
+ connect( lockButton, SIGNAL( clicked() ), SLOT( lock() ));
+ connect( logoutButton, SIGNAL( clicked() ), SLOT( logout() ));
+
+ lockButton->installEventFilter( this );
+ logoutButton->installEventFilter( this );
+
+ if (!kapp->authorize("lock_screen"))
+ lockButton->hide();
+
+ if (!kapp->authorize("logout"))
+ logoutButton->hide();
+
+ lockButton->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));
+ logoutButton->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));
+
+ if ( !kapp->dcopClient()->isAttached() )
+ kapp->dcopClient()->attach();
+
+ connect( kapp, SIGNAL( iconChanged(int) ), SLOT( slotIconChanged() ));
+}
+
+Lockout::~Lockout()
+{
+ KGlobal::locale()->removeCatalogue("lockout");
+}
+
+// the -2 is due to kicker allowing us a width/height of 42 and the buttons
+// having a size of 44. So we rather cut those 2 pixels instead of changing
+// direction and wasting a lot of space.
+void Lockout::checkLayout( int height ) const
+{
+ QSize s = minimumSizeHint();
+ QBoxLayout::Direction direction = layout->direction();
+
+ if ( direction == QBoxLayout::LeftToRight &&
+ ( ( orientation() == Vertical && s.width() - 2 >= height ) ||
+ ( orientation() == Horizontal && s.width() - 2 < height ) ) ) {
+ layout->setDirection( QBoxLayout::TopToBottom );
+ }
+ else if ( direction == QBoxLayout::TopToBottom &&
+ ( ( orientation() == Vertical && s.height() - 2 < height ) ||
+ ( orientation() == Horizontal && s.height() - 2 >= height ) ) ) {
+ layout->setDirection( QBoxLayout::LeftToRight );
+ }
+}
+
+int Lockout::widthForHeight( int height ) const
+{
+ checkLayout( height );
+ return sizeHint().width();
+}
+
+int Lockout::heightForWidth( int width ) const
+{
+ checkLayout( width );
+ return sizeHint().height();
+}
+
+void Lockout::lock()
+{
+ QCString appname( "kdesktop" );
+ int kicker_screen_number = qt_xscreen();
+ if ( kicker_screen_number )
+ appname.sprintf("kdesktop-screen-%d", kicker_screen_number);
+ kapp->dcopClient()->send(appname, "KScreensaverIface", "lock()", "");
+}
+
+void Lockout::logout()
+{
+ kapp->requestShutDown();
+}
+
+void Lockout::mousePressEvent(QMouseEvent* e)
+{
+ propagateMouseEvent(e);
+}
+
+void Lockout::mouseReleaseEvent(QMouseEvent* e)
+{
+ propagateMouseEvent(e);
+}
+
+void Lockout::mouseDoubleClickEvent(QMouseEvent* e)
+{
+ propagateMouseEvent(e);
+}
+
+void Lockout::mouseMoveEvent(QMouseEvent* e)
+{
+ propagateMouseEvent(e);
+}
+
+void Lockout::propagateMouseEvent(QMouseEvent* e)
+{
+ if ( !isTopLevel() ) {
+ QMouseEvent me(e->type(), mapTo( topLevelWidget(), e->pos() ),
+ e->globalPos(), e->button(), e->state() );
+ QApplication::sendEvent( topLevelWidget(), &me );
+ }
+}
+
+bool Lockout::eventFilter( QObject *o, QEvent *e )
+{
+ if (!kapp->authorizeKAction("kicker_rmb"))
+ return false; // Process event normally:
+
+ if( e->type() == QEvent::MouseButtonPress )
+ {
+ KConfig *conf = config();
+ conf->setGroup("lockout");
+
+ QMouseEvent *me = static_cast<QMouseEvent *>( e );
+ if( me->button() == QMouseEvent::RightButton )
+ {
+ if( o == lockButton )
+ {
+ QPopupMenu *popup = new QPopupMenu();
+
+ popup->insertItem( SmallIcon( "lock" ), i18n("Lock Session"),
+ this, SLOT( lock() ) );
+ popup->insertSeparator();
+
+ i18n("&Transparent");
+ //popup->insertItem( i18n( "&Transparent" ), 100 );
+ popup->insertItem( SmallIcon( "configure" ),
+ i18n( "&Configure Screen Saver..." ),
+ this, SLOT( slotLockPrefs() ) );
+
+ //popup->setItemChecked( 100, bTransparent );
+ //popup->connectItem(100, this, SLOT( slotTransparent() ) );
+ //if (conf->entryIsImmutable( "Transparent" ))
+ // popup->setItemEnabled( 100, false );
+ popup->exec( me->globalPos() );
+ delete popup;
+
+ return true;
+ }
+ else if ( o == logoutButton )
+ {
+ QPopupMenu *popup = new QPopupMenu();
+
+ popup->insertItem( SmallIcon( "exit" ), i18n("&Log Out..."),
+ this, SLOT( logout() ) );
+ popup->insertSeparator();
+ //popup->insertItem( i18n( "&Transparent" ), 100 );
+ popup->insertItem( SmallIcon( "configure" ),
+ i18n( "&Configure Session Manager..." ),
+ this, SLOT( slotLogoutPrefs() ) );
+
+ //popup->setItemChecked( 100, bTransparent );
+ //popup->connectItem(100, this, SLOT( slotTransparent() ) );
+ //if (conf->entryIsImmutable( "Transparent" ))
+ // popup->setItemEnabled( 100, false );
+ popup->exec( me->globalPos() );
+ delete popup;
+
+ return true;
+ } // if o
+ } // if me->button
+ } // if e->type
+
+ // Process event normally:
+ return false;
+}
+
+void Lockout::slotLockPrefs()
+{
+ // Run the screensaver settings
+ KRun::run( "kcmshell screensaver", KURL::List() );
+}
+
+void Lockout::slotTransparent()
+{
+ bTransparent = !bTransparent;
+
+ KConfig* conf = config();
+ conf->setGroup("lockout");
+ conf->writeEntry( "Transparent", bTransparent );
+ conf->sync();
+}
+
+void Lockout::slotLogoutPrefs()
+{
+ // Run the logout settings.
+ KRun::run( "kcmshell kcmsmserver", KURL::List() );
+}
+
+void Lockout::slotIconChanged()
+{
+ lockButton->setPixmap( SmallIcon( "lock" ));
+ logoutButton->setPixmap( SmallIcon( "exit" ));
+}
+
+#include "lockout.moc"
diff --git a/kicker/applets/lockout/lockout.desktop b/kicker/applets/lockout/lockout.desktop
new file mode 100644
index 000000000..e8681cc88
--- /dev/null
+++ b/kicker/applets/lockout/lockout.desktop
@@ -0,0 +1,125 @@
+[Desktop Entry]
+Type=Plugin
+Name=Lock/Logout Buttons
+Name[af]=Sluit/Teken af Knoppies
+Name[ar]=أزرار الإقفال/الخروج
+Name[be]=Кнопкі блакавання/выхаду
+Name[bg]=Заключване и изход
+Name[bn]=লক/লগ-আউট বাটন
+Name[bs]=Dugmad za zaključavanje/odjavu
+Name[ca]=Botons bloqueja/surt
+Name[cs]=Tlačítka odhlášení/uzamčení
+Name[csb]=Knąpë blokòwaniô ekranu/wëlogòwaniô
+Name[da]=Lås/Logaf-knapper
+Name[de]=Bildschirmsperre und Abmeldung aus KDE
+Name[el]=Κουμπιά κλειδώματος/αποσύνδεσης
+Name[eo]=Ŝloso- kaj adiaŭo-butonoj
+Name[es]=Botones de bloqueo/salida
+Name[et]=Lukustamise/väljalogimise nupud
+Name[eu]=Blokeatu/Irteteko botoiak
+Name[fa]=دکمه‌های قفل/خروج
+Name[fi]=Lukitus/Uloskirjautumispainikkeet
+Name[fr]=Boutons de verrouillage et déconnexion
+Name[fy]=Beskoattelje/ôfmeldknoppen
+Name[ga]=Cnaipí Glasála/Logála Amach
+Name[gl]=Botóns de Bloqueo/Saída
+Name[he]=כפתורי נעילה\יציאה
+Name[hr]=Gumb za zaključavanje/odjavljivanje
+Name[hu]=Zároló/kijelentkező gombok
+Name[is]=Læsa/stimpla út hnappar
+Name[it]=Pulsanti di uscita e bloccaggio schermo
+Name[ja]=ロック/ログアウトボタン
+Name[ka]=დაბლოკვის/გამოსვლის ღილაკები
+Name[kk]=Шығу не экранды бұғаттау батырмалары
+Name[km]=ប៊ូតុង ចាក់សោ/ចេញ
+Name[ko]=잠금/로그아웃
+Name[lt]=Užrakinimo/išsiregistravimo mygtukai
+Name[mk]=Копчиња „Заклучи/Одјави се“
+Name[nb]=Panelprogram for skjermlås/utlogging
+Name[nds]=Knööp för dat Afsluten oder Afmellen
+Name[ne]=ताल्चा लगाउने/लगआउट गर्ने बटन
+Name[nl]=Vergrendel/afmeldknoppen
+Name[nn]=Knappar for skjermlås/utlogging
+Name[pa]=ਤਾਲਾ/ਬਾਹਰੀ ਦਰ ਬਟਨ
+Name[pl]=Przyciski blokowania ekranu/wylogowania
+Name[pt]=Botões de Bloqueio/Saída
+Name[pt_BR]=Botões de Travar/Sair
+Name[ro]=Butoane de blocare/ieșire
+Name[ru]=Кнопки выхода и запирания экрана
+Name[se]=Lohkadan/olggosčálihan boalut
+Name[sk]=Tlačidlá na ohlásenie/zamknutie
+Name[sl]=Gumba za zaklep in odjavo
+Name[sr]=Дугмад за закључавање/одјављивање
+Name[sr@Latn]=Dugmad za zaključavanje/odjavljivanje
+Name[sv]=Lås/Logga ut-knappar
+Name[te]=తాళం వెయి/లాగౌట్ బటన్లు
+Name[tg]=Тугмаҳои Қулф/Баромадан
+Name[th]=ปุ่มล็อค/ล็อกเอาท์
+Name[tr]=Kilitle/Çık Düğmeleri
+Name[uk]=Кнопки Замикання/Виходу з системи
+Name[uz]=Qulflash/chiqish tugmalari
+Name[uz@cyrillic]=Қулфлаш/чиқиш тугмалари
+Name[vi]=Tiểu ứng dụng Khoá/Đăng xuất
+Name[wa]=Boton po serer a clé ou dislodjî
+Name[zh_CN]=锁定/注销按钮
+Name[zh_TW]=「螢幕鎖定/登出」按鈕
+Comment=Adds buttons for locking screen and session logout
+Comment[af]=Voeg skerm sluit en afteken knoppies by
+Comment[ar]=يضيف أزرار لإقفال الشاشة و الخروج من الجلسة
+Comment[be]=Дадае кнопкі для блакіроўкі экрана і заканчэння сесіі
+Comment[bg]=Добавяне на бутоните за заключване на екрана и изход
+Comment[bn]=স্ক্রীণ লক এবং লগ-আউট করার জন্য বাটন যোগ করে
+Comment[bs]=Dodaje na panel dugmad za zaključavanje ekrana i odjavu sa sistema
+Comment[ca]=Afegeix botons per bloquejar la pantalla i sortir de la sessió
+Comment[cs]=Přidá tlačítka pro uzamčení obrazovky a odhlášení z relace
+Comment[csb]=Dodôwô knapë blokòwaniô ekranu ë wëlogòwaniô
+Comment[da]=Tilføjer knapper for at låse skærmen og logge ud fra sessionen
+Comment[de]=Fügt Knöpfe zur Bildschirmsperre und Abmeldung aus KDE hinzu
+Comment[el]=Προσθέτει κουμπιά για το κλείδωμα της οθόνης και την αποσύνδεση συνεδρίας
+Comment[eo]=Aldonu butonojn por ŝlosi ekranon kaj seanco-eliron
+Comment[es]=Añade botones para bloquear la sesión y para salirse de esta
+Comment[et]=Lisab nupud ekraani lukustamiseks ning seansi lõpetamiseks
+Comment[eu]=Pantaila blokeatu eta saiotik irteteko botoiak gehitzen ditu
+Comment[fa]=دکمه‌ها را برای قفل پرده و خروج نشست اضافه می‌کند
+Comment[fi]=Lisää painikkeet ruudun lukitsemiseen ja uloskirjautumiseen
+Comment[fr]=Ajoute des boutons permettant de verrouiller l'écran et de déconnecter la session en cours
+Comment[fy]=Heakket knoppen ta foar it beskoattelje fan it skerm en it sluten fan de sesje
+Comment[gl]=Engade botóns para bloquear a pantalla e sair da sesión
+Comment[he]=מוסיף כפתורים לנעילת המסך ויציאה מהמערכת
+Comment[hr]=Dodavanje gumba za zaključavanje zaslona i odjavljivanja sesije
+Comment[hu]=Nyomógombok a képernyő zárolásához és kijelentkezéshez
+Comment[is]=Bætir við hnöppum til að læsa skjánum og stimpla sig út
+Comment[it]=Aggiunge i pulsanti per bloccare lo schermo o uscire dalla sessione
+Comment[ja]=スクリーンロックとセッションログアウト用ボタンを追加
+Comment[kk]=Экранды бұғаттау және сеанстан шығу батырмаларды қосу
+Comment[km]=បន្ថែម​ប៊ូតុង​សម្រាប់​ចាក់សោ​អេក្រង់ និង​ចេញ​ពី​សម័យ
+Comment[ko]=세션을 잠그거나 끝내기
+Comment[lt]=Prideda mygtukus ekrano užrakinimui ir sesijos užbaigimui
+Comment[mk]=Додава копчиња за заклучување на екранот и одјавување од сесијата
+Comment[nb]=Legger til knapper for å låse skjermen og logge ut av økta.
+Comment[nds]=Föögt Knööp för dat Afsluten vun den Schirm oder dat Afmellen ut KDE to
+Comment[ne]=पर्दा ताल्चा लगाउन र सत्र लग आउट गर्नका लागि बटनहरू थप्छ
+Comment[nl]=Voegt knoppen toe voor het vergrendelen van het scherm en het afsluiten van de sessie
+Comment[nn]=Legg til knappar for å låsa skjermen og logga ut av økta.
+Comment[pa]=ਪਰਦੇ ਨੂੰ ਤਾਲਾਬੰਦ ਕਰਨ ਅਤੇ ਅਜਲਾਸ ਬੰਦ ਕਰਨ ਲਈ ਬਟਨ ਜੋੜਦਾ ਹੈ
+Comment[pl]=Dodaje przyciski zablokowania ekranu i wylogowania
+Comment[pt]=Adiciona botões para bloquear o ecrã e encerrar a sessão
+Comment[pt_BR]=Adiciona os botões para bloquear a tela e finalizar a sessão
+Comment[ro]=Adaugă butoane pentru blocarea ecranului și sesiunea de ieșire
+Comment[ru]=Добавление кнопок выхода из KDE и запирания экрана
+Comment[se]=Lasit boaluid mat sáhttet lohkadit šearpma ja heaittihit bargovuoru
+Comment[sk]=Pridá tlačidlá na zamknutie obrazovky a ukončenie relácie
+Comment[sl]=Doda gumba za zaklep zaslona in odjavo iz seje
+Comment[sr]=Додаје дугмад за закључавање екрана и одјављивање из сесије
+Comment[sr@Latn]=Dodaje dugmad za zaključavanje ekrana i odjavljivanje iz sesije
+Comment[sv]=Lägger till knappar för att låsa skärmen och logga ut från sessionen
+Comment[th]=เพิ่มปุ่มสำหรับล็อคหน้าจอและล็อกเอาท์ออกจากวาระที่กำลังใช้งานอยู่
+Comment[uk]=Додає кнопки для замикання екрана та виходу з сеансу
+Comment[uz]=Ekranni qulflash va seansdan chiqish uchun tugmalar
+Comment[uz@cyrillic]=Экранни қулфлаш ва сеансдан чиқиш учун тугмалар
+Comment[vi]=Thêm nút khoá màn hình và đăng xuất khỏi phiên làm việc
+Comment[wa]=Radjout des botons po serer l' waitroûle a clé et dislodjî del session
+Comment[zh_CN]=添加锁定屏幕和注销会话的按钮
+Comment[zh_TW]=加入用來鎖定螢幕與登出作業階段的按鈕
+Icon=exit
+X-KDE-Library=lockout_panelapplet
diff --git a/kicker/applets/lockout/lockout.h b/kicker/applets/lockout/lockout.h
new file mode 100644
index 000000000..606870a99
--- /dev/null
+++ b/kicker/applets/lockout/lockout.h
@@ -0,0 +1,52 @@
+#ifndef LOCKOUT_H
+#define LOCKOUT_H
+
+#include <qevent.h>
+#include <qstring.h>
+#include <kpanelapplet.h>
+
+#include "simplebutton.h"
+
+class QBoxLayout;
+class QToolButton;
+
+class Lockout : public KPanelApplet
+{
+ Q_OBJECT
+
+public:
+ Lockout( const QString& configFile,
+ QWidget *parent = 0, const char *name = 0 );
+ ~Lockout();
+
+ int widthForHeight(int height) const;
+ int heightForWidth(int width) const;
+
+protected:
+ virtual void mousePressEvent( QMouseEvent * );
+ virtual void mouseMoveEvent( QMouseEvent * );
+ virtual void mouseReleaseEvent( QMouseEvent * );
+ virtual void mouseDoubleClickEvent( QMouseEvent * );
+
+ virtual bool eventFilter( QObject *, QEvent * );
+
+private slots:
+ void lock();
+ void logout();
+
+ void slotLockPrefs();
+ void slotLogoutPrefs();
+ void slotTransparent();
+ void slotIconChanged();
+
+private:
+ void propagateMouseEvent( QMouseEvent * );
+ void checkLayout( int height ) const;
+
+ SimpleButton *lockButton, *logoutButton;
+ QBoxLayout *layout;
+
+ bool bTransparent;
+};
+
+#endif // LOCKOUT_H