diff -Npur kdebase-3.5.7/ksmserver/shutdowndlg.cpp kdebase-3.5.7.patched/ksmserver/shutdowndlg.cpp --- kdebase-3.5.7/ksmserver/shutdowndlg.cpp 2007-01-15 12:31:35.000000000 +0100 +++ kdebase-3.5.7.patched/ksmserver/shutdowndlg.cpp 2007-06-01 01:07:49.000000000 +0200 @@ -48,6 +48,60 @@ Copyright (C) 2000 Matthias Ettrich drawPixmap(0,0,btnpic); +} + + +int QStyleButton::heightForWidth(int w) +{ +return w; +} + +int QStyleButton::widthForHeight(int h) +{ +return h; +} +void QStyleButton::enterEvent(QEvent *e) +{ + QPainter p(this); + QPixmap pix=btnpic; + QImage img=pix.convertToImage(); + KIconEffect *m=new KIconEffect(); + img=m->apply(img,KIconEffect::ToGamma,1,QColor(169,156,255),true); + pix.convertFromImage(img); + p.drawPixmap(0,0,pix); + //grabMouse(Qt::PointingHandCursor); + setCursor(Qt::PointingHandCursor); + //QButton::enterEvent(e); +} + +void QStyleButton::leaveEvent(QEvent *e) +{ + QPainter p(this); + p.drawPixmap(0,0,btnpic); + //releaseMouse(); + //QButton::leaveEvent(e); + +} + + + KSMShutdownFeedback * KSMShutdownFeedback::s_pSelf = 0L; KSMShutdownFeedback::KSMShutdownFeedback() @@ -91,8 +145,27 @@ KSMShutdownDlg::KSMShutdownDlg( QWidget* // this is a WType_Popup on purpose. Do not change that! Not // having a popup here has severe side effects. { - QVBoxLayout* vbox = new QVBoxLayout( this ); - QFrame* frame = new QFrame( this ); + KConfig cfg("kcm_hibernaterc"); + KConfigGroupSaver saver(&cfg, "ACPI"); + hibernate_enabled = cfg.readBoolEntry("enable", false); + + KConfig themecfg("ksmserverrc"); + KConfigGroupSaver saver2(&themecfg, "Theme"); + + usetheme = themecfg.readBoolEntry("UseTheme",false); + + themepath = themecfg.readEntry("Theme"); + + if(usetheme) + _gui_setup(maysd, sdtype); + else + plain_gui_setup(this,maysd,sdtype); +} +void KSMShutdownDlg::plain_gui_setup(QWidget *parent,bool maysd, KApplication::ShutdownType sdtype) +{ + + QVBoxLayout* vbox = new QVBoxLayout( parent ); + QFrame* frame = new QFrame( parent ); frame->setFrameStyle( QFrame::StyledPanel | QFrame::Raised ); frame->setLineWidth( style().pixelMetric( QStyle::PM_DefaultFrameWidth, frame ) ); vbox->addWidget( frame ); @@ -180,9 +252,210 @@ KSMShutdownDlg::KSMShutdownDlg( QWidget* KPushButton* btnBack = new KPushButton( KStdGuiItem::cancel(), frame ); buttonlay->addWidget( btnBack ); connect(btnBack, SIGNAL(clicked()), SLOT(reject())); +} +void KSMShutdownDlg::keyPressEvent( QKeyEvent* e) +{ + if(usetheme) + { + if( hibernate_enabled && e->key() == Qt::Key_Shift ) + { + logout->hide(); + s3->show(); + logoutLabel->setText(i18n("Suspend")); + reboot->hide(); + s4->show(); + rebootLabel->setText(i18n("Hibernate")); + _gui_label_alignment(); + e->accept(); + } + QDialog::keyPressEvent(e); + } } +void KSMShutdownDlg::keyReleaseEvent( QKeyEvent* e) +{ + if(usetheme) + { + if( hibernate_enabled && e->key() == Qt::Key_Shift ) + { + logout->show(); + s3->hide(); + logoutLabel->setText(i18n("Logout")); + reboot->show(); + s4->hide(); + rebootLabel->setText(i18n("Reboot")); + _gui_label_alignment(); + e->accept(); + } + QDialog::keyReleaseEvent(e); + } +} + +void KSMShutdownDlg::slotS3() +{ +//QMessageBox::warning(this, "s3","s3 implementation."); + reject(); + this->hide(); + proc.clearArguments(); + proc<<"s3"; + if(fork()==0) + { + proc.start(KProcess::Block); + exit(0); + } +} +void KSMShutdownDlg::slotS4() +{ + reject(); + this->hide(); + proc.clearArguments(); + proc<<"s4"; + if(fork()==0) + { + proc.start(KProcess::Block); + exit(0); + } +} +void KSMShutdownDlg::_gui_label_alignment() +{ + logoutLabel->move(71-logoutLabel->fontMetrics().width(logoutLabel->text())/2, 116); + shutdownLabel->move(156-shutdownLabel->fontMetrics().width(shutdownLabel->text())/2,116); + rebootLabel->move(242-rebootLabel->fontMetrics().width(rebootLabel->text())/2,116); +} + + +void KSMShutdownDlg::_gui_setup(bool maysd, KApplication::ShutdownType sdtype) +{ + QVBoxLayout* vbox = new QVBoxLayout( this ); + QFrame* frame = new QFrame( this ); + frame->setFixedWidth(314); + frame->setFixedHeight(200); + frame->setFrameStyle( QFrame::NoFrame ); + QString bgStr=themepath+"/background.png"; + QImage srcImage; + srcImage.load(bgStr); + + frame->setBackgroundPixmap(QPixmap(srcImage)); + vbox->addWidget( frame ); + + QString logStr=themepath+"/logout.png"; + QImage logImage; + logImage.load(logStr); + logout = new QStyleButton(frame,QPixmap(logImage)); + logout->setCursor( QCursor( 13 ) ); + + QString s3Str=themepath+"/s3.png"; + QImage s3Image; + s3Image.load(s3Str); + s3 = new QStyleButton(frame,QPixmap(s3Image)); + s3->setCursor( QCursor( 13 ) ); + + QString shutStr=themepath+"/shutdown.png"; + QImage shutImage; + shutImage.load(shutStr); + shutdown = new QStyleButton(frame,QPixmap(shutImage)); + shutdown->setCursor( QCursor( 13 ) ); + QString rebootStr=themepath+"/reboot.png"; + QImage rebootImage; + rebootImage.load(rebootStr); + reboot = new QStyleButton(frame,QPixmap(rebootImage)); + reboot->setCursor( QCursor( 13 ) ); + + QString s4Str=themepath+"/s4.png"; + QImage s4Image; + s4Image.load(s4Str); + s4 = new QStyleButton(frame,QPixmap(s4Image)); + s4->setCursor( QCursor( 13 ) ); + s3->hide(); + s4->hide(); + + //vbox = new QVBoxLayout( frame, 15, 11 ); + + QLabel* label = new QLabel( i18n("End Session for \"%1\"").arg(KUser().loginName()), frame ); + label->setBackgroundMode(X11ParentRelative); + label->setPaletteForegroundColor(Qt::white); + QFont fnt = label->font(); + fnt.setBold( true ); + fnt.setPixelSize( fnt.pixelSize() * 3 / 2 ); + label->setFont( fnt ); + label->setFixedWidth(label->fontMetrics().width(i18n("End Session for \"%1\"").arg(KUser().loginName()))); + label->move(304-label->width(), 10); //frame size: 314x200, right space 10px + label->show(); + label->setCursor(QCursor(13)); + logoutLabel = new QLabel( i18n("Logout"), frame ); + logoutLabel->setBackgroundMode(X11ParentRelative); + logoutLabel->setPaletteForegroundColor(Qt::white); + logoutLabel->setFont( fnt ); + + shutdownLabel = new QLabel( i18n("Shutdown"), frame ); + shutdownLabel->setBackgroundMode(X11ParentRelative); + shutdownLabel->setPaletteForegroundColor(Qt::white); + shutdownLabel->setFont( fnt ); + + rebootLabel = new QLabel( i18n("Reboot"), frame ); + rebootLabel->setBackgroundMode(X11ParentRelative); + rebootLabel->setPaletteForegroundColor(Qt::white); + rebootLabel->setFont( fnt ); + + QObject::connect(logout, SIGNAL(clicked()), + this, SLOT(slotLogout())); + QObject::connect(shutdown, SIGNAL(clicked()), + this, SLOT(slotHalt())); + QObject::connect(reboot, SIGNAL(clicked()), + this, SLOT(slotReboot())); + QObject::connect(s3, SIGNAL(clicked()), + this, SLOT(slotS3())); + QObject::connect(s4, SIGNAL(clicked()), + this, SLOT(slotS4())); + + if (maysd) + { + //call this function to alignment all labels + _gui_label_alignment(); + logout->move(55,81); + s3->move(55,81); + logout->show(); + + // logoutLabel->move(71-logoutLabel->fontMetrics().width(i18n("Logout"))/2, 116); + logoutLabel->show(); + + shutdown->move(140,81); + shutdown->show(); + // shutdownLabel->move(156-shutdownLabel->fontMetrics().width(i18n("Shutdown"))/2,116); + shutdownLabel->show(); + + reboot->move(226,81); + s4->move(226,81); + reboot->show(); + // rebootLabel->move(242-rebootLabel->fontMetrics().width(i18n("Reboot"))/2,116); + rebootLabel->show(); + } + else + { + shutdown->hide(); + shutdownLabel->hide(); + reboot->hide(); + rebootLabel->hide(); + logout->move(140,81); + logout->show(); + logoutLabel->move(156-logoutLabel->fontMetrics().width(i18n("Logout"))/2,116); + logoutLabel->show(); + QObject::connect(logout, SIGNAL(clicked()), + this, SLOT(slotLogout())); + + } + KPushButton* cancel = new KPushButton( KStdGuiItem::cancel(), frame ); + cancel->setDefault(true); + connect( cancel, SIGNAL( clicked() ), SLOT( reject() ) ); + cancel->setFixedWidth(60); + cancel->setFixedHeight(20); + cancel->move(243,168); + cancel->show(); +} + + + void KSMShutdownDlg::slotLogout() { diff -Npur kdebase-3.5.7/ksmserver/shutdowndlg.h kdebase-3.5.7.patched/ksmserver/shutdowndlg.h --- kdebase-3.5.7/ksmserver/shutdowndlg.h 2006-01-19 18:01:08.000000000 +0100 +++ kdebase-3.5.7.patched/ksmserver/shutdowndlg.h 2007-06-01 01:07:49.000000000 +0200 @@ -16,6 +16,28 @@ class QPopupMenu; class QTimer; #include +#include +#include +#include +#include +#include +#include +class QStyleButton : public QButton +{ + Q_OBJECT + +public: + QStyleButton( QWidget* parent ,QPixmap); +protected: + void drawButton(QPainter* ); + int widthForHeight(int h); + int heightForWidth(int w); + virtual void enterEvent(QEvent *); + virtual void leaveEvent(QEvent *); + QPixmap btnpic; +protected slots: +}; + // The (singleton) widget that makes the desktop gray. class KSMShutdownFeedback : public QWidget @@ -48,6 +69,8 @@ class KSMShutdownDlg : public QDialog public: static bool confirmShutdown( bool maysd, KApplication::ShutdownType& sdtype, QString& bopt ); + virtual void keyPressEvent( QKeyEvent* e ); + virtual void keyReleaseEvent( QKeyEvent* e ); public slots: void slotLogout(); @@ -55,6 +78,9 @@ public slots: void slotReboot(); void slotReboot(int); + void slotS3(); + void slotS4(); + protected: ~KSMShutdownDlg() {}; @@ -64,6 +90,26 @@ private: QString m_bootOption; QPopupMenu *targets; QStringList rebootOptions; + + QStyleButton * logout; + QStyleButton * s3; + QStyleButton * shutdown; + QStyleButton * reboot; + QStyleButton * s4; + + QLabel* logoutLabel; + QLabel* shutdownLabel; + QLabel* rebootLabel; + QLabel* switchLabel; + + KProcess proc; + + bool hibernate_enabled; + bool usetheme; + QString themepath; + void _gui_label_alignment(); + void _gui_setup(bool maysd, KApplication::ShutdownType sdtype); + void plain_gui_setup(QWidget *parent,bool maysd, KApplication::ShutdownType sdtype); }; class KSMDelayedPushButton : public KPushButton