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

List:       kde-commits
Subject:    koffice/lib/kofficeui
From:       Thorsten Zachmann <t.zachmann () zagge ! de>
Date:       2005-10-23 5:30:23
Message-ID: 1130045423.492681.25971.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 473270 by zachmann:

o Added popup menu for guide lines, where you can delete guide lines, or
  set the position of one guide line.
o Fixed setting of cursor. Don't set cursor when button is allready
  pressed.  

GUI:  


 M  +2 -2      Makefile.am  
 A             koGuideLineDia.cpp   trunk/koffice/kpresenter/kprhelplinedia.cc#469484 \
[License: LGPL (v2+)]  A             koGuideLineDia.h   \
trunk/koffice/kpresenter/kprhelplinedia.h#469484 [License: LGPL (v2+)]  M  +85 -3     \
koGuides.cpp    M  +14 -0     koGuides.h  


--- trunk/koffice/lib/kofficeui/Makefile.am #473269:473270
@@ -20,7 +20,7 @@
 	koCharSelectDia.cc koInsertLink.cc koeditpath.cc kocommandhistory.cpp \
 	koselectaction.cpp kolinewidthaction.cpp kolinestyleaction.cpp \
 	kotoolbutton.cc koImageResource.cc kotoolbox.cc kozoomhandler.cpp \
-    koGuideLines.cpp koGuides.cpp
+    koGuideLines.cpp koGuideLineDia.cpp koGuides.cpp
 
 libkofficeui_la_LDFLAGS	= -version-info 3:0:0 -no-undefined $(all_libraries)
 libkofficeui_la_LIBADD  = $(LIB_KOFFICECORE) 
@@ -36,7 +36,7 @@
 	koCharSelectDia.h koInsertLink.h kotoolbutton.h koeditpath.h \
 	kocommandhistory.h  koImageResource.h \
 	koselectaction.h kolinewidthaction.h kolinestyleaction.h kozoomhandler.h \
-    koGuideLines.h koGuides.h
+    koGuideLines.h koGuideLineDia.h koGuides.h
 
 # FIXME: Disabled for now as it breaks the installation process if
 # KOffice is not installed in $KDEDIR
--- trunk/koffice/lib/kofficeui/koGuides.cpp #473269:473270
@@ -20,23 +20,64 @@
 
 #include "koGuides.h"
 
+#include <qcursor.h>
 #include <qpainter.h>
 #include <qpixmap.h>
 
+#include <klocale.h>
+#include <kpopupmenu.h>
+
 #include <koDocument.h>
 #include <koPoint.h>
 #include <koView.h>
 #include <kozoomhandler.h>
 
+#include "koGuideLineDia.h"
+
+class KoGuides::Popup : public KPopupMenu
+{
+public: 
+    Popup( KoGuides * guides )
+    {
+        m_title = insertTitle( i18n( "Guide Line" ) );
+        m_delete = insertItem( i18n( "&Delete" ), guides, SLOT( slotRemove() ) );
+        m_seperator = insertSeparator();
+        m_pos = insertItem( i18n( "&Set Position..." ), guides, SLOT( \
slotChangePosition() ) ); +    }
+
+    void update( int count )
+    {
+        if ( count == 1 )
+        {
+            changeTitle( m_title, i18n( "Guide Line" ) );
+            setItemVisible( m_seperator, true );
+            setItemVisible( m_pos, true );
+        }
+        else
+        {
+            changeTitle( m_title, i18n( "Guide Lines" ) );
+            setItemVisible( m_seperator, false );
+            setItemVisible( m_pos, false );
+        }
+    }
+private:
+    int m_title;
+    int m_delete;
+    int m_seperator;
+    int m_pos;
+};
+
 KoGuides::KoGuides( KoView *view, KoZoomHandler *zoomHandler )
 : m_view( view )
 , m_zoomHandler( zoomHandler )    
 {
+    m_popup = new Popup( this );
 }
 
 
 KoGuides::~KoGuides()
 {
+    delete m_popup;
 }
 
 
@@ -95,9 +136,12 @@
     if ( guideLine )
     {
         m_lastPoint = e->pos();
-        if ( e->button() == Qt::LeftButton )
+        if ( e->button() == Qt::LeftButton || e->button() == Qt::RightButton )
         {
-            m_mouseSelected = true;
+            if ( e->button() == Qt::LeftButton )
+            {
+                m_mouseSelected = true;
+            }
             if ( e->state() & Qt::ControlButton )
             {
                 if ( guideLine->selected )
@@ -137,6 +181,12 @@
     {
         paint();
     }
+
+    if ( e->button() == Qt::RightButton && hasSelected() )
+    {
+        m_popup->update( m_selectedGuideLines.count() );
+        m_popup->exec( QCursor::pos() );
+    }
     
     return eventProcessed;
 }
@@ -156,7 +206,7 @@
         emit guideLinesChanged( m_view );
         eventProcessed = true;
     }
-    else if ( e->button() == Qt::NoButton )
+    else if ( e->state() == Qt::NoButton )
     {
         KoPoint p( mapFromScreen( e->pos() ) );
         KoGuideLine * guideLine = find( p, m_zoomHandler->unzoomItY( 2 ) );
@@ -329,6 +379,38 @@
 }
 
 
+void KoGuides::slotChangePosition()
+{
+    KoPoint p( mapFromScreen( m_lastPoint ) );
+    KoGuideLine * guideLine = find( p, m_zoomHandler->unzoomItY( 2 ) );
+
+    const KoPageLayout& pl = m_view->koDocument()->pageLayout();
+    double max = 0.0;
+    if ( guideLine->orientation == Qt::Vertical )
+    {
+        max = QMAX( pl.ptWidth, m_zoomHandler->unzoomItX( \
m_view->canvas()->size().width() + m_view->canvasXOffset() - 1 ) ); +    }
+    else
+    {
+        max = QMAX( pl.ptHeight, m_zoomHandler->unzoomItY( \
m_view->canvas()->size().height() + m_view->canvasYOffset() - 1 ) ); +    }
+
+    KoGuideLineDia dia( 0, guideLine->position, 0.0, max, \
m_view->koDocument()->unit() ); +    if ( dia.exec() == QDialog::Accepted )
+    {
+        guideLine->position = dia.pos();
+        paint();
+    }
+}
+
+
+void KoGuides::slotRemove()
+{
+    removeSelected();
+    paint();
+}
+
+
 void KoGuides::paint()
 {
     m_view->canvas()->repaint( false );
--- trunk/koffice/lib/kofficeui/koGuides.h #473269:473270
@@ -171,6 +171,17 @@
      */
     void moveGuides( bool state );
 
+private slots:
+    /**
+     * @brief Execute a dialog to set the position of the guide
+     */
+    void slotChangePosition();
+
+    /**
+     * @brief remove all selected guides
+     */
+    void slotRemove();
+
 private:
     /// Strukt holding the data of a guide line
     struct KoGuideLine 
@@ -290,6 +301,9 @@
     bool m_mouseSelected;
     /// true if a guide is inserted at the moment
     bool m_insertGuide;
+    /// popup menu
+    class Popup;
+    Popup * m_popup;
 };
 
 #endif /* KOGUIDES_H */


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

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