From 9ee6f030fcc6068b7c804f3ec7549d67f0f1f405 Mon Sep 17 00:00:00 2001 From: YiFang Xiao Date: Tue, 24 Dec 2024 11:30:16 +0800 Subject: [PATCH 01/14] opt: add a new toolbar for hitted dictionaries --- src/ui/scanpopup.cc | 47 ++++++++++++++++++++++++++++++++++++++++++++- src/ui/scanpopup.hh | 2 ++ 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/src/ui/scanpopup.cc b/src/ui/scanpopup.cc index bcb955920..8dff37bf6 100644 --- a/src/ui/scanpopup.cc +++ b/src/ui/scanpopup.cc @@ -77,6 +77,7 @@ ScanPopup::ScanPopup( QWidget * parent, hideTimer( this ) { ui.setupUi( this ); + toolBar = new QToolBar("Dictionaries Toolbar" this ); if ( layoutDirection() == Qt::RightToLeft ) { // Adjust button icons for Right-To-Left layout @@ -104,6 +105,7 @@ ScanPopup::ScanPopup( QWidget * parent, connect( this, &ScanPopup::closeMenu, definition, &ArticleView::closePopupMenu ); connect( definition, &ArticleView::sendWordToHistory, this, &ScanPopup::sendWordToHistory ); connect( definition, &ArticleView::typingEvent, this, &ScanPopup::typingEvent ); + connect( definition, &ArticleView::updateFoundInDictsList, this, &ScanPopup::updateFoundInDictsList ); openSearchAction.setShortcut( QKeySequence( "Ctrl+F" ) ); openSearchAction.setShortcutContext( Qt::WidgetWithChildrenShortcut ); @@ -148,7 +150,8 @@ ScanPopup::ScanPopup( QWidget * parent, dictionaryBar.setMutedDictionaries( grp ? &grp->popupMutedDictionaries : nullptr ); } - addToolBar( Qt::RightToolBarArea, &dictionaryBar ); + addToolBar( Qt::TopToolBarArea, &dictionaryBar ); + addToolBar( Qt::RightToolBarArea, toolBar ); connect( &dictionaryBar, &DictionaryBar::editGroupRequested, this, &ScanPopup::editGroupRequested ); connect( this, &ScanPopup::closeMenu, &dictionaryBar, &DictionaryBar::closePopupMenu ); @@ -289,6 +292,48 @@ ScanPopup::ScanPopup( QWidget * parent, applyWordsZoomLevel(); } +void ScanPopup::updateFoundInDictsList() +{ + if ( !toolbar->isVisible() ) { + // nothing to do, the list is not visible + return; + } + toolbar->setUpdatesEnabled( false ); + + unsigned currentId = ui.groupList->getCurrentGroup(); + Instances::Group const * grp = groups.findGroup( currentId ); + + auto dictionaries = !grp ? grp->dictionaries : allDictionaries; + QStringList ids = definition->getArticlesList(); + QString activeId = definition->getActiveArticleId(); + + for ( QStringList::const_iterator i = ids.constBegin(); i != ids.constEnd(); ++i ) { + // Find this dictionary + + for ( unsigned x = dictionaries.size(); x--; ) { + if ( dictionaries[ x ]->getId() == i->toUtf8().data() ) { + + auto dictionary = dictionaries[ x ]; + QIcon icon = dictionary->getIcon(); + QString dictName = QString::fromUtf8( dictionary->getName().c_str() ); + QAction * action = addAction( icon, elideDictName( dictName ) ); + action->setToolTip( dictName ); // Tooltip need not be shortened + QString id = QString::fromStdString( dictionary->getId() ); + action->setData( id ); + + if ( id == activeId ) { + action->setChecked( true ); + } + toolbar->addAction( action ); + + break; + } + } + } + + toolbar->setUpdatesEnabled( true ); +} + void ScanPopup::refresh() { // currentIndexChanged() signal is very trigger-happy. To avoid triggering diff --git a/src/ui/scanpopup.hh b/src/ui/scanpopup.hh index 8d2f9c372..393642c01 100644 --- a/src/ui/scanpopup.hh +++ b/src/ui/scanpopup.hh @@ -136,6 +136,7 @@ private: WordFinder wordFinder; Config::Events configEvents; DictionaryBar dictionaryBar; + QToolBar * toolBar; MainStatusBar * mainStatusBar; /// Fonts saved before words zooming is in effect, so it could be reset back. QFont wordListDefaultFont, translateLineDefaultFont, groupListDefaultFont; @@ -227,4 +228,5 @@ private slots: void alwaysOnTopClicked( bool checked ); void titleChanged( ArticleView *, QString const & title ) const; + void updateFoundInDictsList(); }; From c0fc63afa8984dac7971011dbd199e3c050688c6 Mon Sep 17 00:00:00 2001 From: YiFang Xiao Date: Tue, 24 Dec 2024 11:36:05 +0800 Subject: [PATCH 02/14] opt: exclusive in toolbar --- src/ui/scanpopup.cc | 9 +++++---- src/ui/scanpopup.hh | 5 ++++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/ui/scanpopup.cc b/src/ui/scanpopup.cc index 8dff37bf6..6032adcd0 100644 --- a/src/ui/scanpopup.cc +++ b/src/ui/scanpopup.cc @@ -77,8 +77,9 @@ ScanPopup::ScanPopup( QWidget * parent, hideTimer( this ) { ui.setupUi( this ); - toolBar = new QToolBar("Dictionaries Toolbar" this ); - + toolbar = new QToolBar("Dictionaries Toolbar" this ); + actionGroup = new QActionGroup(this); + actionGroup->setExclusive(true); if ( layoutDirection() == Qt::RightToLeft ) { // Adjust button icons for Right-To-Left layout ui.goBackButton->setIcon( QIcon( ":/icons/next.svg" ) ); @@ -151,7 +152,7 @@ ScanPopup::ScanPopup( QWidget * parent, } addToolBar( Qt::TopToolBarArea, &dictionaryBar ); - addToolBar( Qt::RightToolBarArea, toolBar ); + addToolBar( Qt::RightToolBarArea, toolbar ); connect( &dictionaryBar, &DictionaryBar::editGroupRequested, this, &ScanPopup::editGroupRequested ); connect( this, &ScanPopup::closeMenu, &dictionaryBar, &DictionaryBar::closePopupMenu ); @@ -325,7 +326,7 @@ void ScanPopup::updateFoundInDictsList() action->setChecked( true ); } toolbar->addAction( action ); - + actionGroup->addAction( action ); break; } } diff --git a/src/ui/scanpopup.hh b/src/ui/scanpopup.hh index 393642c01..62000fae5 100644 --- a/src/ui/scanpopup.hh +++ b/src/ui/scanpopup.hh @@ -11,6 +11,8 @@ #include "ui_scanpopup.h" #include #include +#include +#include #include "history.hh" #include "dictionarybar.hh" #include "mainstatusbar.hh" @@ -136,7 +138,8 @@ private: WordFinder wordFinder; Config::Events configEvents; DictionaryBar dictionaryBar; - QToolBar * toolBar; + QToolBar * toolbar; + QActionGroup *actionGroup; MainStatusBar * mainStatusBar; /// Fonts saved before words zooming is in effect, so it could be reset back. QFont wordListDefaultFont, translateLineDefaultFont, groupListDefaultFont; From 3b2c5468373ea9aa2bca773ae373a57ccbe585f9 Mon Sep 17 00:00:00 2001 From: YiFang Xiao Date: Tue, 24 Dec 2024 11:41:36 +0800 Subject: [PATCH 03/14] opt: jump to article --- src/ui/scanpopup.cc | 10 ++++++++++ src/ui/scanpopup.hh | 1 + 2 files changed, 11 insertions(+) diff --git a/src/ui/scanpopup.cc b/src/ui/scanpopup.cc index 6032adcd0..85fb2f261 100644 --- a/src/ui/scanpopup.cc +++ b/src/ui/scanpopup.cc @@ -293,6 +293,15 @@ ScanPopup::ScanPopup( QWidget * parent, applyWordsZoomLevel(); } +void ScanPopup::onActionTriggered() { + QAction *action = qobject_cast(sender()); + if (action) { + auto dictId = action->data().toString(); + qDebug() << "Action triggered:" << dictId; + definition->jumpToDictionary(dictId); + } +} + void ScanPopup::updateFoundInDictsList() { if ( !toolbar->isVisible() ) { @@ -325,6 +334,7 @@ void ScanPopup::updateFoundInDictsList() if ( id == activeId ) { action->setChecked( true ); } + connect(action, &QAction::triggered, this, &ScanPopup::onActionTriggered); toolbar->addAction( action ); actionGroup->addAction( action ); break; diff --git a/src/ui/scanpopup.hh b/src/ui/scanpopup.hh index 62000fae5..8fd80b89a 100644 --- a/src/ui/scanpopup.hh +++ b/src/ui/scanpopup.hh @@ -232,4 +232,5 @@ private slots: void titleChanged( ArticleView *, QString const & title ) const; void updateFoundInDictsList(); + void onActionTriggered(); }; From 7456e57992ccafd36d3dadc234da8973388bb7dd Mon Sep 17 00:00:00 2001 From: YiFang Xiao Date: Thu, 26 Dec 2024 07:23:40 +0800 Subject: [PATCH 04/14] opt: scan popup dictionary bar --- src/ui/scanpopup.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ui/scanpopup.cc b/src/ui/scanpopup.cc index 85fb2f261..0e52cf65d 100644 --- a/src/ui/scanpopup.cc +++ b/src/ui/scanpopup.cc @@ -77,7 +77,7 @@ ScanPopup::ScanPopup( QWidget * parent, hideTimer( this ) { ui.setupUi( this ); - toolbar = new QToolBar("Dictionaries Toolbar" this ); + toolbar = new QToolBar("Dictionaries Toolbar", this ); actionGroup = new QActionGroup(this); actionGroup->setExclusive(true); if ( layoutDirection() == Qt::RightToLeft ) { @@ -298,7 +298,7 @@ void ScanPopup::onActionTriggered() { if (action) { auto dictId = action->data().toString(); qDebug() << "Action triggered:" << dictId; - definition->jumpToDictionary(dictId); + definition->jumpToDictionary(dictId,false); } } @@ -326,7 +326,7 @@ void ScanPopup::updateFoundInDictsList() auto dictionary = dictionaries[ x ]; QIcon icon = dictionary->getIcon(); QString dictName = QString::fromUtf8( dictionary->getName().c_str() ); - QAction * action = addAction( icon, elideDictName( dictName ) ); + QAction * action = addAction( icon, dictName ); action->setToolTip( dictName ); // Tooltip need not be shortened QString id = QString::fromStdString( dictionary->getId() ); action->setData( id ); From e099fb5786c054c6aaf86c180b13f9b1bbd91197 Mon Sep 17 00:00:00 2001 From: YiFang Xiao Date: Thu, 26 Dec 2024 07:24:41 +0800 Subject: [PATCH 05/14] opt: scan popup dictionary bar --- src/ui/scanpopup.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/ui/scanpopup.cc b/src/ui/scanpopup.cc index 0e52cf65d..b2df99190 100644 --- a/src/ui/scanpopup.cc +++ b/src/ui/scanpopup.cc @@ -316,7 +316,8 @@ void ScanPopup::updateFoundInDictsList() auto dictionaries = !grp ? grp->dictionaries : allDictionaries; QStringList ids = definition->getArticlesList(); QString activeId = definition->getActiveArticleId(); - + toolbar->clear(); + actionGroup->clear(); for ( QStringList::const_iterator i = ids.constBegin(); i != ids.constEnd(); ++i ) { // Find this dictionary From a998f6a3265845d2917fab4a0ff036a08884ebf6 Mon Sep 17 00:00:00 2001 From: YiFang Xiao Date: Thu, 26 Dec 2024 07:27:26 +0800 Subject: [PATCH 06/14] opt: scan popup dictionary bar --- src/ui/scanpopup.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ui/scanpopup.cc b/src/ui/scanpopup.cc index b2df99190..a4637d1e2 100644 --- a/src/ui/scanpopup.cc +++ b/src/ui/scanpopup.cc @@ -317,7 +317,7 @@ void ScanPopup::updateFoundInDictsList() QStringList ids = definition->getArticlesList(); QString activeId = definition->getActiveArticleId(); toolbar->clear(); - actionGroup->clear(); + // actionGroup->removeAllActions(); for ( QStringList::const_iterator i = ids.constBegin(); i != ids.constEnd(); ++i ) { // Find this dictionary From b969566b632d33cbe7b77e92c752ec989ba5e134 Mon Sep 17 00:00:00 2001 From: YiFang Xiao Date: Thu, 26 Dec 2024 08:49:56 +0800 Subject: [PATCH 07/14] 1 --- src/ui/scanpopup.cc | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/ui/scanpopup.cc b/src/ui/scanpopup.cc index a4637d1e2..2cee1862b 100644 --- a/src/ui/scanpopup.cc +++ b/src/ui/scanpopup.cc @@ -317,7 +317,10 @@ void ScanPopup::updateFoundInDictsList() QStringList ids = definition->getArticlesList(); QString activeId = definition->getActiveArticleId(); toolbar->clear(); - // actionGroup->removeAllActions(); + if( actionGroup ){ + delete actionGroup; + } + actionGroup = new ActionGroup( this ); for ( QStringList::const_iterator i = ids.constBegin(); i != ids.constEnd(); ++i ) { // Find this dictionary @@ -327,11 +330,11 @@ void ScanPopup::updateFoundInDictsList() auto dictionary = dictionaries[ x ]; QIcon icon = dictionary->getIcon(); QString dictName = QString::fromUtf8( dictionary->getName().c_str() ); - QAction * action = addAction( icon, dictName ); - action->setToolTip( dictName ); // Tooltip need not be shortened + QAction * action = new QAction( dictName,this ); + action->setIcon( icon ); QString id = QString::fromStdString( dictionary->getId() ); action->setData( id ); - + action->setCheckable(true); if ( id == activeId ) { action->setChecked( true ); } From 77ba0008de66487a4a10424af5144cdc733ce16c Mon Sep 17 00:00:00 2001 From: YiFang Xiao Date: Thu, 26 Dec 2024 08:55:09 +0800 Subject: [PATCH 08/14] 1 --- src/ui/scanpopup.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ui/scanpopup.cc b/src/ui/scanpopup.cc index 2cee1862b..4a9371c46 100644 --- a/src/ui/scanpopup.cc +++ b/src/ui/scanpopup.cc @@ -78,8 +78,7 @@ ScanPopup::ScanPopup( QWidget * parent, { ui.setupUi( this ); toolbar = new QToolBar("Dictionaries Toolbar", this ); - actionGroup = new QActionGroup(this); - actionGroup->setExclusive(true); + if ( layoutDirection() == Qt::RightToLeft ) { // Adjust button icons for Right-To-Left layout ui.goBackButton->setIcon( QIcon( ":/icons/next.svg" ) ); @@ -320,7 +319,8 @@ void ScanPopup::updateFoundInDictsList() if( actionGroup ){ delete actionGroup; } - actionGroup = new ActionGroup( this ); + actionGroup = new QActionGroup( this ); + actionGroup->setExclusive(true); for ( QStringList::const_iterator i = ids.constBegin(); i != ids.constEnd(); ++i ) { // Find this dictionary From 96883225501789cd25d5570008ddf058d66721d1 Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Mon, 30 Dec 2024 05:59:20 +0000 Subject: [PATCH 09/14] [autofix.ci] apply automated fixes --- src/ui/scanpopup.cc | 31 ++++++++++++++++--------------- src/ui/scanpopup.hh | 2 +- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/ui/scanpopup.cc b/src/ui/scanpopup.cc index 4a9371c46..844494d86 100644 --- a/src/ui/scanpopup.cc +++ b/src/ui/scanpopup.cc @@ -77,7 +77,7 @@ ScanPopup::ScanPopup( QWidget * parent, hideTimer( this ) { ui.setupUi( this ); - toolbar = new QToolBar("Dictionaries Toolbar", this ); + toolbar = new QToolBar( "Dictionaries Toolbar", this ); if ( layoutDirection() == Qt::RightToLeft ) { // Adjust button icons for Right-To-Left layout @@ -292,13 +292,14 @@ ScanPopup::ScanPopup( QWidget * parent, applyWordsZoomLevel(); } -void ScanPopup::onActionTriggered() { - QAction *action = qobject_cast(sender()); - if (action) { - auto dictId = action->data().toString(); - qDebug() << "Action triggered:" << dictId; - definition->jumpToDictionary(dictId,false); - } +void ScanPopup::onActionTriggered() +{ + QAction * action = qobject_cast< QAction * >( sender() ); + if ( action ) { + auto dictId = action->data().toString(); + qDebug() << "Action triggered:" << dictId; + definition->jumpToDictionary( dictId, false ); + } } void ScanPopup::updateFoundInDictsList() @@ -316,29 +317,29 @@ void ScanPopup::updateFoundInDictsList() QStringList ids = definition->getArticlesList(); QString activeId = definition->getActiveArticleId(); toolbar->clear(); - if( actionGroup ){ + if ( actionGroup ) { delete actionGroup; } actionGroup = new QActionGroup( this ); - actionGroup->setExclusive(true); + actionGroup->setExclusive( true ); for ( QStringList::const_iterator i = ids.constBegin(); i != ids.constEnd(); ++i ) { // Find this dictionary for ( unsigned x = dictionaries.size(); x--; ) { if ( dictionaries[ x ]->getId() == i->toUtf8().data() ) { - auto dictionary = dictionaries[ x ]; - QIcon icon = dictionary->getIcon(); + auto dictionary = dictionaries[ x ]; + QIcon icon = dictionary->getIcon(); QString dictName = QString::fromUtf8( dictionary->getName().c_str() ); - QAction * action = new QAction( dictName,this ); + QAction * action = new QAction( dictName, this ); action->setIcon( icon ); QString id = QString::fromStdString( dictionary->getId() ); action->setData( id ); - action->setCheckable(true); + action->setCheckable( true ); if ( id == activeId ) { action->setChecked( true ); } - connect(action, &QAction::triggered, this, &ScanPopup::onActionTriggered); + connect( action, &QAction::triggered, this, &ScanPopup::onActionTriggered ); toolbar->addAction( action ); actionGroup->addAction( action ); break; diff --git a/src/ui/scanpopup.hh b/src/ui/scanpopup.hh index 8fd80b89a..cc0979980 100644 --- a/src/ui/scanpopup.hh +++ b/src/ui/scanpopup.hh @@ -139,7 +139,7 @@ private: Config::Events configEvents; DictionaryBar dictionaryBar; QToolBar * toolbar; - QActionGroup *actionGroup; + QActionGroup * actionGroup; MainStatusBar * mainStatusBar; /// Fonts saved before words zooming is in effect, so it could be reset back. QFont wordListDefaultFont, translateLineDefaultFont, groupListDefaultFont; From e83d6cdfe924d1d85ec51dfa22a349fe67b8fa70 Mon Sep 17 00:00:00 2001 From: YiFang Xiao Date: Mon, 30 Dec 2024 21:33:46 +0800 Subject: [PATCH 10/14] 1 --- src/ui/scanpopup.hh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/ui/scanpopup.hh b/src/ui/scanpopup.hh index cc0979980..e0263a714 100644 --- a/src/ui/scanpopup.hh +++ b/src/ui/scanpopup.hh @@ -12,7 +12,6 @@ #include #include #include -#include #include "history.hh" #include "dictionarybar.hh" #include "mainstatusbar.hh" @@ -20,6 +19,8 @@ #include "scanflag.hh" #endif +#include + /// This is a popup dialog to show translations when clipboard scanning mode /// is enabled. class ScanPopup: public QMainWindow, KeyboardState From 063df3a4093924295f896cd769faee50cf41fa76 Mon Sep 17 00:00:00 2001 From: YiFang Xiao Date: Mon, 30 Dec 2024 22:08:00 +0800 Subject: [PATCH 11/14] 1 --- src/ui/scanpopup.cc | 12 ++++++------ src/ui/scanpopup.hh | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/ui/scanpopup.cc b/src/ui/scanpopup.cc index 844494d86..3bb632531 100644 --- a/src/ui/scanpopup.cc +++ b/src/ui/scanpopup.cc @@ -77,7 +77,7 @@ ScanPopup::ScanPopup( QWidget * parent, hideTimer( this ) { ui.setupUi( this ); - toolbar = new QToolBar( "Dictionaries Toolbar", this ); + toolbar = new QToolBar( "Found Dictionary", this ); if ( layoutDirection() == Qt::RightToLeft ) { // Adjust button icons for Right-To-Left layout @@ -295,10 +295,10 @@ ScanPopup::ScanPopup( QWidget * parent, void ScanPopup::onActionTriggered() { QAction * action = qobject_cast< QAction * >( sender() ); - if ( action ) { + if ( action != nullptr ) { auto dictId = action->data().toString(); qDebug() << "Action triggered:" << dictId; - definition->jumpToDictionary( dictId, false ); + definition->jumpToDictionary( dictId, true ); } } @@ -313,12 +313,12 @@ void ScanPopup::updateFoundInDictsList() unsigned currentId = ui.groupList->getCurrentGroup(); Instances::Group const * grp = groups.findGroup( currentId ); - auto dictionaries = !grp ? grp->dictionaries : allDictionaries; + auto dictionaries = grp ? grp->dictionaries : allDictionaries; QStringList ids = definition->getArticlesList(); QString activeId = definition->getActiveArticleId(); toolbar->clear(); - if ( actionGroup ) { - delete actionGroup; + if ( actionGroup!= nullptr ) { + actionGroup->deleteLater(); } actionGroup = new QActionGroup( this ); actionGroup->setExclusive( true ); diff --git a/src/ui/scanpopup.hh b/src/ui/scanpopup.hh index e0263a714..3a5df8e1b 100644 --- a/src/ui/scanpopup.hh +++ b/src/ui/scanpopup.hh @@ -140,7 +140,7 @@ private: Config::Events configEvents; DictionaryBar dictionaryBar; QToolBar * toolbar; - QActionGroup * actionGroup; + QActionGroup * actionGroup=nullptr; MainStatusBar * mainStatusBar; /// Fonts saved before words zooming is in effect, so it could be reset back. QFont wordListDefaultFont, translateLineDefaultFont, groupListDefaultFont; From 7fd0a0d4f229f337db915fe6f260e9a272d0c035 Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Mon, 30 Dec 2024 14:09:31 +0000 Subject: [PATCH 12/14] [autofix.ci] apply automated fixes --- src/ui/scanpopup.cc | 2 +- src/ui/scanpopup.hh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ui/scanpopup.cc b/src/ui/scanpopup.cc index 3bb632531..2ff1a5923 100644 --- a/src/ui/scanpopup.cc +++ b/src/ui/scanpopup.cc @@ -317,7 +317,7 @@ void ScanPopup::updateFoundInDictsList() QStringList ids = definition->getArticlesList(); QString activeId = definition->getActiveArticleId(); toolbar->clear(); - if ( actionGroup!= nullptr ) { + if ( actionGroup != nullptr ) { actionGroup->deleteLater(); } actionGroup = new QActionGroup( this ); diff --git a/src/ui/scanpopup.hh b/src/ui/scanpopup.hh index 3a5df8e1b..a14d9f7a9 100644 --- a/src/ui/scanpopup.hh +++ b/src/ui/scanpopup.hh @@ -140,7 +140,7 @@ private: Config::Events configEvents; DictionaryBar dictionaryBar; QToolBar * toolbar; - QActionGroup * actionGroup=nullptr; + QActionGroup * actionGroup = nullptr; MainStatusBar * mainStatusBar; /// Fonts saved before words zooming is in effect, so it could be reset back. QFont wordListDefaultFont, translateLineDefaultFont, groupListDefaultFont; From 86fc3d32d8020b0291831030a162109a2f350c2f Mon Sep 17 00:00:00 2001 From: YiFang Xiao Date: Tue, 31 Dec 2024 17:11:18 +0800 Subject: [PATCH 13/14] do not allow move the dictionary tool bar --- src/ui/scanpopup.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/ui/scanpopup.cc b/src/ui/scanpopup.cc index 2ff1a5923..23521d59c 100644 --- a/src/ui/scanpopup.cc +++ b/src/ui/scanpopup.cc @@ -150,7 +150,6 @@ ScanPopup::ScanPopup( QWidget * parent, dictionaryBar.setMutedDictionaries( grp ? &grp->popupMutedDictionaries : nullptr ); } - addToolBar( Qt::TopToolBarArea, &dictionaryBar ); addToolBar( Qt::RightToolBarArea, toolbar ); connect( &dictionaryBar, &DictionaryBar::editGroupRequested, this, &ScanPopup::editGroupRequested ); @@ -179,6 +178,9 @@ ScanPopup::ScanPopup( QWidget * parent, restoreState( cfg.popupWindowState ); } + //fix this toolbar + addToolBar( Qt::TopToolBarArea, &dictionaryBar ); + ui.onTopButton->setChecked( cfg.popupWindowAlwaysOnTop ); ui.onTopButton->setVisible( cfg.pinPopupWindow ); connect( ui.onTopButton, &QAbstractButton::clicked, this, &ScanPopup::alwaysOnTopClicked ); @@ -186,7 +188,7 @@ ScanPopup::ScanPopup( QWidget * parent, ui.pinButton->setChecked( cfg.pinPopupWindow ); if ( cfg.pinPopupWindow ) { - dictionaryBar.setMovable( true ); + dictionaryBar.setMovable( false ); Qt::WindowFlags flags = pinnedWindowFlags; if ( cfg.popupWindowAlwaysOnTop ) { flags |= Qt::WindowStaysOnTopHint; @@ -959,7 +961,7 @@ void ScanPopup::pinButtonClicked( bool checked ) #endif setWindowTitle( QString( "%1 - GoldenDict-ng" ).arg( elideInputWord() ) ); - dictionaryBar.setMovable( true ); + dictionaryBar.setMovable( false ); hideTimer.stop(); } else { From 6cfff2d02604d20b11538656728947ab8e3b5fc0 Mon Sep 17 00:00:00 2001 From: YiFang Xiao Date: Tue, 31 Dec 2024 17:15:17 +0800 Subject: [PATCH 14/14] do not allow move the dictionary tool bar --- src/ui/mainwindow.hh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ui/mainwindow.hh b/src/ui/mainwindow.hh index ff67b1a4a..ae48f764c 100644 --- a/src/ui/mainwindow.hh +++ b/src/ui/mainwindow.hh @@ -17,7 +17,6 @@ #include "audio/audioplayerfactory.hh" #include "instances.hh" #include "article_maker.hh" -#include "scanpopup.hh" #include "ui/articleview.hh" #include "wordfinder.hh" #include "dictionarybar.hh" @@ -34,6 +33,7 @@ #ifdef HAVE_X11 #include #endif +#include "scanpopup.hh" #if defined( Q_OS_MAC ) #include "macos/gd_clipboard.hh"