From 91632b71b0986986f9255f6a1c0226f24bede586 Mon Sep 17 00:00:00 2001 From: Nav Date: Wed, 22 Dec 2021 03:32:51 +0000 Subject: [PATCH] Re-styled error dialogue --- .../Widgets/ErrorDialogue/ErrorDialogue.cpp | 18 +++-- .../Widgets/ErrorDialogue/ErrorDialogue.hpp | 6 +- .../Widgets/ErrorDialogue/Images/icon.svg | 45 ++++++----- .../Stylesheets/ErrorDialogue.qss | 12 +-- .../ErrorDialogue/UiFiles/ErrorDialogue.ui | 77 ++++++++++++------- 5 files changed, 92 insertions(+), 66 deletions(-) diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/ErrorDialogue/ErrorDialogue.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/ErrorDialogue/ErrorDialogue.cpp index 1bf665d8..d5517f56 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/ErrorDialogue/ErrorDialogue.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/ErrorDialogue/ErrorDialogue.cpp @@ -19,7 +19,6 @@ ErrorDialogue::ErrorDialogue( this->setObjectName("error-dialogue"); this->setAttribute(Qt::WA_DeleteOnClose, true); this->setWindowTitle(windowTitle); - this->setFixedSize(500, 180); auto dialogueUiFile = QFile( QString::fromStdString(Paths::compiledResourcesPath() @@ -46,13 +45,20 @@ ErrorDialogue::ErrorDialogue( auto uiLoader = UiLoader(this); this->container = uiLoader.load(&dialogueUiFile, this); - this->container->setFixedSize(this->size()); - this->container->setContentsMargins(15, 15, 15, 15); - - this->errorMessageLabel = this->container->findChild("error-message-label"); + this->errorMessageDescriptionLabel = this->container->findChild("error-message-description-label"); this->okButton = this->container->findChild("ok-btn"); - this->errorMessageLabel->setText(errorMessage); + this->container->setContentsMargins(15, 10, 15, 15); + + this->errorMessageDescriptionLabel->setText(errorMessage); QObject::connect(this->okButton, &QPushButton::clicked, this, &QDialog::close); } + +void ErrorDialogue::showEvent(QShowEvent* event) { + const auto containerSize = this->container->sizeHint(); + const auto windowSize = QSize(std::max(containerSize.width(), 500), std::max(containerSize.height(), 100)); + + this->setFixedSize(windowSize); + this->container->setFixedSize(windowSize); +} diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/ErrorDialogue/ErrorDialogue.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/ErrorDialogue/ErrorDialogue.hpp index 5681b213..224060df 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/ErrorDialogue/ErrorDialogue.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/ErrorDialogue/ErrorDialogue.hpp @@ -3,6 +3,7 @@ #include #include #include +#include namespace Bloom::Widgets { @@ -13,9 +14,12 @@ namespace Bloom::Widgets public: ErrorDialogue(const QString& windowTitle, const QString& errorMessage, QWidget* parent); + protected: + void showEvent(QShowEvent* event) override; + private: QWidget* container = nullptr; - QLabel* errorMessageLabel = nullptr; + QLabel* errorMessageDescriptionLabel = nullptr; QPushButton* okButton = nullptr; }; } diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/ErrorDialogue/Images/icon.svg b/src/Insight/UserInterfaces/InsightWindow/Widgets/ErrorDialogue/Images/icon.svg index e730a6bb..33bd5216 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/ErrorDialogue/Images/icon.svg +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/ErrorDialogue/Images/icon.svg @@ -7,9 +7,9 @@ xmlns="http://www.w3.org/2000/svg" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" - width="64" - height="64" - viewBox="0 0 16.933334 16.933333" + width="40" + height="44" + viewBox="0 0 10.583333 11.641666" version="1.1" id="svg974" sodipodi:docname="icon.svg" @@ -23,9 +23,9 @@ borderopacity="1.0" inkscape:pageopacity="0" inkscape:pageshadow="2" - inkscape:zoom="5.9851538" - inkscape:cx="23.56709" - inkscape:cy="34.557656" + inkscape:zoom="2.1160714" + inkscape:cx="-130.38062" + inkscape:cy="-2.8237951" inkscape:document-units="px" inkscape:current-layer="layer2" inkscape:document-rotation="0" @@ -70,20 +70,25 @@ id="layer2" inkscape:label="Layer 2"> + style="opacity:1;fill:#7f7f7e;fill-opacity:1;stroke-width:0.2144" + id="rect882" + width="9.5249996" + height="10.583333" + x="0.52916664" + y="0.52916658" /> + style="opacity:1;fill:#373835;fill-opacity:0.996078;stroke-width:0.21603" + id="rect835" + width="1.5875" + height="4.2333331" + x="4.4979162" + y="2.6458333" /> + diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/ErrorDialogue/Stylesheets/ErrorDialogue.qss b/src/Insight/UserInterfaces/InsightWindow/Widgets/ErrorDialogue/Stylesheets/ErrorDialogue.qss index 031a7037..f907f77d 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/ErrorDialogue/Stylesheets/ErrorDialogue.qss +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/ErrorDialogue/Stylesheets/ErrorDialogue.qss @@ -1,15 +1,7 @@ -* { - color: #afb1b3; - font-family: 'Ubuntu', sans-serif; - font-size: 14px; -} - #error-dialogue { background-color: #373835; } -QPushButton { - background-color: #373937; - border: 1px solid #484A49; - padding: 3px 25px; +#error-message-title-label { + font-size: 16px; } diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/ErrorDialogue/UiFiles/ErrorDialogue.ui b/src/Insight/UserInterfaces/InsightWindow/Widgets/ErrorDialogue/UiFiles/ErrorDialogue.ui index bdeacec9..fddc26fe 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/ErrorDialogue/UiFiles/ErrorDialogue.ui +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/ErrorDialogue/UiFiles/ErrorDialogue.ui @@ -2,24 +2,59 @@ - - - - :/compiled/src/Insight/UserInterfaces/InsightWindow/Widgets/ErrorDialogue/Images/icon.svg + + 0 + + + + + 0 - - 64 - - - 74 - - + + + + :/compiled/src/Insight/UserInterfaces/InsightWindow/Widgets/ErrorDialogue/Images/icon.svg + + + 44 + + + 40 + + + + + + + + 10 + + + + QSizePolicy::Fixed + + + + + + + + + + true + + + Qt::AlignLeft + + + + - 20 + 10 @@ -27,23 +62,7 @@ - - - - true - - - Qt::AlignHCenter - - - 65 - - - 480 - - - - + Qt::Vertical