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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
|
/*
*
* $Id: k3binteractiondialog.h 619556 2007-01-03 17:38:12Z trueg $
* Copyright (C) 2003 Sebastian Trueg <trueg@k3b.org>
*
* This file is part of the K3b project.
* Copyright (C) 1998-2007 Sebastian Trueg <trueg@k3b.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
* See the file "COPYING" for the exact licensing terms.
*/
#ifndef _K3B_INTERACTION_DIALOG_H_
#define _K3B_INTERACTION_DIALOG_H_
#include <kdialog.h>
class TQGridLayout;
class TQLabel;
class KPushButton;
class TQButton;
class K3bThemedHeader;
class KConfigBase;
class KGuiItem;
/**
* This is the base dialog for all the dialogs in K3b that start
* some job. Use setMainWidget to set the contents or let mainWidget()
* create an empty plain page.
* The default implementations of the slots just emit the
* corresponding signals.
*/
class K3bInteractionDialog : public KDialog
{
Q_OBJECT
public:
/**
* The constructor.
* loadUserDefaults will be called automatically when the dialog is showing.
*
* @param title the text to be displayed in the K3b header (not the widget frame)
* @param subTitle additional text that will be displayed after the title in smaller size
* @param buttonMask combination of Buttons
* @param defaultButton may also be null to deactivate the feature
* @param configgroup The config group used for the loadUserDefaults and saveUserDefaults methods
*/
K3bInteractionDialog( TQWidget* parent = 0,
const char* name = 0,
const TQString& title = TQString(),
const TQString& subTitle = TQString(),
int buttonMask = START_BUTTON|CANCEL_BUTTON,
int defaultButton = START_BUTTON,
const TQString& configgroup = TQString(),
bool modal = true,
WFlags fl = 0 );
virtual ~K3bInteractionDialog();
void setMainWidget( TQWidget* w );
void setTitle( const TQString& title, const TQString& subTitle = TQString() );
void setDefaultButton( int b );
/**
* Reimplemented for internal reasons. The API does not change.
*/
int exec();
/**
* @param returnOnHide if false the dialog can be hidden and shown without being closed.
* one needs to call close() to actually close the dialog.
*/
int exec( bool returnOnHide );
/**
* reimplemented to allow initialization after the dialog has been opened.
*/
void show();
/**
* Reimplemented for internal reasons. The API does not change.
*/
void hide();
/**
* Reimplemented for internal reasons. The API does not change.
*/
bool close( bool alsoDelete );
inline bool close() { return close( false ); }
/**
* If no mainWidget has been set a plain page will be created.
*/
TQWidget* mainWidget();
enum Buttons {
START_BUTTON = 1,
SAVE_BUTTON = 2,
CANCEL_BUTTON = 4
};
TQSize sizeHint() const;
const TQString& configGroup() const { return m_configGroup; }
/**
* K3b's dialogs use this method to determine if it is safe to hide when starting
* some action. Take for example the copy dialog which starts a copy job with a progress
* dialog. Both the job and the progress dialog are deleted by the copy dialog after the
* progress dialog has been closed. If the copy dialog would hide itself before starting
* the job and exitLoopOnHide() would return true the hiding would result in the exec call
* of the copy dialog to return. And what would that mean for the code after the hide()
* statement (deleting of the job and so on).
*
* \return true in case this dialog will not exit it's private event loop
* in case it is hidden.
*
* \see exec(bool)
*/
bool exitLoopOnHide() const { return m_exitLoopOnHide; }
enum StartUpSettings {
LOAD_K3B_DEFAULTS = 1,
LOAD_SAVED_SETTINGS = 2,
LOAD_LAST_SETTINGS = 3
};
signals:
void started();
void canceled();
void saved();
public slots:
/**
* \deprecated use setButtonText
*/
void setStartButtonText( const TQString& text,
const TQString& tooltip = TQString(),
const TQString& whatsthis = TQString() );
/**
* \deprecated use setButtonText
*/
void setCancelButtonText( const TQString& text,
const TQString& tooltip = TQString(),
const TQString& whatsthis = TQString() );
/**
* \deprecated use setButtonText
*/
void setSaveButtonText( const TQString& text,
const TQString& tooltip = TQString(),
const TQString& whatsthis = TQString() );
void setButtonGui( int button,
const KGuiItem& );
void setButtonText( int button,
const TQString& text,
const TQString& tooltip = TQString(),
const TQString& whatsthis = TQString() );
void setButtonEnabled( int button, bool enabled );
void setButtonShown( int button, bool enabled );
/**
* If set true the init() method will be called via a TQTimer to ensure event
* handling be done before (default: false).
*/
void setDelayedInitialization( bool b ) { m_delayedInit = b; }
protected slots:
// FIXME: replace these with protected methods which are called from private slots.
virtual void slotStartClicked();
/**
* The default implementation emits the canceled() signal
* and calls close()
*/
virtual void slotCancelClicked();
virtual void slotSaveClicked();
/**
* This slot will call the toggleAll() method protecting from infinite loops
* caused by one element influencing another element which in turn influences
* the first.
*
* Connect this slot to GUI elements (like Checkboxes) that change
* the state of the whole dialog.
*/
void slotToggleAll();
protected:
/**
* Reimplement this method in case you are using slotToggleAll()
*/
virtual void toggleAll();
/**
* Reimplement this to support the save/load user default buttons.
* @p config is already set to the correct group.
*
* The save/load buttons are only activated if the config group is
* set in the constructor.
*/
virtual void saveUserDefaults( KConfigBase* config );
/**
* Reimplement this to support the save/load user default buttons.
* @p config is already set to the correct group.
*
* The save/load buttons are only activated if the config group is
* set in the constructor.
*/
virtual void loadUserDefaults( KConfigBase* config );
/**
* Reimplement this to support the "k3b defaults" button.
* set all GUI options to reasonable defaults.
*/
virtual void loadK3bDefaults();
/**
* This is called after the dialog has been shown.
* Use this for initialization that should happen
* when the user already sees the dialog.
*/
virtual void init() {}
/**
* reimplemented from TQDialog
*/
virtual bool eventFilter( TQObject*, TQEvent* );
protected slots:
/**
* Reimplemented for internal reasons. The API does not change.
*/
virtual void done( int );
private slots:
void slotLoadK3bDefaults();
void slotLoadUserDefaults();
void slotSaveUserDefaults();
void slotLoadLastSettings();
void slotStartClickedInternal();
void slotDelayedInit();
private:
void initConnections();
void initToolTipsAndWhatsThis();
void saveLastSettings();
void loadStartupSettings();
KPushButton* getButton( int );
K3bThemedHeader* m_dialogHeader;
KPushButton* m_buttonStart;
KPushButton* m_buttonSave;
KPushButton* m_buttonCancel;
TQWidget* m_mainWidget;
TQButton* m_buttonLoadSettings;
TQButton* m_buttonSaveSettings;
TQGridLayout* mainGrid;
int m_defaultButton;
TQString m_configGroup;
bool m_exitLoopOnHide;
bool m_inLoop;
bool m_inToggleMode;
bool m_delayedInit;
};
#endif
|