From 4337d051261d4dee6066d9832ea26885701014ea Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sun, 7 Sep 2014 13:35:30 +0200 Subject: [PATCH] added right-click handling support to SceneTool class --- apps/opencs/view/widget/pushbutton.cpp | 5 +++++ apps/opencs/view/widget/pushbutton.hpp | 2 ++ apps/opencs/view/widget/scenetool.cpp | 17 ++++++++++++++++- apps/opencs/view/widget/scenetool.hpp | 8 ++++++++ apps/opencs/view/widget/scenetoolrun.cpp | 5 +++++ apps/opencs/view/widget/scenetoolrun.hpp | 2 ++ 6 files changed, 38 insertions(+), 1 deletion(-) diff --git a/apps/opencs/view/widget/pushbutton.cpp b/apps/opencs/view/widget/pushbutton.cpp index 21f5f03878..f234625859 100644 --- a/apps/opencs/view/widget/pushbutton.cpp +++ b/apps/opencs/view/widget/pushbutton.cpp @@ -91,4 +91,9 @@ bool CSVWidget::PushButton::hasKeepOpen() const QString CSVWidget::PushButton::getBaseToolTip() const { return mToolTip; +} + +CSVWidget::PushButton::Type CSVWidget::PushButton::getType() const +{ + return mType; } \ No newline at end of file diff --git a/apps/opencs/view/widget/pushbutton.hpp b/apps/opencs/view/widget/pushbutton.hpp index 0b5ad68332..35062a137b 100644 --- a/apps/opencs/view/widget/pushbutton.hpp +++ b/apps/opencs/view/widget/pushbutton.hpp @@ -51,6 +51,8 @@ namespace CSVWidget /// Return tooltip used at construction (without any button-specific modifications) QString getBaseToolTip() const; + + Type getType() const; }; } diff --git a/apps/opencs/view/widget/scenetool.cpp b/apps/opencs/view/widget/scenetool.cpp index 8239074b6f..b8e9f895f4 100644 --- a/apps/opencs/view/widget/scenetool.cpp +++ b/apps/opencs/view/widget/scenetool.cpp @@ -1,6 +1,8 @@ #include "scenetool.hpp" +#include + #include "scenetoolbar.hpp" CSVWidget::SceneTool::SceneTool (SceneToolbar *parent, Type type) @@ -13,7 +15,20 @@ CSVWidget::SceneTool::SceneTool (SceneToolbar *parent, Type type) connect (this, SIGNAL (clicked()), this, SLOT (openRequest())); } +void CSVWidget::SceneTool::activate() {} + +void CSVWidget::SceneTool::mouseReleaseEvent (QMouseEvent *event) +{ + if (getType()==Type_TopAction && event->button()==Qt::RightButton) + showPanel (parentWidget()->mapToGlobal (pos())); + else + PushButton::mouseReleaseEvent (event); +} + void CSVWidget::SceneTool::openRequest() { - showPanel (parentWidget()->mapToGlobal (pos())); + if (getType()==Type_TopAction) + activate(); + else + showPanel (parentWidget()->mapToGlobal (pos())); } diff --git a/apps/opencs/view/widget/scenetool.hpp b/apps/opencs/view/widget/scenetool.hpp index 1aa4df9f7c..cdea88096a 100644 --- a/apps/opencs/view/widget/scenetool.hpp +++ b/apps/opencs/view/widget/scenetool.hpp @@ -18,6 +18,14 @@ namespace CSVWidget virtual void showPanel (const QPoint& position) = 0; + /// This function will only called for buttons of type Type_TopAction. The default + /// implementation is empty. + virtual void activate(); + + protected: + + void mouseReleaseEvent (QMouseEvent *event); + private slots: void openRequest(); diff --git a/apps/opencs/view/widget/scenetoolrun.cpp b/apps/opencs/view/widget/scenetoolrun.cpp index ce2dbe76f7..4a89c9fe90 100644 --- a/apps/opencs/view/widget/scenetoolrun.cpp +++ b/apps/opencs/view/widget/scenetoolrun.cpp @@ -29,6 +29,11 @@ CSVWidget::SceneToolRun::SceneToolRun (SceneToolbar *parent, const QString& tool } void CSVWidget::SceneToolRun::showPanel (const QPoint& position) +{ + +} + +void CSVWidget::SceneToolRun::activate() { if (mCurrentIndex!=-1) emit runRequest (mProfiles[mCurrentIndex]); diff --git a/apps/opencs/view/widget/scenetoolrun.hpp b/apps/opencs/view/widget/scenetoolrun.hpp index 50008dae91..b1ea3229d5 100644 --- a/apps/opencs/view/widget/scenetoolrun.hpp +++ b/apps/opencs/view/widget/scenetoolrun.hpp @@ -31,6 +31,8 @@ namespace CSVWidget virtual void showPanel (const QPoint& position); + virtual void activate(); + void removeProfile (const std::string& profile); signals: