add DQT3_SUPPORT
[kdenetwork.git] / kdict / options.h
blob4fd41b9e610998daef3c6aaa32d11386bf9aa447
1 /* -------------------------------------------------------------
3 options.h (part of The KDE Dictionary Client)
5 Copyright (C) 2000-2001 Christian Gebauer <gebauer@kde.org>
7 This file is distributed under the Artistic License.
8 See LICENSE for details.
10 -------------------------------------------------------------
12 GlobalData manages all global data of Kdict
13 DialgoListBox a list box which ignores Enter, useful for dialogs
14 OptionsDialog the "Preferences" dialog
16 ------------------------------------------------------------- */
18 #ifndef _KDICT_OPTIONS_H_
19 #define _KDICT_OPTIONS_H_
21 #include <q3listbox.h>
22 //Added by qt3to4:
23 #include <Q3PtrList>
24 #include <QKeyEvent>
25 #include <QFrame>
26 #include <QLabel>
27 #include <KPageDialog>
28 #include <kglobalsettings.h>
30 class QLineEdit;
31 class QCheckBox;
32 class QComboBox;
33 class QRadioButton;
35 class KColorButton;
36 class KLineEdit;
37 class KIntSpinBox;
40 //********* GlobalData ******************************************
42 #define COL_CNT 6
43 #define FNT_CNT 2
45 class GlobalData
48 public:
50 enum ColorIndex { Ctext=0, Cbackground=1, CheadingsText=2, CheadingsBackground=3, Clinks=4, CvisitedLinks=5 };
51 enum FontIndex { Ftext=0, Fheadings=1 };
53 void read();
54 void write();
56 // colors...
57 const QColor& color(int i) { return c_olors[i]; }
58 const QString& colorName(int i) { return c_olorNames[i]; }
59 int colorCount() const { return COL_CNT; }
60 QColor defaultColor(int i);
61 bool useCustomColors;
62 QColor textColor();
63 QColor backgroundColor();
64 QColor headingsTextColor();
65 QColor headingsBackgroundColor();
66 QColor linksColor();
67 QColor visitedLinksColor();
69 // fonts...
70 const QFont& font(int i) { return f_onts[i]; }
71 const QString& fontName(int i) { return f_ontNames[i]; }
72 int fontCount() const { return FNT_CNT; }
73 QFont defaultFont(int);
74 bool useCustomFonts;
75 QFont textFont();
76 QFont headingsFont();
78 QString encryptStr(const QString& aStr);
80 bool defineClipboard; // define clipboard content on startup?
82 QSize optSize,setsSize,matchSize; // window geometry
83 bool showMatchList;
84 QList<int> splitterSizes;
86 KGlobalSettings::Completion queryComboCompletionMode;
88 QStringList queryHistory;
89 bool saveHistory; // save query history to disk on exit?
90 unsigned int maxHistEntrys, maxBrowseListEntrys, maxDefinitions;
91 int headLayout;
93 QString server; // network client...
94 int port,timeout,pipeSize,idleHold;
95 QString encoding;
96 bool authEnabled;
97 QString user, secret;
98 QStringList serverDatabases, databases, strategies;
99 Q3PtrList<QStringList> databaseSets;
100 unsigned int currentDatabase, currentStrategy;
102 QColor c_olors[COL_CNT];
103 QString c_olorNames[COL_CNT];
104 QFont f_onts[FNT_CNT];
105 QString f_ontNames[FNT_CNT];
107 QWidget *topLevel;
110 extern GlobalData *global;
113 //********* OptionsDialog ******************************************
116 class OptionsDialog : public KPageDialog
118 Q_OBJECT
120 public:
122 OptionsDialog(QWidget *parent=0);
123 ~OptionsDialog();
125 private:
126 KPageWidgetItem *serverItem;
127 KPageWidgetItem *appItem;
128 KPageWidgetItem *layoutItem;
129 KPageWidgetItem *otherItem;
131 //===================================================================================
133 class DialogListBox : public Q3ListBox {
135 public:
136 // alwaysIgnore==false: enter is ignored when the widget isn't visible/out of focus
137 DialogListBox(bool alwaysIgnore=false, QWidget * parent=0, const char * name=0);
138 ~DialogListBox();
140 protected:
141 void keyPressEvent( QKeyEvent *e );
143 bool a_lwaysIgnore;
146 //===================================================================================
148 class ColorListItem : public Q3ListBoxText {
150 public:
151 ColorListItem( const QString &text, const QColor &color=Qt::black );
152 ~ColorListItem();
153 const QColor& color() { return mColor; }
154 void setColor( const QColor &color ) { mColor = color; }
156 protected:
157 virtual void paint( QPainter * );
158 virtual int height( const Q3ListBox * ) const;
159 virtual int width( const Q3ListBox * ) const;
161 private:
162 QColor mColor;
165 //===================================================================================
167 class FontListItem : public Q3ListBoxText {
169 public:
170 FontListItem( const QString &name, const QFont & );
171 ~FontListItem();
172 const QFont& font() { return f_ont; }
173 void setFont( const QFont &);
174 protected:
175 virtual void paint( QPainter * );
176 virtual int width( const Q3ListBox * ) const;
178 private:
179 QFont f_ont;
180 QString fontInfo;
183 //===================================================================================
185 signals:
187 void optionsChanged();
189 protected slots:
190 void slotApply();
191 void slotDefault();
192 void slotChanged();
194 //server
195 void slotAuthRequiredToggled( bool );
197 //colors
198 void slotColCheckBoxToggled(bool b);
199 void slotColItemSelected(Q3ListBoxItem *); // show color dialog for the entry
200 void slotColDefaultBtnClicked();
201 void slotColChangeBtnClicked();
202 void slotColSelectionChanged();
204 //fonts
205 void slotFontCheckBoxToggled(bool b);
206 void slotFontItemSelected(Q3ListBoxItem *); // show font dialog for the entry
207 void slotFontDefaultBtnClicked();
208 void slotFontChangeBtnClicked();
209 void slotFontSelectionChanged();
211 private:
213 QFrame *serverTab;
214 QLabel *l_user, *l_secret;
215 KLineEdit *w_server, *w_user, *w_secret, *w_port;
216 QComboBox *w_encoding;
217 QCheckBox *w_auth;
218 KIntSpinBox *w_idleHold,*w_timeout,*w_pipesize;
220 QFrame *appTab;
221 DialogListBox *c_List,
222 *f_List;
223 QCheckBox *c_olorCB,
224 *f_ontCB;
225 QPushButton *c_olDefBtn,
226 *c_olChngBtn,
227 *f_ntDefBtn,
228 *f_ntChngBtn;
230 QFrame *layoutTab;
231 QRadioButton *w_layout[3];
233 QFrame *otherTab;
234 QCheckBox *w_Clipboard, *w_Savehist;
235 KIntSpinBox *w_Maxhist, *w_Maxbrowse, *w_MaxDefinitions;
236 bool configChanged;
239 #endif