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 */
|
|
|
|
|
|
|
|
#include "config.hh"
|
|
|
|
#include <QDir>
|
|
|
|
#include <QFile>
|
|
|
|
#include <QtXml>
|
2013-11-16 18:34:09 +00:00
|
|
|
#include "gddebug.hh"
|
2009-04-29 23:18:26 +00:00
|
|
|
|
2016-04-07 21:45:27 +00:00
|
|
|
#if defined( _MSC_VER ) && _MSC_VER < 1800 // VS2012 and older
|
2009-04-29 23:18:26 +00:00
|
|
|
#include <stdint_msvc.h>
|
|
|
|
#else
|
2009-04-27 12:25:15 +00:00
|
|
|
#include <stdint.h>
|
2009-04-29 23:18:26 +00:00
|
|
|
#endif
|
2009-01-28 20:55:45 +00:00
|
|
|
|
2009-04-30 21:47:42 +00:00
|
|
|
#ifdef Q_OS_WIN32
|
|
|
|
#include "shlobj.h"
|
|
|
|
#endif
|
|
|
|
|
2009-10-21 19:30:14 +00:00
|
|
|
#include "atomic_rename.hh"
|
2013-05-30 15:05:41 +00:00
|
|
|
#include "qt4x5.hh"
|
2009-10-18 11:01:13 +00:00
|
|
|
|
2009-01-28 20:55:45 +00:00
|
|
|
namespace Config {
|
|
|
|
|
|
|
|
namespace
|
|
|
|
{
|
|
|
|
QDir getHomeDir()
|
|
|
|
{
|
2010-05-28 16:50:54 +00:00
|
|
|
if ( isPortableVersion() )
|
|
|
|
return QDir( QCoreApplication::applicationDirPath() + "/portable" );
|
|
|
|
|
2011-10-28 14:36:21 +00:00
|
|
|
QDir result;
|
|
|
|
|
2011-10-30 08:13:17 +00:00
|
|
|
result = QDir::home();
|
2011-10-28 14:36:21 +00:00
|
|
|
#ifdef Q_OS_WIN32
|
2011-10-30 08:13:17 +00:00
|
|
|
if ( result.cd( "Application Data/GoldenDict" ) )
|
|
|
|
return result;
|
2011-10-28 14:36:21 +00:00
|
|
|
char const * pathInHome = "GoldenDict";
|
|
|
|
result = QDir::fromNativeSeparators( QString::fromWCharArray( _wgetenv( L"APPDATA" ) ) );
|
|
|
|
#else
|
|
|
|
char const * pathInHome = ".goldendict";
|
|
|
|
#endif
|
2009-01-28 20:55:45 +00:00
|
|
|
|
|
|
|
result.mkpath( pathInHome );
|
|
|
|
|
|
|
|
if ( !result.cd( pathInHome ) )
|
|
|
|
throw exCantUseHomeDir();
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-04-01 17:00:13 +00:00
|
|
|
ProxyServer::ProxyServer(): enabled( false ), useSystemProxy( false ), type( Socks5 ), port( 3128 )
|
2009-04-03 17:10:27 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2009-04-21 18:27:26 +00:00
|
|
|
HotKey::HotKey(): modifiers( 0 ), key1( 0 ), key2( 0 )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// Does anyone know how to separate modifiers from the keycode? We'll
|
|
|
|
// use our own mask.
|
|
|
|
|
|
|
|
uint32_t const keyMask = 0x01FFFFFF;
|
|
|
|
|
|
|
|
HotKey::HotKey( QKeySequence const & seq ):
|
|
|
|
modifiers( seq[ 0 ] & ~keyMask ),
|
|
|
|
key1( seq[ 0 ] & keyMask ),
|
|
|
|
key2( seq[ 1 ] & keyMask )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
QKeySequence HotKey::toKeySequence() const
|
|
|
|
{
|
2010-07-05 14:13:29 +00:00
|
|
|
int v2 = key2 ? ( key2 | modifiers ): 0;
|
|
|
|
|
|
|
|
return QKeySequence( key1 | modifiers, v2 );
|
2009-04-21 18:27:26 +00:00
|
|
|
}
|
|
|
|
|
2018-03-29 17:00:53 +00:00
|
|
|
bool InternalPlayerBackend::anyAvailable()
|
|
|
|
{
|
|
|
|
#if defined( MAKE_FFMPEG_PLAYER ) || defined( MAKE_QTMULTIMEDIA_PLAYER )
|
|
|
|
return true;
|
|
|
|
#else
|
|
|
|
return false;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
InternalPlayerBackend InternalPlayerBackend::defaultBackend()
|
|
|
|
{
|
|
|
|
#if defined( MAKE_FFMPEG_PLAYER )
|
|
|
|
return ffmpeg();
|
|
|
|
#elif defined( MAKE_QTMULTIMEDIA_PLAYER )
|
|
|
|
return qtmultimedia();
|
|
|
|
#else
|
|
|
|
return InternalPlayerBackend( QString() );
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
QStringList InternalPlayerBackend::nameList()
|
|
|
|
{
|
|
|
|
QStringList result;
|
|
|
|
#ifdef MAKE_FFMPEG_PLAYER
|
|
|
|
result.push_back( ffmpeg().uiName() );
|
|
|
|
#endif
|
|
|
|
#ifdef MAKE_QTMULTIMEDIA_PLAYER
|
|
|
|
result.push_back( qtmultimedia().uiName() );
|
|
|
|
#endif
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool InternalPlayerBackend::isFfmpeg() const
|
|
|
|
{
|
|
|
|
#ifdef MAKE_FFMPEG_PLAYER
|
|
|
|
return *this == ffmpeg();
|
|
|
|
#else
|
|
|
|
return false;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
bool InternalPlayerBackend::isQtmultimedia() const
|
|
|
|
{
|
|
|
|
#ifdef MAKE_QTMULTIMEDIA_PLAYER
|
|
|
|
return *this == qtmultimedia();
|
|
|
|
#else
|
|
|
|
return false;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
Allow customizing unpinned scan popup window flags on X11 with Qt5
My tests in many desktop environments and window managers indicate that
no single configuration works perfectly in all environments. There are
also behavior differences between Qt::Popup and Qt::Tool flags, which
are not exactly bugs, so I suppose users might subjectively prefer
different options.
Customizing the flags allows the user to prevent unpinned scan popup
window flickering with Qt5 on Linux. In a way adding these options fixes
issue #645, which is: the scan popup window blinks rapidly, barely
noticeably in some applications, such as Calibre ebook-viewer
and Chromium. In this case the scan popup window usually ends up hidden
when selection ends, unless it was finished with a jerk.
I have tested the new options in 9 desktop environments and window
managers: at least one configuration for each eliminates #645 and makes
the scan popup window work the same as with Qt4 in this regard:
the popup window remains visible, text in the popup's translation line
keeps up with the text selection in the external application,
and the selected text is being translated on the fly.
Moreover, for each tested DE/WM, at least one configuration makes
the scan popup window work perfectly as far as I am concerned.
This issue was partially worked around with a 200ms scan popup delay
timer in the recent commit 58e41fe3ceb769cab37608e36637044e597ba1f8
for the duplicate issue #854. However the timer solution is incomplete
because it requires the user to select text quickly and without delays.
If global mouse selection does not change for 200ms while the left mouse
button is held down, the user will likely not see the scan popup when
(s)he finishes selection, and will have to try selecting again -
hopefully faster this time.
The 200ms delay is no longer critically important after this commit,
but it is still beneficial: the lookup query changes less often,
which in turn reduces article definition update frequency.
So the delay improves the UI (perhaps subjectively) and performance.
2018-04-09 17:50:23 +00:00
|
|
|
ScanPopupWindowFlags spwfFromInt( int id )
|
|
|
|
{
|
|
|
|
if( id == SPWF_Popup )
|
|
|
|
return SPWF_Popup;
|
|
|
|
if( id == SPWF_Tool )
|
|
|
|
return SPWF_Tool;
|
|
|
|
|
|
|
|
if( id != SPWF_default )
|
|
|
|
gdWarning( "Invalid ScanPopup unpinned window flags: %d\n", id );
|
|
|
|
return SPWF_default;
|
|
|
|
}
|
|
|
|
|
2009-02-05 20:55:00 +00:00
|
|
|
Preferences::Preferences():
|
2009-04-13 12:51:25 +00:00
|
|
|
newTabsOpenAfterCurrentOne( false ),
|
|
|
|
newTabsOpenInBackground( true ),
|
2011-06-23 14:17:09 +00:00
|
|
|
hideSingleTab( false ),
|
2011-11-02 23:37:50 +00:00
|
|
|
mruTabOrder ( false ),
|
2011-06-26 11:53:28 +00:00
|
|
|
hideMenubar( false ),
|
2009-03-29 13:43:37 +00:00
|
|
|
enableTrayIcon( true ),
|
2009-02-05 20:55:00 +00:00
|
|
|
startToTray( false ),
|
2009-03-29 13:43:37 +00:00
|
|
|
closeToTray( true ),
|
2009-04-18 18:16:04 +00:00
|
|
|
autoStart( false ),
|
2010-04-08 20:37:59 +00:00
|
|
|
doubleClickTranslates( true ),
|
2012-09-26 13:59:48 +00:00
|
|
|
selectWordBySingleClick( false ),
|
2011-05-07 13:42:49 +00:00
|
|
|
escKeyHidesMainWindow( false ),
|
2012-12-29 11:19:49 +00:00
|
|
|
alwaysOnTop ( false ),
|
2013-01-05 11:26:55 +00:00
|
|
|
searchInDock ( false ),
|
2009-04-21 18:27:26 +00:00
|
|
|
|
|
|
|
enableMainWindowHotkey( true ),
|
|
|
|
mainWindowHotkey( QKeySequence( "Ctrl+F11,F11" ) ),
|
|
|
|
enableClipboardHotkey( true ),
|
2009-05-24 19:04:24 +00:00
|
|
|
clipboardHotkey( QKeySequence( "Ctrl+C,C" ) ),
|
2009-04-21 18:27:26 +00:00
|
|
|
|
2009-03-29 13:43:37 +00:00
|
|
|
enableScanPopup( true ),
|
2009-02-08 20:20:02 +00:00
|
|
|
startWithScanPopupOn( false ),
|
2009-02-05 20:55:00 +00:00
|
|
|
enableScanPopupModifiers( false ),
|
2009-04-10 21:07:03 +00:00
|
|
|
scanPopupModifiers( 0 ),
|
2009-04-11 16:44:14 +00:00
|
|
|
scanPopupAltMode( false ),
|
|
|
|
scanPopupAltModeSecs( 3 ),
|
2018-04-16 12:23:22 +00:00
|
|
|
ignoreOwnClipboardChanges( false ),
|
2011-07-10 09:48:57 +00:00
|
|
|
scanPopupUseUIAutomation( true ),
|
|
|
|
scanPopupUseIAccessibleEx( true ),
|
|
|
|
scanPopupUseGDMessage( true ),
|
Allow customizing unpinned scan popup window flags on X11 with Qt5
My tests in many desktop environments and window managers indicate that
no single configuration works perfectly in all environments. There are
also behavior differences between Qt::Popup and Qt::Tool flags, which
are not exactly bugs, so I suppose users might subjectively prefer
different options.
Customizing the flags allows the user to prevent unpinned scan popup
window flickering with Qt5 on Linux. In a way adding these options fixes
issue #645, which is: the scan popup window blinks rapidly, barely
noticeably in some applications, such as Calibre ebook-viewer
and Chromium. In this case the scan popup window usually ends up hidden
when selection ends, unless it was finished with a jerk.
I have tested the new options in 9 desktop environments and window
managers: at least one configuration for each eliminates #645 and makes
the scan popup window work the same as with Qt4 in this regard:
the popup window remains visible, text in the popup's translation line
keeps up with the text selection in the external application,
and the selected text is being translated on the fly.
Moreover, for each tested DE/WM, at least one configuration makes
the scan popup window work perfectly as far as I am concerned.
This issue was partially worked around with a 200ms scan popup delay
timer in the recent commit 58e41fe3ceb769cab37608e36637044e597ba1f8
for the duplicate issue #854. However the timer solution is incomplete
because it requires the user to select text quickly and without delays.
If global mouse selection does not change for 200ms while the left mouse
button is held down, the user will likely not see the scan popup when
(s)he finishes selection, and will have to try selecting again -
hopefully faster this time.
The 200ms delay is no longer critically important after this commit,
but it is still beneficial: the lookup query changes less often,
which in turn reduces article definition update frequency.
So the delay improves the UI (perhaps subjectively) and performance.
2018-04-09 17:50:23 +00:00
|
|
|
scanPopupUnpinnedWindowFlags( SPWF_default ),
|
|
|
|
scanPopupUnpinnedBypassWMHint( false ),
|
2011-11-16 12:52:25 +00:00
|
|
|
scanToMainWindow( false ),
|
2018-06-13 16:00:42 +00:00
|
|
|
ignoreDiacritics( false ),
|
2017-06-05 13:15:38 +00:00
|
|
|
#ifdef HAVE_X11
|
|
|
|
showScanFlag( false ),
|
|
|
|
#endif
|
2009-04-10 21:07:03 +00:00
|
|
|
pronounceOnLoadMain( false ),
|
2009-04-20 19:54:34 +00:00
|
|
|
pronounceOnLoadPopup( false ),
|
2018-03-29 17:00:53 +00:00
|
|
|
useInternalPlayer( InternalPlayerBackend::anyAvailable() ),
|
|
|
|
internalPlayerBackend( InternalPlayerBackend::defaultBackend() ),
|
2009-04-30 19:57:25 +00:00
|
|
|
checkForNewReleases( true ),
|
2009-08-31 12:18:08 +00:00
|
|
|
disallowContentFromOtherSites( false ),
|
2011-05-08 21:19:08 +00:00
|
|
|
enableWebPlugins( false ),
|
2013-04-08 12:20:12 +00:00
|
|
|
hideGoldenDictHeader( false ),
|
2010-07-02 11:19:02 +00:00
|
|
|
zoomFactor( 1 ),
|
2014-06-23 15:11:15 +00:00
|
|
|
helpZoomFactor( 1 ),
|
2012-02-16 14:56:25 +00:00
|
|
|
wordsZoomLevel( 0 ),
|
2012-09-11 13:03:10 +00:00
|
|
|
maxStringsInHistory( 500 ),
|
2012-09-16 10:19:47 +00:00
|
|
|
storeHistory( 1 ),
|
2013-12-18 14:24:02 +00:00
|
|
|
alwaysExpandOptionalParts( false )
|
2013-02-05 12:51:23 +00:00
|
|
|
, historyStoreInterval( 0 )
|
2017-05-13 10:18:25 +00:00
|
|
|
, favoritesStoreInterval( 0 )
|
2017-05-17 15:26:32 +00:00
|
|
|
, confirmFavoritesDeletion( true )
|
2013-06-02 11:20:33 +00:00
|
|
|
, collapseBigArticles( false )
|
|
|
|
, articleSizeLimit( 2000 )
|
2013-06-11 18:31:01 +00:00
|
|
|
, maxDictionaryRefsInContextMenu ( 20 )
|
2014-01-09 14:17:50 +00:00
|
|
|
#ifndef Q_WS_X11
|
|
|
|
, trackClipboardChanges( false )
|
|
|
|
#endif
|
2017-03-09 16:11:17 +00:00
|
|
|
, synonymSearchEnabled( true )
|
2009-02-05 20:55:00 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2015-10-25 13:54:38 +00:00
|
|
|
#ifdef MAKE_CHINESE_CONVERSION_SUPPORT
|
2015-10-19 13:52:23 +00:00
|
|
|
Chinese::Chinese():
|
|
|
|
enable( false ),
|
2015-10-20 03:37:50 +00:00
|
|
|
enableSCToTWConversion( true ),
|
|
|
|
enableSCToHKConversion( true ),
|
|
|
|
enableTCToSCConversion( true )
|
2015-10-19 13:52:23 +00:00
|
|
|
{
|
|
|
|
}
|
2015-10-25 13:54:38 +00:00
|
|
|
#endif
|
2015-10-19 13:52:23 +00:00
|
|
|
|
2009-05-06 14:39:08 +00:00
|
|
|
Romaji::Romaji():
|
|
|
|
enable( false ),
|
|
|
|
enableHepburn( true ),
|
|
|
|
enableNihonShiki( false ),
|
|
|
|
enableKunreiShiki( false ),
|
|
|
|
enableHiragana( true ),
|
|
|
|
enableKatakana( true )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-09-26 13:13:47 +00:00
|
|
|
Group * Class::getGroup( unsigned id )
|
|
|
|
{
|
2012-12-10 12:49:45 +00:00
|
|
|
for( int x = 0; x < groups.size(); x++ )
|
|
|
|
if( groups.at( x ).id == id )
|
2012-09-26 13:13:47 +00:00
|
|
|
return &groups[ x ];
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
Group const * Class::getGroup( unsigned id ) const
|
|
|
|
{
|
2012-12-10 12:49:45 +00:00
|
|
|
for( int x = 0; x < groups.size(); x++ )
|
|
|
|
if( groups.at( x ).id == id )
|
|
|
|
return &groups.at( x );
|
2012-09-26 13:13:47 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-09-23 18:44:38 +00:00
|
|
|
void Events::signalMutedDictionariesChanged()
|
2009-09-21 17:50:03 +00:00
|
|
|
{
|
2009-09-23 18:44:38 +00:00
|
|
|
emit mutedDictionariesChanged();
|
2009-09-21 17:50:03 +00:00
|
|
|
}
|
|
|
|
|
2009-03-27 10:48:44 +00:00
|
|
|
namespace {
|
|
|
|
|
|
|
|
MediaWikis makeDefaultMediaWikis( bool enable )
|
|
|
|
{
|
|
|
|
MediaWikis mw;
|
|
|
|
|
2015-03-24 17:01:40 +00:00
|
|
|
mw.push_back( MediaWiki( "ae6f89aac7151829681b85f035d54e48", "English Wikipedia", "https://en.wikipedia.org/w", enable, "" ) );
|
|
|
|
mw.push_back( MediaWiki( "affcf9678e7bfe701c9b071f97eccba3", "English Wiktionary", "https://en.wiktionary.org/w", false, "" ) );
|
2015-02-20 14:17:41 +00:00
|
|
|
mw.push_back( MediaWiki( "8e0c1c2b6821dab8bdba8eb869ca7176", "Russian Wikipedia", "https://ru.wikipedia.org/w", false, "" ) );
|
|
|
|
mw.push_back( MediaWiki( "b09947600ae3902654f8ad4567ae8567", "Russian Wiktionary", "https://ru.wiktionary.org/w", false, "" ) );
|
2015-03-24 17:01:40 +00:00
|
|
|
mw.push_back( MediaWiki( "a8a66331a1242ca2aeb0b4aed361c41d", "German Wikipedia", "https://de.wikipedia.org/w", false, "" ) );
|
|
|
|
mw.push_back( MediaWiki( "21c64bca5ec10ba17ff19f3066bc962a", "German Wiktionary", "https://de.wiktionary.org/w", false, "" ) );
|
|
|
|
mw.push_back( MediaWiki( "96957cb2ad73a20c7a1d561fc83c253a", "Portuguese Wikipedia", "https://pt.wikipedia.org/w", false, "" ) );
|
|
|
|
mw.push_back( MediaWiki( "ed4c3929196afdd93cc08b9a903aad6a", "Portuguese Wiktionary", "https://pt.wiktionary.org/w", false, "" ) );
|
|
|
|
mw.push_back( MediaWiki( "f3b4ec8531e52ddf5b10d21e4577a7a2", "Greek Wikipedia", "https://el.wikipedia.org/w", false, "" ) );
|
|
|
|
mw.push_back( MediaWiki( "5d45232075d06e002dea72fe3e137da1", "Greek Wiktionary", "https://el.wiktionary.org/w", false, "" ) );
|
2009-03-27 10:48:44 +00:00
|
|
|
|
|
|
|
return mw;
|
|
|
|
}
|
|
|
|
|
2009-05-16 18:04:21 +00:00
|
|
|
WebSites makeDefaultWebSites()
|
|
|
|
{
|
|
|
|
WebSites ws;
|
|
|
|
|
2017-10-10 10:23:52 +00:00
|
|
|
ws.push_back( WebSite( "b88cb2898e634c6638df618528284c2d", "Google En-En (Oxford)", "https://www.google.com/search?q=define:%GDWORD%&hl=en", false, "", true ) );
|
2016-06-17 14:27:48 +00:00
|
|
|
ws.push_back( WebSite( "f376365a0de651fd7505e7e5e683aa45", "Urban Dictionary", "https://www.urbandictionary.com/define.php?term=%GDWORD%", false, "", true ) );
|
|
|
|
ws.push_back( WebSite( "324ca0306187df7511b26d3847f4b07c", "Multitran (En)", "https://multitran.ru/c/m.exe?CL=1&l1=1&s=%GD1251%", false, "", true ) );
|
|
|
|
ws.push_back( WebSite( "924db471b105299c82892067c0f10787", "Lingvo (En-Ru)", "http://lingvopro.abbyyonline.com/en/Search/en-ru/%GDWORD%", false, "", true ) );
|
|
|
|
ws.push_back( WebSite( "087a6d65615fb047f4c80eef0a9465db", "Michaelis (Pt-En)", "http://michaelis.uol.com.br/moderno/ingles/index.php?lingua=portugues-ingles&palavra=%GDISO1%", false, "", true ) );
|
2009-05-16 18:04:21 +00:00
|
|
|
|
|
|
|
return ws;
|
|
|
|
}
|
|
|
|
|
2014-04-30 12:55:53 +00:00
|
|
|
DictServers makeDefaultDictServers()
|
|
|
|
{
|
|
|
|
DictServers ds;
|
|
|
|
|
|
|
|
return ds;
|
|
|
|
}
|
|
|
|
|
2011-05-29 05:08:37 +00:00
|
|
|
Programs makeDefaultPrograms()
|
|
|
|
{
|
|
|
|
Programs programs;
|
|
|
|
|
|
|
|
// The following list doesn't make a lot of sense under Windows
|
2013-05-31 04:28:29 +00:00
|
|
|
#ifndef Q_OS_WIN
|
2012-12-09 17:29:27 +00:00
|
|
|
programs.push_back( Program( false, Program::Audio, "428b4c2b905ef568a43d9a16f59559b0", "Festival", "festival --tts", "" ) );
|
|
|
|
programs.push_back( Program( false, Program::Audio, "2cf8b3a60f27e1ac812de0b57c148340", "Espeak", "espeak %GDWORD%", "" ) );
|
|
|
|
programs.push_back( Program( false, Program::Html, "4f898f7582596cea518c6b0bfdceb8b3", "Manpages", "man -a --html=/bin/cat %GDWORD%", "" ) );
|
2011-05-29 05:08:37 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
return programs;
|
|
|
|
}
|
|
|
|
|
2009-04-21 18:27:26 +00:00
|
|
|
/// Sets option to true of false if node is "1" or "0" respectively, or leaves
|
|
|
|
/// it intact if it's neither "1" nor "0".
|
|
|
|
void applyBoolOption( bool & option, QDomNode const & node )
|
|
|
|
{
|
|
|
|
QString value = node.toElement().text();
|
|
|
|
|
|
|
|
if ( value == "1" )
|
|
|
|
option = true;
|
|
|
|
else
|
|
|
|
if ( value == "0" )
|
|
|
|
option = false;
|
|
|
|
}
|
|
|
|
|
2009-05-16 15:22:02 +00:00
|
|
|
Group loadGroup( QDomElement grp, unsigned * nextId = 0 )
|
|
|
|
{
|
|
|
|
Group g;
|
|
|
|
|
|
|
|
if ( grp.hasAttribute( "id" ) )
|
|
|
|
g.id = grp.attribute( "id" ).toUInt();
|
|
|
|
else
|
|
|
|
g.id = nextId ? (*nextId)++ : 0;
|
|
|
|
|
|
|
|
g.name = grp.attribute( "name" );
|
|
|
|
g.icon = grp.attribute( "icon" );
|
2017-05-05 14:39:51 +00:00
|
|
|
g.favoritesFolder = grp.attribute( "favoritesFolder" );
|
2009-05-16 15:22:02 +00:00
|
|
|
|
2010-07-05 18:36:03 +00:00
|
|
|
if ( !grp.attribute( "iconData" ).isEmpty() )
|
2013-02-03 20:19:55 +00:00
|
|
|
g.iconData = QByteArray::fromBase64( grp.attribute( "iconData" ).toLatin1() );
|
2010-07-05 18:36:03 +00:00
|
|
|
|
2010-07-05 14:13:29 +00:00
|
|
|
if ( !grp.attribute( "shortcut" ).isEmpty() )
|
|
|
|
g.shortcut = QKeySequence::fromString( grp.attribute( "shortcut" ) );
|
|
|
|
|
2009-05-16 15:22:02 +00:00
|
|
|
QDomNodeList dicts = grp.elementsByTagName( "dictionary" );
|
|
|
|
|
2013-05-30 15:05:41 +00:00
|
|
|
for( Qt4x5::Dom::size_type y = 0; y < dicts.length(); ++y )
|
2009-05-16 15:22:02 +00:00
|
|
|
g.dictionaries.push_back( DictionaryRef( dicts.item( y ).toElement().text(),
|
|
|
|
dicts.item( y ).toElement().attribute( "name" ) ) );
|
|
|
|
|
2012-09-26 13:13:47 +00:00
|
|
|
QDomNode muted = grp.namedItem( "mutedDictionaries" );
|
|
|
|
dicts = muted.toElement().elementsByTagName( "mutedDictionary" );
|
2013-05-30 15:05:41 +00:00
|
|
|
for( Qt4x5::Dom::size_type x = 0; x < dicts.length(); ++x )
|
2012-09-26 13:13:47 +00:00
|
|
|
g.mutedDictionaries.insert( dicts.item( x ).toElement().text() );
|
|
|
|
|
|
|
|
dicts = muted.toElement().elementsByTagName( "popupMutedDictionary" );
|
2013-05-30 15:05:41 +00:00
|
|
|
for( Qt4x5::Dom::size_type x = 0; x < dicts.length(); ++x )
|
2012-09-26 13:13:47 +00:00
|
|
|
g.popupMutedDictionaries.insert( dicts.item( x ).toElement().text() );
|
|
|
|
|
2009-05-16 15:22:02 +00:00
|
|
|
return g;
|
|
|
|
}
|
|
|
|
|
2010-03-30 20:15:55 +00:00
|
|
|
MutedDictionaries loadMutedDictionaries( QDomNode mutedDictionaries )
|
|
|
|
{
|
|
|
|
MutedDictionaries result;
|
|
|
|
|
|
|
|
if ( !mutedDictionaries.isNull() )
|
|
|
|
{
|
|
|
|
QDomNodeList nl = mutedDictionaries.toElement().
|
|
|
|
elementsByTagName( "mutedDictionary" );
|
|
|
|
|
2013-05-30 15:05:41 +00:00
|
|
|
for( Qt4x5::Dom::size_type x = 0; x < nl.length(); ++x )
|
2010-03-30 20:15:55 +00:00
|
|
|
result.insert( nl.item( x ).toElement().text() );
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
void saveMutedDictionaries( QDomDocument & dd, QDomElement & muted,
|
|
|
|
MutedDictionaries const & mutedDictionaries )
|
|
|
|
{
|
|
|
|
for( MutedDictionaries::const_iterator i = mutedDictionaries.begin();
|
|
|
|
i != mutedDictionaries.end(); ++i )
|
|
|
|
{
|
|
|
|
QDomElement dict = dd.createElement( "mutedDictionary" );
|
|
|
|
muted.appendChild( dict );
|
|
|
|
|
|
|
|
QDomText value = dd.createTextNode( *i );
|
|
|
|
dict.appendChild( value );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-03-27 10:48:44 +00:00
|
|
|
}
|
2009-02-05 20:55:00 +00:00
|
|
|
|
2018-05-21 15:32:04 +00:00
|
|
|
Class load() THROW_SPEC( exError )
|
2009-01-28 20:55:45 +00:00
|
|
|
{
|
|
|
|
QString configName = getConfigFileName();
|
|
|
|
|
2009-04-23 13:43:51 +00:00
|
|
|
bool loadFromTemplate = false;
|
|
|
|
|
2009-01-28 20:55:45 +00:00
|
|
|
if ( !QFile::exists( configName ) )
|
|
|
|
{
|
|
|
|
// Make the default config, save it and return it
|
|
|
|
Class c;
|
|
|
|
|
|
|
|
#ifdef Q_OS_LINUX
|
2009-03-28 22:37:03 +00:00
|
|
|
if ( QDir( "/usr/share/stardict/dic" ).exists() )
|
|
|
|
c.paths.push_back( Path( "/usr/share/stardict/dic", true ) );
|
2009-04-04 19:20:09 +00:00
|
|
|
|
2009-04-09 19:03:28 +00:00
|
|
|
if ( QDir( "/usr/share/dictd" ).exists() )
|
|
|
|
c.paths.push_back( Path( "/usr/share/dictd", true ) );
|
|
|
|
|
2013-07-18 18:22:41 +00:00
|
|
|
if ( QDir( "/usr/share/opendict/dictionaries" ).exists() )
|
|
|
|
c.paths.push_back( Path( "/usr/share/opendict/dictionaries", true ) );
|
|
|
|
|
2013-07-18 18:14:01 +00:00
|
|
|
if ( QDir( "/usr/share/goldendict-wordnet" ).exists() )
|
|
|
|
c.paths.push_back( Path( "/usr/share/goldendict-wordnet", true ) );
|
|
|
|
|
2009-04-04 19:20:09 +00:00
|
|
|
if ( QDir( "/usr/share/WyabdcRealPeopleTTS" ).exists() )
|
2013-02-02 22:00:19 +00:00
|
|
|
c.soundDirs.push_back( SoundDir( "/usr/share/WyabdcRealPeopleTTS", "WyabdcRealPeopleTTS" ) );
|
2009-04-09 14:15:01 +00:00
|
|
|
|
|
|
|
if ( QDir( "/usr/share/myspell/dicts" ).exists() )
|
|
|
|
c.hunspell.dictionariesPath = "/usr/share/myspell/dicts";
|
|
|
|
|
2009-04-03 23:40:39 +00:00
|
|
|
#endif
|
2009-01-28 20:55:45 +00:00
|
|
|
|
2009-04-03 23:40:39 +00:00
|
|
|
#ifdef Q_OS_WIN32
|
2009-04-18 18:16:04 +00:00
|
|
|
|
2009-04-30 21:47:42 +00:00
|
|
|
// get path to Program Files
|
|
|
|
wchar_t buf[ MAX_PATH ];
|
|
|
|
SHGetFolderPathW( NULL, CSIDL_PROGRAM_FILES, NULL, 0, buf );
|
|
|
|
QString pathToProgramFiles = QString::fromWCharArray( buf );
|
|
|
|
if ( pathToProgramFiles.isEmpty() )
|
|
|
|
pathToProgramFiles = "C:\\Program Files";
|
|
|
|
|
|
|
|
if ( QDir( pathToProgramFiles + "\\StarDict\\dic" ).exists() )
|
|
|
|
c.paths.push_back( Path( pathToProgramFiles + "\\StarDict\\dic", true ) );
|
|
|
|
|
|
|
|
if ( QDir( pathToProgramFiles + "\\StarDict\\WyabdcRealPeopleTTS" ).exists() )
|
2013-02-02 22:00:19 +00:00
|
|
|
c.soundDirs.push_back( SoundDir( pathToProgramFiles + "\\StarDict\\WyabdcRealPeopleTTS", "WyabdcRealPeopleTTS" ) );
|
2009-04-30 21:47:42 +00:00
|
|
|
else
|
|
|
|
if ( QDir( pathToProgramFiles + "\\WyabdcRealPeopleTTS" ).exists() )
|
2013-02-02 22:00:19 +00:00
|
|
|
c.soundDirs.push_back( SoundDir( pathToProgramFiles + "\\WyabdcRealPeopleTTS", "WyabdcRealPeopleTTS" ) );
|
2009-04-30 21:47:42 +00:00
|
|
|
|
2009-04-18 18:16:04 +00:00
|
|
|
// #### "C:/Program Files" is bad! will not work for German Windows etc.
|
|
|
|
// #### should be replaced to system path
|
|
|
|
|
2009-04-30 21:47:42 +00:00
|
|
|
// if ( QDir( "C:/Program Files/StarDict/dic" ).exists() )
|
|
|
|
// c.paths.push_back( Path( "C:/Program Files/StarDict/dic", true ) );
|
|
|
|
//
|
|
|
|
// if ( QDir( "C:/Program Files/StarDict/WyabdcRealPeopleTTS" ).exists() )
|
2013-02-02 22:00:19 +00:00
|
|
|
// c.soundDirs.push_back( SoundDir( "C:/Program Files/StarDict/WyabdcRealPeopleTTS", "WyabdcRealPeopleTTS" ) );
|
2009-04-30 21:47:42 +00:00
|
|
|
// else
|
|
|
|
// if ( QDir( "C:/Program Files/WyabdcRealPeopleTTS" ).exists() )
|
2013-02-02 22:00:19 +00:00
|
|
|
// c.soundDirs.push_back( SoundDir( "C:/Program Files/WyabdcRealPeopleTTS", "WyabdcRealPeopleTTS" ) );
|
2009-04-04 19:20:09 +00:00
|
|
|
|
2009-01-28 20:55:45 +00:00
|
|
|
#endif
|
|
|
|
|
2009-04-10 21:07:03 +00:00
|
|
|
#ifndef Q_OS_WIN32
|
|
|
|
c.preferences.audioPlaybackProgram = "mplayer";
|
|
|
|
#endif
|
|
|
|
|
2009-05-24 17:35:47 +00:00
|
|
|
QString possibleMorphologyPath = getProgramDataDir() + "/content/morphology";
|
|
|
|
|
|
|
|
if ( QDir( possibleMorphologyPath ).exists() )
|
|
|
|
c.hunspell.dictionariesPath = possibleMorphologyPath;
|
|
|
|
|
2009-03-27 10:48:44 +00:00
|
|
|
c.mediawikis = makeDefaultMediaWikis( true );
|
2009-05-16 18:04:21 +00:00
|
|
|
c.webSites = makeDefaultWebSites();
|
2014-04-30 12:55:53 +00:00
|
|
|
c.dictServers = makeDefaultDictServers();
|
2020-10-10 06:49:36 +00:00
|
|
|
c.programs = makeDefaultPrograms();
|
2009-03-26 19:00:08 +00:00
|
|
|
|
2009-04-23 13:43:51 +00:00
|
|
|
// Check if we have a template config file. If we do, load it instead
|
|
|
|
|
|
|
|
configName = getProgramDataDir() + "/content/defconfig";
|
|
|
|
loadFromTemplate = QFile( configName ).exists();
|
|
|
|
|
|
|
|
if ( !loadFromTemplate )
|
|
|
|
{
|
|
|
|
save( c );
|
2009-01-28 20:55:45 +00:00
|
|
|
|
2009-04-23 13:43:51 +00:00
|
|
|
return c;
|
|
|
|
}
|
2009-01-28 20:55:45 +00:00
|
|
|
}
|
|
|
|
|
2012-12-10 14:14:13 +00:00
|
|
|
getStylesDir();
|
|
|
|
|
2009-01-28 20:55:45 +00:00
|
|
|
QFile configFile( configName );
|
|
|
|
|
|
|
|
if ( !configFile.open( QFile::ReadOnly ) )
|
|
|
|
throw exCantReadConfigFile();
|
|
|
|
|
|
|
|
QDomDocument dd;
|
|
|
|
|
|
|
|
QString errorStr;
|
|
|
|
int errorLine, errorColumn;
|
|
|
|
|
2009-04-23 13:43:51 +00:00
|
|
|
if ( !loadFromTemplate )
|
2009-01-28 20:55:45 +00:00
|
|
|
{
|
2009-04-23 13:43:51 +00:00
|
|
|
// Load the config as usual
|
|
|
|
if ( !dd.setContent( &configFile, false, &errorStr, &errorLine, &errorColumn ) )
|
|
|
|
{
|
2014-05-10 21:02:31 +00:00
|
|
|
GD_DPRINTF( "Error: %s at %d,%d\n", errorStr.toLocal8Bit().constData(), errorLine, errorColumn );
|
2009-04-23 13:43:51 +00:00
|
|
|
throw exMalformedConfigFile();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// We need to replace all %PROGRAMDIR% with the program data dir
|
|
|
|
QByteArray data = configFile.readAll();
|
|
|
|
|
|
|
|
data.replace( "%PROGRAMDIR%", getProgramDataDir().toUtf8() );
|
|
|
|
|
|
|
|
QBuffer bufferedData( &data );
|
|
|
|
|
|
|
|
if ( !dd.setContent( &bufferedData, false, &errorStr, &errorLine, &errorColumn ) )
|
|
|
|
{
|
2014-05-10 21:02:31 +00:00
|
|
|
GD_DPRINTF( "Error: %s at %d,%d\n", errorStr.toLocal8Bit().constData(), errorLine, errorColumn );
|
2009-04-23 13:43:51 +00:00
|
|
|
throw exMalformedConfigFile();
|
|
|
|
}
|
2009-01-28 20:55:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
configFile.close();
|
|
|
|
|
|
|
|
QDomNode root = dd.namedItem( "config" );
|
|
|
|
|
|
|
|
Class c;
|
|
|
|
|
|
|
|
QDomNode paths = root.namedItem( "paths" );
|
|
|
|
|
|
|
|
if ( !paths.isNull() )
|
|
|
|
{
|
|
|
|
QDomNodeList nl = paths.toElement().elementsByTagName( "path" );
|
|
|
|
|
2013-05-30 15:05:41 +00:00
|
|
|
for( Qt4x5::Dom::size_type x = 0; x < nl.length(); ++x )
|
2009-03-28 22:37:03 +00:00
|
|
|
c.paths.push_back(
|
|
|
|
Path( nl.item( x ).toElement().text(),
|
|
|
|
nl.item( x ).toElement().attribute( "recursive" ) == "1" ) );
|
2009-01-28 20:55:45 +00:00
|
|
|
}
|
2009-04-18 18:16:04 +00:00
|
|
|
|
2009-04-04 16:06:06 +00:00
|
|
|
QDomNode soundDirs = root.namedItem( "sounddirs" );
|
|
|
|
|
|
|
|
if ( !soundDirs.isNull() )
|
|
|
|
{
|
|
|
|
QDomNodeList nl = soundDirs.toElement().elementsByTagName( "sounddir" );
|
|
|
|
|
2013-05-30 15:05:41 +00:00
|
|
|
for( Qt4x5::Dom::size_type x = 0; x < nl.length(); ++x )
|
2009-04-04 16:06:06 +00:00
|
|
|
c.soundDirs.push_back(
|
|
|
|
SoundDir( nl.item( x ).toElement().text(),
|
2013-02-02 18:25:24 +00:00
|
|
|
nl.item( x ).toElement().attribute( "name" ),
|
|
|
|
nl.item( x ).toElement().attribute( "icon" ) ) );
|
2009-04-04 16:06:06 +00:00
|
|
|
}
|
2009-01-28 20:55:45 +00:00
|
|
|
|
2009-05-16 15:22:02 +00:00
|
|
|
QDomNode dictionaryOrder = root.namedItem( "dictionaryOrder" );
|
|
|
|
|
|
|
|
if ( !dictionaryOrder.isNull() )
|
|
|
|
c.dictionaryOrder = loadGroup( dictionaryOrder.toElement() );
|
|
|
|
|
|
|
|
QDomNode inactiveDictionaries = root.namedItem( "inactiveDictionaries" );
|
|
|
|
|
|
|
|
if ( !inactiveDictionaries.isNull() )
|
|
|
|
c.inactiveDictionaries = loadGroup( inactiveDictionaries.toElement() );
|
|
|
|
|
2009-01-28 20:55:45 +00:00
|
|
|
QDomNode groups = root.namedItem( "groups" );
|
|
|
|
|
|
|
|
if ( !groups.isNull() )
|
|
|
|
{
|
2009-04-10 12:48:40 +00:00
|
|
|
c.groups.nextId = groups.toElement().attribute( "nextId", "1" ).toUInt();
|
|
|
|
|
2009-01-28 20:55:45 +00:00
|
|
|
QDomNodeList nl = groups.toElement().elementsByTagName( "group" );
|
|
|
|
|
2013-05-30 15:05:41 +00:00
|
|
|
for( Qt4x5::Dom::size_type x = 0; x < nl.length(); ++x )
|
2009-01-28 20:55:45 +00:00
|
|
|
{
|
|
|
|
QDomElement grp = nl.item( x ).toElement();
|
|
|
|
|
2009-05-16 15:22:02 +00:00
|
|
|
c.groups.push_back( loadGroup( grp, &c.groups.nextId ) );
|
2009-01-28 20:55:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-04-09 14:15:01 +00:00
|
|
|
QDomNode hunspell = root.namedItem( "hunspell" );
|
|
|
|
|
|
|
|
if ( !hunspell.isNull() )
|
|
|
|
{
|
|
|
|
c.hunspell.dictionariesPath = hunspell.toElement().attribute( "dictionariesPath" );
|
|
|
|
|
|
|
|
QDomNodeList nl = hunspell.toElement().elementsByTagName( "enabled" );
|
|
|
|
|
2013-05-30 15:05:41 +00:00
|
|
|
for( Qt4x5::Dom::size_type x = 0; x < nl.length(); ++x )
|
2009-04-09 14:15:01 +00:00
|
|
|
c.hunspell.enabledDictionaries.push_back( nl.item( x ).toElement().text() );
|
|
|
|
}
|
|
|
|
|
2009-05-06 14:39:08 +00:00
|
|
|
QDomNode transliteration = root.namedItem( "transliteration" );
|
2009-05-11 23:37:18 +00:00
|
|
|
|
2009-05-06 14:39:08 +00:00
|
|
|
if ( !transliteration.isNull() )
|
|
|
|
{
|
|
|
|
applyBoolOption( c.transliteration.enableRussianTransliteration,
|
|
|
|
transliteration.namedItem( "enableRussianTransliteration" ) );
|
2009-05-11 23:37:18 +00:00
|
|
|
|
|
|
|
applyBoolOption( c.transliteration.enableGermanTransliteration,
|
|
|
|
transliteration.namedItem( "enableGermanTransliteration" ) );
|
|
|
|
|
2010-05-29 09:22:08 +00:00
|
|
|
applyBoolOption( c.transliteration.enableGreekTransliteration,
|
|
|
|
transliteration.namedItem( "enableGreekTransliteration" ) );
|
|
|
|
|
2013-01-18 19:21:56 +00:00
|
|
|
applyBoolOption( c.transliteration.enableBelarusianTransliteration,
|
|
|
|
transliteration.namedItem( "enableBelarusianTransliteration" ) );
|
|
|
|
|
2015-10-25 13:54:38 +00:00
|
|
|
#ifdef MAKE_CHINESE_CONVERSION_SUPPORT
|
2015-10-19 13:52:23 +00:00
|
|
|
QDomNode chinese = transliteration.namedItem( "chinese" );
|
|
|
|
|
|
|
|
if ( !chinese.isNull() )
|
|
|
|
{
|
|
|
|
applyBoolOption( c.transliteration.chinese.enable, chinese.namedItem( "enable" ) );
|
2015-10-20 03:37:50 +00:00
|
|
|
applyBoolOption( c.transliteration.chinese.enableSCToTWConversion, chinese.namedItem( "enableSCToTWConversion" ) );
|
|
|
|
applyBoolOption( c.transliteration.chinese.enableSCToHKConversion, chinese.namedItem( "enableSCToHKConversion" ) );
|
|
|
|
applyBoolOption( c.transliteration.chinese.enableTCToSCConversion, chinese.namedItem( "enableTCToSCConversion" ) );
|
2015-10-19 13:52:23 +00:00
|
|
|
}
|
2015-10-25 13:54:38 +00:00
|
|
|
#endif
|
2015-10-19 13:52:23 +00:00
|
|
|
|
2009-05-06 14:39:08 +00:00
|
|
|
QDomNode romaji = transliteration.namedItem( "romaji" );
|
|
|
|
|
|
|
|
if ( !romaji.isNull() )
|
|
|
|
{
|
|
|
|
applyBoolOption( c.transliteration.romaji.enable, romaji.namedItem( "enable" ) );
|
|
|
|
applyBoolOption( c.transliteration.romaji.enableHepburn, romaji.namedItem( "enableHepburn" ) );
|
|
|
|
applyBoolOption( c.transliteration.romaji.enableNihonShiki, romaji.namedItem( "enableNihonShiki" ) );
|
|
|
|
applyBoolOption( c.transliteration.romaji.enableKunreiShiki, romaji.namedItem( "enableKunreiShiki" ) );
|
|
|
|
applyBoolOption( c.transliteration.romaji.enableHiragana, romaji.namedItem( "enableHiragana" ) );
|
|
|
|
applyBoolOption( c.transliteration.romaji.enableKatakana, romaji.namedItem( "enableKatakana" ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-06-12 20:16:35 +00:00
|
|
|
QDomNode forvo = root.namedItem( "forvo" );
|
|
|
|
|
|
|
|
if ( !forvo.isNull() )
|
|
|
|
{
|
|
|
|
applyBoolOption( c.forvo.enable,
|
|
|
|
forvo.namedItem( "enable" ) );
|
|
|
|
|
|
|
|
c.forvo.apiKey = forvo.namedItem( "apiKey" ).toElement().text();
|
|
|
|
c.forvo.languageCodes = forvo.namedItem( "languageCodes" ).toElement().text();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
c.forvo.languageCodes = "en, ru"; // Default demo values
|
|
|
|
|
2011-05-29 05:08:37 +00:00
|
|
|
QDomNode programs = root.namedItem( "programs" );
|
|
|
|
|
|
|
|
if ( !programs.isNull() )
|
|
|
|
{
|
|
|
|
QDomNodeList nl = programs.toElement().elementsByTagName( "program" );
|
|
|
|
|
2013-05-30 15:05:41 +00:00
|
|
|
for( Qt4x5::Dom::size_type x = 0; x < nl.length(); ++x )
|
2011-05-29 05:08:37 +00:00
|
|
|
{
|
|
|
|
QDomElement pr = nl.item( x ).toElement();
|
|
|
|
|
|
|
|
Program p;
|
|
|
|
|
|
|
|
p.id = pr.attribute( "id" );
|
|
|
|
p.name = pr.attribute( "name" );
|
|
|
|
p.commandLine = pr.attribute( "commandLine" );
|
|
|
|
p.enabled = ( pr.attribute( "enabled" ) == "1" );
|
|
|
|
p.type = (Program::Type)( pr.attribute( "type" ).toInt() );
|
2012-12-07 11:59:59 +00:00
|
|
|
p.iconFilename = pr.attribute( "icon" );
|
2011-05-29 05:08:37 +00:00
|
|
|
|
|
|
|
c.programs.push_back( p );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2020-10-10 06:49:36 +00:00
|
|
|
{
|
2011-05-29 05:08:37 +00:00
|
|
|
c.programs = makeDefaultPrograms();
|
2020-10-10 06:49:36 +00:00
|
|
|
}
|
2011-05-29 05:08:37 +00:00
|
|
|
|
2009-03-26 19:00:08 +00:00
|
|
|
QDomNode mws = root.namedItem( "mediawikis" );
|
|
|
|
|
|
|
|
if ( !mws.isNull() )
|
|
|
|
{
|
|
|
|
QDomNodeList nl = mws.toElement().elementsByTagName( "mediawiki" );
|
|
|
|
|
2013-05-30 15:05:41 +00:00
|
|
|
for( Qt4x5::Dom::size_type x = 0; x < nl.length(); ++x )
|
2009-03-26 19:00:08 +00:00
|
|
|
{
|
|
|
|
QDomElement mw = nl.item( x ).toElement();
|
|
|
|
|
|
|
|
MediaWiki w;
|
|
|
|
|
|
|
|
w.id = mw.attribute( "id" );
|
|
|
|
w.name = mw.attribute( "name" );
|
|
|
|
w.url = mw.attribute( "url" );
|
|
|
|
w.enabled = ( mw.attribute( "enabled" ) == "1" );
|
2012-06-21 09:43:28 +00:00
|
|
|
w.icon = mw.attribute( "icon" );
|
2009-03-26 19:00:08 +00:00
|
|
|
|
|
|
|
c.mediawikis.push_back( w );
|
|
|
|
}
|
|
|
|
}
|
2009-03-27 10:48:44 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
// When upgrading, populate the list with some choices, but don't enable
|
|
|
|
// anything.
|
|
|
|
c.mediawikis = makeDefaultMediaWikis( false );
|
|
|
|
}
|
2009-03-26 19:00:08 +00:00
|
|
|
|
2009-05-16 18:04:21 +00:00
|
|
|
QDomNode wss = root.namedItem( "websites" );
|
|
|
|
|
|
|
|
if ( !wss.isNull() )
|
|
|
|
{
|
|
|
|
QDomNodeList nl = wss.toElement().elementsByTagName( "website" );
|
|
|
|
|
2013-05-30 15:05:41 +00:00
|
|
|
for( Qt4x5::Dom::size_type x = 0; x < nl.length(); ++x )
|
2009-05-16 18:04:21 +00:00
|
|
|
{
|
|
|
|
QDomElement ws = nl.item( x ).toElement();
|
|
|
|
|
|
|
|
WebSite w;
|
|
|
|
|
|
|
|
w.id = ws.attribute( "id" );
|
|
|
|
w.name = ws.attribute( "name" );
|
|
|
|
w.url = ws.attribute( "url" );
|
|
|
|
w.enabled = ( ws.attribute( "enabled" ) == "1" );
|
2012-12-03 12:48:31 +00:00
|
|
|
w.iconFilename = ws.attribute( "icon" );
|
2016-06-17 14:27:48 +00:00
|
|
|
w.inside_iframe = ( ws.attribute( "inside_iframe", "1" ) == "1" );
|
2009-05-16 18:04:21 +00:00
|
|
|
|
|
|
|
c.webSites.push_back( w );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Upgrading
|
|
|
|
c.webSites = makeDefaultWebSites();
|
|
|
|
}
|
|
|
|
|
2014-04-30 12:55:53 +00:00
|
|
|
QDomNode dss = root.namedItem( "dictservers" );
|
|
|
|
|
|
|
|
if ( !dss.isNull() )
|
|
|
|
{
|
|
|
|
QDomNodeList nl = dss.toElement().elementsByTagName( "server" );
|
|
|
|
|
2014-05-12 14:11:12 +00:00
|
|
|
for( Qt4x5::Dom::size_type x = 0; x < nl.length(); ++x )
|
2014-04-30 12:55:53 +00:00
|
|
|
{
|
|
|
|
QDomElement ds = nl.item( x ).toElement();
|
|
|
|
|
|
|
|
DictServer d;
|
|
|
|
|
|
|
|
d.id = ds.attribute( "id" );
|
|
|
|
d.name = ds.attribute( "name" );
|
|
|
|
d.url = ds.attribute( "url" );
|
|
|
|
d.enabled = ( ds.attribute( "enabled" ) == "1" );
|
|
|
|
d.databases = ds.attribute( "databases" );
|
2014-05-03 17:41:16 +00:00
|
|
|
d.strategies = ds.attribute( "strategies" );
|
2014-04-30 12:55:53 +00:00
|
|
|
d.iconFilename = ds.attribute( "icon" );
|
|
|
|
|
|
|
|
c.dictServers.push_back( d );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Upgrading
|
|
|
|
c.dictServers = makeDefaultDictServers();
|
|
|
|
}
|
|
|
|
|
2013-04-24 14:52:04 +00:00
|
|
|
QDomNode ves = root.namedItem( "voiceEngines" );
|
|
|
|
|
2013-04-26 13:41:39 +00:00
|
|
|
if ( !ves.isNull() )
|
2013-04-24 14:52:04 +00:00
|
|
|
{
|
|
|
|
QDomNodeList nl = ves.toElement().elementsByTagName( "voiceEngine" );
|
|
|
|
|
2013-05-30 15:05:41 +00:00
|
|
|
for ( Qt4x5::Dom::size_type x = 0; x < nl.length(); ++x )
|
2013-04-24 14:52:04 +00:00
|
|
|
{
|
|
|
|
QDomElement ve = nl.item( x ).toElement();
|
|
|
|
VoiceEngine v;
|
|
|
|
|
|
|
|
v.enabled = ve.attribute( "enabled" ) == "1";
|
|
|
|
v.id = ve.attribute( "id" );
|
|
|
|
v.name = ve.attribute( "name" );
|
|
|
|
v.iconFilename = ve.attribute( "icon" );
|
2013-04-26 13:41:39 +00:00
|
|
|
v.volume = ve.attribute( "volume", "50" ).toInt();
|
|
|
|
if( v.volume < 0 || v.volume > 100 )
|
|
|
|
v.volume = 50;
|
|
|
|
v.rate = ve.attribute( "rate", "50" ).toInt();
|
|
|
|
if( v.rate < 0 || v.rate > 100 )
|
|
|
|
v.rate = 50;
|
2013-04-24 14:52:04 +00:00
|
|
|
c.voiceEngines.push_back( v );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-03-30 20:15:55 +00:00
|
|
|
c.mutedDictionaries = loadMutedDictionaries( root.namedItem( "mutedDictionaries" ) );
|
|
|
|
c.popupMutedDictionaries = loadMutedDictionaries( root.namedItem( "popupMutedDictionaries" ) );
|
2009-09-21 17:50:03 +00:00
|
|
|
|
2009-02-05 20:55:00 +00:00
|
|
|
QDomNode preferences = root.namedItem( "preferences" );
|
|
|
|
|
|
|
|
if ( !preferences.isNull() )
|
|
|
|
{
|
2009-04-12 20:46:25 +00:00
|
|
|
c.preferences.interfaceLanguage = preferences.namedItem( "interfaceLanguage" ).toElement().text();
|
2014-06-25 14:01:11 +00:00
|
|
|
c.preferences.helpLanguage = preferences.namedItem( "helpLanguage" ).toElement().text();
|
2009-05-11 11:03:36 +00:00
|
|
|
c.preferences.displayStyle = preferences.namedItem( "displayStyle" ).toElement().text();
|
2009-04-13 12:51:25 +00:00
|
|
|
c.preferences.newTabsOpenAfterCurrentOne = ( preferences.namedItem( "newTabsOpenAfterCurrentOne" ).toElement().text() == "1" );
|
|
|
|
c.preferences.newTabsOpenInBackground = ( preferences.namedItem( "newTabsOpenInBackground" ).toElement().text() == "1" );
|
2011-06-23 14:17:09 +00:00
|
|
|
c.preferences.hideSingleTab = ( preferences.namedItem( "hideSingleTab" ).toElement().text() == "1" );
|
2011-11-02 23:37:50 +00:00
|
|
|
c.preferences.mruTabOrder = ( preferences.namedItem( "mruTabOrder" ).toElement().text() == "1" );
|
2011-06-26 11:53:28 +00:00
|
|
|
c.preferences.hideMenubar = ( preferences.namedItem( "hideMenubar" ).toElement().text() == "1" );
|
2009-02-05 20:55:00 +00:00
|
|
|
c.preferences.enableTrayIcon = ( preferences.namedItem( "enableTrayIcon" ).toElement().text() == "1" );
|
|
|
|
c.preferences.startToTray = ( preferences.namedItem( "startToTray" ).toElement().text() == "1" );
|
|
|
|
c.preferences.closeToTray = ( preferences.namedItem( "closeToTray" ).toElement().text() == "1" );
|
2009-04-18 18:16:04 +00:00
|
|
|
c.preferences.autoStart = ( preferences.namedItem( "autoStart" ).toElement().text() == "1" );
|
2012-12-29 11:19:49 +00:00
|
|
|
c.preferences.alwaysOnTop = ( preferences.namedItem( "alwaysOnTop" ).toElement().text() == "1" );
|
2013-01-05 11:26:55 +00:00
|
|
|
c.preferences.searchInDock = ( preferences.namedItem( "searchInDock" ).toElement().text() == "1" );
|
2009-04-21 18:27:26 +00:00
|
|
|
|
2010-04-08 20:37:59 +00:00
|
|
|
if ( !preferences.namedItem( "doubleClickTranslates" ).isNull() )
|
|
|
|
c.preferences.doubleClickTranslates = ( preferences.namedItem( "doubleClickTranslates" ).toElement().text() == "1" );
|
|
|
|
|
2012-09-26 13:59:48 +00:00
|
|
|
if ( !preferences.namedItem( "selectWordBySingleClick" ).isNull() )
|
|
|
|
c.preferences.selectWordBySingleClick = ( preferences.namedItem( "selectWordBySingleClick" ).toElement().text() == "1" );
|
|
|
|
|
2011-05-07 13:42:49 +00:00
|
|
|
if ( !preferences.namedItem( "escKeyHidesMainWindow" ).isNull() )
|
|
|
|
c.preferences.escKeyHidesMainWindow = ( preferences.namedItem( "escKeyHidesMainWindow" ).toElement().text() == "1" );
|
|
|
|
|
2009-04-30 19:57:25 +00:00
|
|
|
if ( !preferences.namedItem( "zoomFactor" ).isNull() )
|
|
|
|
c.preferences.zoomFactor = preferences.namedItem( "zoomFactor" ).toElement().text().toDouble();
|
|
|
|
|
2014-06-23 15:11:15 +00:00
|
|
|
if ( !preferences.namedItem( "helpZoomFactor" ).isNull() )
|
|
|
|
c.preferences.helpZoomFactor = preferences.namedItem( "helpZoomFactor" ).toElement().text().toDouble();
|
|
|
|
|
2010-07-02 11:19:02 +00:00
|
|
|
if ( !preferences.namedItem( "wordsZoomLevel" ).isNull() )
|
|
|
|
c.preferences.wordsZoomLevel = preferences.namedItem( "wordsZoomLevel" ).toElement().text().toInt();
|
|
|
|
|
2009-04-21 18:27:26 +00:00
|
|
|
applyBoolOption( c.preferences.enableMainWindowHotkey, preferences.namedItem( "enableMainWindowHotkey" ) );
|
|
|
|
if ( !preferences.namedItem( "mainWindowHotkey" ).isNull() )
|
|
|
|
c.preferences.mainWindowHotkey = QKeySequence::fromString( preferences.namedItem( "mainWindowHotkey" ).toElement().text() );
|
|
|
|
applyBoolOption( c.preferences.enableClipboardHotkey, preferences.namedItem( "enableClipboardHotkey" ) );
|
|
|
|
if ( !preferences.namedItem( "clipboardHotkey" ).isNull() )
|
|
|
|
c.preferences.clipboardHotkey = QKeySequence::fromString( preferences.namedItem( "clipboardHotkey" ).toElement().text() );
|
|
|
|
|
2009-02-05 20:55:00 +00:00
|
|
|
c.preferences.enableScanPopup = ( preferences.namedItem( "enableScanPopup" ).toElement().text() == "1" );
|
2009-02-08 20:20:02 +00:00
|
|
|
c.preferences.startWithScanPopupOn = ( preferences.namedItem( "startWithScanPopupOn" ).toElement().text() == "1" );
|
2009-02-05 20:55:00 +00:00
|
|
|
c.preferences.enableScanPopupModifiers = ( preferences.namedItem( "enableScanPopupModifiers" ).toElement().text() == "1" );
|
2009-04-03 17:10:27 +00:00
|
|
|
c.preferences.scanPopupModifiers = ( preferences.namedItem( "scanPopupModifiers" ).toElement().text().toULong() );
|
2009-04-11 16:44:14 +00:00
|
|
|
c.preferences.scanPopupAltMode = ( preferences.namedItem( "scanPopupAltMode" ).toElement().text() == "1" );
|
|
|
|
if ( !preferences.namedItem( "scanPopupAltModeSecs" ).isNull() )
|
|
|
|
c.preferences.scanPopupAltModeSecs = preferences.namedItem( "scanPopupAltModeSecs" ).toElement().text().toUInt();
|
2018-04-16 12:23:22 +00:00
|
|
|
c.preferences.ignoreOwnClipboardChanges = ( preferences.namedItem( "ignoreOwnClipboardChanges" ).toElement().text() == "1" );
|
2011-11-16 12:52:25 +00:00
|
|
|
c.preferences.scanToMainWindow = ( preferences.namedItem( "scanToMainWindow" ).toElement().text() == "1" );
|
2018-06-13 16:00:42 +00:00
|
|
|
c.preferences.ignoreDiacritics = ( preferences.namedItem( "ignoreDiacritics" ).toElement().text() == "1" );
|
2017-06-05 13:15:38 +00:00
|
|
|
#ifdef HAVE_X11
|
|
|
|
c.preferences.showScanFlag= ( preferences.namedItem( "showScanFlag" ).toElement().text() == "1" );
|
|
|
|
#endif
|
2011-07-09 19:26:30 +00:00
|
|
|
c.preferences.scanPopupUseUIAutomation = ( preferences.namedItem( "scanPopupUseUIAutomation" ).toElement().text() == "1" );
|
|
|
|
c.preferences.scanPopupUseIAccessibleEx = ( preferences.namedItem( "scanPopupUseIAccessibleEx" ).toElement().text() == "1" );
|
|
|
|
c.preferences.scanPopupUseGDMessage = ( preferences.namedItem( "scanPopupUseGDMessage" ).toElement().text() == "1" );
|
Allow customizing unpinned scan popup window flags on X11 with Qt5
My tests in many desktop environments and window managers indicate that
no single configuration works perfectly in all environments. There are
also behavior differences between Qt::Popup and Qt::Tool flags, which
are not exactly bugs, so I suppose users might subjectively prefer
different options.
Customizing the flags allows the user to prevent unpinned scan popup
window flickering with Qt5 on Linux. In a way adding these options fixes
issue #645, which is: the scan popup window blinks rapidly, barely
noticeably in some applications, such as Calibre ebook-viewer
and Chromium. In this case the scan popup window usually ends up hidden
when selection ends, unless it was finished with a jerk.
I have tested the new options in 9 desktop environments and window
managers: at least one configuration for each eliminates #645 and makes
the scan popup window work the same as with Qt4 in this regard:
the popup window remains visible, text in the popup's translation line
keeps up with the text selection in the external application,
and the selected text is being translated on the fly.
Moreover, for each tested DE/WM, at least one configuration makes
the scan popup window work perfectly as far as I am concerned.
This issue was partially worked around with a 200ms scan popup delay
timer in the recent commit 58e41fe3ceb769cab37608e36637044e597ba1f8
for the duplicate issue #854. However the timer solution is incomplete
because it requires the user to select text quickly and without delays.
If global mouse selection does not change for 200ms while the left mouse
button is held down, the user will likely not see the scan popup when
(s)he finishes selection, and will have to try selecting again -
hopefully faster this time.
The 200ms delay is no longer critically important after this commit,
but it is still beneficial: the lookup query changes less often,
which in turn reduces article definition update frequency.
So the delay improves the UI (perhaps subjectively) and performance.
2018-04-09 17:50:23 +00:00
|
|
|
c.preferences.scanPopupUnpinnedWindowFlags = spwfFromInt( preferences.namedItem( "scanPopupUnpinnedWindowFlags" ).toElement().text().toInt() );
|
|
|
|
c.preferences.scanPopupUnpinnedBypassWMHint = ( preferences.namedItem( "scanPopupUnpinnedBypassWMHint" ).toElement().text() == "1" );
|
2009-04-03 17:10:27 +00:00
|
|
|
|
2009-04-10 21:07:03 +00:00
|
|
|
c.preferences.pronounceOnLoadMain = ( preferences.namedItem( "pronounceOnLoadMain" ).toElement().text() == "1" );
|
|
|
|
c.preferences.pronounceOnLoadPopup = ( preferences.namedItem( "pronounceOnLoadPopup" ).toElement().text() == "1" );
|
2013-04-24 14:52:04 +00:00
|
|
|
|
2018-03-29 17:00:53 +00:00
|
|
|
if ( InternalPlayerBackend::anyAvailable() )
|
|
|
|
{
|
|
|
|
if ( !preferences.namedItem( "useInternalPlayer" ).isNull() )
|
|
|
|
c.preferences.useInternalPlayer = ( preferences.namedItem( "useInternalPlayer" ).toElement().text() == "1" );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
c.preferences.useInternalPlayer = false;
|
|
|
|
|
|
|
|
if ( !preferences.namedItem( "internalPlayerBackend" ).isNull() )
|
|
|
|
c.preferences.internalPlayerBackend.setUiName( preferences.namedItem( "internalPlayerBackend" ).toElement().text() );
|
2012-11-23 12:43:36 +00:00
|
|
|
|
2009-04-10 21:07:03 +00:00
|
|
|
if ( !preferences.namedItem( "audioPlaybackProgram" ).isNull() )
|
|
|
|
c.preferences.audioPlaybackProgram = preferences.namedItem( "audioPlaybackProgram" ).toElement().text();
|
|
|
|
else
|
|
|
|
c.preferences.audioPlaybackProgram = "mplayer";
|
|
|
|
|
2009-04-03 17:10:27 +00:00
|
|
|
QDomNode proxy = preferences.namedItem( "proxyserver" );
|
|
|
|
|
|
|
|
if ( !proxy.isNull() )
|
|
|
|
{
|
|
|
|
c.preferences.proxyServer.enabled = ( proxy.toElement().attribute( "enabled" ) == "1" );
|
2014-04-01 17:00:13 +00:00
|
|
|
c.preferences.proxyServer.useSystemProxy = ( proxy.toElement().attribute( "useSystemProxy" ) == "1" );
|
2009-04-03 17:10:27 +00:00
|
|
|
c.preferences.proxyServer.type = ( ProxyServer::Type ) proxy.namedItem( "type" ).toElement().text().toULong();
|
|
|
|
c.preferences.proxyServer.host = proxy.namedItem( "host" ).toElement().text();
|
|
|
|
c.preferences.proxyServer.port = proxy.namedItem( "port" ).toElement().text().toULong();
|
|
|
|
c.preferences.proxyServer.user = proxy.namedItem( "user" ).toElement().text();
|
|
|
|
c.preferences.proxyServer.password = proxy.namedItem( "password" ).toElement().text();
|
2014-04-03 14:21:02 +00:00
|
|
|
c.preferences.proxyServer.systemProxyUser = proxy.namedItem( "systemProxyUser" ).toElement().text();
|
|
|
|
c.preferences.proxyServer.systemProxyPassword = proxy.namedItem( "systemProxyPassword" ).toElement().text();
|
2009-04-03 17:10:27 +00:00
|
|
|
}
|
2009-04-20 19:54:34 +00:00
|
|
|
|
|
|
|
if ( !preferences.namedItem( "checkForNewReleases" ).isNull() )
|
|
|
|
c.preferences.checkForNewReleases = ( preferences.namedItem( "checkForNewReleases" ).toElement().text() == "1" );
|
2009-08-31 12:18:08 +00:00
|
|
|
|
|
|
|
if ( !preferences.namedItem( "disallowContentFromOtherSites" ).isNull() )
|
|
|
|
c.preferences.disallowContentFromOtherSites = ( preferences.namedItem( "disallowContentFromOtherSites" ).toElement().text() == "1" );
|
2011-05-08 21:19:08 +00:00
|
|
|
|
|
|
|
if ( !preferences.namedItem( "enableWebPlugins" ).isNull() )
|
|
|
|
c.preferences.enableWebPlugins = ( preferences.namedItem( "enableWebPlugins" ).toElement().text() == "1" );
|
2012-02-16 14:56:25 +00:00
|
|
|
|
2013-04-08 12:20:12 +00:00
|
|
|
if ( !preferences.namedItem( "hideGoldenDictHeader" ).isNull() )
|
|
|
|
c.preferences.hideGoldenDictHeader = ( preferences.namedItem( "hideGoldenDictHeader" ).toElement().text() == "1" );
|
|
|
|
|
2012-02-16 14:56:25 +00:00
|
|
|
if ( !preferences.namedItem( "maxStringsInHistory" ).isNull() )
|
|
|
|
c.preferences.maxStringsInHistory = preferences.namedItem( "maxStringsInHistory" ).toElement().text().toUInt() ;
|
2012-09-10 18:00:29 +00:00
|
|
|
|
2012-09-11 13:03:10 +00:00
|
|
|
if ( !preferences.namedItem( "storeHistory" ).isNull() )
|
|
|
|
c.preferences.storeHistory = preferences.namedItem( "storeHistory" ).toElement().text().toUInt() ;
|
2012-09-16 10:19:47 +00:00
|
|
|
|
|
|
|
if ( !preferences.namedItem( "alwaysExpandOptionalParts" ).isNull() )
|
|
|
|
c.preferences.alwaysExpandOptionalParts = preferences.namedItem( "alwaysExpandOptionalParts" ).toElement().text().toUInt() ;
|
2012-12-10 14:14:13 +00:00
|
|
|
|
|
|
|
if ( !preferences.namedItem( "addonStyle" ).isNull() )
|
|
|
|
c.preferences.addonStyle = preferences.namedItem( "addonStyle" ).toElement().text();
|
2013-02-05 12:51:23 +00:00
|
|
|
|
|
|
|
if ( !preferences.namedItem( "historyStoreInterval" ).isNull() )
|
|
|
|
c.preferences.historyStoreInterval = preferences.namedItem( "historyStoreInterval" ).toElement().text().toUInt() ;
|
2013-06-02 11:20:33 +00:00
|
|
|
|
2017-05-13 10:18:25 +00:00
|
|
|
if ( !preferences.namedItem( "favoritesStoreInterval" ).isNull() )
|
|
|
|
c.preferences.favoritesStoreInterval = preferences.namedItem( "favoritesStoreInterval" ).toElement().text().toUInt() ;
|
|
|
|
|
2017-05-17 15:26:32 +00:00
|
|
|
if ( !preferences.namedItem( "confirmFavoritesDeletion" ).isNull() )
|
|
|
|
c.preferences.confirmFavoritesDeletion = ( preferences.namedItem( "confirmFavoritesDeletion" ).toElement().text() == "1" );
|
|
|
|
|
2013-06-02 11:20:33 +00:00
|
|
|
if ( !preferences.namedItem( "collapseBigArticles" ).isNull() )
|
|
|
|
c.preferences.collapseBigArticles = ( preferences.namedItem( "collapseBigArticles" ).toElement().text() == "1" );
|
|
|
|
|
|
|
|
if ( !preferences.namedItem( "articleSizeLimit" ).isNull() )
|
2020-11-06 19:51:44 +00:00
|
|
|
c.preferences.articleSizeLimit = preferences.namedItem( "articleSizeLimit" ).toElement().text().toInt();
|
2013-06-11 18:31:01 +00:00
|
|
|
|
|
|
|
if ( !preferences.namedItem( "maxDictionaryRefsInContextMenu" ).isNull() )
|
|
|
|
c.preferences.maxDictionaryRefsInContextMenu = preferences.namedItem( "maxDictionaryRefsInContextMenu" ).toElement().text().toUShort();
|
2014-01-09 14:17:50 +00:00
|
|
|
|
|
|
|
#ifndef Q_WS_X11
|
|
|
|
if ( !preferences.namedItem( "trackClipboardChanges" ).isNull() )
|
|
|
|
c.preferences.trackClipboardChanges = ( preferences.namedItem( "trackClipboardChanges" ).toElement().text() == "1" );
|
|
|
|
#endif
|
2014-04-17 14:31:51 +00:00
|
|
|
|
2017-03-09 16:11:17 +00:00
|
|
|
if ( !preferences.namedItem( "synonymSearchEnabled" ).isNull() )
|
|
|
|
c.preferences.synonymSearchEnabled = ( preferences.namedItem( "synonymSearchEnabled" ).toElement().text() == "1" );
|
|
|
|
|
2014-04-17 14:31:51 +00:00
|
|
|
QDomNode fts = preferences.namedItem( "fullTextSearch" );
|
|
|
|
|
|
|
|
if ( !fts.isNull() )
|
|
|
|
{
|
|
|
|
if ( !fts.namedItem( "searchMode" ).isNull() )
|
|
|
|
c.preferences.fts.searchMode = fts.namedItem( "searchMode" ).toElement().text().toInt();
|
|
|
|
|
|
|
|
if ( !fts.namedItem( "matchCase" ).isNull() )
|
|
|
|
c.preferences.fts.matchCase = ( fts.namedItem( "matchCase" ).toElement().text() == "1" );
|
|
|
|
|
|
|
|
if ( !fts.namedItem( "maxArticlesPerDictionary" ).isNull() )
|
|
|
|
c.preferences.fts.maxArticlesPerDictionary = fts.namedItem( "maxArticlesPerDictionary" ).toElement().text().toInt();
|
|
|
|
|
|
|
|
if ( !fts.namedItem( "maxDistanceBetweenWords" ).isNull() )
|
|
|
|
c.preferences.fts.maxDistanceBetweenWords = fts.namedItem( "maxDistanceBetweenWords" ).toElement().text().toInt();
|
|
|
|
|
|
|
|
if ( !fts.namedItem( "useMaxArticlesPerDictionary" ).isNull() )
|
|
|
|
c.preferences.fts.useMaxArticlesPerDictionary = ( fts.namedItem( "useMaxArticlesPerDictionary" ).toElement().text() == "1" );
|
|
|
|
|
|
|
|
if ( !fts.namedItem( "useMaxDistanceBetweenWords" ).isNull() )
|
|
|
|
c.preferences.fts.useMaxDistanceBetweenWords = ( fts.namedItem( "useMaxDistanceBetweenWords" ).toElement().text() == "1" );
|
|
|
|
|
|
|
|
if ( !fts.namedItem( "dialogGeometry" ).isNull() )
|
|
|
|
c.preferences.fts.dialogGeometry = QByteArray::fromBase64( fts.namedItem( "dialogGeometry" ).toElement().text().toLatin1() );
|
|
|
|
|
|
|
|
if( !fts.namedItem( "disabledTypes" ).isNull() )
|
|
|
|
c.preferences.fts.disabledTypes = fts.namedItem( "disabledTypes" ).toElement().text();
|
|
|
|
|
|
|
|
if ( !fts.namedItem( "enabled" ).isNull() )
|
2014-05-21 14:15:18 +00:00
|
|
|
c.preferences.fts.enabled = ( fts.namedItem( "enabled" ).toElement().text() == "1" );
|
2014-04-17 14:31:51 +00:00
|
|
|
|
2017-07-25 15:28:29 +00:00
|
|
|
if ( !fts.namedItem( "ignoreWordsOrder" ).isNull() )
|
|
|
|
c.preferences.fts.ignoreWordsOrder = ( fts.namedItem( "ignoreWordsOrder" ).toElement().text() == "1" );
|
|
|
|
|
2018-04-10 14:49:52 +00:00
|
|
|
if ( !fts.namedItem( "ignoreDiacritics" ).isNull() )
|
|
|
|
c.preferences.fts.ignoreDiacritics = ( fts.namedItem( "ignoreDiacritics" ).toElement().text() == "1" );
|
|
|
|
|
2014-04-17 14:31:51 +00:00
|
|
|
if ( !fts.namedItem( "maxDictionarySize" ).isNull() )
|
|
|
|
c.preferences.fts.maxDictionarySize = fts.namedItem( "maxDictionarySize" ).toElement().text().toUInt();
|
|
|
|
}
|
|
|
|
|
2009-02-05 20:55:00 +00:00
|
|
|
}
|
|
|
|
|
2009-04-10 12:48:40 +00:00
|
|
|
c.lastMainGroupId = root.namedItem( "lastMainGroupId" ).toElement().text().toUInt();
|
|
|
|
c.lastPopupGroupId = root.namedItem( "lastPopupGroupId" ).toElement().text().toUInt();
|
2009-02-06 17:04:11 +00:00
|
|
|
|
2010-03-30 20:15:55 +00:00
|
|
|
QDomNode popupWindowState = root.namedItem( "popupWindowState" );
|
2009-02-06 17:16:33 +00:00
|
|
|
|
2010-03-30 20:15:55 +00:00
|
|
|
if ( !popupWindowState.isNull() )
|
|
|
|
c.popupWindowState = QByteArray::fromBase64( popupWindowState.toElement().text().toLatin1() );
|
|
|
|
|
|
|
|
QDomNode popupWindowGeometry = root.namedItem( "popupWindowGeometry" );
|
|
|
|
|
|
|
|
if ( !popupWindowGeometry.isNull() )
|
|
|
|
c.popupWindowGeometry = QByteArray::fromBase64( popupWindowGeometry.toElement().text().toLatin1() );
|
2009-02-06 17:16:33 +00:00
|
|
|
|
2011-05-01 23:52:11 +00:00
|
|
|
c.pinPopupWindow = ( root.namedItem( "pinPopupWindow" ).toElement().text() == "1" );
|
|
|
|
|
2017-07-13 15:00:19 +00:00
|
|
|
c.popupWindowAlwaysOnTop = ( root.namedItem( "popupWindowAlwaysOnTop" ).toElement().text() == "1" );
|
|
|
|
|
2009-04-03 21:24:07 +00:00
|
|
|
QDomNode mainWindowState = root.namedItem( "mainWindowState" );
|
|
|
|
|
|
|
|
if ( !mainWindowState.isNull() )
|
|
|
|
c.mainWindowState = QByteArray::fromBase64( mainWindowState.toElement().text().toLatin1() );
|
|
|
|
|
|
|
|
QDomNode mainWindowGeometry = root.namedItem( "mainWindowGeometry" );
|
|
|
|
|
|
|
|
if ( !mainWindowGeometry.isNull() )
|
|
|
|
c.mainWindowGeometry = QByteArray::fromBase64( mainWindowGeometry.toElement().text().toLatin1() );
|
|
|
|
|
2014-06-23 15:11:15 +00:00
|
|
|
QDomNode helpWindowGeometry = root.namedItem( "helpWindowGeometry" );
|
|
|
|
|
|
|
|
if ( !helpWindowGeometry.isNull() )
|
|
|
|
c.helpWindowGeometry = QByteArray::fromBase64( helpWindowGeometry.toElement().text().toLatin1() );
|
|
|
|
|
|
|
|
QDomNode helpSplitterState = root.namedItem( "helpSplitterState" );
|
|
|
|
|
|
|
|
if ( !helpSplitterState.isNull() )
|
|
|
|
c.helpSplitterState = QByteArray::fromBase64( helpSplitterState.toElement().text().toLatin1() );
|
|
|
|
|
2013-02-04 14:10:37 +00:00
|
|
|
#ifdef Q_OS_WIN
|
2013-01-29 19:20:53 +00:00
|
|
|
QDomNode maximizedMainWindowGeometry = root.namedItem( "maximizedMainWindowGeometry" );
|
|
|
|
|
|
|
|
if ( !maximizedMainWindowGeometry.isNull() )
|
|
|
|
{
|
|
|
|
int x = 0, y = 0, width = 0, height = 0;
|
|
|
|
if( !maximizedMainWindowGeometry.namedItem( "x" ).isNull() )
|
|
|
|
x = maximizedMainWindowGeometry.namedItem( "x" ).toElement().text().toInt();
|
|
|
|
if( !maximizedMainWindowGeometry.namedItem( "y" ).isNull() )
|
|
|
|
y = maximizedMainWindowGeometry.namedItem( "y" ).toElement().text().toInt();
|
|
|
|
if( !maximizedMainWindowGeometry.namedItem( "width" ).isNull() )
|
|
|
|
width = maximizedMainWindowGeometry.namedItem( "width" ).toElement().text().toInt();
|
|
|
|
if( !maximizedMainWindowGeometry.namedItem( "height" ).isNull() )
|
|
|
|
height = maximizedMainWindowGeometry.namedItem( "height" ).toElement().text().toInt();
|
|
|
|
c.maximizedMainWindowGeometry = QRect( x, y, width, height );
|
|
|
|
}
|
2013-12-20 14:25:33 +00:00
|
|
|
|
|
|
|
QDomNode normalMainWindowGeometry = root.namedItem( "normalMainWindowGeometry" );
|
|
|
|
|
|
|
|
if ( !normalMainWindowGeometry.isNull() )
|
|
|
|
{
|
|
|
|
int x = 0, y = 0, width = 0, height = 0;
|
|
|
|
if( !normalMainWindowGeometry.namedItem( "x" ).isNull() )
|
|
|
|
x = normalMainWindowGeometry.namedItem( "x" ).toElement().text().toInt();
|
|
|
|
if( !normalMainWindowGeometry.namedItem( "y" ).isNull() )
|
|
|
|
y = normalMainWindowGeometry.namedItem( "y" ).toElement().text().toInt();
|
|
|
|
if( !normalMainWindowGeometry.namedItem( "width" ).isNull() )
|
|
|
|
width = normalMainWindowGeometry.namedItem( "width" ).toElement().text().toInt();
|
|
|
|
if( !normalMainWindowGeometry.namedItem( "height" ).isNull() )
|
|
|
|
height = normalMainWindowGeometry.namedItem( "height" ).toElement().text().toInt();
|
|
|
|
c.normalMainWindowGeometry = QRect( x, y, width, height );
|
|
|
|
}
|
2013-02-04 14:10:37 +00:00
|
|
|
#endif
|
2013-01-29 19:20:53 +00:00
|
|
|
|
2012-09-27 13:00:40 +00:00
|
|
|
QDomNode dictInfoGeometry = root.namedItem( "dictInfoGeometry" );
|
|
|
|
|
|
|
|
if ( !dictInfoGeometry.isNull() )
|
|
|
|
c.dictInfoGeometry = QByteArray::fromBase64( dictInfoGeometry.toElement().text().toLatin1() );
|
|
|
|
|
2013-05-30 02:18:28 +00:00
|
|
|
QDomNode inspectorGeometry = root.namedItem( "inspectorGeometry" );
|
|
|
|
|
|
|
|
if ( !inspectorGeometry.isNull() )
|
|
|
|
c.inspectorGeometry = QByteArray::fromBase64( inspectorGeometry.toElement().text().toLatin1() );
|
|
|
|
|
2009-04-20 19:54:34 +00:00
|
|
|
QDomNode timeForNewReleaseCheck = root.namedItem( "timeForNewReleaseCheck" );
|
|
|
|
|
|
|
|
if ( !timeForNewReleaseCheck.isNull() )
|
|
|
|
c.timeForNewReleaseCheck = QDateTime::fromString( timeForNewReleaseCheck.toElement().text(),
|
|
|
|
Qt::ISODate );
|
|
|
|
|
2009-05-14 17:59:49 +00:00
|
|
|
c.skippedRelease = root.namedItem( "skippedRelease" ).toElement().text();
|
|
|
|
|
2009-10-12 12:41:20 +00:00
|
|
|
c.showingDictBarNames = ( root.namedItem( "showingDictBarNames" ).toElement().text() == "1" );
|
|
|
|
|
2011-05-22 02:42:05 +00:00
|
|
|
c.usingSmallIconsInToolbars = ( root.namedItem( "usingSmallIconsInToolbars" ).toElement().text() == "1" );
|
|
|
|
|
2012-09-12 17:19:21 +00:00
|
|
|
if ( !root.namedItem( "historyExportPath" ).isNull() )
|
|
|
|
c.historyExportPath = root.namedItem( "historyExportPath" ).toElement().text();
|
|
|
|
|
2013-02-22 12:44:23 +00:00
|
|
|
if ( !root.namedItem( "resourceSavePath" ).isNull() )
|
|
|
|
c.resourceSavePath = root.namedItem( "resourceSavePath" ).toElement().text();
|
|
|
|
|
2013-04-12 06:57:41 +00:00
|
|
|
if ( !root.namedItem( "articleSavePath" ).isNull() )
|
|
|
|
c.articleSavePath = root.namedItem( "articleSavePath" ).toElement().text();
|
|
|
|
|
2012-11-28 19:32:37 +00:00
|
|
|
if ( !root.namedItem( "editDictionaryCommandLine" ).isNull() )
|
|
|
|
c.editDictionaryCommandLine = root.namedItem( "editDictionaryCommandLine" ).toElement().text();
|
|
|
|
|
2012-12-07 11:59:29 +00:00
|
|
|
if ( !root.namedItem( "maxPictureWidth" ).isNull() )
|
|
|
|
c.maxPictureWidth = root.namedItem( "maxPictureWidth" ).toElement().text().toInt();
|
|
|
|
|
2013-01-11 09:58:14 +00:00
|
|
|
if ( !root.namedItem( "maxHeadwordSize" ).isNull() )
|
|
|
|
{
|
|
|
|
unsigned int value = root.namedItem( "maxHeadwordSize" ).toElement().text().toUInt();
|
|
|
|
if ( value != 0 ) // 0 is invalid value for our purposes
|
|
|
|
{
|
|
|
|
c.maxHeadwordSize = value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-25 14:37:39 +00:00
|
|
|
if ( !root.namedItem( "maxHeadwordsToExpand" ).isNull() )
|
|
|
|
c.maxHeadwordsToExpand = root.namedItem( "maxHeadwordsToExpand" ).toElement().text().toUInt();
|
|
|
|
|
2014-02-28 12:36:28 +00:00
|
|
|
QDomNode headwordsDialog = root.namedItem( "headwordsDialog" );
|
|
|
|
|
|
|
|
if ( !headwordsDialog.isNull() )
|
|
|
|
{
|
|
|
|
if ( !headwordsDialog.namedItem( "searchMode" ).isNull() )
|
2014-04-16 16:18:28 +00:00
|
|
|
c.headwordsDialog.searchMode = headwordsDialog.namedItem( "searchMode" ).toElement().text().toInt();
|
2014-02-28 12:36:28 +00:00
|
|
|
|
|
|
|
if ( !headwordsDialog.namedItem( "matchCase" ).isNull() )
|
|
|
|
c.headwordsDialog.matchCase = ( headwordsDialog.namedItem( "matchCase" ).toElement().text() == "1" );
|
|
|
|
|
|
|
|
if ( !headwordsDialog.namedItem( "autoApply" ).isNull() )
|
|
|
|
c.headwordsDialog.autoApply = ( headwordsDialog.namedItem( "autoApply" ).toElement().text() == "1" );
|
|
|
|
|
|
|
|
if ( !headwordsDialog.namedItem( "headwordsExportPath" ).isNull() )
|
|
|
|
c.headwordsDialog.headwordsExportPath = headwordsDialog.namedItem( "headwordsExportPath" ).toElement().text();
|
|
|
|
|
|
|
|
if ( !headwordsDialog.namedItem( "headwordsDialogGeometry" ).isNull() )
|
|
|
|
c.headwordsDialog.headwordsDialogGeometry = QByteArray::fromBase64( headwordsDialog.namedItem( "headwordsDialogGeometry" ).toElement().text().toLatin1() );
|
|
|
|
}
|
|
|
|
|
2009-01-28 20:55:45 +00:00
|
|
|
return c;
|
|
|
|
}
|
|
|
|
|
2009-05-16 15:22:02 +00:00
|
|
|
namespace {
|
|
|
|
void saveGroup( Group const & data, QDomElement & group )
|
|
|
|
{
|
|
|
|
QDomDocument dd = group.ownerDocument();
|
|
|
|
|
|
|
|
QDomAttr id = dd.createAttribute( "id" );
|
|
|
|
|
|
|
|
id.setValue( QString::number( data.id ) );
|
|
|
|
|
|
|
|
group.setAttributeNode( id );
|
|
|
|
|
|
|
|
QDomAttr name = dd.createAttribute( "name" );
|
|
|
|
|
|
|
|
name.setValue( data.name );
|
|
|
|
|
|
|
|
group.setAttributeNode( name );
|
|
|
|
|
2017-05-05 14:39:51 +00:00
|
|
|
if( data.favoritesFolder.size() )
|
|
|
|
{
|
|
|
|
QDomAttr folder = dd.createAttribute( "favoritesFolder" );
|
|
|
|
folder.setValue( data.favoritesFolder );
|
|
|
|
group.setAttributeNode( folder );
|
|
|
|
}
|
|
|
|
|
2009-05-16 15:22:02 +00:00
|
|
|
if ( data.icon.size() )
|
|
|
|
{
|
|
|
|
QDomAttr icon = dd.createAttribute( "icon" );
|
|
|
|
|
|
|
|
icon.setValue( data.icon );
|
|
|
|
|
|
|
|
group.setAttributeNode( icon );
|
|
|
|
}
|
|
|
|
|
2010-07-05 18:36:03 +00:00
|
|
|
if ( data.iconData.size() )
|
|
|
|
{
|
|
|
|
QDomAttr iconData = dd.createAttribute( "iconData" );
|
|
|
|
|
2013-02-03 20:19:55 +00:00
|
|
|
iconData.setValue( QString::fromLatin1( data.iconData.toBase64() ) );
|
2010-07-05 18:36:03 +00:00
|
|
|
|
|
|
|
group.setAttributeNode( iconData );
|
|
|
|
}
|
|
|
|
|
2010-07-05 14:13:29 +00:00
|
|
|
if ( !data.shortcut.isEmpty() )
|
|
|
|
{
|
|
|
|
QDomAttr shortcut = dd.createAttribute( "shortcut" );
|
|
|
|
|
|
|
|
shortcut.setValue( data.shortcut.toString() );
|
|
|
|
|
|
|
|
group.setAttributeNode( shortcut );
|
|
|
|
}
|
|
|
|
|
2012-12-10 12:49:45 +00:00
|
|
|
for( QVector< DictionaryRef >::const_iterator j = data.dictionaries.begin(); j != data.dictionaries.end(); ++j )
|
2009-05-16 15:22:02 +00:00
|
|
|
{
|
|
|
|
QDomElement dictionary = dd.createElement( "dictionary" );
|
|
|
|
|
|
|
|
group.appendChild( dictionary );
|
|
|
|
|
|
|
|
QDomText value = dd.createTextNode( j->id );
|
|
|
|
|
|
|
|
dictionary.appendChild( value );
|
|
|
|
|
|
|
|
QDomAttr name = dd.createAttribute( "name" );
|
|
|
|
|
|
|
|
name.setValue( j->name );
|
|
|
|
|
|
|
|
dictionary.setAttributeNode( name );
|
|
|
|
}
|
2012-09-26 13:13:47 +00:00
|
|
|
|
|
|
|
QDomElement muted = dd.createElement( "mutedDictionaries" );
|
|
|
|
group.appendChild( muted );
|
|
|
|
|
|
|
|
for( MutedDictionaries::const_iterator i = data.mutedDictionaries.begin();
|
|
|
|
i != data.mutedDictionaries.end(); ++i )
|
|
|
|
{
|
|
|
|
QDomElement dict = dd.createElement( "mutedDictionary" );
|
|
|
|
muted.appendChild( dict );
|
|
|
|
|
|
|
|
QDomText value = dd.createTextNode( *i );
|
|
|
|
dict.appendChild( value );
|
|
|
|
}
|
|
|
|
|
|
|
|
for( MutedDictionaries::const_iterator i = data.popupMutedDictionaries.begin();
|
|
|
|
i != data.popupMutedDictionaries.end(); ++i )
|
|
|
|
{
|
|
|
|
QDomElement dict = dd.createElement( "popupMutedDictionary" );
|
|
|
|
muted.appendChild( dict );
|
|
|
|
|
|
|
|
QDomText value = dd.createTextNode( *i );
|
|
|
|
dict.appendChild( value );
|
|
|
|
}
|
2009-05-16 15:22:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-05-21 15:32:04 +00:00
|
|
|
void save( Class const & c ) THROW_SPEC( exError )
|
2009-01-28 20:55:45 +00:00
|
|
|
{
|
2009-10-18 11:01:13 +00:00
|
|
|
QFile configFile( getConfigFileName() + ".tmp" );
|
2009-01-28 20:55:45 +00:00
|
|
|
|
|
|
|
if ( !configFile.open( QFile::WriteOnly ) )
|
|
|
|
throw exCantWriteConfigFile();
|
|
|
|
|
|
|
|
QDomDocument dd;
|
|
|
|
|
|
|
|
QDomElement root = dd.createElement( "config" );
|
|
|
|
dd.appendChild( root );
|
|
|
|
|
|
|
|
{
|
|
|
|
QDomElement paths = dd.createElement( "paths" );
|
|
|
|
root.appendChild( paths );
|
2009-04-18 18:16:04 +00:00
|
|
|
|
2009-01-28 20:55:45 +00:00
|
|
|
for( Paths::const_iterator i = c.paths.begin(); i != c.paths.end(); ++i )
|
|
|
|
{
|
|
|
|
QDomElement path = dd.createElement( "path" );
|
|
|
|
paths.appendChild( path );
|
2009-03-28 22:37:03 +00:00
|
|
|
|
|
|
|
QDomAttr recursive = dd.createAttribute( "recursive" );
|
|
|
|
recursive.setValue( i->recursive ? "1" : "0" );
|
|
|
|
path.setAttributeNode( recursive );
|
|
|
|
|
|
|
|
QDomText value = dd.createTextNode( i->path );
|
2009-04-18 18:16:04 +00:00
|
|
|
|
2009-01-28 20:55:45 +00:00
|
|
|
path.appendChild( value );
|
|
|
|
}
|
|
|
|
}
|
2009-04-18 18:16:04 +00:00
|
|
|
|
2009-04-04 16:06:06 +00:00
|
|
|
{
|
|
|
|
QDomElement soundDirs = dd.createElement( "sounddirs" );
|
|
|
|
root.appendChild( soundDirs );
|
|
|
|
|
|
|
|
for( SoundDirs::const_iterator i = c.soundDirs.begin(); i != c.soundDirs.end(); ++i )
|
|
|
|
{
|
|
|
|
QDomElement soundDir = dd.createElement( "sounddir" );
|
|
|
|
soundDirs.appendChild( soundDir );
|
|
|
|
|
|
|
|
QDomAttr name = dd.createAttribute( "name" );
|
|
|
|
name.setValue( i->name );
|
|
|
|
soundDir.setAttributeNode( name );
|
|
|
|
|
2013-02-02 18:25:24 +00:00
|
|
|
QDomAttr icon = dd.createAttribute( "icon" );
|
|
|
|
icon.setValue( i->iconFilename );
|
|
|
|
soundDir.setAttributeNode( icon );
|
|
|
|
|
2009-04-04 16:06:06 +00:00
|
|
|
QDomText value = dd.createTextNode( i->path );
|
|
|
|
|
|
|
|
soundDir.appendChild( value );
|
|
|
|
}
|
|
|
|
}
|
2009-01-28 20:55:45 +00:00
|
|
|
|
2009-05-16 15:22:02 +00:00
|
|
|
{
|
|
|
|
QDomElement dictionaryOrder = dd.createElement( "dictionaryOrder" );
|
|
|
|
root.appendChild( dictionaryOrder );
|
|
|
|
saveGroup( c.dictionaryOrder, dictionaryOrder );
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
QDomElement inactiveDictionaries = dd.createElement( "inactiveDictionaries" );
|
|
|
|
root.appendChild( inactiveDictionaries );
|
|
|
|
saveGroup( c.inactiveDictionaries, inactiveDictionaries );
|
|
|
|
}
|
|
|
|
|
2009-01-28 20:55:45 +00:00
|
|
|
{
|
|
|
|
QDomElement groups = dd.createElement( "groups" );
|
|
|
|
root.appendChild( groups );
|
|
|
|
|
2009-04-10 12:48:40 +00:00
|
|
|
QDomAttr nextId = dd.createAttribute( "nextId" );
|
|
|
|
nextId.setValue( QString::number( c.groups.nextId ) );
|
|
|
|
groups.setAttributeNode( nextId );
|
|
|
|
|
2009-01-28 20:55:45 +00:00
|
|
|
for( Groups::const_iterator i = c.groups.begin(); i != c.groups.end(); ++i )
|
|
|
|
{
|
|
|
|
QDomElement group = dd.createElement( "group" );
|
|
|
|
groups.appendChild( group );
|
|
|
|
|
2009-05-16 15:22:02 +00:00
|
|
|
saveGroup( *i, group );
|
2009-01-28 20:55:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-04-09 14:15:01 +00:00
|
|
|
{
|
|
|
|
QDomElement hunspell = dd.createElement( "hunspell" );
|
|
|
|
QDomAttr path = dd.createAttribute( "dictionariesPath" );
|
|
|
|
path.setValue( c.hunspell.dictionariesPath );
|
|
|
|
hunspell.setAttributeNode( path );
|
|
|
|
root.appendChild( hunspell );
|
|
|
|
|
2012-12-10 12:49:45 +00:00
|
|
|
for( int x = 0; x < c.hunspell.enabledDictionaries.size(); ++x )
|
2009-04-09 14:15:01 +00:00
|
|
|
{
|
|
|
|
QDomElement en = dd.createElement( "enabled" );
|
2012-12-10 12:49:45 +00:00
|
|
|
QDomText value = dd.createTextNode( c.hunspell.enabledDictionaries.at( x ) );
|
2009-04-09 14:15:01 +00:00
|
|
|
|
|
|
|
en.appendChild( value );
|
|
|
|
hunspell.appendChild( en );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-06 14:39:08 +00:00
|
|
|
{
|
2009-05-11 23:37:18 +00:00
|
|
|
// Russian translit
|
|
|
|
|
2009-05-06 14:39:08 +00:00
|
|
|
QDomElement transliteration = dd.createElement( "transliteration" );
|
|
|
|
root.appendChild( transliteration );
|
|
|
|
|
|
|
|
QDomElement opt = dd.createElement( "enableRussianTransliteration" );
|
|
|
|
opt.appendChild( dd.createTextNode( c.transliteration.enableRussianTransliteration ? "1":"0" ) );
|
|
|
|
transliteration.appendChild( opt );
|
|
|
|
|
2009-05-11 23:37:18 +00:00
|
|
|
// German translit
|
|
|
|
|
|
|
|
opt = dd.createElement( "enableGermanTransliteration" );
|
|
|
|
opt.appendChild( dd.createTextNode( c.transliteration.enableGermanTransliteration ? "1":"0" ) );
|
2009-05-12 17:33:33 +00:00
|
|
|
transliteration.appendChild( opt );
|
2009-05-11 23:37:18 +00:00
|
|
|
|
2010-05-29 09:22:08 +00:00
|
|
|
// Greek translit
|
|
|
|
|
|
|
|
opt = dd.createElement( "enableGreekTransliteration" );
|
|
|
|
opt.appendChild( dd.createTextNode( c.transliteration.enableGreekTransliteration ? "1":"0" ) );
|
|
|
|
transliteration.appendChild( opt );
|
|
|
|
|
2013-01-18 19:21:56 +00:00
|
|
|
// Belarusian translit
|
|
|
|
|
|
|
|
opt = dd.createElement( "enableBelarusianTransliteration" );
|
|
|
|
opt.appendChild( dd.createTextNode( c.transliteration.enableBelarusianTransliteration ? "1":"0" ) );
|
|
|
|
transliteration.appendChild( opt );
|
|
|
|
|
2015-10-25 13:54:38 +00:00
|
|
|
#ifdef MAKE_CHINESE_CONVERSION_SUPPORT
|
2015-10-19 13:52:23 +00:00
|
|
|
// Chinese
|
|
|
|
|
|
|
|
QDomElement chinese = dd.createElement( "chinese" );
|
|
|
|
transliteration.appendChild( chinese );
|
|
|
|
|
|
|
|
opt = dd.createElement( "enable" );
|
|
|
|
opt.appendChild( dd.createTextNode( c.transliteration.chinese.enable ? "1":"0" ) );
|
|
|
|
chinese.appendChild( opt );
|
|
|
|
|
2015-10-20 03:37:50 +00:00
|
|
|
opt = dd.createElement( "enableSCToTWConversion" );
|
|
|
|
opt.appendChild( dd.createTextNode( c.transliteration.chinese.enableSCToTWConversion ? "1":"0" ) );
|
2015-10-19 13:52:23 +00:00
|
|
|
chinese.appendChild( opt );
|
|
|
|
|
2015-10-20 03:37:50 +00:00
|
|
|
opt = dd.createElement( "enableSCToHKConversion" );
|
|
|
|
opt.appendChild( dd.createTextNode( c.transliteration.chinese.enableSCToHKConversion ? "1":"0" ) );
|
|
|
|
chinese.appendChild( opt );
|
|
|
|
|
|
|
|
opt = dd.createElement( "enableTCToSCConversion" );
|
|
|
|
opt.appendChild( dd.createTextNode( c.transliteration.chinese.enableTCToSCConversion ? "1":"0" ) );
|
2015-10-19 13:52:23 +00:00
|
|
|
chinese.appendChild( opt );
|
2015-10-25 13:54:38 +00:00
|
|
|
#endif
|
2015-10-19 13:52:23 +00:00
|
|
|
|
2009-05-11 23:37:18 +00:00
|
|
|
// Romaji
|
|
|
|
|
2009-05-06 14:39:08 +00:00
|
|
|
QDomElement romaji = dd.createElement( "romaji" );
|
|
|
|
transliteration.appendChild( romaji );
|
|
|
|
|
|
|
|
opt = dd.createElement( "enable" );
|
|
|
|
opt.appendChild( dd.createTextNode( c.transliteration.romaji.enable ? "1":"0" ) );
|
|
|
|
romaji.appendChild( opt );
|
2009-05-11 23:37:18 +00:00
|
|
|
|
2009-05-06 14:39:08 +00:00
|
|
|
opt = dd.createElement( "enableHepburn" );
|
|
|
|
opt.appendChild( dd.createTextNode( c.transliteration.romaji.enableHepburn ? "1":"0" ) );
|
|
|
|
romaji.appendChild( opt );
|
2009-05-11 23:37:18 +00:00
|
|
|
|
2009-05-06 14:39:08 +00:00
|
|
|
opt = dd.createElement( "enableNihonShiki" );
|
|
|
|
opt.appendChild( dd.createTextNode( c.transliteration.romaji.enableNihonShiki ? "1":"0" ) );
|
|
|
|
romaji.appendChild( opt );
|
2009-05-11 23:37:18 +00:00
|
|
|
|
2009-05-06 14:39:08 +00:00
|
|
|
opt = dd.createElement( "enableKunreiShiki" );
|
2009-05-11 23:37:18 +00:00
|
|
|
opt.appendChild( dd.createTextNode( c.transliteration.romaji.enableKunreiShiki ? "1":"0" ) );
|
2009-05-06 14:39:08 +00:00
|
|
|
romaji.appendChild( opt );
|
2009-05-11 23:37:18 +00:00
|
|
|
|
2009-05-06 14:39:08 +00:00
|
|
|
opt = dd.createElement( "enableHiragana" );
|
|
|
|
opt.appendChild( dd.createTextNode( c.transliteration.romaji.enableHiragana ? "1":"0" ) );
|
|
|
|
romaji.appendChild( opt );
|
2009-05-11 23:37:18 +00:00
|
|
|
|
2009-05-06 14:39:08 +00:00
|
|
|
opt = dd.createElement( "enableKatakana" );
|
|
|
|
opt.appendChild( dd.createTextNode( c.transliteration.romaji.enableKatakana ? "1":"0" ) );
|
|
|
|
romaji.appendChild( opt );
|
2010-06-12 20:16:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
// Forvo
|
|
|
|
|
|
|
|
QDomElement forvo = dd.createElement( "forvo" );
|
|
|
|
root.appendChild( forvo );
|
|
|
|
|
|
|
|
QDomElement opt = dd.createElement( "enable" );
|
|
|
|
opt.appendChild( dd.createTextNode( c.forvo.enable ? "1":"0" ) );
|
|
|
|
forvo.appendChild( opt );
|
|
|
|
|
|
|
|
opt = dd.createElement( "apiKey" );
|
|
|
|
opt.appendChild( dd.createTextNode( c.forvo.apiKey ) );
|
|
|
|
forvo.appendChild( opt );
|
|
|
|
|
|
|
|
opt = dd.createElement( "languageCodes" );
|
|
|
|
opt.appendChild( dd.createTextNode( c.forvo.languageCodes ) );
|
|
|
|
forvo.appendChild( opt );
|
2009-05-06 14:39:08 +00:00
|
|
|
}
|
2009-05-11 23:37:18 +00:00
|
|
|
|
2009-03-26 19:00:08 +00:00
|
|
|
{
|
|
|
|
QDomElement mws = dd.createElement( "mediawikis" );
|
|
|
|
root.appendChild( mws );
|
|
|
|
|
|
|
|
for( MediaWikis::const_iterator i = c.mediawikis.begin(); i != c.mediawikis.end(); ++i )
|
|
|
|
{
|
|
|
|
QDomElement mw = dd.createElement( "mediawiki" );
|
|
|
|
mws.appendChild( mw );
|
|
|
|
|
|
|
|
QDomAttr id = dd.createAttribute( "id" );
|
|
|
|
id.setValue( i->id );
|
|
|
|
mw.setAttributeNode( id );
|
|
|
|
|
|
|
|
QDomAttr name = dd.createAttribute( "name" );
|
|
|
|
name.setValue( i->name );
|
|
|
|
mw.setAttributeNode( name );
|
|
|
|
|
|
|
|
QDomAttr url = dd.createAttribute( "url" );
|
|
|
|
url.setValue( i->url );
|
|
|
|
mw.setAttributeNode( url );
|
|
|
|
|
|
|
|
QDomAttr enabled = dd.createAttribute( "enabled" );
|
|
|
|
enabled.setValue( i->enabled ? "1" : "0" );
|
|
|
|
mw.setAttributeNode( enabled );
|
2012-06-21 09:43:28 +00:00
|
|
|
|
|
|
|
QDomAttr icon = dd.createAttribute( "icon" );
|
|
|
|
icon.setValue( i->icon );
|
|
|
|
mw.setAttributeNode( icon );
|
2009-03-26 19:00:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-16 18:04:21 +00:00
|
|
|
{
|
|
|
|
QDomElement wss = dd.createElement( "websites" );
|
|
|
|
root.appendChild( wss );
|
|
|
|
|
|
|
|
for( WebSites::const_iterator i = c.webSites.begin(); i != c.webSites.end(); ++i )
|
|
|
|
{
|
|
|
|
QDomElement ws = dd.createElement( "website" );
|
|
|
|
wss.appendChild( ws );
|
|
|
|
|
|
|
|
QDomAttr id = dd.createAttribute( "id" );
|
|
|
|
id.setValue( i->id );
|
|
|
|
ws.setAttributeNode( id );
|
|
|
|
|
|
|
|
QDomAttr name = dd.createAttribute( "name" );
|
|
|
|
name.setValue( i->name );
|
|
|
|
ws.setAttributeNode( name );
|
|
|
|
|
|
|
|
QDomAttr url = dd.createAttribute( "url" );
|
|
|
|
url.setValue( i->url );
|
|
|
|
ws.setAttributeNode( url );
|
|
|
|
|
|
|
|
QDomAttr enabled = dd.createAttribute( "enabled" );
|
|
|
|
enabled.setValue( i->enabled ? "1" : "0" );
|
|
|
|
ws.setAttributeNode( enabled );
|
2012-12-03 12:48:31 +00:00
|
|
|
|
|
|
|
QDomAttr icon = dd.createAttribute( "icon" );
|
|
|
|
icon.setValue( i->iconFilename );
|
|
|
|
ws.setAttributeNode( icon );
|
2016-06-17 14:27:48 +00:00
|
|
|
|
|
|
|
QDomAttr inside_iframe = dd.createAttribute( "inside_iframe" );
|
|
|
|
inside_iframe.setValue( i->inside_iframe ? "1" : "0" );
|
|
|
|
ws.setAttributeNode( inside_iframe );
|
2009-05-16 18:04:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-04-30 12:55:53 +00:00
|
|
|
{
|
|
|
|
QDomElement dss = dd.createElement( "dictservers" );
|
|
|
|
root.appendChild( dss );
|
|
|
|
|
|
|
|
for( DictServers::const_iterator i = c.dictServers.begin(); i != c.dictServers.end(); ++i )
|
|
|
|
{
|
|
|
|
QDomElement ds = dd.createElement( "server" );
|
|
|
|
dss.appendChild( ds );
|
|
|
|
|
|
|
|
QDomAttr id = dd.createAttribute( "id" );
|
|
|
|
id.setValue( i->id );
|
|
|
|
ds.setAttributeNode( id );
|
|
|
|
|
|
|
|
QDomAttr name = dd.createAttribute( "name" );
|
|
|
|
name.setValue( i->name );
|
|
|
|
ds.setAttributeNode( name );
|
|
|
|
|
|
|
|
QDomAttr url = dd.createAttribute( "url" );
|
|
|
|
url.setValue( i->url );
|
|
|
|
ds.setAttributeNode( url );
|
|
|
|
|
|
|
|
QDomAttr enabled = dd.createAttribute( "enabled" );
|
|
|
|
enabled.setValue( i->enabled ? "1" : "0" );
|
|
|
|
ds.setAttributeNode( enabled );
|
|
|
|
|
|
|
|
QDomAttr databases = dd.createAttribute( "databases" );
|
|
|
|
databases.setValue( i->databases );
|
|
|
|
ds.setAttributeNode( databases );
|
|
|
|
|
2014-05-03 17:41:16 +00:00
|
|
|
QDomAttr strategies = dd.createAttribute( "strategies" );
|
|
|
|
strategies.setValue( i->strategies );
|
|
|
|
ds.setAttributeNode( strategies );
|
|
|
|
|
2014-04-30 12:55:53 +00:00
|
|
|
QDomAttr icon = dd.createAttribute( "icon" );
|
|
|
|
icon.setValue( i->iconFilename );
|
|
|
|
ds.setAttributeNode( icon );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-05-29 05:08:37 +00:00
|
|
|
{
|
|
|
|
QDomElement programs = dd.createElement( "programs" );
|
|
|
|
root.appendChild( programs );
|
|
|
|
|
|
|
|
for( Programs::const_iterator i = c.programs.begin(); i != c.programs.end(); ++i )
|
|
|
|
{
|
|
|
|
QDomElement p = dd.createElement( "program" );
|
|
|
|
programs.appendChild( p );
|
|
|
|
|
|
|
|
QDomAttr id = dd.createAttribute( "id" );
|
|
|
|
id.setValue( i->id );
|
|
|
|
p.setAttributeNode( id );
|
|
|
|
|
|
|
|
QDomAttr name = dd.createAttribute( "name" );
|
|
|
|
name.setValue( i->name );
|
|
|
|
p.setAttributeNode( name );
|
|
|
|
|
|
|
|
QDomAttr commandLine = dd.createAttribute( "commandLine" );
|
|
|
|
commandLine.setValue( i->commandLine );
|
|
|
|
p.setAttributeNode( commandLine );
|
|
|
|
|
|
|
|
QDomAttr enabled = dd.createAttribute( "enabled" );
|
|
|
|
enabled.setValue( i->enabled ? "1" : "0" );
|
|
|
|
p.setAttributeNode( enabled );
|
|
|
|
|
|
|
|
QDomAttr type = dd.createAttribute( "type" );
|
|
|
|
type.setValue( QString::number( i->type ) );
|
|
|
|
p.setAttributeNode( type );
|
2012-12-07 11:59:59 +00:00
|
|
|
|
|
|
|
QDomAttr icon = dd.createAttribute( "icon" );
|
|
|
|
icon.setValue( i->iconFilename );
|
|
|
|
p.setAttributeNode( icon );
|
2011-05-29 05:08:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-04-24 14:52:04 +00:00
|
|
|
{
|
|
|
|
QDomNode ves = dd.createElement( "voiceEngines" );
|
|
|
|
root.appendChild( ves );
|
|
|
|
|
|
|
|
for ( VoiceEngines::const_iterator i = c.voiceEngines.begin(); i != c.voiceEngines.end(); ++i )
|
|
|
|
{
|
|
|
|
QDomElement v = dd.createElement( "voiceEngine" );
|
|
|
|
ves.appendChild( v );
|
|
|
|
|
|
|
|
QDomAttr id = dd.createAttribute( "id" );
|
|
|
|
id.setValue( i->id );
|
|
|
|
v.setAttributeNode( id );
|
|
|
|
|
|
|
|
QDomAttr name = dd.createAttribute( "name" );
|
|
|
|
name.setValue( i->name );
|
|
|
|
v.setAttributeNode( name );
|
|
|
|
|
|
|
|
QDomAttr enabled = dd.createAttribute( "enabled" );
|
|
|
|
enabled.setValue( i->enabled ? "1" : "0" );
|
|
|
|
v.setAttributeNode( enabled );
|
|
|
|
|
|
|
|
QDomAttr icon = dd.createAttribute( "icon" );
|
|
|
|
icon.setValue( i->iconFilename );
|
|
|
|
v.setAttributeNode( icon );
|
2013-04-26 13:41:39 +00:00
|
|
|
|
|
|
|
QDomAttr volume = dd.createAttribute( "volume" );
|
|
|
|
volume.setValue( QString::number( i->volume ) );
|
|
|
|
v.setAttributeNode( volume );
|
|
|
|
|
|
|
|
QDomAttr rate = dd.createAttribute( "rate" );
|
|
|
|
rate.setValue( QString::number( i->rate ) );
|
|
|
|
v.setAttributeNode( rate );
|
2013-04-24 14:52:04 +00:00
|
|
|
}
|
|
|
|
}
|
2010-03-30 20:15:55 +00:00
|
|
|
|
2009-09-21 17:50:03 +00:00
|
|
|
{
|
|
|
|
QDomElement muted = dd.createElement( "mutedDictionaries" );
|
|
|
|
root.appendChild( muted );
|
2010-03-30 20:15:55 +00:00
|
|
|
saveMutedDictionaries( dd, muted, c.mutedDictionaries );
|
|
|
|
}
|
2009-09-21 17:50:03 +00:00
|
|
|
|
2010-03-30 20:15:55 +00:00
|
|
|
{
|
|
|
|
QDomElement muted = dd.createElement( "popupMutedDictionaries" );
|
|
|
|
root.appendChild( muted );
|
|
|
|
saveMutedDictionaries( dd, muted, c.popupMutedDictionaries );
|
2009-09-21 17:50:03 +00:00
|
|
|
}
|
|
|
|
|
2009-02-05 20:55:00 +00:00
|
|
|
{
|
|
|
|
QDomElement preferences = dd.createElement( "preferences" );
|
|
|
|
root.appendChild( preferences );
|
|
|
|
|
2009-04-12 20:46:25 +00:00
|
|
|
QDomElement opt = dd.createElement( "interfaceLanguage" );
|
|
|
|
opt.appendChild( dd.createTextNode( c.preferences.interfaceLanguage ) );
|
|
|
|
preferences.appendChild( opt );
|
|
|
|
|
2014-06-25 14:01:11 +00:00
|
|
|
opt = dd.createElement( "helpLanguage" );
|
|
|
|
opt.appendChild( dd.createTextNode( c.preferences.helpLanguage ) );
|
|
|
|
preferences.appendChild( opt );
|
|
|
|
|
2009-05-11 11:03:36 +00:00
|
|
|
opt = dd.createElement( "displayStyle" );
|
|
|
|
opt.appendChild( dd.createTextNode( c.preferences.displayStyle ) );
|
|
|
|
preferences.appendChild( opt );
|
|
|
|
|
2009-04-13 12:51:25 +00:00
|
|
|
opt = dd.createElement( "newTabsOpenAfterCurrentOne" );
|
|
|
|
opt.appendChild( dd.createTextNode( c.preferences.newTabsOpenAfterCurrentOne ? "1":"0" ) );
|
|
|
|
preferences.appendChild( opt );
|
|
|
|
|
|
|
|
opt = dd.createElement( "newTabsOpenInBackground" );
|
|
|
|
opt.appendChild( dd.createTextNode( c.preferences.newTabsOpenInBackground ? "1":"0" ) );
|
|
|
|
preferences.appendChild( opt );
|
|
|
|
|
2011-06-23 14:17:09 +00:00
|
|
|
opt = dd.createElement( "hideSingleTab" );
|
|
|
|
opt.appendChild( dd.createTextNode( c.preferences.hideSingleTab ? "1":"0" ) );
|
|
|
|
preferences.appendChild( opt );
|
|
|
|
|
2011-11-02 23:37:50 +00:00
|
|
|
opt = dd.createElement( "mruTabOrder" );
|
|
|
|
opt.appendChild( dd.createTextNode( c.preferences.mruTabOrder ? "1":"0" ) );
|
|
|
|
preferences.appendChild( opt );
|
|
|
|
|
2011-06-26 11:53:28 +00:00
|
|
|
opt = dd.createElement( "hideMenubar" );
|
|
|
|
opt.appendChild( dd.createTextNode( c.preferences.hideMenubar ? "1":"0" ) );
|
|
|
|
preferences.appendChild( opt );
|
|
|
|
|
2009-04-12 20:46:25 +00:00
|
|
|
opt = dd.createElement( "enableTrayIcon" );
|
2009-02-05 20:55:00 +00:00
|
|
|
opt.appendChild( dd.createTextNode( c.preferences.enableTrayIcon ? "1":"0" ) );
|
|
|
|
preferences.appendChild( opt );
|
|
|
|
|
|
|
|
opt = dd.createElement( "startToTray" );
|
|
|
|
opt.appendChild( dd.createTextNode( c.preferences.startToTray ? "1":"0" ) );
|
|
|
|
preferences.appendChild( opt );
|
|
|
|
|
|
|
|
opt = dd.createElement( "closeToTray" );
|
|
|
|
opt.appendChild( dd.createTextNode( c.preferences.closeToTray ? "1":"0" ) );
|
|
|
|
preferences.appendChild( opt );
|
|
|
|
|
2009-04-18 18:16:04 +00:00
|
|
|
opt = dd.createElement( "autoStart" );
|
|
|
|
opt.appendChild( dd.createTextNode( c.preferences.autoStart ? "1":"0" ) );
|
|
|
|
preferences.appendChild( opt );
|
|
|
|
|
2010-04-08 20:37:59 +00:00
|
|
|
opt = dd.createElement( "doubleClickTranslates" );
|
|
|
|
opt.appendChild( dd.createTextNode( c.preferences.doubleClickTranslates ? "1":"0" ) );
|
|
|
|
preferences.appendChild( opt );
|
|
|
|
|
2012-09-26 13:59:48 +00:00
|
|
|
opt = dd.createElement( "selectWordBySingleClick" );
|
|
|
|
opt.appendChild( dd.createTextNode( c.preferences.selectWordBySingleClick ? "1":"0" ) );
|
|
|
|
preferences.appendChild( opt );
|
|
|
|
|
2011-05-07 13:42:49 +00:00
|
|
|
opt = dd.createElement( "escKeyHidesMainWindow" );
|
|
|
|
opt.appendChild( dd.createTextNode( c.preferences.escKeyHidesMainWindow ? "1":"0" ) );
|
|
|
|
preferences.appendChild( opt );
|
|
|
|
|
2009-04-30 19:57:25 +00:00
|
|
|
opt = dd.createElement( "zoomFactor" );
|
|
|
|
opt.appendChild( dd.createTextNode( QString::number( c.preferences.zoomFactor ) ) );
|
|
|
|
preferences.appendChild( opt );
|
|
|
|
|
2014-06-23 15:11:15 +00:00
|
|
|
opt = dd.createElement( "helpZoomFactor" );
|
|
|
|
opt.appendChild( dd.createTextNode( QString::number( c.preferences.helpZoomFactor ) ) );
|
|
|
|
preferences.appendChild( opt );
|
|
|
|
|
2010-07-02 11:19:02 +00:00
|
|
|
opt = dd.createElement( "wordsZoomLevel" );
|
|
|
|
opt.appendChild( dd.createTextNode( QString::number( c.preferences.wordsZoomLevel ) ) );
|
|
|
|
preferences.appendChild( opt );
|
|
|
|
|
2009-04-21 18:27:26 +00:00
|
|
|
opt = dd.createElement( "enableMainWindowHotkey" );
|
|
|
|
opt.appendChild( dd.createTextNode( c.preferences.enableMainWindowHotkey ? "1":"0" ) );
|
|
|
|
preferences.appendChild( opt );
|
|
|
|
|
|
|
|
opt = dd.createElement( "mainWindowHotkey" );
|
|
|
|
opt.appendChild( dd.createTextNode( c.preferences.mainWindowHotkey.toKeySequence().toString() ) );
|
|
|
|
preferences.appendChild( opt );
|
|
|
|
|
|
|
|
opt = dd.createElement( "enableClipboardHotkey" );
|
|
|
|
opt.appendChild( dd.createTextNode( c.preferences.enableClipboardHotkey ? "1":"0" ) );
|
|
|
|
preferences.appendChild( opt );
|
|
|
|
|
|
|
|
opt = dd.createElement( "clipboardHotkey" );
|
|
|
|
opt.appendChild( dd.createTextNode( c.preferences.clipboardHotkey.toKeySequence().toString() ) );
|
|
|
|
preferences.appendChild( opt );
|
|
|
|
|
2009-02-05 20:55:00 +00:00
|
|
|
opt = dd.createElement( "enableScanPopup" );
|
|
|
|
opt.appendChild( dd.createTextNode( c.preferences.enableScanPopup ? "1":"0" ) );
|
|
|
|
preferences.appendChild( opt );
|
2009-04-18 18:16:04 +00:00
|
|
|
|
2009-02-08 20:20:02 +00:00
|
|
|
opt = dd.createElement( "startWithScanPopupOn" );
|
|
|
|
opt.appendChild( dd.createTextNode( c.preferences.startWithScanPopupOn ? "1":"0" ) );
|
|
|
|
preferences.appendChild( opt );
|
2009-02-05 20:55:00 +00:00
|
|
|
|
|
|
|
opt = dd.createElement( "enableScanPopupModifiers" );
|
|
|
|
opt.appendChild( dd.createTextNode( c.preferences.enableScanPopupModifiers ? "1":"0" ) );
|
|
|
|
preferences.appendChild( opt );
|
|
|
|
|
|
|
|
opt = dd.createElement( "scanPopupModifiers" );
|
|
|
|
opt.appendChild( dd.createTextNode( QString::number( c.preferences.scanPopupModifiers ) ) );
|
|
|
|
preferences.appendChild( opt );
|
2009-04-03 17:10:27 +00:00
|
|
|
|
2009-04-11 16:44:14 +00:00
|
|
|
opt = dd.createElement( "scanPopupAltMode" );
|
|
|
|
opt.appendChild( dd.createTextNode( c.preferences.scanPopupAltMode ? "1":"0" ) );
|
|
|
|
preferences.appendChild( opt );
|
|
|
|
|
|
|
|
opt = dd.createElement( "scanPopupAltModeSecs" );
|
|
|
|
opt.appendChild( dd.createTextNode( QString::number( c.preferences.scanPopupAltModeSecs ) ) );
|
|
|
|
preferences.appendChild( opt );
|
2018-04-16 12:23:22 +00:00
|
|
|
|
|
|
|
opt = dd.createElement( "ignoreOwnClipboardChanges" );
|
|
|
|
opt.appendChild( dd.createTextNode( c.preferences.ignoreOwnClipboardChanges ? "1":"0" ) );
|
|
|
|
preferences.appendChild( opt );
|
2009-04-11 16:44:14 +00:00
|
|
|
|
2011-11-16 12:52:25 +00:00
|
|
|
opt = dd.createElement( "scanToMainWindow" );
|
|
|
|
opt.appendChild( dd.createTextNode( c.preferences.scanToMainWindow ? "1":"0" ) );
|
|
|
|
preferences.appendChild( opt );
|
|
|
|
|
2018-06-13 16:00:42 +00:00
|
|
|
opt = dd.createElement( "ignoreDiacritics" );
|
|
|
|
opt.appendChild( dd.createTextNode( c.preferences.ignoreDiacritics ? "1":"0" ) );
|
|
|
|
preferences.appendChild( opt );
|
|
|
|
|
2017-06-05 13:15:38 +00:00
|
|
|
#ifdef HAVE_X11
|
|
|
|
opt = dd.createElement( "showScanFlag" );
|
|
|
|
opt.appendChild( dd.createTextNode( c.preferences.showScanFlag? "1":"0" ) );
|
|
|
|
preferences.appendChild( opt );
|
|
|
|
#endif
|
|
|
|
|
2011-07-09 19:26:30 +00:00
|
|
|
opt = dd.createElement( "scanPopupUseUIAutomation" );
|
|
|
|
opt.appendChild( dd.createTextNode( c.preferences.scanPopupUseUIAutomation ? "1":"0" ) );
|
|
|
|
preferences.appendChild( opt );
|
|
|
|
|
|
|
|
opt = dd.createElement( "scanPopupUseIAccessibleEx" );
|
|
|
|
opt.appendChild( dd.createTextNode( c.preferences.scanPopupUseIAccessibleEx ? "1":"0" ) );
|
|
|
|
preferences.appendChild( opt );
|
|
|
|
|
|
|
|
opt = dd.createElement( "scanPopupUseGDMessage" );
|
|
|
|
opt.appendChild( dd.createTextNode( c.preferences.scanPopupUseGDMessage ? "1":"0" ) );
|
|
|
|
preferences.appendChild( opt );
|
|
|
|
|
Allow customizing unpinned scan popup window flags on X11 with Qt5
My tests in many desktop environments and window managers indicate that
no single configuration works perfectly in all environments. There are
also behavior differences between Qt::Popup and Qt::Tool flags, which
are not exactly bugs, so I suppose users might subjectively prefer
different options.
Customizing the flags allows the user to prevent unpinned scan popup
window flickering with Qt5 on Linux. In a way adding these options fixes
issue #645, which is: the scan popup window blinks rapidly, barely
noticeably in some applications, such as Calibre ebook-viewer
and Chromium. In this case the scan popup window usually ends up hidden
when selection ends, unless it was finished with a jerk.
I have tested the new options in 9 desktop environments and window
managers: at least one configuration for each eliminates #645 and makes
the scan popup window work the same as with Qt4 in this regard:
the popup window remains visible, text in the popup's translation line
keeps up with the text selection in the external application,
and the selected text is being translated on the fly.
Moreover, for each tested DE/WM, at least one configuration makes
the scan popup window work perfectly as far as I am concerned.
This issue was partially worked around with a 200ms scan popup delay
timer in the recent commit 58e41fe3ceb769cab37608e36637044e597ba1f8
for the duplicate issue #854. However the timer solution is incomplete
because it requires the user to select text quickly and without delays.
If global mouse selection does not change for 200ms while the left mouse
button is held down, the user will likely not see the scan popup when
(s)he finishes selection, and will have to try selecting again -
hopefully faster this time.
The 200ms delay is no longer critically important after this commit,
but it is still beneficial: the lookup query changes less often,
which in turn reduces article definition update frequency.
So the delay improves the UI (perhaps subjectively) and performance.
2018-04-09 17:50:23 +00:00
|
|
|
opt = dd.createElement( "scanPopupUnpinnedWindowFlags" );
|
|
|
|
opt.appendChild( dd.createTextNode( QString::number( c.preferences.scanPopupUnpinnedWindowFlags ) ) );
|
|
|
|
preferences.appendChild( opt );
|
|
|
|
|
|
|
|
opt = dd.createElement( "scanPopupUnpinnedBypassWMHint" );
|
|
|
|
opt.appendChild( dd.createTextNode( c.preferences.scanPopupUnpinnedBypassWMHint ? "1":"0" ) );
|
|
|
|
preferences.appendChild( opt );
|
|
|
|
|
2009-04-10 21:07:03 +00:00
|
|
|
opt = dd.createElement( "pronounceOnLoadMain" );
|
|
|
|
opt.appendChild( dd.createTextNode( c.preferences.pronounceOnLoadMain ? "1" : "0" ) );
|
|
|
|
preferences.appendChild( opt );
|
|
|
|
|
|
|
|
opt = dd.createElement( "pronounceOnLoadPopup" );
|
|
|
|
opt.appendChild( dd.createTextNode( c.preferences.pronounceOnLoadPopup ? "1" : "0" ) );
|
|
|
|
preferences.appendChild( opt );
|
2010-01-02 18:16:22 +00:00
|
|
|
|
2013-05-05 10:22:12 +00:00
|
|
|
opt = dd.createElement( "useInternalPlayer" );
|
|
|
|
opt.appendChild( dd.createTextNode( c.preferences.useInternalPlayer ? "1" : "0" ) );
|
2012-11-23 12:43:36 +00:00
|
|
|
preferences.appendChild( opt );
|
|
|
|
|
2018-03-29 17:00:53 +00:00
|
|
|
opt = dd.createElement( "internalPlayerBackend" );
|
|
|
|
opt.appendChild( dd.createTextNode( c.preferences.internalPlayerBackend.uiName() ) );
|
|
|
|
preferences.appendChild( opt );
|
|
|
|
|
2009-04-10 21:07:03 +00:00
|
|
|
opt = dd.createElement( "audioPlaybackProgram" );
|
|
|
|
opt.appendChild( dd.createTextNode( c.preferences.audioPlaybackProgram ) );
|
|
|
|
preferences.appendChild( opt );
|
|
|
|
|
2012-12-29 11:19:49 +00:00
|
|
|
opt = dd.createElement( "alwaysOnTop" );
|
|
|
|
opt.appendChild( dd.createTextNode( c.preferences.alwaysOnTop ? "1" : "0" ) );
|
|
|
|
preferences.appendChild( opt );
|
|
|
|
|
2013-01-05 11:26:55 +00:00
|
|
|
opt = dd.createElement( "searchInDock" );
|
|
|
|
opt.appendChild( dd.createTextNode( c.preferences.searchInDock ? "1" : "0" ) );
|
|
|
|
preferences.appendChild( opt );
|
|
|
|
|
2013-02-05 12:51:23 +00:00
|
|
|
opt = dd.createElement( "historyStoreInterval" );
|
|
|
|
opt.appendChild( dd.createTextNode( QString::number( c.preferences.historyStoreInterval ) ) );
|
|
|
|
preferences.appendChild( opt );
|
|
|
|
|
2017-05-13 10:18:25 +00:00
|
|
|
opt = dd.createElement( "favoritesStoreInterval" );
|
|
|
|
opt.appendChild( dd.createTextNode( QString::number( c.preferences.favoritesStoreInterval ) ) );
|
|
|
|
preferences.appendChild( opt );
|
|
|
|
|
2017-05-17 15:26:32 +00:00
|
|
|
opt = dd.createElement( "confirmFavoritesDeletion" );
|
|
|
|
opt.appendChild( dd.createTextNode( c.preferences.confirmFavoritesDeletion ? "1" : "0" ) );
|
|
|
|
preferences.appendChild( opt );
|
|
|
|
|
2009-04-03 17:10:27 +00:00
|
|
|
{
|
|
|
|
QDomElement proxy = dd.createElement( "proxyserver" );
|
|
|
|
preferences.appendChild( proxy );
|
|
|
|
|
|
|
|
QDomAttr enabled = dd.createAttribute( "enabled" );
|
|
|
|
enabled.setValue( c.preferences.proxyServer.enabled ? "1" : "0" );
|
|
|
|
proxy.setAttributeNode( enabled );
|
|
|
|
|
2014-04-01 17:00:13 +00:00
|
|
|
QDomAttr useSystemProxy = dd.createAttribute( "useSystemProxy" );
|
|
|
|
useSystemProxy.setValue( c.preferences.proxyServer.useSystemProxy ? "1" : "0" );
|
|
|
|
proxy.setAttributeNode( useSystemProxy );
|
|
|
|
|
2009-04-03 17:10:27 +00:00
|
|
|
opt = dd.createElement( "type" );
|
|
|
|
opt.appendChild( dd.createTextNode( QString::number( c.preferences.proxyServer.type ) ) );
|
|
|
|
proxy.appendChild( opt );
|
|
|
|
|
|
|
|
opt = dd.createElement( "host" );
|
|
|
|
opt.appendChild( dd.createTextNode( c.preferences.proxyServer.host ) );
|
|
|
|
proxy.appendChild( opt );
|
|
|
|
|
|
|
|
opt = dd.createElement( "port" );
|
|
|
|
opt.appendChild( dd.createTextNode( QString::number( c.preferences.proxyServer.port ) ) );
|
|
|
|
proxy.appendChild( opt );
|
|
|
|
|
|
|
|
opt = dd.createElement( "user" );
|
|
|
|
opt.appendChild( dd.createTextNode( c.preferences.proxyServer.user ) );
|
|
|
|
proxy.appendChild( opt );
|
|
|
|
|
|
|
|
opt = dd.createElement( "password" );
|
|
|
|
opt.appendChild( dd.createTextNode( c.preferences.proxyServer.password ) );
|
|
|
|
proxy.appendChild( opt );
|
2014-04-03 14:21:02 +00:00
|
|
|
|
|
|
|
opt = dd.createElement( "systemProxyUser" );
|
|
|
|
opt.appendChild( dd.createTextNode( c.preferences.proxyServer.systemProxyUser ) );
|
|
|
|
proxy.appendChild( opt );
|
|
|
|
|
|
|
|
opt = dd.createElement( "systemProxyPassword" );
|
|
|
|
opt.appendChild( dd.createTextNode( c.preferences.proxyServer.systemProxyPassword ) );
|
|
|
|
proxy.appendChild( opt );
|
2009-04-03 17:10:27 +00:00
|
|
|
}
|
2009-04-20 19:54:34 +00:00
|
|
|
|
|
|
|
opt = dd.createElement( "checkForNewReleases" );
|
|
|
|
opt.appendChild( dd.createTextNode( c.preferences.checkForNewReleases ? "1" : "0" ) );
|
|
|
|
preferences.appendChild( opt );
|
2009-08-31 12:18:08 +00:00
|
|
|
|
|
|
|
opt = dd.createElement( "disallowContentFromOtherSites" );
|
|
|
|
opt.appendChild( dd.createTextNode( c.preferences.disallowContentFromOtherSites ? "1" : "0" ) );
|
|
|
|
preferences.appendChild( opt );
|
2011-05-08 21:19:08 +00:00
|
|
|
|
|
|
|
opt = dd.createElement( "enableWebPlugins" );
|
|
|
|
opt.appendChild( dd.createTextNode( c.preferences.enableWebPlugins ? "1" : "0" ) );
|
|
|
|
preferences.appendChild( opt );
|
2012-02-16 14:56:25 +00:00
|
|
|
|
2013-04-08 12:20:12 +00:00
|
|
|
opt = dd.createElement( "hideGoldenDictHeader" );
|
|
|
|
opt.appendChild( dd.createTextNode( c.preferences.hideGoldenDictHeader ? "1" : "0" ) );
|
|
|
|
preferences.appendChild( opt );
|
|
|
|
|
2012-02-16 14:56:25 +00:00
|
|
|
opt = dd.createElement( "maxStringsInHistory" );
|
|
|
|
opt.appendChild( dd.createTextNode( QString::number( c.preferences.maxStringsInHistory ) ) );
|
|
|
|
preferences.appendChild( opt );
|
2012-09-10 18:00:29 +00:00
|
|
|
|
2012-09-11 13:03:10 +00:00
|
|
|
opt = dd.createElement( "storeHistory" );
|
|
|
|
opt.appendChild( dd.createTextNode( QString::number( c.preferences.storeHistory ) ) );
|
|
|
|
preferences.appendChild( opt );
|
|
|
|
|
2012-09-16 10:19:47 +00:00
|
|
|
opt = dd.createElement( "alwaysExpandOptionalParts" );
|
|
|
|
opt.appendChild( dd.createTextNode( QString::number( c.preferences.alwaysExpandOptionalParts ) ) );
|
|
|
|
preferences.appendChild( opt );
|
2012-12-10 14:14:13 +00:00
|
|
|
|
|
|
|
opt = dd.createElement( "addonStyle" );
|
|
|
|
opt.appendChild( dd.createTextNode( c.preferences.addonStyle ) );
|
|
|
|
preferences.appendChild( opt );
|
2013-06-02 11:20:33 +00:00
|
|
|
|
|
|
|
opt = dd.createElement( "collapseBigArticles" );
|
|
|
|
opt.appendChild( dd.createTextNode( c.preferences.collapseBigArticles ? "1" : "0" ) );
|
|
|
|
preferences.appendChild( opt );
|
|
|
|
|
|
|
|
opt = dd.createElement( "articleSizeLimit" );
|
|
|
|
opt.appendChild( dd.createTextNode( QString::number( c.preferences.articleSizeLimit ) ) );
|
2013-06-11 18:31:01 +00:00
|
|
|
preferences.appendChild( opt );
|
|
|
|
|
|
|
|
opt = dd.createElement( "maxDictionaryRefsInContextMenu" );
|
|
|
|
opt.appendChild( dd.createTextNode( QString::number( c.preferences.maxDictionaryRefsInContextMenu ) ) );
|
2014-01-09 14:17:50 +00:00
|
|
|
preferences.appendChild( opt );
|
|
|
|
|
|
|
|
#ifndef Q_WS_X11
|
|
|
|
opt = dd.createElement( "trackClipboardChanges" );
|
|
|
|
opt.appendChild( dd.createTextNode( c.preferences.trackClipboardChanges ? "1" : "0" ) );
|
|
|
|
preferences.appendChild( opt );
|
|
|
|
#endif
|
2017-03-09 16:11:17 +00:00
|
|
|
|
|
|
|
opt = dd.createElement( "synonymSearchEnabled" );
|
|
|
|
opt.appendChild( dd.createTextNode( c.preferences.synonymSearchEnabled ? "1" : "0" ) );
|
|
|
|
preferences.appendChild( opt );
|
|
|
|
|
2014-04-17 14:31:51 +00:00
|
|
|
{
|
|
|
|
QDomNode hd = dd.createElement( "fullTextSearch" );
|
|
|
|
preferences.appendChild( hd );
|
|
|
|
|
|
|
|
QDomElement opt = dd.createElement( "searchMode" );
|
|
|
|
opt.appendChild( dd.createTextNode( QString::number( c.preferences.fts.searchMode ) ) );
|
|
|
|
hd.appendChild( opt );
|
|
|
|
|
|
|
|
opt = dd.createElement( "matchCase" );
|
|
|
|
opt.appendChild( dd.createTextNode( c.preferences.fts.matchCase ? "1" : "0" ) );
|
|
|
|
hd.appendChild( opt );
|
|
|
|
|
|
|
|
opt = dd.createElement( "maxArticlesPerDictionary" );
|
|
|
|
opt.appendChild( dd.createTextNode( QString::number( c.preferences.fts.maxArticlesPerDictionary ) ) );
|
|
|
|
hd.appendChild( opt );
|
|
|
|
|
|
|
|
opt = dd.createElement( "maxDistanceBetweenWords" );
|
|
|
|
opt.appendChild( dd.createTextNode( QString::number( c.preferences.fts.maxDistanceBetweenWords ) ) );
|
|
|
|
hd.appendChild( opt );
|
|
|
|
|
|
|
|
opt = dd.createElement( "useMaxArticlesPerDictionary" );
|
|
|
|
opt.appendChild( dd.createTextNode( c.preferences.fts.useMaxArticlesPerDictionary ? "1" : "0" ) );
|
|
|
|
hd.appendChild( opt );
|
|
|
|
|
|
|
|
opt = dd.createElement( "useMaxDistanceBetweenWords" );
|
|
|
|
opt.appendChild( dd.createTextNode( c.preferences.fts.useMaxDistanceBetweenWords ? "1" : "0" ) );
|
|
|
|
hd.appendChild( opt );
|
|
|
|
|
|
|
|
opt = dd.createElement( "dialogGeometry" );
|
|
|
|
opt.appendChild( dd.createTextNode( QString::fromLatin1( c.preferences.fts.dialogGeometry.toBase64() ) ) );
|
|
|
|
hd.appendChild( opt );
|
|
|
|
|
|
|
|
opt = dd.createElement( "disabledTypes" );
|
|
|
|
opt.appendChild( dd.createTextNode( c.preferences.fts.disabledTypes ) );
|
|
|
|
hd.appendChild( opt );
|
|
|
|
|
|
|
|
opt = dd.createElement( "enabled" );
|
|
|
|
opt.appendChild( dd.createTextNode( c.preferences.fts.enabled ? "1" : "0" ) );
|
|
|
|
hd.appendChild( opt );
|
|
|
|
|
2017-07-25 15:28:29 +00:00
|
|
|
opt = dd.createElement( "ignoreWordsOrder" );
|
|
|
|
opt.appendChild( dd.createTextNode( c.preferences.fts.ignoreWordsOrder ? "1" : "0" ) );
|
|
|
|
hd.appendChild( opt );
|
|
|
|
|
2018-04-10 14:49:52 +00:00
|
|
|
opt = dd.createElement( "ignoreDiacritics" );
|
|
|
|
opt.appendChild( dd.createTextNode( c.preferences.fts.ignoreDiacritics ? "1" : "0" ) );
|
|
|
|
hd.appendChild( opt );
|
|
|
|
|
2014-04-17 14:31:51 +00:00
|
|
|
opt = dd.createElement( "maxDictionarySize" );
|
|
|
|
opt.appendChild( dd.createTextNode( QString::number( c.preferences.fts.maxDictionarySize ) ) );
|
|
|
|
hd.appendChild( opt );
|
|
|
|
}
|
|
|
|
|
2014-01-09 14:17:50 +00:00
|
|
|
}
|
2009-02-05 20:55:00 +00:00
|
|
|
|
2009-02-06 17:04:11 +00:00
|
|
|
{
|
2009-04-10 12:48:40 +00:00
|
|
|
QDomElement opt = dd.createElement( "lastMainGroupId" );
|
|
|
|
opt.appendChild( dd.createTextNode( QString::number( c.lastMainGroupId ) ) );
|
2009-02-06 17:04:11 +00:00
|
|
|
root.appendChild( opt );
|
|
|
|
|
2009-04-10 12:48:40 +00:00
|
|
|
opt = dd.createElement( "lastPopupGroupId" );
|
|
|
|
opt.appendChild( dd.createTextNode( QString::number( c.lastPopupGroupId ) ) );
|
2009-02-06 17:04:11 +00:00
|
|
|
root.appendChild( opt );
|
2009-02-06 17:16:33 +00:00
|
|
|
|
2010-03-30 20:15:55 +00:00
|
|
|
opt = dd.createElement( "popupWindowState" );
|
|
|
|
opt.appendChild( dd.createTextNode( QString::fromLatin1( c.popupWindowState.toBase64() ) ) );
|
|
|
|
root.appendChild( opt );
|
2009-02-06 17:16:33 +00:00
|
|
|
|
2010-03-30 20:15:55 +00:00
|
|
|
opt = dd.createElement( "popupWindowGeometry" );
|
|
|
|
opt.appendChild( dd.createTextNode( QString::fromLatin1( c.popupWindowGeometry.toBase64() ) ) );
|
|
|
|
root.appendChild( opt );
|
2009-04-03 21:24:07 +00:00
|
|
|
|
2011-05-01 23:52:11 +00:00
|
|
|
opt = dd.createElement( "pinPopupWindow" );
|
|
|
|
opt.appendChild( dd.createTextNode( c.pinPopupWindow ? "1" : "0" ) );
|
|
|
|
root.appendChild( opt );
|
|
|
|
|
2017-07-13 15:00:19 +00:00
|
|
|
opt = dd.createElement( "popupWindowAlwaysOnTop" );
|
|
|
|
opt.appendChild( dd.createTextNode( c.popupWindowAlwaysOnTop ? "1" : "0" ) );
|
|
|
|
root.appendChild( opt );
|
|
|
|
|
2009-04-03 21:24:07 +00:00
|
|
|
opt = dd.createElement( "mainWindowState" );
|
|
|
|
opt.appendChild( dd.createTextNode( QString::fromLatin1( c.mainWindowState.toBase64() ) ) );
|
|
|
|
root.appendChild( opt );
|
|
|
|
|
|
|
|
opt = dd.createElement( "mainWindowGeometry" );
|
|
|
|
opt.appendChild( dd.createTextNode( QString::fromLatin1( c.mainWindowGeometry.toBase64() ) ) );
|
|
|
|
root.appendChild( opt );
|
2009-04-20 19:54:34 +00:00
|
|
|
|
2014-06-23 15:11:15 +00:00
|
|
|
opt = dd.createElement( "helpWindowGeometry" );
|
|
|
|
opt.appendChild( dd.createTextNode( QString::fromLatin1( c.helpWindowGeometry.toBase64() ) ) );
|
|
|
|
root.appendChild( opt );
|
|
|
|
|
|
|
|
opt = dd.createElement( "helpSplitterState" );
|
|
|
|
opt.appendChild( dd.createTextNode( QString::fromLatin1( c.helpSplitterState.toBase64() ) ) );
|
|
|
|
root.appendChild( opt );
|
|
|
|
|
2013-02-04 14:10:37 +00:00
|
|
|
#ifdef Q_OS_WIN
|
2013-01-29 19:20:53 +00:00
|
|
|
{
|
|
|
|
QDomElement maximizedMainWindowGeometry = dd.createElement( "maximizedMainWindowGeometry" );
|
|
|
|
root.appendChild( maximizedMainWindowGeometry );
|
|
|
|
|
|
|
|
opt = dd.createElement( "x" );
|
|
|
|
opt.appendChild( dd.createTextNode( QString::number( c.maximizedMainWindowGeometry.x() ) ) );
|
|
|
|
maximizedMainWindowGeometry.appendChild( opt );
|
|
|
|
|
|
|
|
opt = dd.createElement( "y" );
|
|
|
|
opt.appendChild( dd.createTextNode( QString::number( c.maximizedMainWindowGeometry.y() ) ) );
|
|
|
|
maximizedMainWindowGeometry.appendChild( opt );
|
|
|
|
|
|
|
|
opt = dd.createElement( "width" );
|
|
|
|
opt.appendChild( dd.createTextNode( QString::number( c.maximizedMainWindowGeometry.width() ) ) );
|
|
|
|
maximizedMainWindowGeometry.appendChild( opt );
|
|
|
|
|
|
|
|
opt = dd.createElement( "height" );
|
|
|
|
opt.appendChild( dd.createTextNode( QString::number( c.maximizedMainWindowGeometry.height() ) ) );
|
|
|
|
maximizedMainWindowGeometry.appendChild( opt );
|
2013-12-20 14:25:33 +00:00
|
|
|
|
|
|
|
QDomElement normalMainWindowGeometry = dd.createElement( "normalMainWindowGeometry" );
|
|
|
|
root.appendChild( normalMainWindowGeometry );
|
|
|
|
|
|
|
|
opt = dd.createElement( "x" );
|
|
|
|
opt.appendChild( dd.createTextNode( QString::number( c.normalMainWindowGeometry.x() ) ) );
|
|
|
|
normalMainWindowGeometry.appendChild( opt );
|
|
|
|
|
|
|
|
opt = dd.createElement( "y" );
|
|
|
|
opt.appendChild( dd.createTextNode( QString::number( c.normalMainWindowGeometry.y() ) ) );
|
|
|
|
normalMainWindowGeometry.appendChild( opt );
|
|
|
|
|
|
|
|
opt = dd.createElement( "width" );
|
|
|
|
opt.appendChild( dd.createTextNode( QString::number( c.normalMainWindowGeometry.width() ) ) );
|
|
|
|
normalMainWindowGeometry.appendChild( opt );
|
|
|
|
|
|
|
|
opt = dd.createElement( "height" );
|
|
|
|
opt.appendChild( dd.createTextNode( QString::number( c.normalMainWindowGeometry.height() ) ) );
|
|
|
|
normalMainWindowGeometry.appendChild( opt );
|
2013-01-29 19:20:53 +00:00
|
|
|
}
|
2013-02-04 14:10:37 +00:00
|
|
|
#endif
|
2013-01-29 19:20:53 +00:00
|
|
|
|
2012-09-27 13:00:40 +00:00
|
|
|
opt = dd.createElement( "dictInfoGeometry" );
|
|
|
|
opt.appendChild( dd.createTextNode( QString::fromLatin1( c.dictInfoGeometry.toBase64() ) ) );
|
|
|
|
root.appendChild( opt );
|
|
|
|
|
2013-05-30 02:18:28 +00:00
|
|
|
opt = dd.createElement( "inspectorGeometry" );
|
|
|
|
opt.appendChild( dd.createTextNode( QString::fromLatin1( c.inspectorGeometry.toBase64() ) ) );
|
|
|
|
root.appendChild( opt );
|
|
|
|
|
2009-04-20 19:54:34 +00:00
|
|
|
opt = dd.createElement( "timeForNewReleaseCheck" );
|
|
|
|
opt.appendChild( dd.createTextNode( c.timeForNewReleaseCheck.toString( Qt::ISODate ) ) );
|
|
|
|
root.appendChild( opt );
|
2009-05-14 17:59:49 +00:00
|
|
|
|
|
|
|
opt = dd.createElement( "skippedRelease" );
|
|
|
|
opt.appendChild( dd.createTextNode( c.skippedRelease ) );
|
|
|
|
root.appendChild( opt );
|
2009-10-12 12:41:20 +00:00
|
|
|
|
|
|
|
opt = dd.createElement( "showingDictBarNames" );
|
|
|
|
opt.appendChild( dd.createTextNode( c.showingDictBarNames ? "1" : "0" ) );
|
|
|
|
root.appendChild( opt );
|
2011-05-22 02:42:05 +00:00
|
|
|
|
|
|
|
opt = dd.createElement( "usingSmallIconsInToolbars" );
|
|
|
|
opt.appendChild( dd.createTextNode( c.usingSmallIconsInToolbars ? "1" : "0" ) );
|
|
|
|
root.appendChild( opt );
|
2011-06-09 19:45:04 +00:00
|
|
|
|
2012-09-12 17:19:21 +00:00
|
|
|
if( !c.historyExportPath.isEmpty() )
|
|
|
|
{
|
|
|
|
opt = dd.createElement( "historyExportPath" );
|
|
|
|
opt.appendChild( dd.createTextNode( c.historyExportPath ) );
|
|
|
|
root.appendChild( opt );
|
|
|
|
}
|
2012-11-28 19:32:37 +00:00
|
|
|
|
2013-02-22 12:44:23 +00:00
|
|
|
if( !c.resourceSavePath.isEmpty() )
|
|
|
|
{
|
|
|
|
opt = dd.createElement( "resourceSavePath" );
|
|
|
|
opt.appendChild( dd.createTextNode( c.resourceSavePath ) );
|
|
|
|
root.appendChild( opt );
|
|
|
|
}
|
|
|
|
|
2013-04-12 06:57:41 +00:00
|
|
|
if( !c.articleSavePath.isEmpty() )
|
|
|
|
{
|
|
|
|
opt = dd.createElement( "articleSavePath" );
|
|
|
|
opt.appendChild( dd.createTextNode( c.articleSavePath ) );
|
|
|
|
root.appendChild( opt );
|
|
|
|
}
|
|
|
|
|
2012-11-28 19:32:37 +00:00
|
|
|
opt = dd.createElement( "editDictionaryCommandLine" );
|
|
|
|
opt.appendChild( dd.createTextNode( c.editDictionaryCommandLine ) );
|
|
|
|
root.appendChild( opt );
|
|
|
|
|
2012-12-07 11:59:29 +00:00
|
|
|
opt = dd.createElement( "maxPictureWidth" );
|
|
|
|
opt.appendChild( dd.createTextNode( QString::number( c.maxPictureWidth ) ) );
|
|
|
|
root.appendChild( opt );
|
2013-01-11 09:58:14 +00:00
|
|
|
|
|
|
|
opt = dd.createElement( "maxHeadwordSize" );
|
|
|
|
opt.appendChild( dd.createTextNode( QString::number( c.maxHeadwordSize ) ) );
|
|
|
|
root.appendChild( opt );
|
2017-10-25 14:37:39 +00:00
|
|
|
|
|
|
|
opt = dd.createElement( "maxHeadwordsToExpand" );
|
|
|
|
opt.appendChild( dd.createTextNode( QString::number( c.maxHeadwordsToExpand ) ) );
|
|
|
|
root.appendChild( opt );
|
2009-02-06 17:04:11 +00:00
|
|
|
}
|
|
|
|
|
2014-02-28 12:36:28 +00:00
|
|
|
{
|
|
|
|
QDomNode hd = dd.createElement( "headwordsDialog" );
|
|
|
|
root.appendChild( hd );
|
|
|
|
|
|
|
|
QDomElement opt = dd.createElement( "searchMode" );
|
|
|
|
opt.appendChild( dd.createTextNode( QString::number( c.headwordsDialog.searchMode ) ) );
|
|
|
|
hd.appendChild( opt );
|
|
|
|
|
|
|
|
opt = dd.createElement( "matchCase" );
|
|
|
|
opt.appendChild( dd.createTextNode( c.headwordsDialog.matchCase ? "1" : "0" ) );
|
|
|
|
hd.appendChild( opt );
|
|
|
|
|
|
|
|
opt = dd.createElement( "autoApply" );
|
|
|
|
opt.appendChild( dd.createTextNode( c.headwordsDialog.autoApply ? "1" : "0" ) );
|
|
|
|
hd.appendChild( opt );
|
|
|
|
|
|
|
|
opt = dd.createElement( "headwordsExportPath" );
|
|
|
|
opt.appendChild( dd.createTextNode( c.headwordsDialog.headwordsExportPath ) );
|
|
|
|
hd.appendChild( opt );
|
|
|
|
|
|
|
|
opt = dd.createElement( "headwordsDialogGeometry" );
|
|
|
|
opt.appendChild( dd.createTextNode( QString::fromLatin1( c.headwordsDialog.headwordsDialogGeometry.toBase64() ) ) );
|
|
|
|
hd.appendChild( opt );
|
|
|
|
}
|
|
|
|
|
2009-10-18 11:01:13 +00:00
|
|
|
QByteArray result( dd.toByteArray() );
|
|
|
|
|
|
|
|
if ( configFile.write( result ) != result.size() )
|
|
|
|
throw exCantWriteConfigFile();
|
|
|
|
|
|
|
|
configFile.close();
|
|
|
|
|
2009-10-21 19:30:14 +00:00
|
|
|
renameAtomically( configFile.fileName(), getConfigFileName() );
|
2009-01-28 20:55:45 +00:00
|
|
|
}
|
|
|
|
|
2013-05-08 16:50:06 +00:00
|
|
|
QString getConfigFileName()
|
|
|
|
{
|
|
|
|
return getHomeDir().absoluteFilePath( "config" );
|
|
|
|
}
|
|
|
|
|
2018-05-21 15:32:04 +00:00
|
|
|
QString getConfigDir() THROW_SPEC( exError )
|
2011-07-10 07:36:43 +00:00
|
|
|
{
|
|
|
|
return getHomeDir().path() + QDir::separator();
|
|
|
|
}
|
|
|
|
|
2018-05-21 15:32:04 +00:00
|
|
|
QString getIndexDir() THROW_SPEC( exError )
|
2009-01-28 20:55:45 +00:00
|
|
|
{
|
|
|
|
QDir result = getHomeDir();
|
|
|
|
|
|
|
|
result.mkpath( "index" );
|
|
|
|
|
|
|
|
if ( !result.cd( "index" ) )
|
|
|
|
throw exCantUseIndexDir();
|
|
|
|
|
|
|
|
return result.path() + QDir::separator();
|
|
|
|
}
|
|
|
|
|
2018-05-21 15:32:04 +00:00
|
|
|
QString getPidFileName() THROW_SPEC( exError )
|
2009-05-12 19:13:20 +00:00
|
|
|
{
|
|
|
|
return getHomeDir().filePath( "pid" );
|
|
|
|
}
|
|
|
|
|
2018-05-21 15:32:04 +00:00
|
|
|
QString getHistoryFileName() THROW_SPEC( exError )
|
2009-10-21 19:30:14 +00:00
|
|
|
{
|
|
|
|
return getHomeDir().filePath( "history" );
|
|
|
|
}
|
|
|
|
|
2018-05-21 15:32:04 +00:00
|
|
|
QString getFavoritiesFileName() THROW_SPEC( exError )
|
2017-05-05 14:39:51 +00:00
|
|
|
{
|
|
|
|
return getHomeDir().filePath( "favorites" );
|
|
|
|
}
|
|
|
|
|
2018-05-21 15:32:04 +00:00
|
|
|
QString getUserCssFileName() THROW_SPEC( exError )
|
2009-01-28 20:55:45 +00:00
|
|
|
{
|
2009-02-08 17:21:46 +00:00
|
|
|
return getHomeDir().filePath( "article-style.css" );
|
2009-01-28 20:55:45 +00:00
|
|
|
}
|
|
|
|
|
2018-05-21 15:32:04 +00:00
|
|
|
QString getUserCssPrintFileName() THROW_SPEC( exError )
|
2009-05-01 12:20:33 +00:00
|
|
|
{
|
|
|
|
return getHomeDir().filePath( "article-style-print.css" );
|
|
|
|
}
|
|
|
|
|
2018-05-21 15:32:04 +00:00
|
|
|
QString getUserQtCssFileName() THROW_SPEC( exError )
|
2009-02-01 00:08:08 +00:00
|
|
|
{
|
|
|
|
return getHomeDir().filePath( "qt-style.css" );
|
|
|
|
}
|
|
|
|
|
2009-04-12 19:41:58 +00:00
|
|
|
QString getProgramDataDir() throw()
|
|
|
|
{
|
2010-05-28 16:50:54 +00:00
|
|
|
if ( isPortableVersion() )
|
|
|
|
return QCoreApplication::applicationDirPath();
|
|
|
|
|
2009-04-12 19:41:58 +00:00
|
|
|
#ifdef PROGRAM_DATA_DIR
|
|
|
|
return PROGRAM_DATA_DIR;
|
|
|
|
#else
|
2009-04-23 13:43:51 +00:00
|
|
|
return QCoreApplication::applicationDirPath();
|
2009-04-12 19:41:58 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2009-07-29 16:39:27 +00:00
|
|
|
QString getLocDir() throw()
|
|
|
|
{
|
|
|
|
if ( QDir( getProgramDataDir() ).cd( "locale" ) )
|
|
|
|
return getProgramDataDir() + "/locale";
|
|
|
|
else
|
|
|
|
return QCoreApplication::applicationDirPath() + "/locale";
|
|
|
|
}
|
|
|
|
|
2014-06-24 13:55:06 +00:00
|
|
|
QString getHelpDir() throw()
|
|
|
|
{
|
|
|
|
if ( QDir( getProgramDataDir() ).cd( "help" ) )
|
|
|
|
return getProgramDataDir() + "/help";
|
|
|
|
else
|
|
|
|
return QCoreApplication::applicationDirPath() + "/help";
|
|
|
|
}
|
|
|
|
|
2015-10-26 03:56:39 +00:00
|
|
|
#ifdef MAKE_CHINESE_CONVERSION_SUPPORT
|
|
|
|
QString getOpenCCDir() throw()
|
|
|
|
{
|
2016-04-22 14:18:42 +00:00
|
|
|
#if defined( Q_OS_WIN )
|
2015-10-26 03:56:39 +00:00
|
|
|
if ( QDir( "opencc" ).exists() )
|
|
|
|
return "opencc";
|
|
|
|
else
|
|
|
|
return QCoreApplication::applicationDirPath() + "/opencc";
|
2016-04-22 14:18:42 +00:00
|
|
|
#elif defined( Q_OS_MAC )
|
|
|
|
QString path = QCoreApplication::applicationDirPath() + "/opencc";
|
|
|
|
if ( QDir( path ).exists() )
|
|
|
|
return path;
|
|
|
|
|
|
|
|
return QString();
|
|
|
|
#else
|
|
|
|
return QString();
|
|
|
|
#endif
|
2015-10-26 03:56:39 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-05-28 16:50:54 +00:00
|
|
|
bool isPortableVersion() throw()
|
|
|
|
{
|
|
|
|
struct IsPortable
|
|
|
|
{
|
|
|
|
bool isPortable;
|
|
|
|
|
|
|
|
IsPortable(): isPortable( QFileInfo( QCoreApplication::applicationDirPath() + "/portable" ).isDir() )
|
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
|
|
|
static IsPortable p;
|
|
|
|
|
|
|
|
return p.isPortable;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString getPortableVersionDictionaryDir() throw()
|
|
|
|
{
|
|
|
|
if ( isPortableVersion() )
|
|
|
|
return getProgramDataDir() + "/content";
|
|
|
|
else
|
|
|
|
return QString();
|
|
|
|
}
|
|
|
|
|
|
|
|
QString getPortableVersionMorphoDir() throw()
|
|
|
|
{
|
|
|
|
if ( isPortableVersion() )
|
|
|
|
return getPortableVersionDictionaryDir() + "/morphology";
|
|
|
|
else
|
|
|
|
return QString();
|
|
|
|
}
|
|
|
|
|
2012-12-10 14:14:13 +00:00
|
|
|
QString getStylesDir() throw()
|
|
|
|
{
|
|
|
|
QDir result = getHomeDir();
|
|
|
|
|
|
|
|
result.mkpath( "styles" );
|
|
|
|
|
|
|
|
if ( !result.cd( "styles" ) )
|
|
|
|
return QString();
|
|
|
|
|
|
|
|
return result.path() + QDir::separator();
|
|
|
|
}
|
|
|
|
|
2009-01-28 20:55:45 +00:00
|
|
|
}
|