Re-styled error dialogue

This commit is contained in:
Nav
2021-12-22 03:32:51 +00:00
parent 7aee91c5ff
commit 91632b71b0
5 changed files with 92 additions and 66 deletions

View File

@@ -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<QLabel*>("error-message-label");
this->errorMessageDescriptionLabel = this->container->findChild<QLabel*>("error-message-description-label");
this->okButton = this->container->findChild<QPushButton*>("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);
}

View File

@@ -3,6 +3,7 @@
#include <QDialog>
#include <QLabel>
#include <QPushButton>
#include <QShowEvent>
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;
};
}

View File

@@ -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">
<rect
style="fill:#6f383a;fill-opacity:0.996078;stroke:none;stroke-width:1.32559;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect935"
width="2.6458333"
height="12.7"
x="-1.3229166"
y="5.6236749"
transform="rotate(-45)" />
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" />
<rect
style="fill:#6f383a;fill-opacity:0.996078;stroke:none;stroke-width:1.32559;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect935-5"
width="2.6458333"
height="12.7"
x="10.650759"
y="-6.3499999"
transform="rotate(45)" />
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" />
<rect
style="opacity:1;fill:#373835;fill-opacity:0.996078;stroke-width:0.132291"
id="rect835-3"
width="1.5875"
height="1.5875"
x="4.4979162"
y="7.6729188" />
</g>
</svg>

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

View File

@@ -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;
}

View File

@@ -2,24 +2,32 @@
<ui version="4.0">
<widget class="QWidget" name="container">
<layout class="QVBoxLayout">
<item alignment="Qt::AlignHCenter">
<property name="spacing">
<number>0</number>
</property>
<item>
<layout class="QHBoxLayout">
<property name="spacing">
<number>0</number>
</property>
<item alignment="Qt::AlignTop">
<widget class="SvgWidget" name="icon">
<property name="svgFilePath">
<string>:/compiled/src/Insight/UserInterfaces/InsightWindow/Widgets/ErrorDialogue/Images/icon.svg</string>
</property>
<property name="containerHeight">
<number>64</number>
<number>44</number>
</property>
<property name="containerWidth">
<number>74</number>
<number>40</number>
</property>
</widget>
</item>
<item>
<spacer name="vertical-spacer">
<spacer name="horizontal-spacer">
<property name="sizeHint">
<size>
<height>20</height>
<width>10</width>
</size>
</property>
<property name="sizeType">
@@ -27,23 +35,34 @@
</property>
</spacer>
</item>
<item alignment="Qt::AlignHCenter">
<widget class="QLabel" name="error-message-label">
<item alignment="Qt::AlignVCenter">
<widget class="QLabel" name="error-message-description-label">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed"/>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="alignment">
<enum>Qt::AlignHCenter</enum>
</property>
<property name="minimumHeight">
<number>65</number>
</property>
<property name="minimumWidth">
<number>480</number>
<enum>Qt::AlignLeft</enum>
</property>
</widget>
</item>
<item alignment="Qt::AlignHCenter">
</layout>
</item>
<item>
<spacer name="vertical-spacer">
<property name="sizeHint">
<size>
<height>10</height>
</size>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
</spacer>
</item>
<item alignment="Qt::AlignLeft">
<spacer name="vertical-spacer">
<property name="orientation">
<enum>Qt::Vertical</enum>