mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Added a new class to handle the pseudo-buttons on the canvas.
Added a new class, named Button, that has a clicked() signal, and can be connected to the view to emulate buttons. While I know that Qt supports widgets on canvas - I think it's too nineties to have such square controls on something that can have rounded borders. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
This commit is contained in:
parent
01d1a49d94
commit
28f48227f7
2 changed files with 33 additions and 1 deletions
|
@ -43,6 +43,14 @@ DivePlannerGraphics::DivePlannerGraphics(QWidget* parent): QGraphicsView(parent)
|
||||||
depthString = new QGraphicsSimpleTextItem();
|
depthString = new QGraphicsSimpleTextItem();
|
||||||
depthString->setFlag(QGraphicsItem::ItemIgnoresTransformations);
|
depthString->setFlag(QGraphicsItem::ItemIgnoresTransformations);
|
||||||
scene()->addItem(depthString);
|
scene()->addItem(depthString);
|
||||||
|
|
||||||
|
plusDepth = new Button();
|
||||||
|
plusDepth->setPos(15, 1);
|
||||||
|
scene()->addItem(plusDepth);
|
||||||
|
|
||||||
|
plusTime = new Button();
|
||||||
|
plusTime->setPos( 95, 90);
|
||||||
|
scene()->addItem(plusTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DivePlannerGraphics::mouseDoubleClickEvent(QMouseEvent* event)
|
void DivePlannerGraphics::mouseDoubleClickEvent(QMouseEvent* event)
|
||||||
|
@ -352,3 +360,13 @@ double Ruler::minimum() const
|
||||||
return min;
|
return min;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Button::Button(QObject* parent): QObject(parent), QGraphicsPixmapItem()
|
||||||
|
{
|
||||||
|
setPixmap(QPixmap(":plus").scaled(20,20));
|
||||||
|
setFlag(ItemIgnoresTransformations);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Button::mousePressEvent(QGraphicsSceneMouseEvent* event)
|
||||||
|
{
|
||||||
|
emit clicked();
|
||||||
|
}
|
||||||
|
|
|
@ -5,6 +5,16 @@
|
||||||
#include <QGraphicsPathItem>
|
#include <QGraphicsPathItem>
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
|
||||||
|
class Button : public QObject, public QGraphicsPixmapItem {
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit Button(QObject* parent = 0);
|
||||||
|
protected:
|
||||||
|
virtual void mousePressEvent(QGraphicsSceneMouseEvent* event);
|
||||||
|
signals:
|
||||||
|
void clicked();
|
||||||
|
};
|
||||||
|
|
||||||
class DiveHandler : public QGraphicsEllipseItem{
|
class DiveHandler : public QGraphicsEllipseItem{
|
||||||
public:
|
public:
|
||||||
DiveHandler();
|
DiveHandler();
|
||||||
|
@ -52,7 +62,6 @@ protected:
|
||||||
void clear_generated_deco();
|
void clear_generated_deco();
|
||||||
void create_deco_stop();
|
void create_deco_stop();
|
||||||
bool isPointOutOfBoundaries(const QPointF& point);
|
bool isPointOutOfBoundaries(const QPointF& point);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void moveActiveHandler(const QPointF& pos);
|
void moveActiveHandler(const QPointF& pos);
|
||||||
|
@ -68,6 +77,11 @@ private:
|
||||||
Ruler *depthLine;
|
Ruler *depthLine;
|
||||||
QGraphicsSimpleTextItem *depthString;
|
QGraphicsSimpleTextItem *depthString;
|
||||||
|
|
||||||
|
Button *plusTime;
|
||||||
|
Button *plusDepth;
|
||||||
|
Button *lessTime;
|
||||||
|
Button *lessDepth;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace Ui{
|
namespace Ui{
|
||||||
|
|
Loading…
Add table
Reference in a new issue