summaryrefslogtreecommitdiffabout
path: root/microkde/kdialogbase.h
blob: 7b44bfb7ac2e7a694740563c0a1d348a10d2b46e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#ifndef MINIKDE_KDIALOGBASE_H
#define MINIKDE_KDIALOGBASE_H

#include <qframe.h>

#include "kdialog.h"

class QPushButton;
class QLayout;
class QTabWidget;
class QBoxLayout;

class KDialogBase : public KDialog
{
    Q_OBJECT
  public:
    enum ButtonCode
    {
      Help    = 0x00000001,
      Default = 0x00000002,
      Ok      = 0x00000004,
      Apply   = 0x00000008,
      Try     = 0x00000010,
      Cancel  = 0x00000020,
      Close   = 0x00000040,
      User1   = 0x00000080,
      User2   = 0x00000100,
      User3   = 0x00000200,
      No      = 0x00000080,
      Yes     = 0x00000100,
      Details = 0x00000400,
      Filler  = 0x40000000,
      Stretch = 0x80000000
    };

    enum DialogType
    {
      TreeList,
      Tabbed,
      Plain, 
      Swallow,
      IconList
    };

    KDialogBase();
    KDialogBase( QWidget *parent=0, const char *name=0, bool modal=true,
		 const QString &caption=QString::null,
		 int buttonMask=Ok|Apply|Cancel, ButtonCode defaultButton=Ok,
		 bool separator=false, 
		 const QString &user1=QString::null,
		 const QString &user2=QString::null,
		 const QString &user3=QString::null);
    KDialogBase( int dialogFace, const QString &caption, 
		 int buttonMask, ButtonCode defaultButton, 
		 QWidget *parent=0, const char *name=0, bool modal=true, 
		 bool separator=false,
		 const QString &user1=QString::null,
		 const QString &user2=QString::null,
		 const QString &user3=QString::null);
    virtual ~KDialogBase();
    
    QFrame *addPage( const QString & );
    QFrame *addPage( const QString &, int, const QPixmap & );

    void setMainWidget( QWidget *widget );

    void setButtonText( ButtonCode id, const QString &text );

    void enableButton( ButtonCode id, bool state );
    void enableButtonOK( bool state );
    void enableButtonApply( bool state );

    void showButton( ButtonCode, bool show );

    int pageIndex( QWidget *widget ) const;

    bool showPage( int index );
    void hideButtons();

    QFrame *plainPage();

  signals:
    void user1Clicked();
    void user2Clicked();
 /**
     * The Apply button was pressed. This signal is only emitted if
     * @ref slotApply() is not replaced.
     */
    void applyClicked();

    /**
     * The OK button was pressed. This signal is only emitted if
     * @ref slotOk() is not replaced.
     */
    void okClicked();
    
    /**
     * The Cancel button was pressed. This signal is only emitted if
     * @ref slotCancel() is not replaced.
     */
    void cancelClicked();
    
    /**
     * The Close button was pressed. This signal is only emitted if
     * @ref slotClose() is not replaced.
     */
    void closeClicked();
    void defaultClicked();

  protected slots:
    virtual void slotOk();
    virtual void slotApply();
    virtual void slotCancel();
    virtual void slotClose();
    virtual void slotUser1();
    virtual void slotUser2();

  protected:
    QPushButton *findButton( ButtonCode );

  private:
    QTabWidget *tabWidget();
    void init( const QString &caption, int buttonMask,
               const QString &user1=QString::null, const QString &user2=QString::null );
    void initLayout();

    QWidget *mMainWidget;
    QTabWidget *mTabWidget;
    QFrame *mPlainPage;
    QBoxLayout *mTopLayout;
    
    QPushButton *mUser1Button;
    QPushButton *mUser2Button;
    QPushButton *mCloseButton;
    QPushButton *mOkButton;
    QPushButton *mApplyButton;
    QPushButton *mCancelButton;     
    QPushButton *mDefaultButton;    
};

#endif