~ubuntu-branches/ubuntu/utopic/kde-workspace/utopic-proposed

« back to all changes in this revision

Viewing changes to kwin/kcmkwin/kwincompositing/ktimerdialog.h

  • Committer: Bazaar Package Importer
  • Author(s): Michał Zając
  • Date: 2011-07-09 08:31:15 UTC
  • Revision ID: james.westby@ubuntu.com-20110709083115-ohyxn6z93mily9fc
Tags: upstream-4.6.90
Import upstream version 4.6.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *  This file is part of the KDE Libraries
 
3
 *  Copyright (C) 2002 Hamish Rodda <rodda@kde.org>
 
4
 *
 
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.
 
9
 *
 
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.
 
14
 *
 
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.
 
19
 *
 
20
 */
 
21
#ifndef _KTIMERDIALOG_H_
 
22
#define _KTIMERDIALOG_H_
 
23
 
 
24
#include <QLabel>
 
25
 
 
26
#include <kdialog.h>
 
27
#include <kvbox.h>
 
28
 
 
29
class QTimer;
 
30
class KHBox;
 
31
class QProgressBar;
 
32
class QLabel;
 
33
 
 
34
/**
 
35
 * Provides a dialog that is only available for a specified amount
 
36
 * of time, and reports the time remaining to the user.
 
37
 *
 
38
 * The timer is capable of counting up or down, for any number of milliseconds.
 
39
 *
 
40
 * The button which is activated upon timeout can be specified, as can the
 
41
 * update interval for the dialog box.
 
42
 *
 
43
 * In addition, this class retains all of the functionality of @see KDialog.
 
44
 *
 
45
 * @short A dialog with a time limit and corresponding UI features.
 
46
 * @author Hamish Rodda <rodda@kde.org>
 
47
 */
 
48
class KTimerDialog : public KDialog
 
49
{
 
50
    Q_OBJECT
 
51
 
 
52
public:
 
53
 
 
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.
 
59
     */
 
60
    enum TimerStyle {
 
61
        CountDown,
 
62
        CountUp,
 
63
        Manual
 
64
    };
 
65
 
 
66
    /**
 
67
     * Constructor for the standard mode where you must specify the main
 
68
     * widget with @ref setMainWidget() . See @see KDialog for further details.
 
69
     *
 
70
     * For the rest of the arguments, See @see KDialog .
 
71
     */
 
72
    explicit KTimerDialog(int msec, TimerStyle style = CountDown, QWidget *parent = 0,
 
73
                          const QString &caption = QString(),
 
74
                          int buttonMask = Ok | Apply | Cancel, ButtonCode defaultButton = Ok,
 
75
                          bool separator = false,
 
76
                          const KGuiItem &user1 = KGuiItem(),
 
77
                          const KGuiItem &user2 = KGuiItem(),
 
78
                          const KGuiItem &user3 = KGuiItem());
 
79
 
 
80
    /**
 
81
     * Destructor.
 
82
     */
 
83
    ~KTimerDialog();
 
84
 
 
85
    /**
 
86
     * Execute the dialog modelessly - see @see QDialog .
 
87
     */
 
88
    virtual void setVisible(bool visible);
 
89
 
 
90
    /**
 
91
     * Set the refresh interval for the timer progress. Defaults to one second.
 
92
     */
 
93
    void setRefreshInterval(int msec);
 
94
 
 
95
    /**
 
96
     * Retrieves the @ref ButtonCode which will be activated once the timer
 
97
     * times out. @see setTimeoutButton
 
98
     */
 
99
    int timeoutButton() const;
 
100
 
 
101
    /**
 
102
     * Sets the @ref ButtonCode to determine which button will be activated
 
103
     * once the timer times out. @see timeoutButton
 
104
     */
 
105
    void setTimeoutButton(ButtonCode newButton);
 
106
 
 
107
    /**
 
108
     * Retrieves the current @ref TimerStyle. @see setTimerStyle
 
109
     */
 
110
    int timerStyle() const;
 
111
 
 
112
    /**
 
113
     * Sets the @ref TimerStyle. @see timerStyle
 
114
     */
 
115
    void setTimerStyle(TimerStyle newStyle);
 
116
 
 
117
    /**
 
118
     * Overridden function which is used to set the main widget of the dialog.
 
119
     * @see KDialog::setMainWidget.
 
120
     */
 
121
    void setMainWidget(QWidget *widget);
 
122
 
 
123
Q_SIGNALS:
 
124
    /**
 
125
     * Signal which is emitted once the timer has timed out.
 
126
     */
 
127
    void timerTimeout();
 
128
 
 
129
public Q_SLOTS:
 
130
    /**
 
131
     * Execute the dialog modally - see @see QDialog .
 
132
     */
 
133
    int exec();
 
134
 
 
135
private Q_SLOTS:
 
136
    /**
 
137
     * Updates the dialog with the current progress levels.
 
138
     */
 
139
    void slotUpdateTime(bool update = true);
 
140
 
 
141
    /**
 
142
     * The internal
 
143
     */
 
144
    void slotInternalTimeout();
 
145
 
 
146
private:
 
147
    /**
 
148
     * Prepares the layout that manages the widgets of the dialog
 
149
     */
 
150
    void setupLayout();
 
151
 
 
152
    QTimer *totalTimer;
 
153
    QTimer *updateTimer;
 
154
    int msecRemaining, updateInterval, msecTotal;
 
155
 
 
156
    ButtonCode buttonOnTimeout;
 
157
    TimerStyle tStyle;
 
158
 
 
159
    KHBox *timerWidget;
 
160
    QProgressBar *timerProgress;
 
161
    QLabel *timerLabel;
 
162
    KVBox *mainWidget;
 
163
 
 
164
    class KTimerDialogPrivate;
 
165
    KTimerDialogPrivate *d;
 
166
};
 
167
 
 
168
#endif
 
169
 
 
170
 
 
171