author | zautrix <zautrix> | 2005-02-25 11:29:28 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-02-25 11:29:28 (UTC) |
commit | ff810f8f74f6928e664bf52f8e8d128edb8ac5ad (patch) (unidiff) | |
tree | d5473801c69b42d90879104fc4d05a5ad9b69e87 /microkde | |
parent | ff8a2f593fae5ffe82f889ab70d32bf02a45f4fb (diff) | |
download | kdepimpi-ff810f8f74f6928e664bf52f8e8d128edb8ac5ad.zip kdepimpi-ff810f8f74f6928e664bf52f8e8d128edb8ac5ad.tar.gz kdepimpi-ff810f8f74f6928e664bf52f8e8d128edb8ac5ad.tar.bz2 |
many small fixes
-rw-r--r-- | microkde/kdialogbase.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/microkde/kdialogbase.cpp b/microkde/kdialogbase.cpp index 801094a..f453331 100644 --- a/microkde/kdialogbase.cpp +++ b/microkde/kdialogbase.cpp | |||
@@ -1,271 +1,273 @@ | |||
1 | #include <qtabwidget.h> | 1 | #include <qtabwidget.h> |
2 | #include <qpushbutton.h> | 2 | #include <qpushbutton.h> |
3 | #include <qlayout.h> | 3 | #include <qlayout.h> |
4 | #include <qframe.h> | 4 | #include <qframe.h> |
5 | 5 | ||
6 | 6 | ||
7 | #include "klocale.h" | 7 | #include "klocale.h" |
8 | #include "kdebug.h" | 8 | #include "kdebug.h" |
9 | 9 | ||
10 | #include "kdialogbase.h" | 10 | #include "kdialogbase.h" |
11 | 11 | ||
12 | KDialogBase::KDialogBase() | 12 | KDialogBase::KDialogBase() |
13 | { | 13 | { |
14 | } | 14 | } |
15 | 15 | ||
16 | KDialogBase::KDialogBase( QWidget *parent, const char *name, bool modal, | 16 | KDialogBase::KDialogBase( QWidget *parent, const char *name, bool modal, |
17 | const QString &caption, | 17 | const QString &caption, |
18 | int buttonMask, ButtonCode defaultButton, | 18 | int buttonMask, ButtonCode defaultButton, |
19 | bool separator, | 19 | bool separator, |
20 | const QString &user1, | 20 | const QString &user1, |
21 | const QString &user2, | 21 | const QString &user2, |
22 | const QString &user3) : | 22 | const QString &user3) : |
23 | KDialog( parent, name, modal ) | 23 | KDialog( parent, name, modal ) |
24 | { | 24 | { |
25 | init( caption, buttonMask, user1, user2 ); | 25 | init( caption, buttonMask, user1, user2 ); |
26 | if (findButton( defaultButton ) ) { | 26 | if (findButton( defaultButton ) ) { |
27 | (findButton( defaultButton ) )->setFocus(); | 27 | (findButton( defaultButton ) )->setFocus(); |
28 | (findButton( defaultButton ) )->setDefault( true ); | 28 | (findButton( defaultButton ) )->setDefault( true ); |
29 | } | 29 | } |
30 | 30 | ||
31 | } | 31 | } |
32 | 32 | ||
33 | KDialogBase::KDialogBase( int dialogFace, const QString &caption, | 33 | KDialogBase::KDialogBase( int dialogFace, const QString &caption, |
34 | int buttonMask, ButtonCode defaultButton, | 34 | int buttonMask, ButtonCode defaultButton, |
35 | QWidget *parent, const char *name, bool modal, | 35 | QWidget *parent, const char *name, bool modal, |
36 | bool separator, | 36 | bool separator, |
37 | const QString &user1, | 37 | const QString &user1, |
38 | const QString &user2, | 38 | const QString &user2, |
39 | const QString &user3) : | 39 | const QString &user3) : |
40 | KDialog( parent, name, modal ) | 40 | KDialog( parent, name, modal ) |
41 | { | 41 | { |
42 | init( caption, buttonMask, user1, user2 ); | 42 | init( caption, buttonMask, user1, user2 ); |
43 | if (findButton( defaultButton ) ) | 43 | if (findButton( defaultButton ) ) { |
44 | (findButton( defaultButton ) )->setFocus(); | 44 | (findButton( defaultButton ) )->setFocus(); |
45 | (findButton( defaultButton ) )->setDefault( true ); | ||
46 | } | ||
45 | 47 | ||
46 | } | 48 | } |
47 | 49 | ||
48 | KDialogBase::~KDialogBase() | 50 | KDialogBase::~KDialogBase() |
49 | { | 51 | { |
50 | } | 52 | } |
51 | 53 | ||
52 | void KDialogBase::init( const QString &caption, int buttonMask, | 54 | void KDialogBase::init( const QString &caption, int buttonMask, |
53 | const QString &user1 ,const QString &user2 ) | 55 | const QString &user1 ,const QString &user2 ) |
54 | { | 56 | { |
55 | mMainWidget = 0; | 57 | mMainWidget = 0; |
56 | mTabWidget = 0; | 58 | mTabWidget = 0; |
57 | mPlainPage = 0; | 59 | mPlainPage = 0; |
58 | mTopLayout = 0; | 60 | mTopLayout = 0; |
59 | if ( !caption.isEmpty() ) { | 61 | if ( !caption.isEmpty() ) { |
60 | setCaption( caption ); | 62 | setCaption( caption ); |
61 | } | 63 | } |
62 | 64 | ||
63 | if ( buttonMask & User1 ) { | 65 | if ( buttonMask & User1 ) { |
64 | mUser1Button = new QPushButton( user1, this ); | 66 | mUser1Button = new QPushButton( user1, this ); |
65 | connect( mUser1Button, SIGNAL( clicked() ), SLOT( slotUser1() ) ); | 67 | connect( mUser1Button, SIGNAL( clicked() ), SLOT( slotUser1() ) ); |
66 | } else { | 68 | } else { |
67 | mUser1Button = 0; | 69 | mUser1Button = 0; |
68 | } | 70 | } |
69 | if ( buttonMask & User2 ) { | 71 | if ( buttonMask & User2 ) { |
70 | mUser2Button = new QPushButton( user2, this ); | 72 | mUser2Button = new QPushButton( user2, this ); |
71 | connect( mUser2Button, SIGNAL( clicked() ), SLOT( slotUser2() ) ); | 73 | connect( mUser2Button, SIGNAL( clicked() ), SLOT( slotUser2() ) ); |
72 | } else { | 74 | } else { |
73 | mUser2Button = 0; | 75 | mUser2Button = 0; |
74 | } | 76 | } |
75 | 77 | ||
76 | if ( buttonMask & Ok ) { | 78 | if ( buttonMask & Ok ) { |
77 | mOkButton = new QPushButton( i18n("Ok"), this ); | 79 | mOkButton = new QPushButton( i18n("Ok"), this ); |
78 | connect( mOkButton, SIGNAL( clicked() ), SLOT( slotOk() ) ); | 80 | connect( mOkButton, SIGNAL( clicked() ), SLOT( slotOk() ) ); |
79 | mOkButton->setDefault( true ); | 81 | //mOkButton->setDefault( true ); |
80 | } else { | 82 | } else { |
81 | mOkButton = 0; | 83 | mOkButton = 0; |
82 | } | 84 | } |
83 | if ( buttonMask & Default ) { | 85 | if ( buttonMask & Default ) { |
84 | mDefaultButton = new QPushButton( i18n("Default"), this ); | 86 | mDefaultButton = new QPushButton( i18n("Default"), this ); |
85 | connect( mDefaultButton, SIGNAL( clicked() ), SIGNAL( defaultClicked() ) ); | 87 | connect( mDefaultButton, SIGNAL( clicked() ), SIGNAL( defaultClicked() ) ); |
86 | } else { | 88 | } else { |
87 | mDefaultButton = 0; | 89 | mDefaultButton = 0; |
88 | } | 90 | } |
89 | 91 | ||
90 | if ( buttonMask & Apply ) { | 92 | if ( buttonMask & Apply ) { |
91 | mApplyButton = new QPushButton( i18n("Apply"), this ); | 93 | mApplyButton = new QPushButton( i18n("Apply"), this ); |
92 | connect( mApplyButton, SIGNAL( clicked() ), SLOT( slotApply() ) ); | 94 | connect( mApplyButton, SIGNAL( clicked() ), SLOT( slotApply() ) ); |
93 | } else { | 95 | } else { |
94 | mApplyButton = 0; | 96 | mApplyButton = 0; |
95 | } | 97 | } |
96 | 98 | ||
97 | if ( buttonMask & Cancel ) { | 99 | if ( buttonMask & Cancel ) { |
98 | mCancelButton = new QPushButton( i18n("Cancel"), this ); | 100 | mCancelButton = new QPushButton( i18n("Cancel"), this ); |
99 | connect( mCancelButton, SIGNAL( clicked() ), SLOT( slotCancel() ) ); | 101 | connect( mCancelButton, SIGNAL( clicked() ), SLOT( slotCancel() ) ); |
100 | } else { | 102 | } else { |
101 | mCancelButton = 0; | 103 | mCancelButton = 0; |
102 | } | 104 | } |
103 | 105 | ||
104 | if ( buttonMask & Close ) { | 106 | if ( buttonMask & Close ) { |
105 | mCloseButton = new QPushButton( i18n("Close"), this ); | 107 | mCloseButton = new QPushButton( i18n("Close"), this ); |
106 | connect( mCloseButton, SIGNAL( clicked() ), SLOT( slotClose() ) ); | 108 | connect( mCloseButton, SIGNAL( clicked() ), SLOT( slotClose() ) ); |
107 | } else { | 109 | } else { |
108 | mCloseButton = 0; | 110 | mCloseButton = 0; |
109 | } | 111 | } |
110 | } | 112 | } |
111 | 113 | ||
112 | QTabWidget *KDialogBase::tabWidget() | 114 | QTabWidget *KDialogBase::tabWidget() |
113 | { | 115 | { |
114 | if ( !mTabWidget ) { | 116 | if ( !mTabWidget ) { |
115 | mTabWidget = new QTabWidget( this ); | 117 | mTabWidget = new QTabWidget( this ); |
116 | setMainWidget( mTabWidget ); | 118 | setMainWidget( mTabWidget ); |
117 | } | 119 | } |
118 | return mTabWidget; | 120 | return mTabWidget; |
119 | } | 121 | } |
120 | 122 | ||
121 | void KDialogBase::hideButtons() | 123 | void KDialogBase::hideButtons() |
122 | { | 124 | { |
123 | if ( mUser1Button ) mUser1Button->hide() ; | 125 | if ( mUser1Button ) mUser1Button->hide() ; |
124 | if ( mUser2Button ) mUser2Button->hide() ; | 126 | if ( mUser2Button ) mUser2Button->hide() ; |
125 | if ( mOkButton ) mOkButton->hide() ; | 127 | if ( mOkButton ) mOkButton->hide() ; |
126 | if ( mApplyButton ) mApplyButton->hide() ; | 128 | if ( mApplyButton ) mApplyButton->hide() ; |
127 | if ( mDefaultButton ) mDefaultButton->hide(); | 129 | if ( mDefaultButton ) mDefaultButton->hide(); |
128 | if ( mCancelButton ) mCancelButton->hide() ; | 130 | if ( mCancelButton ) mCancelButton->hide() ; |
129 | if ( mCloseButton ) mCloseButton->hide() ; | 131 | if ( mCloseButton ) mCloseButton->hide() ; |
130 | 132 | ||
131 | } | 133 | } |
132 | void KDialogBase::initLayout() | 134 | void KDialogBase::initLayout() |
133 | { | 135 | { |
134 | 136 | ||
135 | delete mTopLayout; | 137 | delete mTopLayout; |
136 | mTopLayout = new QVBoxLayout( this ); | 138 | mTopLayout = new QVBoxLayout( this ); |
137 | mTopLayout->setMargin( marginHint() ); | 139 | mTopLayout->setMargin( marginHint() ); |
138 | mTopLayout->setSpacing( spacingHint() ); | 140 | mTopLayout->setSpacing( spacingHint() ); |
139 | 141 | ||
140 | mTopLayout->addWidget( mMainWidget ); | 142 | mTopLayout->addWidget( mMainWidget ); |
141 | 143 | ||
142 | QBoxLayout *buttonLayout = new QHBoxLayout; | 144 | QBoxLayout *buttonLayout = new QHBoxLayout; |
143 | mTopLayout->addLayout( buttonLayout ); | 145 | mTopLayout->addLayout( buttonLayout ); |
144 | 146 | ||
145 | if ( mUser1Button ) buttonLayout->addWidget( mUser1Button ); | 147 | if ( mUser1Button ) buttonLayout->addWidget( mUser1Button ); |
146 | if ( mUser2Button ) buttonLayout->addWidget( mUser2Button ); | 148 | if ( mUser2Button ) buttonLayout->addWidget( mUser2Button ); |
147 | if ( mOkButton ) buttonLayout->addWidget( mOkButton ); | 149 | if ( mOkButton ) buttonLayout->addWidget( mOkButton ); |
148 | if ( mApplyButton ) buttonLayout->addWidget( mApplyButton ); | 150 | if ( mApplyButton ) buttonLayout->addWidget( mApplyButton ); |
149 | if ( mDefaultButton ) buttonLayout->addWidget( mDefaultButton ); | 151 | if ( mDefaultButton ) buttonLayout->addWidget( mDefaultButton ); |
150 | if ( mCancelButton ) buttonLayout->addWidget( mCancelButton ); | 152 | if ( mCancelButton ) buttonLayout->addWidget( mCancelButton ); |
151 | if ( mCloseButton ) buttonLayout->addWidget( mCloseButton ); | 153 | if ( mCloseButton ) buttonLayout->addWidget( mCloseButton ); |
152 | } | 154 | } |
153 | 155 | ||
154 | QFrame *KDialogBase::addPage( const QString &name ) | 156 | QFrame *KDialogBase::addPage( const QString &name ) |
155 | { | 157 | { |
156 | // kdDebug() << "KDialogBase::addPage(): " << name << endl; | 158 | // kdDebug() << "KDialogBase::addPage(): " << name << endl; |
157 | QFrame *frame = new QFrame( tabWidget() ); | 159 | QFrame *frame = new QFrame( tabWidget() ); |
158 | tabWidget()->addTab( frame, name ); | 160 | tabWidget()->addTab( frame, name ); |
159 | return frame; | 161 | return frame; |
160 | } | 162 | } |
161 | 163 | ||
162 | QFrame *KDialogBase::addPage( const QString &name, int, const QPixmap & ) | 164 | QFrame *KDialogBase::addPage( const QString &name, int, const QPixmap & ) |
163 | { | 165 | { |
164 | return addPage( name ); | 166 | return addPage( name ); |
165 | } | 167 | } |
166 | 168 | ||
167 | 169 | ||
168 | void KDialogBase::setMainWidget( QWidget *widget ) | 170 | void KDialogBase::setMainWidget( QWidget *widget ) |
169 | { | 171 | { |
170 | kdDebug() << "KDialogBase::setMainWidget()" << endl; | 172 | kdDebug() << "KDialogBase::setMainWidget()" << endl; |
171 | 173 | ||
172 | mMainWidget = widget; | 174 | mMainWidget = widget; |
173 | initLayout(); | 175 | initLayout(); |
174 | } | 176 | } |
175 | 177 | ||
176 | void KDialogBase::setButtonText( ButtonCode id, const QString &text ) | 178 | void KDialogBase::setButtonText( ButtonCode id, const QString &text ) |
177 | { | 179 | { |
178 | QPushButton *button = findButton( id ); | 180 | QPushButton *button = findButton( id ); |
179 | if ( button ) { | 181 | if ( button ) { |
180 | button->setText( text ); | 182 | button->setText( text ); |
181 | } | 183 | } |
182 | } | 184 | } |
183 | 185 | ||
184 | void KDialogBase::enableButton( ButtonCode id, bool state ) | 186 | void KDialogBase::enableButton( ButtonCode id, bool state ) |
185 | { | 187 | { |
186 | QPushButton *button = findButton( id ); | 188 | QPushButton *button = findButton( id ); |
187 | if ( button ) { | 189 | if ( button ) { |
188 | button->setEnabled( state ); | 190 | button->setEnabled( state ); |
189 | } | 191 | } |
190 | } | 192 | } |
191 | 193 | ||
192 | QPushButton *KDialogBase::findButton( ButtonCode id ) | 194 | QPushButton *KDialogBase::findButton( ButtonCode id ) |
193 | { | 195 | { |
194 | QPushButton *button = 0; | 196 | QPushButton *button = 0; |
195 | switch ( id ) { | 197 | switch ( id ) { |
196 | case Ok: | 198 | case Ok: |
197 | button = mOkButton; | 199 | button = mOkButton; |
198 | break; | 200 | break; |
199 | case Apply: | 201 | case Apply: |
200 | button = mApplyButton; | 202 | button = mApplyButton; |
201 | break; | 203 | break; |
202 | case User1: | 204 | case User1: |
203 | button = mUser1Button; | 205 | button = mUser1Button; |
204 | break; | 206 | break; |
205 | case User2: | 207 | case User2: |
206 | button = mUser2Button; | 208 | button = mUser2Button; |
207 | break; | 209 | break; |
208 | case Cancel: | 210 | case Cancel: |
209 | button = mCancelButton; | 211 | button = mCancelButton; |
210 | break; | 212 | break; |
211 | case Default: | 213 | case Default: |
212 | button = mDefaultButton; | 214 | button = mDefaultButton; |
213 | break; | 215 | break; |
214 | case Close: | 216 | case Close: |
215 | button = mCloseButton; | 217 | button = mCloseButton; |
216 | break; | 218 | break; |
217 | default: | 219 | default: |
218 | break; | 220 | break; |
219 | } | 221 | } |
220 | return button; | 222 | return button; |
221 | } | 223 | } |
222 | 224 | ||
223 | void KDialogBase::enableButtonOK( bool state ) | 225 | void KDialogBase::enableButtonOK( bool state ) |
224 | { | 226 | { |
225 | enableButton( Ok, state ); | 227 | enableButton( Ok, state ); |
226 | } | 228 | } |
227 | 229 | ||
228 | void KDialogBase::enableButtonApply( bool state ) | 230 | void KDialogBase::enableButtonApply( bool state ) |
229 | { | 231 | { |
230 | enableButton( Apply, state ); | 232 | enableButton( Apply, state ); |
231 | } | 233 | } |
232 | 234 | ||
233 | void KDialogBase::showButton( ButtonCode id, bool show ) | 235 | void KDialogBase::showButton( ButtonCode id, bool show ) |
234 | { | 236 | { |
235 | QPushButton *button = findButton( id ); | 237 | QPushButton *button = findButton( id ); |
236 | if ( button ) { | 238 | if ( button ) { |
237 | if ( show ) button->show(); | 239 | if ( show ) button->show(); |
238 | else button->hide(); | 240 | else button->hide(); |
239 | } | 241 | } |
240 | } | 242 | } |
241 | 243 | ||
242 | int KDialogBase::pageIndex( QWidget *widget ) const | 244 | int KDialogBase::pageIndex( QWidget *widget ) const |
243 | { | 245 | { |
244 | return 0; | 246 | return 0; |
245 | } | 247 | } |
246 | 248 | ||
247 | 249 | ||
248 | bool KDialogBase::showPage( int index ) | 250 | bool KDialogBase::showPage( int index ) |
249 | { | 251 | { |
250 | tabWidget()->setCurrentPage( index );return false; | 252 | tabWidget()->setCurrentPage( index );return false; |
251 | } | 253 | } |
252 | 254 | ||
253 | QFrame *KDialogBase::plainPage() | 255 | QFrame *KDialogBase::plainPage() |
254 | { | 256 | { |
255 | if ( !mPlainPage ) { | 257 | if ( !mPlainPage ) { |
256 | mPlainPage = new QFrame( this ); | 258 | mPlainPage = new QFrame( this ); |
257 | setMainWidget( mPlainPage ); | 259 | setMainWidget( mPlainPage ); |
258 | } | 260 | } |
259 | return mPlainPage; | 261 | return mPlainPage; |
260 | } | 262 | } |
261 | 263 | ||
262 | void KDialogBase::slotOk() | 264 | void KDialogBase::slotOk() |
263 | { | 265 | { |
264 | emit okClicked(); | 266 | emit okClicked(); |
265 | accept(); | 267 | accept(); |
266 | } | 268 | } |
267 | 269 | ||
268 | void KDialogBase::slotApply() | 270 | void KDialogBase::slotApply() |
269 | { | 271 | { |
270 | emit applyClicked(); | 272 | emit applyClicked(); |
271 | } | 273 | } |