summaryrefslogtreecommitdiff
path: root/noncore/apps/tinykate/libkate/microkde/kdialogbase.cpp
authorjowenn <jowenn>2002-11-10 21:08:01 (UTC)
committer jowenn <jowenn>2002-11-10 21:08:01 (UTC)
commite97a6da57804aa14907dec327fbae71bff9b383e (patch) (unidiff)
tree15f6ee292dba24bdda72f5c72f6d2224c3516763 /noncore/apps/tinykate/libkate/microkde/kdialogbase.cpp
parent7c012ee8cd16d8befacc6f6750711443fac0fd5e (diff)
downloadopie-e97a6da57804aa14907dec327fbae71bff9b383e.zip
opie-e97a6da57804aa14907dec327fbae71bff9b383e.tar.gz
opie-e97a6da57804aa14907dec327fbae71bff9b383e.tar.bz2
import of tiny kate. (saving not possible yet)
Diffstat (limited to 'noncore/apps/tinykate/libkate/microkde/kdialogbase.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/tinykate/libkate/microkde/kdialogbase.cpp214
1 files changed, 214 insertions, 0 deletions
diff --git a/noncore/apps/tinykate/libkate/microkde/kdialogbase.cpp b/noncore/apps/tinykate/libkate/microkde/kdialogbase.cpp
new file mode 100644
index 0000000..8caefe0
--- a/dev/null
+++ b/noncore/apps/tinykate/libkate/microkde/kdialogbase.cpp
@@ -0,0 +1,214 @@
1#include <qtabwidget.h>
2#include <qpushbutton.h>
3#include <qlayout.h>
4#include <qframe.h>
5
6#include "klocale.h"
7#include "kdebug.h"
8
9#include "kdialogbase.h"
10
11KDialogBase::KDialogBase()
12{
13}
14
15KDialogBase::KDialogBase( QWidget *parent, const char *name, bool modal,
16 const QString &caption,
17 int buttonMask, ButtonCode defaultButton,
18 bool separator,
19 const QString &user1,
20 const QString &user2,
21 const QString &user3) :
22 KDialog( parent, name, modal )
23{
24 init( caption, buttonMask, user1 );
25}
26
27KDialogBase::KDialogBase( int dialogFace, const QString &caption,
28 int buttonMask, ButtonCode defaultButton,
29 QWidget *parent, const char *name, bool modal,
30 bool separator,
31 const QString &user1,
32 const QString &user2,
33 const QString &user3) :
34 KDialog( parent, name, modal )
35{
36 init( caption, buttonMask, user1 );
37}
38
39KDialogBase::~KDialogBase()
40{
41}
42
43void KDialogBase::init( const QString &caption, int buttonMask,
44 const QString &user1 )
45{
46 mMainWidget = 0;
47 mTabWidget = 0;
48 mPlainPage = 0;
49 mTopLayout = 0;
50
51 if ( !caption.isEmpty() ) {
52 setCaption( caption );
53 }
54
55 if ( buttonMask & User1 ) {
56 mUser1Button = new QPushButton( user1, this );
57 connect( mUser1Button, SIGNAL( clicked() ), SLOT( slotUser1() ) );
58 } else {
59 mUser1Button = 0;
60 }
61
62 if ( buttonMask & Ok ) {
63 mOkButton = new QPushButton( i18n("Ok"), this );
64 connect( mOkButton, SIGNAL( clicked() ), SLOT( slotOk() ) );
65 } else {
66 mOkButton = 0;
67 }
68
69 if ( buttonMask & Apply ) {
70 mApplyButton = new QPushButton( i18n("Apply"), this );
71 connect( mApplyButton, SIGNAL( clicked() ), SLOT( slotApply() ) );
72 } else {
73 mApplyButton = 0;
74 }
75
76 if ( buttonMask & Cancel ) {
77 mCancelButton = new QPushButton( i18n("Cancel"), this );
78 connect( mCancelButton, SIGNAL( clicked() ), SLOT( slotCancel() ) );
79 } else {
80 mCancelButton = 0;
81 }
82
83 if ( buttonMask & Close ) {
84 mCloseButton = new QPushButton( i18n("Close"), this );
85 connect( mCloseButton, SIGNAL( clicked() ), SLOT( slotClose() ) );
86 } else {
87 mCloseButton = 0;
88 }
89}
90
91QTabWidget *KDialogBase::tabWidget()
92{
93 if ( !mTabWidget ) {
94 mTabWidget = new QTabWidget( this );
95 setMainWidget( mTabWidget );
96 }
97 return mTabWidget;
98}
99
100void KDialogBase::initLayout()
101{
102 delete mTopLayout;
103 mTopLayout = new QVBoxLayout( this );
104 mTopLayout->setMargin( marginHint() );
105 mTopLayout->setSpacing( spacingHint() );
106
107 mTopLayout->addWidget( mMainWidget );
108
109 QBoxLayout *buttonLayout = new QHBoxLayout;
110 mTopLayout->addLayout( buttonLayout );
111
112 if ( mUser1Button ) buttonLayout->addWidget( mUser1Button );
113 if ( mOkButton ) buttonLayout->addWidget( mOkButton );
114 if ( mApplyButton ) buttonLayout->addWidget( mApplyButton );
115 if ( mCancelButton ) buttonLayout->addWidget( mCancelButton );
116 if ( mCloseButton ) buttonLayout->addWidget( mCloseButton );
117}
118
119QFrame *KDialogBase::addPage( const QString &name )
120{
121// kdDebug() << "KDialogBase::addPage(): " << name << endl;
122
123 QFrame *frame = new QFrame( tabWidget() );
124 tabWidget()->addTab( frame, name );
125 return frame;
126}
127
128QFrame *KDialogBase::addPage( const QString &name, int, const QPixmap & )
129{
130 return addPage( name );
131}
132
133
134void KDialogBase::setMainWidget( QWidget *widget )
135{
136 kdDebug() << "KDialogBase::setMainWidget()" << endl;
137
138 mMainWidget = widget;
139 initLayout();
140}
141
142
143void KDialogBase::enableButton( ButtonCode id, bool state )
144{
145 QPushButton *button = 0;
146 switch ( id ) {
147 case Ok:
148 button = mOkButton;
149 break;
150 case Apply:
151 button = mApplyButton;
152 break;
153 default:
154 break;
155 }
156 if ( button ) {
157 button->setEnabled( state );
158 }
159}
160
161void KDialogBase::enableButtonOK( bool state )
162{
163 enableButton( Ok, state );
164}
165
166void KDialogBase::enableButtonApply( bool state )
167{
168 enableButton( Apply, state );
169}
170
171
172int KDialogBase::pageIndex( QWidget *widget ) const
173{
174 return 0;
175}
176
177
178bool KDialogBase::showPage( int index )
179{
180 return false;
181}
182
183QFrame *KDialogBase::plainPage()
184{
185 if ( !mPlainPage ) {
186 mPlainPage = new QFrame( this );
187 setMainWidget( mPlainPage );
188 }
189 return mPlainPage;
190}
191
192void KDialogBase::slotOk()
193{
194 accept();
195}
196
197void KDialogBase::slotApply()
198{
199}
200
201void KDialogBase::slotCancel()
202{
203 reject();
204}
205
206void KDialogBase::slotClose()
207{
208 accept();
209}
210
211void KDialogBase::slotUser1()
212{
213 emit user1Clicked();
214}