[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdegraphics/okular/ui
From:       Albert Astals Cid <tsdgeos () terra ! es>
Date:       2011-01-31 23:51:35
Message-ID: 20110131235135.088DD3E1F1 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1218185 by aacid:

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


 M  +31 -7     pageviewannotator.cpp  
 M  +4 -0      pageviewannotator.h  
 M  +6 -0      pageviewutils.cpp  
 M  +8 -0      pageviewutils.h  


--- trunk/KDE/kdegraphics/okular/ui/pageviewannotator.cpp #1218184:1218185
@@ -603,7 +603,7 @@
 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 @@
                 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 @@
     // 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 @@
                 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 @@
 {
     if ( event->key() == Qt::Key_Escape )
     {
-        m_toolBar->selectButton( -1 );
+        detachAnnotation();
         return true;
     }
     return false;
@@ -837,6 +850,7 @@
         m_lastDrawnRect = QRect();
     }
 
+    if ( toolID != m_lastToolID ) m_continuousMode = false;
     // store current tool for later usage
     m_lastToolID = toolID;
 
@@ -906,6 +920,16 @@
     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; */
--- trunk/KDE/kdegraphics/okular/ui/pageviewannotator.h #1218184:1218185
@@ -70,8 +70,11 @@
     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 @@
         QLinkedList<AnnotationToolItem> m_items;
         bool m_textToolsEnabled;
         bool m_toolsEnabled;
+        bool m_continuousMode;
 
         // creation related variables
         int m_lastToolID;
--- trunk/KDE/kdegraphics/okular/ui/pageviewutils.cpp #1218184:1218185
@@ -464,6 +464,11 @@
         setToolTip( item.text );
 }
 
+void ToolBarButton::mouseDoubleClickEvent( QMouseEvent * /*event*/ )
+{
+  emit buttonDoubleClicked( buttonID() );
+}
+
 /* PageViewToolBar */
 
 static const int toolBarGridSize = 40;
@@ -542,6 +547,7 @@
     {
         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 );
     }
 
--- trunk/KDE/kdegraphics/okular/ui/pageviewutils.h #1218184:1218185
@@ -169,6 +169,12 @@
         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 @@
         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 }


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic