[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-core-devel
Subject: [PATCH] ksmserver: take two
From: ossi () master ! kde ! org
Date: 2002-01-30 22:00:23
[Download RAW message or body]
this patch is based on the part of Martijn's patch i didn't commit yet.
the gui part is trivial.
i also did some changes i consider a cleanup. however, i'm concerned about
removing the keyEvent and mouseEvent handlers: theoretically they are not
necessary, but i'm not sure why they were introduced in the first place -
but in the testsh it _seems_ to behave correctly.
dfaure: you introduced the keyevent handler - what was the idea behind it?
qdialog handles escape for us, doesn't it?
mettrich: why do you swallow all mouse press events? the qwidget that
covers the whole desktop won't allow them to do any harm anyway, or?
greetings
["ksmserver.diff" (text/plain)]
Index: shutdown.cpp
===================================================================
RCS file: /home/kde/kdebase/ksmserver/shutdown.cpp,v
retrieving revision 1.18
diff -u -b -r1.18 shutdown.cpp
--- shutdown.cpp 2002/01/04 22:44:59 1.18
+++ shutdown.cpp 2002/01/30 21:46:07
@@ -13,7 +13,6 @@
#include <qcheckbox.h>
#include <qradiobutton.h>
#include <qvbuttongroup.h>
-#include <qpushbutton.h>
#include <qlabel.h>
#include <qvbox.h>
#include <qpainter.h>
@@ -24,6 +23,8 @@
#include <klocale.h>
#include <kapplication.h>
#include <kdebug.h>
+#include <kpushbutton.h>
+#include <kstdguiitem.h>
#include <kwin.h>
#include <X11/Xlib.h>
@@ -48,22 +49,6 @@
p.end();
}
-void KSMShutdownFeedback::start() //static
-{
- (void) self();
-}
-
-void KSMShutdownFeedback::keyPressEvent( QKeyEvent * event )
-{
- if ( event->key() == Key_Escape )
- {
- kdDebug() << "Esc pressed -> aborting shutdown" << endl;
- emit aborted();
- }
- else
- QWidget::keyPressEvent( event );
-}
-
//////
KSMShutdownDlg::KSMShutdownDlg( QWidget* parent,
@@ -83,10 +68,12 @@
vbox->addWidget( frame );
vbox = new QVBoxLayout( frame, 15, 5 );
- QLabel* label = new QLabel(i18n(
- "<center><b><big><big>End KDE \
Session?</big></big></b></center>"),
- frame );
- vbox->addWidget( label );
+ QLabel* label = new QLabel( i18n("End KDE Session?"), frame );
+ QFont fnt = label->font();
+ fnt.setBold( true );
+ fnt.setPixelSize( fnt.pixelSize() * 3 / 2 );
+ label->setFont( fnt );
+ vbox->addWidget( label, 0, AlignHCenter );
if (maysd)
{
@@ -104,26 +91,33 @@
rTry = new QRadioButton( i18n("&Try Now"), mgrp );
hbox->addWidget( mgrp, AlignTop );
}
- else
- vbox->addStretch();
checkbox = new QCheckBox( i18n("&Save session for future logins"), \
frame );
- vbox->addWidget( checkbox, 0, AlignLeft );
+ vbox->addWidget( checkbox, 0, AlignCenter );
vbox->addStretch();
+#if 0
+ QFrame *line = new QFrame( frame );
+ line->setFrameShape( QFrame::HLine );
+ line->setFrameShadow( QFrame::Sunken );
+ vbox->addWidget( line );
+#endif
+
QHBoxLayout* hbox = new QHBoxLayout( vbox );
hbox->addStretch();
- QPushButton* yes = new QPushButton(maysd ? i18n("&OK") : \
i18n("&Logout"), frame ); + KPushButton* yes = new KPushButton( maysd ?
+ KStdGuiItem::ok() :
+ KGuiItem( i18n( "&Logout" ) ),
+ frame );
connect( yes, SIGNAL( clicked() ), SLOT( accept() ) );
yes->setDefault( TRUE );
hbox->addWidget( yes );
hbox->addStretch();
- QPushButton* cancel = new QPushButton(i18n("&Cancel"), frame );
+ KPushButton* cancel = new KPushButton( KStdGuiItem::cancel(), frame );
connect( cancel, SIGNAL( clicked() ), SLOT( reject() ) );
hbox->addWidget( cancel );
hbox->addStretch();
- QTimer::singleShot( 0, this, SLOT( requestFocus() ) );
checkbox->setFocus();
checkbox->setChecked( saveSession );
@@ -151,11 +145,6 @@
mgrp->setEnabled( !rLogout->isChecked() );
}
-void KSMShutdownDlg::requestFocus()
-{
- XSetInputFocus( qt_xdisplay(), winId(), RevertToParent, CurrentTime );
-}
-
bool KSMShutdownDlg::confirmShutdown( bool& saveSession,
bool maysd, bool maynuke,
KApplication::ShutdownType& sdtype, KApplication::ShutdownMode& sdmode )
@@ -175,12 +164,11 @@
QRect rect = desktop->screenGeometry(desktop->screenNumber(QCursor::pos()));
l->move(rect.x() + (rect.width() - sh.width())/2,
rect.y() + (rect.height() - sh.height())/2);
+ l->show();
+ XSetInputFocus( qt_xdisplay(), l->winId(), RevertToParent, CurrentTime \
); bool result = l->exec();
l->hide();
- // Restore background
- bitBlt( KSMShutdownFeedback::self(), l->x(), l->y(), &l->pixmap() );
-
if (maysd)
{
sdtype = l->rHalt->isChecked() ? KApplication::ShutdownTypeHalt \
: @@ -207,3 +195,8 @@
x(), y(), width(), height() );
}
+void KSMShutdownDlg::hideEvent( QHideEvent * )
+{
+ // Restore background
+ bitBlt( KSMShutdownFeedback::self(), x(), y(), &pm );
+}
Index: shutdown.h
===================================================================
RCS file: /home/kde/kdebase/ksmserver/shutdown.h,v
retrieving revision 1.4
diff -u -b -r1.4 shutdown.h
--- shutdown.h 2002/01/04 22:44:59 1.4
+++ shutdown.h 2002/01/30 21:46:07
@@ -19,51 +19,39 @@
class KSMShutdownFeedback : public QWidget
{
Q_OBJECT
-protected:
- KSMShutdownFeedback();
-public:
- static KSMShutdownFeedback * self() {
- if ( !s_pSelf )
- s_pSelf = new KSMShutdownFeedback;
- return s_pSelf;
- }
- ~KSMShutdownFeedback() {}
- static void start();
+public:
+ static void start() { if ( !s_pSelf ) s_pSelf = new \
KSMShutdownFeedback; } static void stop() { delete s_pSelf; s_pSelf = 0L; \
}
-
+ static KSMShutdownFeedback * self() { return s_pSelf; }
// TODO more feedback (which apps have saved themselves, etc.)
-signals:
- void aborted();
+protected:
+ ~KSMShutdownFeedback() {}
private:
- //virtual void paintEvent( QPaintEvent *event );
- virtual void keyPressEvent( QKeyEvent * event );
static KSMShutdownFeedback * s_pSelf;
+ KSMShutdownFeedback();
};
// The confirmation dialog
class KSMShutdownDlg : public QDialog
{
Q_OBJECT
-public:
- KSMShutdownDlg( QWidget* parent, bool saveSession, bool maysd, bool \
maynuke, KApplication::ShutdownType sdtype, KApplication::ShutdownMode \
sdmode );
- ~KSMShutdownDlg() {}
+public:
static bool confirmShutdown( bool& saveSession, bool maysd, bool \
maynuke, KApplication::ShutdownType& sdtype, KApplication::ShutdownMode& \
sdmode );
- const QPixmap & pixmap() { return pm; }
-
public slots:
void slotSdMode(int);
-private slots:
- void requestFocus();
+protected:
+ ~KSMShutdownDlg() {};
+ virtual void showEvent( QShowEvent * );
+ virtual void hideEvent( QHideEvent * );
private:
- virtual void mousePressEvent( QMouseEvent * ){}
- virtual void showEvent( QShowEvent * e );
+ KSMShutdownDlg( QWidget* parent, bool saveSession, bool maysd, bool \
maynuke, KApplication::ShutdownType sdtype, KApplication::ShutdownMode \
sdmode ); QCheckBox* checkbox;
QRadioButton *rLogout, *rHalt, *rReboot, *rSched, *rTry, *rForce;
QVButtonGroup *mgrp;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic