src: refactored UI elements and graphics file structure

* split QtIconButton into multiple files
* moved graph elements from view to graphics
* structured elements into sub directories
This commit is contained in:
Eberhard Graether
2019-05-29 18:31:11 +02:00
parent 1cc61a93a2
commit 841a87469b
117 changed files with 518 additions and 483 deletions
+120 -108
View File
@@ -5,95 +5,133 @@ add_files(
platform_includes/includesMac.h
platform_includes/includesWindows.h
qt/element/QtAutocompletionList.cpp
qt/element/QtAutocompletionList.h
qt/element/QtBookmark.cpp
qt/element/QtBookmark.h
qt/element/QtBookmarkCategory.cpp
qt/element/QtBookmarkCategory.h
qt/element/QtCodeArea.cpp
qt/element/QtCodeArea.h
qt/element/QtCodeField.cpp
qt/element/QtCodeField.h
qt/element/QtCodeFile.cpp
qt/element/QtCodeFile.h
qt/element/QtCodeFileList.cpp
qt/element/QtCodeFileList.h
qt/element/QtCodeFileSingle.cpp
qt/element/QtCodeFileSingle.h
qt/element/QtCodeFileTitleBar.cpp
qt/element/QtCodeFileTitleBar.h
qt/element/QtCodeFileTitleButton.cpp
qt/element/QtCodeFileTitleButton.h
qt/element/QtCodeNavigateable.cpp
qt/element/QtCodeNavigateable.h
qt/element/QtCodeNavigator.cpp
qt/element/QtCodeNavigator.h
qt/element/QtCodeSnippet.cpp
qt/element/QtCodeSnippet.h
qt/element/QtHelpButton.cpp
qt/element/QtHelpButton.h
qt/element/QtHistoryList.cpp
qt/element/QtHistoryList.h
qt/element/QtIconButton.cpp
qt/element/QtIconButton.h
qt/element/QtLineEdit.cpp
qt/element/QtLineEdit.h
qt/element/QtListBox.cpp
qt/element/QtListBox.h
qt/element/QtListBoxItem.cpp
qt/element/QtListBoxItem.h
qt/element/QtLocationPicker.cpp
qt/element/QtLocationPicker.h
qt/element/QtNewsWidget.cpp
qt/element/QtNewsWidget.h
qt/element/QtPathListBox.cpp
qt/element/QtPathListBox.h
qt/element/QtPathListBoxItem.cpp
qt/element/QtPathListBoxItem.h
qt/element/QtProgressBar.cpp
qt/element/QtProgressBar.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/QtStringListBox.cpp
qt/element/QtStringListBox.h
qt/element/QtStringListBoxItem.cpp
qt/element/QtStringListBoxItem.h
qt/element/bookmark/QtBookmark.cpp
qt/element/bookmark/QtBookmark.h
qt/element/bookmark/QtBookmarkCategory.cpp
qt/element/bookmark/QtBookmarkCategory.h
qt/element/button/QtHelpButton.cpp
qt/element/button/QtHelpButton.h
qt/element/button/QtHoverButton.cpp
qt/element/button/QtHoverButton.h
qt/element/button/QtIconButton.cpp
qt/element/button/QtIconButton.h
qt/element/button/QtIconStateButton.cpp
qt/element/button/QtIconStateButton.h
qt/element/button/QtSelfRefreshIconButton.cpp
qt/element/button/QtSelfRefreshIconButton.h
qt/element/code/QtCodeArea.cpp
qt/element/code/QtCodeArea.h
qt/element/code/QtCodeField.cpp
qt/element/code/QtCodeField.h
qt/element/code/QtCodeFile.cpp
qt/element/code/QtCodeFile.h
qt/element/code/QtCodeFileList.cpp
qt/element/code/QtCodeFileList.h
qt/element/code/QtCodeFileSingle.cpp
qt/element/code/QtCodeFileSingle.h
qt/element/code/QtCodeFileTitleBar.cpp
qt/element/code/QtCodeFileTitleBar.h
qt/element/code/QtCodeFileTitleButton.cpp
qt/element/code/QtCodeFileTitleButton.h
qt/element/code/QtCodeNavigateable.cpp
qt/element/code/QtCodeNavigateable.h
qt/element/code/QtCodeNavigator.cpp
qt/element/code/QtCodeNavigator.h
qt/element/code/QtCodeSnippet.cpp
qt/element/code/QtCodeSnippet.h
qt/element/history/QtHistoryList.cpp
qt/element/history/QtHistoryList.h
qt/element/history/QtUndoRedo.cpp
qt/element/history/QtUndoRedo.h
qt/element/search/QtAutocompletionList.cpp
qt/element/search/QtAutocompletionList.h
qt/element/search/QtScreenSearchBox.cpp
qt/element/search/QtScreenSearchBox.h
qt/element/search/QtSearchBar.cpp
qt/element/search/QtSearchBar.h
qt/element/search/QtSearchBarButton.cpp
qt/element/search/QtSearchBarButton.h
qt/element/search/QtSmartSearchBox.cpp
qt/element/search/QtSmartSearchBox.h
qt/element/dialog/QtLineEdit.cpp
qt/element/dialog/QtLineEdit.h
qt/element/dialog/QtListBox.cpp
qt/element/dialog/QtListBox.h
qt/element/dialog/QtListBoxItem.cpp
qt/element/dialog/QtListBoxItem.h
qt/element/dialog/QtLocationPicker.cpp
qt/element/dialog/QtLocationPicker.h
qt/element/dialog/QtNewsWidget.cpp
qt/element/dialog/QtNewsWidget.h
qt/element/dialog/QtPathListBox.cpp
qt/element/dialog/QtPathListBox.h
qt/element/dialog/QtPathListBoxItem.cpp
qt/element/dialog/QtPathListBoxItem.h
qt/element/dialog/QtProgressBar.cpp
qt/element/dialog/QtProgressBar.h
qt/element/dialog/QtStringListBox.cpp
qt/element/dialog/QtStringListBox.h
qt/element/dialog/QtStringListBoxItem.cpp
qt/element/dialog/QtStringListBoxItem.h
qt/element/dialog/QtTextEdit.cpp
qt/element/dialog/QtTextEdit.h
qt/element/dialog/QtUpdateCheckerWidget.cpp
qt/element/dialog/QtUpdateCheckerWidget.h
qt/element/QtTooltip.cpp
qt/element/QtTooltip.h
qt/element/QtStatusBar.cpp
qt/element/QtStatusBar.h
qt/element/QtTabBar.cpp
qt/element/QtTabBar.h
qt/element/QtTable.cpp
qt/element/QtTable.h
qt/element/QtTextEdit.cpp
qt/element/QtTextEdit.h
qt/element/QtTooltip.cpp
qt/element/QtTooltip.h
qt/element/QtUndoRedo.cpp
qt/element/QtUndoRedo.h
qt/element/QtUpdateCheckerWidget.cpp
qt/element/QtUpdateCheckerWidget.h
qt/graphics/QtCountCircleItem.cpp
qt/graphics/QtCountCircleItem.h
qt/graphics/QtGraphicsView.cpp
qt/graphics/QtGraphicsView.h
qt/graphics/QtLineItemAngled.cpp
qt/graphics/QtLineItemAngled.h
qt/graphics/QtLineItemBase.cpp
qt/graphics/QtLineItemBase.h
qt/graphics/QtLineItemBezier.cpp
qt/graphics/QtLineItemBezier.h
qt/graphics/QtLineItemStraight.cpp
qt/graphics/QtLineItemStraight.h
qt/graphics/QtRoundedRectItem.cpp
qt/graphics/QtRoundedRectItem.h
qt/graphics/base/QtCountCircleItem.cpp
qt/graphics/base/QtCountCircleItem.h
qt/graphics/base/QtGraphicsView.cpp
qt/graphics/base/QtGraphicsView.h
qt/graphics/base/QtLineItemAngled.cpp
qt/graphics/base/QtLineItemAngled.h
qt/graphics/base/QtLineItemBase.cpp
qt/graphics/base/QtLineItemBase.h
qt/graphics/base/QtLineItemBezier.cpp
qt/graphics/base/QtLineItemBezier.h
qt/graphics/base/QtLineItemStraight.cpp
qt/graphics/base/QtLineItemStraight.h
qt/graphics/base/QtRoundedRectItem.cpp
qt/graphics/base/QtRoundedRectItem.h
qt/graphics/component/QtGraphNodeComponent.cpp
qt/graphics/component/QtGraphNodeComponent.h
qt/graphics/component/QtGraphNodeComponentClickable.cpp
qt/graphics/component/QtGraphNodeComponentClickable.h
qt/graphics/component/QtGraphNodeComponentMoveable.cpp
qt/graphics/component/QtGraphNodeComponentMoveable.h
qt/graphics/graph/QtGraphEdge.cpp
qt/graphics/graph/QtGraphEdge.h
qt/graphics/graph/QtGraphNode.cpp
qt/graphics/graph/QtGraphNode.h
qt/graphics/graph/QtGraphNodeAccess.cpp
qt/graphics/graph/QtGraphNodeAccess.h
qt/graphics/graph/QtGraphNodeBundle.cpp
qt/graphics/graph/QtGraphNodeBundle.h
qt/graphics/graph/QtGraphNodeData.cpp
qt/graphics/graph/QtGraphNodeData.h
qt/graphics/graph/QtGraphNodeExpandToggle.cpp
qt/graphics/graph/QtGraphNodeExpandToggle.h
qt/graphics/graph/QtGraphNodeGroup.cpp
qt/graphics/graph/QtGraphNodeGroup.h
qt/graphics/graph/QtGraphNodeQualifier.cpp
qt/graphics/graph/QtGraphNodeQualifier.h
qt/graphics/graph/QtGraphNodeText.cpp
qt/graphics/graph/QtGraphNodeText.h
qt/network/QtIDECommunicationController.cpp
qt/network/QtIDECommunicationController.h
@@ -202,32 +240,6 @@ add_files(
qt/utility/utilityQt.cpp
qt/utility/utilityQt.h
qt/view/graphElements/nodeComponents/QtGraphNodeComponent.cpp
qt/view/graphElements/nodeComponents/QtGraphNodeComponent.h
qt/view/graphElements/nodeComponents/QtGraphNodeComponentClickable.cpp
qt/view/graphElements/nodeComponents/QtGraphNodeComponentClickable.h
qt/view/graphElements/nodeComponents/QtGraphNodeComponentMoveable.cpp
qt/view/graphElements/nodeComponents/QtGraphNodeComponentMoveable.h
qt/view/graphElements/QtGraphEdge.cpp
qt/view/graphElements/QtGraphEdge.h
qt/view/graphElements/QtGraphNode.cpp
qt/view/graphElements/QtGraphNode.h
qt/view/graphElements/QtGraphNodeAccess.cpp
qt/view/graphElements/QtGraphNodeAccess.h
qt/view/graphElements/QtGraphNodeBundle.cpp
qt/view/graphElements/QtGraphNodeBundle.h
qt/view/graphElements/QtGraphNodeData.cpp
qt/view/graphElements/QtGraphNodeData.h
qt/view/graphElements/QtGraphNodeExpandToggle.cpp
qt/view/graphElements/QtGraphNodeExpandToggle.h
qt/view/graphElements/QtGraphNodeGroup.cpp
qt/view/graphElements/QtGraphNodeGroup.h
qt/view/graphElements/QtGraphNodeQualifier.cpp
qt/view/graphElements/QtGraphNodeQualifier.h
qt/view/graphElements/QtGraphNodeText.cpp
qt/view/graphElements/QtGraphNodeText.h
qt/view/QtBookmarkButtonsView.cpp
qt/view/QtBookmarkButtonsView.h
qt/view/QtBookmarkView.cpp
-222
View File
@@ -1,222 +0,0 @@
#include "QtIconButton.h"
#include <QEvent>
#include "utilityQt.h"
#include "ColorScheme.h"
QtHoverButton::QtHoverButton(QWidget* parent)
: QPushButton("", parent)
{
setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac
setMouseTracking(true);
}
void QtHoverButton::enterEvent(QEvent *event)
{
if (isEnabled())
{
emit hoveredIn(this);
}
}
void QtHoverButton::leaveEvent(QEvent *event)
{
if (isEnabled())
{
emit hoveredOut(this);
}
}
QtIconButton::QtIconButton(const FilePath& iconPath, const FilePath& hoveredIconPath, QWidget* parent)
: QPushButton("", parent)
, m_iconPath(iconPath)
, m_hoveredIconPath(hoveredIconPath)
, m_color(Qt::transparent)
{
setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac
if (!m_hoveredIconPath.empty())
{
setMouseTracking(true);
}
leaveEvent(nullptr);
}
void QtIconButton::setColor(QColor color)
{
m_color = color;
leaveEvent(nullptr);
}
void QtIconButton::enterEvent(QEvent *event)
{
if (!m_hoveredIconPath.empty() && isEnabled())
{
setIconFromPath(m_hoveredIconPath);
}
}
void QtIconButton::leaveEvent(QEvent *event)
{
if (!m_iconPath.empty())
{
setIconFromPath(m_iconPath);
}
}
void QtIconButton::setIconFromPath(const FilePath& path)
{
QPixmap pixmap = QPixmap(QString::fromStdWString(path.wstr()));
if (m_color != Qt::transparent)
{
pixmap = utility::colorizePixmap(pixmap, m_color);
}
setIcon(QIcon(pixmap));
}
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(MessageRefreshUI* message)
{
m_onQtThread([this]()
{
refresh();
});
}
void QtSelfRefreshIconButton::refresh()
{
if (!m_iconPath.empty())
{
setIcon(utility::createButtonIcon(m_iconPath, m_buttonKey));
}
}
QtIconStateButton::QtIconStateButton(QWidget* parent)
: QPushButton("", parent)
{
setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac
setMouseTracking(true);
setObjectName("iconStateButton");
leaveEvent(nullptr);
}
void QtIconStateButton::addState(ButtonState buttonState, const FilePath& iconPath, QColor color)
{
State state;
state.iconPath = iconPath;
state.color = color;
m_states.emplace(buttonState, state);
if (buttonState == STATE_DEFAULT)
{
leaveEvent(nullptr);
}
}
void QtIconStateButton::hoverIn()
{
enterEvent(nullptr);
}
void QtIconStateButton::hoverOut()
{
leaveEvent(nullptr);
}
void QtIconStateButton::changeEvent(QEvent *event)
{
if (event->type() != QEvent::EnabledChange)
{
return;
}
auto it = m_states.find(isEnabled() ? STATE_DEFAULT : STATE_DISABLED);
if (it != m_states.end())
{
setState(it->second);
}
}
void QtIconStateButton::enterEvent(QEvent *event)
{
if (!isEnabled())
{
return;
}
auto it = m_states.find(STATE_HOVERED);
if (it != m_states.end())
{
setState(it->second);
if (event)
{
emit hoveredIn(this);
}
}
}
void QtIconStateButton::leaveEvent(QEvent *event)
{
if (!isEnabled())
{
return;
}
auto it = m_states.find(STATE_DEFAULT);
if (it != m_states.end())
{
setState(it->second);
if (event)
{
emit hoveredOut(this);
}
}
}
void QtIconStateButton::setState(State state)
{
QPixmap pixmap = QPixmap(QString::fromStdWString(state.iconPath.wstr()));
if (state.color != Qt::transparent)
{
pixmap = utility::colorizePixmap(pixmap, state.color);
}
QIcon icon(pixmap);
icon.addPixmap(pixmap, QIcon::Disabled);
setIcon(icon);
}
-119
View File
@@ -1,119 +0,0 @@
#ifndef QT_ICON_BUTTON_H
#define QT_ICON_BUTTON_H
#include <QPushButton>
#include "FilePath.h"
#include "MessageListener.h"
#include "MessageRefreshUI.h"
#include "QtThreadedFunctor.h"
class QtHoverButton
: public QPushButton
{
Q_OBJECT
public:
QtHoverButton(QWidget* parent = nullptr);
signals:
void hoveredIn(QPushButton*);
void hoveredOut(QPushButton*);
protected:
void enterEvent(QEvent *event);
void leaveEvent(QEvent *event);
};
class QtIconButton
: public QPushButton
{
Q_OBJECT
public:
QtIconButton(const FilePath& iconPath, const FilePath& hoveredIconPath, QWidget* parent = nullptr);
~QtIconButton() = default;
void setColor(QColor color);
protected:
void enterEvent(QEvent *event);
void leaveEvent(QEvent *event);
private:
void setIconFromPath(const FilePath& path);
const FilePath m_iconPath;
const FilePath m_hoveredIconPath;
QColor m_color;
};
class QtSelfRefreshIconButton
: public QPushButton
, public MessageListener<MessageRefreshUI>
{
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(MessageRefreshUI* message) override;
virtual void refresh();
private:
QtThreadedLambdaFunctor m_onQtThread;
FilePath m_iconPath;
const std::string m_buttonKey;
};
class QtIconStateButton
: public QPushButton
{
Q_OBJECT
public:
enum ButtonState
{
STATE_DEFAULT,
STATE_HOVERED,
STATE_DISABLED
};
struct State
{
FilePath iconPath;
QColor color;
};
QtIconStateButton(QWidget* parent = nullptr);
void addState(ButtonState buttonState, const FilePath& iconPath, QColor color = Qt::transparent);
void hoverIn();
void hoverOut();
signals:
void hoveredIn(QPushButton*);
void hoveredOut(QPushButton*);
protected:
void changeEvent(QEvent *event);
void enterEvent(QEvent *event);
void leaveEvent(QEvent *event);
private:
void setState(State state);
std::map<ButtonState, State> m_states;
};
#endif // QT_ICON_BUTTON_H
@@ -0,0 +1,24 @@
#include "QtHoverButton.h"
QtHoverButton::QtHoverButton(QWidget* parent)
: QPushButton("", parent)
{
setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac
setMouseTracking(true);
}
void QtHoverButton::enterEvent(QEvent *event)
{
if (isEnabled())
{
emit hoveredIn(this);
}
}
void QtHoverButton::leaveEvent(QEvent *event)
{
if (isEnabled())
{
emit hoveredOut(this);
}
}
@@ -0,0 +1,23 @@
#ifndef QT_HOVER_BUTTON_H
#define QT_HOVER_BUTTON_H
#include <QPushButton>
class QtHoverButton
: public QPushButton
{
Q_OBJECT
public:
QtHoverButton(QWidget* parent = nullptr);
signals:
void hoveredIn(QPushButton*);
void hoveredOut(QPushButton*);
protected:
void enterEvent(QEvent *event);
void leaveEvent(QEvent *event);
};
#endif // QT_HOVER_BUTTON_H
@@ -0,0 +1,56 @@
#include "QtIconButton.h"
#include <QEvent>
#include "utilityQt.h"
QtIconButton::QtIconButton(const FilePath& iconPath, const FilePath& hoveredIconPath, QWidget* parent)
: QPushButton("", parent)
, m_iconPath(iconPath)
, m_hoveredIconPath(hoveredIconPath)
, m_color(Qt::transparent)
{
setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac
if (!m_hoveredIconPath.empty())
{
setMouseTracking(true);
}
leaveEvent(nullptr);
}
void QtIconButton::setColor(QColor color)
{
m_color = color;
leaveEvent(nullptr);
}
void QtIconButton::enterEvent(QEvent *event)
{
if (!m_hoveredIconPath.empty() && isEnabled())
{
setIconFromPath(m_hoveredIconPath);
}
}
void QtIconButton::leaveEvent(QEvent *event)
{
if (!m_iconPath.empty())
{
setIconFromPath(m_iconPath);
}
}
void QtIconButton::setIconFromPath(const FilePath& path)
{
QPixmap pixmap = QPixmap(QString::fromStdWString(path.wstr()));
if (m_color != Qt::transparent)
{
pixmap = utility::colorizePixmap(pixmap, m_color);
}
setIcon(QIcon(pixmap));
}
@@ -0,0 +1,31 @@
#ifndef QT_ICON_BUTTON_H
#define QT_ICON_BUTTON_H
#include <QPushButton>
#include "FilePath.h"
class QtIconButton
: public QPushButton
{
Q_OBJECT
public:
QtIconButton(const FilePath& iconPath, const FilePath& hoveredIconPath, QWidget* parent = nullptr);
~QtIconButton() = default;
void setColor(QColor color);
protected:
void enterEvent(QEvent *event);
void leaveEvent(QEvent *event);
private:
void setIconFromPath(const FilePath& path);
const FilePath m_iconPath;
const FilePath m_hoveredIconPath;
QColor m_color;
};
#endif // QT_ICON_BUTTON_H
@@ -0,0 +1,107 @@
#include "QtIconStateButton.h"
#include <QEvent>
#include "utilityQt.h"
QtIconStateButton::QtIconStateButton(QWidget* parent)
: QPushButton("", parent)
{
setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac
setMouseTracking(true);
setObjectName("iconStateButton");
leaveEvent(nullptr);
}
void QtIconStateButton::addState(ButtonState buttonState, const FilePath& iconPath, QColor color)
{
State state;
state.iconPath = iconPath;
state.color = color;
m_states.emplace(buttonState, state);
if (buttonState == STATE_DEFAULT)
{
leaveEvent(nullptr);
}
}
void QtIconStateButton::hoverIn()
{
enterEvent(nullptr);
}
void QtIconStateButton::hoverOut()
{
leaveEvent(nullptr);
}
void QtIconStateButton::changeEvent(QEvent *event)
{
if (event->type() != QEvent::EnabledChange)
{
return;
}
auto it = m_states.find(isEnabled() ? STATE_DEFAULT : STATE_DISABLED);
if (it != m_states.end())
{
setState(it->second);
}
}
void QtIconStateButton::enterEvent(QEvent *event)
{
if (!isEnabled())
{
return;
}
auto it = m_states.find(STATE_HOVERED);
if (it != m_states.end())
{
setState(it->second);
if (event)
{
emit hoveredIn(this);
}
}
}
void QtIconStateButton::leaveEvent(QEvent *event)
{
if (!isEnabled())
{
return;
}
auto it = m_states.find(STATE_DEFAULT);
if (it != m_states.end())
{
setState(it->second);
if (event)
{
emit hoveredOut(this);
}
}
}
void QtIconStateButton::setState(State state)
{
QPixmap pixmap = QPixmap(QString::fromStdWString(state.iconPath.wstr()));
if (state.color != Qt::transparent)
{
pixmap = utility::colorizePixmap(pixmap, state.color);
}
QIcon icon(pixmap);
icon.addPixmap(pixmap, QIcon::Disabled);
setIcon(icon);
}
@@ -0,0 +1,49 @@
#ifndef QT_ICON_STATE_BUTTON_H
#define QT_ICON_STATE_BUTTON_H
#include <QPushButton>
#include "FilePath.h"
class QtIconStateButton
: public QPushButton
{
Q_OBJECT
public:
enum ButtonState
{
STATE_DEFAULT,
STATE_HOVERED,
STATE_DISABLED
};
struct State
{
FilePath iconPath;
QColor color;
};
QtIconStateButton(QWidget* parent = nullptr);
void addState(ButtonState buttonState, const FilePath& iconPath, QColor color = Qt::transparent);
void hoverIn();
void hoverOut();
signals:
void hoveredIn(QPushButton*);
void hoveredOut(QPushButton*);
protected:
void changeEvent(QEvent *event);
void enterEvent(QEvent *event);
void leaveEvent(QEvent *event);
private:
void setState(State state);
std::map<ButtonState, State> m_states;
};
#endif // QT_ICON_STATE_BUTTON_H
@@ -0,0 +1,39 @@
#include "QtSelfRefreshIconButton.h"
#include "utilityQt.h"
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(MessageRefreshUI* message)
{
m_onQtThread([this]()
{
refresh();
});
}
void QtSelfRefreshIconButton::refresh()
{
if (!m_iconPath.empty())
{
setIcon(utility::createButtonIcon(m_iconPath, m_buttonKey));
}
}
@@ -0,0 +1,34 @@
#ifndef QT_SELF_REFRESH_ICON_BUTTON_H
#define QT_SELF_REFRESH_ICON_BUTTON_H
#include <QPushButton>
#include "FilePath.h"
#include "MessageListener.h"
#include "MessageRefreshUI.h"
#include "QtThreadedFunctor.h"
class QtSelfRefreshIconButton
: public QPushButton
, public MessageListener<MessageRefreshUI>
{
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(MessageRefreshUI* message) override;
virtual void refresh();
private:
QtThreadedLambdaFunctor m_onQtThread;
FilePath m_iconPath;
const std::string m_buttonKey;
};
#endif // QT_SELF_REFRESH_ICON_BUTTON_H
@@ -5,9 +5,11 @@
#include <QVariant>
#include "Application.h"
#include "Project.h"
#include "ResourcePaths.h"
#include "MessageErrorsForFile.h"
#include "Project.h"
#include "QtIconStateButton.h"
#include "QtSelfRefreshIconButton.h"
#include "ResourcePaths.h"
QtCodeFileTitleBar::QtCodeFileTitleBar(QWidget* parent, bool isHovering, bool isSingle)
: QtHoverButton(parent)
@@ -2,11 +2,12 @@
#define QT_CODE_FILE_TITLE_BAR_H
#include "QtCodeFileTitleButton.h"
#include "QtIconButton.h"
#include "QtHoverButton.h"
class QLabel;
class QtCodeFileTitleButton;
class QtIconStateButton;
class QtSelfRefreshIconButton;
class QtCodeFileTitleBar
: public QtHoverButton
@@ -2,10 +2,9 @@
#define QT_CODE_FILE_TITLE_BUTTON_H
#include "FilePath.h"
#include "QtSelfRefreshIconButton.h"
#include "TimeStamp.h"
#include "QtIconButton.h"
class QtCodeFileTitleButton
: public QtSelfRefreshIconButton
{
@@ -8,9 +8,9 @@
#include <QPushButton>
#include <QTimer>
#include "QtIconButton.h"
#include "utilityQt.h"
#include "QtSelfRefreshIconButton.h"
#include "ResourcePaths.h"
#include "utilityQt.h"
QtFocusInFilter::QtFocusInFilter(QObject* parent)
@@ -1,7 +1,7 @@
#ifndef QT_SEARCH_BAR_BUTTON_H
#define QT_SEARCH_BAR_BUTTON_H
#include "QtIconButton.h"
#include "QtSelfRefreshIconButton.h"
class QtSearchBarButton
: public QtSelfRefreshIconButton
@@ -11,15 +11,6 @@
#include <QParallelAnimationGroup>
#include <QSvgGenerator>
#include "QtIconButton.h"
#include "QtGraphEdge.h"
#include "QtGraphNode.h"
#include "QtGraphNodeBundle.h"
#include "QtGraphNodeData.h"
#include "QtGraphNodeExpandToggle.h"
#include "QtContextMenu.h"
#include "QtFileDialog.h"
#include "utilityQt.h"
#include "ApplicationSettings.h"
#include "MessageActivateLegend.h"
#include "MessageBookmarkCreate.h"
@@ -27,8 +18,17 @@
#include "MessageGraphNodeExpand.h"
#include "MessageGraphNodeHide.h"
#include "MessageTabOpenWith.h"
#include "QtContextMenu.h"
#include "QtFileDialog.h"
#include "QtGraphEdge.h"
#include "QtGraphNode.h"
#include "QtGraphNodeBundle.h"
#include "QtGraphNodeData.h"
#include "QtGraphNodeExpandToggle.h"
#include "QtSelfRefreshIconButton.h"
#include "ResourcePaths.h"
#include "utilityApp.h"
#include "utilityQt.h"
QtGraphicsView::QtGraphicsView(QWidget* parent)
: QGraphicsView(parent)

Some files were not shown because too many files have changed in this diff Show More