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

List:       kde-commits
Subject:    branches/marble/marble-1.1/src/lib
From:       Torsten Rahn <tackat () kde ! org>
Date:       2011-01-06 14:20:29
Message-ID: 20110106142029.B07BBAC8B0 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1212312 by rahn:

Backport:

rahn * r1212295 trunk/KDE/kdeedu/marble/src/lib/ (AbstractFloatItem.cpp
AbstractFloatItem.h)
- Commit http://reviewboard.kde.org/r/6237/ by Daniel Marth.
Default submenus for floatitems! Yay!



 M  +49 -0     AbstractFloatItem.cpp  
 M  +5 -2      AbstractFloatItem.h  


--- branches/marble/marble-1.1/src/lib/AbstractFloatItem.cpp #1212311:1212312
@@ -11,6 +11,12 @@
 // Self
 #include "AbstractFloatItem.h"
 
+// Qt
+#include <QtGui/QMenu>
+#include <QtGui/QAction>
+#include <QtGui/QDialog>
+#include <QtGui/QContextMenuEvent>
+
 // Marble
 #include "MarbleDebug.h"
 
@@ -91,11 +97,15 @@
 
 void AbstractFloatItem::setVisible( bool visible )
 {
+    // Reimplemented since AbstractFloatItem does multiple inheritance 
+    // and the (set)Visible() methods are available in both base classes!
     RenderPlugin::setVisible( visible );
 }
 
 bool AbstractFloatItem::visible() const
 {
+    // Reimplemented since AbstractFloatItem does multiple inheritance 
+    // and the (set)Visible() methods are available in both base classes!
     return RenderPlugin::visible();
 }
 
@@ -124,6 +134,35 @@
         return false;
     }
 
+    if( e->type() == QEvent::ContextMenu )
+    {
+        QWidget *widget = dynamic_cast<QWidget *>( object );
+        QContextMenuEvent *menuEvent = dynamic_cast<QContextMenuEvent *> ( e );
+        if( widget != NULL && menuEvent != NULL && contains( menuEvent->pos() ) )
+        {
+	    QMenu menu;
+	    QAction *lockaction = menu.addAction( tr( "&Lock" ) );
+	    lockaction->setCheckable( true );
+	    lockaction->setChecked( positionLocked() );
+	    connect( lockaction, SIGNAL( triggered( bool ) ),
+		    this, SLOT( setPositionLocked( bool ) ) );
+	    QAction *hideaction = menu.addAction( tr( "&Hide" ) );
+	    connect( hideaction, SIGNAL( triggered() ),
+		    this, SLOT( hide() ) );
+	    QDialog *dialog = configDialog();
+	    if( dialog != NULL )
+	    {
+		menu.addSeparator();
+		QAction *configaction = menu.addAction( tr( "&Configure..." ) );
+		connect( configaction, SIGNAL( triggered() ),
+			dialog, SLOT( exec() ) );
+	    }
+	    menu.exec( widget->mapToGlobal( menuEvent->pos() ) );
+            return true;
+        }
+        return false;
+    }
+
     return ScreenGraphicsItem::eventFilter( object, e );
 }
 
@@ -159,6 +198,16 @@
     return true;
 }
 
+void AbstractFloatItem::show()
+{
+    setVisible( true );
 }
 
+void AbstractFloatItem::hide()
+{
+    setVisible( false );
+}
+
+}
+
 #include "AbstractFloatItem.moc"
--- branches/marble/marble-1.1/src/lib/AbstractFloatItem.h #1212311:1212312
@@ -64,10 +64,13 @@
 
     bool visible() const;
 
+    bool positionLocked();
+
+ public slots:
     void setPositionLocked( bool lock );
+    void show();
+    void hide();
 
-    bool positionLocked();
-
  protected:
     virtual bool eventFilter( QObject *object, QEvent *e );
 
[prev in list] [next in list] [prev in thread] [next in thread] 

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