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