Created custom PushButton widget and added custom styleName property for styling primary buttons
This commit is contained in:
@@ -18,6 +18,7 @@ target_sources(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/UserInterfaces/InsightWindow/Widgets/SvgToolButton.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/UserInterfaces/InsightWindow/Widgets/ClickableWidget.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/UserInterfaces/InsightWindow/Widgets/ExpandingHeightScrollAreaWidget.hpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/UserInterfaces/InsightWindow/Widgets/PushButton.cpp
|
||||
|
||||
# Insight worker tasks
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/InsightWorker/Tasks/InsightWorkerTask.cpp
|
||||
|
||||
@@ -199,3 +199,8 @@ Bloom--Widgets--SvgToolButton QMenu::item {
|
||||
padding-left: 10px;
|
||||
min-width: 250px;
|
||||
}
|
||||
|
||||
Bloom--Widgets--PushButton[styleName="primary"] {
|
||||
background-color: #353C41;
|
||||
border: 1px solid #454C52;
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "Widgets/RotatableLabel.hpp"
|
||||
#include "Widgets/LabeledSeparator.hpp"
|
||||
#include "Widgets/TextInput.hpp"
|
||||
#include "Widgets/PushButton.hpp"
|
||||
#include "Widgets/SvgWidget.hpp"
|
||||
#include "Widgets/SvgToolButton.hpp"
|
||||
#include "Widgets/ExpandingHeightScrollAreaWidget.hpp"
|
||||
@@ -54,6 +55,15 @@ namespace Bloom
|
||||
return widget;
|
||||
}
|
||||
},
|
||||
{
|
||||
"PushButton",
|
||||
[this] (QWidget* parent, const QString& name) {
|
||||
auto* widget = new PushButton(parent);
|
||||
widget->setObjectName(name);
|
||||
widget->setStyleSheet(parent->styleSheet());
|
||||
return widget;
|
||||
}
|
||||
},
|
||||
{
|
||||
"ExpandingHeightScrollAreaWidget",
|
||||
[this] (QWidget* parent, const QString& name) {
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
#include "PushButton.hpp"
|
||||
|
||||
namespace Bloom::Widgets
|
||||
{
|
||||
PushButton::PushButton(QWidget* parent)
|
||||
: QPushButton(parent)
|
||||
{}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
#pragma once
|
||||
|
||||
#include <QPushButton>
|
||||
#include <QString>
|
||||
|
||||
namespace Bloom::Widgets
|
||||
{
|
||||
class PushButton: public QPushButton
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QString styleName READ getStyleName WRITE setStyleName DESIGNABLE true)
|
||||
|
||||
public:
|
||||
explicit PushButton(QWidget* parent = nullptr);
|
||||
|
||||
void setStyleName(const QString& styleName) {
|
||||
this->styleName = styleName;
|
||||
}
|
||||
|
||||
[[nodiscard]] QString getStyleName() const {
|
||||
return this->styleName;
|
||||
}
|
||||
|
||||
protected:
|
||||
QString styleName;
|
||||
};
|
||||
}
|
||||
@@ -77,9 +77,9 @@ namespace Bloom::Widgets
|
||||
|
||||
this->stackedFormLayout = this->container->findChild<QStackedLayout*>("stacked-form-layout");
|
||||
|
||||
this->applyButton = this->container->findChild<QPushButton*>("apply-btn");
|
||||
this->helpButton = this->container->findChild<QPushButton*>("help-btn");
|
||||
this->closeButton = this->container->findChild<QPushButton*>("close-btn");
|
||||
this->applyButton = this->container->findChild<PushButton*>("apply-btn");
|
||||
this->helpButton = this->container->findChild<PushButton*>("help-btn");
|
||||
this->closeButton = this->container->findChild<PushButton*>("close-btn");
|
||||
|
||||
regionSelectorToolBar->setContentsMargins(0, 0, 0, 0);
|
||||
this->regionItemScrollArea->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <QWidget>
|
||||
#include <QPushButton>
|
||||
#include <set>
|
||||
#include <vector>
|
||||
#include <QShowEvent>
|
||||
@@ -17,6 +16,7 @@
|
||||
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/ExcludedMemoryRegion.hpp"
|
||||
|
||||
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/SvgToolButton.hpp"
|
||||
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/PushButton.hpp"
|
||||
#include "RegionItem.hpp"
|
||||
#include "FocusedRegionItem.hpp"
|
||||
#include "ExcludedRegionItem.hpp"
|
||||
@@ -51,9 +51,9 @@ namespace Bloom::Widgets
|
||||
QWidget* container = nullptr;
|
||||
QWidget* regionSelector = nullptr;
|
||||
|
||||
QPushButton* applyButton = nullptr;
|
||||
QPushButton* helpButton = nullptr;
|
||||
QPushButton* closeButton = nullptr;
|
||||
PushButton* applyButton = nullptr;
|
||||
PushButton* helpButton = nullptr;
|
||||
PushButton* closeButton = nullptr;
|
||||
|
||||
SvgToolButton* addRegionButton = nullptr;
|
||||
QAction* addFocusedRegionMenuAction = nullptr;
|
||||
|
||||
@@ -130,8 +130,3 @@
|
||||
border-top: 1px solid #2F2F2D;
|
||||
min-height: 50px;
|
||||
}
|
||||
|
||||
#apply-btn {
|
||||
background-color: #353C41;
|
||||
border: 1px solid #454C52;
|
||||
}
|
||||
|
||||
@@ -200,7 +200,7 @@
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="help-btn">
|
||||
<widget class="PushButton" name="help-btn">
|
||||
<property name="text">
|
||||
<string>Help</string>
|
||||
</property>
|
||||
@@ -214,14 +214,17 @@
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="close-btn">
|
||||
<widget class="PushButton" name="close-btn">
|
||||
<property name="text">
|
||||
<string>Close</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="apply-btn">
|
||||
<widget class="PushButton" name="apply-btn">
|
||||
<property name="styleName">
|
||||
<string>primary</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>OK</string>
|
||||
</property>
|
||||
|
||||
@@ -28,11 +28,6 @@
|
||||
max-width: 500px;
|
||||
}
|
||||
|
||||
#apply-btn {
|
||||
background-color: #353C41;
|
||||
border: 1px solid #454C52;
|
||||
}
|
||||
|
||||
/* BitsetWidget */
|
||||
#bitset-widget {
|
||||
font-size: 12px;
|
||||
|
||||
@@ -81,10 +81,10 @@ namespace Bloom::Widgets
|
||||
this->registerValueBitsetWidgetContainer = this->registerValueContainer->findChild<QWidget*>(
|
||||
"register-value-bitset-widget-container"
|
||||
);
|
||||
this->refreshValueButton = this->container->findChild<QPushButton*>("refresh-value-btn");
|
||||
this->applyButton = this->container->findChild<QPushButton*>("apply-btn");
|
||||
this->helpButton = this->container->findChild<QPushButton*>("help-btn");
|
||||
this->closeButton = this->container->findChild<QPushButton*>("close-btn");
|
||||
this->refreshValueButton = this->container->findChild<PushButton*>("refresh-value-btn");
|
||||
this->applyButton = this->container->findChild<PushButton*>("apply-btn");
|
||||
this->helpButton = this->container->findChild<PushButton*>("help-btn");
|
||||
this->closeButton = this->container->findChild<PushButton*>("close-btn");
|
||||
|
||||
this->registerHistoryWidget = new RegisterHistoryWidget(
|
||||
this->registerDescriptor,
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
#include <QWidget>
|
||||
#include <QLineEdit>
|
||||
#include <QPushButton>
|
||||
#include <set>
|
||||
#include <QSize>
|
||||
#include <QString>
|
||||
@@ -14,6 +13,7 @@
|
||||
#include "src/Targets/TargetState.hpp"
|
||||
|
||||
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/Label.hpp"
|
||||
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/PushButton.hpp"
|
||||
#include "BitsetWidget/BitsetWidget.hpp"
|
||||
#include "RegisterHistoryWidget/RegisterHistoryWidget.hpp"
|
||||
|
||||
@@ -54,10 +54,10 @@ namespace Bloom::Widgets
|
||||
QWidget* registerValueBitsetWidgetContainer = nullptr;
|
||||
std::vector<BitsetWidget*> bitsetWidgets;
|
||||
|
||||
QPushButton* refreshValueButton = nullptr;
|
||||
QPushButton* applyButton = nullptr;
|
||||
QPushButton* helpButton = nullptr;
|
||||
QPushButton* closeButton = nullptr;
|
||||
PushButton* refreshValueButton = nullptr;
|
||||
PushButton* applyButton = nullptr;
|
||||
PushButton* helpButton = nullptr;
|
||||
PushButton* closeButton = nullptr;
|
||||
|
||||
Targets::TargetState targetState = Targets::TargetState::UNKNOWN;
|
||||
|
||||
|
||||
@@ -330,7 +330,7 @@
|
||||
<number>15</number>
|
||||
</property>
|
||||
<item alignment="Qt::AlignCenter">
|
||||
<widget class="QPushButton" name="refresh-value-btn">
|
||||
<widget class="PushButton" name="refresh-value-btn">
|
||||
<property name="text">
|
||||
<string>Refresh Value</string>
|
||||
</property>
|
||||
@@ -344,7 +344,10 @@
|
||||
</spacer>
|
||||
</item>
|
||||
<item alignment="Qt::AlignCenter">
|
||||
<widget class="QPushButton" name="apply-btn">
|
||||
<widget class="PushButton" name="apply-btn">
|
||||
<property name="styleName">
|
||||
<string>primary</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Write Value</string>
|
||||
</property>
|
||||
@@ -414,7 +417,7 @@
|
||||
</spacer>
|
||||
</item>
|
||||
<item alignment="Qt::AlignRight">
|
||||
<widget class="QPushButton" name="help-btn">
|
||||
<widget class="PushButton" name="help-btn">
|
||||
<property name="text">
|
||||
<string>Help</string>
|
||||
</property>
|
||||
@@ -428,7 +431,7 @@
|
||||
</spacer>
|
||||
</item>
|
||||
<item alignment="Qt::AlignRight">
|
||||
<widget class="QPushButton" name="close-btn">
|
||||
<widget class="PushButton" name="close-btn">
|
||||
<property name="text">
|
||||
<string>Close</string>
|
||||
</property>
|
||||
|
||||
Reference in New Issue
Block a user