less Q3 (remove a lot of unused Q3 headers, port small things)
[kdenetwork.git] / kdict / options.h
blobc5e9191fca21991924ea6968a933ceda6e22b369
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, usefull 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 <Q3ValueList>
27 #include <QLabel>
28 #include <kdialogbase.h>
29 #include <kglobalsettings.h>
31 class QLineEdit;
32 class QCheckBox;
33 class QComboBox;
34 class QRadioButton;
36 class KColorButton;
37 class KLineEdit;
38 class KIntSpinBox;
41 //********* GlobalData ******************************************
43 #define COL_CNT 6
44 #define FNT_CNT 2
46 class GlobalData
49 public:
51 enum ColorIndex { Ctext=0, Cbackground=1, CheadingsText=2, CheadingsBackground=3, Clinks=4, CvisitedLinks=5 };
52 enum FontIndex { Ftext=0, Fheadings=1 };
54 void read();
55 void write();
57 // colors...
58 const QColor& color(int i) { return c_olors[i]; }
59 const QString& colorName(int i) { return c_olorNames[i]; }
60 int colorCount() const { return COL_CNT; }
61 QColor defaultColor(int i);
62 bool useCustomColors;
63 QColor textColor();
64 QColor backgroundColor();
65 QColor headingsTextColor();
66 QColor headingsBackgroundColor();
67 QColor linksColor();
68 QColor visitedLinksColor();
70 // fonts...
71 const QFont& font(int i) { return f_onts[i]; }
72 const QString& fontName(int i) { return f_ontNames[i]; }
73 int fontCount() const { return FNT_CNT; }
74 QFont defaultFont(int);
75 bool useCustomFonts;
76 QFont textFont();
77 QFont headingsFont();
79 QString encryptStr(const QString& aStr);
81 bool defineClipboard; // define clipboard content on startup?
83 QSize optSize,setsSize,matchSize; // window geometry
84 bool showMatchList;
85 Q3ValueList<int> splitterSizes;
87 KGlobalSettings::Completion queryComboCompletionMode;
89 QStringList queryHistory;
90 bool saveHistory; // save query history to disk on exit?
91 unsigned int maxHistEntrys, maxBrowseListEntrys, maxDefinitions;
92 int headLayout;
94 QString server; // network client...
95 int port,timeout,pipeSize,idleHold;
96 QString encoding;
97 bool authEnabled;
98 QString user, secret;
99 QStringList serverDatabases, databases, strategies;
100 Q3PtrList<QStringList> databaseSets;
101 unsigned int currentDatabase, currentStrategy;
103 QColor c_olors[COL_CNT];
104 QString c_olorNames[COL_CNT];
105 QFont f_onts[FNT_CNT];
106 QString f_ontNames[FNT_CNT];
108 QWidget *topLevel;
111 extern GlobalData *global;
114 //********* OptionsDialog ******************************************
117 class OptionsDialog : public KDialogBase
119 Q_OBJECT
121 public:
123 OptionsDialog(QWidget *parent=0, const char *name=0);
124 ~OptionsDialog();
126 //===================================================================================
128 class DialogListBox : public Q3ListBox {
130 public:
131 // alwaysIgnore==false: enter is ignored when the widget isn't visible/out of focus
132 DialogListBox(bool alwaysIgnore=false, QWidget * parent=0, const char * name=0);
133 ~DialogListBox();
135 protected:
136 void keyPressEvent( QKeyEvent *e );
138 bool a_lwaysIgnore;
141 //===================================================================================
143 class ColorListItem : public Q3ListBoxText {
145 public:
146 ColorListItem( const QString &text, const QColor &color=Qt::black );
147 ~ColorListItem();
148 const QColor& color() { return mColor; }
149 void setColor( const QColor &color ) { mColor = color; }
151 protected:
152 virtual void paint( QPainter * );
153 virtual int height( const Q3ListBox * ) const;
154 virtual int width( const Q3ListBox * ) const;
156 private:
157 QColor mColor;
160 //===================================================================================
162 class FontListItem : public Q3ListBoxText {
164 public:
165 FontListItem( const QString &name, const QFont & );
166 ~FontListItem();
167 const QFont& font() { return f_ont; }
168 void setFont( const QFont &);
169 protected:
170 virtual void paint( QPainter * );
171 virtual int width( const Q3ListBox * ) const;
173 private:
174 QFont f_ont;
175 QString fontInfo;
178 //===================================================================================
180 signals:
182 void optionsChanged();
184 protected slots:
185 void slotApply();
186 void slotOk();
187 void slotDefault();
188 void slotChanged();
190 //server
191 void slotAuthRequiredToggled( bool );
193 //colors
194 void slotColCheckBoxToggled(bool b);
195 void slotColItemSelected(Q3ListBoxItem *); // show color dialog for the entry
196 void slotColDefaultBtnClicked();
197 void slotColChangeBtnClicked();
198 void slotColSelectionChanged();
200 //fonts
201 void slotFontCheckBoxToggled(bool b);
202 void slotFontItemSelected(Q3ListBoxItem *); // show font dialog for the entry
203 void slotFontDefaultBtnClicked();
204 void slotFontChangeBtnClicked();
205 void slotFontSelectionChanged();
207 private:
209 QFrame *serverTab;
210 QLabel *l_user, *l_secret;
211 KLineEdit *w_server, *w_user, *w_secret, *w_port;
212 QComboBox *w_encoding;
213 QCheckBox *w_auth;
214 KIntSpinBox *w_idleHold,*w_timeout,*w_pipesize;
216 QFrame *appTab;
217 DialogListBox *c_List,
218 *f_List;
219 QCheckBox *c_olorCB,
220 *f_ontCB;
221 QPushButton *c_olDefBtn,
222 *c_olChngBtn,
223 *f_ntDefBtn,
224 *f_ntChngBtn;
226 QFrame *layoutTab;
227 QRadioButton *w_layout[3];
229 QFrame *otherTab;
230 QCheckBox *w_Clipboard, *w_Savehist;
231 KIntSpinBox *w_Maxhist, *w_Maxbrowse, *w_MaxDefinitions;
232 bool configChanged;
235 #endif