2012-02-20 21:47:14 +00:00
|
|
|
/* This file is (c) 2008-2012 Konstantin Isakov <ikm@goldendict.org>
|
2009-01-28 20:55:45 +00:00
|
|
|
* Part of GoldenDict. Licensed under GPLv3 or later, see the LICENSE file */
|
|
|
|
|
|
|
|
#ifndef __CONFIG_HH_INCLUDED__
|
|
|
|
#define __CONFIG_HH_INCLUDED__
|
|
|
|
|
2014-12-12 14:04:27 +00:00
|
|
|
#include <QObject>
|
2012-12-10 12:49:45 +00:00
|
|
|
#include <QList>
|
2009-01-28 20:55:45 +00:00
|
|
|
#include <QString>
|
2009-02-06 17:16:33 +00:00
|
|
|
#include <QSize>
|
2009-04-20 19:54:34 +00:00
|
|
|
#include <QDateTime>
|
2009-04-21 18:27:26 +00:00
|
|
|
#include <QKeySequence>
|
2009-09-21 17:50:03 +00:00
|
|
|
#include <QSet>
|
2021-06-10 16:13:11 +00:00
|
|
|
#include <QMetaType>
|
2009-01-28 20:55:45 +00:00
|
|
|
#include "ex.hh"
|
2023-07-16 10:54:07 +00:00
|
|
|
#include <QDomDocument>
|
2022-07-31 01:19:50 +00:00
|
|
|
#include <QLocale>
|
2023-06-04 00:02:39 +00:00
|
|
|
#include <optional>
|
2023-07-20 14:50:32 +00:00
|
|
|
#include <QThread>
|
2009-01-28 20:55:45 +00:00
|
|
|
|
2024-11-05 05:51:53 +00:00
|
|
|
/// Special group IDs
|
|
|
|
enum GroupId : unsigned {
|
|
|
|
AllGroupId = UINT_MAX - 1, /// The 'All' group
|
|
|
|
HelpGroupId = UINT_MAX, /// The fictitious 'Help' group
|
|
|
|
NoGroupId = 0, /// Invalid value, used to specify that no group id is specified at all.
|
|
|
|
};
|
|
|
|
|
2009-01-28 20:55:45 +00:00
|
|
|
/// GoldenDict's configuration
|
|
|
|
namespace Config {
|
|
|
|
|
2024-11-06 03:27:19 +00:00
|
|
|
// Tri states enum for Dark and Dark reader mode
|
|
|
|
enum class Dark : std::uint8_t {
|
|
|
|
Off = 0,
|
|
|
|
On = 1,
|
|
|
|
// TODO: Auto = 2,
|
|
|
|
};
|
|
|
|
|
2012-09-26 13:13:47 +00:00
|
|
|
/// Dictionaries which are temporarily disabled via the dictionary bar.
|
|
|
|
typedef QSet< QString > MutedDictionaries;
|
|
|
|
|
2009-04-04 16:06:06 +00:00
|
|
|
/// A path where to search for the dictionaries
|
2009-03-28 22:37:03 +00:00
|
|
|
struct Path
|
|
|
|
{
|
|
|
|
QString path;
|
|
|
|
bool recursive;
|
|
|
|
|
|
|
|
Path():
|
|
|
|
recursive( false )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
Path( QString const & path_, bool recursive_ ):
|
|
|
|
path( path_ ),
|
|
|
|
recursive( recursive_ )
|
|
|
|
{
|
|
|
|
}
|
2009-04-30 15:29:03 +00:00
|
|
|
|
|
|
|
bool operator==( Path const & other ) const
|
|
|
|
{
|
|
|
|
return path == other.path && recursive == other.recursive;
|
|
|
|
}
|
2009-03-28 22:37:03 +00:00
|
|
|
};
|
|
|
|
|
2009-01-28 20:55:45 +00:00
|
|
|
/// A list of paths where to search for the dictionaries
|
2012-12-10 12:49:45 +00:00
|
|
|
typedef QList< Path > Paths;
|
2009-01-28 20:55:45 +00:00
|
|
|
|
2009-04-04 16:06:06 +00:00
|
|
|
/// A directory holding bunches of audiofiles, which is indexed into a separate
|
|
|
|
/// dictionary.
|
|
|
|
struct SoundDir
|
|
|
|
{
|
|
|
|
QString path, name;
|
2013-02-02 18:25:24 +00:00
|
|
|
QString iconFilename;
|
2009-04-04 16:06:06 +00:00
|
|
|
|
|
|
|
SoundDir() {}
|
|
|
|
|
2013-02-02 22:00:19 +00:00
|
|
|
SoundDir( QString const & path_, QString const & name_, QString iconFilename_ = "" ):
|
2013-02-02 18:25:24 +00:00
|
|
|
path( path_ ),
|
|
|
|
name( name_ ),
|
|
|
|
iconFilename( iconFilename_ )
|
2009-04-04 16:06:06 +00:00
|
|
|
{
|
|
|
|
}
|
2009-04-30 15:29:03 +00:00
|
|
|
|
|
|
|
bool operator==( SoundDir const & other ) const
|
2013-02-02 18:25:24 +00:00
|
|
|
{
|
|
|
|
return path == other.path && name == other.name && iconFilename == other.iconFilename;
|
|
|
|
}
|
2009-04-04 16:06:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/// A list of SoundDirs
|
2012-12-10 12:49:45 +00:00
|
|
|
typedef QList< SoundDir > SoundDirs;
|
2009-04-04 16:06:06 +00:00
|
|
|
|
2009-04-01 12:00:28 +00:00
|
|
|
struct DictionaryRef
|
|
|
|
{
|
|
|
|
QString id; // Dictionrary id, which is usually an md5 hash
|
|
|
|
QString name; // Dictionary name, used to recover when its id changes
|
|
|
|
|
|
|
|
DictionaryRef() {}
|
|
|
|
|
|
|
|
DictionaryRef( QString const & id_, QString const & name_ ):
|
|
|
|
id( id_ ),
|
|
|
|
name( name_ )
|
|
|
|
{
|
|
|
|
}
|
2009-04-30 15:29:03 +00:00
|
|
|
|
|
|
|
bool operator==( DictionaryRef const & other ) const
|
|
|
|
{
|
|
|
|
return id == other.id && name == other.name;
|
|
|
|
}
|
2009-04-01 12:00:28 +00:00
|
|
|
};
|
|
|
|
|
2009-01-28 20:55:45 +00:00
|
|
|
/// A dictionary group
|
|
|
|
struct Group
|
|
|
|
{
|
2009-04-10 12:48:40 +00:00
|
|
|
unsigned id;
|
2009-01-28 20:55:45 +00:00
|
|
|
QString name, icon;
|
2010-07-05 18:36:03 +00:00
|
|
|
QByteArray iconData;
|
2010-07-05 14:13:29 +00:00
|
|
|
QKeySequence shortcut;
|
2017-05-05 14:39:51 +00:00
|
|
|
QString favoritesFolder;
|
2012-12-10 12:49:45 +00:00
|
|
|
QList< DictionaryRef > dictionaries;
|
2012-09-26 13:13:47 +00:00
|
|
|
Config::MutedDictionaries mutedDictionaries; // Disabled via dictionary bar
|
|
|
|
Config::MutedDictionaries popupMutedDictionaries; // Disabled via dictionary bar in popup
|
2009-04-10 12:48:40 +00:00
|
|
|
|
|
|
|
Group():
|
|
|
|
id( 0 )
|
|
|
|
{
|
|
|
|
}
|
2009-04-30 15:29:03 +00:00
|
|
|
|
|
|
|
bool operator==( Group const & other ) const
|
2009-05-01 11:52:10 +00:00
|
|
|
{
|
|
|
|
return id == other.id && name == other.name && icon == other.icon && favoritesFolder == other.favoritesFolder
|
2010-07-05 18:36:03 +00:00
|
|
|
&& dictionaries == other.dictionaries && shortcut == other.shortcut
|
2012-09-26 13:59:48 +00:00
|
|
|
&& mutedDictionaries == other.mutedDictionaries && popupMutedDictionaries == other.popupMutedDictionaries
|
2012-10-31 13:58:35 +00:00
|
|
|
&& iconData == other.iconData;
|
|
|
|
}
|
2009-05-18 18:01:50 +00:00
|
|
|
|
|
|
|
bool operator!=( Group const & other ) const
|
|
|
|
{
|
|
|
|
return !operator==( other );
|
|
|
|
}
|
2009-01-28 20:55:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/// All the groups
|
2012-12-10 12:49:45 +00:00
|
|
|
struct Groups: public QList< Group >
|
2009-04-10 12:48:40 +00:00
|
|
|
{
|
|
|
|
unsigned nextId; // Id to use to create the group next time
|
|
|
|
|
|
|
|
Groups():
|
|
|
|
nextId( 1 )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
};
|
2009-01-28 20:55:45 +00:00
|
|
|
|
2009-04-03 17:10:27 +00:00
|
|
|
/// Proxy server configuration
|
|
|
|
struct ProxyServer
|
|
|
|
{
|
|
|
|
bool enabled;
|
2014-04-01 17:00:13 +00:00
|
|
|
bool useSystemProxy;
|
2009-04-03 17:10:27 +00:00
|
|
|
|
|
|
|
enum Type {
|
|
|
|
Socks5 = 0,
|
|
|
|
HttpConnect,
|
|
|
|
HttpGet
|
|
|
|
} type;
|
|
|
|
|
|
|
|
QString host;
|
|
|
|
unsigned port;
|
|
|
|
QString user, password;
|
2014-04-03 14:21:02 +00:00
|
|
|
QString systemProxyUser, systemProxyPassword;
|
2009-04-03 17:10:27 +00:00
|
|
|
|
|
|
|
ProxyServer();
|
|
|
|
};
|
|
|
|
|
2022-05-21 02:30:32 +00:00
|
|
|
struct AnkiConnectServer
|
|
|
|
{
|
|
|
|
bool enabled;
|
|
|
|
|
|
|
|
QString host;
|
2023-03-22 20:34:05 +00:00
|
|
|
int port; // Port will be passed to QUrl::setPort() which expects an int.
|
|
|
|
|
2022-05-21 06:03:26 +00:00
|
|
|
QString deck;
|
|
|
|
QString model;
|
2022-05-21 02:30:32 +00:00
|
|
|
|
2023-03-16 11:55:47 +00:00
|
|
|
QString word;
|
|
|
|
QString text;
|
|
|
|
QString sentence;
|
|
|
|
|
2022-05-21 02:30:32 +00:00
|
|
|
AnkiConnectServer();
|
|
|
|
};
|
|
|
|
|
2009-04-21 18:27:26 +00:00
|
|
|
// A hotkey -- currently qt modifiers plus one or two keys
|
|
|
|
struct HotKey
|
|
|
|
{
|
|
|
|
Qt::KeyboardModifiers modifiers;
|
|
|
|
int key1, key2;
|
|
|
|
|
|
|
|
HotKey();
|
|
|
|
|
2022-12-29 12:10:21 +00:00
|
|
|
/// Hotkey's constructor, take a QKeySequence's first two keys
|
|
|
|
/// 1st key's modifier will be the `modifiers` above
|
|
|
|
/// 1st key without modifier will becomes `key1`
|
|
|
|
/// 2nd key without modifier will becomes `key2`
|
|
|
|
/// The relation between the int and qt's KeyCode should consult qt's doc
|
|
|
|
|
2009-04-21 18:27:26 +00:00
|
|
|
HotKey( QKeySequence const & );
|
|
|
|
|
|
|
|
QKeySequence toKeySequence() const;
|
|
|
|
};
|
|
|
|
|
2014-04-17 14:31:51 +00:00
|
|
|
struct FullTextSearch
|
|
|
|
{
|
|
|
|
int searchMode;
|
|
|
|
bool enabled;
|
2023-05-17 14:29:56 +00:00
|
|
|
|
2014-04-17 14:31:51 +00:00
|
|
|
quint32 maxDictionarySize;
|
2023-07-20 14:50:32 +00:00
|
|
|
quint32 parallelThreads = QThread::idealThreadCount() / 3 + 1;
|
2014-04-17 14:31:51 +00:00
|
|
|
QByteArray dialogGeometry;
|
|
|
|
QString disabledTypes;
|
|
|
|
|
2023-05-17 14:29:56 +00:00
|
|
|
FullTextSearch():
|
|
|
|
searchMode( 0 ),
|
2014-04-17 14:31:51 +00:00
|
|
|
enabled( true ),
|
|
|
|
maxDictionarySize( 0 )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2023-07-16 10:54:07 +00:00
|
|
|
struct CustomFonts
|
|
|
|
{
|
|
|
|
QString standard;
|
|
|
|
QString serif;
|
|
|
|
QString sansSerif;
|
|
|
|
QString monospace;
|
|
|
|
|
|
|
|
bool operator==( CustomFonts const & other ) const
|
|
|
|
{
|
|
|
|
return standard == other.standard && serif == other.serif && sansSerif == other.sansSerif
|
|
|
|
&& monospace == other.monospace;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator!=( CustomFonts const & other ) const
|
|
|
|
{
|
|
|
|
return !operator==( other );
|
|
|
|
}
|
|
|
|
|
|
|
|
QDomElement toElement( QDomDocument dd ) const
|
|
|
|
{
|
|
|
|
QDomElement proxy = dd.createElement( "customFonts" );
|
|
|
|
|
|
|
|
QDomAttr standard_attr = dd.createAttribute( "standard" );
|
|
|
|
standard_attr.setValue( this->standard );
|
|
|
|
proxy.setAttributeNode( standard_attr );
|
|
|
|
|
|
|
|
QDomAttr serif_attr = dd.createAttribute( "serif" );
|
|
|
|
serif_attr.setValue( this->serif );
|
|
|
|
proxy.setAttributeNode( serif_attr );
|
|
|
|
|
|
|
|
QDomAttr sans_attr = dd.createAttribute( "sans-serif" );
|
|
|
|
sans_attr.setValue( this->sansSerif );
|
|
|
|
proxy.setAttributeNode( sans_attr );
|
|
|
|
QDomAttr mono_attr = dd.createAttribute( "monospace" );
|
|
|
|
mono_attr.setValue( this->monospace );
|
|
|
|
proxy.setAttributeNode( mono_attr );
|
|
|
|
return proxy;
|
|
|
|
}
|
|
|
|
|
|
|
|
static CustomFonts fromElement( QDomElement proxy )
|
|
|
|
{
|
|
|
|
CustomFonts c;
|
|
|
|
c.standard = proxy.attribute( "standard" );
|
|
|
|
c.serif = proxy.attribute( "serif" );
|
|
|
|
c.sansSerif = proxy.attribute( "sans-serif" );
|
|
|
|
c.monospace = proxy.attribute( "monospace" );
|
|
|
|
return c;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2018-03-29 17:00:53 +00:00
|
|
|
/// This class encapsulates supported backend preprocessor logic,
|
|
|
|
/// discourages duplicating backend names in code, which is error-prone.
|
|
|
|
class InternalPlayerBackend
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/// Returns true if at least one backend is available.
|
|
|
|
static bool anyAvailable();
|
|
|
|
/// Returns the default backend or null backend if none is available.
|
|
|
|
static InternalPlayerBackend defaultBackend();
|
|
|
|
/// Returns the name list of supported backends.
|
|
|
|
static QStringList nameList();
|
|
|
|
|
|
|
|
/// Returns true if built with FFmpeg player support and the name matches.
|
|
|
|
bool isFfmpeg() const;
|
|
|
|
/// Returns true if built with Qt Multimedia player support and the name matches.
|
|
|
|
bool isQtmultimedia() const;
|
|
|
|
|
|
|
|
QString const & uiName() const
|
|
|
|
{
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
|
|
|
void setUiName( QString const & name_ )
|
|
|
|
{
|
|
|
|
name = name_;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator==( InternalPlayerBackend const & other ) const
|
|
|
|
{
|
|
|
|
return name == other.name;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator!=( InternalPlayerBackend const & other ) const
|
|
|
|
{
|
|
|
|
return !operator==( other );
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
#ifdef MAKE_FFMPEG_PLAYER
|
|
|
|
static InternalPlayerBackend ffmpeg()
|
2022-11-05 05:44:10 +00:00
|
|
|
{
|
|
|
|
return InternalPlayerBackend( "FFmpeg" );
|
|
|
|
}
|
2018-03-29 17:00:53 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef MAKE_QTMULTIMEDIA_PLAYER
|
|
|
|
static InternalPlayerBackend qtmultimedia()
|
|
|
|
{
|
|
|
|
return InternalPlayerBackend( "Qt Multimedia" );
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
explicit InternalPlayerBackend( QString const & name_ ):
|
|
|
|
name( name_ )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
QString name;
|
|
|
|
};
|
|
|
|
|
2009-02-05 20:55:00 +00:00
|
|
|
/// Various user preferences
|
|
|
|
struct Preferences
|
|
|
|
{
|
2009-04-12 20:46:25 +00:00
|
|
|
QString interfaceLanguage; // Empty value corresponds to system default
|
2023-09-07 01:53:51 +00:00
|
|
|
QString interfaceFont; //Empty as default value.
|
2023-07-20 12:10:44 +00:00
|
|
|
|
2023-07-16 10:54:07 +00:00
|
|
|
CustomFonts customFonts;
|
2009-04-13 12:51:25 +00:00
|
|
|
bool newTabsOpenAfterCurrentOne;
|
|
|
|
bool newTabsOpenInBackground;
|
2011-06-23 14:17:09 +00:00
|
|
|
bool hideSingleTab;
|
2011-11-02 23:37:50 +00:00
|
|
|
bool mruTabOrder;
|
2011-06-26 11:53:28 +00:00
|
|
|
bool hideMenubar;
|
2009-02-05 20:55:00 +00:00
|
|
|
bool enableTrayIcon;
|
|
|
|
bool startToTray;
|
|
|
|
bool closeToTray;
|
2009-04-18 18:16:04 +00:00
|
|
|
bool autoStart;
|
2010-04-08 20:37:59 +00:00
|
|
|
bool doubleClickTranslates;
|
2012-09-26 13:59:48 +00:00
|
|
|
bool selectWordBySingleClick;
|
2019-01-11 13:50:40 +00:00
|
|
|
bool autoScrollToTargetArticle;
|
2011-05-07 13:42:49 +00:00
|
|
|
bool escKeyHidesMainWindow;
|
2012-12-29 11:19:49 +00:00
|
|
|
bool alwaysOnTop;
|
2009-04-21 18:27:26 +00:00
|
|
|
|
2013-01-05 11:26:55 +00:00
|
|
|
/// An old UI mode when tranlateLine and wordList
|
|
|
|
/// are in the dockable side panel, not on the toolbar.
|
|
|
|
bool searchInDock;
|
|
|
|
|
2009-04-21 18:27:26 +00:00
|
|
|
bool enableMainWindowHotkey;
|
|
|
|
bool enableClipboardHotkey;
|
2023-05-31 03:15:30 +00:00
|
|
|
|
|
|
|
QKeySequence mainWindowHotkey;
|
2022-12-29 17:11:22 +00:00
|
|
|
QKeySequence clipboardHotkey;
|
2009-04-21 18:27:26 +00:00
|
|
|
|
2009-02-08 20:20:02 +00:00
|
|
|
bool startWithScanPopupOn;
|
2009-02-05 20:55:00 +00:00
|
|
|
bool enableScanPopupModifiers;
|
|
|
|
unsigned long scanPopupModifiers; // Combination of KeyboardState::Modifier
|
2018-04-16 12:23:22 +00:00
|
|
|
bool ignoreOwnClipboardChanges;
|
2022-09-25 04:49:22 +00:00
|
|
|
|
2011-11-16 12:52:25 +00:00
|
|
|
bool scanToMainWindow;
|
2018-06-13 16:00:42 +00:00
|
|
|
bool ignoreDiacritics;
|
2022-04-23 08:15:23 +00:00
|
|
|
bool ignorePunctuation;
|
2023-04-15 02:48:12 +00:00
|
|
|
bool sessionCollapse = false;
|
2017-06-05 13:15:38 +00:00
|
|
|
#ifdef HAVE_X11
|
2022-11-19 16:35:25 +00:00
|
|
|
bool trackClipboardScan;
|
|
|
|
bool trackSelectionScan;
|
2017-06-05 13:15:38 +00:00
|
|
|
bool showScanFlag;
|
2023-06-05 11:30:14 +00:00
|
|
|
int selectionChangeDelayTimer;
|
2017-06-05 13:15:38 +00:00
|
|
|
#endif
|
2009-02-05 20:55:00 +00:00
|
|
|
|
2009-04-10 21:07:03 +00:00
|
|
|
// Whether the word should be pronounced on page load, in main window/popup
|
|
|
|
bool pronounceOnLoadMain, pronounceOnLoadPopup;
|
2013-05-05 10:22:12 +00:00
|
|
|
bool useInternalPlayer;
|
2018-03-29 17:00:53 +00:00
|
|
|
InternalPlayerBackend internalPlayerBackend;
|
|
|
|
QString audioPlaybackProgram;
|
2009-04-10 21:07:03 +00:00
|
|
|
|
2009-04-03 17:10:27 +00:00
|
|
|
ProxyServer proxyServer;
|
2022-05-21 02:30:32 +00:00
|
|
|
AnkiConnectServer ankiConnectServer;
|
2009-04-03 17:10:27 +00:00
|
|
|
|
2009-04-20 19:54:34 +00:00
|
|
|
bool checkForNewReleases;
|
2009-08-31 12:18:08 +00:00
|
|
|
bool disallowContentFromOtherSites;
|
2013-04-08 12:20:12 +00:00
|
|
|
bool hideGoldenDictHeader;
|
2020-11-12 15:57:10 +00:00
|
|
|
int maxNetworkCacheSize;
|
|
|
|
bool clearNetworkCacheOnExit;
|
2023-08-17 15:17:53 +00:00
|
|
|
bool removeInvalidIndexOnExit = false;
|
2009-04-20 19:54:34 +00:00
|
|
|
|
2009-04-30 19:57:25 +00:00
|
|
|
qreal zoomFactor;
|
2014-06-23 15:11:15 +00:00
|
|
|
qreal helpZoomFactor;
|
2010-07-02 11:19:02 +00:00
|
|
|
int wordsZoomLevel;
|
2009-04-30 19:57:25 +00:00
|
|
|
|
2012-02-16 14:56:25 +00:00
|
|
|
unsigned maxStringsInHistory;
|
2012-09-11 13:03:10 +00:00
|
|
|
unsigned storeHistory;
|
2012-09-16 10:19:47 +00:00
|
|
|
bool alwaysExpandOptionalParts;
|
2012-02-16 14:56:25 +00:00
|
|
|
|
2024-10-10 04:20:02 +00:00
|
|
|
unsigned historyStoreInterval = 15; // unit is minutes
|
|
|
|
unsigned favoritesStoreInterval = 15;
|
2013-02-05 12:51:23 +00:00
|
|
|
|
2017-05-17 15:26:32 +00:00
|
|
|
bool confirmFavoritesDeletion;
|
|
|
|
|
2013-06-02 11:20:33 +00:00
|
|
|
bool collapseBigArticles;
|
|
|
|
int articleSizeLimit;
|
|
|
|
|
2020-11-06 19:51:30 +00:00
|
|
|
bool limitInputPhraseLength;
|
|
|
|
int inputPhraseLengthLimit;
|
2023-05-28 16:01:54 +00:00
|
|
|
QString sanitizeInputPhrase( QString const & inputWord ) const;
|
2020-11-06 19:51:30 +00:00
|
|
|
|
2013-06-11 18:31:01 +00:00
|
|
|
unsigned short maxDictionaryRefsInContextMenu;
|
|
|
|
|
2017-03-09 16:11:17 +00:00
|
|
|
bool synonymSearchEnabled;
|
2022-12-13 13:42:53 +00:00
|
|
|
bool stripClipboard;
|
2023-03-17 01:54:45 +00:00
|
|
|
bool raiseWindowOnSearch;
|
2017-03-09 16:11:17 +00:00
|
|
|
|
2023-07-20 12:10:44 +00:00
|
|
|
FullTextSearch fts;
|
|
|
|
|
|
|
|
// Appearances
|
|
|
|
|
2024-11-06 03:27:19 +00:00
|
|
|
Dark darkMode = Dark::Off;
|
|
|
|
Dark darkReaderMode = Dark::Off;
|
2012-12-10 14:14:13 +00:00
|
|
|
QString addonStyle;
|
2023-07-20 12:10:44 +00:00
|
|
|
QString displayStyle; // Article Display style (Which also affect interface style on windows)
|
2012-12-10 14:14:13 +00:00
|
|
|
|
2023-07-20 12:10:44 +00:00
|
|
|
#if !defined( Q_OS_WIN )
|
|
|
|
// QApplication style https://doc.qt.io/qt-6/qapplication.html#setStyle
|
|
|
|
// In addition to Qt's styles, "Default" is added as default.
|
|
|
|
QString interfaceStyle;
|
|
|
|
#endif
|
2014-04-17 14:31:51 +00:00
|
|
|
|
2009-02-05 20:55:00 +00:00
|
|
|
Preferences();
|
|
|
|
};
|
|
|
|
|
2009-03-26 19:00:08 +00:00
|
|
|
/// A MediaWiki network dictionary definition
|
|
|
|
struct MediaWiki
|
|
|
|
{
|
2012-11-17 17:03:58 +00:00
|
|
|
QString id, name, url;
|
2009-03-26 19:00:08 +00:00
|
|
|
bool enabled;
|
2012-11-17 17:03:58 +00:00
|
|
|
QString icon;
|
2024-01-25 23:56:17 +00:00
|
|
|
QString lang;
|
2009-03-26 19:00:08 +00:00
|
|
|
|
|
|
|
MediaWiki():
|
|
|
|
enabled( false )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2024-01-25 23:56:17 +00:00
|
|
|
MediaWiki( QString const & id_,
|
|
|
|
QString const & name_,
|
|
|
|
QString const & url_,
|
|
|
|
bool enabled_,
|
|
|
|
QString const & icon_,
|
|
|
|
QString const & lang_ = "" ):
|
2012-06-21 09:43:28 +00:00
|
|
|
id( id_ ),
|
|
|
|
name( name_ ),
|
|
|
|
url( url_ ),
|
|
|
|
enabled( enabled_ ),
|
2024-01-25 23:56:17 +00:00
|
|
|
icon( icon_ ),
|
|
|
|
lang( lang_ )
|
2012-06-21 09:43:28 +00:00
|
|
|
{
|
|
|
|
}
|
2009-04-30 15:29:03 +00:00
|
|
|
|
|
|
|
bool operator==( MediaWiki const & other ) const
|
|
|
|
{
|
2024-01-25 23:56:17 +00:00
|
|
|
return id == other.id && name == other.name && url == other.url && enabled == other.enabled && icon == other.icon
|
|
|
|
&& lang == other.lang;
|
2012-06-21 09:43:28 +00:00
|
|
|
}
|
2009-03-26 19:00:08 +00:00
|
|
|
};
|
|
|
|
|
2009-05-16 18:04:21 +00:00
|
|
|
/// Any website which can be queried though a simple template substitution
|
|
|
|
struct WebSite
|
|
|
|
{
|
|
|
|
QString id, name, url;
|
|
|
|
bool enabled;
|
2012-12-03 12:48:31 +00:00
|
|
|
QString iconFilename;
|
2016-06-17 14:27:48 +00:00
|
|
|
bool inside_iframe;
|
2009-05-16 18:04:21 +00:00
|
|
|
|
|
|
|
WebSite():
|
|
|
|
enabled( false )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
WebSite( QString const & id_,
|
|
|
|
QString const & name_,
|
|
|
|
QString const & url_,
|
2016-06-17 14:27:48 +00:00
|
|
|
bool enabled_,
|
|
|
|
QString const & iconFilename_,
|
|
|
|
bool inside_iframe_ ):
|
|
|
|
id( id_ ),
|
|
|
|
name( name_ ),
|
|
|
|
url( url_ ),
|
|
|
|
enabled( enabled_ ),
|
|
|
|
iconFilename( iconFilename_ ),
|
|
|
|
inside_iframe( inside_iframe_ )
|
|
|
|
{
|
|
|
|
}
|
2009-05-16 18:04:21 +00:00
|
|
|
|
|
|
|
bool operator==( WebSite const & other ) const
|
|
|
|
{
|
|
|
|
return id == other.id && name == other.name && url == other.url && enabled == other.enabled
|
2016-06-17 14:27:48 +00:00
|
|
|
&& iconFilename == other.iconFilename && inside_iframe == other.inside_iframe;
|
|
|
|
}
|
2009-05-16 18:04:21 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/// All the WebSites
|
2012-12-10 12:49:45 +00:00
|
|
|
typedef QList< WebSite > WebSites;
|
2009-05-16 18:04:21 +00:00
|
|
|
|
2014-04-30 12:55:53 +00:00
|
|
|
/// Any DICT server
|
|
|
|
struct DictServer
|
|
|
|
{
|
|
|
|
QString id, name, url;
|
|
|
|
bool enabled;
|
|
|
|
QString databases;
|
2014-05-03 17:41:16 +00:00
|
|
|
QString strategies;
|
2014-04-30 12:55:53 +00:00
|
|
|
QString iconFilename;
|
|
|
|
|
|
|
|
DictServer():
|
|
|
|
enabled( false )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
DictServer( QString const & id_,
|
|
|
|
QString const & name_,
|
|
|
|
QString const & url_,
|
2014-05-03 17:41:16 +00:00
|
|
|
bool enabled_,
|
|
|
|
QString const & databases_,
|
|
|
|
QString const & strategies_,
|
|
|
|
QString const & iconFilename_ ):
|
2014-04-30 12:55:53 +00:00
|
|
|
id( id_ ),
|
|
|
|
name( name_ ),
|
|
|
|
url( url_ ),
|
|
|
|
enabled( enabled_ ),
|
|
|
|
databases( databases_ ),
|
2014-05-03 17:41:16 +00:00
|
|
|
strategies( strategies_ ),
|
|
|
|
iconFilename( iconFilename_ )
|
|
|
|
{
|
|
|
|
}
|
2023-07-20 08:02:22 +00:00
|
|
|
|
2014-04-30 12:55:53 +00:00
|
|
|
bool operator==( DictServer const & other ) const
|
|
|
|
{
|
|
|
|
return id == other.id && name == other.name && url == other.url && enabled == other.enabled
|
|
|
|
&& databases == other.databases && strategies == other.strategies && iconFilename == other.iconFilename;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/// All the DictServers
|
|
|
|
typedef QList< DictServer > DictServers;
|
|
|
|
|
2009-04-09 14:15:01 +00:00
|
|
|
/// Hunspell configuration
|
|
|
|
struct Hunspell
|
|
|
|
{
|
|
|
|
QString dictionariesPath;
|
|
|
|
|
2012-12-10 12:49:45 +00:00
|
|
|
typedef QList< QString > Dictionaries;
|
2009-04-09 14:15:01 +00:00
|
|
|
|
|
|
|
Dictionaries enabledDictionaries;
|
2009-04-30 15:29:03 +00:00
|
|
|
|
|
|
|
bool operator==( Hunspell const & other ) const
|
|
|
|
{
|
|
|
|
return dictionariesPath == other.dictionariesPath && enabledDictionaries == other.enabledDictionaries;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator!=( Hunspell const & other ) const
|
|
|
|
{
|
|
|
|
return !operator==( other );
|
|
|
|
}
|
2009-04-09 14:15:01 +00:00
|
|
|
};
|
|
|
|
|
2009-03-26 19:00:08 +00:00
|
|
|
/// All the MediaWikis
|
2012-12-10 12:49:45 +00:00
|
|
|
typedef QList< MediaWiki > MediaWikis;
|
2009-03-26 19:00:08 +00:00
|
|
|
|
2022-01-29 01:27:32 +00:00
|
|
|
|
2015-10-19 13:52:23 +00:00
|
|
|
/// Chinese transliteration configuration
|
|
|
|
struct Chinese
|
|
|
|
{
|
|
|
|
bool enable;
|
|
|
|
|
2015-10-20 03:37:50 +00:00
|
|
|
bool enableSCToTWConversion;
|
|
|
|
bool enableSCToHKConversion;
|
|
|
|
bool enableTCToSCConversion;
|
2015-10-19 13:52:23 +00:00
|
|
|
|
|
|
|
Chinese();
|
|
|
|
|
|
|
|
bool operator==( Chinese const & other ) const
|
|
|
|
{
|
2015-10-20 03:37:50 +00:00
|
|
|
return enable == other.enable && enableSCToTWConversion == other.enableSCToTWConversion
|
|
|
|
&& enableSCToHKConversion == other.enableSCToHKConversion
|
|
|
|
&& enableTCToSCConversion == other.enableTCToSCConversion;
|
2015-10-19 13:52:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool operator!=( Chinese const & other ) const
|
2023-07-20 08:02:22 +00:00
|
|
|
{
|
2023-05-13 11:56:09 +00:00
|
|
|
return !operator==( other );
|
2023-07-20 08:02:22 +00:00
|
|
|
}
|
2015-10-19 13:52:23 +00:00
|
|
|
};
|
2022-01-29 01:27:32 +00:00
|
|
|
|
2015-10-19 13:52:23 +00:00
|
|
|
|
2023-05-13 11:56:09 +00:00
|
|
|
struct CustomTrans
|
|
|
|
{
|
|
|
|
bool enable = false;
|
|
|
|
|
|
|
|
QString context;
|
|
|
|
|
|
|
|
bool operator==( CustomTrans const & other ) const
|
|
|
|
{
|
|
|
|
return enable == other.enable && context == other.context;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator!=( CustomTrans const & other ) const
|
|
|
|
{
|
|
|
|
return !operator==( other );
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2009-05-06 14:39:08 +00:00
|
|
|
/// Romaji transliteration configuration
|
|
|
|
struct Romaji
|
|
|
|
{
|
|
|
|
bool enable;
|
|
|
|
|
|
|
|
bool enableHepburn;
|
|
|
|
bool enableNihonShiki;
|
|
|
|
bool enableKunreiShiki;
|
|
|
|
bool enableHiragana;
|
|
|
|
bool enableKatakana;
|
|
|
|
|
|
|
|
Romaji();
|
|
|
|
|
|
|
|
bool operator==( Romaji const & other ) const
|
|
|
|
{
|
|
|
|
return enable == other.enable && enableHepburn == other.enableHepburn && enableNihonShiki == other.enableNihonShiki
|
|
|
|
&& enableKunreiShiki == other.enableKunreiShiki && enableHiragana == other.enableHiragana
|
|
|
|
&& enableKatakana == other.enableKatakana;
|
|
|
|
}
|
2009-05-11 23:37:18 +00:00
|
|
|
|
2009-05-06 14:39:08 +00:00
|
|
|
bool operator!=( Romaji const & other ) const
|
2023-07-20 08:02:22 +00:00
|
|
|
{
|
2023-05-13 11:56:09 +00:00
|
|
|
return !operator==( other );
|
2023-07-20 08:02:22 +00:00
|
|
|
}
|
2009-05-06 14:39:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct Transliteration
|
|
|
|
{
|
|
|
|
bool enableRussianTransliteration;
|
2009-05-11 23:37:18 +00:00
|
|
|
bool enableGermanTransliteration;
|
2010-05-29 09:22:08 +00:00
|
|
|
bool enableGreekTransliteration;
|
2013-01-18 19:21:56 +00:00
|
|
|
bool enableBelarusianTransliteration;
|
2023-05-13 11:56:09 +00:00
|
|
|
|
|
|
|
CustomTrans customTrans;
|
2015-10-25 13:54:38 +00:00
|
|
|
#ifdef MAKE_CHINESE_CONVERSION_SUPPORT
|
2015-10-19 13:52:23 +00:00
|
|
|
Chinese chinese;
|
2015-10-25 13:54:38 +00:00
|
|
|
#endif
|
2009-05-06 14:39:08 +00:00
|
|
|
Romaji romaji;
|
|
|
|
|
2023-05-13 11:56:09 +00:00
|
|
|
bool operator==( Transliteration const & other ) const
|
|
|
|
{
|
|
|
|
return enableRussianTransliteration == other.enableRussianTransliteration
|
|
|
|
&& enableGermanTransliteration == other.enableGermanTransliteration
|
|
|
|
&& enableGreekTransliteration == other.enableGreekTransliteration
|
|
|
|
&& enableBelarusianTransliteration == other.enableBelarusianTransliteration && customTrans == other.customTrans &&
|
2015-10-25 13:54:38 +00:00
|
|
|
#ifdef MAKE_CHINESE_CONVERSION_SUPPORT
|
2023-05-13 11:56:09 +00:00
|
|
|
chinese == other.chinese &&
|
2015-10-25 13:54:38 +00:00
|
|
|
#endif
|
2023-05-13 11:56:09 +00:00
|
|
|
romaji == other.romaji;
|
2009-05-11 23:37:18 +00:00
|
|
|
}
|
2009-05-06 14:39:08 +00:00
|
|
|
|
|
|
|
bool operator!=( Transliteration const & other ) const
|
|
|
|
{
|
|
|
|
return !operator==( other );
|
|
|
|
}
|
|
|
|
|
2009-05-11 23:37:18 +00:00
|
|
|
Transliteration():
|
|
|
|
enableRussianTransliteration( false ),
|
2010-05-29 09:22:08 +00:00
|
|
|
enableGermanTransliteration( false ),
|
2013-01-18 19:21:56 +00:00
|
|
|
enableGreekTransliteration( false ),
|
|
|
|
enableBelarusianTransliteration( false )
|
2009-05-06 14:39:08 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2022-12-24 14:42:40 +00:00
|
|
|
struct Lingua
|
|
|
|
{
|
|
|
|
bool enable;
|
|
|
|
QString languageCodes;
|
|
|
|
|
|
|
|
bool operator==( Lingua const & other ) const
|
|
|
|
{
|
|
|
|
return enable == other.enable && languageCodes == other.languageCodes;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator!=( Lingua const & other ) const
|
|
|
|
{
|
|
|
|
return !operator==( other );
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2010-06-12 20:16:35 +00:00
|
|
|
struct Forvo
|
|
|
|
{
|
|
|
|
bool enable;
|
|
|
|
QString apiKey;
|
|
|
|
QString languageCodes;
|
|
|
|
|
|
|
|
Forvo():
|
|
|
|
enable( false )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator==( Forvo const & other ) const
|
|
|
|
{
|
|
|
|
return enable == other.enable && apiKey == other.apiKey && languageCodes == other.languageCodes;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator!=( Forvo const & other ) const
|
|
|
|
{
|
|
|
|
return !operator==( other );
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2011-05-29 05:08:37 +00:00
|
|
|
struct Program
|
|
|
|
{
|
|
|
|
bool enabled;
|
|
|
|
enum Type {
|
|
|
|
Audio,
|
|
|
|
PlainText,
|
|
|
|
Html,
|
2011-06-04 21:35:09 +00:00
|
|
|
PrefixMatch,
|
2011-05-29 05:08:37 +00:00
|
|
|
MaxTypeValue
|
|
|
|
} type;
|
|
|
|
QString id, name, commandLine;
|
2012-12-07 11:59:59 +00:00
|
|
|
QString iconFilename;
|
2011-05-29 05:08:37 +00:00
|
|
|
|
|
|
|
Program():
|
|
|
|
enabled( false )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
Program( bool enabled_,
|
|
|
|
Type type_,
|
|
|
|
QString const & id_,
|
2012-12-09 17:29:27 +00:00
|
|
|
QString const & name_,
|
|
|
|
QString const & commandLine_,
|
|
|
|
QString const & iconFilename_ ):
|
2011-05-29 05:08:37 +00:00
|
|
|
enabled( enabled_ ),
|
|
|
|
type( type_ ),
|
|
|
|
id( id_ ),
|
|
|
|
name( name_ ),
|
2012-12-07 11:59:59 +00:00
|
|
|
commandLine( commandLine_ ),
|
|
|
|
iconFilename( iconFilename_ )
|
|
|
|
{
|
|
|
|
}
|
2011-05-29 05:08:37 +00:00
|
|
|
|
|
|
|
bool operator==( Program const & other ) const
|
|
|
|
{
|
2012-12-07 11:59:59 +00:00
|
|
|
return enabled == other.enabled && type == other.type && name == other.name && commandLine == other.commandLine
|
|
|
|
&& iconFilename == other.iconFilename;
|
2011-05-29 05:08:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool operator!=( Program const & other ) const
|
|
|
|
{
|
|
|
|
return !operator==( other );
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2012-12-10 12:49:45 +00:00
|
|
|
typedef QList< Program > Programs;
|
2011-05-29 05:08:37 +00:00
|
|
|
|
2024-03-20 03:08:17 +00:00
|
|
|
#ifndef NO_TTS_SUPPORT
|
2013-04-24 14:52:04 +00:00
|
|
|
struct VoiceEngine
|
|
|
|
{
|
2013-04-26 13:41:39 +00:00
|
|
|
bool enabled;
|
2022-07-31 01:19:50 +00:00
|
|
|
//engine name.
|
|
|
|
QString engine_name;
|
2013-04-26 13:41:39 +00:00
|
|
|
QString name;
|
2022-07-31 01:19:50 +00:00
|
|
|
//voice name.
|
|
|
|
QString voice_name;
|
2013-04-24 14:52:04 +00:00
|
|
|
QString iconFilename;
|
2022-07-31 01:19:50 +00:00
|
|
|
QLocale locale;
|
|
|
|
int volume; // 0~1 allowed
|
|
|
|
int rate; // -1 ~ 1 allowed
|
|
|
|
|
|
|
|
VoiceEngine():
|
|
|
|
enabled( false ),
|
|
|
|
volume( 50 ),
|
|
|
|
rate( 0 )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
VoiceEngine( QString engine_nane_, QString name_, QString voice_name_, QLocale locale_, int volume_, int rate_ ):
|
|
|
|
enabled( false ),
|
|
|
|
engine_name( engine_nane_ ),
|
|
|
|
name( name_ ),
|
|
|
|
voice_name( voice_name_ ),
|
|
|
|
locale( locale_ ),
|
|
|
|
volume( volume_ ),
|
|
|
|
rate( rate_ )
|
2013-04-26 13:41:39 +00:00
|
|
|
{
|
|
|
|
}
|
2013-04-24 14:52:04 +00:00
|
|
|
|
2013-04-26 13:41:39 +00:00
|
|
|
bool operator==( VoiceEngine const & other ) const
|
|
|
|
{
|
2022-07-31 01:19:50 +00:00
|
|
|
return enabled == other.enabled && engine_name == other.engine_name && name == other.name
|
|
|
|
&& voice_name == other.voice_name && locale == other.locale && iconFilename == other.iconFilename
|
|
|
|
&& volume == other.volume && rate == other.rate;
|
2013-04-26 13:41:39 +00:00
|
|
|
}
|
2013-04-24 14:52:04 +00:00
|
|
|
|
2013-04-26 13:41:39 +00:00
|
|
|
bool operator!=( VoiceEngine const & other ) const
|
|
|
|
{
|
|
|
|
return !operator==( other );
|
|
|
|
}
|
2013-04-24 14:52:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef QList< VoiceEngine > VoiceEngines;
|
2024-03-20 03:08:17 +00:00
|
|
|
#endif
|
2013-04-24 14:52:04 +00:00
|
|
|
|
2014-02-28 12:36:28 +00:00
|
|
|
struct HeadwordsDialog
|
|
|
|
{
|
|
|
|
int searchMode;
|
|
|
|
bool matchCase;
|
|
|
|
bool autoApply;
|
|
|
|
QString headwordsExportPath;
|
|
|
|
QByteArray headwordsDialogGeometry;
|
|
|
|
|
|
|
|
HeadwordsDialog():
|
|
|
|
searchMode( 0 ),
|
|
|
|
matchCase( false ),
|
|
|
|
autoApply( false )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2024-09-30 04:36:27 +00:00
|
|
|
// TODO: arbitrary sizing
|
|
|
|
enum class ToolbarsIconSize : std::uint8_t {
|
|
|
|
Small = 0,
|
|
|
|
Normal = 1,
|
|
|
|
Large = 2,
|
|
|
|
};
|
|
|
|
|
2024-11-01 02:52:45 +00:00
|
|
|
struct GroupBackup
|
|
|
|
{
|
|
|
|
Group dictionaryOrder;
|
|
|
|
Group inactiveDictionaries;
|
|
|
|
Groups groups;
|
|
|
|
};
|
|
|
|
|
2009-01-28 20:55:45 +00:00
|
|
|
struct Class
|
|
|
|
{
|
|
|
|
Paths paths;
|
2009-04-04 16:06:06 +00:00
|
|
|
SoundDirs soundDirs;
|
2009-05-16 15:22:02 +00:00
|
|
|
Group dictionaryOrder;
|
|
|
|
Group inactiveDictionaries;
|
2009-01-28 20:55:45 +00:00
|
|
|
Groups groups;
|
2009-02-05 20:55:00 +00:00
|
|
|
Preferences preferences;
|
2009-03-26 19:00:08 +00:00
|
|
|
MediaWikis mediawikis;
|
2009-05-16 18:04:21 +00:00
|
|
|
WebSites webSites;
|
2014-04-30 12:55:53 +00:00
|
|
|
DictServers dictServers;
|
2009-04-09 14:15:01 +00:00
|
|
|
Hunspell hunspell;
|
2009-05-06 14:39:08 +00:00
|
|
|
Transliteration transliteration;
|
2022-12-24 14:42:40 +00:00
|
|
|
Lingua lingua;
|
2010-06-12 20:16:35 +00:00
|
|
|
Forvo forvo;
|
2011-05-29 05:08:37 +00:00
|
|
|
Programs programs;
|
2024-03-20 03:08:17 +00:00
|
|
|
#ifndef NO_TTS_SUPPORT
|
2013-04-24 14:52:04 +00:00
|
|
|
VoiceEngines voiceEngines;
|
2024-03-20 03:08:17 +00:00
|
|
|
#endif
|
2009-02-06 17:04:11 +00:00
|
|
|
|
2009-04-10 12:48:40 +00:00
|
|
|
unsigned lastMainGroupId; // Last used group in main window
|
|
|
|
unsigned lastPopupGroupId; // Last used group in popup window
|
2012-12-07 11:59:59 +00:00
|
|
|
|
2010-03-30 20:15:55 +00:00
|
|
|
QByteArray popupWindowState; // Binary state saved by QMainWindow
|
|
|
|
QByteArray popupWindowGeometry; // Geometry saved by QMainWindow
|
2012-09-27 13:00:40 +00:00
|
|
|
QByteArray dictInfoGeometry; // Geometry of "Dictionary info" window
|
2024-06-21 02:00:52 +00:00
|
|
|
QByteArray inspectorGeometry; // Geometry of Web Engine inspector window
|
2021-06-22 15:30:13 +00:00
|
|
|
QByteArray dictionariesDialogGeometry; // Geometry of Dictionaries dialog
|
2009-04-03 21:24:07 +00:00
|
|
|
|
2012-09-12 17:19:21 +00:00
|
|
|
QString historyExportPath; // Path for export/import history
|
2013-04-12 06:57:41 +00:00
|
|
|
QString resourceSavePath; // Path to save images/audio
|
|
|
|
QString articleSavePath; // Path to save articles
|
2012-09-12 17:19:21 +00:00
|
|
|
|
2011-05-07 13:42:49 +00:00
|
|
|
bool pinPopupWindow; // Last pin status
|
2017-07-13 15:00:19 +00:00
|
|
|
bool popupWindowAlwaysOnTop; // Last status of pinned popup window
|
2011-05-01 23:52:11 +00:00
|
|
|
|
2009-04-03 21:24:07 +00:00
|
|
|
QByteArray mainWindowState; // Binary state saved by QMainWindow
|
|
|
|
QByteArray mainWindowGeometry; // Geometry saved by QMainWindow
|
2009-04-10 12:48:40 +00:00
|
|
|
|
2009-09-21 17:50:03 +00:00
|
|
|
MutedDictionaries mutedDictionaries; // Disabled via dictionary bar
|
2010-03-30 20:15:55 +00:00
|
|
|
MutedDictionaries popupMutedDictionaries; // Disabled via dictionary bar in popup
|
2009-09-21 17:50:03 +00:00
|
|
|
|
2023-07-16 07:33:22 +00:00
|
|
|
QDateTime timeForNewReleaseCheck; // Last time when the release was checked.
|
|
|
|
|
2009-05-14 17:59:49 +00:00
|
|
|
QString skippedRelease; // Empty by default
|
2009-04-20 19:54:34 +00:00
|
|
|
|
2009-10-12 12:41:20 +00:00
|
|
|
bool showingDictBarNames;
|
|
|
|
|
2024-09-30 04:36:27 +00:00
|
|
|
ToolbarsIconSize usingToolbarsIconSize = ToolbarsIconSize::Normal;
|
2011-05-22 02:42:05 +00:00
|
|
|
|
2013-01-11 09:58:14 +00:00
|
|
|
/// Maximum size for the headwords.
|
|
|
|
/// Bigger headwords won't be indexed. For now, only in DSL.
|
|
|
|
unsigned int maxHeadwordSize;
|
|
|
|
|
2017-10-25 14:37:39 +00:00
|
|
|
unsigned int maxHeadwordsToExpand;
|
|
|
|
|
2014-02-28 12:36:28 +00:00
|
|
|
HeadwordsDialog headwordsDialog;
|
|
|
|
|
2023-05-27 01:42:58 +00:00
|
|
|
Class():
|
|
|
|
lastMainGroupId( 0 ),
|
|
|
|
lastPopupGroupId( 0 ),
|
|
|
|
pinPopupWindow( false ),
|
|
|
|
showingDictBarNames( false ),
|
|
|
|
maxHeadwordSize( 256U ),
|
|
|
|
maxHeadwordsToExpand( 0 )
|
|
|
|
{
|
|
|
|
}
|
2012-09-26 13:13:47 +00:00
|
|
|
Group * getGroup( unsigned id );
|
|
|
|
Group const * getGroup( unsigned id ) const;
|
2023-05-27 01:42:58 +00:00
|
|
|
//disable tts dictionary. does not need to save to persistent file
|
|
|
|
bool notts = false;
|
2023-06-09 11:56:04 +00:00
|
|
|
bool resetState;
|
2009-01-28 20:55:45 +00:00
|
|
|
};
|
|
|
|
|
2009-09-21 17:50:03 +00:00
|
|
|
/// Configuration-specific events. Some parts of the program need to react
|
|
|
|
/// to specific changes in configuration. The object of this class is used
|
|
|
|
/// to emit signals when such events happen -- and the listeners connect to
|
|
|
|
/// them to be notified of them.
|
|
|
|
/// This class is separate from the main Class since QObjects can't be copied.
|
|
|
|
class Events: public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2009-09-23 18:44:38 +00:00
|
|
|
/// Signals that the value of the mutedDictionaries has changed.
|
|
|
|
/// This emits mutedDictionariesChanged() signal, so the subscribers will
|
|
|
|
/// be notified.
|
|
|
|
void signalMutedDictionariesChanged();
|
2009-09-21 17:50:03 +00:00
|
|
|
|
|
|
|
signals:
|
|
|
|
|
2009-09-23 18:44:38 +00:00
|
|
|
/// THe value of the mutedDictionaries has changed.
|
|
|
|
void mutedDictionariesChanged();
|
2009-09-21 17:50:03 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
};
|
|
|
|
|
2009-01-28 20:55:45 +00:00
|
|
|
DEF_EX( exError, "Error with the program's configuration", std::exception )
|
2021-10-31 20:49:38 +00:00
|
|
|
DEF_EX( exCantUseDataDir, "Can't use XDG_DATA_HOME directory to store GoldenDict data", exError )
|
2009-01-28 20:55:45 +00:00
|
|
|
DEF_EX( exCantUseHomeDir, "Can't use home directory to store GoldenDict preferences", exError )
|
|
|
|
DEF_EX( exCantUseIndexDir, "Can't use index directory to store GoldenDict index files", exError )
|
|
|
|
DEF_EX( exCantReadConfigFile, "Can't read the configuration file", exError )
|
|
|
|
DEF_EX( exCantWriteConfigFile, "Can't write the configuration file", exError )
|
|
|
|
DEF_EX( exMalformedConfigFile, "The configuration file is malformed", exError )
|
|
|
|
|
|
|
|
/// Loads the configuration, or creates the default one if none is present
|
2022-01-09 08:35:07 +00:00
|
|
|
Class load();
|
2009-01-28 20:55:45 +00:00
|
|
|
|
|
|
|
/// Saves the configuration
|
2022-01-09 08:35:07 +00:00
|
|
|
void save( Class const & );
|
2009-01-28 20:55:45 +00:00
|
|
|
|
2013-05-08 16:50:06 +00:00
|
|
|
/// Returns the configuration file name.
|
|
|
|
QString getConfigFileName();
|
|
|
|
|
2011-07-10 07:36:43 +00:00
|
|
|
/// Returns the main configuration directory.
|
2022-01-09 08:35:07 +00:00
|
|
|
QString getConfigDir();
|
2011-07-10 07:36:43 +00:00
|
|
|
|
2009-01-28 20:55:45 +00:00
|
|
|
/// Returns the index directory, where the indices are to be stored.
|
2022-01-09 08:35:07 +00:00
|
|
|
QString getIndexDir();
|
2009-01-28 20:55:45 +00:00
|
|
|
|
2009-05-12 19:13:20 +00:00
|
|
|
/// Returns the filename of a .pid file which should store current pid of
|
|
|
|
/// the process.
|
2022-01-09 08:35:07 +00:00
|
|
|
QString getPidFileName();
|
2009-05-12 19:13:20 +00:00
|
|
|
|
2009-10-21 19:30:14 +00:00
|
|
|
/// Returns the filename of a history file which stores search history.
|
2022-01-09 08:35:07 +00:00
|
|
|
QString getHistoryFileName();
|
2009-10-21 19:30:14 +00:00
|
|
|
|
2017-05-05 14:39:51 +00:00
|
|
|
/// Returns the filename of a favorities file.
|
2022-01-09 08:35:07 +00:00
|
|
|
QString getFavoritiesFileName();
|
2017-05-05 14:39:51 +00:00
|
|
|
|
2023-06-04 00:02:39 +00:00
|
|
|
/// Returns the user .css file name (article-style.css).
|
2022-01-09 08:35:07 +00:00
|
|
|
QString getUserCssFileName();
|
2009-01-28 20:55:45 +00:00
|
|
|
|
2023-06-04 00:02:39 +00:00
|
|
|
/// Returns the user .js file name (article-script.js).
|
|
|
|
std::optional< std::string > getUserJsFileName();
|
|
|
|
|
2009-05-01 12:20:33 +00:00
|
|
|
/// Returns the user .css file name used for printing only.
|
2022-01-09 08:35:07 +00:00
|
|
|
QString getUserCssPrintFileName();
|
2009-05-01 12:20:33 +00:00
|
|
|
|
2009-02-01 00:08:08 +00:00
|
|
|
/// Returns the user .css file name for the Qt interface customization.
|
2022-01-09 08:35:07 +00:00
|
|
|
QString getUserQtCssFileName();
|
2009-02-01 00:08:08 +00:00
|
|
|
|
2009-04-12 19:41:58 +00:00
|
|
|
/// Returns the program's data dir. Under Linux that would be something like
|
|
|
|
/// /usr/share/apps/goldendict, under Windows C:/Program Files/GoldenDict.
|
2022-06-03 13:28:41 +00:00
|
|
|
QString getProgramDataDir() noexcept;
|
2009-04-12 19:41:58 +00:00
|
|
|
|
2009-07-29 16:39:27 +00:00
|
|
|
/// Returns the directory storing program localizized files (.qm).
|
2022-06-03 13:28:41 +00:00
|
|
|
QString getLocDir() noexcept;
|
2010-05-28 16:50:54 +00:00
|
|
|
|
2014-06-24 13:55:06 +00:00
|
|
|
/// Returns the directory storing program help files (.qch).
|
2022-06-03 13:28:41 +00:00
|
|
|
QString getHelpDir() noexcept;
|
2014-06-24 13:55:06 +00:00
|
|
|
|
2015-10-26 03:56:39 +00:00
|
|
|
#ifdef MAKE_CHINESE_CONVERSION_SUPPORT
|
|
|
|
/// Returns the directory storing OpenCC configuration and dictionary files (.json and .ocd).
|
2022-06-03 13:28:41 +00:00
|
|
|
QString getOpenCCDir() noexcept;
|
2015-10-26 03:56:39 +00:00
|
|
|
#endif
|
|
|
|
|
2010-05-28 16:50:54 +00:00
|
|
|
/// Returns true if the program is configured as a portable version. In that
|
|
|
|
/// mode, all the settings and indices are kept in the program's directory.
|
2022-06-03 13:28:41 +00:00
|
|
|
bool isPortableVersion() noexcept;
|
2010-05-28 16:50:54 +00:00
|
|
|
|
|
|
|
/// Returns directory with dictionaries for portable version. It is content/
|
|
|
|
/// in the application's directory.
|
2022-06-03 13:28:41 +00:00
|
|
|
QString getPortableVersionDictionaryDir() noexcept;
|
2010-05-28 16:50:54 +00:00
|
|
|
|
|
|
|
/// Returns directory with morpgologies for portable version. It is
|
|
|
|
/// content/morphology in the application's directory.
|
2022-06-03 13:28:41 +00:00
|
|
|
QString getPortableVersionMorphoDir() noexcept;
|
2010-05-28 16:50:54 +00:00
|
|
|
|
2012-12-10 14:14:13 +00:00
|
|
|
/// Returns the add-on styles directory.
|
2022-02-13 06:26:45 +00:00
|
|
|
QString getStylesDir();
|
2012-12-10 14:14:13 +00:00
|
|
|
|
2020-11-12 15:57:10 +00:00
|
|
|
/// Returns the directory where user-specific non-essential (cached) data should be written.
|
2022-06-03 13:28:41 +00:00
|
|
|
QString getCacheDir() noexcept;
|
2020-11-12 15:57:10 +00:00
|
|
|
|
2009-01-28 20:55:45 +00:00
|
|
|
} // namespace Config
|
|
|
|
|
2021-06-10 16:13:11 +00:00
|
|
|
#endif
|