1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
//===========================================================================
//
// This file is part of the KDE project
//
// Copyright (c) 2004 Chris Howells <[email protected]>
#include "lockprocess.h"
#include "autologout.h"
#include <kapplication.h>
#include <klocale.h>
#include <kglobalsettings.h>
#include <kconfig.h>
#include <kiconloader.h>
#include <kdebug.h>
#include <dcopref.h>
#include <kmessagebox.h>
#include <kdialog.h>
#include <tqlayout.h>
#include <tqmessagebox.h>
#include <tqlabel.h>
#include <tqstyle.h>
#include <tqapplication.h>
#include <tqdialog.h>
#include <tqprogressbar.h>
#define COUNTDOWN 30
AutoLogout::AutoLogout(LockProcess *parent) : TQDialog(parent, "password dialog", true, (WFlags)WX11BypassWM)
{
frame = new TQFrame(this);
frame->setFrameStyle(TQFrame::Panel | TQFrame::Raised);
frame->setLineWidth(2);
TQLabel *pixLabel = new TQLabel( frame, "pixlabel" );
pixLabel->setPixmap(DesktopIcon("exit"));
TQLabel *greetLabel = new TQLabel(i18n("<nobr><qt><b>Automatic Log Out</b></qt><nobr>"), frame);
TQLabel *infoLabel = new TQLabel(i18n("<qt>To prevent being logged out, resume using this session by moving the mouse or pressing a key.</qt>"), frame);
mStatusLabel = new TQLabel("<b> </b>", frame);
mStatusLabel->tqsetAlignment(TQLabel::AlignCenter);
TQLabel *mProgressLabel = new TQLabel("Time Remaining:", frame);
mProgressRemaining = new TQProgressBar(frame);
mProgressRemaining->setPercentageVisible(false);
TQVBoxLayout *unlockDialogLayout = new TQVBoxLayout( this );
unlockDialogLayout->addWidget( frame );
frameLayout = new TQGridLayout(frame, 1, 1, KDialog::marginHint(), KDialog::spacingHint());
frameLayout->addMultiCellWidget(pixLabel, 0, 2, 0, 0, Qt::AlignCenter | Qt::AlignTop);
frameLayout->addWidget(greetLabel, 0, 1);
frameLayout->addWidget(mStatusLabel, 1, 1);
frameLayout->addWidget(infoLabel, 2, 1);
frameLayout->addWidget(mProgressLabel, 3, 1);
frameLayout->addWidget(mProgressRemaining, 4, 1);
// get the time remaining in seconds for the status label
mRemaining = COUNTDOWN * 25;
mProgressRemaining->setTotalSteps(COUNTDOWN * 25);
updateInfo(mRemaining);
mCountdownTimerId = startTimer(1000/25);
connect(tqApp, TQT_SIGNAL(activity()), TQT_SLOT(slotActivity()));
}
AutoLogout::~AutoLogout()
{
hide();
}
void AutoLogout::updateInfo(int timeout)
{
mStatusLabel->setText(i18n("<nobr><qt>You will be automatically logged out in 1 second</qt></nobr>",
"<nobr><qt>You will be automatically logged out in %n seconds</qt></nobr>",
timeout / 25) );
mProgressRemaining->setProgress(timeout);
}
void AutoLogout::timerEvent(TQTimerEvent *ev)
{
if (ev->timerId() == mCountdownTimerId)
{
updateInfo(mRemaining);
--mRemaining;
if (mRemaining < 0)
{
logout();
}
}
}
void AutoLogout::slotActivity()
{
accept();
}
void AutoLogout::logout()
{
TQT_TQOBJECT(this)->killTimers();
DCOPRef("ksmserver","ksmserver").send("logout", 0, 0, 0);
}
void AutoLogout::show()
{
TQDialog::show();
TQApplication::flushX();
}
#include "autologout.moc"
|