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 ***************************************************************************/ 20 21 #ifndef SETTINGS_H 22 #define SETTINGS_H 23 24 #include <KCModule> 25 #include <KMainWindow> //For Global::mainWindow() 26 27 #include <QtCore/QDate> 28 #include <QAction> //For UseSysTray 29 30 #include "basket_export.h" 31 #include "bnpview.h" 32 #include "systemtray.h" 33 34 class KComboBox; 35 36 class QString; 37 class QCheckBox; 38 class QPushButton; 39 class QPoint; 40 class QSize; 41 class QSpinBox; 42 43 class LinkLook; 44 class LinkLookEditWidget; 45 class RunCommandRequester; 46 47 class BASKET_EXPORT GeneralPage : public KCModule 48 { 49 Q_OBJECT 50 public: 51 explicit GeneralPage(QWidget * parent = 0, const char * name = 0); ~GeneralPage()52 virtual ~GeneralPage() {} 53 54 virtual void load(); 55 virtual void save(); 56 virtual void defaults(); 57 58 private: 59 // General 60 KComboBox *m_treeOnLeft; 61 KComboBox *m_filterOnTop; 62 QCheckBox *m_usePassivePopup; 63 64 // System Tray Icon 65 QCheckBox *m_useSystray; 66 QWidget *m_systray; 67 QCheckBox *m_showIconInSystray; 68 QCheckBox *m_hideOnMouseOut; 69 QSpinBox *m_timeToHideOnMouseOut; 70 QCheckBox *m_showOnMouseIn; 71 QSpinBox *m_timeToShowOnMouseIn; 72 }; 73 74 class BASKET_EXPORT BasketsPage : public KCModule 75 { 76 Q_OBJECT 77 public: 78 explicit BasketsPage(QWidget * parent = 0, const char * name = 0); 79 80 virtual void load(); 81 virtual void save(); 82 virtual void defaults(); 83 84 private: 85 // Appearance 86 QCheckBox *m_playAnimations; 87 QCheckBox *m_showNotesToolTip; 88 QCheckBox *m_bigNotes; 89 90 // Behavior 91 QCheckBox *m_autoBullet; 92 QCheckBox *m_confirmNoteDeletion; 93 QCheckBox *m_exportTextTags; 94 QWidget *m_groupOnInsertionLineWidget; 95 QCheckBox *m_groupOnInsertionLine; 96 KComboBox *m_middleAction; 97 QCheckBox *m_pasteAsPlainText; 98 99 // Protection 100 QCheckBox *m_useGnuPGAgent; 101 QCheckBox *m_enableReLockTimeoutMinutes; 102 QSpinBox *m_reLockTimeoutMinutes; 103 }; 104 105 class BASKET_EXPORT NewNotesPage : public KCModule 106 { 107 Q_OBJECT 108 public: 109 explicit NewNotesPage(QWidget * parent = 0, const char * name = 0); 110 111 virtual void load(); 112 virtual void save(); 113 virtual void defaults(); 114 115 private slots: 116 void visualize(); 117 118 private: 119 // Notes Image Size 120 QSpinBox *m_imgSizeX; 121 QSpinBox *m_imgSizeY; 122 QPushButton *m_pushVisualize; 123 124 // Note Addition 125 KComboBox *m_newNotesPlace; 126 QCheckBox *m_viewTextFileContent; 127 QCheckBox *m_viewHtmlFileContent; 128 QCheckBox *m_viewImageFileContent; 129 QCheckBox *m_viewSoundFileContent; 130 }; 131 132 class BASKET_EXPORT NotesAppearancePage : public KCModule 133 { 134 Q_OBJECT 135 public: 136 explicit NotesAppearancePage(QWidget * parent = 0, const char * name = 0); 137 138 virtual void load(); 139 virtual void save(); 140 virtual void defaults(); 141 142 private: 143 // Link Looks 144 LinkLookEditWidget *m_soundLook; 145 LinkLookEditWidget *m_fileLook; 146 LinkLookEditWidget *m_localLinkLook; 147 LinkLookEditWidget *m_networkLinkLook; 148 LinkLookEditWidget *m_launcherLook; 149 LinkLookEditWidget *m_crossReferenceLook; 150 }; 151 152 class BASKET_EXPORT ApplicationsPage : public KCModule 153 { 154 Q_OBJECT 155 public: 156 explicit ApplicationsPage(QWidget * parent = 0, const char * name = 0); 157 158 virtual void load(); 159 virtual void save(); 160 virtual void defaults(); 161 162 private: 163 // Applications 164 QCheckBox *m_htmlUseProg; 165 QCheckBox *m_imageUseProg; 166 QCheckBox *m_animationUseProg; 167 QCheckBox *m_soundUseProg; 168 RunCommandRequester *m_htmlProg; 169 RunCommandRequester *m_imageProg; 170 RunCommandRequester *m_animationProg; 171 RunCommandRequester *m_soundProg; 172 }; 173 174 /** Handle all global variables (to avoid lot of extern declarations) 175 * @author Sébastien Laoût 176 */ 177 class BASKET_EXPORT Settings // FIXME: Distaptch new config events ? 178 { 179 protected: 180 /** Main window */ 181 static bool s_treeOnLeft; 182 static bool s_filterOnTop; 183 static bool s_playAnimations; 184 static bool s_showNotesToolTip; 185 static bool s_confirmNoteDeletion; 186 static bool s_bigNotes; 187 static bool s_autoBullet; 188 static bool s_pasteAsPlainText; 189 static bool s_exportTextTags; 190 static bool s_useGnuPGAgent; 191 static bool s_usePassivePopup; 192 static int s_middleAction; // O:Nothing ; 1:Paste ; 2:Text ; 3:Html ; 4:Image ; 5:Link ; 6:Launcher ; 7:Color 193 static bool s_groupOnInsertionLine; 194 static bool s_spellCheckTextNotes; 195 static int s_basketTreeWidth; 196 static bool s_welcomeBasketsAdded; 197 static QString s_dataFolder; 198 static QDate s_lastBackup; 199 static QPoint s_mainWindowPosition; 200 static QSize s_mainWindowSize; 201 static bool s_showEmptyBasketInfo; 202 static bool s_blinkedFilter; 203 static bool s_enableReLockTimeout; 204 static int s_reLockTimeoutMinutes; 205 /** Note Addition */ 206 static int s_newNotesPlace; // 0:OnTop ; 1:OnBottom ; 2:AtCurrentNote 207 static int s_viewTextFileContent; 208 static int s_viewHtmlFileContent; 209 static int s_viewImageFileContent; 210 static int s_viewSoundFileContent; 211 /** System tray Icon */ 212 static bool s_useSystray; 213 static bool s_showIconInSystray; 214 static bool s_startDocked; 215 static bool s_hideOnMouseOut; 216 static int s_timeToHideOnMouseOut; 217 static bool s_showOnMouseIn; 218 static int s_timeToShowOnMouseIn; 219 /** Programs */ 220 static bool s_htmlUseProg; 221 static bool s_imageUseProg; 222 static bool s_animationUseProg; 223 static bool s_soundUseProg; 224 static QString s_htmlProg; 225 static QString s_imageProg; 226 static QString s_animationProg; 227 static QString s_soundProg; 228 /** Insert Note Default Values */ 229 static int s_defImageX; 230 static int s_defImageY; 231 static int s_defIconSize; 232 /** Version Sync */ 233 static bool s_versionSyncEnabled; 234 public: /* And the following methods are just getter / setters */ 235 /** App settings GET */ treeOnLeft()236 static inline bool treeOnLeft() { 237 return s_treeOnLeft; 238 } filterOnTop()239 static inline bool filterOnTop() { 240 return s_filterOnTop; 241 } playAnimations()242 static inline bool playAnimations() { 243 return s_playAnimations; 244 } showNotesToolTip()245 static inline bool showNotesToolTip() { 246 return s_showNotesToolTip; 247 } confirmNoteDeletion()248 static inline bool confirmNoteDeletion() { 249 return s_confirmNoteDeletion; 250 } bigNotes()251 static inline bool bigNotes() { 252 return s_bigNotes; 253 } autoBullet()254 static inline bool autoBullet() { 255 return s_autoBullet; 256 } pasteAsPlainText()257 static inline bool pasteAsPlainText() { 258 return s_pasteAsPlainText; 259 } exportTextTags()260 static inline bool exportTextTags() { 261 return s_exportTextTags; 262 } useGnuPGAgent()263 static inline bool useGnuPGAgent() { 264 return s_useGnuPGAgent; 265 } blinkedFilter()266 static inline bool blinkedFilter() { 267 return s_blinkedFilter; 268 } enableReLockTimeout()269 static inline bool enableReLockTimeout() { 270 return s_enableReLockTimeout; 271 } reLockTimeoutMinutes()272 static inline int reLockTimeoutMinutes() { 273 return s_reLockTimeoutMinutes; 274 } useSystray()275 static inline bool useSystray() { 276 return s_useSystray; 277 } showIconInSystray()278 static inline bool showIconInSystray() { 279 return s_showIconInSystray; 280 } startDocked()281 static inline bool startDocked() { 282 return s_startDocked; 283 } middleAction()284 static inline int middleAction() { 285 return s_middleAction; 286 } groupOnInsertionLine()287 static inline bool groupOnInsertionLine() { 288 return s_groupOnInsertionLine; 289 } spellCheckTextNotes()290 static inline bool spellCheckTextNotes() { 291 return s_spellCheckTextNotes; 292 } hideOnMouseOut()293 static inline bool hideOnMouseOut() { 294 return s_hideOnMouseOut; 295 } timeToHideOnMouseOut()296 static inline int timeToHideOnMouseOut() { 297 return s_timeToHideOnMouseOut; 298 } showOnMouseIn()299 static inline bool showOnMouseIn() { 300 return s_showOnMouseIn; 301 } timeToShowOnMouseIn()302 static inline int timeToShowOnMouseIn() { 303 return s_timeToShowOnMouseIn; 304 } basketTreeWidth()305 static inline int basketTreeWidth() { 306 return s_basketTreeWidth; 307 } dropTimeToShow()308 static inline int dropTimeToShow() { 309 return 7; 310 } // TODO: 700 ; TODO: There is certainly a KGlobalConfig ??? usePassivePopup()311 static inline bool usePassivePopup() { 312 return s_usePassivePopup; 313 } welcomeBasketsAdded()314 static inline bool welcomeBasketsAdded() { 315 return s_welcomeBasketsAdded; 316 } dataFolder()317 static inline QString dataFolder() { 318 return s_dataFolder; 319 } lastBackup()320 static inline QDate lastBackup() { 321 return s_lastBackup; 322 } mainWindowPosition()323 static inline QPoint mainWindowPosition() { 324 return s_mainWindowPosition; 325 } mainWindowSize()326 static inline QSize mainWindowSize() { 327 return s_mainWindowSize; 328 } showEmptyBasketInfo()329 static inline bool showEmptyBasketInfo() { 330 return s_showEmptyBasketInfo; 331 } 332 /** Programs */ isHtmlUseProg()333 static inline bool isHtmlUseProg() { 334 return s_htmlUseProg; 335 } isImageUseProg()336 static inline bool isImageUseProg() { 337 return s_imageUseProg; 338 } isAnimationUseProg()339 static inline bool isAnimationUseProg() { 340 return s_animationUseProg; 341 } isSoundUseProg()342 static inline bool isSoundUseProg() { 343 return s_soundUseProg; 344 } htmlProg()345 static inline QString htmlProg() { 346 return s_htmlProg; 347 } imageProg()348 static inline QString imageProg() { 349 return s_imageProg; 350 } animationProg()351 static inline QString animationProg() { 352 return s_animationProg; 353 } soundProg()354 static inline QString soundProg() { 355 return s_soundProg; 356 } 357 /** Insert Note Default Values */ defImageX()358 static inline int defImageX() { 359 return s_defImageX; 360 } defImageY()361 static inline int defImageY() { 362 return s_defImageY; 363 } defIconSize()364 static inline int defIconSize() { 365 return s_defIconSize; 366 } 367 /** Note Addition */ newNotesPlace()368 static inline int newNotesPlace() { 369 return s_newNotesPlace; 370 } viewTextFileContent()371 static inline int viewTextFileContent() { 372 return s_viewTextFileContent; 373 } viewHtmlFileContent()374 static inline int viewHtmlFileContent() { 375 return s_viewHtmlFileContent; 376 } viewImageFileContent()377 static inline int viewImageFileContent() { 378 return s_viewImageFileContent; 379 } viewSoundFileContent()380 static inline int viewSoundFileContent() { 381 return s_viewSoundFileContent; 382 } 383 /** Version Sync */ versionSyncEnabled()384 static inline bool versionSyncEnabled() { 385 return s_versionSyncEnabled; 386 } 387 388 /** App settings SET */ setTreeOnLeft(bool onLeft)389 static void setTreeOnLeft(bool onLeft) { 390 s_treeOnLeft = onLeft; 391 if (Global::bnpView) 392 Global::bnpView->setTreePlacement(onLeft); 393 } setFilterOnTop(bool onTop)394 static void setFilterOnTop(bool onTop) { 395 if (s_filterOnTop != onTop) { 396 s_filterOnTop = onTop; 397 if (Global::bnpView) 398 Global::bnpView->filterPlacementChanged(onTop); 399 } 400 } setShowNotesToolTip(bool show)401 static void setShowNotesToolTip(bool show) { 402 s_showNotesToolTip = show; 403 } setUseSystray(bool useSystray)404 static void setUseSystray(bool useSystray) { 405 if (s_useSystray != useSystray) { 406 s_useSystray = useSystray; 407 if (Global::systemTray != 0L) { 408 if (Settings::useSystray()) 409 Global::systemTray->setStatus(KStatusNotifierItem::Active); 410 else { 411 Global::systemTray->setStatus(KStatusNotifierItem::Passive); 412 if (Global::activeMainWindow()) Global::activeMainWindow()->show(); 413 } 414 } 415 if (Global::bnpView) 416 Global::bnpView->m_actHideWindow->setEnabled(useSystray); 417 } 418 } setShowIconInSystray(bool show)419 static void setShowIconInSystray(bool show) { 420 if (s_showIconInSystray != show) 421 s_showIconInSystray = show; 422 } setConfirmNoteDeletion(bool confirm)423 static inline void setConfirmNoteDeletion(bool confirm) { 424 s_confirmNoteDeletion = confirm; 425 } setPasteAsPlainText(bool yes)426 static inline void setPasteAsPlainText(bool yes) { 427 s_pasteAsPlainText = yes; 428 } 429 static void setBigNotes(bool big); 430 static void setAutoBullet(bool yes); setExportTextTags(bool yes)431 static inline void setExportTextTags(bool yes) { 432 s_exportTextTags = yes; 433 } setUseGnuPGAgent(bool yes)434 static inline void setUseGnuPGAgent(bool yes) { 435 s_useGnuPGAgent = yes; 436 } setPlayAnimations(bool play)437 static inline void setPlayAnimations(bool play) { 438 s_playAnimations = play; 439 } setBlinkedFilter(bool blinked)440 static inline void setBlinkedFilter(bool blinked) { 441 s_blinkedFilter = blinked; 442 } setEnableReLockTimeout(bool yes)443 static inline void setEnableReLockTimeout(bool yes) { 444 s_enableReLockTimeout = yes; 445 } setReLockTimeoutMinutes(int minutes)446 static inline void setReLockTimeoutMinutes(int minutes) { 447 s_reLockTimeoutMinutes = minutes; 448 } setStartDocked(bool docked)449 static inline void setStartDocked(bool docked) { 450 s_startDocked = docked; 451 } setMiddleAction(int action)452 static inline void setMiddleAction(int action) { 453 s_middleAction = action; 454 } setGroupOnInsertionLine(bool yes)455 static inline void setGroupOnInsertionLine(bool yes) { 456 s_groupOnInsertionLine = yes; 457 } setSpellCheckTextNotes(bool yes)458 static inline void setSpellCheckTextNotes(bool yes) { 459 s_spellCheckTextNotes = yes; 460 } setHideOnMouseOut(bool hide)461 static inline void setHideOnMouseOut(bool hide) { 462 s_hideOnMouseOut = hide; 463 } setTimeToHideOnMouseOut(int time)464 static inline void setTimeToHideOnMouseOut(int time) { 465 s_timeToHideOnMouseOut = time; 466 } setShowOnMouseIn(bool show)467 static inline void setShowOnMouseIn(bool show) { 468 s_showOnMouseIn = show; 469 } setTimeToShowOnMouseIn(int time)470 static inline void setTimeToShowOnMouseIn(int time) { 471 s_timeToShowOnMouseIn = time; 472 } setBasketTreeWidth(int width)473 static inline void setBasketTreeWidth(int width) { 474 s_basketTreeWidth = width; 475 } setUsePassivePopup(bool enable)476 static inline void setUsePassivePopup(bool enable) { 477 s_usePassivePopup = enable; 478 } setWelcomeBasketsAdded(bool added)479 static inline void setWelcomeBasketsAdded(bool added) { 480 s_welcomeBasketsAdded = added; 481 } setDataFolder(const QString & folder)482 static inline void setDataFolder(const QString &folder) { 483 s_dataFolder = folder; 484 } setLastBackup(const QDate & date)485 static inline void setLastBackup(const QDate &date) { 486 s_lastBackup = date; 487 } setMainWindowPosition(const QPoint & pos)488 static inline void setMainWindowPosition(const QPoint &pos) { 489 s_mainWindowPosition = pos; 490 } setMainWindowSize(const QSize & size)491 static inline void setMainWindowSize(const QSize &size) { 492 s_mainWindowSize = size; 493 } setShowEmptyBasketInfo(bool show)494 static inline void setShowEmptyBasketInfo(bool show) { 495 s_showEmptyBasketInfo = show; 496 } 497 // Programs : setIsHtmlUseProg(bool useProg)498 static inline void setIsHtmlUseProg(bool useProg) { 499 s_htmlUseProg = useProg; 500 } setIsImageUseProg(bool useProg)501 static inline void setIsImageUseProg(bool useProg) { 502 s_imageUseProg = useProg; 503 } setIsAnimationUseProg(bool useProg)504 static inline void setIsAnimationUseProg(bool useProg) { 505 s_animationUseProg = useProg; 506 } setIsSoundUseProg(bool useProg)507 static inline void setIsSoundUseProg(bool useProg) { 508 s_soundUseProg = useProg; 509 } setHtmlProg(const QString & prog)510 static inline void setHtmlProg(const QString &prog) { 511 s_htmlProg = prog; 512 } setImageProg(const QString & prog)513 static inline void setImageProg(const QString &prog) { 514 s_imageProg = prog; 515 } setAnimationProg(const QString & prog)516 static inline void setAnimationProg(const QString &prog) { 517 s_animationProg = prog; 518 } setSoundProg(const QString & prog)519 static inline void setSoundProg(const QString &prog) { 520 s_soundProg = prog; 521 } 522 // Insert Note Default Values : setDefImageX(int val)523 static inline void setDefImageX(int val) { 524 s_defImageX = val; 525 } setDefImageY(int val)526 static inline void setDefImageY(int val) { 527 s_defImageY = val; 528 } setDefIconSize(int val)529 static inline void setDefIconSize(int val) { 530 s_defIconSize = val; 531 } 532 // Note Addition setNewNotesPlace(int val)533 static inline void setNewNotesPlace(int val) { 534 s_newNotesPlace = val; 535 } setViewTextFileContent(bool view)536 static inline void setViewTextFileContent(bool view) { 537 s_viewTextFileContent = view; 538 } setViewHtmlFileContent(bool view)539 static inline void setViewHtmlFileContent(bool view) { 540 s_viewHtmlFileContent = view; 541 } setViewImageFileContent(bool view)542 static inline void setViewImageFileContent(bool view) { 543 s_viewImageFileContent = view; 544 } setViewSoundFileContent(bool view)545 static inline void setViewSoundFileContent(bool view) { 546 s_viewSoundFileContent = view; 547 } 548 // Version Sync setVersionSyncEnabled(bool enable)549 static inline void setVersionSyncEnabled(bool enable) { 550 s_versionSyncEnabled = enable; 551 } 552 public: 553 /* Save and load config */ 554 static void loadConfig(); 555 static void saveConfig(); 556 protected: 557 static void loadLinkLook(LinkLook *look, const QString &name, const LinkLook &defaultLook); 558 static void saveLinkLook(LinkLook *look, const QString &name); 559 }; 560 561 #endif // SETTINGS_H 562