Debian Codegraph @

src/qdjviewprefs.h

raw
1 //C- -*- C++ -*-
2 //C- -------------------------------------------------------------------
3 //C- DjView4
4 //C- Copyright (c) 2006- Leon Bottou
5 //C-
6 //C- This software is subject to, and may be distributed under, the
7 //C- GNU General Public License, either version 2 of the license,
8 //C- or (at your option) any later version. The license should have
9 //C- accompanied the software or you may obtain a copy of the license
10 //C- from the Free Software Foundation at http://www.fsf.org .
11 //C-
12 //C- This program is distributed in the hope that it will be useful,
13 //C- but WITHOUT ANY WARRANTY; without even the implied warranty of
14 //C- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 //C- GNU General Public License for more details.
16 //C- ------------------------------------------------------------------
17
18 #ifndef QDJVIEWPREFS_H
19 #define QDJVIEWPREFS_H
20
21 #if AUTOCONF
22 # include "config.h"
23 #endif
24
25 #include "version.h"
26
27 #include <Qt>
28 #include <QByteArray>
29 #include <QDialog>
30 #include <QFlags>
31 #include <QFrame>
32 #include <QObject>
33 #include <QPainter>
34 #include <QSettings>
35 #include <QSize>
36 #include <QString>
37 #include <QStringList>
38 #include <QUrl>
39 #include <QVariant>
40 #include <QWidget>
41
42
43 // ========================================
44 // QDJVIEWPREFS
45 // ========================================
46
47
48 class QDjViewPrefs : public QObject
49 {
50 Q_OBJECT
51 Q_ENUMS(Option Tool)
52
53 public:
54
55 enum Option {
56 SHOW_MENUBAR = 0x000001,
57 SHOW_TOOLBAR = 0x000002,
58 SHOW_SIDEBAR = 0x000004,
59 SHOW_STATUSBAR = 0x000010,
60 SHOW_SCROLLBARS = 0x000020,
61 SHOW_FRAME = 0x000100,
62 SHOW_MAPAREAS = 0x000200,
63 SHOW_MASK = 0x000FFF,
64 LAYOUT_CONTINUOUS = 0x001000,
65 LAYOUT_SIDEBYSIDE = 0x002000,
66 LAYOUT_COVERPAGE = 0x004000,
67 LAYOUT_RIGHTTOLEFT = 0x008000,
68 LAYOUT_MASK = 0x00F000,
69 HANDLE_MOUSE = 0x100000,
70 HANDLE_KEYBOARD = 0x200000,
71 HANDLE_LINKS = 0x400000,
72 HANDLE_CONTEXTMENU = 0x800000,
73 };
74
75 enum Tool {
76 TOOLBAR_TOP = 0x80000000,
77 TOOLBAR_BOTTOM = 0x40000000,
78 TOOLBAR_AUTOHIDE = 0x10000000,
79 TOOL_MODECOMBO = 0x00001,
80 TOOL_MODEBUTTONS = 0x00002,
81 TOOL_ZOOMCOMBO = 0x00004,
82 TOOL_ZOOMBUTTONS = 0x00008,
83 TOOL_PAGECOMBO = 0x00010,
84 TOOL_PREVNEXT = 0x00020,
85 TOOL_FIRSTLAST = 0x00040,
86 TOOL_BACKFORW = 0x00080,
87 TOOL_NEW = 0x00100,
88 TOOL_OPEN = 0x00200,
89 TOOL_FIND = 0x00400,
90 TOOL_SELECT = 0x00800,
91 TOOL_SAVE = 0x01000,
92 TOOL_PRINT = 0x02000,
93 TOOL_LAYOUT = 0x04000,
94 TOOL_ROTATE = 0x08000,
95 TOOL_WHATSTHIS = 0x10000,
96 };
97
98 Q_DECLARE_FLAGS(Options, Option)
99 Q_DECLARE_FLAGS(Tools, Tool)
100
101 static const Options defaultOptions;
102 static const Tools defaultTools;
103
104 static QString versionString();
105 QString modifiersToString(Qt::KeyboardModifiers);
106 Qt::KeyboardModifiers stringToModifiers(QString);
107 QString optionsToString(Options);
108 Options stringToOptions(QString);
109 QString toolsToString(Tools);
110 Tools stringToTools(QString);
111
112
113 struct Saved {
114 Saved();
115 bool remember; //!< Save before closing.
116 Options options; //!< Miscellaneous flags.
117 int zoom; //!< Zoom factor.
118 QByteArray state; //!< Toolbar and sidebar geometry.
119 QBrush nsBorderBrush; //!< Border brush (not saved)
120 int nsBorderSize; //!< Border size (not saved)
121 };
122
123 // Preferences remembered between program invocations.
124 Saved forEmbeddedPlugin; //!< Prefs for the embedded plugin mode.
125 Saved forFullPagePlugin; //!< Prefs for the full page plugin mode.
126 Saved forStandalone; //!< Prefs for the standalone viewer mode.
127 Saved forFullScreen; //!< Prefs for the full screen mode.
128 Saved forSlideShow; //!< Prefs for the slideshow mode.
129 QSize windowSize; //!< Size of the standalone window.
130 bool windowMaximized; //!< Window was maximized.
131
132 // Preferences set via the preference dialog.
133 Tools tools; //!< Toolbar composition.
134 double gamma; //!< Gamma value of the target screen.
135 QColor white; //!< White point of the target screen.
136 int resolution; //!< Forced screen resolution or zero.
137 qlonglong cacheSize; //!< Size of the decoded page cache.
138 int pixelCacheSize; //!< Size of the pixel cache.
139 int lensSize; //!< Size of the magnification lens.
140 int lensPower; //!< Power of the magnification lens.
141 QString browserProgram; //!< Preferred web browser.
142 QUrl proxyUrl; //!< Proxy information.
143 bool enableAnimations; //!< Animated page movements.
144 bool advancedFeatures; //!< Advanced features.
145 bool showTextLabel; //!< Show text label.
146 bool invertLuminance; //!< Invert luminance by default.
147 bool mouseWheelZoom; //!< Mouse wheel zooms instead of scroll.
148 QString languageOverride; //!< Language settings
149 bool restrictOverride; //!< Override noprint/nosave
150 bool openGLAccel; //!< Use opengl acceleration
151 int slideShowDelay; //!< Delay between page switches
152 Qt::KeyboardModifiers modifiersForLens; //!< Keys for the lens.
153 Qt::KeyboardModifiers modifiersForSelect; //!< Keys for selecting.
154 Qt::KeyboardModifiers modifiersForLinks; //!< Keys for showing the links.
155
156 // Sidebar preferences
157 int thumbnailSize;
158 bool thumbnailSmart;
159 bool searchWordsOnly;
160 bool searchCaseSensitive;
161 bool searchRegExpMode;
162
163 // Dialog preferences
164 int infoDialogTab; //!< Active tab in info dialog.
165 int metaDialogTab; //!< Active tab in meta dialog.
166 double printerGamma; //!< Gamma value for the printer.
167 QString printerName; //!< Name of the printer
168 QString printFile; //!< Output file for print data
169 bool printReverse; //!< Print revere flag
170 bool printCollate; //!< Print collate flag
171
172 // Recent files
173 QStringList recentFiles; //!< Recently opened files
174
175 public:
176 static QDjViewPrefs *instance(void);
177
178 public slots:
179 void loadRecent();
180 void load();
181 void saveRecent();
182 void saveRemembered();
183 void save();
184
185 signals:
186 void updated();
187
188 private:
189 QDjViewPrefs(void);
190 void loadGroup(QSettings &s, QString name, Saved &saved);
191 void saveGroup(QSettings &s, QString name, Saved &saved);
192 friend class QDjViewPrefsDialog;
193 };
194
195
196 Q_DECLARE_OPERATORS_FOR_FLAGS(QDjViewPrefs::Options)
197 Q_DECLARE_OPERATORS_FOR_FLAGS(QDjViewPrefs::Tools)
198
199
200
201
202 // ========================================
203 // QDJVIEWPREFSDIALOG
204 // ========================================
205
206
207 class QDjView;
208
209 class QDjViewPrefsDialog : public QDialog
210 {
211 Q_OBJECT
212 public:
213 ~QDjViewPrefsDialog();
214 static QDjViewPrefsDialog *instance();
215 public slots:
216 void load(QDjView *djview);
217 void apply();
218 void reset();
219 virtual void done(int);
220 protected slots:
221 void cacheClear();
222 void modeComboChanged(int);
223 void zoomComboEdited();
224 void setModified();
225 void forceResolutionChanged();
226 private:
227 QDjViewPrefsDialog();
228 void connectModified(QWidget *w);
229 void loadLanguageComboBox(QString lang);
230 struct Private;
231 Private *d;
232 };
233
234
235
236
237
238 #endif
239
240 /* -------------------------------------------------------------
241 Local Variables:
242 c++-font-lock-extra-types: ( "\\sw+_t" "[A-Z]\\sw*[a-z]\\sw*" "qlonglong" )
243 End:
244 ------------------------------------------------------------- */
245