From 83bdb1db6f021419055fca85d1cb30e5eb62bc78 Mon Sep 17 00:00:00 2001 From: Abs62 Date: Wed, 19 Sep 2012 16:44:36 +0400 Subject: [PATCH] Ctrl(Shift)+Click on "Found in dictionaries" pane do same action as on dictionary toolbar --- dictionarybar.cc | 13 +++++++++++++ dictionarybar.hh | 2 ++ mainwindow.cc | 16 ++++++++++++++++ mainwindow.hh | 6 ++++++ 4 files changed, 37 insertions(+) diff --git a/dictionarybar.cc b/dictionarybar.cc index 275e2161..003db596 100644 --- a/dictionarybar.cc +++ b/dictionarybar.cc @@ -217,3 +217,16 @@ void DictionaryBar::actionWasTriggered( QAction * action ) } } +void DictionaryBar::dictsPaneClicked( const QString & id ) +{ + for( QList< QAction * >::iterator i = dictActions.begin(); + i != dictActions.end(); ++i ) + { + QString dictId = (*i)->data().toString(); + if ( dictId == id ) + { + (*i)->activate( QAction::Trigger ); + break; + } + } +} diff --git a/dictionarybar.hh b/dictionarybar.hh index d86adb8a..51aa516a 100644 --- a/dictionarybar.hh +++ b/dictionarybar.hh @@ -47,6 +47,8 @@ private slots: void mutedDictionariesChanged(); void actionWasTriggered( QAction * ); + + void dictsPaneClicked( QString const & ); }; #endif diff --git a/mainwindow.cc b/mainwindow.cc index 1a7807dc..72a38e01 100644 --- a/mainwindow.cc +++ b/mainwindow.cc @@ -104,6 +104,9 @@ MainWindow::MainWindow( Config::Class & cfg_ ): connect( ui.dictsPane, SIGNAL( visibilityChanged( bool ) ), this, SLOT( dictsPaneVisibilityChanged ( bool ) ) ); + connect( ui.dictsList, SIGNAL( itemClicked( QListWidgetItem * ) ), + this, SLOT( dictsPaneClicked( QListWidgetItem * ) ) ); + // Make the toolbar navToolbar = addToolBar( tr( "Navigation" ) ); navToolbar->setObjectName( "navToolbar" ); @@ -329,6 +332,9 @@ MainWindow::MainWindow( Config::Class & cfg_ ): useSmallIconsInToolbarsTriggered(); + connect( this, SIGNAL( clickOnDictPane( QString const & ) ), + &dictionaryBar, SLOT( dictsPaneClicked( QString const & ) ) ); + addToolBar( &dictionaryBar ); connect( dictionaryBar.toggleViewAction(), SIGNAL(triggered(bool)), @@ -2962,6 +2968,16 @@ void MainWindow::switchExpandOptionalPartsMode() view->switchExpandOptionalParts(); } +void MainWindow::dictsPaneClicked( QListWidgetItem * item ) +{ + if ( QApplication::keyboardModifiers() & + ( Qt::ControlModifier | Qt::ShiftModifier ) ) + { + QString id = item->data( Qt::UserRole ).toString(); + emit clickOnDictPane( id ); + } +} + #ifdef Q_OS_WIN32 bool MainWindow::winEvent( MSG * message, long * result ) diff --git a/mainwindow.hh b/mainwindow.hh index e30b3e6f..f2666800 100644 --- a/mainwindow.hh +++ b/mainwindow.hh @@ -193,6 +193,9 @@ private slots: /// Signalled when the lastestReleaseReply is finished() void latestReleaseReplyReady(); + /// Receive click on "Found in:" pane + void dictsPaneClicked( QListWidgetItem * item ); + private slots: // Executed in response to a user click on an 'add tab' tool button @@ -342,6 +345,9 @@ signals: /// Set optional parts expand mode for all tabs void setExpandOptionalParts( bool expand ); + /// Retranslate Ctrl(Shift) + Click on dictionary pane to dictionary toolbar + void clickOnDictPane( QString const & id ); + #ifdef Q_OS_WIN32 /// For receiving message from scan libraries protected: