[Marble-commits] KDE/kdeedu/marble/src/lib
Torsten Rahn
tackat at kde.org
Wed Jul 29 11:38:38 CEST 2009
SVN commit 1004066 by rahn:
BUG: 184191
- Committing patch for more generic enabling of mouse buttons in the input handler.
Patch by Dennis Nienhüser.
M +4 -0 MarbleWidget.cpp
M +5 -0 MarbleWidget.h
M +27 -14 MarbleWidgetInputHandler.cpp
M +18 -14 MarbleWidgetInputHandler.h
--- trunk/KDE/kdeedu/marble/src/lib/MarbleWidget.cpp #1004065:1004066
@@ -246,6 +246,10 @@
}
}
+MarbleWidgetInputHandler *MarbleWidget::inputHandler() const
+{
+ return d->m_inputhandler;
+}
Quaternion MarbleWidget::planetAxis() const
{
--- trunk/KDE/kdeedu/marble/src/lib/MarbleWidget.h #1004065:1004066
@@ -187,6 +187,11 @@
MarbleModel *model() const;
/**
+ * Returns the current input handler
+ */
+ MarbleWidgetInputHandler *inputHandler() const;
+
+ /**
* @brief Set the input handler
*/
void setInputHandler(MarbleWidgetInputHandler *handler);
--- trunk/KDE/kdeedu/marble/src/lib/MarbleWidgetInputHandler.cpp #1004065:1004066
@@ -36,7 +36,8 @@
: m_widget( 0 ),
m_model( 0 ),
m_positionSignalConnected( false ),
- m_mouseWheelTimer( new QTimer(this) )
+ m_mouseWheelTimer( new QTimer(this) ),
+ m_disabledMouseButtons(Qt::NoButton)
{
connect( m_mouseWheelTimer, SIGNAL( timeout() ),
this, SLOT( restoreViewContext() ) );
@@ -58,9 +59,25 @@
}
}
+void MarbleWidgetInputHandler::setMouseButtonPopupEnabled(Qt::MouseButton mouseButton, bool enabled)
+{
+ if (enabled)
+ {
+ m_disabledMouseButtons &= ~Qt::MouseButtons(mouseButton);
+ }
+ else
+ {
+ m_disabledMouseButtons |= mouseButton;
+ }
+}
+bool MarbleWidgetInputHandler::isMouseButtonPopupEnabled(Qt::MouseButton mouseButton) const
+{
+ return !(m_disabledMouseButtons & mouseButton);
+}
+
MarbleWidgetDefaultInputHandler::MarbleWidgetDefaultInputHandler()
- : MarbleWidgetInputHandler(), m_popupmenu( 0 ), m_leftpopup(true)
+ : MarbleWidgetInputHandler(), m_popupmenu( 0 )
{
curpmtl.load( MarbleDirs::path("bitmaps/cursor_tl.xpm") );
curpmtc.load( MarbleDirs::path("bitmaps/cursor_tc.xpm") );
@@ -122,7 +139,7 @@
m_popupmenu = new MarbleWidgetPopupMenu( m_widget, m_model );
}
connect( this, SIGNAL( rmbRequest( int, int ) ),
- m_popupmenu, SLOT( showRmbMenu( int, int ) ) );
+ this, SLOT( showRmbMenu( int, int ) ) );
connect( m_popupmenu, SIGNAL( addMeasurePoint( qreal, qreal ) ),
measureTool, SLOT( addMeasurePoint( qreal, qreal ) ) );
connect( m_popupmenu, SIGNAL( removeLastMeasurePoint() ),
@@ -137,21 +154,17 @@
void MarbleWidgetDefaultInputHandler::showLmbMenu( int x, int y)
{
- if (m_leftpopup)
- {
- m_popupmenu->showLmbMenu(x,y);
- }
+ if ( isMouseButtonPopupEnabled( Qt::LeftButton ) ) {
+ m_popupmenu->showLmbMenu( x, y );
+ }
}
-void MarbleWidgetDefaultInputHandler::setLeftMouseButtonPopup(bool enabled)
+void MarbleWidgetDefaultInputHandler::showRmbMenu( int x, int y)
{
- m_leftpopup = enabled;
+ if ( isMouseButtonPopupEnabled( Qt::RightButton ) ) {
+ m_popupmenu->showRmbMenu( x, y );
+ }
}
-
-bool MarbleWidgetDefaultInputHandler::leftMouseButtonPopup()
-{
- return m_leftpopup;
-}
bool MarbleWidgetDefaultInputHandler::eventFilter( QObject* o, QEvent* e )
{
--- trunk/KDE/kdeedu/marble/src/lib/MarbleWidgetInputHandler.h #1004065:1004066
@@ -52,6 +52,18 @@
virtual void init(MarbleWidget*);
+ /**
+ * @brief Set whether a popup menu appears on a click (not drag) with the left mouse button
+ * @param enabled True to enable the popup menu (default), false to disable it
+ */
+ void setMouseButtonPopupEnabled(Qt::MouseButton mouseButton, bool enabled);
+
+ /**
+ * @brief Return whether the left mouse button popup menu is active
+ * @return True iff a popup menu is shown on left mouse button clicks
+ */
+ bool isMouseButtonPopupEnabled(Qt::MouseButton mouseButton) const;
+
Q_SIGNALS:
// Mouse button menus
void lmbRequest( int, int );
@@ -71,7 +83,9 @@
bool m_positionSignalConnected;
QTimer *m_mouseWheelTimer;
-
+
+ Qt::MouseButtons m_disabledMouseButtons;
+
private:
Q_DISABLE_COPY( MarbleWidgetInputHandler )
};
@@ -90,23 +104,14 @@
virtual void init(MarbleWidget*);
- /**
- * @brief Set whether a popup menu appears on a click (not drag) with the left mouse button
- * @param enabled True to enable the popup menu (default), false to disable it
- */
- void setLeftMouseButtonPopup(bool enabled);
-
- /**
- * @brief Return whether the left mouse button popup menu is active
- * @return True iff a popup menu is shown on left mouse button clicks
- */
- bool leftMouseButtonPopup();
-
protected:
bool eventFilter( QObject *, QEvent * );
private Q_SLOTS:
void showLmbMenu( int, int );
+
+ void showRmbMenu( int, int );
+
private:
QPixmap curpmtl;
@@ -139,7 +144,6 @@
MarbleWidgetPopupMenu *m_popupmenu;
- bool m_leftpopup;
};
}
More information about the Marble-commits
mailing list