00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
#ifndef _KDIALOG_BASE_H_
00024
#define _KDIALOG_BASE_H_
00025
00026
#include <kdialog.h>
00027
#include <kjanuswidget.h>
00028
#include <kguiitem.h>
00029
#include <kstdguiitem.h>
00030
#include <qptrlist.h>
00031
00032
class QPushButton;
00033
class KSeparator;
00034
class KURLLabel;
00035
class QBoxLayout;
00036
class QPixmap;
00037
class KGuiItem;
00042
class KDialogBaseButton;
00043
00048
class KDialogBaseTile;
00049
00193 class KDEUI_EXPORT KDialogBase :
public KDialog
00194 {
00195 Q_OBJECT
00196
00197
public:
00198
00218 enum ButtonCode
00219 {
00220 Help = 0x00000001,
00221 Default = 0x00000002,
00222 Ok = 0x00000004,
00223 Apply = 0x00000008,
00224 Try = 0x00000010,
00225 Cancel = 0x00000020,
00226 Close = 0x00000040,
00227 User1 = 0x00000080,
00228 User2 = 0x00000100,
00229 User3 = 0x00000200,
00230 No = 0x00000080,
00231 Yes = 0x00000100,
00232 Details = 0x00000400,
00233 Filler = 0x40000000,
00234 Stretch = 0x80000000,
00235 NoDefault
00236 };
00237
00238
enum ActionButtonStyle
00239 {
00240 ActionStyle0=0,
00241 ActionStyle1,
00242 ActionStyle2,
00243 ActionStyle3,
00244 ActionStyle4,
00245 ActionStyleMAX
00246 };
00247
00258 enum DialogType
00259 {
00260 TreeList = KJanusWidget::TreeList,
00261 Tabbed = KJanusWidget::Tabbed,
00262 Plain = KJanusWidget::Plain,
00263 Swallow = KJanusWidget::Swallow,
00264 IconList = KJanusWidget::IconList
00265 };
00266
00267
public:
00268
00291 KDialogBase(
QWidget *parent=0,
const char *name=0,
bool modal=
true,
00292
const QString &caption=QString::null,
00293
int buttonMask=Ok|Apply|Cancel, ButtonCode defaultButton=Ok,
00294
bool separator=
false,
00295
const KGuiItem &user1=
KGuiItem(),
00296
const KGuiItem &user2=
KGuiItem(),
00297
const KGuiItem &user3=
KGuiItem() );
00298
00326 KDialogBase(
int dialogFace,
const QString &caption,
00327
int buttonMask, ButtonCode defaultButton,
00328
QWidget *parent=0,
const char *name=0,
bool modal=
true,
00329
bool separator=
false,
00330
const KGuiItem &user1=
KGuiItem(),
00331
const KGuiItem &user2=
KGuiItem(),
00332
const KGuiItem &user3=
KGuiItem() );
00333
00334
00362 KDialogBase( KDialogBase::DialogType dialogFace, WFlags f,
00363
QWidget *parent=0,
const char *name=0,
bool modal=
true,
00364
const QString &caption=QString::null,
00365
int buttonMask=Ok|Apply|Cancel, ButtonCode defaultButton=Ok,
00366
bool separator=
false,
00367
const KGuiItem &user1=
KGuiItem(),
00368
const KGuiItem &user2=
KGuiItem(),
00369
const KGuiItem &user3=
KGuiItem() );
00370
00402 KDialogBase(
const QString &caption,
int buttonMask=Yes|No|Cancel,
00403 ButtonCode defaultButton=Yes, ButtonCode escapeButton=Cancel,
00404
QWidget *parent=0,
const char *name=0,
00405
bool modal=
true,
bool separator=
false,
00406
const KGuiItem &yes = KStdGuiItem::yes(),
00407
const KGuiItem &no = KStdGuiItem::no(),
00408
const KGuiItem &cancel = KStdGuiItem::cancel()
00409 );
00410
00414 ~KDialogBase();
00415
00426
void setButtonBoxOrientation(
int orientation );
00427
00439
void setEscapeButton( ButtonCode
id );
00440
00441
00449
virtual void adjustSize();
00450
virtual QSize sizeHint() const;
00451 virtual
QSize minimumSizeHint() const;
00452
00463
QFrame *plainPage();
00464
00492
QFrame *addPage( const
QString &itemName,
00493 const
QString &header=
QString::null,
00494 const
QPixmap &pixmap=
QPixmap() );
00495
00507
QFrame *addPage( const
QStringList &items,
00508 const
QString &header=
QString::null,
00509 const QPixmap &pixmap=QPixmap() );
00510
00535
QVBox *addVBoxPage( const
QString &itemName,
00536 const
QString &header=
QString::null,
00537 const QPixmap &pixmap=QPixmap() );
00538
00550
QVBox *addVBoxPage( const
QStringList &items,
00551 const
QString &header=
QString::null,
00552 const QPixmap &pixmap=QPixmap() );
00553
00572
QHBox *addHBoxPage( const
QString &itemName,
00573 const
QString &header=
QString::null,
00574 const QPixmap &pixmap=QPixmap() );
00575
00587
QHBox *addHBoxPage( const
QStringList &items,
00588 const
QString &header=
QString::null,
00589 const QPixmap &pixmap=QPixmap() );
00590
00611
QGrid *addGridPage(
int n, Orientation dir,
00612 const
QString &itemName,
00613 const
QString &header=
QString::null,
00614 const QPixmap &pixmap=QPixmap() );
00615
00616
00628
QGrid *addGridPage(
int n, Orientation dir,
00629 const
QStringList &items,
00630 const
QString &header=
QString::null,
00631 const QPixmap &pixmap=QPixmap() );
00632
00633
00640
void setFolderIcon(const
QStringList &path,const QPixmap &pixmap);
00641
00655
QFrame *makeMainWidget();
00656
00670
QVBox *makeVBoxMainWidget();
00671
00685
QHBox *makeHBoxMainWidget();
00686
00704
QGrid *makeGridMainWidget(
int n, Orientation dir );
00705
00706
00711
void enableButtonSeparator(
bool state );
00712
00723
void showButton( ButtonCode
id,
bool state );
00724
00733
void showButtonOK(
bool state );
00734
00743
void showButtonApply(
bool state );
00744
00751
void showButtonCancel(
bool state );
00752
00763
bool showPage(
int index );
00764
00773
int activePageIndex() const;
00774
00775
00792
int pageIndex(
QWidget *widget ) const;
00793
00794
00807
void setMainWidget(
QWidget *widget );
00808
00814
QWidget *mainWidget();
00815
00823
void disableResize();
00824
00836
void setInitialSize( const
QSize &s,
bool noResize=false );
00837
00848
void incInitialSize( const
QSize &s,
bool noResize=false );
00849
00857
QSize configDialogSize( const
QString& groupName ) const;
00858
00868
QSize configDialogSize(
KConfig& config, const
QString& groupName ) const;
00869
00879
void saveDialogSize( const
QString& groupName,
bool global=false );
00880
00891
void saveDialogSize(
KConfig& config, const
QString& groupName,
00892
bool global=false ) const;
00893
00903
void setButtonOK( const
KGuiItem &item =
KStdGuiItem::ok() );
00904
00920
void setButtonOKText( const
QString &text=
QString::null,
00921 const
QString &tooltip=
QString::null,
00922 const
QString &quickhelp=
QString::null ) KDE_DEPRECATED;
00923
00933
void setButtonApply( const
KGuiItem &item =
KStdGuiItem::apply() );
00934
00950
void setButtonApplyText( const
QString &text=
QString::null,
00951 const
QString &tooltip=
QString::null,
00952 const
QString &quickhelp=
QString::null ) KDE_DEPRECATED;
00953
00963
void setButtonCancel( const
KGuiItem &item =
KStdGuiItem::cancel() );
00964
00978
void setButtonCancelText( const
QString &text=
QString::null,
00979 const
QString &tooltip=
QString::null,
00980 const
QString &quickhelp=
QString::null ) KDE_DEPRECATED;
00981
00988
void setButtonText( ButtonCode
id, const
QString &text );
00989
00996
void setButtonTip( ButtonCode
id, const
QString &text );
00997
01004
void setButtonWhatsThis( ButtonCode
id, const
QString &text );
01005
01017
void setButtonGuiItem( ButtonCode
id, const
KGuiItem &item );
01018
01029
void setTreeListAutoResize(
bool state );
01030
01043
void setShowIconsInTreeList(
bool state);
01044
01053
void setRootIsDecorated(
bool state );
01054
01068
void unfoldTreeList(
bool persist = false );
01069
01078
void addWidgetBelowList(
QWidget * widget );
01079
01090
void addButtonBelowList( const
QString & text,
QObject * recv, const
char * slot );
01091
01103
void addButtonBelowList( const
KGuiItem & guiitem,
QObject * recv, const
char * slot );
01104
01117
void setIconListAllVisible(
bool state );
01118
01124 static
bool haveBackgroundTile();
01125
01132 static const QPixmap *backgroundTile();
01137 static const QPixmap *getBackgroundTile() KDE_DEPRECATED;
01138
01146 static
void setBackgroundTile( const QPixmap *pix );
01147
01153
void showTile(
bool state );
01154
01166
void getBorderWidths(
int& ulx,
int& uly,
int& lrx,
int& lry ) const KDE_DEPRECATED;
01167
01179
QRect getContentsRect() const KDE_DEPRECATED;
01180
01198
QSize calculateSize(
int w,
int h ) const;
01199
01208
QString helpLinkText() const;
01209
01223
QPushButton *actionButton( ButtonCode
id );
01224
01225 public slots:
01232
void enableButton( ButtonCode
id,
bool state );
01233
01239
void enableButtonOK(
bool state );
01240
01246
void enableButtonApply(
bool state );
01247
01253
void enableButtonCancel(
bool state );
01254
01260
void enableLinkedHelp(
bool state );
01261
01271
void delayedDestruct();
01272
01281
void setHelpLinkText( const
QString &text );
01282
01295
void setHelp( const
QString &anchor,
01296 const
QString &appname =
QString::null );
01297
01301
void helpClickedSlot( const
QString & );
01302
01306
void setDetails(
bool showDetails);
01307
01314
void setDetailsWidget(
QWidget *detailsWidget);
01315
01320
void updateBackground();
01321
01330
void cancel();
01331
01332 signals:
01337
void helpClicked();
01338
01343
void defaultClicked();
01344
01345
01350
void user3Clicked();
01351
01356
void user2Clicked();
01357
01362
void user1Clicked();
01363
01368
void applyClicked();
01369
01374
void tryClicked();
01375
01380
void okClicked();
01381
01386
void yesClicked();
01387
01392
void noClicked();
01393
01398
void cancelClicked();
01399
01404
void closeClicked();
01405
01410
void apply();
01411
01415
void backgroundChanged();
01416
01424
void hidden();
01425
01440
void finished();
01441
01446
void aboutToShowDetails();
01447
01452
void aboutToShowPage(
QWidget *page);
01453
01454 protected:
01460 virtual
void keyPressEvent(
QKeyEvent *e );
01461
01466 virtual
void hideEvent(
QHideEvent * );
01467
01474 virtual
void closeEvent(
QCloseEvent *e );
01475
01476 protected slots:
01481 virtual
void slotHelp();
01482
01486 virtual
void slotDefault();
01487
01492 virtual
void slotDetails();
01493
01497 virtual
void slotUser3();
01498
01502 virtual
void slotUser2();
01503
01507 virtual
void slotUser1();
01508
01513 virtual
void slotOk();
01514
01518 virtual
void slotApply();
01519
01523 virtual
void slotTry();
01524
01529 virtual
void slotYes();
01530
01535 virtual
void slotNo();
01536
01542 virtual
void slotCancel();
01543
01548 virtual
void slotClose();
01549
01555 virtual
void applyPressed();
01556
01560
void updateGeometry();
01561
01569
void slotDelayedDestruct();
01570
01571 private:
01575
void setupLayout();
01576
01582
void makeRelay();
01583
01596
void makeButtonBox(
int mask, ButtonCode defaultButton,
01597 const
KGuiItem &user1 =
KGuiItem(),
01598 const KGuiItem &user2 = KGuiItem(),
01599 const KGuiItem &user3 = KGuiItem() );
01600
01608
void setButtonFocus(
QPushButton *p,
bool isDefault,
bool isFocus );
01609
01615
void printMakeMainWidgetError();
01616
01617 private slots:
01623
void setButtonStyle(
int style );
01624
01625
01626 private:
01627
QBoxLayout *mTopLayout;
01628
QWidget *mMainWidget;
01629
KURLLabel *mUrlHelp;
01630
KJanusWidget *mJanus;
01631
KSeparator *mActionSep;
01632
01633
bool mIsActivated;
01634
01635 QString mAnchor;
01636 QString mHelpApp;
01637 QString mHelpLinkText;
01638
01639 static
KDialogBaseTile *mTile;
01640
bool mShowTile;
01641
01642
bool mMessageBoxMode;
01643
int mButtonOrientation;
01644 ButtonCode mEscapeButton;
01645
01646 protected:
01647 virtual
void virtual_hook(
int id,
void* data );
01648 private:
01649 class KDialogBasePrivate;
01650 KDialogBasePrivate* const d;
01651 };
01652
01653 #endif