mirror of
https://invent.kde.org/graphics/okular
synced 2024-08-24 18:35:37 +00:00
Allow the "continuous" selection of a tool by double clicking on it
Patch by Raffaele Mancuso cleaned up by me This will be in KDE 4.7.0 This fixes the original report of bug 161020 so i'm closing it If there were any other different wish report in that bug, do the proper thing an open a new one BUGS: 161020 svn path=/trunk/KDE/kdegraphics/okular/; revision=1218185
This commit is contained in:
parent
054623a581
commit
72e616551b
|
@ -603,7 +603,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_lastToolID( -1 ), m_lockedItem( 0 )
|
||||
m_continuousMode( 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") );
|
||||
|
@ -682,6 +682,9 @@ void PageViewAnnotator::setEnabled( bool on )
|
|||
this, SLOT( slotToolSelected(int) ) );
|
||||
connect( m_toolBar, SIGNAL( orientationChanged(int) ),
|
||||
this, SLOT( slotSaveToolbarOrientation(int) ) );
|
||||
|
||||
connect( m_toolBar, SIGNAL( buttonDoubleClicked(int) ),
|
||||
this, SLOT( slotToolDoubleClicked(int) ) );
|
||||
}
|
||||
|
||||
// show the toolBar
|
||||
|
@ -717,6 +720,17 @@ QRect PageViewAnnotator::routeEvent( QMouseEvent * e, PageViewItem * item )
|
|||
// figure out the event type and button
|
||||
AnnotatorEngine::decodeEvent( e, &eventType, &button );
|
||||
|
||||
// if the right mouse button was pressed, we simply do nothing. In this way, we are still editing the annotation
|
||||
// and so this function will receive and process the right mouse button release event too. If we detach now the annotation tool,
|
||||
// the release event will be processed by the PageView class which would create the annotation property widget, and we do not want this.
|
||||
if ( button == AnnotatorEngine::Right && eventType == AnnotatorEngine::Press )
|
||||
return QRect();
|
||||
else if ( button == AnnotatorEngine::Right && eventType == AnnotatorEngine::Release )
|
||||
{
|
||||
detachAnnotation();
|
||||
return QRect();
|
||||
}
|
||||
|
||||
// find out normalized mouse coords inside current item
|
||||
const QRect & itemRect = item->uncroppedGeometry();
|
||||
const QPoint eventPos = m_pageView->contentAreaPoint( e->pos() );
|
||||
|
@ -771,11 +785,10 @@ QRect PageViewAnnotator::routeEvent( QMouseEvent * e, PageViewItem * item )
|
|||
m_pageView->setAnnotationWindow( annotation );
|
||||
}
|
||||
|
||||
// go on creating annotations of the same type
|
||||
// for now, disable the "construct again the same annotation"
|
||||
//slotToolSelected( m_lastToolID );
|
||||
slotToolSelected( -1 );
|
||||
m_toolBar->selectButton( -1 );
|
||||
if ( m_continuousMode )
|
||||
slotToolSelected( m_lastToolID );
|
||||
else
|
||||
detachAnnotation();
|
||||
}
|
||||
|
||||
return modifiedRect;
|
||||
|
@ -785,7 +798,7 @@ bool PageViewAnnotator::routeKeyEvent( QKeyEvent * event )
|
|||
{
|
||||
if ( event->key() == Qt::Key_Escape )
|
||||
{
|
||||
m_toolBar->selectButton( -1 );
|
||||
detachAnnotation();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -837,6 +850,7 @@ void PageViewAnnotator::slotToolSelected( int toolID )
|
|||
m_lastDrawnRect = QRect();
|
||||
}
|
||||
|
||||
if ( toolID != m_lastToolID ) m_continuousMode = false;
|
||||
// store current tool for later usage
|
||||
m_lastToolID = toolID;
|
||||
|
||||
|
@ -906,6 +920,16 @@ void PageViewAnnotator::slotSaveToolbarOrientation( int side )
|
|||
Okular::Settings::self()->writeConfig();
|
||||
}
|
||||
|
||||
void PageViewAnnotator::slotToolDoubleClicked( int /*toolID*/ )
|
||||
{
|
||||
m_continuousMode = true;
|
||||
}
|
||||
|
||||
void PageViewAnnotator::detachAnnotation()
|
||||
{
|
||||
m_toolBar->selectButton( -1 );
|
||||
}
|
||||
|
||||
#include "pageviewannotator.moc"
|
||||
|
||||
/* kate: replace-tabs on; indent-width 4; */
|
||||
|
|
|
@ -70,8 +70,11 @@ class PageViewAnnotator : public QObject
|
|||
private slots:
|
||||
void slotToolSelected( int toolID );
|
||||
void slotSaveToolbarOrientation( int side );
|
||||
void slotToolDoubleClicked( int toolID );
|
||||
|
||||
private:
|
||||
void detachAnnotation();
|
||||
|
||||
// global class pointers
|
||||
Okular::Document * m_document;
|
||||
PageView * m_pageView;
|
||||
|
@ -81,6 +84,7 @@ class PageViewAnnotator : public QObject
|
|||
QLinkedList<AnnotationToolItem> m_items;
|
||||
bool m_textToolsEnabled;
|
||||
bool m_toolsEnabled;
|
||||
bool m_continuousMode;
|
||||
|
||||
// creation related variables
|
||||
int m_lastToolID;
|
||||
|
|
|
@ -464,6 +464,11 @@ ToolBarButton::ToolBarButton( QWidget * parent, const AnnotationToolItem &item )
|
|||
setToolTip( item.text );
|
||||
}
|
||||
|
||||
void ToolBarButton::mouseDoubleClickEvent( QMouseEvent * /*event*/ )
|
||||
{
|
||||
emit buttonDoubleClicked( buttonID() );
|
||||
}
|
||||
|
||||
/* PageViewToolBar */
|
||||
|
||||
static const int toolBarGridSize = 40;
|
||||
|
@ -542,6 +547,7 @@ void PageViewToolBar::setItems( const QLinkedList<AnnotationToolItem> &items )
|
|||
{
|
||||
ToolBarButton * button = new ToolBarButton( this, *it );
|
||||
connect( button, SIGNAL( clicked() ), this, SLOT( slotButtonClicked() ) );
|
||||
connect( button, SIGNAL( buttonDoubleClicked(int) ), this, SIGNAL( buttonDoubleClicked(int) ) );
|
||||
d->buttons.append( button );
|
||||
}
|
||||
|
||||
|
|
|
@ -169,6 +169,12 @@ class ToolBarButton : public QToolButton
|
|||
int buttonID() const { return m_id; }
|
||||
bool isText() const { return m_isText; }
|
||||
|
||||
signals:
|
||||
void buttonDoubleClicked( int buttonID );
|
||||
|
||||
protected:
|
||||
void mouseDoubleClickEvent( QMouseEvent * event );
|
||||
|
||||
private:
|
||||
int m_id;
|
||||
bool m_isText;
|
||||
|
@ -210,6 +216,8 @@ class PageViewToolBar : public QWidget
|
|||
void toolSelected( int toolID );
|
||||
// orientation has been changed
|
||||
void orientationChanged( int side );
|
||||
// a tool button of this toolbar has been double clicked
|
||||
void buttonDoubleClicked( int buttonID );
|
||||
|
||||
protected:
|
||||
// handle widget events { anchor_resize, paint, animation, drag }
|
||||
|
|
Loading…
Reference in a new issue