Fix UI
[kdenetwork.git] / kdict / options.h
blobecef7606dfe06267ae3eb15826a29b711ea39596
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 <qlistbox.h>
22 #include <kdialogbase.h>
23 #include <kglobalsettings.h>
25 class QLineEdit;
26 class QCheckBox;
27 class QComboBox;
28 class QRadioButton;
30 class KColorButton;
31 class KLineEdit;
32 class KIntSpinBox;
35 //********* GlobalData ******************************************
37 #define COL_CNT 6
38 #define FNT_CNT 2
40 class GlobalData
43 public:
45 enum ColorIndex { Ctext=0, Cbackground=1, CheadingsText=2, CheadingsBackground=3, Clinks=4, CvisitedLinks=5 };
46 enum FontIndex { Ftext=0, Fheadings=1 };
48 void read();
49 void write();
51 // colors...
52 const QColor& color(int i) { return c_olors[i]; }
53 const QString& colorName(int i) { return c_olorNames[i]; }
54 int colorCount() const { return COL_CNT; }
55 QColor defaultColor(int i);
56 bool useCustomColors;
57 QColor textColor();
58 QColor backgroundColor();
59 QColor headingsTextColor();
60 QColor headingsBackgroundColor();
61 QColor linksColor();
62 QColor visitedLinksColor();
64 // fonts...
65 const QFont& font(int i) { return f_onts[i]; }
66 const QString& fontName(int i) { return f_ontNames[i]; }
67 int fontCount() const { return FNT_CNT; }
68 QFont defaultFont(int);
69 bool useCustomFonts;
70 QFont textFont();
71 QFont headingsFont();
73 QString encryptStr(const QString& aStr);
75 bool defineClipboard; // define clipboard content on startup?
77 QSize optSize,setsSize,matchSize; // window geometry
78 bool showMatchList;
79 QValueList<int> splitterSizes;
81 KGlobalSettings::Completion queryComboCompletionMode;
83 QStringList queryHistory;
84 bool saveHistory; // save query history to disk on exit?
85 unsigned int maxHistEntrys, maxBrowseListEntrys, maxDefinitions;
86 int headLayout;
88 QString server; // network client...
89 int port,timeout,pipeSize,idleHold;
90 QString encoding;
91 bool authEnabled;
92 QString user, secret;
93 QStringList serverDatabases, databases, strategies;
94 QPtrList<QStringList> databaseSets;
95 unsigned int currentDatabase, currentStrategy;
97 QColor c_olors[COL_CNT];
98 QString c_olorNames[COL_CNT];
99 QFont f_onts[FNT_CNT];
100 QString f_ontNames[FNT_CNT];
102 QWidget *topLevel;
105 extern GlobalData *global;
108 //********* OptionsDialog ******************************************
111 class OptionsDialog : public KDialogBase
113 Q_OBJECT
115 public:
117 OptionsDialog(QWidget *parent=0, const char *name=0);
118 ~OptionsDialog();
120 //===================================================================================
122 class DialogListBox : public QListBox {
124 public:
125 // alwaysIgnore==false: enter is ignored when the widget isn't visible/out of focus
126 DialogListBox(bool alwaysIgnore=false, QWidget * parent=0, const char * name=0);
127 ~DialogListBox();
129 protected:
130 void keyPressEvent( QKeyEvent *e );
132 bool a_lwaysIgnore;
135 //===================================================================================
137 class ColorListItem : public QListBoxText {
139 public:
140 ColorListItem( const QString &text, const QColor &color=Qt::black );
141 ~ColorListItem();
142 const QColor& color() { return mColor; }
143 void setColor( const QColor &color ) { mColor = color; }
145 protected:
146 virtual void paint( QPainter * );
147 virtual int height( const QListBox * ) const;
148 virtual int width( const QListBox * ) const;
150 private:
151 QColor mColor;
154 //===================================================================================
156 class FontListItem : public QListBoxText {
158 public:
159 FontListItem( const QString &name, const QFont & );
160 ~FontListItem();
161 const QFont& font() { return f_ont; }
162 void setFont( const QFont &);
163 protected:
164 virtual void paint( QPainter * );
165 virtual int width( const QListBox * ) const;
167 private:
168 QFont f_ont;
169 QString fontInfo;
172 //===================================================================================
174 signals:
176 void optionsChanged();
178 protected slots:
179 void slotApply();
180 void slotOk();
181 void slotDefault();
182 void slotChanged();
184 //server
185 void slotAuthRequiredToggled( bool );
187 //colors
188 void slotColCheckBoxToggled(bool b);
189 void slotColItemSelected(QListBoxItem *); // show color dialog for the entry
190 void slotColDefaultBtnClicked();
191 void slotColChangeBtnClicked();
192 void slotColSelectionChanged();
194 //fonts
195 void slotFontCheckBoxToggled(bool b);
196 void slotFontItemSelected(QListBoxItem *); // show font dialog for the entry
197 void slotFontDefaultBtnClicked();
198 void slotFontChangeBtnClicked();
199 void slotFontSelectionChanged();
201 private:
203 QFrame *serverTab;
204 QLabel *l_user, *l_secret;
205 KLineEdit *w_server, *w_user, *w_secret, *w_port;
206 QComboBox *w_encoding;
207 QCheckBox *w_auth;
208 KIntSpinBox *w_idleHold,*w_timeout,*w_pipesize;
210 QFrame *appTab;
211 DialogListBox *c_List,
212 *f_List;
213 QCheckBox *c_olorCB,
214 *f_ontCB;
215 QPushButton *c_olDefBtn,
216 *c_olChngBtn,
217 *f_ntDefBtn,
218 *f_ntChngBtn;
220 QFrame *layoutTab;
221 QRadioButton *w_layout[3];
223 QFrame *otherTab;
224 QCheckBox *w_Clipboard, *w_Savehist;
225 KIntSpinBox *w_Maxhist, *w_Maxbrowse, *w_MaxDefinitions;
226 bool configChanged;
229 #endif