add more spacing
[personal-kdebase.git] / workspace / kcontrol / randr / ktimerdialog.h
blobbfbbf1c7fcd1332887424e380bb13e8ad73c24c0
1 /*
2 * This file is part of the KDE Libraries
3 * Copyright (C) 2002 Hamish Rodda <rodda@kde.org>
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public License
16 * along with this library; see the file COPYING.LIB. If not, write to
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
21 #ifndef _KTIMERDIALOG_H_
22 #define _KTIMERDIALOG_H_
24 #include <QLabel>
26 #include <kdialog.h>
27 #include <kvbox.h>
29 class QTimer;
30 class KHBox;
31 class QProgressBar;
32 class QLabel;
34 /**
35 * Provides a dialog that is only available for a specified amount
36 * of time, and reports the time remaining to the user.
38 * The timer is capable of counting up or down, for any number of milliseconds.
40 * The button which is activated upon timeout can be specified, as can the
41 * update interval for the dialog box.
43 * In addition, this class retains all of the functionality of @see KDialog.
45 * @short A dialog with a time limit and corresponding UI features.
46 * @author Hamish Rodda <rodda@kde.org>
48 class KTimerDialog : public KDialog
50 Q_OBJECT
52 public:
54 /**
55 * @li @p CountDown - The timer counts downwards from the seconds given.
56 * @li @p CountUp - The timer counts up to the number of seconds given.
57 * @li @p Manual - The timer is not invoked; the caller must update the
58 * progress.
60 enum TimerStyle
62 CountDown,
63 CountUp,
64 Manual
67 /**
68 * Constructor for the standard mode where you must specify the main
69 * widget with @ref setMainWidget() . See @see KDialog for further details.
71 * For the rest of the arguments, See @see KDialog .
73 explicit KTimerDialog( int msec, TimerStyle style=CountDown, QWidget *parent=0,
74 const char *name=0, bool modal=true,
75 const QString &caption=QString(),
76 int buttonMask=Ok|Apply|Cancel, ButtonCode defaultButton=Ok,
77 bool separator=false,
78 const KGuiItem &user1=KGuiItem(),
79 const KGuiItem &user2=KGuiItem(),
80 const KGuiItem &user3=KGuiItem() );
82 /**
83 * Destructor.
85 ~KTimerDialog();
87 /**
88 * Execute the dialog modelessly - see @see QDialog .
90 virtual void setVisible( bool visible );
92 /**
93 * Set the refresh interval for the timer progress. Defaults to one second.
95 void setRefreshInterval( int msec );
97 /**
98 * Retrieves the @ref ButtonCode which will be activated once the timer
99 * times out. @see setTimeoutButton
101 int timeoutButton() const;
104 * Sets the @ref ButtonCode to determine which button will be activated
105 * once the timer times out. @see timeoutButton
107 void setTimeoutButton( ButtonCode newButton );
110 * Retrieves the current @ref TimerStyle. @see setTimerStyle
112 int timerStyle() const;
115 * Sets the @ref TimerStyle. @see timerStyle
117 void setTimerStyle( TimerStyle newStyle );
120 * Overridden function which is used to set the main widget of the dialog.
121 * @see KDialog::setMainWidget.
123 void setMainWidget( QWidget *widget );
125 Q_SIGNALS:
127 * Signal which is emitted once the timer has timed out.
129 void timerTimeout();
131 public Q_SLOTS:
133 * Execute the dialog modally - see @see QDialog .
135 int exec();
137 private Q_SLOTS:
139 * Updates the dialog with the current progress levels.
141 void slotUpdateTime( bool update = true );
144 * The internal
146 void slotInternalTimeout();
148 private:
150 * Prepares the layout that manages the widgets of the dialog
152 void setupLayout();
154 QTimer *totalTimer;
155 QTimer *updateTimer;
156 int msecRemaining, updateInterval, msecTotal;
158 ButtonCode buttonOnTimeout;
159 TimerStyle tStyle;
161 KHBox *timerWidget;
162 QProgressBar *timerProgress;
163 QLabel *timerLabel;
164 KVBox *mainWidget;
166 class KTimerDialogPrivate;
167 KTimerDialogPrivate *d;
170 #endif