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:
@@ -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));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user