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>
27 #include <KPageDialog>
28 #include <kglobalsettings.h>
40 //********* GlobalData ******************************************
50 enum ColorIndex
{ Ctext
=0, Cbackground
=1, CheadingsText
=2, CheadingsBackground
=3, Clinks
=4, CvisitedLinks
=5 };
51 enum FontIndex
{ Ftext
=0, Fheadings
=1 };
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
);
63 QColor
backgroundColor();
64 QColor
headingsTextColor();
65 QColor
headingsBackgroundColor();
67 QColor
visitedLinksColor();
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);
78 QString
encryptStr(const QString
& aStr
);
80 bool defineClipboard
; // define clipboard content on startup?
82 QSize optSize
,setsSize
,matchSize
; // window geometry
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
;
93 QString server
; // network client...
94 int port
,timeout
,pipeSize
,idleHold
;
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
];
110 extern GlobalData
*global
;
113 //********* OptionsDialog ******************************************
116 class OptionsDialog
: public KPageDialog
122 OptionsDialog(QWidget
*parent
=0);
126 KPageWidgetItem
*serverItem
;
127 KPageWidgetItem
*appItem
;
128 KPageWidgetItem
*layoutItem
;
129 KPageWidgetItem
*otherItem
;
131 //===================================================================================
133 class DialogListBox
: public Q3ListBox
{
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);
141 void keyPressEvent( QKeyEvent
*e
);
146 //===================================================================================
148 class ColorListItem
: public Q3ListBoxText
{
151 ColorListItem( const QString
&text
, const QColor
&color
=Qt::black
);
153 const QColor
& color() { return mColor
; }
154 void setColor( const QColor
&color
) { mColor
= color
; }
157 virtual void paint( QPainter
* );
158 virtual int height( const Q3ListBox
* ) const;
159 virtual int width( const Q3ListBox
* ) const;
165 //===================================================================================
167 class FontListItem
: public Q3ListBoxText
{
170 FontListItem( const QString
&name
, const QFont
& );
172 const QFont
& font() { return f_ont
; }
173 void setFont( const QFont
&);
175 virtual void paint( QPainter
* );
176 virtual int width( const Q3ListBox
* ) const;
183 //===================================================================================
187 void optionsChanged();
195 void slotAuthRequiredToggled( bool );
198 void slotColCheckBoxToggled(bool b
);
199 void slotColItemSelected(Q3ListBoxItem
*); // show color dialog for the entry
200 void slotColDefaultBtnClicked();
201 void slotColChangeBtnClicked();
202 void slotColSelectionChanged();
205 void slotFontCheckBoxToggled(bool b
);
206 void slotFontItemSelected(Q3ListBoxItem
*); // show font dialog for the entry
207 void slotFontDefaultBtnClicked();
208 void slotFontChangeBtnClicked();
209 void slotFontSelectionChanged();
214 QLabel
*l_user
, *l_secret
;
215 KLineEdit
*w_server
, *w_user
, *w_secret
, *w_port
;
216 QComboBox
*w_encoding
;
218 KIntSpinBox
*w_idleHold
,*w_timeout
,*w_pipesize
;
221 DialogListBox
*c_List
,
225 QPushButton
*c_olDefBtn
,
231 QRadioButton
*w_layout
[3];
234 QCheckBox
*w_Clipboard
, *w_Savehist
;
235 KIntSpinBox
*w_Maxhist
, *w_Maxbrowse
, *w_MaxDefinitions
;