1 /***************************************************************************
2 * Copyright (C) 2003 by Sébastien Laoût *
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. *
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. *
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 ***************************************************************************/
28 #include <qcheckbox.h>
29 #include <qcombobox.h>
36 #include <kmainwindow.h>
37 #include <qdatetime.h>
41 #include "systemtray.h"
54 class LinkLookEditWidget
;
55 class RunCommandRequester
;
58 class GeneralPage
: public KCModule
62 GeneralPage(QWidget
* parent
=0, const char * name
=0);
63 virtual ~GeneralPage() {}
67 virtual void defaults();
71 QComboBox
*m_treeOnLeft
;
72 QComboBox
*m_filterOnTop
;
73 QCheckBox
*m_usePassivePopup
;
76 QCheckBox
*m_useSystray
;
78 QCheckBox
*m_showIconInSystray
;
79 QCheckBox
*m_hideOnMouseOut
;
80 KIntNumInput
*m_timeToHideOnMouseOut
;
81 QCheckBox
*m_showOnMouseIn
;
82 KIntNumInput
*m_timeToShowOnMouseIn
;
85 class BasketsPage
: public KCModule
89 BasketsPage(QWidget
* parent
=0, const char * name
=0);
93 virtual void defaults();
97 QCheckBox
*m_playAnimations
;
98 QCheckBox
*m_showNotesToolTip
;
99 QCheckBox
*m_bigNotes
;
102 QCheckBox
*m_autoBullet
;
103 QCheckBox
*m_confirmNoteDeletion
;
104 QCheckBox
*m_exportTextTags
;
105 QWidget
*m_groupOnInsertionLineWidget
;
106 QCheckBox
*m_groupOnInsertionLine
;
107 QComboBox
*m_middleAction
;
110 QCheckBox
*m_useGnuPGAgent
;
111 QCheckBox
*m_enableReLockTimeoutMinutes
;
112 KIntNumInput
*m_reLockTimeoutMinutes
;
115 class NewNotesPage
: public KCModule
119 NewNotesPage(QWidget
* parent
=0, const char * name
=0);
123 virtual void defaults();
130 KIntNumInput
*m_imgSizeX
;
131 KIntNumInput
*m_imgSizeY
;
132 QPushButton
*m_pushVisualize
;
135 QComboBox
*m_newNotesPlace
;
136 QCheckBox
*m_viewTextFileContent
;
137 QCheckBox
*m_viewHtmlFileContent
;
138 QCheckBox
*m_viewImageFileContent
;
139 QCheckBox
*m_viewSoundFileContent
;
142 class NotesAppearancePage
: public KCModule
146 NotesAppearancePage(QWidget
* parent
=0, const char * name
=0);
150 virtual void defaults();
154 LinkLookEditWidget
*m_soundLook
;
155 LinkLookEditWidget
*m_fileLook
;
156 LinkLookEditWidget
*m_localLinkLook
;
157 LinkLookEditWidget
*m_networkLinkLook
;
158 LinkLookEditWidget
*m_launcherLook
;
161 class ApplicationsPage
: public KCModule
165 ApplicationsPage(QWidget
* parent
=0, const char * name
=0);
169 virtual void defaults();
173 QCheckBox
*m_htmlUseProg
;
174 QCheckBox
*m_imageUseProg
;
175 QCheckBox
*m_animationUseProg
;
176 QCheckBox
*m_soundUseProg
;
177 RunCommandRequester
*m_htmlProg
;
178 RunCommandRequester
*m_imageProg
;
179 RunCommandRequester
*m_animationProg
;
180 RunCommandRequester
*m_soundProg
;
183 /** Handle all global variables (to avoid lot of extern declarations)
184 * @author S�astien Laot
186 class Settings
// FIXME: Distaptch new config events ?
190 static bool s_treeOnLeft
;
191 static bool s_filterOnTop
;
192 static bool s_playAnimations
;
193 static bool s_showNotesToolTip
;
194 static bool s_confirmNoteDeletion
;
195 static bool s_bigNotes
;
196 static bool s_autoBullet
;
197 static bool s_exportTextTags
;
198 static bool s_useGnuPGAgent
;
199 static bool s_usePassivePopup
;
200 static int s_middleAction
; // O:Nothing ; 1:Paste ; 2:Text ; 3:Html ; 4:Image ; 5:Link ; 6:Launcher ; 7:Color
201 static bool s_groupOnInsertionLine
;
202 static bool s_spellCheckTextNotes
;
203 static int s_basketTreeWidth
;
204 static bool s_welcomeBasketsAdded
;
205 static QString s_dataFolder
;
206 static QDate s_lastBackup
;
207 static QPoint s_mainWindowPosition
;
208 static QSize s_mainWindowSize
;
209 static bool s_showEmptyBasketInfo
;
210 static bool s_blinkedFilter
;
211 static bool s_enableReLockTimeout
;
212 static int s_reLockTimeoutMinutes
;
214 static int s_newNotesPlace
; // 0:OnTop ; 1:OnBottom ; 2:AtCurrentNote
215 static int s_viewTextFileContent
;
216 static int s_viewHtmlFileContent
;
217 static int s_viewImageFileContent
;
218 static int s_viewSoundFileContent
;
219 /** System tray Icon */
220 static bool s_useSystray
;
221 static bool s_showIconInSystray
;
222 static bool s_startDocked
;
223 static bool s_hideOnMouseOut
;
224 static int s_timeToHideOnMouseOut
;
225 static bool s_showOnMouseIn
;
226 static int s_timeToShowOnMouseIn
;
228 static bool s_htmlUseProg
;
229 static bool s_imageUseProg
;
230 static bool s_animationUseProg
;
231 static bool s_soundUseProg
;
232 static QString s_htmlProg
;
233 static QString s_imageProg
;
234 static QString s_animationProg
;
235 static QString s_soundProg
;
236 /** Insert Note Default Values */
237 static int s_defImageX
;
238 static int s_defImageY
;
239 static int s_defIconSize
;
240 public: /* And the following methods are just getter / setters */
241 /** App settings GET */
242 static inline bool treeOnLeft() { return s_treeOnLeft
; }
243 static inline bool filterOnTop() { return s_filterOnTop
; }
244 static inline bool playAnimations() { return s_playAnimations
; }
245 static inline bool showNotesToolTip() { return s_showNotesToolTip
; }
246 static inline bool confirmNoteDeletion() { return s_confirmNoteDeletion
; }
247 static inline bool bigNotes() { return s_bigNotes
; }
248 static inline bool autoBullet() { return s_autoBullet
; }
249 static inline bool exportTextTags() { return s_exportTextTags
; }
250 static inline bool useGnuPGAgent() { return s_useGnuPGAgent
; }
251 static inline bool blinkedFilter() { return s_blinkedFilter
; }
252 static inline bool enableReLockTimeout() { return s_enableReLockTimeout
; }
253 static inline int reLockTimeoutMinutes() { return s_reLockTimeoutMinutes
; }
254 static inline bool useSystray() { return s_useSystray
; }
255 static inline bool showIconInSystray() { return s_showIconInSystray
; }
256 static inline bool startDocked() { return s_startDocked
; }
257 static inline int middleAction() { return s_middleAction
; }
258 static inline bool groupOnInsertionLine() { return s_groupOnInsertionLine
; }
259 static inline bool spellCheckTextNotes() { return s_spellCheckTextNotes
; }
260 static inline bool hideOnMouseOut() { return s_hideOnMouseOut
; }
261 static inline int timeToHideOnMouseOut() { return s_timeToHideOnMouseOut
; }
262 static inline bool showOnMouseIn() { return s_showOnMouseIn
; }
263 static inline int timeToShowOnMouseIn() { return s_timeToShowOnMouseIn
; }
264 static inline int basketTreeWidth() { return s_basketTreeWidth
; }
265 static inline int dropTimeToShow() { return 7; } // TODO: 700 ; TODO: There is certainly a KGlobalConfig ???
266 static inline bool usePassivePopup() { return s_usePassivePopup
; }
267 static inline bool welcomeBasketsAdded() { return s_welcomeBasketsAdded
; }
268 static inline QString
dataFolder() { return s_dataFolder
; }
269 static inline QDate
lastBackup() { return s_lastBackup
; }
270 static inline QPoint
mainWindowPosition() { return s_mainWindowPosition
; }
271 static inline QSize
mainWindowSize() { return s_mainWindowSize
; }
272 static inline bool showEmptyBasketInfo() { return s_showEmptyBasketInfo
; }
274 static inline bool isHtmlUseProg() { return s_htmlUseProg
; }
275 static inline bool isImageUseProg() { return s_imageUseProg
; }
276 static inline bool isAnimationUseProg() { return s_animationUseProg
; }
277 static inline bool isSoundUseProg() { return s_soundUseProg
; }
278 static inline QString
htmlProg() { return s_htmlProg
; }
279 static inline QString
imageProg() { return s_imageProg
; }
280 static inline QString
animationProg() { return s_animationProg
; }
281 static inline QString
soundProg() { return s_soundProg
; }
282 /** Insert Note Default Values */
283 static inline int defImageX() { return s_defImageX
; }
284 static inline int defImageY() { return s_defImageY
; }
285 static inline int defIconSize() { return s_defIconSize
; }
287 static inline int newNotesPlace() { return s_newNotesPlace
; }
288 static inline int viewTextFileContent() { return s_viewTextFileContent
; }
289 static inline int viewHtmlFileContent() { return s_viewHtmlFileContent
; }
290 static inline int viewImageFileContent() { return s_viewImageFileContent
; }
291 static inline int viewSoundFileContent() { return s_viewSoundFileContent
; }
293 /** App settings SET */
294 static void setTreeOnLeft(bool onLeft
)
296 s_treeOnLeft
= onLeft
;
298 Global::bnpView
->setTreePlacement(onLeft
);
300 static void setFilterOnTop(bool onTop
)
302 if (s_filterOnTop
!= onTop
) {
303 s_filterOnTop
= onTop
;
305 Global::bnpView
->filterPlacementChanged(onTop
);
308 static void setShowNotesToolTip(bool show
)
310 s_showNotesToolTip
= show
;
312 static void setUseSystray(bool useSystray
)
314 if (s_useSystray
!= useSystray
) {
315 s_useSystray
= useSystray
;
316 if (Global::systemTray
!= 0L) {
317 if (Settings::useSystray())
318 Global::systemTray
->show();
320 Global::systemTray
->hide();
321 if(Global::mainWindow()) Global::mainWindow()->show();
325 Global::bnpView
->m_actHideWindow
->setEnabled(useSystray
);
328 static void setShowIconInSystray(bool show
)
330 if (s_showIconInSystray
!= show
) {
331 s_showIconInSystray
= show
;
332 if (Global::systemTray
!= 0L && Settings::useSystray())
333 Global::systemTray
->updateToolTip();
336 static inline void setConfirmNoteDeletion(bool confirm
) { s_confirmNoteDeletion
= confirm
; }
337 static void setBigNotes(bool big
);
338 static void setAutoBullet(bool yes
);
339 static inline void setExportTextTags(bool yes
) { s_exportTextTags
= yes
; }
340 static inline void setUseGnuPGAgent(bool yes
) { s_useGnuPGAgent
= yes
; }
341 static inline void setPlayAnimations(bool play
) { s_playAnimations
= play
; }
342 static inline void setBlinkedFilter(bool blinked
) { s_blinkedFilter
= blinked
; }
343 static inline void setEnableReLockTimeout(bool yes
) { s_enableReLockTimeout
= yes
; }
344 static inline void setReLockTimeoutMinutes(int minutes
) { s_reLockTimeoutMinutes
= minutes
; }
345 static inline void setStartDocked(bool docked
) { s_startDocked
= docked
; }
346 static inline void setMiddleAction(int action
) { s_middleAction
= action
; }
347 static inline void setGroupOnInsertionLine(bool yes
) { s_groupOnInsertionLine
= yes
; }
348 static inline void setSpellCheckTextNotes(bool yes
) { s_spellCheckTextNotes
= yes
; }
349 static inline void setHideOnMouseOut(bool hide
) { s_hideOnMouseOut
= hide
; }
350 static inline void setTimeToHideOnMouseOut(int time
) { s_timeToHideOnMouseOut
= time
; }
351 static inline void setShowOnMouseIn(bool show
) { s_showOnMouseIn
= show
; }
352 static inline void setTimeToShowOnMouseIn(int time
) { s_timeToShowOnMouseIn
= time
; }
353 static inline void setBasketTreeWidth(int width
) { s_basketTreeWidth
= width
; }
354 static inline void setUsePassivePopup(bool enable
) { s_usePassivePopup
= enable
; }
355 static inline void setWelcomeBasketsAdded(bool added
) { s_welcomeBasketsAdded
= added
; }
356 static inline void setDataFolder(const QString
&folder
) { s_dataFolder
= folder
; }
357 static inline void setLastBackup(const QDate
&date
) { s_lastBackup
= date
; }
358 static inline void setMainWindowPosition(const QPoint
&pos
) { s_mainWindowPosition
= pos
; }
359 static inline void setMainWindowSize(const QSize
&size
) { s_mainWindowSize
= size
; }
360 static inline void setShowEmptyBasketInfo(bool show
) { s_showEmptyBasketInfo
= show
; }
362 static inline void setIsHtmlUseProg(bool useProg
) { s_htmlUseProg
= useProg
; }
363 static inline void setIsImageUseProg(bool useProg
) { s_imageUseProg
= useProg
; }
364 static inline void setIsAnimationUseProg(bool useProg
) { s_animationUseProg
= useProg
; }
365 static inline void setIsSoundUseProg(bool useProg
) { s_soundUseProg
= useProg
; }
366 static inline void setHtmlProg(const QString
&prog
) { s_htmlProg
= prog
; }
367 static inline void setImageProg(const QString
&prog
) { s_imageProg
= prog
; }
368 static inline void setAnimationProg(const QString
&prog
) { s_animationProg
= prog
; }
369 static inline void setSoundProg(const QString
&prog
) { s_soundProg
= prog
; }
370 // Insert Note Default Values :
371 static inline void setDefImageX(int val
) { s_defImageX
= val
; }
372 static inline void setDefImageY(int val
) { s_defImageY
= val
; }
373 static inline void setDefIconSize(int val
) { s_defIconSize
= val
; }
375 static inline void setNewNotesPlace(int val
) { s_newNotesPlace
= val
; }
376 static inline void setViewTextFileContent(bool view
) { s_viewTextFileContent
= view
; }
377 static inline void setViewHtmlFileContent(bool view
) { s_viewHtmlFileContent
= view
; }
378 static inline void setViewImageFileContent(bool view
) { s_viewImageFileContent
= view
; }
379 static inline void setViewSoundFileContent(bool view
) { s_viewSoundFileContent
= view
; }
381 /* Save and load config */
382 static void loadConfig();
383 static void saveConfig();
385 static void loadLinkLook(LinkLook
*look
, const QString
&name
, const LinkLook
&defaultLook
);
386 static void saveLinkLook(LinkLook
*look
, const QString
&name
);