1 /* This file is (c) 2008-2012 Konstantin Isakov <ikm@goldendict.org> 2 * Part of GoldenDict. Licensed under GPLv3 or later, see the LICENSE file */ 3 4 #ifndef __CONFIG_HH_INCLUDED__ 5 #define __CONFIG_HH_INCLUDED__ 6 7 #include <QObject> 8 #include <QVector> 9 #include <QString> 10 #include <QSize> 11 #include <QDateTime> 12 #include <QKeySequence> 13 #include <QSet> 14 #include "cpp_features.hh" 15 #include "ex.hh" 16 17 #ifdef Q_OS_WIN 18 #include <QRect> 19 #endif 20 21 /// GoldenDict's configuration 22 namespace Config { 23 24 /// Dictionaries which are temporarily disabled via the dictionary bar. 25 typedef QSet< QString > MutedDictionaries; 26 27 #ifdef Q_OS_WIN 28 #pragma pack(push,4) 29 #endif 30 31 /// A path where to search for the dictionaries 32 struct Path 33 { 34 QString path; 35 bool recursive; 36 PathConfig::Path37 Path(): recursive( false ) {} PathConfig::Path38 Path( QString const & path_, bool recursive_ ): 39 path( path_ ), recursive( recursive_ ) {} 40 operator ==Config::Path41 bool operator == ( Path const & other ) const 42 { return path == other.path && recursive == other.recursive; } 43 }; 44 45 /// A list of paths where to search for the dictionaries 46 typedef QVector< Path > Paths; 47 48 /// A directory holding bunches of audiofiles, which is indexed into a separate 49 /// dictionary. 50 struct SoundDir 51 { 52 QString path, name; 53 QString iconFilename; 54 SoundDirConfig::SoundDir55 SoundDir() 56 {} 57 SoundDirConfig::SoundDir58 SoundDir( QString const & path_, QString const & name_, QString iconFilename_ = "" ): 59 path( path_ ), name( name_ ), iconFilename( iconFilename_ ) 60 {} 61 operator ==Config::SoundDir62 bool operator == ( SoundDir const & other ) const 63 { return path == other.path && name == other.name && iconFilename == other.iconFilename; } 64 }; 65 66 /// A list of SoundDirs 67 typedef QVector< SoundDir > SoundDirs; 68 69 struct DictionaryRef 70 { 71 QString id; // Dictionrary id, which is usually an md5 hash 72 QString name; // Dictionary name, used to recover when its id changes 73 DictionaryRefConfig::DictionaryRef74 DictionaryRef() 75 {} 76 DictionaryRefConfig::DictionaryRef77 DictionaryRef( QString const & id_, QString const & name_ ): 78 id( id_ ), name( name_ ) {} 79 operator ==Config::DictionaryRef80 bool operator == ( DictionaryRef const & other ) const 81 { return id == other.id && name == other.name; } 82 }; 83 84 /// A dictionary group 85 struct Group 86 { 87 unsigned id; 88 QString name, icon; 89 QByteArray iconData; 90 QKeySequence shortcut; 91 QString favoritesFolder; 92 QVector< DictionaryRef > dictionaries; 93 Config::MutedDictionaries mutedDictionaries; // Disabled via dictionary bar 94 Config::MutedDictionaries popupMutedDictionaries; // Disabled via dictionary bar in popup 95 GroupConfig::Group96 Group(): id( 0 ) {} 97 operator ==Config::Group98 bool operator == ( Group const & other ) const 99 { return id == other.id && name == other.name && icon == other.icon && 100 favoritesFolder == other.favoritesFolder && 101 dictionaries == other.dictionaries && shortcut == other.shortcut && 102 mutedDictionaries == other.mutedDictionaries && 103 popupMutedDictionaries == other.popupMutedDictionaries && 104 iconData == other.iconData; } 105 operator !=Config::Group106 bool operator != ( Group const & other ) const 107 { return ! operator == ( other ); } 108 }; 109 110 /// All the groups 111 struct Groups: public QVector< Group > 112 { 113 unsigned nextId; // Id to use to create the group next time 114 GroupsConfig::Groups115 Groups(): nextId( 1 ) 116 {} 117 }; 118 119 /// Proxy server configuration 120 struct ProxyServer 121 { 122 bool enabled; 123 bool useSystemProxy; 124 125 enum Type 126 { 127 Socks5 = 0, 128 HttpConnect, 129 HttpGet 130 } type; 131 132 QString host; 133 unsigned port; 134 QString user, password; 135 QString systemProxyUser, systemProxyPassword; 136 137 ProxyServer(); 138 }; 139 140 // A hotkey -- currently qt modifiers plus one or two keys 141 struct HotKey 142 { 143 Qt::KeyboardModifiers modifiers; 144 int key1, key2; 145 146 HotKey(); 147 148 /// We use the first two keys of QKeySequence, with modifiers being stored 149 /// in the first one. 150 HotKey( QKeySequence const & ); 151 152 QKeySequence toKeySequence() const; 153 }; 154 155 struct FullTextSearch 156 { 157 int searchMode; 158 bool matchCase; 159 int maxArticlesPerDictionary; 160 int maxDistanceBetweenWords; 161 bool useMaxDistanceBetweenWords; 162 bool useMaxArticlesPerDictionary; 163 bool enabled; 164 bool ignoreWordsOrder; 165 bool ignoreDiacritics; 166 quint32 maxDictionarySize; 167 QByteArray dialogGeometry; 168 QString disabledTypes; 169 FullTextSearchConfig::FullTextSearch170 FullTextSearch() : 171 searchMode( 0 ), matchCase( false ), 172 maxArticlesPerDictionary( 100 ), 173 maxDistanceBetweenWords( 2 ), 174 useMaxDistanceBetweenWords( true ), 175 useMaxArticlesPerDictionary( false ), 176 enabled( true ), 177 ignoreWordsOrder( false ), 178 ignoreDiacritics( false ), 179 maxDictionarySize( 0 ) 180 {} 181 }; 182 183 /// This class encapsulates supported backend preprocessor logic, 184 /// discourages duplicating backend names in code, which is error-prone. 185 class InternalPlayerBackend 186 { 187 public: 188 /// Returns true if at least one backend is available. 189 static bool anyAvailable(); 190 /// Returns the default backend or null backend if none is available. 191 static InternalPlayerBackend defaultBackend(); 192 /// Returns the name list of supported backends. 193 static QStringList nameList(); 194 195 /// Returns true if built with FFmpeg player support and the name matches. 196 bool isFfmpeg() const; 197 /// Returns true if built with Qt Multimedia player support and the name matches. 198 bool isQtmultimedia() const; 199 uiName() const200 QString const & uiName() const 201 { return name; } 202 setUiName(QString const & name_)203 void setUiName( QString const & name_ ) 204 { name = name_; } 205 operator ==(InternalPlayerBackend const & other) const206 bool operator == ( InternalPlayerBackend const & other ) const 207 { return name == other.name; } 208 operator !=(InternalPlayerBackend const & other) const209 bool operator != ( InternalPlayerBackend const & other ) const 210 { return ! operator == ( other ); } 211 212 private: 213 #ifdef MAKE_FFMPEG_PLAYER ffmpeg()214 static InternalPlayerBackend ffmpeg() 215 { return InternalPlayerBackend( "FFmpeg+libao" ); } 216 #endif 217 218 #ifdef MAKE_QTMULTIMEDIA_PLAYER qtmultimedia()219 static InternalPlayerBackend qtmultimedia() 220 { return InternalPlayerBackend( "Qt Multimedia" ); } 221 #endif 222 InternalPlayerBackend(QString const & name_)223 explicit InternalPlayerBackend( QString const & name_ ) : name( name_ ) 224 {} 225 226 QString name; 227 }; 228 229 #if defined( HAVE_X11 ) && QT_VERSION >= QT_VERSION_CHECK( 5, 0, 0 ) 230 // The ScanPopup window flags customization code has been tested 231 // only in X11 desktop environments and window managers. 232 // None of the window flags configurations I have tried works perfectly well 233 // in XFCE with Qt4. Let us enable customization code for Qt5 exclusively to 234 // avoid regressions with Qt4. 235 #define ENABLE_SPWF_CUSTOMIZATION 236 #endif 237 238 enum ScanPopupWindowFlags 239 { 240 SPWF_default = 0, 241 SPWF_Popup, 242 SPWF_Tool 243 }; 244 ScanPopupWindowFlags spwfFromInt( int id ); 245 246 /// Various user preferences 247 struct Preferences 248 { 249 QString interfaceLanguage; // Empty value corresponds to system default 250 QString helpLanguage; // Empty value corresponds to interface language 251 QString displayStyle; // Empty value corresponds to the default one 252 bool newTabsOpenAfterCurrentOne; 253 bool newTabsOpenInBackground; 254 bool hideSingleTab; 255 bool mruTabOrder; 256 bool hideMenubar; 257 bool enableTrayIcon; 258 bool startToTray; 259 bool closeToTray; 260 bool autoStart; 261 bool doubleClickTranslates; 262 bool selectWordBySingleClick; 263 bool escKeyHidesMainWindow; 264 bool alwaysOnTop; 265 266 /// An old UI mode when tranlateLine and wordList 267 /// are in the dockable side panel, not on the toolbar. 268 bool searchInDock; 269 270 bool enableMainWindowHotkey; 271 HotKey mainWindowHotkey; 272 bool enableClipboardHotkey; 273 HotKey clipboardHotkey; 274 275 bool enableScanPopup; 276 bool startWithScanPopupOn; 277 bool enableScanPopupModifiers; 278 unsigned long scanPopupModifiers; // Combination of KeyboardState::Modifier 279 bool scanPopupAltMode; // When you press modifier shortly after the selection 280 unsigned scanPopupAltModeSecs; 281 bool ignoreOwnClipboardChanges; 282 bool scanPopupUseUIAutomation; 283 bool scanPopupUseIAccessibleEx; 284 bool scanPopupUseGDMessage; 285 ScanPopupWindowFlags scanPopupUnpinnedWindowFlags; 286 bool scanPopupUnpinnedBypassWMHint; 287 bool scanToMainWindow; 288 bool ignoreDiacritics; 289 #ifdef HAVE_X11 290 bool showScanFlag; 291 #endif 292 293 // Whether the word should be pronounced on page load, in main window/popup 294 bool pronounceOnLoadMain, pronounceOnLoadPopup; 295 bool useInternalPlayer; 296 InternalPlayerBackend internalPlayerBackend; 297 QString audioPlaybackProgram; 298 299 ProxyServer proxyServer; 300 301 bool checkForNewReleases; 302 bool disallowContentFromOtherSites; 303 bool enableWebPlugins; 304 bool hideGoldenDictHeader; 305 int maxNetworkCacheSize; 306 bool clearNetworkCacheOnExit; 307 308 qreal zoomFactor; 309 qreal helpZoomFactor; 310 int wordsZoomLevel; 311 312 unsigned maxStringsInHistory; 313 unsigned storeHistory; 314 bool alwaysExpandOptionalParts; 315 316 unsigned historyStoreInterval; 317 unsigned favoritesStoreInterval; 318 319 bool confirmFavoritesDeletion; 320 321 bool collapseBigArticles; 322 int articleSizeLimit; 323 324 bool limitInputPhraseLength; 325 int inputPhraseLengthLimit; 326 QString sanitizeInputPhrase( QString const & inputPhrase ) const; 327 328 unsigned short maxDictionaryRefsInContextMenu; 329 #ifndef Q_WS_X11 330 bool trackClipboardChanges; 331 #endif 332 333 bool synonymSearchEnabled; 334 335 QString addonStyle; 336 337 FullTextSearch fts; 338 339 Preferences(); 340 }; 341 342 /// A MediaWiki network dictionary definition 343 struct MediaWiki 344 { 345 QString id, name, url; 346 bool enabled; 347 QString icon; 348 MediaWikiConfig::MediaWiki349 MediaWiki(): enabled( false ) 350 {} 351 MediaWikiConfig::MediaWiki352 MediaWiki( QString const & id_, QString const & name_, QString const & url_, 353 bool enabled_, QString const & icon_ ): 354 id( id_ ), name( name_ ), url( url_ ), enabled( enabled_ ), icon( icon_ ) {} 355 operator ==Config::MediaWiki356 bool operator == ( MediaWiki const & other ) const 357 { return id == other.id && name == other.name && url == other.url && 358 enabled == other.enabled && icon == other.icon ; } 359 }; 360 361 /// Any website which can be queried though a simple template substitution 362 struct WebSite 363 { 364 QString id, name, url; 365 bool enabled; 366 QString iconFilename; 367 bool inside_iframe; 368 WebSiteConfig::WebSite369 WebSite(): enabled( false ) 370 {} 371 WebSiteConfig::WebSite372 WebSite( QString const & id_, QString const & name_, QString const & url_, 373 bool enabled_, QString const & iconFilename_, bool inside_iframe_ ): 374 id( id_ ), name( name_ ), url( url_ ), enabled( enabled_ ), iconFilename( iconFilename_ ), 375 inside_iframe( inside_iframe_ ) {} 376 operator ==Config::WebSite377 bool operator == ( WebSite const & other ) const 378 { return id == other.id && name == other.name && url == other.url && 379 enabled == other.enabled && iconFilename == other.iconFilename && 380 inside_iframe == other.inside_iframe; } 381 }; 382 383 /// All the WebSites 384 typedef QVector< WebSite > WebSites; 385 386 /// Any DICT server 387 struct DictServer 388 { 389 QString id, name, url; 390 bool enabled; 391 QString databases; 392 QString strategies; 393 QString iconFilename; 394 DictServerConfig::DictServer395 DictServer(): enabled( false ) 396 {} 397 DictServerConfig::DictServer398 DictServer( QString const & id_, QString const & name_, QString const & url_, 399 bool enabled_, QString const & databases_, QString const & strategies_, 400 QString const & iconFilename_ ): 401 id( id_ ), name( name_ ), url( url_ ), enabled( enabled_ ), databases( databases_ ), 402 strategies( strategies_ ), iconFilename( iconFilename_ ) {} 403 operator ==Config::DictServer404 bool operator == ( DictServer const & other ) const 405 { return id == other.id && name == other.name && url == other.url 406 && enabled == other.enabled && databases == other.databases 407 && strategies == other.strategies 408 && iconFilename == other.iconFilename; } 409 }; 410 411 /// All the DictServers 412 typedef QVector< DictServer > DictServers; 413 414 /// Hunspell configuration 415 struct Hunspell 416 { 417 QString dictionariesPath; 418 419 typedef QVector< QString > Dictionaries; 420 421 Dictionaries enabledDictionaries; 422 operator ==Config::Hunspell423 bool operator == ( Hunspell const & other ) const 424 { return dictionariesPath == other.dictionariesPath && 425 enabledDictionaries == other.enabledDictionaries; } 426 operator !=Config::Hunspell427 bool operator != ( Hunspell const & other ) const 428 { return ! operator == ( other ); } 429 }; 430 431 /// All the MediaWikis 432 typedef QVector< MediaWiki > MediaWikis; 433 434 #ifdef MAKE_CHINESE_CONVERSION_SUPPORT 435 /// Chinese transliteration configuration 436 struct Chinese 437 { 438 bool enable; 439 440 bool enableSCToTWConversion; 441 bool enableSCToHKConversion; 442 bool enableTCToSCConversion; 443 444 Chinese(); 445 operator ==Config::Chinese446 bool operator == ( Chinese const & other ) const 447 { return enable == other.enable && 448 enableSCToTWConversion == other.enableSCToTWConversion && 449 enableSCToHKConversion == other.enableSCToHKConversion && 450 enableTCToSCConversion == other.enableTCToSCConversion; } 451 operator !=Config::Chinese452 bool operator != ( Chinese const & other ) const 453 { return ! operator == ( other ); } 454 455 }; 456 #endif 457 458 /// Romaji transliteration configuration 459 struct Romaji 460 { 461 bool enable; 462 463 bool enableHepburn; 464 bool enableNihonShiki; 465 bool enableKunreiShiki; 466 bool enableHiragana; 467 bool enableKatakana; 468 469 Romaji(); 470 operator ==Config::Romaji471 bool operator == ( Romaji const & other ) const 472 { return enable == other.enable && 473 enableHepburn == other.enableHepburn && 474 enableNihonShiki == other.enableNihonShiki && 475 enableKunreiShiki == other.enableKunreiShiki && 476 enableHiragana == other.enableHiragana && 477 enableKatakana == other.enableKatakana; } 478 operator !=Config::Romaji479 bool operator != ( Romaji const & other ) const 480 { return ! operator == ( other ); } 481 482 }; 483 484 struct Transliteration 485 { 486 bool enableRussianTransliteration; 487 bool enableGermanTransliteration; 488 bool enableGreekTransliteration; 489 bool enableBelarusianTransliteration; 490 #ifdef MAKE_CHINESE_CONVERSION_SUPPORT 491 Chinese chinese; 492 #endif 493 Romaji romaji; 494 operator ==Config::Transliteration495 bool operator == ( Transliteration const & other ) const 496 { return enableRussianTransliteration == other.enableRussianTransliteration && 497 enableGermanTransliteration == other.enableGermanTransliteration && 498 enableGreekTransliteration == other.enableGreekTransliteration && 499 enableBelarusianTransliteration == other.enableBelarusianTransliteration && 500 #ifdef MAKE_CHINESE_CONVERSION_SUPPORT 501 chinese == other.chinese && 502 #endif 503 romaji == other.romaji; 504 } 505 operator !=Config::Transliteration506 bool operator != ( Transliteration const & other ) const 507 { return ! operator == ( other ); } 508 TransliterationConfig::Transliteration509 Transliteration(): 510 enableRussianTransliteration( false ), 511 enableGermanTransliteration( false ), 512 enableGreekTransliteration( false ), 513 enableBelarusianTransliteration( false ) 514 {} 515 }; 516 517 struct Forvo 518 { 519 bool enable; 520 QString apiKey; 521 QString languageCodes; 522 ForvoConfig::Forvo523 Forvo(): enable( false ) 524 {} 525 operator ==Config::Forvo526 bool operator == ( Forvo const & other ) const 527 { return enable == other.enable && 528 apiKey == other.apiKey && 529 languageCodes == other.languageCodes; 530 } 531 operator !=Config::Forvo532 bool operator != ( Forvo const & other ) const 533 { return ! operator == ( other ); } 534 }; 535 536 struct Program 537 { 538 bool enabled; 539 enum Type 540 { 541 Audio, 542 PlainText, 543 Html, 544 PrefixMatch, 545 MaxTypeValue 546 } type; 547 QString id, name, commandLine; 548 QString iconFilename; 549 ProgramConfig::Program550 Program(): enabled( false ) 551 {} 552 ProgramConfig::Program553 Program( bool enabled_, Type type_, QString const & id_, 554 QString const & name_, QString const & commandLine_, QString const & iconFilename_ ): 555 enabled( enabled_ ), type( type_ ), id( id_ ), name( name_ ), 556 commandLine( commandLine_ ), iconFilename( iconFilename_ ) {} 557 operator ==Config::Program558 bool operator == ( Program const & other ) const 559 { return enabled == other.enabled && 560 type == other.type && 561 name == other.name && 562 commandLine == other.commandLine && 563 iconFilename == other.iconFilename; 564 } 565 operator !=Config::Program566 bool operator != ( Program const & other ) const 567 { return ! operator == ( other ); } 568 }; 569 570 typedef QVector< Program > Programs; 571 572 struct VoiceEngine 573 { 574 bool enabled; 575 QString id; 576 QString name; 577 QString iconFilename; 578 int volume; // 0-100 allowed 579 int rate; // 0-100 allowed 580 VoiceEngineConfig::VoiceEngine581 VoiceEngine(): enabled( false ) 582 , volume( 50 ) 583 , rate( 50 ) 584 {} VoiceEngineConfig::VoiceEngine585 VoiceEngine( QString id_, QString name_, int volume_, int rate_ ): 586 enabled( false ) 587 , id( id_ ) 588 , name( name_ ) 589 , volume( volume_ ) 590 , rate( rate_ ) 591 {} 592 operator ==Config::VoiceEngine593 bool operator == ( VoiceEngine const & other ) const 594 { 595 return enabled == other.enabled && 596 id == other.id && 597 name == other.name && 598 iconFilename == other.iconFilename && 599 volume == other.volume && 600 rate == other.rate; 601 } 602 operator !=Config::VoiceEngine603 bool operator != ( VoiceEngine const & other ) const 604 { return ! operator == ( other ); } 605 }; 606 607 typedef QVector< VoiceEngine> VoiceEngines; 608 609 struct HeadwordsDialog 610 { 611 int searchMode; 612 bool matchCase; 613 bool autoApply; 614 QString headwordsExportPath; 615 QByteArray headwordsDialogGeometry; 616 HeadwordsDialogConfig::HeadwordsDialog617 HeadwordsDialog() : 618 searchMode( 0 ), matchCase( false ) 619 , autoApply( false ) 620 {} 621 }; 622 623 struct Class 624 { 625 Paths paths; 626 SoundDirs soundDirs; 627 Group dictionaryOrder; 628 Group inactiveDictionaries; 629 Groups groups; 630 Preferences preferences; 631 MediaWikis mediawikis; 632 WebSites webSites; 633 DictServers dictServers; 634 Hunspell hunspell; 635 Transliteration transliteration; 636 Forvo forvo; 637 Programs programs; 638 VoiceEngines voiceEngines; 639 640 unsigned lastMainGroupId; // Last used group in main window 641 unsigned lastPopupGroupId; // Last used group in popup window 642 643 QByteArray popupWindowState; // Binary state saved by QMainWindow 644 QByteArray popupWindowGeometry; // Geometry saved by QMainWindow 645 QByteArray dictInfoGeometry; // Geometry of "Dictionary info" window 646 QByteArray inspectorGeometry; // Geometry of WebKit inspector window 647 QByteArray helpWindowGeometry; // Geometry of help window 648 QByteArray helpSplitterState; // Geometry of help splitter 649 650 QString historyExportPath; // Path for export/import history 651 QString resourceSavePath; // Path to save images/audio 652 QString articleSavePath; // Path to save articles 653 654 bool pinPopupWindow; // Last pin status 655 bool popupWindowAlwaysOnTop; // Last status of pinned popup window 656 657 QByteArray mainWindowState; // Binary state saved by QMainWindow 658 QByteArray mainWindowGeometry; // Geometry saved by QMainWindow 659 660 MutedDictionaries mutedDictionaries; // Disabled via dictionary bar 661 MutedDictionaries popupMutedDictionaries; // Disabled via dictionary bar in popup 662 663 QDateTime timeForNewReleaseCheck; // Only effective if 664 // preferences.checkForNewReleases is set 665 QString skippedRelease; // Empty by default 666 667 bool showingDictBarNames; 668 669 bool usingSmallIconsInToolbars; 670 671 int maxPictureWidth; // Maximum picture width 672 673 /// Maximum size for the headwords. 674 /// Bigger headwords won't be indexed. For now, only in DSL. 675 unsigned int maxHeadwordSize; 676 677 unsigned int maxHeadwordsToExpand; 678 679 HeadwordsDialog headwordsDialog; 680 681 #ifdef Q_OS_WIN 682 QRect maximizedMainWindowGeometry; 683 QRect normalMainWindowGeometry; 684 #endif 685 686 QString editDictionaryCommandLine; // Command line to call external editor for dictionary 687 ClassConfig::Class688 Class(): lastMainGroupId( 0 ), lastPopupGroupId( 0 ), 689 pinPopupWindow( false ), showingDictBarNames( false ), 690 usingSmallIconsInToolbars( false ), 691 maxPictureWidth( 0 ), maxHeadwordSize ( 256U ), 692 maxHeadwordsToExpand( 0 ) 693 {} 694 Group * getGroup( unsigned id ); 695 Group const * getGroup( unsigned id ) const; 696 }; 697 698 #ifdef Q_OS_WIN 699 #pragma pack(pop) 700 #endif 701 702 /// Configuration-specific events. Some parts of the program need to react 703 /// to specific changes in configuration. The object of this class is used 704 /// to emit signals when such events happen -- and the listeners connect to 705 /// them to be notified of them. 706 /// This class is separate from the main Class since QObjects can't be copied. 707 class Events: public QObject 708 { 709 Q_OBJECT 710 711 public: 712 713 /// Signals that the value of the mutedDictionaries has changed. 714 /// This emits mutedDictionariesChanged() signal, so the subscribers will 715 /// be notified. 716 void signalMutedDictionariesChanged(); 717 718 signals: 719 720 /// THe value of the mutedDictionaries has changed. 721 void mutedDictionariesChanged(); 722 723 private: 724 }; 725 726 DEF_EX( exError, "Error with the program's configuration", std::exception ) 727 DEF_EX( exCantUseHomeDir, "Can't use home directory to store GoldenDict preferences", exError ) 728 DEF_EX( exCantUseIndexDir, "Can't use index directory to store GoldenDict index files", exError ) 729 DEF_EX( exCantReadConfigFile, "Can't read the configuration file", exError ) 730 DEF_EX( exCantWriteConfigFile, "Can't write the configuration file", exError ) 731 DEF_EX( exMalformedConfigFile, "The configuration file is malformed", exError ) 732 733 /// Loads the configuration, or creates the default one if none is present 734 Class load() THROW_SPEC( exError ); 735 736 /// Saves the configuration 737 void save( Class const & ) THROW_SPEC( exError ); 738 739 /// Returns the configuration file name. 740 QString getConfigFileName(); 741 742 /// Returns the main configuration directory. 743 QString getConfigDir() THROW_SPEC( exError ); 744 745 /// Returns the index directory, where the indices are to be stored. 746 QString getIndexDir() THROW_SPEC( exError ); 747 748 /// Returns the filename of a .pid file which should store current pid of 749 /// the process. 750 QString getPidFileName() THROW_SPEC( exError ); 751 752 /// Returns the filename of a history file which stores search history. 753 QString getHistoryFileName() THROW_SPEC( exError ); 754 755 /// Returns the filename of a favorities file. 756 QString getFavoritiesFileName() THROW_SPEC( exError ); 757 758 /// Returns the user .css file name. 759 QString getUserCssFileName() THROW_SPEC( exError ); 760 761 /// Returns the user .css file name used for printing only. 762 QString getUserCssPrintFileName() THROW_SPEC( exError ); 763 764 /// Returns the user .css file name for the Qt interface customization. 765 QString getUserQtCssFileName() THROW_SPEC( exError ); 766 767 /// Returns the program's data dir. Under Linux that would be something like 768 /// /usr/share/apps/goldendict, under Windows C:/Program Files/GoldenDict. 769 QString getProgramDataDir() throw(); 770 771 /// Returns the directory storing program localizized files (.qm). 772 QString getLocDir() throw(); 773 774 /// Returns the directory storing program help files (.qch). 775 QString getHelpDir() throw(); 776 777 #ifdef MAKE_CHINESE_CONVERSION_SUPPORT 778 /// Returns the directory storing OpenCC configuration and dictionary files (.json and .ocd). 779 QString getOpenCCDir() throw(); 780 #endif 781 782 /// Returns true if the program is configured as a portable version. In that 783 /// mode, all the settings and indices are kept in the program's directory. 784 bool isPortableVersion() throw(); 785 786 /// Returns directory with dictionaries for portable version. It is content/ 787 /// in the application's directory. 788 QString getPortableVersionDictionaryDir() throw(); 789 790 /// Returns directory with morpgologies for portable version. It is 791 /// content/morphology in the application's directory. 792 QString getPortableVersionMorphoDir() throw(); 793 794 /// Returns the add-on styles directory. 795 QString getStylesDir() throw(); 796 797 /// Returns the directory where user-specific non-essential (cached) data should be written. 798 QString getCacheDir() throw(); 799 800 /// Returns the article network disk cache directory. 801 QString getNetworkCacheDir() throw(); 802 803 } 804 805 #endif 806 807