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
+1 -1
View File
@@ -39,7 +39,7 @@ QtListItemWidget #field:disabled {
border-top: 1px solid lightgray;
}
#iconButton, #dotsButton, #plusButton, #minusButton, #editButton {
#helpButton, #dotsButton, #plusButton, #minusButton, #editButton {
border: none;
color: white;
height: 1em;
+1 -1
View File
@@ -72,7 +72,7 @@ QCheckBox:disabled {
background: transparent;
}
#iconButton, #dotsButton {
#helpButton, #dotsButton {
border: none;
color: white;
height: 1em;
+5
View File
@@ -18,6 +18,11 @@ ColorScheme::~ColorScheme()
{
}
bool ColorScheme::hasColor(const std::string& key) const
{
return isValueDefined(key);
}
std::string ColorScheme::getColor(const std::string& key) const
{
return getValue<std::string>(key, "#FF1493");
+2
View File
@@ -19,6 +19,8 @@ public:
static std::shared_ptr<ColorScheme> getInstance();
virtual ~ColorScheme();
bool hasColor(const std::string& key) const;
std::string getColor(const std::string& key) const;
std::string getColor(const std::string& key, const std::string& defaultColor) const;
+2 -2
View File
@@ -45,12 +45,12 @@ add_files(
qt/element/QtLocationPicker.h
qt/element/QtProgressBar.cpp
qt/element/QtProgressBar.h
qt/element/QtRefreshBar.cpp
qt/element/QtRefreshBar.h
qt/element/QtScreenSearchBox.cpp
qt/element/QtScreenSearchBox.h
qt/element/QtSearchBar.cpp
qt/element/QtSearchBar.h
qt/element/QtSearchBarButton.cpp
qt/element/QtSearchBarButton.h
qt/element/QtSmartSearchBox.cpp
qt/element/QtSmartSearchBox.h
qt/element/QtStatusBar.cpp
+1 -1
View File
@@ -30,7 +30,7 @@ public:
void clearFile();
void clearCache();
// QtCodeNaviatebale implementation
// QtCodeNavigateable implementation
virtual QAbstractScrollArea* getScrollArea() override;
virtual void addCodeSnippet(const CodeSnippetParams& params) override;
@@ -60,21 +60,21 @@ QtCodeFileTitleBar::QtCodeFileTitleBar(QWidget* parent, bool isHovering, bool is
QColor inactiveColor(0x5E, 0x5D, 0x5D);
m_minimizeButton = new QtIconStateButton(this);
m_minimizeButton->addState(QtIconStateButton::STATE_DEFAULT, (QString::fromStdWString(imageDir.getConcatenated(L"minimize_active.png").wstr())));
m_minimizeButton->addState(QtIconStateButton::STATE_HOVERED, (QString::fromStdWString(imageDir.getConcatenated(L"minimize_inactive.png").wstr())), inactiveColor);
m_minimizeButton->addState(QtIconStateButton::STATE_DISABLED, (QString::fromStdWString(imageDir.getConcatenated(L"minimize_inactive.png").wstr())));
m_minimizeButton->addState(QtIconStateButton::STATE_DEFAULT, imageDir.getConcatenated(L"minimize_active.png"));
m_minimizeButton->addState(QtIconStateButton::STATE_HOVERED, imageDir.getConcatenated(L"minimize_inactive.png"), inactiveColor);
m_minimizeButton->addState(QtIconStateButton::STATE_DISABLED, imageDir.getConcatenated(L"minimize_inactive.png"));
m_minimizeButton->setToolTip("minimize");
m_snippetButton = new QtIconStateButton(this);
m_snippetButton->addState(QtIconStateButton::STATE_DEFAULT, (QString::fromStdWString(imageDir.getConcatenated(L"snippet_active.png").wstr())));
m_snippetButton->addState(QtIconStateButton::STATE_HOVERED, (QString::fromStdWString(imageDir.getConcatenated(L"snippet_inactive.png").wstr())), inactiveColor);
m_snippetButton->addState(QtIconStateButton::STATE_DISABLED, (QString::fromStdWString(imageDir.getConcatenated(L"snippet_inactive.png").wstr())));
m_snippetButton->addState(QtIconStateButton::STATE_DEFAULT, imageDir.getConcatenated(L"snippet_active.png"));
m_snippetButton->addState(QtIconStateButton::STATE_HOVERED, imageDir.getConcatenated(L"snippet_inactive.png"), inactiveColor);
m_snippetButton->addState(QtIconStateButton::STATE_DISABLED, imageDir.getConcatenated(L"snippet_inactive.png"));
m_snippetButton->setToolTip("show snippets");
m_maximizeButton = new QtIconStateButton(this);
m_maximizeButton->addState(QtIconStateButton::STATE_DEFAULT, (QString::fromStdWString(imageDir.getConcatenated(L"maximize_active.png").wstr())));
m_maximizeButton->addState(QtIconStateButton::STATE_HOVERED, (QString::fromStdWString(imageDir.getConcatenated(L"maximize_inactive.png").wstr())), inactiveColor);
m_maximizeButton->addState(QtIconStateButton::STATE_DISABLED, (QString::fromStdWString(imageDir.getConcatenated(L"maximize_inactive.png").wstr())));
m_maximizeButton->addState(QtIconStateButton::STATE_DEFAULT, imageDir.getConcatenated(L"maximize_active.png"));
m_maximizeButton->addState(QtIconStateButton::STATE_HOVERED, imageDir.getConcatenated(L"maximize_inactive.png"), inactiveColor);
m_maximizeButton->addState(QtIconStateButton::STATE_DISABLED, imageDir.getConcatenated(L"maximize_inactive.png"));
m_maximizeButton->setToolTip("maximize");
for (QtIconStateButton* button : { m_minimizeButton, m_snippetButton, m_maximizeButton })
@@ -3,22 +3,20 @@
#include "utility/file/FileSystem.h"
#include "utility/messaging/type/MessageActivateFile.h"
#include "utility/messaging/type/MessageProjectEdit.h"
#include "utility/ResourcePaths.h"
#include "utility/utilityString.h"
#include "Application.h"
#include "project/Project.h"
#include "qt/utility/QtContextMenu.h"
#include "qt/utility/utilityQt.h"
#include "settings/ColorScheme.h"
#include "utility/ResourcePaths.h"
#include "utility/utilityString.h"
QtCodeFileTitleButton::QtCodeFileTitleButton(QWidget* parent)
: QPushButton(parent)
: QtSelfRefreshIconButton("", FilePath(), "code/file/title", parent)
, m_isComplete(true)
{
setObjectName("title_button");
minimumSizeHint(); // force font loading
setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac
setFixedHeight(std::max(fontMetrics().height() * 1.2, 28.0));
setSizePolicy(sizePolicy().horizontalPolicy(), QSizePolicy::Fixed);
@@ -43,11 +41,7 @@ void QtCodeFileTitleButton::setFilePath(const FilePath& filePath)
if (m_filePath.empty())
{
FilePath iconPath = ResourcePaths::getGuiPath().concatenate(L"code_view/images/file.png");
setIcon(utility::colorizePixmap(
QPixmap(QString::fromStdWString(iconPath.wstr())),
ColorScheme::getInstance()->getColor("code/file/title/icon").c_str()
));
setIconPath(ResourcePaths::getGuiPath().concatenate(L"code_view/images/file.png"));
}
m_filePath = filePath;
@@ -68,10 +62,7 @@ void QtCodeFileTitleButton::setProject(const std::wstring& name)
setText(QString::fromStdWString(name));
setToolTip("edit project");
setIcon(utility::colorizePixmap(
QPixmap(QString::fromStdWString(ResourcePaths::getGuiPath().concatenate(L"code_view/images/edit.png").wstr())),
ColorScheme::getInstance()->getColor("code/file/title/icon").c_str()
));
setIconPath(ResourcePaths::getGuiPath().concatenate(L"code_view/images/edit.png"));
}
bool QtCodeFileTitleButton::isComplete() const
@@ -89,20 +80,7 @@ void QtCodeFileTitleButton::setIsComplete(bool isComplete)
m_isComplete = isComplete;
setProperty("complete", isComplete);
if (!isComplete)
{
FilePath hatchingFilePath = ResourcePaths::getGuiPath().concatenate(L"code_view/images/pattern_" +
utility::decodeFromUtf8(ColorScheme::getInstance()->getColor("code/file/title/hatching")) + L".png"
);
setStyleSheet(QString::fromStdWString(
L"#title_button { background-image: url(" + hatchingFilePath.wstr() + L"); }"
));
}
else
{
setStyleSheet("");
}
updateHatching();
}
void QtCodeFileTitleButton::updateTexts()
@@ -167,6 +145,13 @@ void QtCodeFileTitleButton::contextMenuEvent(QContextMenuEvent* event)
menu.show();
}
void QtCodeFileTitleButton::refresh()
{
QtSelfRefreshIconButton::refresh();
updateHatching();
}
void QtCodeFileTitleButton::clickedTitle()
{
if (!m_filePath.empty())
@@ -178,3 +163,21 @@ void QtCodeFileTitleButton::clickedTitle()
MessageProjectEdit().dispatch();
}
}
void QtCodeFileTitleButton::updateHatching()
{
if (!m_isComplete)
{
FilePath hatchingFilePath = ResourcePaths::getGuiPath().concatenate(L"code_view/images/pattern_" +
utility::decodeFromUtf8(ColorScheme::getInstance()->getColor("code/file/title/hatching")) + L".png"
);
setStyleSheet(QString::fromStdWString(
L"#title_button { background-image: url(" + hatchingFilePath.wstr() + L"); }"
));
}
else
{
setStyleSheet("");
}
}
@@ -1,13 +1,13 @@
#ifndef QT_CODE_FILE_TITLE_BUTTON_H
#define QT_CODE_FILE_TITLE_BUTTON_H
#include <QPushButton>
#include "utility/file/FilePath.h"
#include "utility/TimeStamp.h"
#include "qt/element/QtIconButton.h"
class QtCodeFileTitleButton
: public QPushButton
: public QtSelfRefreshIconButton
{
Q_OBJECT
@@ -25,16 +25,19 @@ public:
void setIsComplete(bool isComplete);
void updateTexts();
void updateFromOther(const QtCodeFileTitleButton* other);
protected:
void contextMenuEvent(QContextMenuEvent* event);
virtual void refresh();
private slots:
void clickedTitle();
private:
void updateHatching();
FilePath m_filePath;
TimeStamp m_modificationTime;
bool m_isComplete;
+11 -45
View File
@@ -2,7 +2,6 @@
#include <QHBoxLayout>
#include <QLabel>
#include <QPushButton>
#include <QScrollBar>
#include <QTimer>
#include <QVBoxLayout>
@@ -18,7 +17,7 @@
#include "qt/element/QtCodeArea.h"
#include "qt/element/QtCodeFile.h"
#include "qt/element/QtCodeSnippet.h"
#include "qt/utility/utilityQt.h"
#include "qt/element/QtSearchBarButton.h"
#include "settings/ApplicationSettings.h"
QtCodeNavigator::QtCodeNavigator(QWidget* parent)
@@ -45,8 +44,8 @@ QtCodeNavigator::QtCodeNavigator(QWidget* parent)
navLayout->setContentsMargins(7, 7, 7, 6);
m_prevButton = new QPushButton();
m_nextButton = new QPushButton();
m_prevButton = new QtSearchBarButton(ResourcePaths::getGuiPath().concatenate(L"code_view/images/arrow_left.png"), true);
m_nextButton = new QtSearchBarButton(ResourcePaths::getGuiPath().concatenate(L"code_view/images/arrow_right.png"), true);
m_prevButton->setObjectName("reference_button_previous");
m_nextButton->setObjectName("reference_button_next");
@@ -54,6 +53,9 @@ QtCodeNavigator::QtCodeNavigator(QWidget* parent)
m_prevButton->setToolTip("previous reference");
m_nextButton->setToolTip("next reference");
m_prevButton->setIconSize(QSize(12, 12));
m_nextButton->setIconSize(QSize(12, 12));
navLayout->addWidget(m_prevButton);
navLayout->addWidget(m_nextButton);
@@ -68,8 +70,8 @@ QtCodeNavigator::QtCodeNavigator(QWidget* parent)
navLayout->addStretch();
m_listButton = new QPushButton();
m_fileButton = new QPushButton();
m_listButton = new QtSearchBarButton(ResourcePaths::getGuiPath().concatenate(L"code_view/images/list.png"), true);
m_fileButton = new QtSearchBarButton(ResourcePaths::getGuiPath().concatenate(L"code_view/images/file.png"), true);
m_listButton->setObjectName("mode_button_list");
m_fileButton->setObjectName("mode_button_single");
@@ -80,6 +82,9 @@ QtCodeNavigator::QtCodeNavigator(QWidget* parent)
m_listButton->setCheckable(true);
m_fileButton->setCheckable(true);
m_listButton->setIconSize(QSize(14, 14));
m_fileButton->setIconSize(QSize(14, 14));
navLayout->addWidget(m_listButton);
navLayout->addWidget(m_fileButton);
@@ -108,8 +113,6 @@ QtCodeNavigator::QtCodeNavigator(QWidget* parent)
setMode(ApplicationSettings::getInstance()->getCodeViewModeSingle() ? MODE_SINGLE : MODE_LIST);
showContents();
refreshStyle();
connect(this, &QtCodeNavigator::scrollRequest, this, &QtCodeNavigator::handleScrollRequest, Qt::QueuedConnection);
}
@@ -559,43 +562,6 @@ void QtCodeNavigator::showContents()
m_current->showContents();
}
void QtCodeNavigator::refreshStyle()
{
float height = std::max(ApplicationSettings::getInstance()->getFontSize() + 10, 24);
m_prevButton->setFixedHeight(height);
m_nextButton->setFixedHeight(height);
m_listButton->setFixedHeight(height);
m_fileButton->setFixedHeight(height);
m_prevButton->setIcon(utility::createButtonIcon(
ResourcePaths::getGuiPath().concatenate(L"code_view/images/arrow_left.png"),
"search/button"
));
m_nextButton->setIcon(utility::createButtonIcon(
ResourcePaths::getGuiPath().concatenate(L"code_view/images/arrow_right.png"),
"search/button"
));
m_listButton->setIcon(utility::createButtonIcon(
ResourcePaths::getGuiPath().concatenate(L"code_view/images/list.png"),
"search/button"
));
m_fileButton->setIcon(utility::createButtonIcon(
ResourcePaths::getGuiPath().concatenate(L"code_view/images/file.png"),
"search/button"
));
m_prevButton->setIconSize(QSize(12, 12));
m_nextButton->setIconSize(QSize(12, 12));
m_listButton->setIconSize(QSize(14, 14));
m_fileButton->setIconSize(QSize(14, 14));
clearCaches();
}
size_t QtCodeNavigator::findScreenMatches(const std::wstring& query)
{
clearScreenMatches();
+6 -4
View File
@@ -17,6 +17,7 @@
class QLabel;
class QPushButton;
class QtSearchBarButton;
class SourceLocationCollection;
class SourceLocationFile;
@@ -187,11 +188,12 @@ private:
int m_value;
QPushButton* m_listButton;
QPushButton* m_fileButton;
QtSearchBarButton* m_listButton;
QtSearchBarButton* m_fileButton;
QLabel* m_refLabel;
QPushButton* m_prevButton;
QPushButton* m_nextButton;
QtSearchBarButton* m_prevButton;
QtSearchBarButton* m_nextButton;
QFrame* m_separatorLine;
std::vector<Reference> m_references;
@@ -30,8 +30,8 @@ QtListItemWidget::QtListItemWidget(QtDirectoryListBox* list, QListWidgetItem* it
m_data->setAcceptDrops(false);
m_button = new QtIconButton(
QString::fromStdWString(ResourcePaths::getGuiPath().concatenate(L"window/dots.png").wstr()),
QString::fromStdWString(ResourcePaths::getGuiPath().concatenate(L"window/dots_hover.png").wstr())
ResourcePaths::getGuiPath().concatenate(L"window/dots.png"),
ResourcePaths::getGuiPath().concatenate(L"window/dots_hover.png")
);
m_button->setIconSize(QSize(16, 16));
m_button->setObjectName("dotsButton");
@@ -153,8 +153,8 @@ QtDirectoryListBox::QtDirectoryListBox(QWidget *parent, const QString& listName,
innerLayout->setSpacing(0);
m_addButton = new QtIconButton(
QString::fromStdWString(ResourcePaths::getGuiPath().concatenate(L"window/plus.png").wstr()),
QString::fromStdWString(ResourcePaths::getGuiPath().concatenate(L"window/plus_hover.png").wstr())
ResourcePaths::getGuiPath().concatenate(L"window/plus.png"),
ResourcePaths::getGuiPath().concatenate(L"window/plus_hover.png")
);
m_addButton->setIconSize(QSize(16, 16));
m_addButton->setObjectName("plusButton");
@@ -162,8 +162,8 @@ QtDirectoryListBox::QtDirectoryListBox(QWidget *parent, const QString& listName,
innerLayout->addWidget(m_addButton);
m_removeButton = new QtIconButton(
QString::fromStdWString(ResourcePaths::getGuiPath().concatenate(L"window/minus.png").wstr()),
QString::fromStdWString(ResourcePaths::getGuiPath().concatenate(L"window/minus_hover.png").wstr())
ResourcePaths::getGuiPath().concatenate(L"window/minus.png"),
ResourcePaths::getGuiPath().concatenate(L"window/minus_hover.png")
);
m_removeButton->setIconSize(QSize(16, 16));
m_removeButton->setObjectName("minusButton");
@@ -179,8 +179,8 @@ QtDirectoryListBox::QtDirectoryListBox(QWidget *parent, const QString& listName,
innerLayout->addWidget(dropInfoText);
QPushButton* editButton = new QtIconButton(
QString::fromStdWString(ResourcePaths::getGuiPath().concatenate(L"code_view/images/edit.png").wstr()),
QString()
ResourcePaths::getGuiPath().concatenate(L"code_view/images/edit.png"),
FilePath()
);
editButton->setIconSize(QSize(16, 16));
editButton->setObjectName("editButton");
+3 -2
View File
@@ -6,8 +6,8 @@
QtHelpButton::QtHelpButton(const QString& helpTitle, const QString& helpText, QWidget* parent)
: QtIconButton(
QString::fromStdWString(ResourcePaths::getGuiPath().concatenate(L"window/help.png").wstr()),
QString::fromStdWString(ResourcePaths::getGuiPath().concatenate(L"window/help_hover.png").wstr()),
ResourcePaths::getGuiPath().concatenate(L"window/help.png"),
ResourcePaths::getGuiPath().concatenate(L"window/help_hover.png"),
parent)
, m_helpTitle(helpTitle)
, m_helpText(helpText)
@@ -18,6 +18,7 @@ QtHelpButton::QtHelpButton(const QString& helpTitle, const QString& helpText, QW
setToolTip("help");
setIconSize(QSize(16, 16));
setObjectName("helpButton");
leaveEvent(nullptr);
+52 -9
View File
@@ -3,6 +3,7 @@
#include <QEvent>
#include "qt/utility/utilityQt.h"
#include "settings/ColorScheme.h"
QtHoverButton::QtHoverButton(QWidget* parent)
@@ -29,7 +30,7 @@ void QtHoverButton::leaveEvent(QEvent *event)
}
QtIconButton::QtIconButton(QString iconPath, QString hoveredIconPath, QWidget* parent)
QtIconButton::QtIconButton(const FilePath& iconPath, const FilePath& hoveredIconPath, QWidget* parent)
: QPushButton("", parent)
, m_iconPath(iconPath)
, m_hoveredIconPath(hoveredIconPath)
@@ -37,9 +38,11 @@ QtIconButton::QtIconButton(QString iconPath, QString hoveredIconPath, QWidget* p
{
setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac
setMouseTracking(true);
setObjectName("iconButton");
if (!m_hoveredIconPath.empty())
{
setMouseTracking(true);
}
leaveEvent(nullptr);
}
@@ -52,7 +55,7 @@ void QtIconButton::setColor(QColor color)
void QtIconButton::enterEvent(QEvent *event)
{
if (m_hoveredIconPath.size() && isEnabled())
if (!m_hoveredIconPath.empty() && isEnabled())
{
setIconFromPath(m_hoveredIconPath);
}
@@ -60,15 +63,15 @@ void QtIconButton::enterEvent(QEvent *event)
void QtIconButton::leaveEvent(QEvent *event)
{
if (m_iconPath.size())
if (!m_iconPath.empty())
{
setIconFromPath(m_iconPath);
}
}
void QtIconButton::setIconFromPath(QString path)
void QtIconButton::setIconFromPath(const FilePath& path)
{
QPixmap pixmap = QPixmap(path);
QPixmap pixmap = QPixmap(QString::fromStdWString(path.wstr()));
if (m_color != Qt::transparent)
{
@@ -79,6 +82,46 @@ void QtIconButton::setIconFromPath(QString path)
}
QtSelfRefreshIconButton::QtSelfRefreshIconButton(
const QString& text, const FilePath& iconPath, const std::string& buttonKey, QWidget* parent
)
: QPushButton(text, parent)
, m_iconPath(iconPath)
, m_buttonKey(buttonKey)
{
setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac
refresh();
}
void QtSelfRefreshIconButton::setIconPath(const FilePath& iconPath)
{
if (iconPath != m_iconPath)
{
m_iconPath = iconPath;
refresh();
}
}
void QtSelfRefreshIconButton::handleMessage(MessageRefresh* message)
{
if (message->uiOnly)
{
m_onQtThread([this]()
{
refresh();
});
}
}
void QtSelfRefreshIconButton::refresh()
{
if (!m_iconPath.empty())
{
setIcon(utility::createButtonIcon(m_iconPath, m_buttonKey));
}
}
QtIconStateButton::QtIconStateButton(QWidget* parent)
: QPushButton("", parent)
{
@@ -91,7 +134,7 @@ QtIconStateButton::QtIconStateButton(QWidget* parent)
leaveEvent(nullptr);
}
void QtIconStateButton::addState(ButtonState buttonState, QString iconPath, QColor color)
void QtIconStateButton::addState(ButtonState buttonState, const FilePath& iconPath, QColor color)
{
State state;
state.iconPath = iconPath;
@@ -168,7 +211,7 @@ void QtIconStateButton::leaveEvent(QEvent *event)
void QtIconStateButton::setState(State state)
{
QPixmap pixmap = QPixmap(state.iconPath);
QPixmap pixmap = QPixmap(QString::fromStdWString(state.iconPath.wstr()));
if (state.color != Qt::transparent)
{
+37 -6
View File
@@ -3,6 +3,12 @@
#include <QPushButton>
#include "utility/file/FilePath.h"
#include "utility/messaging/MessageListener.h"
#include "utility/messaging/type/MessageRefresh.h"
#include "qt/utility/QtThreadedFunctor.h"
class QtHoverButton
: public QPushButton
{
@@ -26,7 +32,8 @@ class QtIconButton
{
Q_OBJECT
public:
QtIconButton(QString iconPath, QString hoveredIconPath, QWidget* parent = nullptr);
QtIconButton(const FilePath& iconPath, const FilePath& hoveredIconPath, QWidget* parent = nullptr);
~QtIconButton() = default;
void setColor(QColor color);
@@ -35,15 +42,39 @@ protected:
void leaveEvent(QEvent *event);
private:
void setIconFromPath(QString path);
void setIconFromPath(const FilePath& path);
QString m_iconPath;
QString m_hoveredIconPath;
const FilePath m_iconPath;
const FilePath m_hoveredIconPath;
QColor m_color;
};
class QtSelfRefreshIconButton
: public QPushButton
, public MessageListener<MessageRefresh>
{
public:
QtSelfRefreshIconButton(
const QString& text, const FilePath& iconPath, const std::string& buttonKey, QWidget* parent = nullptr);
~QtSelfRefreshIconButton() = default;
void setIconPath(const FilePath& iconPath);
protected:
void handleMessage(MessageRefresh* message);
virtual void refresh();
private:
QtThreadedLambdaFunctor m_onQtThread;
FilePath m_iconPath;
const std::string m_buttonKey;
};
class QtIconStateButton
: public QPushButton
{
@@ -59,13 +90,13 @@ public:
struct State
{
QString iconPath;
FilePath iconPath;
QColor color;
};
QtIconStateButton(QWidget* parent = nullptr);
void addState(ButtonState buttonState, QString iconPath, QColor color = Qt::transparent);
void addState(ButtonState buttonState, const FilePath& iconPath, QColor color = Qt::transparent);
void hoverIn();
void hoverOut();
+2 -2
View File
@@ -28,8 +28,8 @@ QtLocationPicker::QtLocationPicker(QWidget *parent)
layout->addWidget(m_data);
m_button = new QtIconButton(
QString::fromStdWString(ResourcePaths::getGuiPath().concatenate(L"window/dots.png").wstr()),
QString::fromStdWString(ResourcePaths::getGuiPath().concatenate(L"window/dots_hover.png").wstr())
ResourcePaths::getGuiPath().concatenate(L"window/dots.png"),
ResourcePaths::getGuiPath().concatenate(L"window/dots_hover.png")
);
m_button->setIconSize(QSize(16, 16));
m_button->setObjectName("dotsButton");
-56
View File
@@ -1,56 +0,0 @@
#include "qt/element/QtRefreshBar.h"
#include <QHBoxLayout>
#include <QPushButton>
#include "utility/messaging/type/MessageRefresh.h"
#include "utility/ResourcePaths.h"
#include "qt/utility/utilityQt.h"
#include "settings/ApplicationSettings.h"
QtRefreshBar::QtRefreshBar()
{
setObjectName("refresh_bar");
QBoxLayout* layout = new QHBoxLayout();
layout->setSpacing(0);
layout->setContentsMargins(0, 0, 0, 0);
layout->setAlignment(Qt::AlignTop);
setLayout(layout);
m_refreshButton = new QPushButton(this);
m_refreshButton->setObjectName("refresh_button");
m_refreshButton->setToolTip("refresh");
m_refreshButton->setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac
layout->addWidget(m_refreshButton);
connect(m_refreshButton, &QPushButton::clicked, this, &QtRefreshBar::refreshClicked);
refreshStyle();
}
QtRefreshBar::~QtRefreshBar()
{
}
void QtRefreshBar::refreshClicked()
{
MessageRefresh().dispatch();
}
void QtRefreshBar::refreshStyle()
{
float height = std::max(ApplicationSettings::getInstance()->getFontSize() + 16, 30);
m_refreshButton->setFixedHeight(height);
m_refreshButton->setIcon(utility::createButtonIcon(
ResourcePaths::getGuiPath().concatenate(L"refresh_view/images/refresh.png"),
"search/button"
));
int iconSize = int(height / 4) * 2 + 2;
m_refreshButton->setIconSize(QSize(iconSize, iconSize));
}
-30
View File
@@ -1,30 +0,0 @@
#ifndef QT_REFRESH_BAR_H
#define QT_REFRESH_BAR_H
#include <QFrame>
#include "qt/utility/QtThreadedFunctor.h"
class QPushButton;
class QtRefreshBar
: public QFrame
{
Q_OBJECT
public:
QtRefreshBar();
virtual ~QtRefreshBar();
void refreshStyle();
private slots:
void refreshClicked();
private:
QtThreadedLambdaFunctor m_onQtThread;
QPushButton* m_refreshButton;
};
#endif // QT_REFRESH_BAR_H
+3 -28
View File
@@ -1,14 +1,12 @@
#include "qt/element/QtSearchBar.h"
#include <QHBoxLayout>
#include <QPushButton>
#include "utility/messaging/type/MessageSearch.h"
#include "utility/ResourcePaths.h"
#include "qt/element/QtSearchBarButton.h"
#include "qt/element/QtSmartSearchBox.h"
#include "qt/utility/utilityQt.h"
#include "settings/ApplicationSettings.h"
QtSearchBar::QtSearchBar()
{
@@ -20,16 +18,14 @@ QtSearchBar::QtSearchBar()
layout->setAlignment(Qt::AlignTop);
setLayout(layout);
m_homeButton = new QPushButton(this);
m_homeButton = new QtSearchBarButton(ResourcePaths::getGuiPath().concatenate(L"search_view/images/home.png"));
m_homeButton->setObjectName("home_button");
m_homeButton->setToolTip("to overview");
m_homeButton->setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac
layout->addWidget(m_homeButton);
connect(m_homeButton, &QPushButton::clicked, this, &QtSearchBar::homeButtonClicked);
m_searchBoxContainer = new QWidget(this);
m_searchBoxContainer->setObjectName("search_box_container");
m_searchBoxContainer->setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac
m_searchBoxContainer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
layout->addWidget(m_searchBoxContainer);
@@ -39,16 +35,14 @@ QtSearchBar::QtSearchBar()
m_searchBox = new QtSmartSearchBox(m_searchBoxContainer);
m_searchBox->setObjectName("search_box");
m_searchBox->setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac
m_searchBox->setAttribute(Qt::WA_MacShowFocusRect, 0); // remove blue focus box on Mac
m_searchBox->setMinimumWidth(100);
m_searchBox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
innerLayout->addWidget(m_searchBox);
m_searchButton = new QPushButton(this);
m_searchButton = new QtSearchBarButton(ResourcePaths::getGuiPath().concatenate(L"search_view/images/search.png"));
m_searchButton->setObjectName("search_button");
m_searchButton->setToolTip("search");
m_searchButton->setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac
layout->addWidget(m_searchButton);
connect(m_searchButton, &QPushButton::clicked, m_searchBox, &QtSmartSearchBox::search);
@@ -97,25 +91,6 @@ QAbstractItemView* QtSearchBar::getCompleterPopup()
void QtSearchBar::refreshStyle()
{
m_searchBox->setFixedHeight(std::max(ApplicationSettings::getInstance()->getFontSize() + 11, 25));
m_searchButton->setFixedHeight(m_searchBox->height() + 5);
m_homeButton->setFixedHeight(m_searchBox->height() + 5);
m_searchButton->setIcon(utility::createButtonIcon(
ResourcePaths::getGuiPath().concatenate(L"search_view/images/search.png"),
"search/button"
));
m_homeButton->setIcon(utility::createButtonIcon(
ResourcePaths::getGuiPath().concatenate(L"search_view/images/home.png"),
"search/button"
));
int iconSize = int((m_searchBox->height() + 5) / 4) * 2 + 2;
m_searchButton->setIconSize(QSize(iconSize, iconSize));
m_homeButton->setIconSize(QSize(iconSize, iconSize));
m_searchBox->refreshStyle();
}
+5 -3
View File
@@ -8,7 +8,7 @@
#include "data/search/SearchMatch.h"
class QPushButton;
class QtSearchBarButton;
class QtSmartSearchBox;
class QtSearchBar
@@ -38,9 +38,11 @@ private slots:
private:
QWidget* m_searchBoxContainer; // used for correct clipping inside the search box
QtSmartSearchBox* m_searchBox;
QPushButton* m_searchButton;
QPushButton* m_homeButton;
QtSearchBarButton* m_searchButton;
QtSearchBarButton* m_homeButton;
};
#endif // QT_SEARCH_BAR_H
@@ -0,0 +1,25 @@
#include "qt/element/QtSearchBarButton.h"
#include "settings/ApplicationSettings.h"
QtSearchBarButton::QtSearchBarButton(const FilePath& iconPath, bool small, QWidget* parent)
: QtSelfRefreshIconButton("", iconPath, "search/button", parent)
, m_small(small)
{
}
void QtSearchBarButton::refresh()
{
QtSelfRefreshIconButton::refresh();
int size = m_small ? 10 : 16;
float height = std::max(ApplicationSettings::getInstance()->getFontSize() + size, size + 14);
setFixedHeight(height);
if (!m_small)
{
int iconSize = int(height / 4) * 2 + 2;
setIconSize(QSize(iconSize, iconSize));
}
}
@@ -0,0 +1,19 @@
#ifndef QT_SEARCH_BAR_BUTTON_H
#define QT_SEARCH_BAR_BUTTON_H
#include "qt/element/QtIconButton.h"
class QtSearchBarButton
: public QtSelfRefreshIconButton
{
public:
QtSearchBarButton(const FilePath& iconPath, bool small = false, QWidget* parent = nullptr);
protected:
void refresh() override;
private:
bool m_small;
};
#endif // QT_SEARCH_BAR_BUTTON_H
+23 -60
View File
@@ -1,6 +1,5 @@
#include "qt/element/QtUndoRedo.h"
#include <QPushButton>
#include <QHBoxLayout>
#include <QTimer>
@@ -9,9 +8,8 @@
#include "utility/ResourcePaths.h"
#include "qt/element/QtHistoryList.h"
#include "qt/utility/utilityQt.h"
#include "qt/element/QtSearchBarButton.h"
#include "qt/utility/QtContextMenu.h"
#include "settings/ApplicationSettings.h"
QtUndoRedo::QtUndoRedo()
: m_pressed(false)
@@ -20,22 +18,19 @@ QtUndoRedo::QtUndoRedo()
{
setObjectName("undo_redo_bar");
m_undoButton = new QPushButton(this);
m_undoButton = new QtSearchBarButton(ResourcePaths::getGuiPath().concatenate(L"undoredo_view/images/arrow_left.png"));
m_undoButton->setObjectName("undo_button");
m_undoButton->setToolTip("back");
m_undoButton->setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac
m_undoButton->setEnabled(false);
m_historyButton = new QPushButton(this);
m_historyButton = new QtSearchBarButton(ResourcePaths::getGuiPath().concatenate(L"undoredo_view/images/history.png"));
m_historyButton->setObjectName("history_button");
m_historyButton->setToolTip("history");
m_historyButton->setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac
m_historyButton->setEnabled(false);
m_redoButton = new QPushButton(this);
m_redoButton = new QtSearchBarButton(ResourcePaths::getGuiPath().concatenate(L"undoredo_view/images/arrow_right.png"));
m_redoButton->setObjectName("redo_button");
m_redoButton->setToolTip("forward");
m_redoButton->setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac
m_redoButton->setEnabled(false);
QBoxLayout* layout = new QHBoxLayout();
@@ -54,14 +49,31 @@ QtUndoRedo::QtUndoRedo()
connect(m_undoButton, &QPushButton::released, this, &QtUndoRedo::undoReleased);
connect(m_redoButton, &QPushButton::released, this, &QtUndoRedo::redoReleased);
connect(m_historyButton, &QPushButton::released, this, &QtUndoRedo::showHistory);
refreshStyle();
}
QtUndoRedo::~QtUndoRedo()
{
}
void QtUndoRedo::setUndoButtonEnabled(bool enabled)
{
m_undoButton->setEnabled(enabled);
QtContextMenu::getInstance()->enableUndo(enabled);
}
void QtUndoRedo::setRedoButtonEnabled(bool enabled)
{
m_redoButton->setEnabled(enabled);
QtContextMenu::getInstance()->enableRedo(enabled);
}
void QtUndoRedo::updateHistory(const std::vector<SearchMatch>& searchMatches, size_t currentIndex)
{
m_history = searchMatches;
m_currentIndex = currentIndex;
m_historyButton->setEnabled(m_history.size() > 1);
}
void QtUndoRedo::buttonPressed()
{
if (TimeStamp::now().deltaMS(m_historyHiddenAt) < 250)
@@ -132,52 +144,3 @@ void QtUndoRedo::hidHistory()
m_historyHiddenAt = TimeStamp::now();
}
}
void QtUndoRedo::setUndoButtonEnabled(bool enabled)
{
m_undoButton->setEnabled(enabled);
QtContextMenu::getInstance()->enableUndo(enabled);
}
void QtUndoRedo::setRedoButtonEnabled(bool enabled)
{
m_redoButton->setEnabled(enabled);
QtContextMenu::getInstance()->enableRedo(enabled);
}
void QtUndoRedo::updateHistory(const std::vector<SearchMatch>& searchMatches, size_t currentIndex)
{
m_history = searchMatches;
m_currentIndex = currentIndex;
m_historyButton->setEnabled(m_history.size() > 1);
}
void QtUndoRedo::refreshStyle()
{
float height = std::max(ApplicationSettings::getInstance()->getFontSize() + 16, 30);
m_undoButton->setFixedHeight(height);
m_redoButton->setFixedHeight(height);
m_historyButton->setFixedHeight(height);
m_undoButton->setIcon(utility::createButtonIcon(
ResourcePaths::getGuiPath().concatenate(L"undoredo_view/images/arrow_left.png"),
"search/button"
));
m_redoButton->setIcon(utility::createButtonIcon(
ResourcePaths::getGuiPath().concatenate(L"undoredo_view/images/arrow_right.png"),
"search/button"
));
m_historyButton->setIcon(utility::createButtonIcon(
ResourcePaths::getGuiPath().concatenate(L"undoredo_view/images/history.png"),
"search/button"
));
int iconSize = int(height / 4) * 2 + 2;
m_undoButton->setIconSize(QSize(iconSize, iconSize));
m_redoButton->setIconSize(QSize(iconSize, iconSize));
m_historyButton->setIconSize(QSize(iconSize, iconSize));
}
+4 -7
View File
@@ -1,13 +1,12 @@
#ifndef QT_UNDO_REDO_H
#define QT_UNDO_REDO_H
#include <string>
#include <QFrame>
#include "data/search/SearchMatch.h"
#include "utility/TimeStamp.h"
class QPushButton;
class QtSearchBarButton;
class QtHistoryList;
class QtUndoRedo
@@ -24,8 +23,6 @@ public:
void updateHistory(const std::vector<SearchMatch>& searchMatches, size_t currentIndex);
void refreshStyle();
private slots:
void buttonPressed();
@@ -36,9 +33,9 @@ private slots:
void hidHistory();
private:
QPushButton* m_undoButton;
QPushButton* m_historyButton;
QPushButton* m_redoButton;
QtSearchBarButton* m_undoButton;
QtSearchBarButton* m_historyButton;
QtSearchBarButton* m_redoButton;
std::vector<SearchMatch> m_history;
size_t m_currentIndex;
+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;
+11 -6
View File
@@ -214,13 +214,18 @@ namespace utility
QIcon createButtonIcon(const FilePath& iconPath, const std::string& colorId)
{
QPixmap pixmap(QString::fromStdWString(iconPath.wstr()));
ColorScheme* scheme = ColorScheme::getInstance().get();
QIcon icon(utility::colorizePixmap(pixmap, ColorScheme::getInstance()->getColor(colorId + "/icon").c_str()));
icon.addPixmap(
utility::colorizePixmap(pixmap, ColorScheme::getInstance()->getColor(colorId + "/icon_disabled").c_str()),
QIcon::Disabled
);
QPixmap pixmap(QString::fromStdWString(iconPath.wstr()));
QIcon icon(utility::colorizePixmap(pixmap, scheme->getColor(colorId + "/icon").c_str()));
if (scheme->hasColor(colorId + "/icon_disabled"))
{
icon.addPixmap(
utility::colorizePixmap(pixmap, scheme->getColor(colorId + "/icon_disabled").c_str()),
QIcon::Disabled
);
}
return icon;
}
+15 -51
View File
@@ -5,13 +5,13 @@
#include <QMessageBox>
#include <QPushButton>
#include "qt/element/QtSearchBarButton.h"
#include "qt/utility/utilityQt.h"
#include "qt/view/QtViewWidgetWrapper.h"
#include "qt/window/QtBookmarkCreator.h"
#include "qt/window/QtBookmarkBrowser.h"
#include "qt/view/QtMainView.h"
#include "qt/view/QtViewWidgetWrapper.h"
#include "qt/window/QtBookmarkBrowser.h"
#include "qt/window/QtBookmarkCreator.h"
#include "qt/window/QtMainWindow.h"
#include "settings/ApplicationSettings.h"
#include "utility/ResourcePaths.h"
QtBookmarkView::QtBookmarkView(ViewLayout* viewLayout)
@@ -42,26 +42,23 @@ void QtBookmarkView::initView()
layout->setAlignment(Qt::AlignTop);
m_widget->setLayout(layout);
m_createBookmarkButton = new QPushButton();
m_createBookmarkButton = new QtSearchBarButton(
ResourcePaths::getGuiPath().concatenate(L"bookmark_view/images/edit_bookmark_icon.png"));
m_createBookmarkButton->setObjectName("bookmark_button");
m_createBookmarkButton->setToolTip("create a bookmark for the active symbol");
m_createBookmarkButton->setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac
m_createBookmarkButton->setEnabled(false);
layout->addWidget(m_createBookmarkButton);
connect(m_createBookmarkButton, &QPushButton::clicked, this, &QtBookmarkView::createBookmarkClicked);
m_showBookmarksButton = new QPushButton();
m_showBookmarksButton = new QtSearchBarButton(
ResourcePaths::getGuiPath().concatenate(L"bookmark_view/images/bookmark_list_icon.png"));
m_showBookmarksButton->setObjectName("show_bookmark_button");
m_showBookmarksButton->setToolTip("Show bookmarks");
m_showBookmarksButton->setAttribute(Qt::WA_LayoutUsesWidgetRect);
m_showBookmarksButton->setEnabled(false);
layout->addWidget(m_showBookmarksButton);
connect(m_showBookmarksButton, &QPushButton::clicked, this, &QtBookmarkView::showBookmarksClicked);
setStyleSheet();
refreshStyle();
}
void QtBookmarkView::refreshView()
@@ -69,8 +66,9 @@ void QtBookmarkView::refreshView()
m_onQtThread(
[=]()
{
setStyleSheet();
refreshStyle();
m_widget->setStyleSheet(utility::getStyleSheet(
ResourcePaths::getGuiPath().concatenate(L"bookmark_view/bookmark_view.css")
).c_str());
}
);
}
@@ -82,10 +80,8 @@ void QtBookmarkView::setCreateButtonState(const CreateButtonState& state)
{
m_createButtonState = state;
m_createBookmarkButton->setIcon(utility::createButtonIcon(
ResourcePaths::getGuiPath().concatenate(L"bookmark_view/images/edit_bookmark_icon.png"),
"search/button"
));
m_createBookmarkButton->setIconPath(
ResourcePaths::getGuiPath().concatenate(L"bookmark_view/images/edit_bookmark_icon.png"));
if (state == BookmarkView::CreateButtonState::CAN_CREATE)
{
@@ -99,10 +95,8 @@ void QtBookmarkView::setCreateButtonState(const CreateButtonState& state)
{
m_createBookmarkButton->setEnabled(true);
m_createBookmarkButton->setIcon(utility::createButtonIcon(
ResourcePaths::getGuiPath().concatenate(L"bookmark_view/images/bookmark_active.png"),
"search/button"
));
m_createBookmarkButton->setIconPath(
ResourcePaths::getGuiPath().concatenate(L"bookmark_view/images/bookmark_active.png"));
}
else
{
@@ -246,33 +240,3 @@ void QtBookmarkView::showBookmarksClicked()
{
m_controllerProxy.executeAsTask(&BookmarkController::displayBookmarks);
}
void QtBookmarkView::setStyleSheet()
{
m_widget->setStyleSheet(utility::getStyleSheet(
ResourcePaths::getGuiPath().concatenate(L"bookmark_view/bookmark_view.css")
).c_str());
}
void QtBookmarkView::refreshStyle()
{
float height = std::max(ApplicationSettings::getInstance()->getFontSize() + 16, 30);
m_createBookmarkButton->setFixedHeight(height);
m_showBookmarksButton->setFixedHeight(height);
m_createBookmarkButton->setIcon(utility::createButtonIcon(
ResourcePaths::getGuiPath().concatenate(L"bookmark_view/images/edit_bookmark_icon.png"),
"search/button"
));
m_showBookmarksButton->setIcon(utility::createButtonIcon(
ResourcePaths::getGuiPath().concatenate(L"bookmark_view/images/bookmark_list_icon.png"),
"search/button"
));
int iconSize = int(height / 4) * 2 + 2;
m_createBookmarkButton->setIconSize(QSize(iconSize, iconSize));
m_showBookmarksButton->setIconSize(QSize(iconSize, iconSize));
}
+4 -6
View File
@@ -8,8 +8,8 @@
#include "qt/utility/QtThreadedFunctor.h"
class QFrame;
class QPushButton;
class QtBookmarkBrowser;
class QtSearchBarButton;
class QtBookmarkView
: public QObject
@@ -26,6 +26,7 @@ public:
virtual void initView();
virtual void refreshView();
// BookmarkView implementation
virtual void setCreateButtonState(const CreateButtonState& state);
virtual void displayBookmarkCreator(
@@ -43,16 +44,13 @@ private slots:
void showBookmarksClicked();
private:
void setStyleSheet();
void refreshStyle();
ControllerProxy<BookmarkController> m_controllerProxy;
QtThreadedLambdaFunctor m_onQtThread;
QFrame* m_widget;
QPushButton* m_createBookmarkButton;
QPushButton* m_showBookmarksButton;
QtSearchBarButton* m_createBookmarkButton;
QtSearchBarButton* m_showBookmarksButton;
QtBookmarkBrowser* m_bookmarkBrowser;
+1 -1
View File
@@ -37,7 +37,7 @@ void QtCodeView::refreshView()
setStyleSheet();
m_widget->refreshStyle();
m_widget->clearCaches();
QtCodeArea::clearAnnotationColors();
QtHighlighter::clearHighlightingRules();
+8 -8
View File
@@ -14,6 +14,7 @@
#include <QStyledItemDelegate>
#include "qt/element/QtHelpButton.h"
#include "qt/element/QtIconButton.h"
#include "qt/element/QtTable.h"
#include "qt/utility/utilityQt.h"
#include "qt/view/QtViewWidgetWrapper.h"
@@ -174,17 +175,21 @@ void QtErrorView::initView()
{
m_editButton = new QPushButton("Edit Project");
m_editButton = new QtSelfRefreshIconButton(
"Edit Project",
ResourcePaths::getGuiPath().concatenate(L"code_view/images/edit.png"),
"window/button"
);
m_editButton->setObjectName("screen_button");
m_editButton->setToolTip("edit project");
connect(m_editButton, &QPushButton::clicked,
[]()
{
MessageProjectEdit().dispatch();
}
);
checkboxes->addWidget(m_editButton);
m_editButton->setToolTip("edit project");
checkboxes->addWidget(m_editButton);
}
checkboxes->addSpacing(10);
@@ -309,11 +314,6 @@ void QtErrorView::setStyleSheet() const
m_helpButton->setColor(QColor(ColorScheme::getInstance()->getColor("table/text/normal").c_str()));
m_editButton->setIcon(utility::createButtonIcon(
ResourcePaths::getGuiPath().concatenate(L"code_view/images/edit.png"),
"window/button"
));
m_table->updateRows();
}
+2 -1
View File
@@ -13,6 +13,7 @@ class QLabel;
class QPushButton;
class QStandardItemModel;
class QtHelpButton;
class QtSelfRefreshIconButton;
class QtTable;
class QtErrorView
@@ -77,7 +78,7 @@ private:
QCheckBox* m_showNonIndexedFatals;
QtHelpButton* m_helpButton;
QPushButton* m_editButton;
QtSelfRefreshIconButton* m_editButton;
QStandardItemModel* m_model;
QtTable* m_table;
+20 -47
View File
@@ -10,19 +10,19 @@
#include <QPushButton>
#include <QScrollBar>
#include <QSequentialAnimationGroup>
#include <QStackedLayout>
#include <QSlider>
#include <QStackedLayout>
#include "component/controller/helper/DummyEdge.h"
#include "component/controller/helper/DummyNode.h"
#include "component/view/GraphViewStyle.h"
#include "settings/ApplicationSettings.h"
#include "utility/messaging/type/MessageActivateTrail.h"
#include "utility/messaging/type/MessageDeactivateEdge.h"
#include "utility/messaging/type/MessageScrollGraph.h"
#include "utility/messaging/type/MessageStatus.h"
#include "utility/ResourcePaths.h"
#include "component/controller/helper/DummyEdge.h"
#include "component/controller/helper/DummyNode.h"
#include "component/view/GraphViewStyle.h"
#include "qt/element/QtIconButton.h"
#include "qt/graphics/QtGraphicsView.h"
#include "qt/utility/utilityQt.h"
#include "qt/view/QtViewWidgetWrapper.h"
@@ -35,6 +35,7 @@
#include "qt/view/graphElements/QtGraphNodeExpandToggle.h"
#include "qt/view/graphElements/QtGraphNodeQualifier.h"
#include "qt/view/graphElements/QtGraphNodeText.h"
#include "settings/ApplicationSettings.h"
QtGraphView::QtGraphView(ViewLayout* viewLayout)
: GraphView(viewLayout)
@@ -87,9 +88,11 @@ void QtGraphView::initView()
QStackedLayout* stack = new QStackedLayout();
{
m_expandButton = new QPushButton();
m_expandButton = new QtSelfRefreshIconButton(
"", ResourcePaths::getGuiPath().concatenate(L"graph_view/images/graph.png"), "search/button");
m_expandButton->setObjectName("expand_button");
m_expandButton->setToolTip("show depth graph controls");
m_expandButton->setIconSize(QSize(16, 16));
m_expandButton->setGeometry(0, 0, 26, 26);
connect(m_expandButton, &QPushButton::clicked, this, &QtGraphView::clickedExpand);
stack->addWidget(m_expandButton);
@@ -100,17 +103,21 @@ void QtGraphView::initView()
ui->setGeometry(0, 0, 26, 210);
stack->addWidget(ui);
m_collapseButton = new QPushButton(ui);
m_collapseButton = new QtSelfRefreshIconButton(
"", ResourcePaths::getGuiPath().concatenate(L"graph_view/images/graph_arrow.png"), "search/button", ui);
m_collapseButton->setObjectName("collapse_button");
m_collapseButton->setToolTip("hide depth graph controls");
m_collapseButton->setIconSize(QSize(16, 16));
connect(m_collapseButton, &QPushButton::clicked, this, &QtGraphView::clickedCollapse);
m_forwardTrailButton = new QPushButton(ui);
m_forwardTrailButton = new QtSelfRefreshIconButton("", FilePath(), "search/button", ui);
m_forwardTrailButton->setObjectName("trail_button");
m_forwardTrailButton->setIconSize(QSize(16, 16));
connect(m_forwardTrailButton, &QPushButton::clicked, this, &QtGraphView::clickedForwardTrail);
m_backwardTrailButton = new QPushButton(ui);
m_backwardTrailButton = new QtSelfRefreshIconButton("", FilePath(), "search/button", ui);
m_backwardTrailButton->setObjectName("trail_button");
m_backwardTrailButton->setIconSize(QSize(16, 16));
connect(m_backwardTrailButton, &QPushButton::clicked, this, &QtGraphView::clickedBackwardTrail);
m_trailDepthLabel = new QLabel(ui);
@@ -163,23 +170,8 @@ void QtGraphView::refreshView()
const std::string css = utility::getStyleSheet(ResourcePaths::getGuiPath().concatenate(L"graph_view/graph_view.css"));
view->setStyleSheet(css.c_str());
view->setAppZoomFactor(GraphViewStyle::getZoomFactor());
view->refreshStyle();
m_trailWidget->setStyleSheet(css.c_str());
m_expandButton->setIcon(utility::createButtonIcon(
ResourcePaths::getGuiPath().concatenate(L"graph_view/images/graph.png"),
"search/button"
));
m_collapseButton->setIcon(utility::createButtonIcon(
ResourcePaths::getGuiPath().concatenate(L"graph_view/images/graph_arrow.png"),
"search/button"
));
m_expandButton->setIconSize(QSize(16, 16));
m_collapseButton->setIconSize(QSize(16, 16));
updateTrailButtons();
});
}
@@ -729,16 +721,13 @@ void QtGraphView::updateTrailButtons()
m_trailDepthLabel->setEnabled(message.trailType);
m_trailDepthSlider->setEnabled(message.trailType);
std::wstring backwardImagePath;
std::wstring forwardImagePath;
std::wstring backwardImagePath = L"graph_left.png";
std::wstring forwardImagePath = L"graph_right.png";
if (message.trailType & Edge::EDGE_CALL)
{
m_backwardTrailButton->setToolTip("show caller graph");
m_forwardTrailButton->setToolTip("show callee graph");
backwardImagePath = L"graph_left.png";
forwardImagePath = L"graph_right.png";
}
else if (message.trailType & Edge::EDGE_INHERITANCE)
{
@@ -752,31 +741,15 @@ void QtGraphView::updateTrailButtons()
{
m_backwardTrailButton->setToolTip("show including files hierarchy");
m_forwardTrailButton->setToolTip("show included files hierarchy");
backwardImagePath = L"graph_left.png";
forwardImagePath = L"graph_right.png";
}
else
{
m_backwardTrailButton->setToolTip("no depth graph available for active symbol");
m_forwardTrailButton->setToolTip("no depth graph available for active symbol");
backwardImagePath = L"graph_left.png";
forwardImagePath = L"graph_right.png";
}
m_backwardTrailButton->setIcon(utility::createButtonIcon(
ResourcePaths::getGuiPath().concatenate(L"graph_view/images/" + backwardImagePath),
"search/button"
));
m_forwardTrailButton->setIcon(utility::createButtonIcon(
ResourcePaths::getGuiPath().concatenate(L"graph_view/images/" + forwardImagePath),
"search/button"
));
m_backwardTrailButton->setIconSize(QSize(16, 16));
m_forwardTrailButton->setIconSize(QSize(16, 16));
m_forwardTrailButton->setIconPath(ResourcePaths::getGuiPath().concatenate(L"graph_view/images/" + forwardImagePath));
m_backwardTrailButton->setIconPath(ResourcePaths::getGuiPath().concatenate(L"graph_view/images/" + backwardImagePath));
}
void QtGraphView::switchToNewGraphData()
+7 -5
View File
@@ -23,6 +23,7 @@ class QSlider;
class QtGraphEdge;
class QtGraphicsView;
class QtGraphNode;
class QtSelfRefreshIconButton;
class QtGraphView
: public QObject
@@ -99,7 +100,8 @@ private:
QtGraphNode* createNodeRecursive(
QGraphicsView* view, QtGraphNode* parentNode, const DummyNode* node, bool multipleActive);
QtGraphEdge* createEdge(
QGraphicsView* view, const DummyEdge* edge, std::set<Id>* visibleEdgeIds, Graph::TrailMode trailMode, QPointF pathOffset, bool useBezier);
QGraphicsView* view, const DummyEdge* edge, std::set<Id>* visibleEdgeIds, Graph::TrailMode trailMode,
QPointF pathOffset, bool useBezier);
QtGraphEdge* createAggregationEdge(
QGraphicsView* view, const DummyEdge* edge, std::set<Id>* visibleEdgeIds);
@@ -144,10 +146,10 @@ private:
QtScrollSpeedChangeListener m_scrollSpeedChangeListenerVertical;
QWidget* m_trailWidget;
QPushButton* m_expandButton;
QPushButton* m_collapseButton;
QPushButton* m_forwardTrailButton;
QPushButton* m_backwardTrailButton;
QtSelfRefreshIconButton* m_expandButton;
QtSelfRefreshIconButton* m_collapseButton;
QtSelfRefreshIconButton* m_forwardTrailButton;
QtSelfRefreshIconButton* m_backwardTrailButton;
QSlider* m_trailDepthSlider;
QLabel* m_trailDepthLabel;
+24 -14
View File
@@ -1,18 +1,34 @@
#include "qt/view/QtRefreshView.h"
#include "component/controller/RefreshController.h"
#include <QHBoxLayout>
#include <QFrame>
#include "utility/messaging/type/MessageRefresh.h"
#include "utility/ResourcePaths.h"
#include "qt/element/QtSearchBarButton.h"
#include "qt/utility/utilityQt.h"
#include "qt/view/QtViewWidgetWrapper.h"
#include "utility/ResourcePaths.h"
QtRefreshView::QtRefreshView(ViewLayout* viewLayout)
: RefreshView(viewLayout)
{
m_widget = new QtRefreshBar();
}
m_widget = new QFrame();
m_widget->setObjectName("refresh_bar");
QtRefreshView::~QtRefreshView()
{
QBoxLayout* layout = new QHBoxLayout();
layout->setSpacing(0);
layout->setContentsMargins(0, 0, 0, 0);
layout->setAlignment(Qt::AlignTop);
QtSearchBarButton* refreshButton =
new QtSearchBarButton(ResourcePaths::getGuiPath().concatenate(L"refresh_view/images/refresh.png"));
refreshButton->setObjectName("refresh_button");
refreshButton->setToolTip("refresh");
m_widget->connect(refreshButton, &QPushButton::clicked, [](){ MessageRefresh().dispatch(); });
layout->addWidget(refreshButton);
m_widget->setLayout(layout);
}
void QtRefreshView::createWidgetWrapper()
@@ -28,13 +44,7 @@ void QtRefreshView::refreshView()
{
m_onQtThread([this]()
{
setStyleSheet();
m_widget->refreshStyle();
m_widget->setStyleSheet(utility::getStyleSheet(
ResourcePaths::getGuiPath().concatenate(L"refresh_view/refresh_view.css")).c_str());
});
}
void QtRefreshView::setStyleSheet()
{
m_widget->setStyleSheet(utility::getStyleSheet(
ResourcePaths::getGuiPath().concatenate(L"refresh_view/refresh_view.css")).c_str());
}
+8 -11
View File
@@ -2,29 +2,26 @@
#define QT_REFRESH_VIEW_H
#include "component/view/RefreshView.h"
#include "qt/element/QtRefreshBar.h"
#include "qt/utility/QtThreadedFunctor.h"
class QFrame;
class QtRefreshView
: public RefreshView
{
public:
QtRefreshView(ViewLayout* viewLayout);
~QtRefreshView();
~QtRefreshView() = default;
// View implementation
virtual void createWidgetWrapper();
virtual void initView();
virtual void refreshView();
// RefreshView implementation
void createWidgetWrapper() override;
void initView() override;
void refreshView() override;
private:
void setStyleSheet();
QtThreadedLambdaFunctor m_onQtThread;
QtRefreshBar* m_widget;
QFrame* m_widget;
};
# endif // QT_REFRESH_VIEW_H
#endif // QT_REFRESH_VIEW_H
+2 -3
View File
@@ -1,10 +1,9 @@
#include "qt/view/QtSearchView.h"
#include "qt/utility/utilityQt.h"
#include "utility/ResourcePaths.h"
#include "component/controller/SearchController.h"
#include "qt/element/QtSearchBar.h"
#include "qt/utility/utilityQt.h"
#include "qt/view/QtViewWidgetWrapper.h"
QtSearchView::QtSearchView(ViewLayout* viewLayout)
+4 -2
View File
@@ -4,10 +4,12 @@
#include <vector>
#include "component/view/SearchView.h"
#include "qt/element/QtSearchBar.h"
#include "qt/utility/QtThreadedFunctor.h"
class QtSearchView: public SearchView
class QtSearchBar;
class QtSearchView
: public SearchView
{
public:
QtSearchView(ViewLayout* viewLayout);
+3 -9
View File
@@ -29,8 +29,9 @@ void QtUndoRedoView::refreshView()
m_onQtThread(
[=]()
{
setStyleSheet();
m_widget->refreshStyle();
m_widget->setStyleSheet(utility::getStyleSheet(
ResourcePaths::getGuiPath().concatenate(L"undoredo_view/undoredo_view.css")
).c_str());
}
);
}
@@ -64,10 +65,3 @@ void QtUndoRedoView::updateHistory(const std::vector<SearchMatch>& searchMatches
}
);
}
void QtUndoRedoView::setStyleSheet()
{
m_widget->setStyleSheet(utility::getStyleSheet(
ResourcePaths::getGuiPath().concatenate(L"undoredo_view/undoredo_view.css")
).c_str());
}
-2
View File
@@ -26,8 +26,6 @@ public:
virtual void updateHistory(const std::vector<SearchMatch>& searchMatches, size_t currentIndex);
private:
void setStyleSheet();
QtThreadedLambdaFunctor m_onQtThread;
QtUndoRedo* m_widget;
@@ -147,18 +147,18 @@ void QtProjectWizzard::populateWindow(QWidget* widget)
buttonsLayout->setSpacing(0);
QPushButton* addButton = new QtIconButton(
QString::fromStdWString(ResourcePaths::getGuiPath().concatenate(L"window/source_group_add.png").wstr()),
QString::fromStdWString(ResourcePaths::getGuiPath().concatenate(L"window/source_group_add_hover.png").wstr())
ResourcePaths::getGuiPath().concatenate(L"window/source_group_add.png"),
ResourcePaths::getGuiPath().concatenate(L"window/source_group_add_hover.png")
);
m_removeButton = new QtIconButton(
QString::fromStdWString(ResourcePaths::getGuiPath().concatenate(L"window/source_group_delete.png").wstr()),
QString::fromStdWString(ResourcePaths::getGuiPath().concatenate(L"window/source_group_delete_hover.png").wstr())
ResourcePaths::getGuiPath().concatenate(L"window/source_group_delete.png"),
ResourcePaths::getGuiPath().concatenate(L"window/source_group_delete_hover.png")
);
m_duplicateButton = new QtIconButton(
QString::fromStdWString(ResourcePaths::getGuiPath().concatenate(L"window/source_group_copy.png").wstr()),
QString::fromStdWString(ResourcePaths::getGuiPath().concatenate(L"window/source_group_copy_hover.png").wstr())
ResourcePaths::getGuiPath().concatenate(L"window/source_group_copy.png"),
ResourcePaths::getGuiPath().concatenate(L"window/source_group_copy_hover.png")
);
addButton->setIconSize(QSize(20, 20));
@@ -840,8 +840,8 @@ void QtProjectWizzard::sourcePathsJavaMaven()
{
std::dynamic_pointer_cast<SourceGroupSettingsJavaMaven>(m_newSourceGroupSettings)->setMavenDependenciesDirectory(
FilePath(
L"./sourcetrail_dependencies/" + utility::replace(m_projectSettings->getProjectName(), L" ", L"_") +
L"/" +
L"./sourcetrail_dependencies/" + utility::replace(m_projectSettings->getProjectName(), L" ", L"_") +
L"/" +
utility::decodeFromUtf8(m_newSourceGroupSettings->getId()) +
L"/maven"
)
@@ -864,8 +864,8 @@ void QtProjectWizzard::sourcePathsJavaGradle()
{
std::dynamic_pointer_cast<SourceGroupSettingsJavaGradle>(m_newSourceGroupSettings)->setGradleDependenciesDirectory(
FilePath(
L"./sourcetrail_dependencies/" + utility::replace(m_projectSettings->getProjectName(), L" ", L"_") +
L"/" +
L"./sourcetrail_dependencies/" + utility::replace(m_projectSettings->getProjectName(), L" ", L"_") +
L"/" +
utility::decodeFromUtf8(m_newSourceGroupSettings->getId()) +
L"/gradle"
)