added right-click handling support to SceneTool class

This commit is contained in:
Marc Zinnschlag 2014-09-07 13:35:30 +02:00
parent f913d51e35
commit 4337d05126
6 changed files with 38 additions and 1 deletions

View file

@ -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;
}

View file

@ -51,6 +51,8 @@ namespace CSVWidget
/// Return tooltip used at construction (without any button-specific modifications)
QString getBaseToolTip() const;
Type getType() const;
};
}

View file

@ -1,6 +1,8 @@
#include "scenetool.hpp"
#include <QMouseEvent>
#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()));
}

View file

@ -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();

View file

@ -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]);

View file

@ -31,6 +31,8 @@ namespace CSVWidget
virtual void showPanel (const QPoint& position);
virtual void activate();
void removeProfile (const std::string& profile);
signals: