Merge pull request #287 from xiaoyifang/staged

merge staged to dev
This commit is contained in:
xiaoyifang 2022-12-28 16:40:15 +08:00 committed by GitHub
commit 37a0a9a314
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
50 changed files with 688 additions and 924 deletions

35
.clang-tidy Normal file
View file

@ -0,0 +1,35 @@
# https://clang.llvm.org/extra/clang-tidy/
---
Checks: >
-*
bugprone-*,
cert-*,
clang-analyzer-*,
clang-diagnostic-*,
cppcoreguidelines-*,
google-*,
misc-*,
modernize-*,
performance-*,
portability-*,
readability-*,
-bugprone-easily-swappable-parameters,
-bugprone-reserved-identifier,
-cppcoreguidelines-owning-memory,
-google-default-arguments,
-misc-non-private-member-variables-in-classes,
-misc-const-correctness,
-modernize-avoid-c-arrays,
-modernize-use-auto,
-modernize-use-nodiscard,
-modernize-use-trailing-return-type,
-readability-magic-numbers,
-google-readability-braces-around-statements,
-readability-braces-around-statements,
-readability-identifier-length,
-readability-function-cognitive-complexity,
CheckOptions:
- key: modernize-loop-convert.MinConfidence
value: reasonable
...

View file

@ -7,6 +7,8 @@ on:
push: push:
branches: branches:
- dev - dev
- staged
pull_request: pull_request:
types: [opened, synchronize, reopened] types: [opened, synchronize, reopened]
jobs: jobs:

4
.gitignore vendored
View file

@ -42,3 +42,7 @@ GoldenDict.xcodeproj/
/cmake-build-**/ /cmake-build-**/
/build**/ /build**/
CMakeLists.txt.user CMakeLists.txt.user
# kdevelop
.kdev4/
*.kdev4

View file

@ -88,7 +88,7 @@ About::About( QWidget * parent, std::vector< sptr< Dictionary::Class > > * dicto
QString::fromUtf8( QString::fromUtf8(
creditsFile.readAll() ).split( '\n', Qt::SkipEmptyParts ); creditsFile.readAll() ).split( '\n', Qt::SkipEmptyParts );
QString html = "<html><body style='color: black; background: #f4f4f4;'>"; QString html = "<html><body>";
for( int x = 0; x < creditsList.size(); ++x ) for( int x = 0; x < creditsList.size(); ++x )
{ {

View file

@ -149,20 +149,19 @@ std::string ArticleMaker::makeHtmlHeader( QString const & word,
"</script>"; "</script>";
result+= R"(<script type="text/javascript" src="qrc:///scripts/gd-builtin.js"></script>)"; result+= R"(<script type="text/javascript" src="qrc:///scripts/gd-builtin.js"></script>)";
#ifdef Q_OS_WIN32 if( GlobalBroadcaster::instance()->getPreference()->darkReaderMode )
if( GlobalBroadcaster::instance()->getPreference()->darkMode )
{ {
result += "<script type=\"text/javascript\" src=\"qrc:///scripts/darkreader.js\"></script>"; result += R"(
result += <script src="qrc:///scripts/darkreader.js"></script>
"<script type=\"text/javascript\">" <script>
"DarkReader.enable({" DarkReader.enable({
" brightness: 100," brightness: 100,
" contrast: 90," contrast: 90,
" sepia: 10" sepia: 10
"});" });
"</script>"; </script>
)";
} }
#endif
result += "</head><body>"; result += "</head><body>";
return result; return result;
@ -452,8 +451,7 @@ ArticleRequest::ArticleRequest(
{ {
sptr< Dictionary::WordSearchRequest > s = activeDicts[ x ]->findHeadwordsForSynonym( gd::toWString( word ) ); sptr< Dictionary::WordSearchRequest > s = activeDicts[ x ]->findHeadwordsForSynonym( gd::toWString( word ) );
connect( s.get(), SIGNAL( finished() ), connect( s.get(), &Dictionary::Request::finished, this, &ArticleRequest::altSearchFinished, Qt::QueuedConnection );
this, SLOT( altSearchFinished() ), Qt::QueuedConnection );
altSearches.push_back( s ); altSearches.push_back( s );
} }
@ -515,8 +513,7 @@ void ArticleRequest::altSearchFinished()
gd::toWString( contexts.value( QString::fromStdString( activeDicts[ x ]->getId() ) ) ), gd::toWString( contexts.value( QString::fromStdString( activeDicts[ x ]->getId() ) ) ),
ignoreDiacritics ); ignoreDiacritics );
connect( r.get(), SIGNAL( finished() ), connect( r.get(), &Dictionary::Request::finished, this, &ArticleRequest::bodyFinished, Qt::QueuedConnection );
this, SLOT( bodyFinished() ), Qt::QueuedConnection );
bodyRequests.push_back( r ); bodyRequests.push_back( r );
} }
@ -730,8 +727,11 @@ void ArticleRequest::bodyFinished()
// When there were no definitions, we run stemmed search. // When there were no definitions, we run stemmed search.
stemmedWordFinder = std::make_shared<WordFinder>( this ); stemmedWordFinder = std::make_shared<WordFinder>( this );
connect( stemmedWordFinder.get(), SIGNAL( finished() ), connect( stemmedWordFinder.get(),
this, SLOT( stemmedSearchFinished() ), Qt::QueuedConnection ); &WordFinder::finished,
this,
&ArticleRequest::stemmedSearchFinished,
Qt::QueuedConnection );
stemmedWordFinder->stemmedMatch( word, activeDicts ); stemmedWordFinder->stemmedMatch( word, activeDicts );
} }
@ -821,11 +821,13 @@ void ArticleRequest::stemmedSearchFinished()
if ( splittedWords.first.size() > 1 ) // Contains more than one word if ( splittedWords.first.size() > 1 ) // Contains more than one word
{ {
disconnect( stemmedWordFinder.get(), SIGNAL( finished() ), disconnect( stemmedWordFinder.get(), &WordFinder::finished, this, &ArticleRequest::stemmedSearchFinished );
this, SLOT( stemmedSearchFinished() ) );
connect( stemmedWordFinder.get(), SIGNAL( finished() ), connect( stemmedWordFinder.get(),
this, SLOT( individualWordFinished() ), Qt::QueuedConnection ); &WordFinder::finished,
this,
&ArticleRequest::individualWordFinished,
Qt::QueuedConnection );
currentSplittedWordStart = -1; currentSplittedWordStart = -1;
currentSplittedWordEnd = currentSplittedWordStart; currentSplittedWordEnd = currentSplittedWordStart;

View file

@ -25,40 +25,38 @@ using std::string;
// Signals to own slots // Signals to own slots
connect( baseReply, SIGNAL( metaDataChanged() ), this, SLOT( applyMetaData() ) ); connect( baseReply, &QNetworkReply::metaDataChanged, this, &AllowFrameReply::applyMetaData );
connect( baseReply, SIGNAL( errorOccurred( QNetworkReply::NetworkError) ), connect( baseReply, &QNetworkReply::errorOccurred, this, &AllowFrameReply::applyError );
this, SLOT( applyError( QNetworkReply::NetworkError ) ) );
connect( baseReply, SIGNAL( readyRead() ), this, SIGNAL( readyRead() ) ); connect( baseReply, &QIODevice::readyRead, this, &QIODevice::readyRead );
// Redirect QNetworkReply signals // Redirect QNetworkReply signals
connect( baseReply, SIGNAL( downloadProgress( qint64, qint64 ) ), connect( baseReply, &QNetworkReply::downloadProgress, this, &QNetworkReply::downloadProgress );
this, SIGNAL( downloadProgress( qint64, qint64 ) ) );
connect( baseReply, SIGNAL( encrypted() ), this, SIGNAL( encrypted() ) ); connect( baseReply, &QNetworkReply::encrypted, this, &QNetworkReply::encrypted );
connect( baseReply, SIGNAL( finished() ), this, SIGNAL( finished() ) ); connect( baseReply, &QNetworkReply::finished, this, &QNetworkReply::finished );
connect( baseReply, SIGNAL( preSharedKeyAuthenticationRequired( QSslPreSharedKeyAuthenticator * ) ), connect( baseReply,
this, SIGNAL( preSharedKeyAuthenticationRequired( QSslPreSharedKeyAuthenticator * ) ) ); &QNetworkReply::preSharedKeyAuthenticationRequired,
this,
&QNetworkReply::preSharedKeyAuthenticationRequired );
connect( baseReply, SIGNAL( redirected( const QUrl & ) ), this, SIGNAL( redirected( const QUrl & ) ) ); connect( baseReply, &QNetworkReply::redirected, this, &QNetworkReply::redirected );
connect( baseReply, SIGNAL( sslErrors( const QList< QSslError > & ) ), connect( baseReply, &QNetworkReply::sslErrors, this, &QNetworkReply::sslErrors );
this, SIGNAL( sslErrors( const QList< QSslError > & ) ) );
connect( baseReply, SIGNAL( uploadProgress( qint64, qint64 ) ), connect( baseReply, &QNetworkReply::uploadProgress, this, &QNetworkReply::uploadProgress );
this, SIGNAL( uploadProgress( qint64, qint64 ) ) );
// Redirect QIODevice signals // Redirect QIODevice signals
connect( baseReply, SIGNAL( aboutToClose() ), this, SIGNAL( aboutToClose() ) ); connect( baseReply, &QIODevice::aboutToClose, this, &QIODevice::aboutToClose );
connect( baseReply, SIGNAL( bytesWritten( qint64 ) ), this, SIGNAL( bytesWritten( qint64 ) ) ); connect( baseReply, &QIODevice::bytesWritten, this, &QIODevice::bytesWritten );
connect( baseReply, SIGNAL( readChannelFinished() ), this, SIGNAL( readChannelFinished() ) ); connect( baseReply, &QIODevice::readChannelFinished, this, &QIODevice::readChannelFinished );
setOpenMode( QIODevice::ReadOnly ); setOpenMode( QIODevice::ReadOnly );
} }
@ -383,18 +381,22 @@ ArticleResourceReply::ArticleResourceReply( QObject * parent,
if ( contentType.size() ) if ( contentType.size() )
setHeader( QNetworkRequest::ContentTypeHeader, contentType ); setHeader( QNetworkRequest::ContentTypeHeader, contentType );
connect( req.get(), SIGNAL( updated() ), connect( req.get(), &Dictionary::Request::updated, this, &ArticleResourceReply::reqUpdated );
this, SLOT( reqUpdated() ) );
connect( req.get(), SIGNAL( finished() ), connect( req.get(), &Dictionary::Request::finished, this, &ArticleResourceReply::reqFinished );
this, SLOT( reqFinished() ) );
if ( req->isFinished() || req->dataSize() > 0 ) if ( req->isFinished() || req->dataSize() > 0 )
{ {
connect( this, SIGNAL( readyReadSignal() ), connect( this,
this, SLOT( readyReadSlot() ), Qt::QueuedConnection ); &ArticleResourceReply::readyReadSignal,
connect( this, SIGNAL( finishedSignal() ), this,
this, SLOT( finishedSlot() ), Qt::QueuedConnection ); &ArticleResourceReply::readyReadSlot,
Qt::QueuedConnection );
connect( this,
&ArticleResourceReply::finishedSignal,
this,
&ArticleResourceReply::finishedSlot,
Qt::QueuedConnection );
emit readyReadSignal(); emit readyReadSignal();
@ -492,8 +494,7 @@ BlockedNetworkReply::BlockedNetworkReply( QObject * parent ): QNetworkReply( par
{ {
setError( QNetworkReply::ContentOperationNotPermittedError, "Content Blocked" ); setError( QNetworkReply::ContentOperationNotPermittedError, "Content Blocked" );
connect( this, SIGNAL( finishedSignal() ), this, SLOT( finishedSlot() ), connect( this, &BlockedNetworkReply::finishedSignal, this, &BlockedNetworkReply::finishedSlot, Qt::QueuedConnection );
Qt::QueuedConnection );
emit finishedSignal(); // This way we call readyRead()/finished() sometime later emit finishedSignal(); // This way we call readyRead()/finished() sometime later
} }

View file

@ -252,13 +252,11 @@ ArticleView::ArticleView( QWidget * parent, ArticleNetworkAccessManager & nm, Au
goBackAction.setShortcut( QKeySequence( "Alt+Left" ) ); goBackAction.setShortcut( QKeySequence( "Alt+Left" ) );
ui.definition->addAction( &goBackAction ); ui.definition->addAction( &goBackAction );
connect( &goBackAction, SIGNAL( triggered() ), connect( &goBackAction, &QAction::triggered, this, &ArticleView::back );
this, SLOT( back() ) );
goForwardAction.setShortcut( QKeySequence( "Alt+Right" ) ); goForwardAction.setShortcut( QKeySequence( "Alt+Right" ) );
ui.definition->addAction( &goForwardAction ); ui.definition->addAction( &goForwardAction );
connect( &goForwardAction, SIGNAL( triggered() ), connect( &goForwardAction, &QAction::triggered, this, &ArticleView::forward );
this, SLOT( forward() ) );
ui.definition->pageAction( QWebEnginePage::Copy )->setShortcut( QKeySequence::Copy ); ui.definition->pageAction( QWebEnginePage::Copy )->setShortcut( QKeySequence::Copy );
ui.definition->addAction( ui.definition->pageAction( QWebEnginePage::Copy ) ); ui.definition->addAction( ui.definition->pageAction( QWebEnginePage::Copy ) );
@ -270,53 +268,48 @@ ArticleView::ArticleView( QWidget * parent, ArticleNetworkAccessManager & nm, Au
ui.definition->setContextMenuPolicy( Qt::CustomContextMenu ); ui.definition->setContextMenuPolicy( Qt::CustomContextMenu );
connect(ui.definition, SIGNAL(loadFinished(bool)), this, connect( ui.definition, &QWebEngineView::loadFinished, this, &ArticleView::loadFinished );
SLOT(loadFinished(bool)));
connect(ui.definition, SIGNAL(loadProgress(int)), this, connect( ui.definition, &QWebEngineView::loadProgress, this, &ArticleView::loadProgress );
SLOT(loadProgress(int))); connect( ui.definition, &ArticleWebView::linkClicked, this, &ArticleView::linkClicked );
connect( ui.definition, SIGNAL( linkClicked( QUrl ) ), this, SLOT( linkClicked( QUrl ) ) );
connect( ui.definition->page(), SIGNAL( titleChanged( QString ) ), connect( ui.definition->page(), &QWebEnginePage::titleChanged, this, &ArticleView::handleTitleChanged );
this, SLOT( handleTitleChanged( QString ) ) );
connect( ui.definition->page(), SIGNAL( urlChanged(QUrl) ), connect( ui.definition->page(), &QWebEnginePage::urlChanged, this, &ArticleView::handleUrlChanged );
this, SLOT( handleUrlChanged(QUrl) ) );
connect( ui.definition, SIGNAL( customContextMenuRequested( QPoint const & ) ), connect( ui.definition, &QWidget::customContextMenuRequested, this, &ArticleView::contextMenuRequested );
this, SLOT( contextMenuRequested( QPoint const & ) ) );
connect( ui.definition->page(), SIGNAL( linkHovered ( const QString &) ), connect( ui.definition->page(),
this, SLOT( linkHovered ( const QString & ) ) ); SIGNAL( linkHovered( const QString & ) ),
this,
SLOT( linkHovered( const QString & ) ) );
connect( ui.definition, SIGNAL( doubleClicked( QPoint ) ),this,SLOT( doubleClicked( QPoint ) ) ); connect( ui.definition, &ArticleWebView::doubleClicked, this, &ArticleView::doubleClicked );
pasteAction.setShortcut( QKeySequence::Paste ); pasteAction.setShortcut( QKeySequence::Paste );
ui.definition->addAction( &pasteAction ); ui.definition->addAction( &pasteAction );
connect( &pasteAction, SIGNAL( triggered() ), this, SLOT( pasteTriggered() ) ); connect( &pasteAction, &QAction::triggered, this, &ArticleView::pasteTriggered );
articleUpAction.setShortcut( QKeySequence( "Alt+Up" ) ); articleUpAction.setShortcut( QKeySequence( "Alt+Up" ) );
ui.definition->addAction( &articleUpAction ); ui.definition->addAction( &articleUpAction );
connect( &articleUpAction, SIGNAL( triggered() ), this, SLOT( moveOneArticleUp() ) ); connect( &articleUpAction, &QAction::triggered, this, &ArticleView::moveOneArticleUp );
articleDownAction.setShortcut( QKeySequence( "Alt+Down" ) ); articleDownAction.setShortcut( QKeySequence( "Alt+Down" ) );
ui.definition->addAction( &articleDownAction ); ui.definition->addAction( &articleDownAction );
connect( &articleDownAction, SIGNAL( triggered() ), this, SLOT( moveOneArticleDown() ) ); connect( &articleDownAction, &QAction::triggered, this, &ArticleView::moveOneArticleDown );
ui.definition->addAction( &openSearchAction ); ui.definition->addAction( &openSearchAction );
connect( &openSearchAction, SIGNAL( triggered() ), this, SLOT( openSearch() ) ); connect( &openSearchAction, &QAction::triggered, this, &ArticleView::openSearch );
selectCurrentArticleAction.setShortcut( QKeySequence( "Ctrl+Shift+A" )); selectCurrentArticleAction.setShortcut( QKeySequence( "Ctrl+Shift+A" ));
selectCurrentArticleAction.setText( tr( "Select Current Article" ) ); selectCurrentArticleAction.setText( tr( "Select Current Article" ) );
ui.definition->addAction( &selectCurrentArticleAction ); ui.definition->addAction( &selectCurrentArticleAction );
connect( &selectCurrentArticleAction, SIGNAL( triggered() ), connect( &selectCurrentArticleAction, &QAction::triggered, this, &ArticleView::selectCurrentArticle );
this, SLOT( selectCurrentArticle() ) );
copyAsTextAction.setShortcut( QKeySequence( "Ctrl+Shift+C" ) ); copyAsTextAction.setShortcut( QKeySequence( "Ctrl+Shift+C" ) );
copyAsTextAction.setText( tr( "Copy as text" ) ); copyAsTextAction.setText( tr( "Copy as text" ) );
ui.definition->addAction( &copyAsTextAction ); ui.definition->addAction( &copyAsTextAction );
connect( &copyAsTextAction, SIGNAL( triggered() ), connect( &copyAsTextAction, &QAction::triggered, this, &ArticleView::copyAsText );
this, SLOT( copyAsText() ) );
inspectAction.setShortcut( QKeySequence( Qt::Key_F12 ) ); inspectAction.setShortcut( QKeySequence( Qt::Key_F12 ) );
inspectAction.setText( tr( "Inspect" ) ); inspectAction.setText( tr( "Inspect" ) );
@ -359,11 +352,9 @@ ArticleView::ArticleView( QWidget * parent, ArticleNetworkAccessManager & nm, Au
// Variable name for store current selection range // Variable name for store current selection range
rangeVarName = QString( "sr_%1" ).arg( QString::number( (quint64)this, 16 ) ); rangeVarName = QString( "sr_%1" ).arg( QString::number( (quint64)this, 16 ) );
connect(GlobalBroadcaster::instance(), SIGNAL( dictionaryChanges(ActiveDictIds)), this, connect( GlobalBroadcaster::instance(), &GlobalBroadcaster::dictionaryChanges, this, &ArticleView::setActiveDictIds );
SLOT(setActiveDictIds(ActiveDictIds)));
connect( GlobalBroadcaster::instance(), &GlobalBroadcaster::dictionaryClear, this, connect( GlobalBroadcaster::instance(), &GlobalBroadcaster::dictionaryClear, this, &ArticleView::dictionaryClear );
&ArticleView::dictionaryClear );
channel = new QWebChannel(ui.definition->page()); channel = new QWebChannel(ui.definition->page());
agent = new ArticleViewAgent(this); agent = new ArticleViewAgent(this);
@ -1221,8 +1212,7 @@ void ArticleView::openLink( QUrl const & url, QUrl const & ref,
resourceDownloadRequests.push_back( req ); resourceDownloadRequests.push_back( req );
connect( req.get(), SIGNAL( finished() ), connect( req.get(), &Dictionary::Request::finished, this, &ArticleView::resourceDownloadFinished );
this, SLOT( resourceDownloadFinished() ) );
} }
else else
if ( url.scheme() == "gdau" && url.host() == "search" ) if ( url.scheme() == "gdau" && url.host() == "search" )
@ -1270,8 +1260,7 @@ void ArticleView::openLink( QUrl const & url, QUrl const & ref,
if ( !req->isFinished() ) if ( !req->isFinished() )
{ {
// Queued loading // Queued loading
connect( req.get(), SIGNAL( finished() ), connect( req.get(), &Dictionary::Request::finished, this, &ArticleView::resourceDownloadFinished );
this, SLOT( resourceDownloadFinished() ) );
} }
else else
{ {
@ -1310,8 +1299,7 @@ void ArticleView::openLink( QUrl const & url, QUrl const & ref,
if ( !req->isFinished() ) if ( !req->isFinished() )
{ {
// Queued loading // Queued loading
connect( req.get(), SIGNAL( finished() ), connect( req.get(), &Dictionary::Request::finished, this, &ArticleView::resourceDownloadFinished );
this, SLOT( resourceDownloadFinished() ) );
} }
else else
{ {
@ -1360,8 +1348,7 @@ void ArticleView::openLink( QUrl const & url, QUrl const & ref,
resourceDownloadRequests.push_back( req ); resourceDownloadRequests.push_back( req );
connect( req.get(), SIGNAL( finished() ), connect( req.get(), &Dictionary::Request::finished, this, &ArticleView::resourceDownloadFinished );
this, SLOT( resourceDownloadFinished() ) );
} }
} }
@ -1387,8 +1374,7 @@ void ArticleView::openLink( QUrl const & url, QUrl const & ref,
// Found the corresponding program. // Found the corresponding program.
Programs::RunInstance * req = new Programs::RunInstance; Programs::RunInstance * req = new Programs::RunInstance;
connect( req, SIGNAL(finished(QByteArray,QString)), connect( req, &Programs::RunInstance::finished, req, &QObject::deleteLater );
req, SLOT( deleteLater() ) );
QString error; QString error;
@ -1766,7 +1752,7 @@ void ArticleView::contextMenuRequested( QPoint const & pos )
{ {
if ( !isExternalLink( targetUrl ) ) if ( !isExternalLink( targetUrl ) )
{ {
followLink = new QAction( tr( "&Open Link" ), &menu ); followLink = new QAction( tr( "Op&en Link" ), &menu );
menu.addAction( followLink ); menu.addAction( followLink );
if( !popupView && !isAudioLink( targetUrl ) ) if( !popupView && !isAudioLink( targetUrl ) )
@ -1964,7 +1950,7 @@ void ArticleView::contextMenuRequested( QPoint const & pos )
if ( !menu.isEmpty() ) if ( !menu.isEmpty() )
{ {
connect( this, SIGNAL( closePopupMenu() ), &menu, SLOT( close() ) ); connect( this, &ArticleView::closePopupMenu, &menu, &QWidget::close );
QAction * result = menu.exec( ui.definition->mapToGlobal( pos ) ); QAction * result = menu.exec( ui.definition->mapToGlobal( pos ) );
if ( !result ) if ( !result )
@ -2098,7 +2084,11 @@ void ArticleView::resourceDownloadFinished()
Dictionary::WebMultimediaDownload::isAudioUrl( resourceDownloadUrl ) ) Dictionary::WebMultimediaDownload::isAudioUrl( resourceDownloadUrl ) )
{ {
// Audio data // Audio data
connect( audioPlayer.data(), SIGNAL( error( QString ) ), this, SLOT( audioPlayerError( QString ) ), Qt::UniqueConnection ); connect( audioPlayer.data(),
&AudioPlayerInterface::error,
this,
&ArticleView::audioPlayerError,
Qt::UniqueConnection );
QString errorMessage = audioPlayer->play( data.data(), data.size() ); QString errorMessage = audioPlayer->play( data.data(), data.size() );
if( !errorMessage.isEmpty() ) if( !errorMessage.isEmpty() )
QMessageBox::critical( this, "GoldenDict", tr( "Failed to play sound file: %1" ).arg( errorMessage ) ); QMessageBox::critical( this, "GoldenDict", tr( "Failed to play sound file: %1" ).arg( errorMessage ) );
@ -2739,18 +2729,16 @@ ResourceToSaveHandler::ResourceToSaveHandler(ArticleView * view, QString const &
fileName( fileName ), fileName( fileName ),
alreadyDone( false ) alreadyDone( false )
{ {
connect( this, SIGNAL( statusBarMessage( QString, int, QPixmap ) ), connect( this, &ResourceToSaveHandler::statusBarMessage, view, &ArticleView::statusBarMessage );
view, SIGNAL( statusBarMessage( QString, int, QPixmap ) ) );
} }
void ResourceToSaveHandler::addRequest( sptr<Dictionary::DataRequest> req ) void ResourceToSaveHandler::addRequest( sptr< Dictionary::DataRequest > req )
{ {
if( !alreadyDone ) if( !alreadyDone )
{ {
downloadRequests.push_back( req ); downloadRequests.push_back( req );
connect( req.get(), SIGNAL( finished() ), connect( req.get(), &Dictionary::Request::finished, this, &ResourceToSaveHandler::downloadFinished );
this, SLOT( downloadFinished() ) );
} }
} }

View file

@ -230,6 +230,7 @@ Preferences::Preferences():
autoScrollToTargetArticle( true ), autoScrollToTargetArticle( true ),
escKeyHidesMainWindow( false ), escKeyHidesMainWindow( false ),
darkMode( false ), darkMode( false ),
darkReaderMode ( false ),
alwaysOnTop ( false ), alwaysOnTop ( false ),
searchInDock ( false ), searchInDock ( false ),
@ -892,6 +893,9 @@ Class load()
if ( !preferences.namedItem( "darkMode" ).isNull() ) if ( !preferences.namedItem( "darkMode" ).isNull() )
c.preferences.darkMode = ( preferences.namedItem( "darkMode" ).toElement().text() == "1" ); c.preferences.darkMode = ( preferences.namedItem( "darkMode" ).toElement().text() == "1" );
if ( !preferences.namedItem("darkReaderMode").isNull())
c.preferences.darkReaderMode = (preferences.namedItem("darkReaderMode").toElement().text() == "1");
if ( !preferences.namedItem( "zoomFactor" ).isNull() ) if ( !preferences.namedItem( "zoomFactor" ).isNull() )
c.preferences.zoomFactor = preferences.namedItem( "zoomFactor" ).toElement().text().toDouble(); c.preferences.zoomFactor = preferences.namedItem( "zoomFactor" ).toElement().text().toDouble();
@ -1757,6 +1761,10 @@ void save( Class const & c )
opt.appendChild( dd.createTextNode( c.preferences.darkMode ? "1":"0" ) ); opt.appendChild( dd.createTextNode( c.preferences.darkMode ? "1":"0" ) );
preferences.appendChild( opt ); preferences.appendChild( opt );
opt = dd.createElement( "darkReaderMode" );
opt.appendChild( dd.createTextNode( c.preferences.darkReaderMode ? "1":"0" ) );
preferences.appendChild( opt );
opt = dd.createElement( "zoomFactor" ); opt = dd.createElement( "zoomFactor" );
opt.appendChild( dd.createTextNode( QString::number( c.preferences.zoomFactor ) ) ); opt.appendChild( dd.createTextNode( QString::number( c.preferences.zoomFactor ) ) );
preferences.appendChild( opt ); preferences.appendChild( opt );

View file

@ -308,6 +308,7 @@ struct Preferences
bool autoScrollToTargetArticle; bool autoScrollToTargetArticle;
bool escKeyHidesMainWindow; bool escKeyHidesMainWindow;
bool darkMode; bool darkMode;
bool darkReaderMode;
bool alwaysOnTop; bool alwaysOnTop;
/// An old UI mode when tranlateLine and wordList /// An old UI mode when tranlateLine and wordList

View file

@ -72,46 +72,38 @@ DictHeadwords::DictHeadwords( QWidget *parent, Config::Class & cfg_,
ui.autoApply->setChecked( cfg.headwordsDialog.autoApply ); ui.autoApply->setChecked( cfg.headwordsDialog.autoApply );
connect( this, SIGNAL( finished( int ) ), this, SLOT( savePos() ) ); connect( this, &QDialog::finished, this, &DictHeadwords::savePos );
if( !fromMainWindow ) if( !fromMainWindow )
{ {
ui.helpButton->hide(); ui.helpButton->hide();
connect( this, SIGNAL( closeDialog() ), this, SLOT( accept() ) ); connect( this, &DictHeadwords::closeDialog, this, &QDialog::accept );
} }
else else
{ {
connect( ui.helpButton, SIGNAL( clicked() ), connect( ui.helpButton, &QAbstractButton::clicked, this, &DictHeadwords::helpRequested );
this, SLOT( helpRequested() ) );
helpAction.setShortcut( QKeySequence( "F1" ) ); helpAction.setShortcut( QKeySequence( "F1" ) );
helpAction.setShortcutContext( Qt::WidgetWithChildrenShortcut ); helpAction.setShortcutContext( Qt::WidgetWithChildrenShortcut );
connect( &helpAction, SIGNAL( triggered() ), connect( &helpAction, &QAction::triggered, this, &DictHeadwords::helpRequested );
this, SLOT( helpRequested() ) );
addAction( &helpAction ); addAction( &helpAction );
} }
connect( ui.OKButton, SIGNAL( clicked( bool ) ), this, SLOT( okButtonClicked() ) ); connect( ui.OKButton, &QAbstractButton::clicked, this, &DictHeadwords::okButtonClicked );
connect( ui.exportButton, SIGNAL( clicked( bool ) ), this, SLOT( exportButtonClicked() ) ); connect( ui.exportButton, &QAbstractButton::clicked, this, &DictHeadwords::exportButtonClicked );
connect( ui.applyButton, SIGNAL( clicked( bool ) ), this, SLOT( filterChanged() ) ); connect( ui.applyButton, &QAbstractButton::clicked, this, &DictHeadwords::filterChanged );
connect( ui.autoApply, SIGNAL( stateChanged( int ) ), connect( ui.autoApply, &QCheckBox::stateChanged, this, &DictHeadwords::autoApplyStateChanged );
this, SLOT( autoApplyStateChanged( int ) ) );
connect( ui.filterLine, SIGNAL( textChanged( QString ) ), connect( ui.filterLine, &QLineEdit::textChanged, this, &DictHeadwords::filterChangedInternal );
this, SLOT( filterChangedInternal() ) ); connect( ui.searchModeCombo, &QComboBox::currentIndexChanged, this, &DictHeadwords::filterChangedInternal );
connect( ui.searchModeCombo, SIGNAL( currentIndexChanged( int ) ), connect( ui.matchCase, &QCheckBox::stateChanged, this, &DictHeadwords::filterChangedInternal );
this, SLOT( filterChangedInternal() ) );
connect( ui.matchCase, SIGNAL( stateChanged( int ) ),
this, SLOT( filterChangedInternal() ) );
connect( ui.headersListView, SIGNAL( clicked( QModelIndex ) ), connect( ui.headersListView, &QAbstractItemView::clicked, this, &DictHeadwords::itemClicked );
this, SLOT( itemClicked( QModelIndex ) ) );
connect( proxy, SIGNAL( dataChanged( QModelIndex, QModelIndex ) ), connect( proxy, &QAbstractItemModel::dataChanged, this, &DictHeadwords::showHeadwordsNumber );
this, SLOT( showHeadwordsNumber() ) );
ui.headersListView->installEventFilter( this ); ui.headersListView->installEventFilter( this );
@ -204,7 +196,7 @@ void DictHeadwords::filterChangedInternal()
{ {
// emit signal in async manner, to avoid UI slowdown // emit signal in async manner, to avoid UI slowdown
if( ui.autoApply->isChecked() ) if( ui.autoApply->isChecked() )
QTimer::singleShot( 100, this, SLOT( filterChanged() ) ); QTimer::singleShot( 100, this, &DictHeadwords::filterChanged );
} }
void DictHeadwords::filterChanged() void DictHeadwords::filterChanged()

View file

@ -11,7 +11,7 @@ DictInfo::DictInfo( Config::Class &cfg_, QWidget *parent ) :
ui.setupUi( this ); ui.setupUi( this );
if( cfg.dictInfoGeometry.size() > 0 ) if( cfg.dictInfoGeometry.size() > 0 )
restoreGeometry( cfg.dictInfoGeometry ); restoreGeometry( cfg.dictInfoGeometry );
connect( this, SIGNAL( finished( int ) ), this, SLOT( savePos( int ) ) ); connect( this, &QDialog::finished, this, &DictInfo::savePos );
} }
void DictInfo::showInfo( sptr<Dictionary::Class> dict ) void DictInfo::showInfo( sptr<Dictionary::Class> dict )

View file

@ -22,11 +22,9 @@ DictionaryBar::DictionaryBar( QWidget * parent,
maxDictionaryRefsAction = new QAction( QIcon(":/icons/expand_opt.png"), tr( "Extended menu with all dictionaries..." ), this ); maxDictionaryRefsAction = new QAction( QIcon(":/icons/expand_opt.png"), tr( "Extended menu with all dictionaries..." ), this );
connect( &events, SIGNAL( mutedDictionariesChanged() ), connect( &events, &Config::Events::mutedDictionariesChanged, this, &DictionaryBar::mutedDictionariesChanged );
this, SLOT( mutedDictionariesChanged() ) );
connect( this, SIGNAL(actionTriggered(QAction*)), connect( this, &QToolBar::actionTriggered, this, &DictionaryBar::actionWasTriggered );
this, SLOT(actionWasTriggered(QAction*)) );
} }
static QString elideDictName( QString const & name ) static QString elideDictName( QString const & name )
@ -169,7 +167,7 @@ void DictionaryBar::showContextMenu( QContextMenuEvent * event, bool extended )
action->setIconVisibleInMenu( true ); action->setIconVisibleInMenu( true );
} }
connect( this, SIGNAL( closePopupMenu() ), &menu, SLOT( close() ) ); connect( this, &DictionaryBar::closePopupMenu, &menu, &QWidget::close );
QAction * result = menu.exec( event->globalPos() ); QAction * result = menu.exec( event->globalPos() );

View file

@ -47,25 +47,23 @@ EditDictionaries::EditDictionaries( QWidget * parent, Config::Class & cfg_,
ui.tabs->addTab( orderAndProps, QIcon(":/icons/book.svg"), tr( "&Dictionaries" ) ); ui.tabs->addTab( orderAndProps, QIcon(":/icons/book.svg"), tr( "&Dictionaries" ) );
ui.tabs->addTab( groups.get(), QIcon(":/icons/bookcase.svg"), tr( "&Groups" ) ); ui.tabs->addTab( groups.get(), QIcon(":/icons/bookcase.svg"), tr( "&Groups" ) );
connect( ui.buttons, SIGNAL( clicked( QAbstractButton * ) ), connect( ui.buttons, &QDialogButtonBox::clicked, this, &EditDictionaries::buttonBoxClicked );
this, SLOT( buttonBoxClicked( QAbstractButton * ) ) );
connect( &sources, SIGNAL( rescan() ), this, SLOT( rescanSources() ) ); connect( &sources, &Sources::rescan, this, &EditDictionaries::rescanSources );
connect( groups.get(), SIGNAL( showDictionaryInfo( QString const & ) ), connect( groups.get(), &Groups::showDictionaryInfo, this, &EditDictionaries::showDictionaryInfo );
this, SIGNAL( showDictionaryInfo( QString const & ) ) );
connect( orderAndProps, SIGNAL( showDictionaryHeadwords( QString const & ) ), connect( orderAndProps.data(),
this, SIGNAL( showDictionaryHeadwords( QString const & ) ) ); &OrderAndProps::showDictionaryHeadwords,
this,
&EditDictionaries::showDictionaryHeadwords );
connect( ui.buttons, SIGNAL( helpRequested() ), connect( ui.buttons, &QDialogButtonBox::helpRequested, this, &EditDictionaries::helpRequested );
this, SLOT( helpRequested() ) );
helpAction.setShortcut( QKeySequence( "F1" ) ); helpAction.setShortcut( QKeySequence( "F1" ) );
helpAction.setShortcutContext( Qt::WidgetWithChildrenShortcut ); helpAction.setShortcutContext( Qt::WidgetWithChildrenShortcut );
connect( &helpAction, SIGNAL( triggered() ), connect( &helpAction, &QAction::triggered, this, &EditDictionaries::helpRequested );
this, SLOT( helpRequested() ) );
addAction( &helpAction ); addAction( &helpAction );
@ -278,8 +276,7 @@ void EditDictionaries::helpRequested()
{ {
helpWindow->setWindowFlags( Qt::Window ); helpWindow->setWindowFlags( Qt::Window );
connect( helpWindow, SIGNAL( needClose() ), connect( helpWindow, &Help::HelpWindow::needClose, this, &EditDictionaries::closeHelp );
this, SLOT( closeHelp() ) );
helpWindow->showHelpFor( "Manage dictionaries" ); helpWindow->showHelpFor( "Manage dictionaries" );
helpWindow->show(); helpWindow->show();
} }

View file

@ -84,8 +84,7 @@ void ExternalAudioPlayer::onViewerDestroyed( QObject * destroyedViewer )
QString ExternalAudioPlayer::startViewer() QString ExternalAudioPlayer::startViewer()
{ {
Q_ASSERT( !exitingViewer && viewer ); Q_ASSERT( !exitingViewer && viewer );
connect( viewer.data(), SIGNAL( destroyed( QObject * ) ), connect( viewer.data(), &QObject::destroyed, this, &ExternalAudioPlayer::onViewerDestroyed );
this, SLOT( onViewerDestroyed( QObject * ) ) );
try try
{ {
viewer->start(); viewer->start();

View file

@ -33,10 +33,8 @@ ExternalViewer::ExternalViewer( const char * data, int size,
void ExternalViewer::start() void ExternalViewer::start()
{ {
connect( &viewer, SIGNAL( finished( int, QProcess::ExitStatus ) ), connect( &viewer, &QProcess::finished, this, &QObject::deleteLater );
this, SLOT( deleteLater() ) ); connect( &viewer, &QProcess::errorOccurred, this, &QObject::deleteLater );
connect( &viewer, SIGNAL( errorOccurred( QProcess::ProcessError ) ),
this, SLOT( deleteLater() ) );
QStringList args = parseCommandLine( viewerCmdLine ); QStringList args = parseCommandLine( viewerCmdLine );
@ -58,7 +56,7 @@ bool ExternalViewer::stop()
if( viewer.state() == QProcess::NotRunning ) if( viewer.state() == QProcess::NotRunning )
return true; return true;
viewer.terminate(); viewer.terminate();
QTimer::singleShot( 1000, &viewer, SLOT( kill() ) ); // In case terminate() fails. QTimer::singleShot( 1000, &viewer, &QProcess::kill ); // In case terminate() fails.
return false; return false;
} }

View file

@ -20,10 +20,10 @@ ExtLineEdit::ExtLineEdit(QWidget *parent) :
ensurePolished(); ensurePolished();
updateMargins(); updateMargins();
connect(iconButtons[Left], SIGNAL(clicked()), this, SLOT(iconClicked())); connect( iconButtons[ Left ], &QAbstractButton::clicked, this, &ExtLineEdit::iconClicked );
connect(iconButtons[Right], SIGNAL(clicked()), this, SLOT(iconClicked())); connect( iconButtons[ Right ], &QAbstractButton::clicked, this, &ExtLineEdit::iconClicked );
connect(this, SIGNAL( textChanged( QString ) ), this, SLOT( updateButtons( QString ) ) ); connect( this, &QLineEdit::textChanged, this, &ExtLineEdit::updateButtons );
} }
ExtLineEdit::~ExtLineEdit() ExtLineEdit::~ExtLineEdit()

View file

@ -32,8 +32,7 @@ void FavoritesPaneWidget::setUp( Config::Class * cfg, QMenu * menu )
m_deleteSelectedAction->setShortcut( QKeySequence( QKeySequence::Delete ) ); m_deleteSelectedAction->setShortcut( QKeySequence( QKeySequence::Delete ) );
m_deleteSelectedAction->setShortcutContext( Qt::WidgetWithChildrenShortcut ); m_deleteSelectedAction->setShortcutContext( Qt::WidgetWithChildrenShortcut );
addAction( m_deleteSelectedAction ); addAction( m_deleteSelectedAction );
connect( m_deleteSelectedAction, SIGNAL( triggered() ), connect( m_deleteSelectedAction, &QAction::triggered, this, &FavoritesPaneWidget::deleteSelectedItems );
this, SLOT( deleteSelectedItems() ) );
// Copy selected items to clipboard // Copy selected items to clipboard
m_copySelectedToClipboard = new QAction( this ); m_copySelectedToClipboard = new QAction( this );
@ -41,14 +40,13 @@ void FavoritesPaneWidget::setUp( Config::Class * cfg, QMenu * menu )
m_copySelectedToClipboard->setShortcut( QKeySequence( QKeySequence::Copy ) ); m_copySelectedToClipboard->setShortcut( QKeySequence( QKeySequence::Copy ) );
m_copySelectedToClipboard->setShortcutContext( Qt::WidgetWithChildrenShortcut ); m_copySelectedToClipboard->setShortcutContext( Qt::WidgetWithChildrenShortcut );
addAction( m_copySelectedToClipboard ); addAction( m_copySelectedToClipboard );
connect( m_copySelectedToClipboard, SIGNAL( triggered() ), connect( m_copySelectedToClipboard, &QAction::triggered, this, &FavoritesPaneWidget::copySelectedItems );
this, SLOT( copySelectedItems() ) );
// Add folder to tree view // Add folder to tree view
m_addFolder = new QAction( this ); m_addFolder = new QAction( this );
m_addFolder->setText( tr( "Add folder" ) ); m_addFolder->setText( tr( "Add folder" ) );
addAction( m_addFolder ); addAction( m_addFolder );
connect( m_addFolder, SIGNAL( triggered() ), this, SLOT( addFolder() ) ); connect( m_addFolder, &QAction::triggered, this, &FavoritesPaneWidget::addFolder );
// Handle context menu, reusing some of the top-level window's History menu // Handle context menu, reusing some of the top-level window's History menu
@ -88,14 +86,11 @@ void FavoritesPaneWidget::setUp( Config::Class * cfg, QMenu * menu )
if( oldModel ) if( oldModel )
oldModel->deleteLater(); oldModel->deleteLater();
connect( m_favoritesTree, SIGNAL( expanded( QModelIndex ) ), connect( m_favoritesTree, &QTreeView::expanded, m_favoritesModel, &FavoritesModel::itemExpanded );
m_favoritesModel, SLOT( itemExpanded( QModelIndex ) ) );
connect( m_favoritesTree, SIGNAL( collapsed( QModelIndex ) ), connect( m_favoritesTree, &QTreeView::collapsed, m_favoritesModel, &FavoritesModel::itemCollapsed );
m_favoritesModel, SLOT( itemCollapsed( QModelIndex ) ) );
connect( m_favoritesModel, SIGNAL( expandItem( QModelIndex) ), connect( m_favoritesModel, &FavoritesModel::expandItem, m_favoritesTree, &QTreeView::expand );
m_favoritesTree, SLOT( expand( QModelIndex ) ) );
m_favoritesModel->checkAllNodesForExpand(); m_favoritesModel->checkAllNodesForExpand();
m_favoritesTree->viewport()->setAcceptDrops( true ); m_favoritesTree->viewport()->setAcceptDrops( true );
@ -115,14 +110,14 @@ void FavoritesPaneWidget::setUp( Config::Class * cfg, QMenu * menu )
m_favoritesTree->viewport()->installEventFilter( this ); m_favoritesTree->viewport()->installEventFilter( this );
// list selection and keyboard navigation // list selection and keyboard navigation
connect( m_favoritesTree, SIGNAL( clicked( QModelIndex const & ) ), connect( m_favoritesTree, &QAbstractItemView::clicked, this, &FavoritesPaneWidget::onItemClicked );
this, SLOT( onItemClicked( QModelIndex const & ) ) );
connect ( m_favoritesTree->selectionModel(), SIGNAL( selectionChanged ( QItemSelection const & , QItemSelection const & ) ), connect( m_favoritesTree->selectionModel(),
this, SLOT( onSelectionChanged( QItemSelection const & ) ) ); SIGNAL( selectionChanged( QItemSelection const &, QItemSelection const & ) ),
this,
SLOT( onSelectionChanged( QItemSelection const & ) ) );
connect( m_favoritesTree, SIGNAL( customContextMenuRequested( QPoint const & ) ), connect( m_favoritesTree, &QWidget::customContextMenuRequested, this, &FavoritesPaneWidget::showCustomMenu );
this, SLOT( showCustomMenu( QPoint const & ) ) );
} }
FavoritesPaneWidget::~FavoritesPaneWidget() FavoritesPaneWidget::~FavoritesPaneWidget()

View file

@ -63,9 +63,9 @@ void AudioService::playMemory( const char * ptr, int size )
QByteArray audioData( ptr, size ); QByteArray audioData( ptr, size );
DecoderThread * thread = new DecoderThread( audioData, this ); DecoderThread * thread = new DecoderThread( audioData, this );
connect( thread, SIGNAL( error( QString ) ), this, SIGNAL( error( QString ) ) ); connect( thread, &DecoderThread::error, this, &AudioService::error );
connect( this, SIGNAL( cancelPlaying( bool ) ), thread, SLOT( cancel( bool ) ), Qt::DirectConnection ); connect( this, &AudioService::cancelPlaying, thread, &DecoderThread::cancel, Qt::DirectConnection );
connect( thread, SIGNAL( finished() ), thread, SLOT( deleteLater() ) ); connect( thread, &QThread::finished, thread, &QObject::deleteLater );
thread->start(); thread->start();
} }

View file

@ -16,16 +16,9 @@ class AudioPlayer : public AudioPlayerInterface
{ {
Q_OBJECT Q_OBJECT
public: public:
AudioPlayer() AudioPlayer() { connect( &AudioService::instance(), &AudioService::error, this, &AudioPlayerInterface::error ); }
{
connect( &AudioService::instance(), SIGNAL( error( QString ) ),
this, SIGNAL( error( QString ) ) );
}
~AudioPlayer() ~AudioPlayer() { stop(); }
{
stop();
}
virtual QString play( const char * data, int size ) virtual QString play( const char * data, int size )
{ {

View file

@ -117,9 +117,7 @@ ForvoArticleRequest::ForvoArticleRequest( wstring const & str,
apiKey( apiKey_ ), languageCode( languageCode_ ), apiKey( apiKey_ ), languageCode( languageCode_ ),
dictionaryId( dictionaryId_ ) dictionaryId( dictionaryId_ )
{ {
connect( &mgr, SIGNAL( finished( QNetworkReply * ) ), connect( &mgr, &QNetworkAccessManager::finished, this, &ForvoArticleRequest::requestFinished, Qt::QueuedConnection );
this, SLOT( requestFinished( QNetworkReply * ) ),
Qt::QueuedConnection );
addQuery( mgr, str ); addQuery( mgr, str );

View file

@ -108,7 +108,7 @@ void FtsIndexing::doIndexing()
Indexing *idx = new Indexing( isCancelled, dictionaries, indexingExited ); Indexing *idx = new Indexing( isCancelled, dictionaries, indexingExited );
connect( idx, SIGNAL( sendNowIndexingName( QString ) ), this, SLOT( setNowIndexedName( QString ) ) ); connect( idx, &Indexing::sendNowIndexingName, this, &FtsIndexing::setNowIndexedName );
QThreadPool::globalInstance()->start( idx ); QThreadPool::globalInstance()->start( idx );
@ -238,8 +238,7 @@ FullTextSearchDialog::FullTextSearchDialog( QWidget * parent,
setNewIndexingName( ftsIdx.nowIndexingName() ); setNewIndexingName( ftsIdx.nowIndexingName() );
connect( &ftsIdx, SIGNAL( newIndexingName( QString ) ), connect( &ftsIdx, &FtsIndexing::newIndexingName, this, &FullTextSearchDialog::setNewIndexingName );
this, SLOT( setNewIndexingName( QString ) ) );
ui.searchMode->addItem( tr( "Whole words" ), WholeWords ); ui.searchMode->addItem( tr( "Whole words" ), WholeWords );
ui.searchMode->addItem( tr( "Plain text"), PlainText ); ui.searchMode->addItem( tr( "Plain text"), PlainText );
@ -297,38 +296,33 @@ FullTextSearchDialog::FullTextSearchDialog( QWidget * parent,
setLimitsUsing(); setLimitsUsing();
connect( ui.checkBoxDistanceBetweenWords, SIGNAL( stateChanged( int ) ), connect( ui.checkBoxDistanceBetweenWords, &QCheckBox::stateChanged, this, &FullTextSearchDialog::setLimitsUsing );
this, SLOT( setLimitsUsing() ) ); connect( ui.checkBoxArticlesPerDictionary, &QCheckBox::stateChanged, this, &FullTextSearchDialog::setLimitsUsing );
connect( ui.checkBoxArticlesPerDictionary, SIGNAL( stateChanged( int ) ), connect( ui.searchMode, &QComboBox::currentIndexChanged, this, &FullTextSearchDialog::setLimitsUsing );
this, SLOT( setLimitsUsing() ) ); connect( ui.checkBoxIgnoreWordOrder, &QCheckBox::stateChanged, this, &FullTextSearchDialog::ignoreWordsOrderClicked );
connect( ui.searchMode, SIGNAL( currentIndexChanged( int ) ), connect( ui.checkBoxIgnoreDiacritics,
this, SLOT( setLimitsUsing() ) ); &QCheckBox::stateChanged,
connect( ui.checkBoxIgnoreWordOrder, SIGNAL( stateChanged( int ) ), this,
this, SLOT( ignoreWordsOrderClicked() ) ); &FullTextSearchDialog::ignoreDiacriticsClicked );
connect( ui.checkBoxIgnoreDiacritics, SIGNAL( stateChanged( int ) ),
this, SLOT( ignoreDiacriticsClicked() ) );
model = new HeadwordsListModel( this, results, activeDicts ); model = new HeadwordsListModel( this, results, activeDicts );
ui.headwordsView->setModel( model ); ui.headwordsView->setModel( model );
ui.articlesFoundLabel->setText( tr( "Articles found: " ) + "0" ); ui.articlesFoundLabel->setText( tr( "Articles found: " ) + "0" );
connect( ui.headwordsView, SIGNAL( clicked( QModelIndex ) ), connect( ui.headwordsView, &QAbstractItemView::clicked, this, &FullTextSearchDialog::itemClicked );
this, SLOT( itemClicked( QModelIndex ) ) );
connect( this, SIGNAL( finished( int ) ), this, SLOT( saveData() ) ); connect( this, &QDialog::finished, this, &FullTextSearchDialog::saveData );
connect( ui.OKButton, SIGNAL( clicked() ), this, SLOT( accept() ) ); connect( ui.OKButton, SIGNAL( clicked() ), this, SLOT( accept() ) );
connect( ui.cancelButton, SIGNAL( clicked() ), this, SLOT( reject() ) ); connect( ui.cancelButton, SIGNAL( clicked() ), this, SLOT( reject() ) );
connect( ui.helpButton, SIGNAL( clicked() ), connect( ui.helpButton, &QAbstractButton::clicked, this, &FullTextSearchDialog::helpRequested );
this, SLOT( helpRequested() ) );
helpAction.setShortcut( QKeySequence( "F1" ) ); helpAction.setShortcut( QKeySequence( "F1" ) );
helpAction.setShortcutContext( Qt::WidgetWithChildrenShortcut ); helpAction.setShortcutContext( Qt::WidgetWithChildrenShortcut );
connect( &helpAction, SIGNAL( triggered() ), connect( &helpAction, &QAction::triggered, this, &FullTextSearchDialog::helpRequested );
this, SLOT( helpRequested() ) );
addAction( &helpAction ); addAction( &helpAction );
@ -492,11 +486,17 @@ void FullTextSearchDialog::accept()
ignoreWordsOrder, ignoreWordsOrder,
ignoreDiacritics ignoreDiacritics
); );
connect( req.get(), SIGNAL( finished() ), connect( req.get(),
this, SLOT( searchReqFinished() ), Qt::QueuedConnection ); &Dictionary::Request::finished,
this,
&FullTextSearchDialog::searchReqFinished,
Qt::QueuedConnection );
connect( req.get(), SIGNAL( matchCount(int) ), connect( req.get(),
this, SLOT( matchCount(int) ), Qt::QueuedConnection ); &Dictionary::Request::matchCount,
this,
&FullTextSearchDialog::matchCount,
Qt::QueuedConnection );
searchReqs.push_back( req ); searchReqs.push_back( req );
} }

View file

@ -14,19 +14,16 @@ GroupComboBox::GroupComboBox( QWidget * parent ): QComboBox( parent ),
setToolTip( tr( "Choose a Group (Alt+G)" ) ); setToolTip( tr( "Choose a Group (Alt+G)" ) );
popupAction.setShortcut( QKeySequence( "Alt+G" ) ); popupAction.setShortcut( QKeySequence( "Alt+G" ) );
connect( &popupAction, SIGNAL( triggered() ), connect( &popupAction, &QAction::triggered, this, &GroupComboBox::popupGroups );
this, SLOT( popupGroups() ) );
addAction( &popupAction ); addAction( &popupAction );
selectNextAction.setShortcut( QKeySequence( "Alt+PgDown" ) ); selectNextAction.setShortcut( QKeySequence( "Alt+PgDown" ) );
connect( &selectNextAction, SIGNAL( triggered() ), connect( &selectNextAction, &QAction::triggered, this, &GroupComboBox::selectNextGroup );
this, SLOT( selectNextGroup() ) );
addAction( &selectNextAction ); addAction( &selectNextAction );
selectPreviousAction.setShortcut( QKeySequence( "Alt+PgUp" ) ); selectPreviousAction.setShortcut( QKeySequence( "Alt+PgUp" ) );
connect( &selectPreviousAction, SIGNAL( triggered() ), connect( &selectPreviousAction, &QAction::triggered, this, &GroupComboBox::selectPreviousGroup );
this, SLOT( selectPreviousGroup() ) );
addAction( &selectPreviousAction ); addAction( &selectPreviousAction );
setMaxVisibleItems( 30 ); setMaxVisibleItems( 30 );

View file

@ -37,36 +37,25 @@ Groups::Groups( QWidget * parent,
ui.groups->setCornerWidget( groupsListButton ); ui.groups->setCornerWidget( groupsListButton );
groupsListButton->setFocusPolicy( Qt::ClickFocus ); groupsListButton->setFocusPolicy( Qt::ClickFocus );
connect(groupsListMenu, SIGNAL( aboutToShow() ), this, SLOT( fillGroupsMenu() ) ); connect( groupsListMenu, &QMenu::aboutToShow, this, &Groups::fillGroupsMenu );
connect(groupsListMenu, SIGNAL( triggered( QAction * ) ), connect( groupsListMenu, &QMenu::triggered, this, &Groups::switchToGroup );
this, SLOT( switchToGroup( QAction * ) ) );
// Populate groups' widget // Populate groups' widget
ui.groups->populate( groups, dicts, ui.dictionaries->getCurrentDictionaries() ); ui.groups->populate( groups, dicts, ui.dictionaries->getCurrentDictionaries() );
connect( ui.addGroup, SIGNAL( clicked() ), connect( ui.addGroup, &QAbstractButton::clicked, this, &Groups::addNew );
this, SLOT( addNew() ) ); connect( ui.renameGroup, &QAbstractButton::clicked, this, &Groups::renameCurrent );
connect( ui.renameGroup, SIGNAL( clicked() ), connect( ui.removeGroup, &QAbstractButton::clicked, this, &Groups::removeCurrent );
this, SLOT( renameCurrent() ) ); connect( ui.removeAllGroups, &QAbstractButton::clicked, this, &Groups::removeAll );
connect( ui.removeGroup, SIGNAL( clicked() ), connect( ui.addDictsToGroup, &QAbstractButton::clicked, this, &Groups::addToGroup );
this, SLOT( removeCurrent() ) ); connect( ui.dictionaries, &QAbstractItemView::doubleClicked, this, &Groups::addToGroup );
connect( ui.removeAllGroups, SIGNAL( clicked() ), connect( ui.removeDictsFromGroup, &QAbstractButton::clicked, this, &Groups::removeFromGroup );
this, SLOT( removeAll() ) ); connect( ui.autoGroups, &QAbstractButton::clicked, this, &Groups::addAutoGroups );
connect( ui.addDictsToGroup, SIGNAL( clicked() ), connect( ui.groups, &DictGroupsWidget::showDictionaryInfo, this, &Groups::showDictionaryInfo );
this, SLOT( addToGroup() ) );
connect( ui.dictionaries, SIGNAL( doubleClicked(const QModelIndex &) ),
this, SLOT( addToGroup() ) );
connect( ui.removeDictsFromGroup, SIGNAL( clicked() ),
this, SLOT( removeFromGroup() ) );
connect( ui.autoGroups, SIGNAL( clicked() ),
this, SLOT( addAutoGroups() ) );
connect( ui.groups, SIGNAL( showDictionaryInfo( QString const & ) ),
this, SIGNAL( showDictionaryInfo( QString const & ) ) );
ui.dictionaries->setContextMenuPolicy( Qt::CustomContextMenu ); ui.dictionaries->setContextMenuPolicy( Qt::CustomContextMenu );
connect( ui.dictionaries, SIGNAL( customContextMenuRequested( QPoint ) ), connect( ui.dictionaries, &QWidget::customContextMenuRequested, this, &Groups::showDictInfo );
this, SLOT( showDictInfo( QPoint ) ) );
countChanged(); countChanged();
} }

View file

@ -65,15 +65,12 @@ DictGroupWidget::DictGroupWidget( QWidget * parent,
ui.favoritesFolder->setText( group.favoritesFolder ); ui.favoritesFolder->setText( group.favoritesFolder );
connect( ui.groupIcon, SIGNAL(activated(int)),this,SLOT(groupIconActivated(int)), connect( ui.groupIcon, &QComboBox::activated, this, &DictGroupWidget::groupIconActivated, Qt::QueuedConnection );
Qt::QueuedConnection );
ui.dictionaries->setContextMenuPolicy( Qt::CustomContextMenu ); ui.dictionaries->setContextMenuPolicy( Qt::CustomContextMenu );
connect( ui.dictionaries, SIGNAL( customContextMenuRequested( QPoint ) ), connect( ui.dictionaries, &QWidget::customContextMenuRequested, this, &DictGroupWidget::showDictInfo );
this, SLOT( showDictInfo( QPoint ) ) );
connect( ui.dictionaries, SIGNAL( doubleClicked( QModelIndex ) ), connect( ui.dictionaries, &QAbstractItemView::doubleClicked, this, &DictGroupWidget::removeCurrentItem );
this, SLOT( removeCurrentItem( QModelIndex ) ) );
} }
void DictGroupWidget::groupIconActivated( int index ) void DictGroupWidget::groupIconActivated( int index )
@ -548,8 +545,7 @@ DictGroupsWidget::DictGroupsWidget( QWidget * parent ):
{ {
setMovable( true ); setMovable( true );
setContextMenuPolicy( Qt::CustomContextMenu ); setContextMenuPolicy( Qt::CustomContextMenu );
connect( this, SIGNAL( customContextMenuRequested( QPoint ) ), connect( this, &QWidget::customContextMenuRequested, this, &DictGroupsWidget::contextMenu );
this, SLOT( contextMenu( QPoint ) ) );
} }
namespace { namespace {
@ -585,7 +581,7 @@ void DictGroupsWidget::populate( Config::Groups const & groups,
DictGroupWidget *gr = new DictGroupWidget( this, *allDicts, groups[ x ] ); DictGroupWidget *gr = new DictGroupWidget( this, *allDicts, groups[ x ] );
addTab( gr, escapeAmps( groups[ x ].name ) ); addTab( gr, escapeAmps( groups[ x ].name ) );
connect( gr, &DictGroupWidget::showDictionaryInfo,this, &DictGroupsWidget::showDictionaryInfo ); connect( gr, &DictGroupWidget::showDictionaryInfo,this, &DictGroupsWidget::showDictionaryInfo );
connect( gr->getModel(), SIGNAL( contentChanged() ), this, SLOT( tabDataChanged() ) ); connect( gr->getModel(), &DictListModel::contentChanged, this, &DictGroupsWidget::tabDataChanged );
setCurrentIndex( x ); setCurrentIndex( x );
QString toolTipStr = "\"" + tabText( x ) + "\"\n" + tr( "Dictionaries: " ) QString toolTipStr = "\"" + tabText( x ) + "\"\n" + tr( "Dictionaries: " )
@ -656,12 +652,11 @@ void DictGroupsWidget::addNewGroup( QString const & name )
DictGroupWidget *gr = new DictGroupWidget( this, *allDicts, newGroup ); DictGroupWidget *gr = new DictGroupWidget( this, *allDicts, newGroup );
insertTab( idx, gr, escapeAmps( name ) ); insertTab( idx, gr, escapeAmps( name ) );
connect( gr, SIGNAL( showDictionaryInfo( QString const & ) ), connect( gr, &DictGroupWidget::showDictionaryInfo, this, &DictGroupsWidget::showDictionaryInfo );
this, SIGNAL( showDictionaryInfo( QString const & ) ) );
setCurrentIndex( idx ); setCurrentIndex( idx );
connect( gr->getModel(), SIGNAL( contentChanged() ), this, SLOT( tabDataChanged() ) ); connect( gr->getModel(), &DictListModel::contentChanged, this, &DictGroupsWidget::tabDataChanged );
QString toolTipStr = "\"" + tabText( idx ) + "\"\n" + tr( "Dictionaries: " ) QString toolTipStr = "\"" + tabText( idx ) + "\"\n" + tr( "Dictionaries: " )
+ QString::number( getCurrentModel()->getCurrentDictionaries().size() ); + QString::number( getCurrentModel()->getCurrentDictionaries().size() );
@ -829,12 +824,12 @@ void DictGroupsWidget::combineGroups( int source, int target )
setCurrentIndex( target ); setCurrentIndex( target );
DictListModel *model = getCurrentModel(); DictListModel *model = getCurrentModel();
disconnect( model, SIGNAL( contentChanged() ), this, SLOT( tabDataChanged() ) ); disconnect( model, &DictListModel::contentChanged, this, &DictGroupsWidget::tabDataChanged );
for( unsigned i = 0; i < dicts.size(); i++ ) for( unsigned i = 0; i < dicts.size(); i++ )
model->addRow( QModelIndex(), dicts[ i ] ); model->addRow( QModelIndex(), dicts[ i ] );
connect( model, SIGNAL( contentChanged() ), this, SLOT( tabDataChanged() ) ); connect( model, &DictListModel::contentChanged, this, &DictGroupsWidget::tabDataChanged );
QString toolTipStr = "\"" + tabText( target ) + "\"\n" + tr( "Dictionaries: " ) QString toolTipStr = "\"" + tabText( target ) + "\"\n" + tr( "Dictionaries: " )
+ QString::number( model->getCurrentDictionaries().size() ); + QString::number( model->getCurrentDictionaries().size() );
@ -1023,8 +1018,7 @@ QuickFilterLine::QuickFilterLine( QWidget * parent ): ExtLineEdit( parent ), m_f
setPlaceholderText( tr( "Dictionary search/filter (Ctrl+F)" ) ); setPlaceholderText( tr( "Dictionary search/filter (Ctrl+F)" ) );
m_focusAction.setShortcut( QKeySequence( "Ctrl+F" ) ); m_focusAction.setShortcut( QKeySequence( "Ctrl+F" ) );
connect( &m_focusAction, SIGNAL( triggered() ), connect( &m_focusAction, &QAction::triggered, this, &QuickFilterLine::focusFilterLine );
this, SLOT( focusFilterLine() ) );
QPixmap image(":/icons/system-search.svg"); QPixmap image(":/icons/system-search.svg");
setButtonPixmap(ExtLineEdit::Left, image.scaled(18, 18, Qt::KeepAspectRatio, Qt::SmoothTransformation)); setButtonPixmap(ExtLineEdit::Left, image.scaled(18, 18, Qt::KeepAspectRatio, Qt::SmoothTransformation));
@ -1036,12 +1030,11 @@ QuickFilterLine::QuickFilterLine( QWidget * parent ): ExtLineEdit( parent ), m_f
setButtonToolTip(ExtLineEdit::Right, tr("Clear Search")); setButtonToolTip(ExtLineEdit::Right, tr("Clear Search"));
setButtonVisible(ExtLineEdit::Right, true); setButtonVisible(ExtLineEdit::Right, true);
setButtonAutoHide(ExtLineEdit::Right, true); setButtonAutoHide(ExtLineEdit::Right, true);
connect( this, SIGNAL( rightButtonClicked() ), this, SLOT( clear() ) ); connect( this, &ExtLineEdit::rightButtonClicked, this, &QLineEdit::clear );
setFocusPolicy(Qt::StrongFocus); setFocusPolicy(Qt::StrongFocus);
connect (this, SIGNAL( textChanged( QString const & ) ), connect( this, &QLineEdit::textChanged, this, &QuickFilterLine::filterChangedInternal );
this, SLOT( filterChangedInternal() ) );
} }
QuickFilterLine::~QuickFilterLine() QuickFilterLine::~QuickFilterLine()
@ -1070,7 +1063,7 @@ QModelIndex QuickFilterLine::mapToSource( QModelIndex const & idx )
void QuickFilterLine::filterChangedInternal() void QuickFilterLine::filterChangedInternal()
{ {
// emit signal in async manner, to avoid UI slowdown // emit signal in async manner, to avoid UI slowdown
QTimer::singleShot( 1, this, SLOT( emitFilterChanged() ) ); QTimer::singleShot( 1, this, &QuickFilterLine::emitFilterChanged );
} }
void QuickFilterLine::emitFilterChanged() void QuickFilterLine::emitFilterChanged()

View file

@ -42,7 +42,7 @@ void HeadwordListModel::setFilter( QRegularExpression reg )
filtering = true; filtering = true;
filterWords.clear(); filterWords.clear();
auto sr = _dict->prefixMatch( gd::toWString( reg.pattern() ), 30 ); auto sr = _dict->prefixMatch( gd::toWString( reg.pattern() ), 30 );
connect( sr.get(), SIGNAL( finished() ), this, SLOT( requestFinished() ), Qt::QueuedConnection ); connect( sr.get(), &Dictionary::Request::finished, this, &HeadwordListModel::requestFinished, Qt::QueuedConnection );
queuedRequests.push_back( sr ); queuedRequests.push_back( sr );
} }

View file

@ -19,7 +19,7 @@ HelpBrowser::HelpBrowser( QHelpEngineCore * engine, QWidget *parent ) :
QTextBrowser( parent ), QTextBrowser( parent ),
helpEngine( engine ) helpEngine( engine )
{ {
connect( this, SIGNAL( anchorClicked( QUrl ) ), this, SLOT( linkClicked( QUrl ) ) ); connect( this, &QTextBrowser::anchorClicked, this, &HelpBrowser::linkClicked );
} }
void HelpBrowser::showHelpForKeyword( QString const & id ) void HelpBrowser::showHelpForKeyword( QString const & id )
@ -143,22 +143,19 @@ HelpWindow::HelpWindow( QWidget * parent, Config::Class & cfg_ ) :
connect( helpEngine->indexWidget(), SIGNAL( linkActivated( QUrl, QString ) ), connect( helpEngine->indexWidget(), SIGNAL( linkActivated( QUrl, QString ) ),
helpBrowser, SLOT( setSource( QUrl ) ) ); helpBrowser, SLOT( setSource( QUrl ) ) );
connect( navHome, SIGNAL( triggered() ), helpBrowser, SLOT( home() ) ); connect( navHome, &QAction::triggered, helpBrowser, &QTextBrowser::home );
connect( navForward, SIGNAL( triggered() ), helpBrowser, SLOT( forward() ) ); connect( navForward, &QAction::triggered, helpBrowser, &QTextBrowser::forward );
connect( navBack, SIGNAL( triggered() ), helpBrowser, SLOT( backward() ) ); connect( navBack, &QAction::triggered, helpBrowser, &QTextBrowser::backward );
connect( helpBrowser, SIGNAL( forwardAvailable( bool ) ), connect( helpBrowser, &QTextBrowser::forwardAvailable, this, &HelpWindow::forwardEnabled );
this, SLOT( forwardEnabled( bool ) ) );
connect( helpBrowser, SIGNAL( backwardAvailable( bool ) ), connect( helpBrowser, &QTextBrowser::backwardAvailable, this, &HelpWindow::backwardEnabled );
this, SLOT( backwardEnabled( bool ) ) );
connect( helpEngine->contentWidget(), SIGNAL( clicked( QModelIndex ) ), connect( helpEngine->contentWidget(), &QAbstractItemView::clicked, this, &HelpWindow::contentsItemClicked );
this, SLOT( contentsItemClicked( QModelIndex ) ) );
connect( zoomInAction, SIGNAL( triggered( ) ), this, SLOT( zoomIn() ) ); connect( zoomInAction, &QAction::triggered, this, &HelpWindow::zoomIn );
connect( zoomOutAction, SIGNAL( triggered( ) ), this, SLOT( zoomOut() ) ); connect( zoomOutAction, &QAction::triggered, this, &HelpWindow::zoomOut );
connect( zoomBaseAction, SIGNAL( triggered( ) ), this, SLOT( zoomBase() ) ); connect( zoomBaseAction, &QAction::triggered, this, &HelpWindow::zoomBase );
splitter = new QSplitter( this ); splitter = new QSplitter( this );
splitter->addWidget( tabWidget ); splitter->addWidget( tabWidget );

View file

@ -24,8 +24,7 @@ void HistoryPaneWidget::setUp( Config::Class * cfg, History * history, QMenu *
m_deleteSelectedAction->setShortcut( QKeySequence( QKeySequence::Delete ) ); m_deleteSelectedAction->setShortcut( QKeySequence( QKeySequence::Delete ) );
m_deleteSelectedAction->setShortcutContext( Qt::WidgetWithChildrenShortcut ); m_deleteSelectedAction->setShortcutContext( Qt::WidgetWithChildrenShortcut );
addAction( m_deleteSelectedAction ); addAction( m_deleteSelectedAction );
connect( m_deleteSelectedAction, SIGNAL( triggered() ), connect( m_deleteSelectedAction, &QAction::triggered, this, &HistoryPaneWidget::deleteSelectedItems );
this, SLOT( deleteSelectedItems() ) );
// Copy selected items to clipboard // Copy selected items to clipboard
m_copySelectedToClipboard = new QAction( this ); m_copySelectedToClipboard = new QAction( this );
@ -33,8 +32,7 @@ void HistoryPaneWidget::setUp( Config::Class * cfg, History * history, QMenu *
m_copySelectedToClipboard->setShortcut( QKeySequence( QKeySequence::Copy ) ); m_copySelectedToClipboard->setShortcut( QKeySequence( QKeySequence::Copy ) );
m_copySelectedToClipboard->setShortcutContext( Qt::WidgetWithChildrenShortcut ); m_copySelectedToClipboard->setShortcutContext( Qt::WidgetWithChildrenShortcut );
addAction( m_copySelectedToClipboard ); addAction( m_copySelectedToClipboard );
connect( m_copySelectedToClipboard, SIGNAL( triggered() ), connect( m_copySelectedToClipboard, &QAction::triggered, this, &HistoryPaneWidget::copySelectedItems );
this, SLOT( copySelectedItems() ) );
// Handle context menu, reusing some of the top-level window's History menu // Handle context menu, reusing some of the top-level window's History menu
@ -79,15 +77,12 @@ void HistoryPaneWidget::setUp( Config::Class * cfg, History * history, QMenu *
m_historyList->viewport()->installEventFilter( this ); m_historyList->viewport()->installEventFilter( this );
// list selection and keyboard navigation // list selection and keyboard navigation
connect( m_historyList, SIGNAL( clicked( QModelIndex const & ) ), connect( m_historyList, &QAbstractItemView::clicked, this, &HistoryPaneWidget::onItemClicked );
this, SLOT( onItemClicked( QModelIndex const & ) ) ); connect( m_history, &History::itemsChanged, this, &HistoryPaneWidget::updateHistoryCounts );
connect( m_history, SIGNAL( itemsChanged() ),
this, SLOT( updateHistoryCounts() ) );
connect ( m_historyList->selectionModel(), SIGNAL( selectionChanged ( QItemSelection const & , QItemSelection const & ) ), connect ( m_historyList->selectionModel(), SIGNAL( selectionChanged ( QItemSelection const & , QItemSelection const & ) ),
this, SLOT( onSelectionChanged( QItemSelection const & ) ) ); this, SLOT( onSelectionChanged( QItemSelection const & ) ) );
connect( m_historyList, SIGNAL( customContextMenuRequested( QPoint const & ) ), connect( m_historyList, &QWidget::customContextMenuRequested, this, &HistoryPaneWidget::showCustomMenu );
this, SLOT( showCustomMenu( QPoint const & ) ) );
listItemDelegate = new WordListItemDelegate( m_historyList->itemDelegate() ); listItemDelegate = new WordListItemDelegate( m_historyList->itemDelegate() );
m_historyList->setItemDelegate( listItemDelegate ); m_historyList->setItemDelegate( listItemDelegate );
@ -231,9 +226,7 @@ HistoryModel::HistoryModel( History * history, QObject * parent )
: QAbstractListModel( parent ), m_history(history) : QAbstractListModel( parent ), m_history(history)
{ {
connect( m_history, SIGNAL( itemsChanged() ), connect( m_history, &History::itemsChanged, this, &HistoryModel::historyChanged );
this, SLOT( historyChanged() ) );
} }
int HistoryModel::rowCount( QModelIndex const & /*parent*/ ) const int HistoryModel::rowCount( QModelIndex const & /*parent*/ ) const

View file

@ -21,11 +21,17 @@ QHotkeyApplication::QHotkeyApplication( int & argc, char ** argv ):
, mainWindow( 0 ) , mainWindow( 0 )
#endif #endif
{ {
connect( this, SIGNAL( commitDataRequest( QSessionManager& ) ), connect( this,
this, SLOT( hotkeyAppCommitData( QSessionManager& ) ), Qt::DirectConnection ); &QGuiApplication::commitDataRequest,
this,
&QHotkeyApplication::hotkeyAppCommitData,
Qt::DirectConnection );
connect( this, SIGNAL( saveStateRequest( QSessionManager& ) ), connect( this,
this, SLOT( hotkeyAppSaveState( QSessionManager& ) ), Qt::DirectConnection ); &QGuiApplication::saveStateRequest,
this,
&QHotkeyApplication::hotkeyAppSaveState,
Qt::DirectConnection );
#if defined( Q_OS_WIN ) #if defined( Q_OS_WIN )
installNativeEventFilter( this ); installNativeEventFilter( this );
@ -39,11 +45,17 @@ QHotkeyApplication::QHotkeyApplication( QString const & id,
, mainWindow( 0 ) , mainWindow( 0 )
#endif #endif
{ {
connect( this, SIGNAL( commitDataRequest( QSessionManager& ) ), connect( this,
this, SLOT( hotkeyAppCommitData( QSessionManager& ) ), Qt::DirectConnection ); &QGuiApplication::commitDataRequest,
this,
&QHotkeyApplication::hotkeyAppCommitData,
Qt::DirectConnection );
connect( this, SIGNAL( saveStateRequest( QSessionManager& ) ), connect( this,
this, SLOT( hotkeyAppSaveState( QSessionManager& ) ), Qt::DirectConnection ); &QGuiApplication::saveStateRequest,
this,
&QHotkeyApplication::hotkeyAppSaveState,
Qt::DirectConnection );
#if defined( Q_OS_WIN ) #if defined( Q_OS_WIN )
installNativeEventFilter( this ); installNativeEventFilter( this );
@ -250,7 +262,7 @@ bool HotkeyWrapper::checkState(quint32 vk, quint32 mod)
state2 = true; state2 = true;
state2waiter = hs; state2waiter = hs;
QTimer::singleShot(500, this, SLOT(waitKey2())); QTimer::singleShot( 500, this, &HotkeyWrapper::waitKey2 );
#ifdef HAVE_X11 #ifdef HAVE_X11
@ -530,9 +542,7 @@ void HotkeyWrapper::init()
// This is required to ensure context was indeed created // This is required to ensure context was indeed created
XSync( display, False ); XSync( display, False );
connect( this, SIGNAL( keyRecorded( quint32, quint32 ) ), connect( this, &HotkeyWrapper::keyRecorded, this, &HotkeyWrapper::checkState, Qt::QueuedConnection );
this, SLOT( checkState( quint32, quint32 ) ),
Qt::QueuedConnection );
start(); start();
} }

View file

@ -78,8 +78,8 @@ void LoadDictionaries::run()
{ {
try try
{ {
for( Config::Paths::const_iterator i = paths.begin(); i != paths.end(); ++i ) for(const auto & path : paths)
handlePath( *i ); handlePath( path );
// Make soundDirs // Make soundDirs
{ {
@ -107,6 +107,10 @@ void LoadDictionaries::run()
} }
} }
void LoadDictionaries::addDicts( const std::vector< sptr< Dictionary::Class > >& dicts ) {
std::move(dicts.begin(), dicts.end(), std::back_inserter(dictionaries));
}
void LoadDictionaries::handlePath( Config::Path const & path ) void LoadDictionaries::handlePath( Config::Path const & path )
{ {
vector< string > allFiles; vector< string > allFiles;
@ -132,112 +136,24 @@ void LoadDictionaries::handlePath( Config::Path const & path )
allFiles.push_back( FsEncoding::encode( QDir::toNativeSeparators( fullName ) ) ); allFiles.push_back( FsEncoding::encode( QDir::toNativeSeparators( fullName ) ) );
} }
{ addDicts(Bgl::makeDictionaries( allFiles, FsEncoding::encode( Config::getIndexDir() ), *this ) );
vector< sptr< Dictionary::Class > > bglDictionaries = addDicts(Stardict::makeDictionaries( allFiles, FsEncoding::encode( Config::getIndexDir() ), *this, maxHeadwordToExpand ) );
Bgl::makeDictionaries( allFiles, FsEncoding::encode( Config::getIndexDir() ), *this ); addDicts(Lsa::makeDictionaries( allFiles, FsEncoding::encode( Config::getIndexDir() ), *this ) );
addDicts(Dsl::makeDictionaries( allFiles,FsEncoding::encode( Config::getIndexDir() ),*this,maxPictureWidth,maxHeadwordSize ) );
addDicts(DictdFiles::makeDictionaries( allFiles, FsEncoding::encode( Config::getIndexDir() ), *this ) );
addDicts(Xdxf::makeDictionaries( allFiles, FsEncoding::encode( Config::getIndexDir() ), *this ) );
addDicts(Sdict::makeDictionaries( allFiles, FsEncoding::encode( Config::getIndexDir() ), *this ) );
addDicts(Aard::makeDictionaries( allFiles, FsEncoding::encode( Config::getIndexDir() ), *this, maxHeadwordToExpand ) );
addDicts(ZipSounds::makeDictionaries( allFiles, FsEncoding::encode( Config::getIndexDir() ), *this ) );
addDicts(Mdx::makeDictionaries( allFiles, FsEncoding::encode( Config::getIndexDir() ), *this ) );
addDicts(Gls::makeDictionaries( allFiles, FsEncoding::encode( Config::getIndexDir() ), *this ) );
dictionaries.insert( dictionaries.end(), bglDictionaries.begin(),
bglDictionaries.end() );
}
{
vector< sptr< Dictionary::Class > > stardictDictionaries =
Stardict::makeDictionaries( allFiles, FsEncoding::encode( Config::getIndexDir() ), *this, maxHeadwordToExpand );
dictionaries.insert( dictionaries.end(), stardictDictionaries.begin(),
stardictDictionaries.end() );
}
{
vector< sptr< Dictionary::Class > > lsaDictionaries =
Lsa::makeDictionaries( allFiles, FsEncoding::encode( Config::getIndexDir() ), *this );
dictionaries.insert( dictionaries.end(), lsaDictionaries.begin(),
lsaDictionaries.end() );
}
{
vector< sptr< Dictionary::Class > > dslDictionaries =
Dsl::makeDictionaries(
allFiles, FsEncoding::encode( Config::getIndexDir() ), *this, maxPictureWidth, maxHeadwordSize );
dictionaries.insert( dictionaries.end(), dslDictionaries.begin(),
dslDictionaries.end() );
}
{
vector< sptr< Dictionary::Class > > dictdDictionaries =
DictdFiles::makeDictionaries( allFiles, FsEncoding::encode( Config::getIndexDir() ), *this );
dictionaries.insert( dictionaries.end(), dictdDictionaries.begin(),
dictdDictionaries.end() );
}
{
vector< sptr< Dictionary::Class > > xdxfDictionaries =
Xdxf::makeDictionaries( allFiles, FsEncoding::encode( Config::getIndexDir() ), *this );
dictionaries.insert( dictionaries.end(), xdxfDictionaries.begin(),
xdxfDictionaries.end() );
}
{
vector< sptr< Dictionary::Class > > sdictDictionaries =
Sdict::makeDictionaries( allFiles, FsEncoding::encode( Config::getIndexDir() ), *this );
dictionaries.insert( dictionaries.end(), sdictDictionaries.begin(),
sdictDictionaries.end() );
}
{
vector< sptr< Dictionary::Class > > aardDictionaries =
Aard::makeDictionaries( allFiles, FsEncoding::encode( Config::getIndexDir() ), *this, maxHeadwordToExpand );
dictionaries.insert( dictionaries.end(), aardDictionaries.begin(),
aardDictionaries.end() );
}
{
vector< sptr< Dictionary::Class > > zipSoundsDictionaries =
ZipSounds::makeDictionaries( allFiles, FsEncoding::encode( Config::getIndexDir() ), *this );
dictionaries.insert( dictionaries.end(), zipSoundsDictionaries.begin(),
zipSoundsDictionaries.end() );
}
{
vector< sptr< Dictionary::Class > > mdxDictionaries =
Mdx::makeDictionaries( allFiles, FsEncoding::encode( Config::getIndexDir() ), *this );
dictionaries.insert( dictionaries.end(), mdxDictionaries.begin(),
mdxDictionaries.end() );
}
{
vector< sptr< Dictionary::Class > > glsDictionaries =
Gls::makeDictionaries( allFiles, FsEncoding::encode( Config::getIndexDir() ), *this );
dictionaries.insert( dictionaries.end(), glsDictionaries.begin(),
glsDictionaries.end() );
}
#ifdef MAKE_ZIM_SUPPORT #ifdef MAKE_ZIM_SUPPORT
{ addDicts(Zim::makeDictionaries( allFiles, FsEncoding::encode( Config::getIndexDir() ), *this, maxHeadwordToExpand ) );
vector< sptr< Dictionary::Class > > zimDictionaries = addDicts(Slob::makeDictionaries( allFiles, FsEncoding::encode( Config::getIndexDir() ), *this, maxHeadwordToExpand ) );
Zim::makeDictionaries( allFiles, FsEncoding::encode( Config::getIndexDir() ), *this, maxHeadwordToExpand );
dictionaries.insert( dictionaries.end(), zimDictionaries.begin(),
zimDictionaries.end() );
}
{
vector< sptr< Dictionary::Class > > slobDictionaries =
Slob::makeDictionaries( allFiles, FsEncoding::encode( Config::getIndexDir() ), *this, maxHeadwordToExpand );
dictionaries.insert( dictionaries.end(), slobDictionaries.begin(),
slobDictionaries.end() );
}
#endif #endif
#ifndef NO_EPWING_SUPPORT #ifndef NO_EPWING_SUPPORT
{ addDicts( Epwing::makeDictionaries( allFiles, FsEncoding::encode( Config::getIndexDir() ), *this ) );
vector< sptr< Dictionary::Class > > epwingDictionaries =
Epwing::makeDictionaries( allFiles, FsEncoding::encode( Config::getIndexDir() ), *this );
dictionaries.insert( dictionaries.end(), epwingDictionaries.begin(),
epwingDictionaries.end() );
}
#endif #endif
} }
@ -261,13 +177,11 @@ void loadDictionaries( QWidget * parent, bool showInitially,
LoadDictionaries loadDicts( cfg ); LoadDictionaries loadDicts( cfg );
QObject::connect( &loadDicts, SIGNAL( indexingDictionarySignal( QString const & ) ), QObject::connect( &loadDicts, &LoadDictionaries::indexingDictionarySignal, &init, &Initializing::indexing );
&init, SLOT( indexing( QString const & ) ) );
QEventLoop localLoop; QEventLoop localLoop;
QObject::connect( &loadDicts, SIGNAL( finished() ), QObject::connect( &loadDicts, &QThread::finished, &localLoop, &QEventLoop::quit );
&localLoop, SLOT( quit() ) );
loadDicts.start(); loadDicts.start();
@ -285,27 +199,20 @@ void loadDictionaries( QWidget * parent, bool showInitially,
dictionaries = loadDicts.getDictionaries(); dictionaries = loadDicts.getDictionaries();
// Helper function that will add a vector of dictionary::Class to the dictionary list
// Implemented as lambda to access method's `dictionaries` variable
auto static addDicts = [&dictionaries](const vector< sptr< Dictionary::Class >> &dicts) {
std::move(dicts.begin(), dicts.end(), std::back_inserter(dictionaries));
};
///// We create transliterations synchronously since they are very simple ///// We create transliterations synchronously since they are very simple
#ifdef MAKE_CHINESE_CONVERSION_SUPPORT #ifdef MAKE_CHINESE_CONVERSION_SUPPORT
// Make Chinese conversion addDicts(Chinese::makeDictionaries( cfg.transliteration.chinese ));
{
vector< sptr< Dictionary::Class > > chineseDictionaries =
Chinese::makeDictionaries( cfg.transliteration.chinese );
dictionaries.insert( dictionaries.end(), chineseDictionaries.begin(),
chineseDictionaries.end() );
}
#endif #endif
// Make Romaji addDicts(Romaji::makeDictionaries( cfg.transliteration.romaji ));
{
vector< sptr< Dictionary::Class > > romajiDictionaries =
Romaji::makeDictionaries( cfg.transliteration.romaji );
dictionaries.insert( dictionaries.end(), romajiDictionaries.begin(),
romajiDictionaries.end() );
}
// Make Russian transliteration // Make Russian transliteration
if ( cfg.transliteration.enableRussianTransliteration ) if ( cfg.transliteration.enableRussianTransliteration )
@ -322,67 +229,17 @@ void loadDictionaries( QWidget * parent, bool showInitially,
// Make Belarusian transliteration // Make Belarusian transliteration
if ( cfg.transliteration.enableBelarusianTransliteration ) if ( cfg.transliteration.enableBelarusianTransliteration )
{ {
vector< sptr< Dictionary::Class > > dicts = BelarusianTranslit::makeDictionaries(); addDicts(BelarusianTranslit::makeDictionaries());
dictionaries.insert( dictionaries.end(), dicts.begin(), dicts.end() );
} }
///// We create MediaWiki dicts synchronously, since they use netmgr addDicts(MediaWiki::makeDictionaries( loadDicts, cfg.mediawikis, dictNetMgr ));
addDicts(WebSite::makeDictionaries( cfg.webSites, dictNetMgr ));
addDicts(Forvo::makeDictionaries( loadDicts, cfg.forvo, dictNetMgr ));
addDicts(Lingua::makeDictionaries( loadDicts, cfg.lingua, dictNetMgr ));
addDicts(Programs::makeDictionaries( cfg.programs ));
addDicts(VoiceEngines::makeDictionaries( cfg.voiceEngines ));
addDicts(DictServer::makeDictionaries( cfg.dictServers ));
{
vector< sptr< Dictionary::Class > > dicts =
MediaWiki::makeDictionaries( loadDicts, cfg.mediawikis, dictNetMgr );
dictionaries.insert( dictionaries.end(), dicts.begin(), dicts.end() );
}
///// WebSites are very simple, no need to create them asynchronously
{
vector< sptr< Dictionary::Class > > dicts =
WebSite::makeDictionaries( cfg.webSites, dictNetMgr );
dictionaries.insert( dictionaries.end(), dicts.begin(), dicts.end() );
}
//// Forvo dictionaries
{
vector< sptr< Dictionary::Class > > dicts =
Forvo::makeDictionaries( loadDicts, cfg.forvo, dictNetMgr );
dictionaries.insert( dictionaries.end(), dicts.begin(), dicts.end() );
}
//// Lingua Libre
{
vector< sptr< Dictionary::Class > > dicts =
Lingua::makeDictionaries( loadDicts, cfg.lingua, dictNetMgr );
dictionaries.insert( dictionaries.end(), dicts.begin(), dicts.end() );
}
//// Programs
{
vector< sptr< Dictionary::Class > > dicts =
Programs::makeDictionaries( cfg.programs );
dictionaries.insert( dictionaries.end(), dicts.begin(), dicts.end() );
}
//// Text to Speech
{
vector< sptr< Dictionary::Class > > dicts =
VoiceEngines::makeDictionaries( cfg.voiceEngines );
dictionaries.insert( dictionaries.end(), dicts.begin(), dicts.end() );
}
{
vector< sptr< Dictionary::Class > > dicts =
DictServer::makeDictionaries( cfg.dictServers );
dictionaries.insert( dictionaries.end(), dicts.begin(), dicts.end() );
}
GD_DPRINTF( "Load done\n" ); GD_DPRINTF( "Load done\n" );

View file

@ -40,9 +40,7 @@ public:
std::string const & getExceptionText() const std::string const & getExceptionText() const
{ return exceptionText; } { return exceptionText; }
signals:
void indexingDictionarySignal( QString const & dictionaryName );
public: public:
@ -51,6 +49,12 @@ public:
private: private:
void handlePath( Config::Path const & ); void handlePath( Config::Path const & );
// Helper function that will add a vector of dictionary::Class to the dictionary list
void addDicts(const std::vector< sptr< Dictionary::Class > >& dicts);
signals:
void indexingDictionarySignal( QString const & dictionaryName );
}; };
/// Loads all dictionaries mentioned in the configuration passed, into the /// Loads all dictionaries mentioned in the configuration passed, into the

View file

@ -3947,9 +3947,29 @@ however, the article from the topmost dictionary is shown.</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../preferences.ui" line="418"/> <location filename="../preferences.ui" line="126"/>
<source>dark mode</source> <source>Article Display style:</source>
<translation></translation> <translation type="unfinished"></translation>
</message>
<message>
<location filename="../preferences.ui" line="161"/>
<source>Turn the UI to dark.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../preferences.ui" line="164"/>
<source>Dark Mode</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../preferences.ui" line="171"/>
<source>Turn the article display style to dark.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../preferences.ui" line="174"/>
<source>Dark Reader Mode</source>
<translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../preferences.ui" line="457"/> <location filename="../preferences.ui" line="457"/>

View file

@ -424,8 +424,7 @@ int main( int argc, char ** argv )
app.addDataCommiter( m ); app.addDataCommiter( m );
QObject::connect( &app, SIGNAL(messageReceived(QString)), QObject::connect( &app, &QtSingleApplication::messageReceived, &m, &MainWindow::messageFromAnotherInstanceReceived );
&m, SLOT(messageFromAnotherInstanceReceived(QString)));
if( gdcl.needSetGroup() ) if( gdcl.needSetGroup() )
m.setGroupByName( gdcl.getGroupName(), true ); m.setGroupByName( gdcl.getGroupName(), true );

View file

@ -38,7 +38,7 @@ MainStatusBar::MainStatusBar( QWidget *parent ) : QWidget( parent )
parentWidget()->installEventFilter( this ); parentWidget()->installEventFilter( this );
connect( timer, SIGNAL( timeout() ), SLOT( clearMessage() ) ); connect( timer, &QTimer::timeout, this, &MainStatusBar::clearMessage );
} }
bool MainStatusBar::hasImage() const bool MainStatusBar::hasImage() const

View file

@ -242,8 +242,7 @@ MainWindow::MainWindow( Config::Class & cfg_ ):
enableScanningAction->setChecked( true ); enableScanningAction->setChecked( true );
} }
connect( enableScanningAction, SIGNAL( toggled( bool ) ), connect( enableScanningAction, &QAction::toggled, this, &MainWindow::scanEnableToggled );
this, SLOT( scanEnableToggled( bool ) ) );
navToolbar->addSeparator(); navToolbar->addSeparator();
@ -288,8 +287,8 @@ MainWindow::MainWindow( Config::Class & cfg_ ):
addToFavorites = navToolbar->addAction( starIcon, tr( "Add current tab to Favorites" ) ); addToFavorites = navToolbar->addAction( starIcon, tr( "Add current tab to Favorites" ) );
navToolbar->widgetForAction( addToFavorites )->setObjectName( "addToFavoritesButton" ); navToolbar->widgetForAction( addToFavorites )->setObjectName( "addToFavoritesButton" );
connect( addToFavorites, SIGNAL( triggered() ), this, SLOT( handleAddToFavoritesButton() ) ); connect( addToFavorites, &QAction::triggered, this, &MainWindow::handleAddToFavoritesButton );
connect( ui.actionAddToFavorites, SIGNAL( triggered() ), this, SLOT( addCurrentTabToFavorites() ) ); connect( ui.actionAddToFavorites, &QAction::triggered, this, &MainWindow::addCurrentTabToFavorites );
beforeOptionsSeparator = navToolbar->addSeparator(); beforeOptionsSeparator = navToolbar->addSeparator();
navToolbar->widgetForAction( beforeOptionsSeparator )->setObjectName( "beforeOptionsSeparator" ); navToolbar->widgetForAction( beforeOptionsSeparator )->setObjectName( "beforeOptionsSeparator" );
@ -333,8 +332,7 @@ MainWindow::MainWindow( Config::Class & cfg_ ):
searchPaneTitleBar.setLayout( &searchPaneTitleBarLayout ); searchPaneTitleBar.setLayout( &searchPaneTitleBarLayout );
ui.searchPane->setTitleBarWidget( &searchPaneTitleBar ); ui.searchPane->setTitleBarWidget( &searchPaneTitleBar );
connect( ui.searchPane->toggleViewAction(), SIGNAL( triggered( bool ) ), connect( ui.searchPane->toggleViewAction(), &QAction::triggered, this, &MainWindow::updateSearchPaneAndBar );
this, SLOT( updateSearchPaneAndBar( bool ) ) );
if ( cfg.preferences.searchInDock ) if ( cfg.preferences.searchInDock )
{ {
@ -372,18 +370,13 @@ MainWindow::MainWindow( Config::Class & cfg_ ):
connect( ui.dictsPane, SIGNAL( visibilityChanged( bool ) ), connect( ui.dictsPane, SIGNAL( visibilityChanged( bool ) ),
this, SLOT( dictsPaneVisibilityChanged ( bool ) ) ); this, SLOT( dictsPaneVisibilityChanged ( bool ) ) );
connect( ui.dictsList, SIGNAL( itemClicked( QListWidgetItem * ) ), connect( ui.dictsList, &QListWidget::itemClicked, this, &MainWindow::foundDictsPaneClicked );
this, SLOT( foundDictsPaneClicked( QListWidgetItem * ) ) );
connect( ui.dictsList, SIGNAL( customContextMenuRequested( const QPoint & ) ), connect( ui.dictsList, &QWidget::customContextMenuRequested, this, &MainWindow::foundDictsContextMenuRequested );
this, SLOT( foundDictsContextMenuRequested( const QPoint & ) ) );
connect( zoomIn, SIGNAL( triggered() ), connect( zoomIn, &QAction::triggered, this, &MainWindow::zoomin );
this, SLOT( zoomin() ) ); connect( zoomOut, &QAction::triggered, this, &MainWindow::zoomout );
connect( zoomOut, SIGNAL( triggered() ), connect( zoomBase, &QAction::triggered, this, &MainWindow::unzoom );
this, SLOT( zoomout() ) );
connect( zoomBase, SIGNAL( triggered() ),
this, SLOT( unzoom() ) );
ui.menuZoom->addAction( zoomIn ); ui.menuZoom->addAction( zoomIn );
ui.menuZoom->addAction( zoomOut ); ui.menuZoom->addAction( zoomOut );
@ -400,18 +393,19 @@ MainWindow::MainWindow( Config::Class & cfg_ ):
wordsZoomBase = ui.menuZoom->addAction( QIcon( ":/icons/icon32_zoombase.png" ), tr( "Words Normal Size" ) ); wordsZoomBase = ui.menuZoom->addAction( QIcon( ":/icons/icon32_zoombase.png" ), tr( "Words Normal Size" ) );
wordsZoomBase->setShortcut( QKeySequence( "Alt+0" ) ); wordsZoomBase->setShortcut( QKeySequence( "Alt+0" ) );
connect( wordsZoomIn, SIGNAL(triggered()), this, SLOT(doWordsZoomIn()) ); connect( wordsZoomIn, &QAction::triggered, this, &MainWindow::doWordsZoomIn );
connect( wordsZoomOut, SIGNAL(triggered()), this, SLOT(doWordsZoomOut()) ); connect( wordsZoomOut, &QAction::triggered, this, &MainWindow::doWordsZoomOut );
connect( wordsZoomBase, SIGNAL(triggered()), this, SLOT(doWordsZoomBase()) ); connect( wordsZoomBase, &QAction::triggered, this, &MainWindow::doWordsZoomBase );
// tray icon // tray icon
connect( trayIconMenu.addAction( tr( "Show &Main Window" ) ), SIGNAL( triggered() ), connect( trayIconMenu.addAction( tr( "Show &Main Window" ) ),
this, SLOT( showMainWindow() ) ); &QAction::triggered,
this,
&MainWindow::showMainWindow );
trayIconMenu.addAction( enableScanningAction ); trayIconMenu.addAction( enableScanningAction );
trayIconMenu.addSeparator(); trayIconMenu.addSeparator();
connect( trayIconMenu.addAction( tr( "&Quit" ) ), SIGNAL( triggered() ), connect( trayIconMenu.addAction( tr( "&Quit" ) ), &QAction::triggered, this, &MainWindow::quitApp );
this, SLOT( quitApp() ) );
addGlobalAction( &escAction, SLOT( handleEsc() ) ); addGlobalAction( &escAction, SLOT( handleEsc() ) );
escAction.setShortcut( QKeySequence( "Esc" ) ); escAction.setShortcut( QKeySequence( "Esc" ) );
@ -435,10 +429,9 @@ MainWindow::MainWindow( Config::Class & cfg_ ):
// Tab management // Tab management
tabListMenu = new MRUQMenu(tr("Opened tabs"), ui.tabWidget); tabListMenu = new MRUQMenu(tr("Opened tabs"), ui.tabWidget);
connect (tabListMenu, SIGNAL(ctrlReleased()), this, SLOT(ctrlReleased())); connect( tabListMenu, &MRUQMenu::ctrlReleased, this, &MainWindow::ctrlReleased );
connect( &addTabAction, SIGNAL( triggered() ), connect( &addTabAction, &QAction::triggered, this, &MainWindow::addNewTab );
this, SLOT( addNewTab() ) );
addAction( &addTabAction ); addAction( &addTabAction );
@ -446,8 +439,7 @@ MainWindow::MainWindow( Config::Class & cfg_ ):
closeCurrentTabAction.setShortcut( QKeySequence( "Ctrl+W" ) ); closeCurrentTabAction.setShortcut( QKeySequence( "Ctrl+W" ) );
closeCurrentTabAction.setText( tr("Close current tab") ); closeCurrentTabAction.setText( tr("Close current tab") );
connect( &closeCurrentTabAction, SIGNAL( triggered() ), connect( &closeCurrentTabAction, &QAction::triggered, this, &MainWindow::closeCurrentTab );
this, SLOT( closeCurrentTab() ) );
addAction( &closeCurrentTabAction ); addAction( &closeCurrentTabAction );
@ -455,32 +447,28 @@ MainWindow::MainWindow( Config::Class & cfg_ ):
closeAllTabAction.setShortcut( QKeySequence( "Ctrl+Shift+W" ) ); closeAllTabAction.setShortcut( QKeySequence( "Ctrl+Shift+W" ) );
closeAllTabAction.setText( tr("Close all tabs") ); closeAllTabAction.setText( tr("Close all tabs") );
connect( &closeAllTabAction, SIGNAL( triggered() ), connect( &closeAllTabAction, &QAction::triggered, this, &MainWindow::closeAllTabs );
this, SLOT( closeAllTabs() ) );
addAction( &closeAllTabAction ); addAction( &closeAllTabAction );
closeRestTabAction.setShortcutContext( Qt::WidgetWithChildrenShortcut ); closeRestTabAction.setShortcutContext( Qt::WidgetWithChildrenShortcut );
closeRestTabAction.setText( tr("Close all tabs except current") ); closeRestTabAction.setText( tr("Close all tabs except current") );
connect( &closeRestTabAction, SIGNAL( triggered() ), connect( &closeRestTabAction, &QAction::triggered, this, &MainWindow::closeRestTabs );
this, SLOT( closeRestTabs() ) );
addAction( &closeRestTabAction ); addAction( &closeRestTabAction );
switchToNextTabAction.setShortcutContext( Qt::WidgetWithChildrenShortcut ); switchToNextTabAction.setShortcutContext( Qt::WidgetWithChildrenShortcut );
switchToNextTabAction.setShortcut( QKeySequence( "Ctrl+PgDown" ) ); switchToNextTabAction.setShortcut( QKeySequence( "Ctrl+PgDown" ) );
connect( &switchToNextTabAction, SIGNAL( triggered() ), connect( &switchToNextTabAction, &QAction::triggered, this, &MainWindow::switchToNextTab );
this, SLOT( switchToNextTab() ) );
addAction( &switchToNextTabAction ); addAction( &switchToNextTabAction );
switchToPrevTabAction.setShortcutContext( Qt::WidgetWithChildrenShortcut ); switchToPrevTabAction.setShortcutContext( Qt::WidgetWithChildrenShortcut );
switchToPrevTabAction.setShortcut( QKeySequence( "Ctrl+PgUp" ) ); switchToPrevTabAction.setShortcut( QKeySequence( "Ctrl+PgUp" ) );
connect( &switchToPrevTabAction, SIGNAL( triggered() ), connect( &switchToPrevTabAction, &QAction::triggered, this, &MainWindow::switchToPrevTab );
this, SLOT( switchToPrevTab() ) );
addAction( &switchToPrevTabAction ); addAction( &switchToPrevTabAction );
@ -490,15 +478,13 @@ MainWindow::MainWindow( Config::Class & cfg_ ):
QKeySequence( Qt::CTRL | Qt::Key_Asterisk ) << QKeySequence( Qt::CTRL | Qt::Key_Asterisk ) <<
QKeySequence( Qt::CTRL | Qt::SHIFT | Qt::Key_8 ) ); QKeySequence( Qt::CTRL | Qt::SHIFT | Qt::Key_8 ) );
connect( &switchExpandModeAction, SIGNAL( triggered() ), connect( &switchExpandModeAction, &QAction::triggered, this, &MainWindow::switchExpandOptionalPartsMode );
this, SLOT(switchExpandOptionalPartsMode() ) );
addAction( &switchExpandModeAction ); addAction( &switchExpandModeAction );
addAllTabToFavoritesAction.setText( tr( "Add all tabs to Favorites" ) ); addAllTabToFavoritesAction.setText( tr( "Add all tabs to Favorites" ) );
connect( &addAllTabToFavoritesAction, SIGNAL( triggered() ), connect( &addAllTabToFavoritesAction, &QAction::triggered, this, &MainWindow::addAllTabsToFavorites );
this, SLOT( addAllTabsToFavorites() ) );
tabMenu = new QMenu(this); tabMenu = new QMenu(this);
tabMenu->addAction( &closeCurrentTabAction ); tabMenu->addAction( &closeCurrentTabAction );
@ -514,24 +500,21 @@ MainWindow::MainWindow( Config::Class & cfg_ ):
showDictBarNamesAction.setCheckable( true ); showDictBarNamesAction.setCheckable( true );
showDictBarNamesAction.setChecked( cfg.showingDictBarNames ); showDictBarNamesAction.setChecked( cfg.showingDictBarNames );
connect( &showDictBarNamesAction, SIGNAL( triggered() ), connect( &showDictBarNamesAction, &QAction::triggered, this, &MainWindow::showDictBarNamesTriggered );
this, SLOT( showDictBarNamesTriggered() ) );
// Use small icons in toolbars // Use small icons in toolbars
useSmallIconsInToolbarsAction.setCheckable( true ); useSmallIconsInToolbarsAction.setCheckable( true );
useSmallIconsInToolbarsAction.setChecked( cfg.usingSmallIconsInToolbars ); useSmallIconsInToolbarsAction.setChecked( cfg.usingSmallIconsInToolbars );
connect( &useSmallIconsInToolbarsAction, SIGNAL( triggered() ), connect( &useSmallIconsInToolbarsAction, &QAction::triggered, this, &MainWindow::useSmallIconsInToolbarsTriggered );
this, SLOT( useSmallIconsInToolbarsTriggered() ) );
// Toggle Menubar // Toggle Menubar
toggleMenuBarAction.setCheckable( true ); toggleMenuBarAction.setCheckable( true );
toggleMenuBarAction.setChecked( !cfg.preferences.hideMenubar ); toggleMenuBarAction.setChecked( !cfg.preferences.hideMenubar );
toggleMenuBarAction.setShortcut( QKeySequence( "Ctrl+M" ) ); toggleMenuBarAction.setShortcut( QKeySequence( "Ctrl+M" ) );
connect( &toggleMenuBarAction, SIGNAL( triggered() ), connect( &toggleMenuBarAction, &QAction::triggered, this, &MainWindow::toggleMenuBarTriggered );
this, SLOT( toggleMenuBarTriggered() ) );
// Populate 'View' menu // Populate 'View' menu
@ -542,9 +525,8 @@ MainWindow::MainWindow( Config::Class & cfg_ ):
ui.menuView->addAction( ui.dictsPane->toggleViewAction() ); ui.menuView->addAction( ui.dictsPane->toggleViewAction() );
ui.dictsPane->toggleViewAction()->setShortcut( QKeySequence( "Ctrl+R" ) ); ui.dictsPane->toggleViewAction()->setShortcut( QKeySequence( "Ctrl+R" ) );
ui.menuView->addAction( ui.favoritesPane->toggleViewAction() ); ui.menuView->addAction( ui.favoritesPane->toggleViewAction() );
ui.favoritesPane->toggleViewAction()->setShortcut( QKeySequence( "Ctrl+I" ) );
ui.menuView->addAction( ui.historyPane->toggleViewAction() ); ui.menuView->addAction( ui.historyPane->toggleViewAction() );
ui.historyPane->toggleViewAction()->setShortcut( QKeySequence( "Ctrl+H" ) );
ui.menuView->addSeparator(); ui.menuView->addSeparator();
ui.menuView->addAction( dictionaryBar.toggleViewAction() ); ui.menuView->addAction( dictionaryBar.toggleViewAction() );
ui.menuView->addAction( navToolbar->toggleViewAction() ); ui.menuView->addAction( navToolbar->toggleViewAction() );
@ -583,51 +565,44 @@ MainWindow::MainWindow( Config::Class & cfg_ ):
addToolBar( &dictionaryBar ); addToolBar( &dictionaryBar );
connect( dictionaryBar.toggleViewAction(), SIGNAL(triggered(bool)), connect( dictionaryBar.toggleViewAction(), &QAction::triggered, this, &MainWindow::dictionaryBarToggled );
this, SLOT(dictionaryBarToggled(bool)) );
// This one will be disconnected once the slot is activated. It exists // This one will be disconnected once the slot is activated. It exists
// only to handle the initial appearance of the dictionary bar. // only to handle the initial appearance of the dictionary bar.
connect( dictionaryBar.toggleViewAction(), SIGNAL(toggled(bool)), connect( dictionaryBar.toggleViewAction(), &QAction::toggled, this, &MainWindow::dictionaryBarToggled );
this, SLOT(dictionaryBarToggled(bool)) );
connect( &dictionaryBar, SIGNAL(editGroupRequested()), connect( &dictionaryBar, &DictionaryBar::editGroupRequested, this, &MainWindow::editCurrentGroup );
this, SLOT(editCurrentGroup()) );
connect( &dictionaryBar, SIGNAL( showDictionaryInfo( QString const & ) ), connect( &dictionaryBar, &DictionaryBar::showDictionaryInfo, this, &MainWindow::showDictionaryInfo );
this, SLOT( showDictionaryInfo( QString const & ) ) );
connect( &dictionaryBar, SIGNAL( showDictionaryHeadwords( QString const & ) ), connect( &dictionaryBar,
this, SLOT( showDictionaryHeadwords( QString const & ) ) ); SIGNAL( showDictionaryHeadwords( QString const & ) ),
this,
SLOT( showDictionaryHeadwords( QString const & ) ) );
connect( &dictionaryBar, SIGNAL( openDictionaryFolder( QString const & ) ), connect( &dictionaryBar, &DictionaryBar::openDictionaryFolder, this, &MainWindow::openDictionaryFolder );
this, SLOT( openDictionaryFolder( QString const & ) ) );
// Favorites // Favorites
ui.favoritesPaneWidget->setUp( &cfg, ui.menuFavorites ); ui.favoritesPaneWidget->setUp( &cfg, ui.menuFavorites );
ui.favoritesPaneWidget->setSaveInterval( cfg.preferences.favoritesStoreInterval ); ui.favoritesPaneWidget->setSaveInterval( cfg.preferences.favoritesStoreInterval );
connect( ui.favoritesPane, SIGNAL( visibilityChanged( bool ) ), connect( ui.favoritesPane, &QDockWidget::visibilityChanged, this, &MainWindow::updateFavoritesMenu );
this, SLOT( updateFavoritesMenu() ) ); connect(ui.showHideFavorites,&QAction::triggered,this,&MainWindow::toggle_favoritesPane);
connect( ui.menuFavorites, SIGNAL( aboutToShow() ), connect( ui.favoritesPaneWidget,
this, SLOT( updateFavoritesMenu() ) ); &FavoritesPaneWidget::favoritesItemRequested,
this,
connect( ui.favoritesPaneWidget, SIGNAL( favoritesItemRequested( QString, QString ) ), &MainWindow::headwordFromFavorites );
this, SLOT( headwordFromFavorites( QString, QString ) ) );
// History // History
ui.historyPaneWidget->setUp( &cfg, &history, ui.menuHistory ); ui.historyPaneWidget->setUp( &cfg, &history, ui.menuHistory );
history.enableAdd( cfg.preferences.storeHistory ); history.enableAdd( cfg.preferences.storeHistory );
connect( ui.historyPaneWidget, SIGNAL( historyItemRequested( QString const & ) ), connect( ui.historyPaneWidget, &HistoryPaneWidget::historyItemRequested, this, &MainWindow::showHistoryItem );
this, SLOT( showHistoryItem( QString const & ) ) );
connect( ui.historyPane, SIGNAL( visibilityChanged( bool ) ), connect( ui.historyPane, &QDockWidget::visibilityChanged, this, &MainWindow::updateHistoryMenu );
this, SLOT( updateHistoryMenu() ) ); connect( ui.showHideHistory, &QAction::triggered, this, &MainWindow::toggle_historyPane );
connect( ui.menuHistory, SIGNAL( aboutToShow() ),
this, SLOT( updateHistoryMenu() ) );
#if !defined( HAVE_X11 ) #if !defined( HAVE_X11 )
// Show tray icon early so the user would be happy. It won't be functional // Show tray icon early so the user would be happy. It won't be functional
@ -643,10 +618,8 @@ MainWindow::MainWindow( Config::Class & cfg_ ):
} }
#endif #endif
connect( navBack, SIGNAL( triggered() ), connect( navBack, &QAction::triggered, this, &MainWindow::backClicked );
this, SLOT( backClicked() ) ); connect( navForward, &QAction::triggered, this, &MainWindow::forwardClicked );
connect( navForward, SIGNAL( triggered() ),
this, SLOT( forwardClicked() ) );
addTab.setAutoRaise( true ); addTab.setAutoRaise( true );
addTab.setToolTip( tr( "New Tab" ) ); addTab.setToolTip( tr( "New Tab" ) );
@ -667,42 +640,29 @@ MainWindow::MainWindow( Config::Class & cfg_ ):
ui.tabWidget->setContextMenuPolicy( Qt::CustomContextMenu ); ui.tabWidget->setContextMenuPolicy( Qt::CustomContextMenu );
connect( &addTab, SIGNAL( clicked() ), connect( &addTab, &QAbstractButton::clicked, this, &MainWindow::addNewTab );
this, SLOT( addNewTab() ) );
connect( ui.tabWidget, SIGNAL( doubleClicked() ), connect( ui.tabWidget, &MainTabWidget::doubleClicked, this, &MainWindow::addNewTab );
this, SLOT( addNewTab() ) );
connect( ui.tabWidget, SIGNAL( tabCloseRequested( int ) ), connect( ui.tabWidget, &QTabWidget::tabCloseRequested, this, &MainWindow::tabCloseRequested );
this, SLOT( tabCloseRequested( int ) ) );
connect( ui.tabWidget, SIGNAL( currentChanged( int ) ), connect( ui.tabWidget, &QTabWidget::currentChanged, this, &MainWindow::tabSwitched );
this, SLOT( tabSwitched( int ) ) );
connect( ui.tabWidget, SIGNAL( customContextMenuRequested(QPoint)) , connect( ui.tabWidget, &QWidget::customContextMenuRequested, this, &MainWindow::tabMenuRequested );
this, SLOT( tabMenuRequested(QPoint)) );
ui.tabWidget->setTabsClosable( true ); ui.tabWidget->setTabsClosable( true );
connect( ui.quit, SIGNAL( triggered() ), connect( ui.quit, &QAction::triggered, this, &MainWindow::quitApp );
this, SLOT( quitApp() ) );
connect( ui.dictionaries, SIGNAL( triggered() ), connect( ui.dictionaries, &QAction::triggered, this, &MainWindow::editDictionaries );
this, SLOT( editDictionaries() ) );
connect( ui.preferences, SIGNAL( triggered() ), connect( ui.preferences, &QAction::triggered, this, &MainWindow::editPreferences );
this, SLOT( editPreferences() ) );
connect( ui.visitHomepage, SIGNAL( triggered() ), connect( ui.visitHomepage, &QAction::triggered, this, &MainWindow::visitHomepage );
this, SLOT( visitHomepage() ) ); connect( ui.visitForum, &QAction::triggered, this, &MainWindow::visitForum );
connect( ui.visitForum, SIGNAL( triggered() ), connect( ui.openConfigFolder, &QAction::triggered, this, &MainWindow::openConfigFolder );
this, SLOT( visitForum() ) ); connect( ui.about, &QAction::triggered, this, &MainWindow::showAbout );
connect( ui.openConfigFolder, SIGNAL( triggered() ), connect( ui.showReference, &QAction::triggered, this, &MainWindow::showGDHelp );
this, SLOT( openConfigFolder() ) );
connect( ui.about, SIGNAL( triggered() ),
this, SLOT( showAbout() ) );
connect( ui.showReference, SIGNAL( triggered() ),
this, SLOT( showGDHelp() ) );
connect( groupListInDock, &GroupComboBox::currentIndexChanged, connect( groupListInDock, &GroupComboBox::currentIndexChanged,
this, &MainWindow::currentGroupChanged ); this, &MainWindow::currentGroupChanged );
@ -710,41 +670,31 @@ MainWindow::MainWindow( Config::Class & cfg_ ):
connect( groupListInToolbar, &GroupComboBox::currentIndexChanged, connect( groupListInToolbar, &GroupComboBox::currentIndexChanged,
this, &MainWindow::currentGroupChanged ); this, &MainWindow::currentGroupChanged );
connect( ui.translateLine, SIGNAL( textChanged( QString const & ) ), connect( ui.translateLine, &QLineEdit::textChanged, this, &MainWindow::translateInputChanged );
this, SLOT( translateInputChanged( QString const & ) ) );
connect( translateBox->translateLine(), SIGNAL( textChanged( QString const & ) ), connect( translateBox->translateLine(), &QLineEdit::textChanged, this, &MainWindow::translateInputChanged );
this, SLOT( translateInputChanged( QString const & ) ) );
connect( ui.translateLine, SIGNAL( returnPressed() ), connect( ui.translateLine, SIGNAL( returnPressed() ), this, SLOT( translateInputFinished() ) );
this, SLOT( translateInputFinished() ) );
connect( translateBox->translateLine(), SIGNAL( returnPressed() ), connect( translateBox->translateLine(), SIGNAL( returnPressed() ),
this, SLOT( translateInputFinished() ) ); this, SLOT( translateInputFinished() ) );
connect( ui.wordList, SIGNAL( itemSelectionChanged() ), connect( ui.wordList, &QListWidget::itemSelectionChanged, this, &MainWindow::wordListSelectionChanged );
this, SLOT( wordListSelectionChanged() ) );
connect( translateBox->wordList(), SIGNAL( itemDoubleClicked ( QListWidgetItem * ) ), connect( translateBox->wordList(), SIGNAL( itemDoubleClicked ( QListWidgetItem * ) ),
this, SLOT( wordListItemActivated( QListWidgetItem * ) ) ); this, SLOT( wordListItemActivated( QListWidgetItem * ) ) );
connect( ui.wordList, SIGNAL( itemClicked( QListWidgetItem * ) ), connect( ui.wordList, &QListWidget::itemClicked, this, &MainWindow::wordListItemActivated );
this, SLOT( wordListItemActivated( QListWidgetItem * ) ) );
connect( ui.wordList, SIGNAL( statusBarMessage( QString const &, int, QPixmap const & ) ), connect( ui.wordList, &WordList::statusBarMessage, this, &MainWindow::showStatusBarMessage );
this, SLOT( showStatusBarMessage( QString const &, int, QPixmap const & ) ) );
connect( translateBox->wordList(), SIGNAL( statusBarMessage( QString const &, int, QPixmap const & ) ), connect( translateBox->wordList(), &WordList::statusBarMessage, this, &MainWindow::showStatusBarMessage );
this, SLOT( showStatusBarMessage( QString const &, int, QPixmap const & ) ) );
connect( ui.dictsList, SIGNAL( itemSelectionChanged() ), connect( ui.dictsList, &QListWidget::itemSelectionChanged, this, &MainWindow::dictsListSelectionChanged );
this, SLOT( dictsListSelectionChanged() ) );
connect( ui.dictsList, SIGNAL( itemDoubleClicked( QListWidgetItem * ) ), connect( ui.dictsList, &QListWidget::itemDoubleClicked, this, &MainWindow::dictsListItemActivated );
this, SLOT( dictsListItemActivated( QListWidgetItem * ) ) );
connect( &configEvents, SIGNAL( mutedDictionariesChanged() ), connect( &configEvents, &Config::Events::mutedDictionariesChanged, this, &MainWindow::mutedDictionariesChanged );
this, SLOT( mutedDictionariesChanged() ) );
this->installEventFilter( this ); this->installEventFilter( this );
@ -769,7 +719,7 @@ MainWindow::MainWindow( Config::Class & cfg_ ):
groupListInDock->installEventFilter( this ); groupListInDock->installEventFilter( this );
groupListInToolbar->installEventFilter( this ); groupListInToolbar->installEventFilter( this );
connect( &ftsIndexing, SIGNAL( newIndexingName( QString ) ), this, SLOT( showFTSIndexingName( QString ) ) ); connect( &ftsIndexing, &FTS::FtsIndexing::newIndexingName, this, &MainWindow::showFTSIndexingName );
#ifndef Q_OS_MAC #ifndef Q_OS_MAC
{ {
@ -787,11 +737,12 @@ MainWindow::MainWindow( Config::Class & cfg_ ):
//set webengineview font //set webengineview font
changeWebEngineViewFont(); changeWebEngineViewFont();
connect( &dictNetMgr, SIGNAL( proxyAuthenticationRequired( QNetworkProxy, QAuthenticator * ) ), connect( &dictNetMgr, &QNetworkAccessManager::proxyAuthenticationRequired, this, &MainWindow::proxyAuthentication );
this, SLOT( proxyAuthentication( QNetworkProxy, QAuthenticator * ) ) );
connect( &articleNetMgr, SIGNAL( proxyAuthenticationRequired( QNetworkProxy, QAuthenticator * ) ), connect( &articleNetMgr,
this, SLOT( proxyAuthentication( QNetworkProxy, QAuthenticator * ) ) ); &QNetworkAccessManager::proxyAuthenticationRequired,
this,
&MainWindow::proxyAuthentication );
setupNetworkCache( cfg.preferences.maxNetworkCacheSize ); setupNetworkCache( cfg.preferences.maxNetworkCacheSize );
@ -833,7 +784,7 @@ MainWindow::MainWindow( Config::Class & cfg_ ):
translateLine->setFocus(); translateLine->setFocus();
applyQtStyleSheet( cfg.preferences.displayStyle, cfg.preferences.addonStyle, cfg.preferences.darkMode ); applyQtStyleSheet( cfg.preferences.addonStyle, cfg.preferences.darkMode );
makeScanPopup(); makeScanPopup();
@ -844,8 +795,7 @@ MainWindow::MainWindow( Config::Class & cfg_ ):
trayIcon->setContextMenu( &trayIconMenu ); trayIcon->setContextMenu( &trayIconMenu );
trayIcon->show(); trayIcon->show();
connect( trayIcon, SIGNAL( activated( QSystemTrayIcon::ActivationReason ) ), connect( trayIcon, &QSystemTrayIcon::activated, this, &MainWindow::trayIconActivated );
this, SLOT( trayIconActivated( QSystemTrayIcon::ActivationReason ) ) );
} }
updateTrayIcon(); updateTrayIcon();
@ -873,8 +823,7 @@ MainWindow::MainWindow( Config::Class & cfg_ ):
focusTranslateLine(); focusTranslateLine();
} }
connect( &newReleaseCheckTimer, SIGNAL( timeout() ), connect( &newReleaseCheckTimer, &QTimer::timeout, this, &MainWindow::checkForNewRelease );
this, SLOT( checkForNewRelease() ) );
if ( cfg.preferences.hideMenubar ) if ( cfg.preferences.hideMenubar )
{ {
@ -1174,7 +1123,7 @@ QPrinter & MainWindow::getPrinter()
return *printer; return *printer;
} }
void MainWindow::applyQtStyleSheet( QString const & displayStyle, QString const & addonStyle, bool const & darkMode ) void MainWindow::applyQtStyleSheet( QString const & addonStyle, bool const & darkMode )
{ {
#ifdef Q_OS_WIN32 #ifdef Q_OS_WIN32
if( darkMode ) if( darkMode )
@ -1264,11 +1213,9 @@ void MainWindow::updateTrayIcon()
trayIcon->setContextMenu( &trayIconMenu ); trayIcon->setContextMenu( &trayIconMenu );
trayIcon->show(); trayIcon->show();
connect( trayIcon, SIGNAL( activated( QSystemTrayIcon::ActivationReason ) ), connect( trayIcon, &QSystemTrayIcon::activated, this, &MainWindow::trayIconActivated );
this, SLOT( trayIconActivated( QSystemTrayIcon::ActivationReason ) ) );
} }
else else if( trayIcon && !cfg.preferences.enableTrayIcon )
if ( trayIcon && !cfg.preferences.enableTrayIcon )
{ {
// Need to hide it // Need to hide it
delete trayIcon; delete trayIcon;
@ -1580,37 +1527,31 @@ void MainWindow::makeScanPopup()
connect( scanPopup.get(), SIGNAL(editGroupRequested( unsigned ) ), connect( scanPopup.get(), SIGNAL(editGroupRequested( unsigned ) ),
this, SLOT(editDictionaries( unsigned )), Qt::QueuedConnection ); this, SLOT(editDictionaries( unsigned )), Qt::QueuedConnection );
connect( scanPopup.get(), SIGNAL(sendPhraseToMainWindow( Config::InputPhrase const & ) ), connect( scanPopup.get(),
this, SLOT(phraseReceived( Config::InputPhrase const & )), Qt::QueuedConnection ); &ScanPopup::sendPhraseToMainWindow,
this,
&MainWindow::phraseReceived,
Qt::QueuedConnection );
connect( this, SIGNAL( setExpandOptionalParts( bool ) ), connect( this, &MainWindow::setExpandOptionalParts, scanPopup.get(), &ScanPopup::setViewExpandMode );
scanPopup.get(), SIGNAL( setViewExpandMode( bool ) ) );
connect( scanPopup.get(), SIGNAL( setExpandMode( bool ) ), connect( scanPopup.get(), &ScanPopup::setExpandMode, this, &MainWindow::setExpandMode );
this, SLOT( setExpandMode( bool ) ) );
connect( scanPopup.get(), &ScanPopup::inspectSignal,this,&MainWindow::inspectElement ); connect( scanPopup.get(), &ScanPopup::inspectSignal,this,&MainWindow::inspectElement );
connect( scanPopup.get(), SIGNAL( forceAddWordToHistory( const QString & ) ), connect( scanPopup.get(), &ScanPopup::forceAddWordToHistory, this, &MainWindow::forceAddWordToHistory );
this, SLOT( forceAddWordToHistory( const QString & ) ) );
connect( scanPopup.get(), SIGNAL( showDictionaryInfo( const QString & ) ), connect( scanPopup.get(), &ScanPopup::showDictionaryInfo, this, &MainWindow::showDictionaryInfo );
this, SLOT( showDictionaryInfo( const QString & ) ) );
connect( scanPopup.get(), SIGNAL( openDictionaryFolder( const QString & ) ), connect( scanPopup.get(), &ScanPopup::openDictionaryFolder, this, &MainWindow::openDictionaryFolder );
this, SLOT( openDictionaryFolder( const QString & ) ) );
connect( scanPopup.get(), SIGNAL( sendWordToHistory( QString ) ), connect( scanPopup.get(), &ScanPopup::sendWordToHistory, this, &MainWindow::addWordToHistory );
this, SLOT( addWordToHistory( QString ) ) );
connect( this, SIGNAL( setPopupGroupByName( QString ) ), connect( this, &MainWindow::setPopupGroupByName, scanPopup.get(), &ScanPopup::setGroupByName );
scanPopup.get(), SLOT( setGroupByName( QString ) ) );
connect( scanPopup.get(), SIGNAL( sendWordToFavorites( QString, uint ) ), connect( scanPopup.get(), &ScanPopup::sendWordToFavorites, this, &MainWindow::addWordToFavorites );
this, SLOT( addWordToFavorites( QString, uint ) ) );
connect( scanPopup.get(), SIGNAL( isWordPresentedInFavorites( QString, uint ) ), connect( scanPopup.get(), &ScanPopup::isWordPresentedInFavorites, this, &MainWindow::isWordPresentedInFavorites );
this, SLOT( isWordPresentedInFavorites( QString, uint ) ) );
#ifdef Q_OS_WIN32 #ifdef Q_OS_WIN32
connect( scanPopup.get(), SIGNAL( isGoldenDictWindow( HWND ) ), connect( scanPopup.get(), SIGNAL( isGoldenDictWindow( HWND ) ),
@ -1657,8 +1598,8 @@ vector< sptr< Dictionary::Class > > const & MainWindow::getActiveDicts()
void MainWindow::createTabList() void MainWindow::createTabList()
{ {
tabListMenu->setIcon(QIcon(":/icons/windows-list.svg")); tabListMenu->setIcon(QIcon(":/icons/windows-list.svg"));
connect(tabListMenu, SIGNAL(aboutToShow()), this, SLOT(fillWindowsMenu())); connect( tabListMenu, &QMenu::aboutToShow, this, &MainWindow::fillWindowsMenu );
connect(tabListMenu, SIGNAL(triggered(QAction*)), this, SLOT(switchToWindow(QAction*))); connect( tabListMenu, &QMenu::triggered, this, &MainWindow::switchToWindow );
tabListButton = new QToolButton(ui.tabWidget); tabListButton = new QToolButton(ui.tabWidget);
tabListButton->setAutoRaise(true); tabListButton->setAutoRaise(true);
@ -1735,55 +1676,41 @@ ArticleView * MainWindow::createNewTab( bool switchToIt,
connect( view, &ArticleView::inspectSignal,this,&MainWindow::inspectElement); connect( view, &ArticleView::inspectSignal,this,&MainWindow::inspectElement);
connect( view, SIGNAL( titleChanged( ArticleView *, QString const & ) ), connect( view, &ArticleView::titleChanged, this, &MainWindow::titleChanged );
this, SLOT( titleChanged( ArticleView *, QString const & ) ) );
connect( view, SIGNAL( iconChanged( ArticleView *, QIcon const & ) ), connect( view, &ArticleView::iconChanged, this, &MainWindow::iconChanged );
this, SLOT( iconChanged( ArticleView *, QIcon const & ) ) );
connect( view, SIGNAL( pageLoaded( ArticleView * ) ), connect( view, &ArticleView::pageLoaded, this, &MainWindow::pageLoaded );
this, SLOT( pageLoaded( ArticleView * ) ) );
connect( view, SIGNAL( updateFoundInDictsList( ) ), connect( view, &ArticleView::updateFoundInDictsList, this, &MainWindow::updateFoundInDictsList );
this, SLOT( updateFoundInDictsList() ) );
connect( view, SIGNAL( openLinkInNewTab( QUrl const &, QUrl const &, QString const &, ArticleView::Contexts const & ) ), connect( view, &ArticleView::openLinkInNewTab, this, &MainWindow::openLinkInNewTab );
this, SLOT( openLinkInNewTab( QUrl const &, QUrl const &, QString const &, ArticleView::Contexts const & ) ) );
connect( view, SIGNAL( showDefinitionInNewTab( QString const &, unsigned, QString const &, ArticleView::Contexts const & ) ), connect( view, &ArticleView::showDefinitionInNewTab, this, &MainWindow::showDefinitionInNewTab );
this, SLOT( showDefinitionInNewTab( QString const &, unsigned, QString const &, ArticleView::Contexts const & ) ) );
connect( view, SIGNAL( typingEvent( QString const & ) ), connect( view, &ArticleView::typingEvent, this, &MainWindow::typingEvent );
this, SLOT( typingEvent( QString const & ) ) );
connect( view, SIGNAL( activeArticleChanged( ArticleView const *, const QString & ) ), connect( view, &ArticleView::activeArticleChanged, this, &MainWindow::activeArticleChanged );
this, SLOT( activeArticleChanged( ArticleView const *, const QString & ) ) );
connect( view, SIGNAL( statusBarMessage( QString const &, int, QPixmap const & ) ), connect( view, &ArticleView::statusBarMessage, this, &MainWindow::showStatusBarMessage );
this, SLOT( showStatusBarMessage( QString const &, int, QPixmap const & ) ) );
connect( view, SIGNAL( showDictsPane( ) ), this, SLOT( showDictsPane( ) ) ); connect( view, &ArticleView::showDictsPane, this, &MainWindow::showDictsPane );
connect( view, SIGNAL( forceAddWordToHistory( const QString & ) ), connect( view, &ArticleView::forceAddWordToHistory, this, &MainWindow::forceAddWordToHistory );
this, SLOT( forceAddWordToHistory( const QString & ) ) );
connect( this, SIGNAL( setExpandOptionalParts( bool ) ), connect( this, &MainWindow::setExpandOptionalParts, view, &ArticleView::receiveExpandOptionalParts );
view, SLOT( receiveExpandOptionalParts( bool ) ) );
connect( view, SIGNAL( setExpandMode( bool ) ), this, SLOT( setExpandMode( bool ) ) ); connect( view, &ArticleView::setExpandMode, this, &MainWindow::setExpandMode );
connect( view, SIGNAL( sendWordToHistory( QString ) ), connect( view, &ArticleView::sendWordToHistory, this, &MainWindow::addWordToHistory );
this, SLOT( addWordToHistory( QString ) ) );
connect( view, SIGNAL( sendWordToInputLine( QString const & ) ), connect( view, &ArticleView::sendWordToInputLine, this, &MainWindow::sendWordToInputLine );
this, SLOT( sendWordToInputLine( QString const & ) ) );
connect( view, SIGNAL( storeResourceSavePath( QString const & ) ), connect( view, &ArticleView::storeResourceSavePath, this, &MainWindow::storeResourceSavePath );
this, SLOT( storeResourceSavePath( QString const & ) ) );
connect( view, SIGNAL( zoomIn()), this, SLOT( zoomin() ) ); connect( view, &ArticleView::zoomIn, this, &MainWindow::zoomin );
connect( view, SIGNAL( zoomOut()), this, SLOT( zoomout() ) ); connect( view, &ArticleView::zoomOut, this, &MainWindow::zoomout );
connect( view, &ArticleView::saveBookmarkSignal, this, &MainWindow::addBookmarkToFavorite ); connect( view, &ArticleView::saveBookmarkSignal, this, &MainWindow::addBookmarkToFavorite );
view->setSelectionBySingleClick( cfg.preferences.selectWordBySingleClick ); view->setSelectionBySingleClick( cfg.preferences.selectWordBySingleClick );
@ -2051,8 +1978,7 @@ void MainWindow::tabMenuRequested(QPoint pos)
void MainWindow::dictionaryBarToggled( bool ) void MainWindow::dictionaryBarToggled( bool )
{ {
// From now on, only the triggered() signal is interesting to us // From now on, only the triggered() signal is interesting to us
disconnect( dictionaryBar.toggleViewAction(), SIGNAL(toggled(bool)), disconnect( dictionaryBar.toggleViewAction(), &QAction::toggled, this, &MainWindow::dictionaryBarToggled );
this, SLOT(dictionaryBarToggled(bool)) );
updateDictionaryBar(); // Updates dictionary bar contents if it's shown updateDictionaryBar(); // Updates dictionary bar contents if it's shown
applyMutedDictionariesState(); // Visibility change affects searches and results applyMutedDictionariesState(); // Visibility change affects searches and results
@ -2172,11 +2098,12 @@ void MainWindow::editDictionaries( unsigned editDictionaryGroup )
Config::Class newCfg = cfg; Config::Class newCfg = cfg;
EditDictionaries dicts( this, newCfg, dictionaries, groupInstances, dictNetMgr ); EditDictionaries dicts( this, newCfg, dictionaries, groupInstances, dictNetMgr );
connect( &dicts, SIGNAL( showDictionaryInfo( QString const & ) ), connect( &dicts, &EditDictionaries::showDictionaryInfo, this, &MainWindow::showDictionaryInfo );
this, SLOT( showDictionaryInfo( QString const & ) ) );
connect( &dicts, SIGNAL( showDictionaryHeadwords( QString const & ) ), connect( &dicts,
this, SLOT( showDictionaryHeadwords( QString const & ) ) ); SIGNAL( showDictionaryHeadwords( QString const & ) ),
this,
SLOT( showDictionaryHeadwords( QString const & ) ) );
if ( editDictionaryGroup != Instances::Group::NoGroupId ) if ( editDictionaryGroup != Instances::Group::NoGroupId )
dicts.editGroup( editDictionaryGroup ); dicts.editGroup( editDictionaryGroup );
@ -2278,10 +2205,10 @@ void MainWindow::editPreferences()
bool needReload = false; bool needReload = false;
// See if we need to reapply stylesheets // See if we need to reapply Qt stylesheets
if ( cfg.preferences.displayStyle != p.displayStyle || cfg.preferences.addonStyle != p.addonStyle || cfg.preferences.darkMode != p.darkMode) if ( cfg.preferences.addonStyle != p.addonStyle || cfg.preferences.darkMode != p.darkMode)
{ {
applyQtStyleSheet( p.displayStyle, p.addonStyle, p.darkMode ); applyQtStyleSheet( p.addonStyle, p.darkMode );
articleMaker.setDisplayStyle( p.displayStyle, p.addonStyle ); articleMaker.setDisplayStyle( p.displayStyle, p.addonStyle );
needReload = true; needReload = true;
} }
@ -2580,24 +2507,7 @@ bool MainWindow::eventFilter( QObject * obj, QEvent * ev )
if ( ev->type() == QEvent::ShortcutOverride if ( ev->type() == QEvent::ShortcutOverride
|| ev->type() == QEvent::KeyPress ) || ev->type() == QEvent::KeyPress )
{ {
// Handle Ctrl+H to show the History Pane.
QKeyEvent * ke = static_cast<QKeyEvent*>( ev ); QKeyEvent * ke = static_cast<QKeyEvent*>( ev );
if ( ke->key() == Qt::Key_H && ke->modifiers() == Qt::ControlModifier )
{
if( ev->type() == QEvent::KeyPress )
on_showHideHistory_triggered();
ev->accept();
return true;
}
// Handle Ctrl+I to show the Favorities Pane.
if ( ke->key() == Qt::Key_I && ke->modifiers() == Qt::ControlModifier )
{
if( ev->type() == QEvent::KeyPress )
on_showHideFavorites_triggered();
ev->accept();
return true;
}
// Handle F3/Shift+F3 shortcuts // Handle F3/Shift+F3 shortcuts
if ( ke->key() == Qt::Key_F3 ) if ( ke->key() == Qt::Key_F3 )
@ -2690,7 +2600,7 @@ bool MainWindow::eventFilter( QObject * obj, QEvent * ev )
// select all on mouse click // select all on mouse click
if ( focusEvent->reason() == Qt::MouseFocusReason ) { if ( focusEvent->reason() == Qt::MouseFocusReason ) {
QTimer::singleShot(0, this, SLOT(focusTranslateLine())); QTimer::singleShot( 0, this, &MainWindow::focusTranslateLine );
} }
return false; return false;
} }
@ -3062,8 +2972,10 @@ void MainWindow::installHotKeys()
1 ); 1 );
} }
connect( hotkeyWrapper.get(), SIGNAL( hotkeyActivated( int ) ), connect( hotkeyWrapper.get(),
this, SLOT( hotKeyActivated( int ) ), &HotkeyWrapper::hotkeyActivated,
this,
&MainWindow::hotKeyActivated,
Qt::AutoConnection ); Qt::AutoConnection );
} }
} }
@ -3129,8 +3041,11 @@ void MainWindow::checkForNewRelease()
latestReleaseReply = articleNetMgr.get( req ); latestReleaseReply = articleNetMgr.get( req );
connect( latestReleaseReply, SIGNAL( finished() ), connect( latestReleaseReply,
this, SLOT( latestReleaseReplyReady() ), Qt::QueuedConnection ); &QNetworkReply::finished,
this,
&MainWindow::latestReleaseReplyReady,
Qt::QueuedConnection );
} }
void MainWindow::latestReleaseReplyReady() void MainWindow::latestReleaseReplyReady()
@ -3445,8 +3360,7 @@ void MainWindow::on_printPreview_triggered()
int index=combox->findText( "100%" ); int index=combox->findText( "100%" );
combox->setCurrentIndex( index ); combox->setCurrentIndex( index );
connect( &dialog, SIGNAL( paintRequested( QPrinter * ) ), connect( &dialog, &QPrintPreviewDialog::paintRequested, this, &MainWindow::printPreviewPaintRequested );
this, SLOT( printPreviewPaintRequested( QPrinter * ) ) );
dialog.showMaximized(); dialog.showMaximized();
dialog.exec(); dialog.exec();
@ -3615,7 +3529,7 @@ void MainWindow::on_saveArticle_triggered()
if( !handler->isEmpty() ) if( !handler->isEmpty() )
{ {
maxVal += 1; maxVal += 1;
connect( handler, SIGNAL( done() ), progressDialog, SLOT( perform() ) ); connect( handler, &ResourceToSaveHandler::done, progressDialog, &ArticleSaveProgressDialog::perform );
} }
} }
@ -3732,7 +3646,7 @@ void MainWindow::applyZoomFactor()
// so all of them except for the first one don't change anything and run very fast. // so all of them except for the first one don't change anything and run very fast.
// In effect, some intermediate zoom factors are skipped when scaling is slow. // In effect, some intermediate zoom factors are skipped when scaling is slow.
// The slower the scaling, the more steps are skipped. // The slower the scaling, the more steps are skipped.
QTimer::singleShot( 0, this, SLOT( scaleArticlesByCurrentZoomFactor() ) ); QTimer::singleShot( 0, this, &MainWindow::scaleArticlesByCurrentZoomFactor );
} }
void MainWindow::adjustCurrentZoomFactor() void MainWindow::adjustCurrentZoomFactor()
@ -3917,7 +3831,7 @@ void MainWindow::headwordReceived( const QString & word, const QString & ID )
void MainWindow::updateFavoritesMenu() void MainWindow::updateFavoritesMenu()
{ {
if ( ui.favoritesPane->toggleViewAction()->isChecked() ) if ( ui.favoritesPane->isVisible() )
{ {
ui.showHideFavorites->setText( tr( "&Hide" ) ); ui.showHideFavorites->setText( tr( "&Hide" ) );
} }
@ -3929,7 +3843,7 @@ void MainWindow::updateFavoritesMenu()
void MainWindow::updateHistoryMenu() void MainWindow::updateHistoryMenu()
{ {
if ( ui.historyPane->toggleViewAction()->isChecked() ) if( ui.historyPane->isVisible() )
{ {
ui.showHideHistory->setText( tr( "&Hide" ) ); ui.showHideHistory->setText( tr( "&Hide" ) );
} }
@ -3939,16 +3853,30 @@ void MainWindow::updateHistoryMenu()
} }
} }
void MainWindow::on_showHideFavorites_triggered() void MainWindow::toggle_favoritesPane()
{ {
ui.favoritesPane->toggleViewAction()->trigger(); if( ui.favoritesPane->isVisible() )
{
ui.favoritesPane->hide();
}
else
{
ui.favoritesPane->show();
ui.favoritesPane->raise(); // useful when the Pane is tabbed. ui.favoritesPane->raise(); // useful when the Pane is tabbed.
}
} }
void MainWindow::on_showHideHistory_triggered() void MainWindow::toggle_historyPane()
{ {
ui.historyPane->toggleViewAction()->trigger(); if( ui.historyPane->isVisible() )
ui.historyPane->raise(); // useful when the Pane is tabbed. {
ui.historyPane->hide();
}
else
{
ui.historyPane->show();
ui.historyPane->raise();
}
} }
void MainWindow::on_exportHistory_triggered() void MainWindow::on_exportHistory_triggered()
@ -4364,10 +4292,8 @@ void MainWindow::showDictionaryHeadwords( QWidget * owner, Dictionary::Class * d
headwordsDlg = new DictHeadwords( this, cfg, dict ); headwordsDlg = new DictHeadwords( this, cfg, dict );
addGlobalActionsToDialog( headwordsDlg ); addGlobalActionsToDialog( headwordsDlg );
addGroupComboBoxActionsToDialog( headwordsDlg, groupList ); addGroupComboBoxActionsToDialog( headwordsDlg, groupList );
connect( headwordsDlg, SIGNAL( headwordSelected( QString, QString ) ), connect( headwordsDlg, &DictHeadwords::headwordSelected, this, &MainWindow::headwordReceived );
this, SLOT( headwordReceived( QString, QString ) ) ); connect( headwordsDlg, &DictHeadwords::closeDialog, this, &MainWindow::closeHeadwordsDialog, Qt::QueuedConnection );
connect( headwordsDlg, SIGNAL( closeDialog() ),
this, SLOT( closeHeadwordsDialog() ), Qt::QueuedConnection );
} }
else else
headwordsDlg->setup( dict ); headwordsDlg->setup( dict );
@ -4590,8 +4516,11 @@ void MainWindow::showFullTextSearchDialog()
connect( ftsDlg, SIGNAL( showTranslationFor( QString, QStringList, QRegExp, bool ) ), connect( ftsDlg, SIGNAL( showTranslationFor( QString, QStringList, QRegExp, bool ) ),
this, SLOT( showTranslationFor( QString, QStringList, QRegExp, bool ) ) ); this, SLOT( showTranslationFor( QString, QStringList, QRegExp, bool ) ) );
connect( ftsDlg, SIGNAL( closeDialog() ), connect( ftsDlg,
this, SLOT( closeFullTextSearchDialog() ), Qt::QueuedConnection ); &FTS::FullTextSearchDialog::closeDialog,
this,
&MainWindow::closeFullTextSearchDialog,
Qt::QueuedConnection );
connect( &configEvents, SIGNAL( mutedDictionariesChanged() ), connect( &configEvents, SIGNAL( mutedDictionariesChanged() ),
ftsDlg, SLOT( updateDictionaries() ) ); ftsDlg, SLOT( updateDictionaries() ) );
@ -4628,7 +4557,7 @@ void MainWindow::showGDHelp()
if( helpWindow->getHelpEngine() ) if( helpWindow->getHelpEngine() )
{ {
connect( helpWindow, SIGNAL( needClose() ), this, SLOT( hideGDHelp() ) ); connect( helpWindow, &Help::HelpWindow::needClose, this, &MainWindow::hideGDHelp );
helpWindow->showHelpFor( "Content" ); helpWindow->showHelpFor( "Content" );
helpWindow->show(); helpWindow->show();
} }

View file

@ -181,8 +181,8 @@ private:
IframeSchemeHandler * iframeSchemeHandler; IframeSchemeHandler * iframeSchemeHandler;
ResourceSchemeHandler * resourceSchemeHandler; ResourceSchemeHandler * resourceSchemeHandler;
/// Applies the qt's stylesheet, given the style's name. /// Applies the custom Qt stylesheet
void applyQtStyleSheet( QString const & displayStyle, QString const & addonStyle, bool const & darkMode ); void applyQtStyleSheet( QString const & addonStyle, bool const & darkMode );
/// Creates, destroys or otherwise updates tray icon, according to the /// Creates, destroys or otherwise updates tray icon, according to the
/// current configuration and situation. /// current configuration and situation.
@ -437,8 +437,8 @@ private slots:
void on_rescanFiles_triggered(); void on_rescanFiles_triggered();
void on_showHideFavorites_triggered(); void toggle_favoritesPane();
void on_showHideHistory_triggered(); void toggle_historyPane(); // Toggling visibility
void on_exportHistory_triggered(); void on_exportHistory_triggered();
void on_importHistory_triggered(); void on_importHistory_triggered();
void on_alwaysOnTop_triggered( bool checked ); void on_alwaysOnTop_triggered( bool checked );

View file

@ -103,26 +103,22 @@ OrderAndProps::OrderAndProps( QWidget * parent,
disableDictionaryDescription(); disableDictionaryDescription();
ui.dictionaryOrder->setContextMenuPolicy( Qt::CustomContextMenu ); ui.dictionaryOrder->setContextMenuPolicy( Qt::CustomContextMenu );
connect( ui.dictionaryOrder, SIGNAL( customContextMenuRequested( QPoint ) ), connect( ui.dictionaryOrder, &QWidget::customContextMenuRequested, this, &OrderAndProps::contextMenuRequested );
this, SLOT( contextMenuRequested( QPoint ) ) );
connect( ui.dictionaryOrder, SIGNAL( gotFocus() ), connect( ui.dictionaryOrder, &DictListWidget::gotFocus, this, &OrderAndProps::dictListFocused );
this, SLOT( dictListFocused() ) ); connect( ui.inactiveDictionaries, &DictListWidget::gotFocus, this, &OrderAndProps::inactiveDictListFocused );
connect( ui.inactiveDictionaries, SIGNAL( gotFocus() ),
this, SLOT( inactiveDictListFocused() ) );
connect ( ui.dictionaryOrder->selectionModel(), SIGNAL( selectionChanged ( const QItemSelection & , const QItemSelection & ) ), connect ( ui.dictionaryOrder->selectionModel(), SIGNAL( selectionChanged ( const QItemSelection & , const QItemSelection & ) ),
this, SLOT( dictionarySelectionChanged( const QItemSelection & ) ) ); this, SLOT( dictionarySelectionChanged( const QItemSelection & ) ) );
connect ( ui.inactiveDictionaries->selectionModel(), SIGNAL( selectionChanged( const QItemSelection &, const QItemSelection & ) ), connect( ui.inactiveDictionaries->selectionModel(),
this, SLOT( inactiveDictionarySelectionChanged( QItemSelection const & ) ) ); &QItemSelectionModel::selectionChanged,
this,
&OrderAndProps::inactiveDictionarySelectionChanged );
connect (ui.searchLine, SIGNAL( filterChanged( QString const & ) ), connect( ui.searchLine, &QuickFilterLine::filterChanged, this, &OrderAndProps::filterChanged );
this, SLOT( filterChanged( QString const &) ) );
connect( ui.dictionaryOrder->getModel(), SIGNAL( contentChanged() ), connect( ui.dictionaryOrder->getModel(), &DictListModel::contentChanged, this, &OrderAndProps::showDictNumbers );
this, SLOT( showDictNumbers() ) ); connect( ui.inactiveDictionaries->getModel(), &DictListModel::contentChanged, this, &OrderAndProps::showDictNumbers );
connect( ui.inactiveDictionaries->getModel(), SIGNAL( contentChanged() ),
this, SLOT( showDictNumbers() ) );
showDictNumbers(); showDictNumbers();
} }

View file

@ -16,40 +16,30 @@ Preferences::Preferences( QWidget * parent, Config::Class & cfg_ ):
Config::Preferences const & p = cfg_.preferences; Config::Preferences const & p = cfg_.preferences;
ui.setupUi( this ); ui.setupUi( this );
connect( ui.enableScanPopupModifiers, SIGNAL( toggled( bool ) ), connect( ui.enableScanPopupModifiers,
this, SLOT( enableScanPopupModifiersToggled( bool ) ) ); &QAbstractButton::toggled,
this,
&Preferences::enableScanPopupModifiersToggled );
connect( ui.showScanFlag, SIGNAL( toggled( bool ) ), connect( ui.showScanFlag, &QAbstractButton::toggled, this, &Preferences::showScanFlagToggled );
this, SLOT( showScanFlagToggled( bool ) ) );
connect( ui.altKey, SIGNAL( clicked( bool ) ), connect( ui.altKey, &QAbstractButton::clicked, this, &Preferences::wholeAltClicked );
this, SLOT( wholeAltClicked( bool ) ) ); connect( ui.ctrlKey, &QAbstractButton::clicked, this, &Preferences::wholeCtrlClicked );
connect( ui.ctrlKey, SIGNAL( clicked( bool ) ), connect( ui.shiftKey, &QAbstractButton::clicked, this, &Preferences::wholeShiftClicked );
this, SLOT( wholeCtrlClicked( bool ) ) );
connect( ui.shiftKey, SIGNAL( clicked( bool ) ),
this, SLOT( wholeShiftClicked( bool ) ) );
connect( ui.leftAlt, SIGNAL( clicked( bool ) ), connect( ui.leftAlt, &QAbstractButton::clicked, this, &Preferences::sideAltClicked );
this, SLOT( sideAltClicked( bool ) ) ); connect( ui.rightAlt, &QAbstractButton::clicked, this, &Preferences::sideAltClicked );
connect( ui.rightAlt, SIGNAL( clicked( bool ) ), connect( ui.leftCtrl, &QAbstractButton::clicked, this, &Preferences::sideCtrlClicked );
this, SLOT( sideAltClicked( bool ) ) ); connect( ui.rightCtrl, &QAbstractButton::clicked, this, &Preferences::sideCtrlClicked );
connect( ui.leftCtrl, SIGNAL( clicked( bool ) ), connect( ui.leftShift, &QAbstractButton::clicked, this, &Preferences::sideShiftClicked );
this, SLOT( sideCtrlClicked( bool ) ) ); connect( ui.rightShift, &QAbstractButton::clicked, this, &Preferences::sideShiftClicked );
connect( ui.rightCtrl, SIGNAL( clicked( bool ) ),
this, SLOT( sideCtrlClicked( bool ) ) );
connect( ui.leftShift, SIGNAL( clicked( bool ) ),
this, SLOT( sideShiftClicked( bool ) ) );
connect( ui.rightShift, SIGNAL( clicked( bool ) ),
this, SLOT( sideShiftClicked( bool ) ) );
connect( ui.buttonBox, SIGNAL( helpRequested() ), connect( ui.buttonBox, &QDialogButtonBox::helpRequested, this, &Preferences::helpRequested );
this, SLOT( helpRequested() ) );
helpAction.setShortcut( QKeySequence( "F1" ) ); helpAction.setShortcut( QKeySequence( "F1" ) );
helpAction.setShortcutContext( Qt::WidgetWithChildrenShortcut ); helpAction.setShortcutContext( Qt::WidgetWithChildrenShortcut );
connect( &helpAction, SIGNAL( triggered() ), connect( &helpAction, &QAction::triggered, this, &Preferences::helpRequested );
this, SLOT( helpRequested() ) );
addAction( &helpAction ); addAction( &helpAction );
@ -182,6 +172,7 @@ Preferences::Preferences( QWidget * parent, Config::Class & cfg_ ):
ui.autoScrollToTargetArticle->setChecked( p.autoScrollToTargetArticle ); ui.autoScrollToTargetArticle->setChecked( p.autoScrollToTargetArticle );
ui.escKeyHidesMainWindow->setChecked( p.escKeyHidesMainWindow ); ui.escKeyHidesMainWindow->setChecked( p.escKeyHidesMainWindow );
ui.darkMode->setChecked(p.darkMode); ui.darkMode->setChecked(p.darkMode);
ui.darkReaderMode -> setChecked(p.darkReaderMode);
#ifndef Q_OS_WIN32 #ifndef Q_OS_WIN32
ui.darkMode->hide(); ui.darkMode->hide();
#endif #endif
@ -329,11 +320,9 @@ Preferences::Preferences( QWidget * parent, Config::Class & cfg_ ):
ui.ankiModel->setText( p.ankiConnectServer.model ); ui.ankiModel->setText( p.ankiConnectServer.model );
ui.ankiDeck->setText(p.ankiConnectServer.deck); ui.ankiDeck->setText(p.ankiConnectServer.deck);
connect( ui.customProxy, SIGNAL( toggled( bool ) ), connect( ui.customProxy, &QAbstractButton::toggled, this, &Preferences::customProxyToggled );
this, SLOT( customProxyToggled( bool ) ) );
connect( ui.useProxyServer, SIGNAL( toggled( bool ) ), connect( ui.useProxyServer, &QGroupBox::toggled, this, &Preferences::customProxyToggled );
this, SLOT( customProxyToggled( bool ) ) );
ui.checkForNewReleases->setChecked( p.checkForNewReleases ); ui.checkForNewReleases->setChecked( p.checkForNewReleases );
ui.disallowContentFromOtherSites->setChecked( p.disallowContentFromOtherSites ); ui.disallowContentFromOtherSites->setChecked( p.disallowContentFromOtherSites );
@ -407,6 +396,7 @@ Config::Preferences Preferences::getPreferences()
p.escKeyHidesMainWindow = ui.escKeyHidesMainWindow->isChecked(); p.escKeyHidesMainWindow = ui.escKeyHidesMainWindow->isChecked();
p.darkMode = ui.darkMode->isChecked(); p.darkMode = ui.darkMode->isChecked();
p.darkReaderMode = ui.darkReaderMode->isChecked();
p.enableMainWindowHotkey = ui.enableMainWindowHotkey->isChecked(); p.enableMainWindowHotkey = ui.enableMainWindowHotkey->isChecked();
p.mainWindowHotkey = ui.mainWindowHotkey->getHotKey(); p.mainWindowHotkey = ui.mainWindowHotkey->getHotKey();
p.enableClipboardHotkey = ui.enableClipboardHotkey->isChecked(); p.enableClipboardHotkey = ui.enableClipboardHotkey->isChecked();
@ -709,8 +699,7 @@ void Preferences::helpRequested()
{ {
helpWindow->setWindowFlags( Qt::Window ); helpWindow->setWindowFlags( Qt::Window );
connect( helpWindow, SIGNAL( needClose() ), connect( helpWindow, &Help::HelpWindow::needClose, this, &Preferences::closeHelp );
this, SLOT( closeHelp() ) );
helpWindow->showHelpFor( "Preferences" ); helpWindow->showHelpFor( "Preferences" );
helpWindow->show(); helpWindow->show();
} }

View file

@ -123,7 +123,7 @@
<item> <item>
<widget class="QLabel" name="label_9"> <widget class="QLabel" name="label_9">
<property name="text"> <property name="text">
<string>Display style:</string> <string>Article Display style:</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -157,8 +157,21 @@
</item> </item>
<item> <item>
<widget class="QCheckBox" name="darkMode"> <widget class="QCheckBox" name="darkMode">
<property name="toolTip">
<string>Turn the UI to dark.</string>
</property>
<property name="text"> <property name="text">
<string>dark mode</string> <string>Dark Mode</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="darkReaderMode">
<property name="toolTip">
<string>Turn the article display style to dark.</string>
</property>
<property name="text">
<string>Dark Reader Mode</string>
</property> </property>
</widget> </widget>
</item> </item>

View file

@ -138,11 +138,9 @@ void ProgramsDictionary::loadIcon() noexcept
RunInstance::RunInstance(): process( this ) RunInstance::RunInstance(): process( this )
{ {
connect( this, SIGNAL(processFinished()), this, connect( this, &RunInstance::processFinished, this, &RunInstance::handleProcessFinished, Qt::QueuedConnection );
SLOT(handleProcessFinished()), Qt::QueuedConnection ); connect( &process, &QProcess::finished, this, &RunInstance::processFinished );
connect( &process, SIGNAL(finished(int)), this, SIGNAL(processFinished())); connect( &process, &QProcess::errorOccurred, this, &RunInstance::processFinished );
connect( &process, SIGNAL(errorOccurred(QProcess::ProcessError)), this,
SIGNAL(processFinished()) );
} }
bool RunInstance::start( Config::Program const & prg, QString const & word, bool RunInstance::start( Config::Program const & prg, QString const & word,
@ -211,8 +209,7 @@ ProgramDataRequest::ProgramDataRequest( QString const & word,
Config::Program const & prg_ ): Config::Program const & prg_ ):
prg( prg_ ) prg( prg_ )
{ {
connect( &instance, SIGNAL(finished(QByteArray,QString)), connect( &instance, &RunInstance::finished, this, &ProgramDataRequest::instanceFinished );
this, SLOT(instanceFinished(QByteArray,QString)) );
QString error; QString error;
if ( !instance.start( prg, word, error ) ) if ( !instance.start( prg, word, error ) )
@ -335,8 +332,7 @@ ProgramWordSearchRequest::ProgramWordSearchRequest( QString const & word,
Config::Program const & prg_ ): Config::Program const & prg_ ):
prg( prg_ ) prg( prg_ )
{ {
connect( &instance, SIGNAL(finished(QByteArray,QString)), connect( &instance, &RunInstance::finished, this, &ProgramWordSearchRequest::instanceFinished );
this, SLOT(instanceFinished(QByteArray,QString)) );
QString error; QString error;
if ( !instance.start( prg, word, error ) ) if ( !instance.start( prg, word, error ) )

View file

@ -108,22 +108,14 @@ ScanPopup::ScanPopup( QWidget * parent,
dictionaryBar.toggleViewAction() dictionaryBar.toggleViewAction()
); );
connect( this, SIGNAL(switchExpandMode() ), connect( this, &ScanPopup::switchExpandMode, definition, &ArticleView::switchExpandOptionalParts );
definition, SLOT( switchExpandOptionalParts() ) ); connect( this, &ScanPopup::setViewExpandMode, definition, &ArticleView::receiveExpandOptionalParts );
connect( this, SIGNAL(setViewExpandMode( bool ) ), connect( definition, &ArticleView::setExpandMode, this, &ScanPopup::setExpandMode );
definition, SLOT( receiveExpandOptionalParts( bool ) ) ); connect( definition, &ArticleView::inspectSignal, this, &ScanPopup::inspectElementWhenPinned );
connect( definition, SIGNAL( setExpandMode( bool ) ), connect( definition, &ArticleView::forceAddWordToHistory, this, &ScanPopup::forceAddWordToHistory );
this, SIGNAL( setExpandMode( bool ) ) ); connect( this, &ScanPopup::closeMenu, definition, &ArticleView::closePopupMenu );
connect( definition, SIGNAL( inspectSignal( QWebEnginePage* ) ), connect( definition, &ArticleView::sendWordToHistory, this, &ScanPopup::sendWordToHistory );
this, SLOT( inspectElementWhenPinned( QWebEnginePage* ) ) ); connect( definition, &ArticleView::typingEvent, this, &ScanPopup::typingEvent );
connect( definition, SIGNAL( forceAddWordToHistory( QString ) ),
this, SIGNAL( forceAddWordToHistory( QString ) ) );
connect( this, SIGNAL( closeMenu() ),
definition, SIGNAL( closePopupMenu() ) );
connect( definition, SIGNAL( sendWordToHistory( QString ) ),
this, SIGNAL( sendWordToHistory( QString ) ) );
connect( definition, SIGNAL( typingEvent( QString const & ) ),
this, SLOT( typingEvent( QString const & ) ) );
wordListDefaultFont = ui.translateBox->wordList()->font(); wordListDefaultFont = ui.translateBox->wordList()->font();
translateLineDefaultFont = ui.translateBox->font(); translateLineDefaultFont = ui.translateBox->font();
@ -135,20 +127,18 @@ ScanPopup::ScanPopup( QWidget * parent,
ui.translateBox->wordList()->setFocusPolicy(Qt::ClickFocus); ui.translateBox->wordList()->setFocusPolicy(Qt::ClickFocus);
ui.translateBox->translateLine()->installEventFilter( this ); ui.translateBox->translateLine()->installEventFilter( this );
connect( ui.translateBox->translateLine(), SIGNAL( textChanged( QString const & ) ), connect( ui.translateBox->translateLine(), &QLineEdit::textChanged, this, &ScanPopup::translateInputChanged );
this, SLOT( translateInputChanged( QString const & ) ) );
connect( ui.translateBox->translateLine(), SIGNAL( returnPressed() ), connect( ui.translateBox->translateLine(), &QLineEdit::returnPressed, this, &ScanPopup::translateInputFinished );
this, SLOT( translateInputFinished() ) );
connect( ui.translateBox->wordList(), SIGNAL( itemClicked( QListWidgetItem * ) ), connect( ui.translateBox->wordList(), &QListWidget::itemClicked, this, &ScanPopup::wordListItemActivated );
this, SLOT( wordListItemActivated( QListWidgetItem * ) ) );
connect( ui.translateBox->wordList(), SIGNAL( itemDoubleClicked ( QListWidgetItem * ) ), connect( ui.translateBox->wordList(),
this, SLOT( wordListItemActivated( QListWidgetItem * ) ) ); SIGNAL( itemDoubleClicked( QListWidgetItem * ) ),
this,
SLOT( wordListItemActivated( QListWidgetItem * ) ) );
connect( ui.translateBox->wordList(), SIGNAL( statusBarMessage( QString const &, int, QPixmap const & ) ), connect( ui.translateBox->wordList(), &WordList::statusBarMessage, this, &ScanPopup::showStatusBarMessage );
this, SLOT( showStatusBarMessage( QString const &, int, QPixmap const & ) ) );
ui.pronounceButton->hide(); ui.pronounceButton->hide();
@ -176,14 +166,11 @@ ScanPopup::ScanPopup( QWidget * parent,
connect( &dictionaryBar, SIGNAL(editGroupRequested()), connect( &dictionaryBar, SIGNAL(editGroupRequested()),
this, SLOT(editGroupRequested()) ); this, SLOT(editGroupRequested()) );
connect( this, SIGNAL( closeMenu() ), connect( this, &ScanPopup::closeMenu, &dictionaryBar, &DictionaryBar::closePopupMenu );
&dictionaryBar, SIGNAL( closePopupMenu() ) ); connect( &dictionaryBar, &DictionaryBar::showDictionaryInfo, this, &ScanPopup::showDictionaryInfo );
connect( &dictionaryBar, SIGNAL( showDictionaryInfo( QString const & ) ), connect( &dictionaryBar, &DictionaryBar::openDictionaryFolder, this, &ScanPopup::openDictionaryFolder );
this, SIGNAL( showDictionaryInfo( QString const & ) ) );
connect( &dictionaryBar, SIGNAL( openDictionaryFolder( QString const & ) ),
this, SIGNAL( openDictionaryFolder( QString const & ) ) );
if ( cfg.popupWindowGeometry.size() ) if( cfg.popupWindowGeometry.size() )
restoreGeometry( cfg.popupWindowGeometry ); restoreGeometry( cfg.popupWindowGeometry );
if ( cfg.popupWindowState.size() ) if ( cfg.popupWindowState.size() )
@ -191,7 +178,7 @@ ScanPopup::ScanPopup( QWidget * parent,
ui.onTopButton->setChecked( cfg.popupWindowAlwaysOnTop ); ui.onTopButton->setChecked( cfg.popupWindowAlwaysOnTop );
ui.onTopButton->setVisible( cfg.pinPopupWindow ); ui.onTopButton->setVisible( cfg.pinPopupWindow );
connect( ui.onTopButton, SIGNAL( clicked( bool ) ), this, SLOT( alwaysOnTopClicked( bool ) ) ); connect( ui.onTopButton, &QAbstractButton::clicked, this, &ScanPopup::alwaysOnTopClicked );
ui.pinButton->setChecked( cfg.pinPopupWindow ); ui.pinButton->setChecked( cfg.pinPopupWindow );
@ -215,8 +202,7 @@ ScanPopup::ScanPopup( QWidget * parent,
#endif #endif
} }
connect( &configEvents, SIGNAL( mutedDictionariesChanged() ), connect( &configEvents, &Config::Events::mutedDictionariesChanged, this, &ScanPopup::mutedDictionariesChanged );
this, SLOT( mutedDictionariesChanged() ) );
definition->focus(); definition->focus();
@ -233,8 +219,7 @@ ScanPopup::ScanPopup( QWidget * parent,
escapeAction.setShortcut( QKeySequence( "Esc" ) ); escapeAction.setShortcut( QKeySequence( "Esc" ) );
addAction( &escapeAction ); addAction( &escapeAction );
connect( &escapeAction, SIGNAL( triggered() ), connect( &escapeAction, &QAction::triggered, this, &ScanPopup::escapePressed );
this, SLOT( escapePressed() ) );
focusTranslateLineAction.setShortcutContext( Qt::WidgetWithChildrenShortcut ); focusTranslateLineAction.setShortcutContext( Qt::WidgetWithChildrenShortcut );
addAction( &focusTranslateLineAction ); addAction( &focusTranslateLineAction );
@ -242,14 +227,13 @@ ScanPopup::ScanPopup( QWidget * parent,
QKeySequence( "Alt+D" ) << QKeySequence( "Alt+D" ) <<
QKeySequence( "Ctrl+L" ) ); QKeySequence( "Ctrl+L" ) );
connect( &focusTranslateLineAction, SIGNAL( triggered() ), connect( &focusTranslateLineAction, &QAction::triggered, this, &ScanPopup::focusTranslateLine );
this, SLOT( focusTranslateLine() ) );
QAction * const focusArticleViewAction = new QAction( this ); QAction * const focusArticleViewAction = new QAction( this );
focusArticleViewAction->setShortcutContext( Qt::WidgetWithChildrenShortcut ); focusArticleViewAction->setShortcutContext( Qt::WidgetWithChildrenShortcut );
focusArticleViewAction->setShortcut( QKeySequence( "Ctrl+N" ) ); focusArticleViewAction->setShortcut( QKeySequence( "Ctrl+N" ) );
addAction( focusArticleViewAction ); addAction( focusArticleViewAction );
connect( focusArticleViewAction, SIGNAL( triggered() ), definition, SLOT( focus() ) ); connect( focusArticleViewAction, &QAction::triggered, definition, &ArticleView::focus );
switchExpandModeAction.setShortcuts( QList< QKeySequence >() << switchExpandModeAction.setShortcuts( QList< QKeySequence >() <<
QKeySequence( Qt::CTRL | Qt::Key_8 ) << QKeySequence( Qt::CTRL | Qt::Key_8 ) <<
@ -257,42 +241,36 @@ ScanPopup::ScanPopup( QWidget * parent,
QKeySequence( Qt::CTRL | Qt::SHIFT | Qt::Key_8 ) ); QKeySequence( Qt::CTRL | Qt::SHIFT | Qt::Key_8 ) );
addAction( &switchExpandModeAction ); addAction( &switchExpandModeAction );
connect( &switchExpandModeAction, SIGNAL( triggered() ), connect( &switchExpandModeAction, &QAction::triggered, this, &ScanPopup::switchExpandOptionalPartsMode );
this, SLOT(switchExpandOptionalPartsMode() ) );
connect( ui.groupList, &QComboBox::currentIndexChanged, connect( ui.groupList, &QComboBox::currentIndexChanged,
this, &ScanPopup::currentGroupChanged); this, &ScanPopup::currentGroupChanged);
connect( &wordFinder, SIGNAL( finished() ), connect( &wordFinder, &WordFinder::finished, this, &ScanPopup::prefixMatchFinished );
this, SLOT( prefixMatchFinished() ) );
connect( ui.pinButton, SIGNAL( clicked( bool ) ), connect( ui.pinButton, &QAbstractButton::clicked, this, &ScanPopup::pinButtonClicked );
this, SLOT( pinButtonClicked( bool ) ) );
connect( definition, SIGNAL( pageLoaded( ArticleView * ) ), connect( definition, &ArticleView::pageLoaded, this, &ScanPopup::pageLoaded );
this, SLOT( pageLoaded( ArticleView * ) ) );
connect( definition, SIGNAL( statusBarMessage( QString const &, int, QPixmap const & ) ), connect( definition, &ArticleView::statusBarMessage, this, &ScanPopup::showStatusBarMessage );
this, SLOT( showStatusBarMessage( QString const &, int, QPixmap const & ) ) );
connect( definition, SIGNAL( titleChanged( ArticleView *, QString const & ) ), connect( definition, &ArticleView::titleChanged, this, &ScanPopup::titleChanged );
this, SLOT( titleChanged( ArticleView *, QString const & ) ) );
#ifdef Q_OS_MAC #ifdef Q_OS_MAC
connect( &MouseOver::instance(), SIGNAL( hovered( QString const &, bool ) ), connect( &MouseOver::instance(),
this, SLOT( mouseHovered( QString const &, bool ) ) ); SIGNAL( hovered( QString const &, bool ) ),
this,
SLOT( mouseHovered( QString const &, bool ) ) );
#endif #endif
hideTimer.setSingleShot( true ); hideTimer.setSingleShot( true );
hideTimer.setInterval( 400 ); hideTimer.setInterval( 400 );
connect( &hideTimer, SIGNAL( timeout() ), connect( &hideTimer, &QTimer::timeout, this, &ScanPopup::hideTimerExpired );
this, SLOT( hideTimerExpired() ) );
mouseGrabPollTimer.setSingleShot( false ); mouseGrabPollTimer.setSingleShot( false );
mouseGrabPollTimer.setInterval( 10 ); mouseGrabPollTimer.setInterval( 10 );
connect( &mouseGrabPollTimer, SIGNAL( timeout() ), connect( &mouseGrabPollTimer, &QTimer::timeout, this, &ScanPopup::mouseGrabPoll );
this, SLOT(mouseGrabPoll()) );
#ifdef Q_OS_MAC #ifdef Q_OS_MAC
MouseOver::instance().setPreferencesPtr( &( cfg.preferences ) ); MouseOver::instance().setPreferencesPtr( &( cfg.preferences ) );
#endif #endif
@ -313,8 +291,7 @@ ScanPopup::ScanPopup( QWidget * parent,
delayTimer.setSingleShot( true ); delayTimer.setSingleShot( true );
delayTimer.setInterval( 200 ); delayTimer.setInterval( 200 );
connect( &delayTimer, SIGNAL( timeout() ), connect( &delayTimer, &QTimer::timeout, this, &ScanPopup::delayShow );
this, SLOT( delayShow() ) );
#endif #endif
applyZoomFactor(); applyZoomFactor();
@ -823,7 +800,7 @@ bool ScanPopup::eventFilter( QObject * watched, QEvent * event )
// select all on mouse click // select all on mouse click
if ( focusEvent->reason() == Qt::MouseFocusReason ) { if ( focusEvent->reason() == Qt::MouseFocusReason ) {
QTimer::singleShot(0, this, SLOT(focusTranslateLine())); QTimer::singleShot( 0, this, &ScanPopup::focusTranslateLine );
} }
return false; return false;
} }
@ -988,7 +965,7 @@ void ScanPopup::showEvent( QShowEvent * ev )
{ {
QMainWindow::showEvent( ev ); QMainWindow::showEvent( ev );
QTimer::singleShot(100, this, SLOT( requestWindowFocus() ) ); QTimer::singleShot( 100, this, &ScanPopup::requestWindowFocus );
if ( groups.size() <= 1 ) // Only the default group? Hide then. if ( groups.size() <= 1 ) // Only the default group? Hide then.
ui.groupList->hide(); ui.groupList->hide();

View file

@ -1,4 +1,4 @@
sonar.projectKey=goldendict sonar.projectKey=xiaoyifang_goldendict
sonar.organization=xiaoyifang sonar.organization=xiaoyifang
# This is the name and version displayed in the SonarCloud UI. # This is the name and version displayed in the SonarCloud UI.

View file

@ -17,7 +17,7 @@
<item> <item>
<widget class="QTabWidget" name="tabWidget"> <widget class="QTabWidget" name="tabWidget">
<property name="currentIndex"> <property name="currentIndex">
<number>7</number> <number>0</number>
</property> </property>
<property name="iconSize"> <property name="iconSize">
<size> <size>

View file

@ -30,15 +30,11 @@ namespace {
{ {
/* map of iso lang code to wikipedia lang id /* map of iso lang code to wikipedia lang id
Data was obtained by this query on https://commons-query.wikimedia.org/ Data was obtained by this query on https://commons-query.wikimedia.org/
SELECT ?language ?languageLabel ?iso ?audios
SELECT ?language ?languageLabel ?iso ?audios WHERE {
WHERE {
{ {
SELECT ?language (COUNT(?audio) AS ?audios) WHERE { SELECT ?language (COUNT(?audio) AS ?audios) WHERE {
# Comment out the below statement to filter to only certain languages (e.g. Q34 or others)
# VALUES ?language { entity:Q34 }
?audio # Filter: P2 'instance of' is Q2 'record' ?audio # Filter: P2 'instance of' is Q2 'record'
wdt:P407 ?language . wdt:P407 ?language .
} }
@ -56,7 +52,8 @@ namespace {
?language rdfs:label ?languageLabel . ?language rdfs:label ?languageLabel .
} }
} }
} }
*/ */
const map< string, string > iso_to_wikipedia_id = { { "grc", "Q35497" }, const map< string, string > iso_to_wikipedia_id = { { "grc", "Q35497" },
@ -313,13 +310,12 @@ namespace {
sptr< DataRequest > getArticle( sptr< DataRequest > getArticle(
wstring const & word, vector< wstring > const & alts, wstring const &, bool ) override wstring const & word, vector< wstring > const & alts, wstring const &, bool ) override
{ {
if( word.size() > 50 ) if( word.size() < 50 )
{
return std::make_shared< DataRequestInstant >( false );
}
else
{ {
return std::make_shared< LinguaArticleRequest >( word, alts, languageCode,langWikipediaID, getId(), netMgr ); return std::make_shared< LinguaArticleRequest >( word, alts, languageCode,langWikipediaID, getId(), netMgr );
} else {
return std::make_shared< DataRequestInstant >( false );
} }
} }
@ -334,7 +330,7 @@ namespace {
} }
}; };
} } // namespace
vector< sptr< Dictionary::Class > > makeDictionaries( vector< sptr< Dictionary::Class > > makeDictionaries(
Dictionary::Initializing &, Config::Lingua const & lingua, QNetworkAccessManager & mgr ) Dictionary::Initializing &, Config::Lingua const & lingua, QNetworkAccessManager & mgr )
@ -383,18 +379,20 @@ void LinguaArticleRequest::addQuery( QNetworkAccessManager & mgr, const wstring
R"(&iiprop=url)" R"(&iiprop=url)"
R"(&iimetadataversion=1)" R"(&iimetadataversion=1)"
R"(&iiextmetadatafilter=Categories)" R"(&iiextmetadatafilter=Categories)"
R"(&gsrsearch=intitle:LL-%1 \(%2\)-.*-%3\.wav/)" R"(&gsrsearch=intitle:LL-%1 \(%2\)-.*-%3\.wav/)" // https://en.wikipedia.org/wiki/Help:Searching/Regex
R"(&gsrnamespace=6)" R"(&gsrnamespace=6)"
R"(&gsrlimit=10)" R"(&gsrlimit=10)"
R"(&gsrwhat=text)"; R"(&gsrwhat=text)";
reqUrl = reqUrl.arg(languageCode,langWikipediaID,QString::fromStdU32String( word ) ); reqUrl = reqUrl.arg(langWikipediaID,languageCode,QString::fromStdU32String( word ) );
qDebug()<< "lingualibre query " << reqUrl; qDebug()<< "lingualibre query " << reqUrl;
auto netRequest = QNetworkRequest( reqUrl );
netRequest.setTransferTimeout(3000);
auto netReply = auto netReply =
std::shared_ptr< QNetworkReply >( mgr.get( std::shared_ptr< QNetworkReply >( mgr.get(netRequest));
QNetworkRequest( reqUrl ) ) );
netReplies.emplace_back( netReply, Utf8::encode( word ) ); netReplies.emplace_back( netReply, Utf8::encode( word ) );
@ -404,10 +402,17 @@ void LinguaArticleRequest::addQuery( QNetworkAccessManager & mgr, const wstring
void LinguaArticleRequest::requestFinished( QNetworkReply * r ) void LinguaArticleRequest::requestFinished( QNetworkReply * r )
{ {
qDebug() << "Lingua query finished"; qDebug() << "Lingua query finished ";
sptr< QNetworkReply > netReply = netReplies.front().reply; sptr< QNetworkReply > netReply = netReplies.front().reply;
if( isFinished() || // Was cancelled
!netReply->isFinished() ||
netReply->error() != QNetworkReply::NoError ){
qWarning()<< "Lingua query failed: " << netReply->error();
return;
}
QJsonObject resultJson = QJsonDocument::fromJson( netReply->readAll() ).object(); QJsonObject resultJson = QJsonDocument::fromJson( netReply->readAll() ).object();
/* /*
@ -488,6 +493,7 @@ void LinguaArticleRequest::requestFinished( QNetworkReply * r )
else else
{ {
hasAnyData = false; hasAnyData = false;
finish();
} }
} }

View file

@ -128,7 +128,7 @@ bool QtLocalPeer::isClient()
#endif #endif
if (!res) if (!res)
qWarning("QtSingleCoreApplication: listen on local socket failed, %s", qPrintable(server->errorString())); qWarning("QtSingleCoreApplication: listen on local socket failed, %s", qPrintable(server->errorString()));
QObject::connect(server, SIGNAL(newConnection()), SLOT(receiveConnection())); QObject::connect( server, &QLocalServer::newConnection, this, &QtLocalPeer::receiveConnection );
return false; return false;
} }

View file

@ -137,7 +137,7 @@ void QtSingleApplication::sysInit(const QString &appId)
{ {
actWin = 0; actWin = 0;
peer = new QtLocalPeer(this, appId); peer = new QtLocalPeer(this, appId);
connect(peer, SIGNAL(messageReceived(const QString&)), SIGNAL(messageReceived(const QString&))); connect( peer, &QtLocalPeer::messageReceived, this, &QtSingleApplication::messageReceived );
} }
@ -232,9 +232,9 @@ void QtSingleApplication::setActivationWindow(QWidget* aw, bool activateOnMessag
{ {
actWin = aw; actWin = aw;
if (activateOnMessage) if (activateOnMessage)
connect(peer, SIGNAL(messageReceived(const QString&)), this, SLOT(activateWindow())); connect( peer, &QtLocalPeer::messageReceived, this, &QtSingleApplication::activateWindow );
else else
disconnect(peer, SIGNAL(messageReceived(const QString&)), this, SLOT(activateWindow())); disconnect( peer, &QtLocalPeer::messageReceived, this, &QtSingleApplication::activateWindow );
} }

View file

@ -74,7 +74,7 @@ QtSingleCoreApplication::QtSingleCoreApplication(int &argc, char **argv)
: QCoreApplication(argc, argv) : QCoreApplication(argc, argv)
{ {
peer = new QtLocalPeer(this); peer = new QtLocalPeer(this);
connect(peer, SIGNAL(messageReceived(const QString&)), SIGNAL(messageReceived(const QString&))); connect( peer, &QtLocalPeer::messageReceived, this, &QtSingleCoreApplication::messageReceived );
} }
@ -87,7 +87,7 @@ QtSingleCoreApplication::QtSingleCoreApplication(const QString &appId, int &argc
: QCoreApplication(argc, argv) : QCoreApplication(argc, argv)
{ {
peer = new QtLocalPeer(this, appId); peer = new QtLocalPeer(this, appId);
connect(peer, SIGNAL(messageReceived(const QString&)), SIGNAL(messageReceived(const QString&))); connect( peer, &QtLocalPeer::messageReceived, this, &QtSingleCoreApplication::messageReceived );
} }

View file

@ -27,11 +27,9 @@ CompletionList::CompletionList(TranslateBox * parent) : WordList(parent),
setAutoFillBackground( true ); setAutoFillBackground( true );
#endif #endif
connect(this, SIGNAL( activated( QModelIndex ) ), connect( this, &QAbstractItemView::activated, this, &CompletionList::acceptCurrentEntry );
this, SLOT( acceptCurrentEntry() ) );
connect(this, SIGNAL( itemClicked( QListWidgetItem * ) ), connect( this, &QListWidget::itemClicked, this, &CompletionList::acceptCurrentEntry );
this, SLOT( acceptCurrentEntry() ) );
translateBox->window()->installEventFilter(this); translateBox->window()->installEventFilter(this);
} }
@ -134,14 +132,11 @@ TranslateBox::TranslateBox(QWidget *parent) : QWidget(parent),
translate_line->installEventFilter( this ); translate_line->installEventFilter( this );
this->installEventFilter( this ); this->installEventFilter( this );
connect(translate_line, SIGNAL( textChanged( QString const & ) ), connect( translate_line, &QLineEdit::textChanged, this, &TranslateBox::onTextEdit );
this, SLOT( onTextEdit() ) );
connect(translate_line, SIGNAL( rightButtonClicked() ), connect( translate_line, &ExtLineEdit::rightButtonClicked, this, &TranslateBox::rightButtonClicked );
this, SLOT( rightButtonClicked() ) );
connect(word_list, SIGNAL( contentChanged() ), connect( word_list, &WordList::contentChanged, this, &TranslateBox::showPopup );
this, SLOT( showPopup() ) );
} }
bool TranslateBox::eventFilter(QObject *obj, QEvent *event) bool TranslateBox::eventFilter(QObject *obj, QEvent *event)

View file

@ -10,8 +10,7 @@ WebMultimediaDownload::WebMultimediaDownload( QUrl const & url,
mgr( _mgr ), mgr( _mgr ),
redirectCount( 0 ) redirectCount( 0 )
{ {
connect( &mgr, SIGNAL(finished(QNetworkReply*)), connect( &mgr, &QNetworkAccessManager::finished, this, &WebMultimediaDownload::replyFinished, Qt::QueuedConnection );
this, SLOT(replyFinished(QNetworkReply*)), Qt::QueuedConnection );
reply = mgr.get( QNetworkRequest( url ) ); reply = mgr.get( QNetworkRequest( url ) );

View file

@ -23,8 +23,7 @@ WordFinder::WordFinder( QObject * parent ):
updateResultsTimer.setInterval( 1000 ); // We use a one second update timer updateResultsTimer.setInterval( 1000 ); // We use a one second update timer
updateResultsTimer.setSingleShot( true ); updateResultsTimer.setSingleShot( true );
connect( &updateResultsTimer, SIGNAL( timeout() ), connect( &updateResultsTimer, &QTimer::timeout, this, &WordFinder::updateResults, Qt::QueuedConnection );
this, SLOT( updateResults() ), Qt::QueuedConnection );
} }
WordFinder::~WordFinder() WordFinder::~WordFinder()
@ -156,8 +155,7 @@ void WordFinder::startSearch()
(*inputDicts)[ x ]->prefixMatch( allWordWritings[ y ], requestedMaxResults ) : (*inputDicts)[ x ]->prefixMatch( allWordWritings[ y ], requestedMaxResults ) :
(*inputDicts)[ x ]->stemmedMatch( allWordWritings[ y ], stemmedMinLength, stemmedMaxSuffixVariation, requestedMaxResults ); (*inputDicts)[ x ]->stemmedMatch( allWordWritings[ y ], stemmedMinLength, stemmedMaxSuffixVariation, requestedMaxResults );
connect( sr.get(), SIGNAL( finished() ), connect( sr.get(), &Dictionary::Request::finished, this, &WordFinder::requestFinished, Qt::QueuedConnection );
this, SLOT( requestFinished() ), Qt::QueuedConnection );
queuedRequests.push_back( sr ); queuedRequests.push_back( sr );
} }

View file

@ -22,18 +22,14 @@ void WordList::attachFinder( WordFinder * finder )
if ( wordFinder ) if ( wordFinder )
{ {
disconnect( wordFinder, SIGNAL( updated() ), disconnect( wordFinder, &WordFinder::updated, this, &WordList::prefixMatchUpdated );
this, SLOT( prefixMatchUpdated() ) ); disconnect( wordFinder, &WordFinder::finished, this, &WordList::prefixMatchFinished );
disconnect( wordFinder, SIGNAL( finished() ),
this, SLOT( prefixMatchFinished() ) );
} }
wordFinder = finder; wordFinder = finder;
connect( wordFinder, SIGNAL( updated() ), connect( wordFinder, &WordFinder::updated, this, &WordList::prefixMatchUpdated );
this, SLOT( prefixMatchUpdated() ) ); connect( wordFinder, &WordFinder::finished, this, &WordList::prefixMatchFinished );
connect( wordFinder, SIGNAL( finished() ),
this, SLOT( prefixMatchFinished() ) );
} }
void WordList::prefixMatchUpdated() void WordList::prefixMatchUpdated()