Commit a2dd088e authored by Sandro Mani's avatar Sandro Mani Committed by Albert Astals Cid
Browse files

Fix Tools->review inconsistency when switching tool

BUGS: 304621
FIXED-IN: 4.9.1
parent 77af86fd
......@@ -4216,9 +4216,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();
......@@ -4230,8 +4230,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();
......@@ -4243,8 +4246,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();
......@@ -4256,8 +4262,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();
......@@ -4271,8 +4280,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();
......@@ -4329,6 +4341,7 @@ void PageView::slotToggleAnnotator( bool on )
// initialize/reset annotator (and show/hide toolbar)
d->annotator->setEnabled( on );
d->annotator->setHidingForced( false );
inHere = false;
}
......
......@@ -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;
......
......@@ -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;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment