From 842a39600c5c1c997d861dc3252298246c0f48f9 Mon Sep 17 00:00:00 2001 From: Nav Date: Sat, 18 Dec 2021 00:16:11 +0000 Subject: [PATCH] Created custom BloomProxyStyle to override Qt system styles --- CMakeLists.txt | 1 + src/Insight/Insight.cpp | 8 +++----- .../InsightWindow/BloomProxyStyle.cpp | 16 ++++++++++++++++ .../InsightWindow/BloomProxyStyle.hpp | 19 +++++++++++++++++++ 4 files changed, 39 insertions(+), 5 deletions(-) create mode 100644 src/Insight/UserInterfaces/InsightWindow/BloomProxyStyle.cpp create mode 100644 src/Insight/UserInterfaces/InsightWindow/BloomProxyStyle.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index ddba2bab..1bcc09e5 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -134,6 +134,7 @@ add_executable(Bloom src/Insight/Insight.cpp src/Insight/InsightWorker/InsightWorker.cpp src/Insight/UserInterfaces/InsightWindow/UiLoader.cpp + src/Insight/UserInterfaces/InsightWindow/BloomProxyStyle.cpp src/Insight/UserInterfaces/InsightWindow/InsightWindow.cpp src/Insight/UserInterfaces/InsightWindow/AboutWindow.cpp src/Insight/UserInterfaces/InsightWindow/Widgets/PanelWidget.cpp diff --git a/src/Insight/Insight.cpp b/src/Insight/Insight.cpp index ce4f01b2..315665b8 100644 --- a/src/Insight/Insight.cpp +++ b/src/Insight/Insight.cpp @@ -1,17 +1,14 @@ #include "Insight.hpp" -#include #include #include #include "src/Helpers/Paths.hpp" #include "src/Logger/Logger.hpp" -#include "src/Exceptions/InvalidConfig.hpp" -#include "src/Targets/TargetState.hpp" +#include "UserInterfaces/InsightWindow/BloomProxyStyle.hpp" #include "src/Application.hpp" #include "InsightWorker/Tasks/QueryLatestVersionNumber.hpp" -#include "src/VersionNumber.hpp" using namespace Bloom; using namespace Bloom::Exceptions; @@ -56,7 +53,8 @@ void Insight::startup() { auto targetDescriptor = this->targetControllerConsole.getTargetDescriptor(); - this->application.setQuitOnLastWindowClosed(true); + QApplication::setQuitOnLastWindowClosed(true); + QApplication::setStyle(new BloomProxyStyle()); qRegisterMetaType(); qRegisterMetaType(); qRegisterMetaType(); diff --git a/src/Insight/UserInterfaces/InsightWindow/BloomProxyStyle.cpp b/src/Insight/UserInterfaces/InsightWindow/BloomProxyStyle.cpp new file mode 100644 index 00000000..c3e5923c --- /dev/null +++ b/src/Insight/UserInterfaces/InsightWindow/BloomProxyStyle.cpp @@ -0,0 +1,16 @@ +#include "BloomProxyStyle.hpp" + +using namespace Bloom; + +int BloomProxyStyle::styleHint( + StyleHint hint, + const QStyleOption* option, + const QWidget* widget, + QStyleHintReturn* returnData +) const { + if (hint == QStyle::SH_ComboBox_Popup) { + return 0; + } + + return QProxyStyle::styleHint(hint, option, widget, returnData); +} diff --git a/src/Insight/UserInterfaces/InsightWindow/BloomProxyStyle.hpp b/src/Insight/UserInterfaces/InsightWindow/BloomProxyStyle.hpp new file mode 100644 index 00000000..409338d4 --- /dev/null +++ b/src/Insight/UserInterfaces/InsightWindow/BloomProxyStyle.hpp @@ -0,0 +1,19 @@ +#pragma once + +#include + +namespace Bloom +{ + class BloomProxyStyle: public QProxyStyle + { + Q_OBJECT + + public: + int styleHint( + StyleHint hint, + const QStyleOption* option = nullptr, + const QWidget* widget = nullptr, + QStyleHintReturn* returnData = nullptr + ) const override; + }; +}