summaryrefslogtreecommitdiffstats
path: root/kdict/options.h
blob: 5a3a58c49bbea45808bdae0a405437d0b2627b28 (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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
/* -------------------------------------------------------------

   options.h (part of The KDE Dictionary Client)

   Copyright (C) 2000-2001 Christian Gebauer <gebauer@kde.org>

   This file is distributed under the Artistic License.
   See LICENSE for details.

   -------------------------------------------------------------

   GlobalData      manages all global data of Kdict
   DialgoListBox   a list box which ignores Enter, usefull for dialogs
   OptionsDialog   the "Preferences" dialog

 ------------------------------------------------------------- */

#ifndef _KDICT_OPTIONS_H_
#define _KDICT_OPTIONS_H_

#include <tqlistbox.h>
#include <kdialogbase.h>
#include <tdeglobalsettings.h>

class TQLineEdit;
class TQCheckBox;
class TQComboBox;
class TQRadioButton;

class KColorButton;
class KLineEdit;
class KIntSpinBox;


//********* GlobalData ******************************************

#define COL_CNT 6
#define FNT_CNT 2

class GlobalData
{

public:

  enum ColorIndex   { Ctext=0, Cbackground=1, CheadingsText=2, CheadingsBackground=3, Clinks=4, CvisitedLinks=5  };
  enum FontIndex    { Ftext=0, Fheadings=1 };

  void read();
  void write();

  // colors...
  const TQColor& color(int i)           { return c_olors[i]; }
  const TQString& colorName(int i)      { return c_olorNames[i]; }
  int colorCount() const                    { return COL_CNT; }
  TQColor defaultColor(int i);
  bool useCustomColors;
  TQColor textColor();
  TQColor backgroundColor();
  TQColor headingsTextColor();
  TQColor headingsBackgroundColor();
  TQColor linksColor();
  TQColor visitedLinksColor();

  // fonts...
  const TQFont& font(int i)             { return f_onts[i]; }
  const TQString& fontName(int i)       { return f_ontNames[i]; }
  int fontCount() const                     { return FNT_CNT; }
  TQFont defaultFont(int);
  bool useCustomFonts;
  TQFont textFont();
  TQFont headingsFont();

  TQString encryptStr(const TQString& aStr);

  bool defineClipboard;           // define clipboard content on startup?

  TQSize optSize,setsSize,matchSize;      // window geometry
  bool showMatchList;
  TQValueList<int> splitterSizes;

  TDEGlobalSettings::Completion queryComboCompletionMode;

  TQStringList queryHistory;
  bool saveHistory;               // save query history to disk on exit?
  unsigned int maxHistEntrys, maxBrowseListEntrys, maxDefinitions;
  int headLayout;

  TQString server;                 // network client...
  int port,timeout,pipeSize,idleHold;
  TQString encoding;
  bool authEnabled;
  TQString user, secret;
  TQStringList serverDatabases, databases, strategies;
  TQPtrList<TQStringList> databaseSets;
  unsigned int currentDatabase, currentStrategy;

  TQColor  c_olors[COL_CNT];
  TQString c_olorNames[COL_CNT];
  TQFont   f_onts[FNT_CNT];
  TQString f_ontNames[FNT_CNT];

  TQWidget *topLevel;
};

extern GlobalData *global;


//*********  OptionsDialog  ******************************************


class OptionsDialog : public KDialogBase
{
  Q_OBJECT
  

public:

  OptionsDialog(TQWidget *parent=0, const char *name=0);
  ~OptionsDialog();

  //===================================================================================

  class DialogListBox : public TQListBox {

    public:
      // alwaysIgnore==false: enter is ignored when the widget isn't visible/out of focus
      DialogListBox(bool alwaysIgnore=false, TQWidget * parent=0, const char * name=0);
      ~DialogListBox();

    protected:
      void keyPressEvent( TQKeyEvent *e );

      bool a_lwaysIgnore;
  };

  //===================================================================================

  class ColorListItem : public TQListBoxText {

    public:
      ColorListItem( const TQString &text, const TQColor &color=TQt::black );
      ~ColorListItem();
      const TQColor& color()                     { return mColor; }
      void  setColor( const TQColor &color )     { mColor = color; }

    protected:
      virtual void paint( TQPainter * );
      virtual int height( const TQListBox * ) const;
      virtual int width( const TQListBox * ) const;

    private:
      TQColor mColor;
  };

  //===================================================================================

  class FontListItem : public TQListBoxText {

    public:
      FontListItem( const TQString &name, const TQFont & );
      ~FontListItem();
      const TQFont& font()                     { return f_ont; }
      void setFont( const TQFont &);
    protected:
      virtual void paint( TQPainter * );
      virtual int width( const TQListBox * ) const;

    private:
      TQFont f_ont;
      TQString fontInfo;
  };

  //===================================================================================

signals:

  void optionsChanged();

protected slots:
  void slotApply();
  void slotOk();
  void slotDefault();
  void slotChanged();

  //server
  void slotAuthRequiredToggled( bool );

  //colors
  void slotColCheckBoxToggled(bool b);
  void slotColItemSelected(TQListBoxItem *);   // show color dialog for the entry
  void slotColDefaultBtnClicked();
  void slotColChangeBtnClicked();
  void slotColSelectionChanged();

  //fonts
  void slotFontCheckBoxToggled(bool b);
  void slotFontItemSelected(TQListBoxItem *);  // show font dialog for the entry
  void slotFontDefaultBtnClicked();
  void slotFontChangeBtnClicked();
  void slotFontSelectionChanged();

private:

  TQFrame *serverTab;
  TQLabel *l_user, *l_secret;
  KLineEdit *w_server, *w_user, *w_secret, *w_port;
  TQComboBox *w_encoding;
  TQCheckBox *w_auth;
  KIntSpinBox *w_idleHold,*w_timeout,*w_pipesize;

  TQFrame *appTab;
  DialogListBox *c_List,
                *f_List;
  TQCheckBox *c_olorCB,
            *f_ontCB;
  TQPushButton *c_olDefBtn,
              *c_olChngBtn,
              *f_ntDefBtn,
              *f_ntChngBtn;

  TQFrame *layoutTab;
  TQRadioButton *w_layout[3];

  TQFrame *otherTab;
  TQCheckBox *w_Clipboard, *w_Savehist;
  KIntSpinBox *w_Maxhist, *w_Maxbrowse, *w_MaxDefinitions;
  bool configChanged;
};

#endif