diff --git a/ui/pageview.cpp b/ui/pageview.cpp index 25dc63b40..91d41f94a 100644 --- a/ui/pageview.cpp +++ b/ui/pageview.cpp @@ -4234,9 +4234,9 @@ void PageView::slotSetMouseNormal() Okular::Settings::setMouseMode( Okular::Settings::EnumMouseMode::Browse ); // hide the messageWindow d->messageWindow->hide(); - // reshow the annotator toolbar if hiding was forced - if ( d->aToggleAnnotator && d->aToggleAnnotator->isChecked() ) - slotToggleAnnotator( true ); + // reshow the annotator toolbar if hiding was forced (and if it is not already visible) + if ( d->annotator && d->annotator->hidingWasForced() && d->aToggleAnnotator && !d->aToggleAnnotator->isChecked() ) + d->aToggleAnnotator->trigger(); // force an update of the cursor updateCursor( contentAreaPosition() + viewport()->mapFromGlobal( QCursor::pos() ) ); Okular::Settings::self()->writeConfig(); @@ -4248,8 +4248,11 @@ void PageView::slotSetMouseZoom() // change the text in messageWindow (and show it if hidden) d->messageWindow->display( i18n( "Select zooming area. Right-click to zoom out." ), QString(), PageViewMessage::Info, -1 ); // force hiding of annotator toolbar - if ( d->annotator ) - d->annotator->setEnabled( false ); + if ( d->aToggleAnnotator && d->aToggleAnnotator->isChecked() ) + { + d->aToggleAnnotator->trigger(); + d->annotator->setHidingForced( true ); + } // force an update of the cursor updateCursor( contentAreaPosition() + viewport()->mapFromGlobal( QCursor::pos() ) ); Okular::Settings::self()->writeConfig(); @@ -4261,8 +4264,11 @@ void PageView::slotSetMouseSelect() // change the text in messageWindow (and show it if hidden) d->messageWindow->display( i18n( "Draw a rectangle around the text/graphics to copy." ), QString(), PageViewMessage::Info, -1 ); // force hiding of annotator toolbar - if ( d->annotator ) - d->annotator->setEnabled( false ); + if ( d->aToggleAnnotator && d->aToggleAnnotator->isChecked() ) + { + d->aToggleAnnotator->trigger(); + d->annotator->setHidingForced( true ); + } // force an update of the cursor updateCursor( contentAreaPosition() + viewport()->mapFromGlobal( QCursor::pos() ) ); Okular::Settings::self()->writeConfig(); @@ -4274,8 +4280,11 @@ void PageView::slotSetMouseTextSelect() // change the text in messageWindow (and show it if hidden) d->messageWindow->display( i18n( "Select text" ), QString(), PageViewMessage::Info, -1 ); // force hiding of annotator toolbar - if ( d->annotator ) - d->annotator->setEnabled( false ); + if ( d->aToggleAnnotator && d->aToggleAnnotator->isChecked() ) + { + d->aToggleAnnotator->trigger(); + d->annotator->setHidingForced( true ); + } // force an update of the cursor updateCursor( contentAreaPosition() + viewport()->mapFromGlobal( QCursor::pos() ) ); Okular::Settings::self()->writeConfig(); @@ -4289,8 +4298,11 @@ void PageView::slotSetMouseTableSelect() "Draw a rectangle around the table, then click near edges to divide up; press Esc to clear." ), QString(), PageViewMessage::Info, -1 ); // force hiding of annotator toolbar - if ( d->annotator ) - d->annotator->setEnabled( false ); + if ( d->aToggleAnnotator && d->aToggleAnnotator->isChecked() ) + { + d->aToggleAnnotator->trigger(); + d->annotator->setHidingForced( true ); + } // force an update of the cursor updateCursor( contentAreaPosition() + viewport()->mapFromGlobal( QCursor::pos() ) ); Okular::Settings::self()->writeConfig(); @@ -4347,6 +4359,7 @@ void PageView::slotToggleAnnotator( bool on ) // initialize/reset annotator (and show/hide toolbar) d->annotator->setEnabled( on ); + d->annotator->setHidingForced( false ); inHere = false; } diff --git a/ui/pageviewannotator.cpp b/ui/pageviewannotator.cpp index 52a464b7e..9754b5eeb 100644 --- a/ui/pageviewannotator.cpp +++ b/ui/pageviewannotator.cpp @@ -604,7 +604,7 @@ class TextSelectorEngine : public AnnotatorEngine PageViewAnnotator::PageViewAnnotator( PageView * parent, Okular::Document * storage ) : QObject( parent ), m_document( storage ), m_pageView( parent ), m_toolBar( 0 ), m_engine( 0 ), m_textToolsEnabled( false ), m_toolsEnabled( false ), - m_continuousMode( false ), m_lastToolID( -1 ), m_lockedItem( 0 ) + m_continuousMode( false ), m_hidingWasForced( false ), m_lastToolID( -1 ), m_lockedItem( 0 ) { // load the tools from the 'xml tools definition' file. store the tree internally. QFile infoFile( KStandardDirs::locate("data", "okular/tools.xml") ); @@ -706,6 +706,16 @@ void PageViewAnnotator::setToolsEnabled( bool enabled ) m_toolBar->setToolsEnabled( m_toolsEnabled ); } +void PageViewAnnotator::setHidingForced( bool forced ) +{ + m_hidingWasForced = forced; +} + +bool PageViewAnnotator::hidingWasForced() const +{ + return m_hidingWasForced; +} + bool PageViewAnnotator::routeEvents() const { return m_engine && m_toolBar; diff --git a/ui/pageviewannotator.h b/ui/pageviewannotator.h index e847208a2..a2ef90d48 100644 --- a/ui/pageviewannotator.h +++ b/ui/pageviewannotator.h @@ -60,6 +60,9 @@ class PageViewAnnotator : public QObject void setToolsEnabled( bool enabled ); + void setHidingForced( bool forced ); + bool hidingWasForced() const; + // methods used when creating the annotation bool routeEvents() const; QRect routeEvent( QMouseEvent * event, PageViewItem * item ); @@ -85,6 +88,7 @@ class PageViewAnnotator : public QObject bool m_textToolsEnabled; bool m_toolsEnabled; bool m_continuousMode; + bool m_hidingWasForced; // creation related variables int m_lastToolID;