2009-02-05 20:55:00 +00:00
|
|
|
#include "keyboardstate.hh"
|
2023-04-17 02:23:39 +00:00
|
|
|
#include "language.hh"
|
|
|
|
#include "preferences.hh"
|
2023-04-22 00:43:50 +00:00
|
|
|
#include "help.hh"
|
2023-05-30 06:31:07 +00:00
|
|
|
|
|
|
|
#include <QDebug>
|
|
|
|
#include <QDir>
|
|
|
|
#include <QFontDatabase>
|
2009-04-12 20:46:25 +00:00
|
|
|
#include <QMessageBox>
|
2023-07-20 14:50:32 +00:00
|
|
|
#include <QThread>
|
2022-05-17 13:24:30 +00:00
|
|
|
#include <QWebEngineProfile>
|
2023-04-17 02:23:39 +00:00
|
|
|
#include <QWebEngineSettings>
|
2023-07-20 12:10:44 +00:00
|
|
|
#include <QStyleFactory>
|
2013-05-05 10:22:12 +00:00
|
|
|
|
2014-06-24 13:55:06 +00:00
|
|
|
Preferences::Preferences( QWidget * parent, Config::Class & cfg_ ):
|
2023-06-01 11:52:16 +00:00
|
|
|
QDialog( parent ),
|
|
|
|
cfg( cfg_ ),
|
|
|
|
helpAction( this )
|
2009-02-05 20:55:00 +00:00
|
|
|
{
|
2014-06-24 13:55:06 +00:00
|
|
|
Config::Preferences const & p = cfg_.preferences;
|
2009-02-05 20:55:00 +00:00
|
|
|
ui.setupUi( this );
|
|
|
|
|
2022-12-26 02:08:17 +00:00
|
|
|
connect( ui.enableScanPopupModifiers,
|
|
|
|
&QAbstractButton::toggled,
|
|
|
|
this,
|
|
|
|
&Preferences::enableScanPopupModifiersToggled );
|
|
|
|
|
|
|
|
connect( ui.showScanFlag, &QAbstractButton::toggled, this, &Preferences::showScanFlagToggled );
|
|
|
|
|
|
|
|
connect( ui.altKey, &QAbstractButton::clicked, this, &Preferences::wholeAltClicked );
|
|
|
|
connect( ui.ctrlKey, &QAbstractButton::clicked, this, &Preferences::wholeCtrlClicked );
|
|
|
|
connect( ui.shiftKey, &QAbstractButton::clicked, this, &Preferences::wholeShiftClicked );
|
|
|
|
|
|
|
|
connect( ui.leftAlt, &QAbstractButton::clicked, this, &Preferences::sideAltClicked );
|
|
|
|
connect( ui.rightAlt, &QAbstractButton::clicked, this, &Preferences::sideAltClicked );
|
|
|
|
connect( ui.leftCtrl, &QAbstractButton::clicked, this, &Preferences::sideCtrlClicked );
|
|
|
|
connect( ui.rightCtrl, &QAbstractButton::clicked, this, &Preferences::sideCtrlClicked );
|
|
|
|
connect( ui.leftShift, &QAbstractButton::clicked, this, &Preferences::sideShiftClicked );
|
|
|
|
connect( ui.rightShift, &QAbstractButton::clicked, this, &Preferences::sideShiftClicked );
|
|
|
|
|
2014-06-24 13:55:06 +00:00
|
|
|
|
|
|
|
helpAction.setShortcut( QKeySequence( "F1" ) );
|
|
|
|
helpAction.setShortcutContext( Qt::WidgetWithChildrenShortcut );
|
|
|
|
|
2023-04-17 02:23:39 +00:00
|
|
|
connect( &helpAction, &QAction::triggered, [ this ]() {
|
|
|
|
const auto * currentTab = ui.tabWidget->currentWidget();
|
|
|
|
if ( ui.tab_popup == currentTab ) {
|
2023-04-22 00:43:50 +00:00
|
|
|
Help::openHelpWebpage( Help::section::ui_popup );
|
2023-04-17 02:23:39 +00:00
|
|
|
}
|
|
|
|
else if ( ui.tab_FTS == currentTab ) {
|
2023-04-22 00:43:50 +00:00
|
|
|
Help::openHelpWebpage( Help::section::ui_fulltextserch );
|
2023-04-17 02:23:39 +00:00
|
|
|
}
|
|
|
|
else {
|
2023-04-22 00:43:50 +00:00
|
|
|
Help::openHelpWebpage();
|
2023-04-17 02:23:39 +00:00
|
|
|
}
|
|
|
|
} );
|
|
|
|
connect( ui.buttonBox, &QDialogButtonBox::helpRequested, &helpAction, &QAction::trigger );
|
2014-06-24 13:55:06 +00:00
|
|
|
|
|
|
|
addAction( &helpAction );
|
|
|
|
|
2009-02-05 20:55:00 +00:00
|
|
|
// Load values into form
|
|
|
|
|
2009-04-12 20:46:25 +00:00
|
|
|
ui.interfaceLanguage->addItem( tr( "System default" ), QString() );
|
2009-07-29 16:39:27 +00:00
|
|
|
// See which other translations do we have
|
|
|
|
|
2022-09-21 15:40:06 +00:00
|
|
|
QStringList availLocs = QDir( Config::getLocDir() ).entryList( QStringList( "*.qm" ), QDir::Files );
|
2009-07-29 16:39:27 +00:00
|
|
|
|
|
|
|
// We need to sort by language name -- otherwise list looks really weird
|
2023-04-28 00:21:36 +00:00
|
|
|
QMultiMap< QString, QString > sortedLocs;
|
|
|
|
sortedLocs.insert( Language::languageForLocale( "en_US" ), "en_US" );
|
|
|
|
for ( const auto & availLoc : availLocs ) {
|
2009-07-29 16:39:27 +00:00
|
|
|
// Here we assume the xx_YY naming, where xx is language and YY is region.
|
2023-04-28 00:21:36 +00:00
|
|
|
//remove .qm suffix.
|
|
|
|
QString locale = availLoc.left( availLoc.size() - 3 );
|
2010-12-03 12:35:06 +00:00
|
|
|
|
2023-04-28 00:21:36 +00:00
|
|
|
if ( locale == "qt" )
|
2010-12-03 19:14:14 +00:00
|
|
|
continue; // We skip qt's own localizations
|
2010-12-03 12:35:06 +00:00
|
|
|
|
2023-04-28 00:21:36 +00:00
|
|
|
auto language = Language::languageForLocale( locale );
|
|
|
|
if ( language.isEmpty() ) {
|
|
|
|
qWarning() << "can not found the corresponding language from locale:" << locale;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
sortedLocs.insert( language, locale );
|
|
|
|
}
|
2009-07-29 16:39:27 +00:00
|
|
|
}
|
|
|
|
|
2023-04-28 00:21:36 +00:00
|
|
|
for ( auto i = sortedLocs.begin(); i != sortedLocs.end(); ++i ) {
|
|
|
|
ui.interfaceLanguage->addItem( i.key(), i.value() );
|
|
|
|
}
|
2009-04-12 20:46:25 +00:00
|
|
|
|
2023-04-28 00:21:36 +00:00
|
|
|
for ( int x = 0; x < ui.interfaceLanguage->count(); ++x ) {
|
2009-04-12 20:46:25 +00:00
|
|
|
if ( ui.interfaceLanguage->itemData( x ).toString() == p.interfaceLanguage ) {
|
|
|
|
ui.interfaceLanguage->setCurrentIndex( x );
|
|
|
|
prevInterfaceLanguage = x;
|
|
|
|
break;
|
|
|
|
}
|
2023-04-28 00:21:36 +00:00
|
|
|
}
|
|
|
|
|
2023-09-07 01:53:51 +00:00
|
|
|
//System Font
|
|
|
|
if ( !p.interfaceFont.isEmpty() ) {
|
|
|
|
ui.systemFont->setCurrentText( p.interfaceFont );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-07-16 10:54:07 +00:00
|
|
|
prevWebFontFamily = p.customFonts;
|
2023-09-07 01:53:51 +00:00
|
|
|
prevSysFont = p.interfaceFont;
|
2022-05-17 13:24:30 +00:00
|
|
|
|
2023-07-16 10:54:07 +00:00
|
|
|
if ( !p.customFonts.standard.isEmpty() )
|
|
|
|
ui.font_standard->setCurrentText( p.customFonts.standard );
|
2023-06-07 13:53:21 +00:00
|
|
|
else {
|
2023-07-16 10:54:07 +00:00
|
|
|
ui.font_standard->setCurrentFont(
|
|
|
|
QWebEngineProfile::defaultProfile()->settings()->fontFamily( QWebEngineSettings::StandardFont ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( !p.customFonts.serif.isEmpty() )
|
|
|
|
ui.font_serif->setCurrentText( p.customFonts.serif );
|
|
|
|
else {
|
|
|
|
ui.font_serif->setCurrentFont(
|
|
|
|
QWebEngineProfile::defaultProfile()->settings()->fontFamily( QWebEngineSettings::SerifFont ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( !p.customFonts.sansSerif.isEmpty() )
|
|
|
|
ui.font_sans->setCurrentText( p.customFonts.sansSerif );
|
|
|
|
else {
|
|
|
|
ui.font_sans->setCurrentFont(
|
|
|
|
QWebEngineProfile::defaultProfile()->settings()->fontFamily( QWebEngineSettings::SansSerifFont ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( !p.customFonts.monospace.isEmpty() )
|
|
|
|
ui.font_monospace->setCurrentText( p.customFonts.monospace );
|
|
|
|
else {
|
|
|
|
ui.font_monospace->setCurrentFont(
|
|
|
|
QWebEngineProfile::defaultProfile()->settings()->fontFamily( QWebEngineSettings::FixedFont ) );
|
2023-06-07 13:53:21 +00:00
|
|
|
}
|
2014-06-25 14:01:11 +00:00
|
|
|
|
2013-07-19 17:07:32 +00:00
|
|
|
ui.displayStyle->addItem( QIcon( ":/icons/programicon_old.png" ), tr( "Default" ), QString() );
|
2022-08-18 12:54:35 +00:00
|
|
|
ui.displayStyle->addItem( QIcon( ":/icons/programicon.png" ), tr( "Classic" ), QString( "classic" ) );
|
2013-03-23 16:48:31 +00:00
|
|
|
ui.displayStyle->addItem( QIcon( ":/icons/programicon.png" ), tr( "Modern" ), QString( "modern" ) );
|
2009-05-11 11:03:36 +00:00
|
|
|
ui.displayStyle->addItem( QIcon( ":/icons/icon32_dsl.png" ), tr( "Lingvo" ), QString( "lingvo" ) );
|
2012-01-28 03:07:23 +00:00
|
|
|
ui.displayStyle->addItem( QIcon( ":/icons/icon32_bgl.png" ), tr( "Babylon" ), QString( "babylon" ) );
|
2013-03-23 18:17:40 +00:00
|
|
|
ui.displayStyle->addItem( QIcon( ":/icons/icon32_lingoes.png" ), tr( "Lingoes" ), QString( "lingoes" ) );
|
2013-03-24 20:19:03 +00:00
|
|
|
ui.displayStyle->addItem( QIcon( ":/icons/icon32_lingoes.png" ), tr( "Lingoes-Blue" ), QString( "lingoes-blue" ) );
|
2009-05-11 11:03:36 +00:00
|
|
|
|
2023-07-20 12:10:44 +00:00
|
|
|
for ( int x = 0; x < ui.displayStyle->count(); ++x ) {
|
2009-05-11 11:03:36 +00:00
|
|
|
if ( ui.displayStyle->itemData( x ).toString() == p.displayStyle ) {
|
|
|
|
ui.displayStyle->setCurrentIndex( x );
|
|
|
|
break;
|
|
|
|
}
|
2023-07-20 12:10:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#if !defined( Q_OS_WIN )
|
|
|
|
ui.InterfaceStyle->addItem( "Default", "Default" );
|
|
|
|
|
|
|
|
for ( const auto & style : QStyleFactory::keys() ) {
|
|
|
|
ui.InterfaceStyle->addItem( style, style );
|
|
|
|
}
|
|
|
|
|
|
|
|
for ( int i = 0; i < ui.InterfaceStyle->count(); ++i ) {
|
|
|
|
if ( ui.InterfaceStyle->itemData( i ).toString() == p.interfaceStyle ) {
|
|
|
|
ui.InterfaceStyle->setCurrentIndex( i );
|
|
|
|
prevInterfaceStyle = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined( Q_OS_WIN )
|
|
|
|
ui.interfaceStyleLabel->hide();
|
|
|
|
ui.InterfaceStyle->hide();
|
|
|
|
#endif
|
2009-05-11 11:03:36 +00:00
|
|
|
|
2020-11-12 15:57:10 +00:00
|
|
|
#ifdef Q_OS_WIN32
|
|
|
|
// 1 MB stands for 2^20 bytes on Windows. "MiB" is never used by this OS.
|
|
|
|
ui.maxNetworkCacheSize->setSuffix( tr( " MB" ) );
|
|
|
|
#endif
|
2023-04-25 14:09:13 +00:00
|
|
|
ui.maxNetworkCacheSize->setToolTip( ui.maxNetworkCacheSize->toolTip().arg( Config::getCacheDir() ) );
|
2020-11-12 15:57:10 +00:00
|
|
|
|
2009-04-13 12:51:25 +00:00
|
|
|
ui.newTabsOpenAfterCurrentOne->setChecked( p.newTabsOpenAfterCurrentOne );
|
|
|
|
ui.newTabsOpenInBackground->setChecked( p.newTabsOpenInBackground );
|
2011-06-23 14:17:09 +00:00
|
|
|
ui.hideSingleTab->setChecked( p.hideSingleTab );
|
2011-11-02 23:37:50 +00:00
|
|
|
ui.mruTabOrder->setChecked( p.mruTabOrder );
|
2009-02-05 20:55:00 +00:00
|
|
|
ui.enableTrayIcon->setChecked( p.enableTrayIcon );
|
|
|
|
ui.startToTray->setChecked( p.startToTray );
|
|
|
|
ui.closeToTray->setChecked( p.closeToTray );
|
2009-04-18 18:21:12 +00:00
|
|
|
ui.cbAutostart->setChecked( p.autoStart );
|
2010-04-08 20:37:59 +00:00
|
|
|
ui.doubleClickTranslates->setChecked( p.doubleClickTranslates );
|
2012-09-26 13:59:48 +00:00
|
|
|
ui.selectBySingleClick->setChecked( p.selectWordBySingleClick );
|
2019-01-11 13:50:40 +00:00
|
|
|
ui.autoScrollToTargetArticle->setChecked( p.autoScrollToTargetArticle );
|
2011-05-07 13:42:49 +00:00
|
|
|
ui.escKeyHidesMainWindow->setChecked( p.escKeyHidesMainWindow );
|
2022-12-11 01:22:54 +00:00
|
|
|
ui.darkMode->setChecked( p.darkMode );
|
2022-12-26 17:26:29 +00:00
|
|
|
ui.darkReaderMode->setChecked( p.darkReaderMode );
|
2022-12-22 12:55:42 +00:00
|
|
|
#ifndef Q_OS_WIN32
|
|
|
|
ui.darkMode->hide();
|
|
|
|
#endif
|
2009-04-21 18:27:26 +00:00
|
|
|
|
|
|
|
ui.enableMainWindowHotkey->setChecked( p.enableMainWindowHotkey );
|
2022-12-29 17:11:22 +00:00
|
|
|
ui.mainWindowHotkey->setKeySequence( p.mainWindowHotkey );
|
2009-04-21 18:27:26 +00:00
|
|
|
ui.enableClipboardHotkey->setChecked( p.enableClipboardHotkey );
|
2022-12-29 17:11:22 +00:00
|
|
|
ui.clipboardHotkey->setKeySequence( p.clipboardHotkey );
|
2009-04-21 18:27:26 +00:00
|
|
|
|
2009-02-08 20:20:02 +00:00
|
|
|
ui.startWithScanPopupOn->setChecked( p.startWithScanPopupOn );
|
2022-11-17 08:41:51 +00:00
|
|
|
ui.enableScanPopupModifiers->setChecked( p.enableScanPopupModifiers );
|
|
|
|
|
|
|
|
ui.altKey->setChecked( p.scanPopupModifiers & KeyboardState::Alt );
|
|
|
|
ui.ctrlKey->setChecked( p.scanPopupModifiers & KeyboardState::Ctrl );
|
|
|
|
ui.shiftKey->setChecked( p.scanPopupModifiers & KeyboardState::Shift );
|
|
|
|
ui.winKey->setChecked( p.scanPopupModifiers & KeyboardState::Win );
|
|
|
|
ui.leftAlt->setChecked( p.scanPopupModifiers & KeyboardState::LeftAlt );
|
|
|
|
ui.rightAlt->setChecked( p.scanPopupModifiers & KeyboardState::RightAlt );
|
|
|
|
ui.leftCtrl->setChecked( p.scanPopupModifiers & KeyboardState::LeftCtrl );
|
|
|
|
ui.rightCtrl->setChecked( p.scanPopupModifiers & KeyboardState::RightCtrl );
|
|
|
|
ui.leftShift->setChecked( p.scanPopupModifiers & KeyboardState::LeftShift );
|
|
|
|
ui.rightShift->setChecked( p.scanPopupModifiers & KeyboardState::RightShift );
|
|
|
|
|
2018-04-16 12:23:22 +00:00
|
|
|
ui.ignoreOwnClipboardChanges->setChecked( p.ignoreOwnClipboardChanges );
|
2011-11-16 12:52:25 +00:00
|
|
|
ui.scanToMainWindow->setChecked( p.scanToMainWindow );
|
2009-04-11 16:44:14 +00:00
|
|
|
|
2012-09-11 13:03:10 +00:00
|
|
|
ui.storeHistory->setChecked( p.storeHistory );
|
2013-01-17 09:08:53 +00:00
|
|
|
ui.historyMaxSizeField->setValue( p.maxStringsInHistory );
|
2013-02-05 12:51:23 +00:00
|
|
|
ui.historySaveIntervalField->setValue( p.historyStoreInterval );
|
2012-09-16 10:19:47 +00:00
|
|
|
ui.alwaysExpandOptionalParts->setChecked( p.alwaysExpandOptionalParts );
|
2012-09-11 13:03:10 +00:00
|
|
|
|
2017-05-13 10:18:25 +00:00
|
|
|
ui.favoritesSaveIntervalField->setValue( p.favoritesStoreInterval );
|
2017-05-17 15:26:32 +00:00
|
|
|
ui.confirmFavoritesDeletion->setChecked( p.confirmFavoritesDeletion );
|
2017-05-13 10:18:25 +00:00
|
|
|
|
2013-06-02 11:20:33 +00:00
|
|
|
ui.collapseBigArticles->setChecked( p.collapseBigArticles );
|
2020-11-19 12:10:36 +00:00
|
|
|
on_collapseBigArticles_toggled( ui.collapseBigArticles->isChecked() );
|
2013-06-02 11:20:33 +00:00
|
|
|
ui.articleSizeLimit->setValue( p.articleSizeLimit );
|
2020-11-19 12:10:36 +00:00
|
|
|
|
2020-11-06 19:51:30 +00:00
|
|
|
ui.limitInputPhraseLength->setChecked( p.limitInputPhraseLength );
|
2020-11-19 12:10:36 +00:00
|
|
|
on_limitInputPhraseLength_toggled( ui.limitInputPhraseLength->isChecked() );
|
2020-11-06 19:51:30 +00:00
|
|
|
ui.inputPhraseLengthLimit->setValue( p.inputPhraseLengthLimit );
|
2020-11-19 12:10:36 +00:00
|
|
|
|
2018-06-13 16:00:42 +00:00
|
|
|
ui.ignoreDiacritics->setChecked( p.ignoreDiacritics );
|
2013-06-02 11:20:33 +00:00
|
|
|
|
2022-04-23 08:15:23 +00:00
|
|
|
ui.ignorePunctuation->setChecked( p.ignorePunctuation );
|
2023-04-15 02:48:12 +00:00
|
|
|
ui.sessionCollapse->setChecked( p.sessionCollapse );
|
2022-04-23 08:15:23 +00:00
|
|
|
|
2017-03-09 16:11:17 +00:00
|
|
|
ui.synonymSearchEnabled->setChecked( p.synonymSearchEnabled );
|
|
|
|
|
2022-12-13 13:42:53 +00:00
|
|
|
ui.stripClipboard->setChecked( p.stripClipboard );
|
|
|
|
|
2023-03-17 01:54:45 +00:00
|
|
|
ui.raiseWindowOnSearch->setChecked( p.raiseWindowOnSearch );
|
|
|
|
|
2013-06-11 18:31:01 +00:00
|
|
|
ui.maxDictsInContextMenu->setValue( p.maxDictionaryRefsInContextMenu );
|
|
|
|
|
2009-02-05 20:55:00 +00:00
|
|
|
// Different platforms have different keys available
|
|
|
|
|
2022-11-17 08:41:51 +00:00
|
|
|
#ifdef Q_OS_WIN32
|
|
|
|
ui.winKey->hide();
|
|
|
|
#else
|
|
|
|
ui.leftAlt->hide();
|
|
|
|
ui.rightAlt->hide();
|
|
|
|
ui.leftCtrl->hide();
|
|
|
|
ui.rightCtrl->hide();
|
|
|
|
ui.leftShift->hide();
|
|
|
|
ui.rightShift->hide();
|
|
|
|
#ifdef Q_OS_MAC
|
|
|
|
ui.altKey->setText( "Opt" );
|
|
|
|
ui.winKey->setText( "Ctrl" );
|
|
|
|
ui.ctrlKey->setText( "Cmd" );
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2011-07-23 11:32:15 +00:00
|
|
|
//Platform-specific options
|
|
|
|
|
2017-06-05 13:15:38 +00:00
|
|
|
#ifdef HAVE_X11
|
2022-11-19 16:35:25 +00:00
|
|
|
ui.enableX11SelectionTrack->setChecked( p.trackSelectionScan );
|
|
|
|
ui.enableClipboardTrack->setChecked( p.trackClipboardScan );
|
|
|
|
ui.showScanFlag->setChecked( p.showScanFlag );
|
2023-06-05 11:30:14 +00:00
|
|
|
ui.delayTimer->setValue( p.selectionChangeDelayTimer );
|
2017-06-05 13:15:38 +00:00
|
|
|
#else
|
2022-11-19 16:35:25 +00:00
|
|
|
ui.enableX11SelectionTrack->hide();
|
|
|
|
ui.enableClipboardTrack->hide();
|
2017-06-05 13:15:38 +00:00
|
|
|
ui.showScanFlag->hide();
|
2018-04-16 12:23:22 +00:00
|
|
|
ui.ignoreOwnClipboardChanges->hide();
|
2023-06-05 11:30:14 +00:00
|
|
|
ui.delayTimer->hide();
|
2017-06-05 13:15:38 +00:00
|
|
|
#endif
|
|
|
|
|
2009-04-10 21:07:03 +00:00
|
|
|
// Sound
|
|
|
|
|
|
|
|
ui.pronounceOnLoadMain->setChecked( p.pronounceOnLoadMain );
|
|
|
|
ui.pronounceOnLoadPopup->setChecked( p.pronounceOnLoadPopup );
|
|
|
|
|
2018-03-29 17:00:53 +00:00
|
|
|
ui.internalPlayerBackend->addItems( Config::InternalPlayerBackend::nameList() );
|
|
|
|
|
|
|
|
// Make sure that exactly one radio button in the group is checked and that
|
|
|
|
// on_useExternalPlayer_toggled() is called.
|
|
|
|
ui.useExternalPlayer->setChecked( true );
|
|
|
|
|
|
|
|
if ( ui.internalPlayerBackend->count() > 0 ) {
|
|
|
|
// Checking ui.useInternalPlayer automatically unchecks ui.useExternalPlayer.
|
|
|
|
ui.useInternalPlayer->setChecked( p.useInternalPlayer );
|
|
|
|
|
|
|
|
int index = ui.internalPlayerBackend->findText( p.internalPlayerBackend.uiName() );
|
|
|
|
if ( index < 0 ) // The specified backend is unavailable.
|
|
|
|
index = ui.internalPlayerBackend->findText( Config::InternalPlayerBackend::defaultBackend().uiName() );
|
|
|
|
Q_ASSERT( index >= 0 && "Logic error: the default backend must be present in the backend name list." );
|
|
|
|
ui.internalPlayerBackend->setCurrentIndex( index );
|
|
|
|
}
|
2013-05-05 10:22:12 +00:00
|
|
|
else {
|
2018-03-29 17:00:53 +00:00
|
|
|
ui.useInternalPlayer->hide();
|
|
|
|
ui.internalPlayerBackend->hide();
|
|
|
|
}
|
2010-11-14 15:38:41 +00:00
|
|
|
|
2010-01-02 18:16:22 +00:00
|
|
|
ui.audioPlaybackProgram->setText( p.audioPlaybackProgram );
|
2009-04-10 21:07:03 +00:00
|
|
|
|
2009-04-03 17:10:27 +00:00
|
|
|
// Proxy server
|
|
|
|
|
|
|
|
ui.useProxyServer->setChecked( p.proxyServer.enabled );
|
|
|
|
|
|
|
|
ui.proxyType->addItem( "SOCKS5" );
|
|
|
|
ui.proxyType->addItem( "HTTP Transp." );
|
|
|
|
ui.proxyType->addItem( "HTTP Caching" );
|
|
|
|
|
|
|
|
ui.proxyType->setCurrentIndex( p.proxyServer.type );
|
|
|
|
|
|
|
|
ui.proxyHost->setText( p.proxyServer.host );
|
|
|
|
ui.proxyPort->setValue( p.proxyServer.port );
|
|
|
|
|
|
|
|
ui.proxyUser->setText( p.proxyServer.user );
|
|
|
|
ui.proxyPassword->setText( p.proxyServer.password );
|
2009-04-20 19:54:34 +00:00
|
|
|
|
2014-04-01 17:00:13 +00:00
|
|
|
if ( p.proxyServer.useSystemProxy ) {
|
|
|
|
ui.systemProxy->setChecked( true );
|
|
|
|
ui.customSettingsGroup->setEnabled( false );
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ui.customProxy->setChecked( true );
|
|
|
|
ui.customSettingsGroup->setEnabled( p.proxyServer.enabled );
|
|
|
|
}
|
|
|
|
|
2022-05-21 02:30:32 +00:00
|
|
|
//anki connect
|
|
|
|
ui.useAnkiConnect->setChecked( p.ankiConnectServer.enabled );
|
|
|
|
ui.ankiHost->setText( p.ankiConnectServer.host );
|
|
|
|
ui.ankiPort->setValue( p.ankiConnectServer.port );
|
2022-05-21 06:03:26 +00:00
|
|
|
ui.ankiModel->setText( p.ankiConnectServer.model );
|
|
|
|
ui.ankiDeck->setText( p.ankiConnectServer.deck );
|
2023-03-16 11:55:47 +00:00
|
|
|
//anki connect fields
|
|
|
|
ui.ankiText->setText( p.ankiConnectServer.text );
|
|
|
|
ui.ankiWord->setText( p.ankiConnectServer.word );
|
|
|
|
ui.ankiSentence->setText( p.ankiConnectServer.sentence );
|
2022-05-21 02:30:32 +00:00
|
|
|
|
2022-12-26 02:08:17 +00:00
|
|
|
connect( ui.customProxy, &QAbstractButton::toggled, this, &Preferences::customProxyToggled );
|
2014-04-01 17:00:13 +00:00
|
|
|
|
2022-12-26 02:08:17 +00:00
|
|
|
connect( ui.useProxyServer, &QGroupBox::toggled, this, &Preferences::customProxyToggled );
|
2014-04-01 17:00:13 +00:00
|
|
|
|
2009-04-20 19:54:34 +00:00
|
|
|
ui.checkForNewReleases->setChecked( p.checkForNewReleases );
|
2009-08-31 12:18:08 +00:00
|
|
|
ui.disallowContentFromOtherSites->setChecked( p.disallowContentFromOtherSites );
|
2013-04-08 12:20:12 +00:00
|
|
|
ui.hideGoldenDictHeader->setChecked( p.hideGoldenDictHeader );
|
2020-11-12 15:57:10 +00:00
|
|
|
ui.maxNetworkCacheSize->setValue( p.maxNetworkCacheSize );
|
|
|
|
ui.clearNetworkCacheOnExit->setChecked( p.clearNetworkCacheOnExit );
|
2012-12-10 14:14:13 +00:00
|
|
|
|
2023-08-17 15:17:53 +00:00
|
|
|
//Misc
|
|
|
|
ui.removeInvalidIndexOnExit->setChecked( p.removeInvalidIndexOnExit );
|
|
|
|
|
2012-12-10 14:14:13 +00:00
|
|
|
// Add-on styles
|
|
|
|
ui.addonStylesLabel->setVisible( ui.addonStyles->count() > 1 );
|
|
|
|
ui.addonStyles->setCurrentStyle( p.addonStyle );
|
2014-04-17 14:31:51 +00:00
|
|
|
|
|
|
|
// Full-text search parameters
|
|
|
|
ui.ftsGroupBox->setChecked( p.fts.enabled );
|
|
|
|
|
|
|
|
ui.allowAard->setChecked( !p.fts.disabledTypes.contains( "AARD", Qt::CaseInsensitive ) );
|
|
|
|
ui.allowBGL->setChecked( !p.fts.disabledTypes.contains( "BGL", Qt::CaseInsensitive ) );
|
|
|
|
ui.allowDictD->setChecked( !p.fts.disabledTypes.contains( "DICTD", Qt::CaseInsensitive ) );
|
|
|
|
ui.allowDSL->setChecked( !p.fts.disabledTypes.contains( "DSL", Qt::CaseInsensitive ) );
|
|
|
|
ui.allowMDict->setChecked( !p.fts.disabledTypes.contains( "MDICT", Qt::CaseInsensitive ) );
|
|
|
|
ui.allowSDict->setChecked( !p.fts.disabledTypes.contains( "SDICT", Qt::CaseInsensitive ) );
|
2015-01-22 15:17:05 +00:00
|
|
|
ui.allowSlob->setChecked( !p.fts.disabledTypes.contains( "SLOB", Qt::CaseInsensitive ) );
|
2014-04-17 14:31:51 +00:00
|
|
|
ui.allowStardict->setChecked( !p.fts.disabledTypes.contains( "STARDICT", Qt::CaseInsensitive ) );
|
|
|
|
ui.allowXDXF->setChecked( !p.fts.disabledTypes.contains( "XDXF", Qt::CaseInsensitive ) );
|
|
|
|
ui.allowZim->setChecked( !p.fts.disabledTypes.contains( "ZIM", Qt::CaseInsensitive ) );
|
2014-05-20 13:59:56 +00:00
|
|
|
ui.allowEpwing->setChecked( !p.fts.disabledTypes.contains( "EPWING", Qt::CaseInsensitive ) );
|
2017-03-06 15:07:39 +00:00
|
|
|
ui.allowGls->setChecked( !p.fts.disabledTypes.contains( "GLS", Qt::CaseInsensitive ) );
|
2023-07-01 14:39:43 +00:00
|
|
|
|
|
|
|
ui.enablePosition->setChecked( p.fts.enablePosition );
|
2014-04-20 08:42:45 +00:00
|
|
|
#ifndef MAKE_ZIM_SUPPORT
|
|
|
|
ui.allowZim->hide();
|
2014-05-20 13:59:56 +00:00
|
|
|
#endif
|
|
|
|
#ifdef NO_EPWING_SUPPORT
|
|
|
|
ui.allowEpwing->hide();
|
2014-04-20 08:42:45 +00:00
|
|
|
#endif
|
2014-04-17 14:31:51 +00:00
|
|
|
ui.maxDictionarySize->setValue( p.fts.maxDictionarySize );
|
2023-07-20 14:50:32 +00:00
|
|
|
|
|
|
|
ui.parallelThreads->setMaximum( QThread::idealThreadCount() );
|
|
|
|
ui.parallelThreads->setValue( p.fts.parallelThreads );
|
2009-02-05 20:55:00 +00:00
|
|
|
}
|
|
|
|
|
2023-06-01 11:53:45 +00:00
|
|
|
void Preferences::buildDisabledTypes( QString & disabledTypes, bool is_checked, QString name )
|
2023-06-01 11:52:16 +00:00
|
|
|
{
|
2023-06-01 11:53:45 +00:00
|
|
|
if ( !is_checked ) {
|
2023-06-01 11:52:16 +00:00
|
|
|
if ( !disabledTypes.isEmpty() )
|
|
|
|
disabledTypes += ',';
|
2023-06-01 11:53:45 +00:00
|
|
|
disabledTypes += name;
|
2023-06-01 11:52:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-02-05 20:55:00 +00:00
|
|
|
Config::Preferences Preferences::getPreferences()
|
|
|
|
{
|
|
|
|
Config::Preferences p;
|
|
|
|
|
2009-04-12 20:46:25 +00:00
|
|
|
p.interfaceLanguage = ui.interfaceLanguage->itemData( ui.interfaceLanguage->currentIndex() ).toString();
|
|
|
|
|
2023-09-07 01:53:51 +00:00
|
|
|
p.interfaceFont = ui.systemFont->currentText();
|
|
|
|
|
2023-07-16 10:54:07 +00:00
|
|
|
Config::CustomFonts c;
|
|
|
|
c.standard = ui.font_standard->currentText();
|
|
|
|
c.serif = ui.font_serif->currentText();
|
|
|
|
c.sansSerif = ui.font_sans->currentText();
|
|
|
|
c.monospace = ui.font_monospace->currentText();
|
|
|
|
p.customFonts = c;
|
|
|
|
|
2022-05-08 08:00:08 +00:00
|
|
|
|
2009-05-11 11:03:36 +00:00
|
|
|
p.displayStyle = ui.displayStyle->itemData( ui.displayStyle->currentIndex() ).toString();
|
2023-07-20 12:10:44 +00:00
|
|
|
#if !defined( Q_OS_WIN )
|
|
|
|
p.interfaceStyle = ui.InterfaceStyle->itemData( ui.InterfaceStyle->currentIndex() ).toString();
|
|
|
|
#endif
|
2009-05-11 11:03:36 +00:00
|
|
|
|
2009-04-13 12:51:25 +00:00
|
|
|
p.newTabsOpenAfterCurrentOne = ui.newTabsOpenAfterCurrentOne->isChecked();
|
|
|
|
p.newTabsOpenInBackground = ui.newTabsOpenInBackground->isChecked();
|
2011-06-23 14:17:09 +00:00
|
|
|
p.hideSingleTab = ui.hideSingleTab->isChecked();
|
2011-11-02 23:37:50 +00:00
|
|
|
p.mruTabOrder = ui.mruTabOrder->isChecked();
|
2009-02-08 20:20:02 +00:00
|
|
|
p.enableTrayIcon = ui.enableTrayIcon->isChecked();
|
|
|
|
p.startToTray = ui.startToTray->isChecked();
|
|
|
|
p.closeToTray = ui.closeToTray->isChecked();
|
2009-04-18 18:21:12 +00:00
|
|
|
p.autoStart = ui.cbAutostart->isChecked();
|
2010-04-08 20:37:59 +00:00
|
|
|
p.doubleClickTranslates = ui.doubleClickTranslates->isChecked();
|
2012-09-26 13:59:48 +00:00
|
|
|
p.selectWordBySingleClick = ui.selectBySingleClick->isChecked();
|
2019-01-11 13:50:40 +00:00
|
|
|
p.autoScrollToTargetArticle = ui.autoScrollToTargetArticle->isChecked();
|
2011-05-07 13:42:49 +00:00
|
|
|
p.escKeyHidesMainWindow = ui.escKeyHidesMainWindow->isChecked();
|
2023-07-20 08:02:22 +00:00
|
|
|
|
2022-12-11 01:22:54 +00:00
|
|
|
p.darkMode = ui.darkMode->isChecked();
|
2022-12-26 17:26:29 +00:00
|
|
|
p.darkReaderMode = ui.darkReaderMode->isChecked();
|
2009-04-21 18:27:26 +00:00
|
|
|
p.enableMainWindowHotkey = ui.enableMainWindowHotkey->isChecked();
|
2022-12-29 17:11:22 +00:00
|
|
|
p.mainWindowHotkey = ui.mainWindowHotkey->keySequence();
|
2009-04-21 18:27:26 +00:00
|
|
|
p.enableClipboardHotkey = ui.enableClipboardHotkey->isChecked();
|
2022-12-29 17:11:22 +00:00
|
|
|
p.clipboardHotkey = ui.clipboardHotkey->keySequence();
|
2009-04-21 18:27:26 +00:00
|
|
|
|
2009-02-08 20:20:02 +00:00
|
|
|
p.startWithScanPopupOn = ui.startWithScanPopupOn->isChecked();
|
2022-11-17 08:41:51 +00:00
|
|
|
p.enableScanPopupModifiers = ui.enableScanPopupModifiers->isChecked();
|
|
|
|
|
|
|
|
p.scanPopupModifiers += ui.altKey->isChecked() ? KeyboardState::Alt : 0;
|
|
|
|
p.scanPopupModifiers += ui.ctrlKey->isChecked() ? KeyboardState::Ctrl : 0;
|
|
|
|
p.scanPopupModifiers += ui.shiftKey->isChecked() ? KeyboardState::Shift : 0;
|
|
|
|
p.scanPopupModifiers += ui.winKey->isChecked() ? KeyboardState::Win : 0;
|
|
|
|
p.scanPopupModifiers += ui.leftAlt->isChecked() ? KeyboardState::LeftAlt : 0;
|
|
|
|
p.scanPopupModifiers += ui.rightAlt->isChecked() ? KeyboardState::RightAlt : 0;
|
|
|
|
p.scanPopupModifiers += ui.leftCtrl->isChecked() ? KeyboardState::LeftCtrl : 0;
|
|
|
|
p.scanPopupModifiers += ui.rightCtrl->isChecked() ? KeyboardState::RightCtrl : 0;
|
|
|
|
p.scanPopupModifiers += ui.leftShift->isChecked() ? KeyboardState::LeftShift : 0;
|
|
|
|
p.scanPopupModifiers += ui.rightShift->isChecked() ? KeyboardState::RightShift : 0;
|
|
|
|
|
2018-04-16 12:23:22 +00:00
|
|
|
p.ignoreOwnClipboardChanges = ui.ignoreOwnClipboardChanges->isChecked();
|
2011-11-16 12:52:25 +00:00
|
|
|
p.scanToMainWindow = ui.scanToMainWindow->isChecked();
|
2017-06-05 13:15:38 +00:00
|
|
|
#ifdef HAVE_X11
|
2022-11-19 16:35:25 +00:00
|
|
|
p.trackSelectionScan = ui.enableX11SelectionTrack->isChecked();
|
|
|
|
p.trackClipboardScan = ui.enableClipboardTrack->isChecked();
|
2017-06-05 13:15:38 +00:00
|
|
|
p.showScanFlag = ui.showScanFlag->isChecked();
|
2023-06-05 11:30:14 +00:00
|
|
|
p.selectionChangeDelayTimer = ui.delayTimer->value();
|
2017-06-05 13:15:38 +00:00
|
|
|
#endif
|
2009-04-11 16:44:14 +00:00
|
|
|
|
2012-09-11 13:03:10 +00:00
|
|
|
p.storeHistory = ui.storeHistory->isChecked();
|
2013-01-17 09:08:53 +00:00
|
|
|
p.maxStringsInHistory = ui.historyMaxSizeField->text().toUInt();
|
2013-02-05 12:51:23 +00:00
|
|
|
p.historyStoreInterval = ui.historySaveIntervalField->text().toUInt();
|
2012-09-16 10:19:47 +00:00
|
|
|
p.alwaysExpandOptionalParts = ui.alwaysExpandOptionalParts->isChecked();
|
2012-09-11 13:03:10 +00:00
|
|
|
|
2017-05-13 10:18:25 +00:00
|
|
|
p.favoritesStoreInterval = ui.favoritesSaveIntervalField->text().toUInt();
|
2017-05-17 15:26:32 +00:00
|
|
|
p.confirmFavoritesDeletion = ui.confirmFavoritesDeletion->isChecked();
|
2017-05-13 10:18:25 +00:00
|
|
|
|
2013-06-02 11:20:33 +00:00
|
|
|
p.collapseBigArticles = ui.collapseBigArticles->isChecked();
|
2020-11-06 19:51:44 +00:00
|
|
|
p.articleSizeLimit = ui.articleSizeLimit->value();
|
2020-11-06 19:51:30 +00:00
|
|
|
p.limitInputPhraseLength = ui.limitInputPhraseLength->isChecked();
|
|
|
|
p.inputPhraseLengthLimit = ui.inputPhraseLengthLimit->value();
|
2018-06-13 16:00:42 +00:00
|
|
|
p.ignoreDiacritics = ui.ignoreDiacritics->isChecked();
|
2022-04-23 08:15:23 +00:00
|
|
|
p.ignorePunctuation = ui.ignorePunctuation->isChecked();
|
2023-04-15 02:48:12 +00:00
|
|
|
p.sessionCollapse = ui.sessionCollapse->isChecked();
|
2022-12-13 13:42:53 +00:00
|
|
|
p.stripClipboard = ui.stripClipboard->isChecked();
|
2023-03-17 01:54:45 +00:00
|
|
|
p.raiseWindowOnSearch = ui.raiseWindowOnSearch->isChecked();
|
2013-06-02 11:20:33 +00:00
|
|
|
|
2017-03-09 16:11:17 +00:00
|
|
|
p.synonymSearchEnabled = ui.synonymSearchEnabled->isChecked();
|
|
|
|
|
2013-06-11 18:31:01 +00:00
|
|
|
p.maxDictionaryRefsInContextMenu = ui.maxDictsInContextMenu->text().toInt();
|
|
|
|
|
2009-04-10 21:07:03 +00:00
|
|
|
p.pronounceOnLoadMain = ui.pronounceOnLoadMain->isChecked();
|
|
|
|
p.pronounceOnLoadPopup = ui.pronounceOnLoadPopup->isChecked();
|
2013-05-05 10:22:12 +00:00
|
|
|
p.useInternalPlayer = ui.useInternalPlayer->isChecked();
|
2018-03-29 17:00:53 +00:00
|
|
|
p.internalPlayerBackend.setUiName( ui.internalPlayerBackend->currentText() );
|
2009-04-10 21:07:03 +00:00
|
|
|
p.audioPlaybackProgram = ui.audioPlaybackProgram->text();
|
|
|
|
|
2009-04-03 17:10:27 +00:00
|
|
|
p.proxyServer.enabled = ui.useProxyServer->isChecked();
|
2014-04-01 17:00:13 +00:00
|
|
|
p.proxyServer.useSystemProxy = ui.systemProxy->isChecked();
|
2009-04-03 17:10:27 +00:00
|
|
|
|
|
|
|
p.proxyServer.type = (Config::ProxyServer::Type)ui.proxyType->currentIndex();
|
|
|
|
|
|
|
|
p.proxyServer.host = ui.proxyHost->text();
|
|
|
|
p.proxyServer.port = (unsigned)ui.proxyPort->value();
|
|
|
|
|
|
|
|
p.proxyServer.user = ui.proxyUser->text();
|
|
|
|
p.proxyServer.password = ui.proxyPassword->text();
|
|
|
|
|
2022-05-21 02:30:32 +00:00
|
|
|
//anki connect
|
|
|
|
p.ankiConnectServer.enabled = ui.useAnkiConnect->isChecked();
|
|
|
|
p.ankiConnectServer.host = ui.ankiHost->text();
|
|
|
|
p.ankiConnectServer.port = (unsigned)ui.ankiPort->value();
|
2022-05-21 06:03:26 +00:00
|
|
|
p.ankiConnectServer.deck = ui.ankiDeck->text();
|
|
|
|
p.ankiConnectServer.model = ui.ankiModel->text();
|
2023-03-16 11:55:47 +00:00
|
|
|
//anki connect fields
|
|
|
|
p.ankiConnectServer.text = ui.ankiText->text();
|
|
|
|
p.ankiConnectServer.word = ui.ankiWord->text();
|
|
|
|
p.ankiConnectServer.sentence = ui.ankiSentence->text();
|
2022-05-21 02:30:32 +00:00
|
|
|
|
2009-04-20 19:54:34 +00:00
|
|
|
p.checkForNewReleases = ui.checkForNewReleases->isChecked();
|
2009-08-31 12:18:08 +00:00
|
|
|
p.disallowContentFromOtherSites = ui.disallowContentFromOtherSites->isChecked();
|
2013-04-08 12:20:12 +00:00
|
|
|
p.hideGoldenDictHeader = ui.hideGoldenDictHeader->isChecked();
|
2020-11-12 15:57:10 +00:00
|
|
|
p.maxNetworkCacheSize = ui.maxNetworkCacheSize->value();
|
|
|
|
p.clearNetworkCacheOnExit = ui.clearNetworkCacheOnExit->isChecked();
|
2009-04-20 19:54:34 +00:00
|
|
|
|
2023-08-17 15:17:53 +00:00
|
|
|
p.removeInvalidIndexOnExit = ui.removeInvalidIndexOnExit->isChecked();
|
|
|
|
|
2012-12-10 14:14:13 +00:00
|
|
|
p.addonStyle = ui.addonStyles->getCurrentStyle();
|
|
|
|
|
2023-07-02 03:41:05 +00:00
|
|
|
p.fts.enabled = ui.ftsGroupBox->isChecked();
|
2014-04-17 14:31:51 +00:00
|
|
|
p.fts.maxDictionarySize = ui.maxDictionarySize->value();
|
2023-07-20 14:50:32 +00:00
|
|
|
p.fts.parallelThreads = ui.parallelThreads->value();
|
2023-07-02 03:41:05 +00:00
|
|
|
p.fts.enablePosition = ui.enablePosition->isChecked();
|
2014-04-17 14:31:51 +00:00
|
|
|
|
2023-06-01 11:52:16 +00:00
|
|
|
buildDisabledTypes( p.fts.disabledTypes, ui.allowAard->isChecked(), "AARD" );
|
|
|
|
buildDisabledTypes( p.fts.disabledTypes, ui.allowBGL->isChecked(), "BGL" );
|
|
|
|
buildDisabledTypes( p.fts.disabledTypes, ui.allowDictD->isChecked(), "DICTD" );
|
|
|
|
buildDisabledTypes( p.fts.disabledTypes, ui.allowDSL->isChecked(), "DSL" );
|
|
|
|
buildDisabledTypes( p.fts.disabledTypes, ui.allowMDict->isChecked(), "MDICT" );
|
|
|
|
buildDisabledTypes( p.fts.disabledTypes, ui.allowSDict->isChecked(), "SDICT" );
|
|
|
|
buildDisabledTypes( p.fts.disabledTypes, ui.allowSlob->isChecked(), "SLOB" );
|
|
|
|
buildDisabledTypes( p.fts.disabledTypes, ui.allowStardict->isChecked(), "STARDICT" );
|
|
|
|
buildDisabledTypes( p.fts.disabledTypes, ui.allowXDXF->isChecked(), "XDXF" );
|
|
|
|
buildDisabledTypes( p.fts.disabledTypes, ui.allowZim->isChecked(), "ZIM" );
|
|
|
|
buildDisabledTypes( p.fts.disabledTypes, ui.allowEpwing->isChecked(), "EPWING" );
|
|
|
|
buildDisabledTypes( p.fts.disabledTypes, ui.allowGls->isChecked(), "GLS" );
|
2017-03-06 15:07:39 +00:00
|
|
|
|
2009-02-05 20:55:00 +00:00
|
|
|
return p;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Preferences::enableScanPopupModifiersToggled( bool b )
|
|
|
|
{
|
2022-11-19 14:50:20 +00:00
|
|
|
ui.scanPopupModifiers->setEnabled( b );
|
2017-06-05 13:15:38 +00:00
|
|
|
if ( b )
|
|
|
|
ui.showScanFlag->setChecked( false );
|
|
|
|
}
|
|
|
|
|
2022-11-17 08:41:51 +00:00
|
|
|
void Preferences::showScanFlagToggled( bool b )
|
|
|
|
{
|
|
|
|
if ( b )
|
|
|
|
ui.enableScanPopupModifiers->setChecked( false );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Preferences::wholeAltClicked( bool b )
|
|
|
|
{
|
|
|
|
if ( b ) {
|
|
|
|
ui.leftAlt->setChecked( false );
|
|
|
|
ui.rightAlt->setChecked( false );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Preferences::wholeCtrlClicked( bool b )
|
|
|
|
{
|
|
|
|
if ( b ) {
|
|
|
|
ui.leftCtrl->setChecked( false );
|
|
|
|
ui.rightCtrl->setChecked( false );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Preferences::wholeShiftClicked( bool b )
|
|
|
|
{
|
|
|
|
if ( b ) {
|
|
|
|
ui.leftShift->setChecked( false );
|
|
|
|
ui.rightShift->setChecked( false );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Preferences::sideAltClicked( bool )
|
|
|
|
{
|
|
|
|
if ( ui.leftAlt->isChecked() || ui.rightAlt->isChecked() )
|
|
|
|
ui.altKey->setChecked( false );
|
|
|
|
}
|
|
|
|
|
|
|
|
void Preferences::sideCtrlClicked( bool )
|
|
|
|
{
|
|
|
|
if ( ui.leftCtrl->isChecked() || ui.rightCtrl->isChecked() )
|
|
|
|
ui.ctrlKey->setChecked( false );
|
|
|
|
}
|
|
|
|
|
|
|
|
void Preferences::sideShiftClicked( bool )
|
|
|
|
{
|
|
|
|
if ( ui.leftShift->isChecked() || ui.rightShift->isChecked() )
|
|
|
|
ui.shiftKey->setChecked( false );
|
|
|
|
}
|
2009-04-21 18:27:26 +00:00
|
|
|
void Preferences::on_enableMainWindowHotkey_toggled( bool checked )
|
|
|
|
{
|
|
|
|
ui.mainWindowHotkey->setEnabled( checked );
|
|
|
|
}
|
|
|
|
|
|
|
|
void Preferences::on_enableClipboardHotkey_toggled( bool checked )
|
|
|
|
{
|
2022-09-11 01:36:52 +00:00
|
|
|
ui.clipboardHotkey->setEnabled( checked );
|
2009-04-21 18:27:26 +00:00
|
|
|
}
|
|
|
|
|
2009-04-12 20:46:25 +00:00
|
|
|
void Preferences::on_buttonBox_accepted()
|
|
|
|
{
|
2023-09-07 01:53:51 +00:00
|
|
|
QString promptText;
|
|
|
|
|
|
|
|
if ( prevInterfaceLanguage != ui.interfaceLanguage->currentIndex() ) {
|
|
|
|
promptText = tr( "Restart the program to apply the language change." );
|
|
|
|
promptText += "\n";
|
|
|
|
}
|
2022-05-08 08:00:08 +00:00
|
|
|
|
2023-07-20 12:10:44 +00:00
|
|
|
#if !defined( Q_OS_WIN )
|
|
|
|
if ( prevInterfaceStyle != ui.InterfaceStyle->currentIndex() ) {
|
2023-09-07 01:53:51 +00:00
|
|
|
promptText += tr( "Restart to apply the interface style change." );
|
|
|
|
promptText += "\n";
|
2023-07-20 12:10:44 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2023-09-07 01:53:51 +00:00
|
|
|
if ( ui.systemFont->currentText() != prevSysFont ) {
|
|
|
|
promptText += tr( "Restart to apply the interface font change." );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( !promptText.isEmpty() ) {
|
|
|
|
QMessageBox::information( this, tr( "Restart needed" ), promptText );
|
|
|
|
}
|
2023-07-20 12:10:44 +00:00
|
|
|
|
2023-07-16 10:54:07 +00:00
|
|
|
auto c = getPreferences();
|
|
|
|
if ( c.customFonts != prevWebFontFamily ) {
|
|
|
|
QWebEngineProfile::defaultProfile()->settings()->setFontFamily( QWebEngineSettings::StandardFont,
|
|
|
|
c.customFonts.standard );
|
|
|
|
QWebEngineProfile::defaultProfile()->settings()->setFontFamily( QWebEngineSettings::SerifFont,
|
|
|
|
c.customFonts.serif );
|
|
|
|
QWebEngineProfile::defaultProfile()->settings()->setFontFamily( QWebEngineSettings::SansSerifFont,
|
|
|
|
c.customFonts.sansSerif );
|
|
|
|
QWebEngineProfile::defaultProfile()->settings()->setFontFamily( QWebEngineSettings::FixedFont,
|
|
|
|
c.customFonts.monospace );
|
2022-05-17 13:24:30 +00:00
|
|
|
}
|
2023-09-07 01:53:51 +00:00
|
|
|
|
|
|
|
//change interface font.
|
|
|
|
if ( ui.systemFont->currentText() != prevSysFont ) {
|
2023-09-28 06:12:42 +00:00
|
|
|
auto font = QApplication::font();
|
|
|
|
font.setFamily( ui.systemFont->currentText() );
|
|
|
|
QApplication::setFont( font );
|
2023-09-07 01:53:51 +00:00
|
|
|
}
|
2009-04-12 20:46:25 +00:00
|
|
|
}
|
|
|
|
|
2010-01-02 18:16:22 +00:00
|
|
|
void Preferences::on_useExternalPlayer_toggled( bool enabled )
|
|
|
|
{
|
2018-03-29 17:00:53 +00:00
|
|
|
ui.internalPlayerBackend->setEnabled( !enabled );
|
2010-01-02 18:16:22 +00:00
|
|
|
ui.audioPlaybackProgram->setEnabled( enabled );
|
|
|
|
}
|
|
|
|
|
2014-04-01 17:00:13 +00:00
|
|
|
void Preferences::customProxyToggled( bool )
|
|
|
|
{
|
|
|
|
ui.customSettingsGroup->setEnabled( ui.customProxy->isChecked() && ui.useProxyServer->isChecked() );
|
|
|
|
}
|
2014-06-24 13:55:06 +00:00
|
|
|
|
2020-11-12 15:57:10 +00:00
|
|
|
void Preferences::on_maxNetworkCacheSize_valueChanged( int value )
|
|
|
|
{
|
2020-11-19 10:49:23 +00:00
|
|
|
ui.clearNetworkCacheOnExit->setEnabled( value != 0 );
|
2020-11-12 15:57:10 +00:00
|
|
|
}
|
|
|
|
|
2020-11-19 12:10:36 +00:00
|
|
|
void Preferences::on_collapseBigArticles_toggled( bool checked )
|
|
|
|
{
|
|
|
|
ui.articleSizeLimit->setEnabled( checked );
|
|
|
|
}
|
|
|
|
|
|
|
|
void Preferences::on_limitInputPhraseLength_toggled( bool checked )
|
|
|
|
{
|
|
|
|
ui.inputPhraseLengthLimit->setEnabled( checked );
|
|
|
|
}
|