1
//===========================================================================
3
// This file is part of the KDE project
5
// Copyright (c) 2004 Chris Howells <howells@kde.org>
7
#include "lockprocess.h"
8
#include "autologout.h"
10
#include <kapplication.h>
12
#include <kglobalsettings.h>
14
#include <kiconloader.h>
17
#include <kmessagebox.h>
21
#include <qmessagebox.h>
24
#include <qapplication.h>
26
#include <qprogressbar.h>
30
AutoLogout::AutoLogout(LockProcess *parent) : QDialog(parent, "password dialog", true, WX11BypassWM)
32
frame = new QFrame(this);
33
frame->setFrameStyle(QFrame::Panel | QFrame::Raised);
34
frame->setLineWidth(2);
36
QLabel *pixLabel = new QLabel( frame, "pixlabel" );
37
pixLabel->setPixmap(DesktopIcon("exit"));
39
QLabel *greetLabel = new QLabel(i18n("<nobr><qt><b>Automatic Log Out</b></qt><nobr>"), frame);
40
QLabel *infoLabel = new QLabel(i18n("<qt>To prevent being logged out, resume using this session by moving the mouse or pressing a key.</qt>"), frame);
42
mStatusLabel = new QLabel("<b> </b>", frame);
43
mStatusLabel->setAlignment(QLabel::AlignCenter);
45
QLabel *mProgressLabel = new QLabel("Time Remaining:", frame);
46
mProgressRemaining = new QProgressBar(frame);
47
mProgressRemaining->setPercentageVisible(false);
49
QVBoxLayout *unlockDialogLayout = new QVBoxLayout( this );
50
unlockDialogLayout->addWidget( frame );
52
frameLayout = new QGridLayout(frame, 1, 1, KDialog::marginHint(), KDialog::spacingHint());
53
frameLayout->addMultiCellWidget(pixLabel, 0, 2, 0, 0, Qt::AlignCenter | Qt::AlignTop);
54
frameLayout->addWidget(greetLabel, 0, 1);
55
frameLayout->addWidget(mStatusLabel, 1, 1);
56
frameLayout->addWidget(infoLabel, 2, 1);
57
frameLayout->addWidget(mProgressLabel, 3, 1);
58
frameLayout->addWidget(mProgressRemaining, 4, 1);
60
// get the time remaining in seconds for the status label
61
mRemaining = COUNTDOWN * 25;
63
mProgressRemaining->setTotalSteps(COUNTDOWN * 25);
65
updateInfo(mRemaining);
67
mCountdownTimerId = startTimer(1000/25);
69
connect(qApp, SIGNAL(activity()), SLOT(slotActivity()));
72
AutoLogout::~AutoLogout()
77
void AutoLogout::updateInfo(int timeout)
79
mStatusLabel->setText(i18n("<nobr><qt>You will be automatically logged out in 1 second</qt></nobr>",
80
"<nobr><qt>You will be automatically logged out in %n seconds</qt></nobr>",
82
mProgressRemaining->setProgress(timeout);
85
void AutoLogout::timerEvent(QTimerEvent *ev)
87
if (ev->timerId() == mCountdownTimerId)
89
updateInfo(mRemaining);
98
void AutoLogout::slotActivity()
103
void AutoLogout::logout()
106
DCOPRef("ksmserver","ksmserver").send("logout", 0, 0, 0);
109
void AutoLogout::show()
112
QApplication::flushX();
115
#include "autologout.moc"