[Marble-commits] KDE/kdeedu/marble/src/lib
Torsten Rahn
tackat at kde.org
Thu Jan 6 14:26:58 CET 2011
SVN commit 1212295 by rahn:
- Commit http://reviewboard.kde.org/r/6237/ by Daniel Marth.
Default submenus for floatitems! Yay!
M +37 -2 AbstractFloatItem.cpp
M +5 -2 AbstractFloatItem.h
--- trunk/KDE/kdeedu/marble/src/lib/AbstractFloatItem.cpp #1212294:1212295
@@ -11,6 +11,11 @@
// Self
#include "AbstractFloatItem.h"
+// Qt
+#include <QtGui/QMenu>
+#include <QtGui/QAction>
+#include <QtGui/QDialog>
+
// Marble
#include "MarbleDebug.h"
@@ -91,11 +96,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();
}
@@ -151,9 +160,25 @@
void AbstractFloatItem::contextMenuEvent ( QWidget *w, QContextMenuEvent *e )
{
- Q_UNUSED( w );
- Q_UNUSED( e );
+ 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( w->mapToGlobal( e->pos() ) );
+}
void AbstractFloatItem::toolTipEvent ( QHelpEvent *e )
{
@@ -192,6 +217,16 @@
return true;
}
+void AbstractFloatItem::show()
+{
+ setVisible( true );
}
+void AbstractFloatItem::hide()
+{
+ setVisible( false );
+}
+
+}
+
#include "AbstractFloatItem.moc"
--- trunk/KDE/kdeedu/marble/src/lib/AbstractFloatItem.h #1212294:1212295
@@ -67,10 +67,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 );
virtual void contextMenuEvent ( QWidget *w, QContextMenuEvent *e );
More information about the Marble-commits
mailing list