ui: made icon buttons self updating on color scheme change

* fixed hatching not replaced in single file view title bar on color scheme change
This commit is contained in:
Eberhard Graether
2018-03-19 22:44:45 +01:00
parent 66ac70850b
commit 166d82b44f
41 changed files with 386 additions and 505 deletions
+6 -18
View File
@@ -10,6 +10,7 @@
#include <QPropertyAnimation>
#include <QParallelAnimationGroup>
#include "qt/element/QtIconButton.h"
#include "qt/view/graphElements/QtGraphEdge.h"
#include "qt/view/graphElements/QtGraphNode.h"
#include "qt/view/graphElements/QtGraphNodeData.h"
@@ -78,19 +79,19 @@ QtGraphicsView::QtGraphicsView(QWidget* parent)
m_zoomState->setObjectName("zoom_state");
m_zoomState->hide();
m_zoomInButton = new QPushButton(this);
m_zoomInButton = new QtSelfRefreshIconButton(
"", ResourcePaths::getGuiPath().concatenate(L"graph_view/images/zoom_in.png"), "search/button", this);
m_zoomInButton->setObjectName("zoom_in_button");
m_zoomInButton->setAutoRepeat(true);
m_zoomInButton->setToolTip("Zoom in (" + modifierName + " + Mousewheel forward)");
connect(m_zoomInButton, &QPushButton::pressed, this, &QtGraphicsView::zoomInPressed);
m_zoomOutButton = new QPushButton(this);
m_zoomOutButton = new QtSelfRefreshIconButton(
"", ResourcePaths::getGuiPath().concatenate(L"graph_view/images/zoom_out.png"), "search/button", this);
m_zoomOutButton->setObjectName("zoom_out_button");
m_zoomOutButton->setAutoRepeat(true);
m_zoomOutButton->setToolTip("Zoom out (" + modifierName + " + Mousewheel back)");
connect(m_zoomOutButton, &QPushButton::pressed, this, &QtGraphicsView::zoomOutPressed);
refreshStyle();
}
float QtGraphicsView::getZoomFactor() const
@@ -187,19 +188,6 @@ void QtGraphicsView::updateZoom(float delta)
setZoomFactor(qBound(0.1, newZoom, 100.0));
}
void QtGraphicsView::refreshStyle()
{
m_zoomInButton->setIcon(utility::createButtonIcon(
ResourcePaths::getGuiPath().concatenate(L"graph_view/images/zoom_in.png"),
"search/button"
));
m_zoomOutButton->setIcon(utility::createButtonIcon(
ResourcePaths::getGuiPath().concatenate(L"graph_view/images/zoom_out.png"),
"search/button"
));
}
void QtGraphicsView::resizeEvent(QResizeEvent* event)
{
m_zoomState->setGeometry(QRect(31, event->size().height() - 27, 65, 19));
@@ -477,7 +465,7 @@ void QtGraphicsView::exportGraph()
font.setPixelSize(14);
painter.setFont(font);
}
QRect boundingRect;
painter.drawText(QRect(margin, margin, image.size().width() - 2 * margin, image.size().height() - 2 * margin), Qt::AlignBottom | Qt::AlignHCenter, "Exported from Sourcetrail", &boundingRect);
+4 -5
View File
@@ -4,13 +4,14 @@
#include <memory>
#include <QGraphicsView>
#include <QPushButton>
#include "utility/types.h"
class QPushButton;
class QTimer;
class QtGraphEdge;
class QtGraphNode;
class QtSelfRefreshIconButton;
class QtGraphicsView
: public QGraphicsView
@@ -32,8 +33,6 @@ public:
void updateZoom(float delta);
void refreshStyle();
protected:
void resizeEvent(QResizeEvent* event);
@@ -100,8 +99,8 @@ private:
QAction* m_bookmarkNodeAction;
QPushButton* m_zoomState;
QPushButton* m_zoomInButton;
QPushButton* m_zoomOutButton;
QtSelfRefreshIconButton* m_zoomInButton;
QtSelfRefreshIconButton* m_zoomOutButton;
float m_zoomInButtonSpeed;
float m_zoomOutButtonSpeed;