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 <tqptrlist.h>
00031
00032 class TQPushButton;
00033 class KSeparator;
00034 class KURLLabel;
00035 class TQBoxLayout;
00036 class TQPixmap;
00037 class KGuiItem;
00042 class KDialogBaseButton;
00043
00048 class KDialogBaseTile;
00049
00191 class TDEUI_EXPORT KDialogBase : public KDialog
00192 {
00193 Q_OBJECT
00194
00195 public:
00196
00197 enum ButtonCode
00198 {
00199 Help = 0x00000001,
00200 Default = 0x00000002,
00201 Ok = 0x00000004,
00202 Apply = 0x00000008,
00203 Try = 0x00000010,
00204 Cancel = 0x00000020,
00205 Close = 0x00000040,
00206 User1 = 0x00000080,
00207 User2 = 0x00000100,
00208 User3 = 0x00000200,
00209 No = 0x00000080,
00210 Yes = 0x00000100,
00211 Details = 0x00000400,
00212 Filler = 0x40000000,
00213 Stretch = 0x80000000,
00214 NoDefault
00215 };
00216
00217 enum ActionButtonStyle
00218 {
00219 ActionStyle0=0,
00220 ActionStyle1,
00221 ActionStyle2,
00222 ActionStyle3,
00223 ActionStyle4,
00224 ActionStyleMAX
00225 };
00226
00237 enum DialogType
00238 {
00239 TreeList = KJanusWidget::TreeList,
00240 Tabbed = KJanusWidget::Tabbed,
00241 Plain = KJanusWidget::Plain,
00242 Swallow = KJanusWidget::Swallow,
00243 IconList = KJanusWidget::IconList
00244 };
00245
00246 public:
00247
00270 KDialogBase( TQWidget *parent=0, const char *name=0, bool modal=true,
00271 const TQString &caption=TQString::null,
00272 int buttonMask=Ok|Apply|Cancel, ButtonCode defaultButton=Ok,
00273 bool separator=false,
00274 const KGuiItem &user1=KGuiItem(),
00275 const KGuiItem &user2=KGuiItem(),
00276 const KGuiItem &user3=KGuiItem() );
00277
00305 KDialogBase( int dialogFace, const TQString &caption,
00306 int buttonMask, ButtonCode defaultButton,
00307 TQWidget *parent=0, const char *name=0, bool modal=true,
00308 bool separator=false,
00309 const KGuiItem &user1=KGuiItem(),
00310 const KGuiItem &user2=KGuiItem(),
00311 const KGuiItem &user3=KGuiItem() );
00312
00313
00341 KDialogBase( KDialogBase::DialogType dialogFace, WFlags f,
00342 TQWidget *parent=0, const char *name=0, bool modal=true,
00343 const TQString &caption=TQString::null,
00344 int buttonMask=Ok|Apply|Cancel, ButtonCode defaultButton=Ok,
00345 bool separator=false,
00346 const KGuiItem &user1=KGuiItem(),
00347 const KGuiItem &user2=KGuiItem(),
00348 const KGuiItem &user3=KGuiItem() );
00349
00381 KDialogBase( const TQString &caption, int buttonMask=Yes|No|Cancel,
00382 ButtonCode defaultButton=Yes, ButtonCode escapeButton=Cancel,
00383 TQWidget *parent=0, const char *name=0,
00384 bool modal=true, bool separator=false,
00385 const KGuiItem &yes = KStdGuiItem::yes(),
00386 const KGuiItem &no = KStdGuiItem::no(),
00387 const KGuiItem &cancel = KStdGuiItem::cancel()
00388 );
00389
00393 ~KDialogBase();
00394
00405 void setButtonBoxOrientation( int orientation );
00406
00418 void setEscapeButton( ButtonCode id );
00419
00420
00428 virtual void adjustSize();
00429 virtual TQSize sizeHint() const;
00430 virtual TQSize minimumSizeHint() const;
00431
00442 TQFrame *plainPage();
00443
00471 TQFrame *addPage( const TQString &itemName,
00472 const TQString &header=TQString::null,
00473 const TQPixmap &pixmap=TQPixmap() );
00474
00486 TQFrame *addPage( const TQStringList &items,
00487 const TQString &header=TQString::null,
00488 const TQPixmap &pixmap=TQPixmap() );
00489
00514 TQVBox *addVBoxPage( const TQString &itemName,
00515 const TQString &header=TQString::null,
00516 const TQPixmap &pixmap=TQPixmap() );
00517
00529 TQVBox *addVBoxPage( const TQStringList &items,
00530 const TQString &header=TQString::null,
00531 const TQPixmap &pixmap=TQPixmap() );
00532
00551 TQHBox *addHBoxPage( const TQString &itemName,
00552 const TQString &header=TQString::null,
00553 const TQPixmap &pixmap=TQPixmap() );
00554
00566 TQHBox *addHBoxPage( const TQStringList &items,
00567 const TQString &header=TQString::null,
00568 const TQPixmap &pixmap=TQPixmap() );
00569
00590 TQGrid *addGridPage( int n, Orientation dir,
00591 const TQString &itemName,
00592 const TQString &header=TQString::null,
00593 const TQPixmap &pixmap=TQPixmap() );
00594
00595
00607 TQGrid *addGridPage( int n, Orientation dir,
00608 const TQStringList &items,
00609 const TQString &header=TQString::null,
00610 const TQPixmap &pixmap=TQPixmap() );
00611
00612
00619 void setFolderIcon(const TQStringList &path,const TQPixmap &pixmap);
00620
00634 TQFrame *makeMainWidget();
00635
00649 TQVBox *makeVBoxMainWidget();
00650
00664 TQHBox *makeHBoxMainWidget();
00665
00683 TQGrid *makeGridMainWidget( int n, Orientation dir );
00684
00685
00690 void enableButtonSeparator( bool state );
00691
00702 void showButton( ButtonCode id, bool state );
00703
00712 void showButtonOK( bool state );
00713
00722 void showButtonApply( bool state );
00723
00730 void showButtonCancel( bool state );
00731
00742 bool showPage( int index );
00743
00752 int activePageIndex() const;
00753
00754
00771 int pageIndex( TQWidget *widget ) const;
00772
00773
00786 void setMainWidget( TQWidget *widget );
00787
00793 TQWidget *mainWidget();
00794
00802 void disableResize();
00803
00815 void setInitialSize( const TQSize &s, bool noResize=false );
00816
00827 void incInitialSize( const TQSize &s, bool noResize=false );
00828
00836 TQSize configDialogSize( const TQString& groupName ) const;
00837
00847 TQSize configDialogSize( TDEConfig& config, const TQString& groupName ) const;
00848
00858 void saveDialogSize( const TQString& groupName, bool global=false );
00859
00870 void saveDialogSize( TDEConfig& config, const TQString& groupName,
00871 bool global=false ) const;
00872
00882 void setButtonOK( const KGuiItem &item = KStdGuiItem::ok() );
00883
00899 void setButtonOKText( const TQString &text=TQString::null,
00900 const TQString &tooltip=TQString::null,
00901 const TQString &quickhelp=TQString::null ) KDE_DEPRECATED;
00902
00912 void setButtonApply( const KGuiItem &item = KStdGuiItem::apply() );
00913
00929 void setButtonApplyText( const TQString &text=TQString::null,
00930 const TQString &tooltip=TQString::null,
00931 const TQString &quickhelp=TQString::null ) KDE_DEPRECATED;
00932
00942 void setButtonCancel( const KGuiItem &item = KStdGuiItem::cancel() );
00943
00957 void setButtonCancelText( const TQString &text=TQString::null,
00958 const TQString &tooltip=TQString::null,
00959 const TQString &quickhelp=TQString::null ) KDE_DEPRECATED;
00960
00967 void setButtonText( ButtonCode id, const TQString &text );
00968
00975 void setButtonTip( ButtonCode id, const TQString &text );
00976
00983 void setButtonWhatsThis( ButtonCode id, const TQString &text );
00984
00996 void setButtonGuiItem( ButtonCode id, const KGuiItem &item );
00997
01008 void setTreeListAutoResize( bool state );
01009
01022 void setShowIconsInTreeList(bool state);
01023
01032 void setRootIsDecorated( bool state );
01033
01047 void unfoldTreeList( bool persist = false );
01048
01057 void addWidgetBelowList( TQWidget * widget );
01058
01069 void addButtonBelowList( const TQString & text, TQObject * recv, const char * slot );
01070
01082 void addButtonBelowList( const KGuiItem & guiitem, TQObject * recv, const char * slot );
01083
01096 void setIconListAllVisible( bool state );
01097
01103 static bool haveBackgroundTile();
01104
01111 static const TQPixmap *backgroundTile();
01116 static const TQPixmap *getBackgroundTile() KDE_DEPRECATED;
01117
01125 static void setBackgroundTile( const TQPixmap *pix );
01126
01132 void showTile( bool state );
01133
01145 void getBorderWidths( int& ulx, int& uly, int& lrx, int& lry ) const KDE_DEPRECATED;
01146
01158 TQRect getContentsRect() const KDE_DEPRECATED;
01159
01177 TQSize calculateSize( int w, int h ) const;
01178
01187 TQString helpLinkText() const;
01188
01202 TQPushButton *actionButton( ButtonCode id );
01203
01204 public slots:
01211 void enableButton( ButtonCode id, bool state );
01212
01218 void enableButtonOK( bool state );
01219
01225 void enableButtonApply( bool state );
01226
01232 void enableButtonCancel( bool state );
01233
01239 void enableLinkedHelp( bool state );
01240
01250 void delayedDestruct();
01251
01260 void setHelpLinkText( const TQString &text );
01261
01274 void setHelp( const TQString &anchor,
01275 const TQString &appname = TQString::null );
01276
01280 void helpClickedSlot( const TQString & );
01281
01285 void setDetails(bool showDetails);
01286
01293 void setDetailsWidget(TQWidget *detailsWidget);
01294
01299 void updateBackground();
01300
01309 void cancel();
01310
01311 signals:
01316 void helpClicked();
01317
01322 void defaultClicked();
01323
01324
01329 void user3Clicked();
01330
01335 void user2Clicked();
01336
01341 void user1Clicked();
01342
01347 void applyClicked();
01348
01353 void tryClicked();
01354
01359 void okClicked();
01360
01365 void yesClicked();
01366
01371 void noClicked();
01372
01377 void cancelClicked();
01378
01383 void closeClicked();
01384
01389 void apply();
01390
01394 void backgroundChanged();
01395
01403 void hidden();
01404
01419 void finished();
01420
01425 void aboutToShowDetails();
01426
01431 void aboutToShowPage(TQWidget *page);
01432
01433 protected:
01439 virtual void keyPressEvent( TQKeyEvent *e );
01440
01445 virtual void hideEvent( TQHideEvent * );
01446
01453 virtual void closeEvent( TQCloseEvent *e );
01454
01455 protected slots:
01460 virtual void slotHelp();
01461
01465 virtual void slotDefault();
01466
01471 virtual void slotDetails();
01472
01476 virtual void slotUser3();
01477
01481 virtual void slotUser2();
01482
01486 virtual void slotUser1();
01487
01492 virtual void slotOk();
01493
01497 virtual void slotApply();
01498
01502 virtual void slotTry();
01503
01508 virtual void slotYes();
01509
01514 virtual void slotNo();
01515
01521 virtual void slotCancel();
01522
01527 virtual void slotClose();
01528
01534 virtual void applyPressed();
01535
01539 void updateGeometry();
01540
01548 void slotDelayedDestruct();
01549
01550 private:
01554 void setupLayout();
01555
01561 void makeRelay();
01562
01575 void makeButtonBox( int mask, ButtonCode defaultButton,
01576 const KGuiItem &user1 = KGuiItem(),
01577 const KGuiItem &user2 = KGuiItem(),
01578 const KGuiItem &user3 = KGuiItem() );
01579
01587 void setButtonFocus( TQPushButton *p, bool isDefault, bool isFocus );
01588
01594 void printMakeMainWidgetError();
01595
01596 private slots:
01602 void setButtonStyle( int style );
01603
01604
01605 private:
01606 TQBoxLayout *mTopLayout;
01607 TQWidget *mMainWidget;
01608 KURLLabel *mUrlHelp;
01609 KJanusWidget *mJanus;
01610 KSeparator *mActionSep;
01611
01612 bool mIsActivated;
01613
01614 TQString mAnchor;
01615 TQString mHelpApp;
01616 TQString mHelpLinkText;
01617
01618 static KDialogBaseTile *mTile;
01619 bool mShowTile;
01620
01621 bool mMessageBoxMode;
01622 int mButtonOrientation;
01623 ButtonCode mEscapeButton;
01624
01625 protected:
01626 virtual void virtual_hook( int id, void* data );
01627 private:
01628 class KDialogBasePrivate;
01629 KDialogBasePrivate* const d;
01630 };
01631
01632 #endif