Ran qt3to4
[basket4.git] / src / settings.h
blob16ade4893cb945033652229fa0c074f1a0d0be3a
1 /***************************************************************************
2 * Copyright (C) 2003 by Sébastien Laoût *
3 * slaout@linux62.org *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
21 #ifndef SETTINGS_H
22 #define SETTINGS_H
24 #include <qstring.h>
25 //Added by qt3to4:
26 #include <QLabel>
27 #include <kdialogbase.h>
28 #include <qcheckbox.h>
29 #include <qcombobox.h>
30 #include <qtooltip.h>
31 #include <qcolor.h>
32 #include <qpoint.h>
33 #include <qsize.h>
34 #include <kcmodule.h>
35 #include <kaction.h>
36 #include <kmainwindow.h>
37 #include <qdatetime.h>
39 #include "global.h"
40 #include "bnpview.h"
41 #include "systemtray.h"
43 class Q3GroupBox;
44 class Q3ButtonGroup;
45 class KColorCombo;
46 class KIntNumInput;
47 class KGlobalAccel;
48 class QLabel;
50 class Container;
51 class SystemTray;
52 class DebugWindow;
53 class LinkLook;
54 class LinkLookEditWidget;
55 class RunCommandRequester;
56 class IconSizeCombo;
58 class GeneralPage : public KCModule
60 Q_OBJECT
61 public:
62 GeneralPage(QWidget * parent=0, const char * name=0);
63 GeneralPage() {};
64 virtual ~GeneralPage() {}
66 virtual void load();
67 virtual void save();
68 virtual void defaults();
70 private:
71 // General
72 QComboBox *m_treeOnLeft;
73 QComboBox *m_filterOnTop;
74 QCheckBox *m_usePassivePopup;
76 // System Tray Icon
77 QCheckBox *m_useSystray;
78 QWidget *m_systray;
79 QCheckBox *m_showIconInSystray;
80 QCheckBox *m_hideOnMouseOut;
81 KIntNumInput *m_timeToHideOnMouseOut;
82 QCheckBox *m_showOnMouseIn;
83 KIntNumInput *m_timeToShowOnMouseIn;
86 class BasketsPage : public KCModule
88 Q_OBJECT
89 public:
90 BasketsPage(QWidget * parent=0, const char * name=0);
91 BasketsPage() {};
93 virtual void load();
94 virtual void save();
95 virtual void defaults();
97 private:
98 // Appearance
99 QCheckBox *m_playAnimations;
100 QCheckBox *m_showNotesToolTip;
101 QCheckBox *m_bigNotes;
103 // Behavior
104 QCheckBox *m_autoBullet;
105 QCheckBox *m_confirmNoteDeletion;
106 QCheckBox *m_exportTextTags;
107 QWidget *m_groupOnInsertionLineWidget;
108 QCheckBox *m_groupOnInsertionLine;
109 QComboBox *m_middleAction;
111 // Protection
112 QCheckBox *m_useGnuPGAgent;
113 QCheckBox *m_enableReLockTimeoutMinutes;
114 KIntNumInput *m_reLockTimeoutMinutes;
117 class NewNotesPage : public KCModule
119 Q_OBJECT
120 public:
121 NewNotesPage(QWidget * parent=0, const char * name=0);
122 NewNotesPage() {};
124 virtual void load();
125 virtual void save();
126 virtual void defaults();
128 private slots:
129 void visualize();
131 private:
132 // Notes Image Size
133 KIntNumInput *m_imgSizeX;
134 KIntNumInput *m_imgSizeY;
135 QPushButton *m_pushVisualize;
137 // Note Addition
138 QComboBox *m_newNotesPlace;
139 QCheckBox *m_viewTextFileContent;
140 QCheckBox *m_viewHtmlFileContent;
141 QCheckBox *m_viewImageFileContent;
142 QCheckBox *m_viewSoundFileContent;
145 class NotesAppearancePage : public KCModule
147 Q_OBJECT
148 public:
149 NotesAppearancePage(QWidget * parent=0, const char * name=0);
150 NotesAppearancePage() {};
152 virtual void load();
153 virtual void save();
154 virtual void defaults();
156 private:
157 // Link Looks
158 LinkLookEditWidget *m_soundLook;
159 LinkLookEditWidget *m_fileLook;
160 LinkLookEditWidget *m_localLinkLook;
161 LinkLookEditWidget *m_networkLinkLook;
162 LinkLookEditWidget *m_launcherLook;
165 class ApplicationsPage : public KCModule
167 Q_OBJECT
168 public:
169 ApplicationsPage(QWidget * parent=0, const char * name=0);
170 ApplicationsPage() {};
172 virtual void load();
173 virtual void save();
174 virtual void defaults();
176 private:
177 // Applications
178 QCheckBox *m_htmlUseProg;
179 QCheckBox *m_imageUseProg;
180 QCheckBox *m_animationUseProg;
181 QCheckBox *m_soundUseProg;
182 RunCommandRequester *m_htmlProg;
183 RunCommandRequester *m_imageProg;
184 RunCommandRequester *m_animationProg;
185 RunCommandRequester *m_soundProg;
188 /** Handle all global variables (to avoid lot of extern declarations)
189 * @author S�astien Laot
191 class Settings // FIXME: Distaptch new config events ?
193 protected:
194 /** Main window */
195 static bool s_treeOnLeft;
196 static bool s_filterOnTop;
197 static bool s_playAnimations;
198 static bool s_showNotesToolTip;
199 static bool s_confirmNoteDeletion;
200 static bool s_bigNotes;
201 static bool s_autoBullet;
202 static bool s_exportTextTags;
203 static bool s_useGnuPGAgent;
204 static bool s_usePassivePopup;
205 static int s_middleAction; // O:Nothing ; 1:Paste ; 2:Text ; 3:Html ; 4:Image ; 5:Link ; 6:Launcher ; 7:Color
206 static bool s_groupOnInsertionLine;
207 static bool s_spellCheckTextNotes;
208 static int s_basketTreeWidth;
209 static bool s_welcomeBasketsAdded;
210 static QString s_dataFolder;
211 static QDate s_lastBackup;
212 static QPoint s_mainWindowPosition;
213 static QSize s_mainWindowSize;
214 static bool s_showEmptyBasketInfo;
215 static bool s_blinkedFilter;
216 static bool s_enableReLockTimeout;
217 static int s_reLockTimeoutMinutes;
218 /** Note Addition */
219 static int s_newNotesPlace; // 0:OnTop ; 1:OnBottom ; 2:AtCurrentNote
220 static int s_viewTextFileContent;
221 static int s_viewHtmlFileContent;
222 static int s_viewImageFileContent;
223 static int s_viewSoundFileContent;
224 /** System tray Icon */
225 static bool s_useSystray;
226 static bool s_showIconInSystray;
227 static bool s_startDocked;
228 static bool s_hideOnMouseOut;
229 static int s_timeToHideOnMouseOut;
230 static bool s_showOnMouseIn;
231 static int s_timeToShowOnMouseIn;
232 /** Programs */
233 static bool s_htmlUseProg;
234 static bool s_imageUseProg;
235 static bool s_animationUseProg;
236 static bool s_soundUseProg;
237 static QString s_htmlProg;
238 static QString s_imageProg;
239 static QString s_animationProg;
240 static QString s_soundProg;
241 /** Insert Note Default Values */
242 static int s_defImageX;
243 static int s_defImageY;
244 static int s_defIconSize;
245 public: /* And the following methods are just getter / setters */
246 /** App settings GET */
247 static inline bool treeOnLeft() { return s_treeOnLeft; }
248 static inline bool filterOnTop() { return s_filterOnTop; }
249 static inline bool playAnimations() { return s_playAnimations; }
250 static inline bool showNotesToolTip() { return s_showNotesToolTip; }
251 static inline bool confirmNoteDeletion() { return s_confirmNoteDeletion; }
252 static inline bool bigNotes() { return s_bigNotes; }
253 static inline bool autoBullet() { return s_autoBullet; }
254 static inline bool exportTextTags() { return s_exportTextTags; }
255 static inline bool useGnuPGAgent() { return s_useGnuPGAgent; }
256 static inline bool blinkedFilter() { return s_blinkedFilter; }
257 static inline bool enableReLockTimeout() { return s_enableReLockTimeout; }
258 static inline int reLockTimeoutMinutes() { return s_reLockTimeoutMinutes; }
259 static inline bool useSystray() { return s_useSystray; }
260 static inline bool showIconInSystray() { return s_showIconInSystray; }
261 static inline bool startDocked() { return s_startDocked; }
262 static inline int middleAction() { return s_middleAction; }
263 static inline bool groupOnInsertionLine() { return s_groupOnInsertionLine; }
264 static inline bool spellCheckTextNotes() { return s_spellCheckTextNotes; }
265 static inline bool hideOnMouseOut() { return s_hideOnMouseOut; }
266 static inline int timeToHideOnMouseOut() { return s_timeToHideOnMouseOut; }
267 static inline bool showOnMouseIn() { return s_showOnMouseIn; }
268 static inline int timeToShowOnMouseIn() { return s_timeToShowOnMouseIn; }
269 static inline int basketTreeWidth() { return s_basketTreeWidth; }
270 static inline int dropTimeToShow() { return 7; } // TODO: 700 ; TODO: There is certainly a KGlobalConfig ???
271 static inline bool usePassivePopup() { return s_usePassivePopup; }
272 static inline bool welcomeBasketsAdded() { return s_welcomeBasketsAdded; }
273 static inline QString dataFolder() { return s_dataFolder; }
274 static inline QDate lastBackup() { return s_lastBackup; }
275 static inline QPoint mainWindowPosition() { return s_mainWindowPosition; }
276 static inline QSize mainWindowSize() { return s_mainWindowSize; }
277 static inline bool showEmptyBasketInfo() { return s_showEmptyBasketInfo; }
278 /** Programs */
279 static inline bool isHtmlUseProg() { return s_htmlUseProg; }
280 static inline bool isImageUseProg() { return s_imageUseProg; }
281 static inline bool isAnimationUseProg() { return s_animationUseProg; }
282 static inline bool isSoundUseProg() { return s_soundUseProg; }
283 static inline QString htmlProg() { return s_htmlProg; }
284 static inline QString imageProg() { return s_imageProg; }
285 static inline QString animationProg() { return s_animationProg; }
286 static inline QString soundProg() { return s_soundProg; }
287 /** Insert Note Default Values */
288 static inline int defImageX() { return s_defImageX; }
289 static inline int defImageY() { return s_defImageY; }
290 static inline int defIconSize() { return s_defIconSize; }
291 /** Note Addition */
292 static inline int newNotesPlace() { return s_newNotesPlace; }
293 static inline int viewTextFileContent() { return s_viewTextFileContent; }
294 static inline int viewHtmlFileContent() { return s_viewHtmlFileContent; }
295 static inline int viewImageFileContent() { return s_viewImageFileContent; }
296 static inline int viewSoundFileContent() { return s_viewSoundFileContent; }
298 /** App settings SET */
299 static void setTreeOnLeft(bool onLeft)
301 s_treeOnLeft = onLeft;
302 if (Global::bnpView)
303 Global::bnpView->setTreePlacement(onLeft);
305 static void setFilterOnTop(bool onTop)
307 if (s_filterOnTop != onTop) {
308 s_filterOnTop = onTop;
309 if (Global::bnpView)
310 Global::bnpView->filterPlacementChanged(onTop);
313 static void setShowNotesToolTip(bool show)
315 s_showNotesToolTip = show;
317 static void setUseSystray(bool useSystray)
319 if (s_useSystray != useSystray) {
320 s_useSystray = useSystray;
321 if (Global::systemTray != 0L) {
322 if (Settings::useSystray())
323 Global::systemTray->show();
324 else {
325 Global::systemTray->hide();
326 if(Global::mainWindow()) Global::mainWindow()->show();
329 if (Global::bnpView)
330 Global::bnpView->m_actHideWindow->setEnabled(useSystray);
333 static void setShowIconInSystray(bool show)
335 if (s_showIconInSystray != show) {
336 s_showIconInSystray = show;
337 if (Global::systemTray != 0L && Settings::useSystray())
338 Global::systemTray->updateToolTip();
341 static inline void setConfirmNoteDeletion(bool confirm) { s_confirmNoteDeletion = confirm; }
342 static void setBigNotes(bool big);
343 static void setAutoBullet(bool yes);
344 static inline void setExportTextTags(bool yes) { s_exportTextTags = yes; }
345 static inline void setUseGnuPGAgent(bool yes) { s_useGnuPGAgent = yes; }
346 static inline void setPlayAnimations(bool play) { s_playAnimations = play; }
347 static inline void setBlinkedFilter(bool blinked) { s_blinkedFilter = blinked; }
348 static inline void setEnableReLockTimeout(bool yes) { s_enableReLockTimeout = yes; }
349 static inline void setReLockTimeoutMinutes(int minutes) { s_reLockTimeoutMinutes = minutes; }
350 static inline void setStartDocked(bool docked) { s_startDocked = docked; }
351 static inline void setMiddleAction(int action) { s_middleAction = action; }
352 static inline void setGroupOnInsertionLine(bool yes) { s_groupOnInsertionLine = yes; }
353 static inline void setSpellCheckTextNotes(bool yes) { s_spellCheckTextNotes = yes; }
354 static inline void setHideOnMouseOut(bool hide) { s_hideOnMouseOut = hide; }
355 static inline void setTimeToHideOnMouseOut(int time) { s_timeToHideOnMouseOut = time; }
356 static inline void setShowOnMouseIn(bool show) { s_showOnMouseIn = show; }
357 static inline void setTimeToShowOnMouseIn(int time) { s_timeToShowOnMouseIn = time; }
358 static inline void setBasketTreeWidth(int width) { s_basketTreeWidth = width; }
359 static inline void setUsePassivePopup(bool enable) { s_usePassivePopup = enable; }
360 static inline void setWelcomeBasketsAdded(bool added) { s_welcomeBasketsAdded = added; }
361 static inline void setDataFolder(const QString &folder) { s_dataFolder = folder; }
362 static inline void setLastBackup(const QDate &date) { s_lastBackup = date; }
363 static inline void setMainWindowPosition(const QPoint &pos) { s_mainWindowPosition = pos; }
364 static inline void setMainWindowSize(const QSize &size) { s_mainWindowSize = size; }
365 static inline void setShowEmptyBasketInfo(bool show) { s_showEmptyBasketInfo = show; }
366 // Programs :
367 static inline void setIsHtmlUseProg(bool useProg) { s_htmlUseProg = useProg; }
368 static inline void setIsImageUseProg(bool useProg) { s_imageUseProg = useProg; }
369 static inline void setIsAnimationUseProg(bool useProg) { s_animationUseProg = useProg; }
370 static inline void setIsSoundUseProg(bool useProg) { s_soundUseProg = useProg; }
371 static inline void setHtmlProg(const QString &prog) { s_htmlProg = prog; }
372 static inline void setImageProg(const QString &prog) { s_imageProg = prog; }
373 static inline void setAnimationProg(const QString &prog) { s_animationProg = prog; }
374 static inline void setSoundProg(const QString &prog) { s_soundProg = prog; }
375 // Insert Note Default Values :
376 static inline void setDefImageX(int val) { s_defImageX = val; }
377 static inline void setDefImageY(int val) { s_defImageY = val; }
378 static inline void setDefIconSize(int val) { s_defIconSize = val; }
379 // Note Addition
380 static inline void setNewNotesPlace(int val) { s_newNotesPlace = val; }
381 static inline void setViewTextFileContent(bool view) { s_viewTextFileContent = view; }
382 static inline void setViewHtmlFileContent(bool view) { s_viewHtmlFileContent = view; }
383 static inline void setViewImageFileContent(bool view) { s_viewImageFileContent = view; }
384 static inline void setViewSoundFileContent(bool view) { s_viewSoundFileContent = view; }
385 public:
386 /* Save and load config */
387 static void loadConfig();
388 static void saveConfig();
389 protected:
390 static void loadLinkLook(LinkLook *look, const QString &name, const LinkLook &defaultLook);
391 static void saveLinkLook(LinkLook *look, const QString &name);
394 #endif // SETTINGS_H