New clickable widget

This commit is contained in:
Nav
2021-08-22 20:43:43 +01:00
parent 109c045536
commit 342384a91c
3 changed files with 46 additions and 0 deletions

View File

@@ -130,6 +130,7 @@ add_executable(Bloom
src/Insight/UserInterfaces/InsightWindow/Widgets/RotatableLabel.cpp
src/Insight/UserInterfaces/InsightWindow/Widgets/SvgWidget.cpp
src/Insight/UserInterfaces/InsightWindow/Widgets/SvgToolButton.hpp
src/Insight/UserInterfaces/InsightWindow/Widgets/ClickableWidget.cpp
src/Insight/UserInterfaces/InsightWindow/Widgets/ExpandingWidget.hpp
src/Insight/UserInterfaces/InsightWindow/Widgets/ExpandingHeightScrollAreaWidget.hpp

View File

@@ -0,0 +1,19 @@
#include "ClickableWidget.hpp"
using namespace Bloom::Widgets;
void ClickableWidget::mouseReleaseEvent(QMouseEvent* event) {
if (event->button() == Qt::MouseButton::LeftButton) {
emit this->clicked();
}
QWidget::mouseReleaseEvent(event);
}
void ClickableWidget::mouseDoubleClickEvent(QMouseEvent* event) {
if (event->button() == Qt::MouseButton::LeftButton) {
emit this->doubleClicked();
}
QWidget::mouseDoubleClickEvent(event);
}

View File

@@ -0,0 +1,26 @@
#pragma once
#include <QFrame>
#include <QEvent>
#include <QMouseEvent>
#include "src/Logger/Logger.hpp"
namespace Bloom::Widgets
{
class Q_WIDGETS_EXPORT ClickableWidget: public QFrame
{
Q_OBJECT
protected:
void mouseReleaseEvent(QMouseEvent* event) override;
void mouseDoubleClickEvent(QMouseEvent* event) override;
public:
explicit ClickableWidget(QWidget* parent): QFrame(parent) {};
signals:
void clicked();
void doubleClicked();
};
}