ui: Added style for graph zoom buttons
* moved zoom buttons to QtGraphicsView due to stylesheet and repositioning on resize
This commit is contained in:
@@ -2,3 +2,22 @@ QGraphicsView, QGraphicsScene {
|
||||
background-color: <color:graph/background>;
|
||||
border: none;
|
||||
}
|
||||
|
||||
QPushButton {
|
||||
background: <color:search/button/normal>;
|
||||
border: none;
|
||||
color: white;
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
QPushButton:disabled {
|
||||
background: <color:search/button/disabled>;
|
||||
}
|
||||
|
||||
QPushButton:hover {
|
||||
background: <color:search/button/hover>;
|
||||
}
|
||||
|
||||
QPushButton:pressed {
|
||||
background: <color:search/button/press>;
|
||||
}
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 881 B |
Binary file not shown.
|
After Width: | Height: | Size: 753 B |
@@ -14,7 +14,9 @@
|
||||
#include "qt/view/graphElements/QtGraphNodeData.h"
|
||||
#include "qt/view/graphElements/QtGraphNodeBundle.h"
|
||||
#include "qt/utility/QtContextMenu.h"
|
||||
#include "qt/utility/utilityQt.h"
|
||||
#include "settings/ApplicationSettings.h"
|
||||
#include "utility/ResourcePaths.h"
|
||||
|
||||
QtGraphicsView::QtGraphicsView(QWidget* parent)
|
||||
: QGraphicsView(parent)
|
||||
@@ -25,6 +27,8 @@ QtGraphicsView::QtGraphicsView(QWidget* parent)
|
||||
, m_left(false)
|
||||
, m_right(false)
|
||||
, m_shift(false)
|
||||
, m_zoomInButtonSpeed(20.0f)
|
||||
, m_zoomOutButtonSpeed(-20.0f)
|
||||
{
|
||||
setTransformationAnchor(QGraphicsView::AnchorUnderMouse);
|
||||
|
||||
@@ -44,6 +48,20 @@ QtGraphicsView::QtGraphicsView(QWidget* parent)
|
||||
m_copyNodeNameAction->setStatusTip(tr("Copies the name of this node to the clipboard"));
|
||||
m_copyNodeNameAction->setToolTip(tr("Copies the name of this node to the clipboard"));
|
||||
connect(m_copyNodeNameAction, SIGNAL(triggered()), this, SLOT(copyNodeName()));
|
||||
|
||||
m_zoomInButton = new QPushButton(this);
|
||||
m_zoomInButton->setObjectName("zoom_in_button");
|
||||
m_zoomInButton->setAutoRepeat(true);
|
||||
m_zoomInButton->setToolTip("Zoom in (Shift + Mousewheel forward)");
|
||||
connect(m_zoomInButton, SIGNAL(pressed()), this, SLOT(zoomInPressed()));
|
||||
|
||||
m_zoomOutButton = new QPushButton(this);
|
||||
m_zoomOutButton->setObjectName("zoom_out_button");
|
||||
m_zoomOutButton->setAutoRepeat(true);
|
||||
m_zoomOutButton->setToolTip("Zoom out (Shift + Mousewheel back)");
|
||||
connect(m_zoomOutButton, SIGNAL(pressed()), this, SLOT(zoomOutPressed()));
|
||||
|
||||
refreshStyle();
|
||||
}
|
||||
|
||||
float QtGraphicsView::getZoomFactor() const
|
||||
@@ -118,6 +136,28 @@ void QtGraphicsView::updateZoom(float delta)
|
||||
updateTransform();
|
||||
}
|
||||
|
||||
void QtGraphicsView::refreshStyle()
|
||||
{
|
||||
m_zoomInButton->setIcon(utility::createButtonIcon(
|
||||
ResourcePaths::getGuiPath() + "graph_view/images/zoomin.png",
|
||||
"search/button"
|
||||
));
|
||||
|
||||
m_zoomOutButton->setIcon(utility::createButtonIcon(
|
||||
ResourcePaths::getGuiPath() + "graph_view/images/zoomout.png",
|
||||
"search/button"
|
||||
));
|
||||
}
|
||||
|
||||
void QtGraphicsView::resizeEvent(QResizeEvent* event)
|
||||
{
|
||||
m_zoomInButton->setGeometry(QRect(8, event->size().height() - 50, 19, 19));
|
||||
m_zoomOutButton->setGeometry(QRect(8, event->size().height() - 27, 19, 19));
|
||||
|
||||
m_zoomInButton->setIconSize(QSize(15, 15));
|
||||
m_zoomOutButton->setIconSize(QSize(15, 15));
|
||||
}
|
||||
|
||||
void QtGraphicsView::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
if (event->button() == Qt::LeftButton && !itemAt(event->pos()))
|
||||
@@ -405,6 +445,16 @@ void QtGraphicsView::copyNodeName()
|
||||
QApplication::clipboard()->setText(m_clipboardNodeName.c_str());
|
||||
}
|
||||
|
||||
void QtGraphicsView::zoomInPressed()
|
||||
{
|
||||
updateZoom(m_zoomInButtonSpeed);
|
||||
}
|
||||
|
||||
void QtGraphicsView::zoomOutPressed()
|
||||
{
|
||||
updateZoom(m_zoomOutButtonSpeed);
|
||||
}
|
||||
|
||||
bool QtGraphicsView::moves() const
|
||||
{
|
||||
return m_up || m_down || m_left || m_right;
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <memory>
|
||||
|
||||
#include <QGraphicsView>
|
||||
#include <QPushButton>
|
||||
|
||||
#include "utility/file/FilePath.h"
|
||||
|
||||
@@ -27,9 +28,13 @@ public:
|
||||
|
||||
void updateZoom(float delta);
|
||||
|
||||
void refreshStyle();
|
||||
|
||||
protected:
|
||||
void mousePressEvent(QMouseEvent *event);
|
||||
void mouseReleaseEvent(QMouseEvent *event);
|
||||
void resizeEvent(QResizeEvent* event);
|
||||
|
||||
void mousePressEvent(QMouseEvent* event);
|
||||
void mouseReleaseEvent(QMouseEvent* event);
|
||||
|
||||
void keyPressEvent(QKeyEvent* event);
|
||||
void keyReleaseEvent(QKeyEvent* event);
|
||||
@@ -48,6 +53,9 @@ private slots:
|
||||
void exportGraph();
|
||||
void copyNodeName();
|
||||
|
||||
void zoomInPressed();
|
||||
void zoomOutPressed();
|
||||
|
||||
private:
|
||||
bool moves() const;
|
||||
|
||||
@@ -71,6 +79,12 @@ private:
|
||||
|
||||
QAction* m_exportGraphAction;
|
||||
QAction* m_copyNodeNameAction;
|
||||
|
||||
QPushButton* m_zoomInButton;
|
||||
QPushButton* m_zoomOutButton;
|
||||
|
||||
float m_zoomInButtonSpeed;
|
||||
float m_zoomOutButtonSpeed;
|
||||
};
|
||||
|
||||
#endif // QT_GRAPHICS_VIEW_H
|
||||
|
||||
@@ -40,10 +40,6 @@ QtGraphView::QtGraphView(ViewLayout* viewLayout)
|
||||
, m_refreshFunctor(std::bind(&QtGraphView::doRefreshView, this))
|
||||
, m_focusInFunctor(std::bind(&QtGraphView::doFocusIn, this, std::placeholders::_1))
|
||||
, m_focusOutFunctor(std::bind(&QtGraphView::doFocusOut, this, std::placeholders::_1))
|
||||
, m_zoomInButton()
|
||||
, m_zoomOutButton()
|
||||
, m_zoomInButtonSpeed(20.0f)
|
||||
, m_zoomOutButtonSpeed(-20.0f)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -74,22 +70,6 @@ void QtGraphView::initView()
|
||||
|
||||
widget->layout()->addWidget(view);
|
||||
|
||||
m_zoomInButton = new QPushButton(widget);
|
||||
m_zoomInButton->setObjectName("zoom_in_button");
|
||||
m_zoomInButton->setText("+");
|
||||
m_zoomInButton->setGeometry(QRect(5, 5, 25, 25));
|
||||
m_zoomInButton->setAutoRepeat(true);
|
||||
m_zoomInButton->setToolTip("Zoom in (Shift + Mousewheel forward)");
|
||||
connect(m_zoomInButton, SIGNAL(pressed()), this, SLOT(zoomInPressed()));
|
||||
|
||||
m_zoomOutButton = new QPushButton(widget);
|
||||
m_zoomOutButton->setObjectName("zoom_out_button");
|
||||
m_zoomOutButton->setText("-");
|
||||
m_zoomOutButton->setGeometry(QRect(5, 34, 25, 25));
|
||||
m_zoomOutButton->setAutoRepeat(true);
|
||||
m_zoomOutButton->setToolTip("Zoom out (Shift + Mousewheel back)");
|
||||
connect(m_zoomOutButton, SIGNAL(pressed()), this, SLOT(zoomOutPressed()));
|
||||
|
||||
connect(view, SIGNAL(emptySpaceClicked()), this, SLOT(clickedInEmptySpace()));
|
||||
|
||||
m_scrollSpeedChangeListenerHorizontal.setScrollBar(view->horizontalScrollBar());
|
||||
@@ -101,6 +81,8 @@ void QtGraphView::initView()
|
||||
void QtGraphView::refreshView()
|
||||
{
|
||||
m_refreshFunctor();
|
||||
|
||||
getView()->refreshStyle();
|
||||
}
|
||||
|
||||
void QtGraphView::rebuildGraph(
|
||||
@@ -166,16 +148,6 @@ void QtGraphView::clickedInEmptySpace()
|
||||
}
|
||||
}
|
||||
|
||||
void QtGraphView::zoomInPressed()
|
||||
{
|
||||
zoom(m_zoomInButtonSpeed);
|
||||
}
|
||||
|
||||
void QtGraphView::zoomOutPressed()
|
||||
{
|
||||
zoom(m_zoomOutButtonSpeed);
|
||||
}
|
||||
|
||||
void QtGraphView::switchToNewGraphData()
|
||||
{
|
||||
m_oldGraph = m_graph;
|
||||
@@ -752,12 +724,3 @@ void QtGraphView::doFocusOut(const std::vector<Id>& tokenIds)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void QtGraphView::zoom(const float delta)
|
||||
{
|
||||
QtGraphicsView* view = getView();
|
||||
if (view != NULL)
|
||||
{
|
||||
view->updateZoom(delta);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,8 +6,6 @@
|
||||
#include <QGraphicsView>
|
||||
#include <QPointF>
|
||||
|
||||
#include <QPushButton>
|
||||
|
||||
#include "component/view/GraphView.h"
|
||||
#include "qt/utility/QtScrollSpeedChangeListener.h"
|
||||
#include "qt/utility/QtThreadedFunctor.h"
|
||||
@@ -55,9 +53,6 @@ private slots:
|
||||
void finishedTransition();
|
||||
void clickedInEmptySpace();
|
||||
|
||||
void zoomInPressed();
|
||||
void zoomOutPressed();
|
||||
|
||||
private:
|
||||
void switchToNewGraphData();
|
||||
|
||||
@@ -75,8 +70,6 @@ private:
|
||||
void doFocusIn(const std::vector<Id>& tokenIds);
|
||||
void doFocusOut(const std::vector<Id>& tokenIds);
|
||||
|
||||
void zoom(const float delta);
|
||||
|
||||
std::shared_ptr<QtGraphNode> findNodeRecursive(const std::list<std::shared_ptr<QtGraphNode>>& nodes, Id tokenId);
|
||||
|
||||
std::shared_ptr<QtGraphNode> createNodeRecursive(
|
||||
@@ -125,12 +118,6 @@ private:
|
||||
|
||||
QtScrollSpeedChangeListener m_scrollSpeedChangeListenerHorizontal;
|
||||
QtScrollSpeedChangeListener m_scrollSpeedChangeListenerVertical;
|
||||
|
||||
QPushButton* m_zoomInButton;
|
||||
QPushButton* m_zoomOutButton;
|
||||
|
||||
float m_zoomInButtonSpeed;
|
||||
float m_zoomOutButtonSpeed;
|
||||
};
|
||||
|
||||
#endif // QT_GRAPH_VIEW_H
|
||||
|
||||
Reference in New Issue
Block a user