Bloom Inisght error dialogue
This commit is contained in:
@@ -0,0 +1,58 @@
|
|||||||
|
#include "ErrorDialogue.hpp"
|
||||||
|
|
||||||
|
#include <QHBoxLayout>
|
||||||
|
#include <QFile>
|
||||||
|
|
||||||
|
#include "src/Helpers/Paths.hpp"
|
||||||
|
#include "src/Insight/UserInterfaces/InsightWindow/UiLoader.hpp"
|
||||||
|
#include "src/Exceptions/Exception.hpp"
|
||||||
|
|
||||||
|
using namespace Bloom::Widgets;
|
||||||
|
|
||||||
|
using Bloom::Exceptions::Exception;
|
||||||
|
|
||||||
|
ErrorDialogue::ErrorDialogue(
|
||||||
|
const QString& windowTitle,
|
||||||
|
const QString& errorMessage,
|
||||||
|
QWidget* parent
|
||||||
|
): QDialog(parent) {
|
||||||
|
this->setObjectName("error-dialogue");
|
||||||
|
this->setAttribute(Qt::WA_DeleteOnClose, true);
|
||||||
|
this->setWindowTitle(windowTitle);
|
||||||
|
this->setFixedSize(500, 180);
|
||||||
|
|
||||||
|
auto dialogueUiFile = QFile(
|
||||||
|
QString::fromStdString(Paths::compiledResourcesPath()
|
||||||
|
+ "/src/Insight/UserInterfaces/InsightWindow/Widgets/ErrorDialogue/UiFiles/ErrorDialogue.ui"
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
auto dialogueStylesheet = QFile(
|
||||||
|
QString::fromStdString(Paths::compiledResourcesPath()
|
||||||
|
+ "/src/Insight/UserInterfaces/InsightWindow/Widgets/ErrorDialogue/Stylesheets/ErrorDialogue.qss"
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!dialogueUiFile.open(QFile::ReadOnly)) {
|
||||||
|
throw Exception("Failed to open ErrorDialogue UI file");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!dialogueStylesheet.open(QFile::ReadOnly)) {
|
||||||
|
throw Exception("Failed to open ErrorDialogue stylesheet file");
|
||||||
|
}
|
||||||
|
|
||||||
|
this->setStyleSheet(dialogueStylesheet.readAll());
|
||||||
|
|
||||||
|
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->okButton = this->container->findChild<QPushButton*>("ok-btn");
|
||||||
|
|
||||||
|
this->errorMessageLabel->setText(errorMessage);
|
||||||
|
|
||||||
|
this->connect(this->okButton, &QPushButton::clicked, this, &QDialog::close);
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QDialog>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QPushButton>
|
||||||
|
|
||||||
|
namespace Bloom::Widgets
|
||||||
|
{
|
||||||
|
class Q_WIDGETS_EXPORT ErrorDialogue: public QDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
QWidget* container = nullptr;
|
||||||
|
QLabel* errorMessageLabel = nullptr;
|
||||||
|
QPushButton* okButton = nullptr;
|
||||||
|
|
||||||
|
public:
|
||||||
|
ErrorDialogue(const QString& windowTitle, const QString& errorMessage, QWidget* parent);
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -0,0 +1,89 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<svg
|
||||||
|
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||||
|
xmlns:cc="http://creativecommons.org/ns#"
|
||||||
|
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||||
|
xmlns:svg="http://www.w3.org/2000/svg"
|
||||||
|
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"
|
||||||
|
version="1.1"
|
||||||
|
id="svg974"
|
||||||
|
sodipodi:docname="icon.svg"
|
||||||
|
inkscape:version="1.0.1 (1.0.1+r75)">
|
||||||
|
<defs
|
||||||
|
id="defs968" />
|
||||||
|
<sodipodi:namedview
|
||||||
|
id="base"
|
||||||
|
pagecolor="#343532"
|
||||||
|
bordercolor="#666666"
|
||||||
|
borderopacity="1.0"
|
||||||
|
inkscape:pageopacity="0"
|
||||||
|
inkscape:pageshadow="2"
|
||||||
|
inkscape:zoom="5.9851538"
|
||||||
|
inkscape:cx="23.56709"
|
||||||
|
inkscape:cy="34.557656"
|
||||||
|
inkscape:document-units="px"
|
||||||
|
inkscape:current-layer="layer2"
|
||||||
|
inkscape:document-rotation="0"
|
||||||
|
showgrid="false"
|
||||||
|
units="px"
|
||||||
|
inkscape:snap-page="true"
|
||||||
|
inkscape:window-width="3440"
|
||||||
|
inkscape:window-height="1353"
|
||||||
|
inkscape:window-x="2560"
|
||||||
|
inkscape:window-y="34"
|
||||||
|
inkscape:window-maximized="1"
|
||||||
|
fit-margin-top="6"
|
||||||
|
fit-margin-left="6"
|
||||||
|
fit-margin-right="6"
|
||||||
|
fit-margin-bottom="6"
|
||||||
|
lock-margins="true"
|
||||||
|
inkscape:snap-object-midpoints="true"
|
||||||
|
inkscape:snap-smooth-nodes="true"
|
||||||
|
inkscape:snap-bbox="true"
|
||||||
|
inkscape:snap-bbox-edge-midpoints="true"
|
||||||
|
inkscape:snap-bbox-midpoints="true"
|
||||||
|
inkscape:bbox-nodes="true" />
|
||||||
|
<metadata
|
||||||
|
id="metadata971">
|
||||||
|
<rdf:RDF>
|
||||||
|
<cc:Work
|
||||||
|
rdf:about="">
|
||||||
|
<dc:format>image/svg+xml</dc:format>
|
||||||
|
<dc:type
|
||||||
|
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||||
|
<dc:title></dc:title>
|
||||||
|
</cc:Work>
|
||||||
|
</rdf:RDF>
|
||||||
|
</metadata>
|
||||||
|
<g
|
||||||
|
inkscape:label="Layer 1"
|
||||||
|
inkscape:groupmode="layer"
|
||||||
|
id="layer1"
|
||||||
|
transform="translate(1.3229167,1.0583334)" />
|
||||||
|
<g
|
||||||
|
inkscape:groupmode="layer"
|
||||||
|
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)" />
|
||||||
|
<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)" />
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 2.6 KiB |
@@ -0,0 +1,15 @@
|
|||||||
|
* {
|
||||||
|
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;
|
||||||
|
}
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<widget class="QWidget" name="container">
|
||||||
|
<layout class="QVBoxLayout">
|
||||||
|
<item alignment="Qt::AlignHCenter">
|
||||||
|
<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>
|
||||||
|
</property>
|
||||||
|
<property name="containerWidth">
|
||||||
|
<number>74</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="vertical-spacer">
|
||||||
|
<property name="sizeHint">
|
||||||
|
<size>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item alignment="Qt::AlignHCenter">
|
||||||
|
<widget class="QLabel" name="error-message-label">
|
||||||
|
<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>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item alignment="Qt::AlignHCenter">
|
||||||
|
<spacer name="vertical-spacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>15</number>
|
||||||
|
</property>
|
||||||
|
<item alignment="Qt::AlignCenter">
|
||||||
|
<widget class="QPushButton" name="ok-btn">
|
||||||
|
<property name="maximumWidth">
|
||||||
|
<number>90</number>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>OK</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</ui>
|
||||||
@@ -7,7 +7,8 @@
|
|||||||
#include <set>
|
#include <set>
|
||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
|
|
||||||
#include "../../UiLoader.hpp"
|
#include "src/Insight/UserInterfaces/InsightWindow/UiLoader.hpp"
|
||||||
|
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/ErrorDialogue/ErrorDialogue.hpp"
|
||||||
|
|
||||||
#include "src/Helpers/Paths.hpp"
|
#include "src/Helpers/Paths.hpp"
|
||||||
#include "src/Helpers/DateTime.hpp"
|
#include "src/Helpers/DateTime.hpp"
|
||||||
@@ -17,8 +18,8 @@
|
|||||||
#include "src/Insight/InsightWorker/Tasks/WriteTargetRegister.hpp"
|
#include "src/Insight/InsightWorker/Tasks/WriteTargetRegister.hpp"
|
||||||
|
|
||||||
using namespace Bloom::Widgets;
|
using namespace Bloom::Widgets;
|
||||||
using namespace Bloom::Exceptions;
|
|
||||||
|
|
||||||
|
using Bloom::Exceptions::Exception;
|
||||||
using Bloom::Targets::TargetRegisterDescriptor;
|
using Bloom::Targets::TargetRegisterDescriptor;
|
||||||
using Bloom::Targets::TargetRegisterDescriptors;
|
using Bloom::Targets::TargetRegisterDescriptors;
|
||||||
using Bloom::Targets::TargetRegisterType;
|
using Bloom::Targets::TargetRegisterType;
|
||||||
@@ -350,9 +351,16 @@ void TargetRegisterInspectorWindow::applyChanges() {
|
|||||||
this->registerHistoryWidget->selectCurrentItem();
|
this->registerHistoryWidget->selectCurrentItem();
|
||||||
});
|
});
|
||||||
|
|
||||||
this->connect(writeRegisterTask, &InsightWorkerTask::failed, this, [this] {
|
this->connect(writeRegisterTask, &InsightWorkerTask::failed, this, [this] (QString errorMessage) {
|
||||||
// TODO: Let the user know the write failed.
|
|
||||||
this->registerValueContainer->setDisabled(false);
|
this->registerValueContainer->setDisabled(false);
|
||||||
|
auto errorDialogue = new ErrorDialogue(
|
||||||
|
"Error",
|
||||||
|
"Failed to update " + QString::fromStdString(
|
||||||
|
this->registerDescriptor.name.value_or("")
|
||||||
|
).toUpper() + " register value - " + errorMessage,
|
||||||
|
this
|
||||||
|
);
|
||||||
|
errorDialogue->show();
|
||||||
});
|
});
|
||||||
|
|
||||||
this->insightWorker.queueTask(writeRegisterTask);
|
this->insightWorker.queueTask(writeRegisterTask);
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
<file alias="/compiled/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegistersPane/UiFiles/TargetRegistersSidePane.ui">./Insight/UserInterfaces/InsightWindow/Widgets/TargetRegistersPane/UiFiles/TargetRegistersSidePane.ui</file>
|
<file alias="/compiled/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegistersPane/UiFiles/TargetRegistersSidePane.ui">./Insight/UserInterfaces/InsightWindow/Widgets/TargetRegistersPane/UiFiles/TargetRegistersSidePane.ui</file>
|
||||||
<file alias="/compiled/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/UiFiles/TargetRegisterInspectorWindow.ui">./Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/UiFiles/TargetRegisterInspectorWindow.ui</file>
|
<file alias="/compiled/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/UiFiles/TargetRegisterInspectorWindow.ui">./Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/UiFiles/TargetRegisterInspectorWindow.ui</file>
|
||||||
<file alias="/compiled/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/RegisterHistoryWidget/UiFiles/RegisterHistoryWidget.ui">./Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/RegisterHistoryWidget/UiFiles/RegisterHistoryWidget.ui</file>
|
<file alias="/compiled/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/RegisterHistoryWidget/UiFiles/RegisterHistoryWidget.ui">./Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/RegisterHistoryWidget/UiFiles/RegisterHistoryWidget.ui</file>
|
||||||
|
<file alias="/compiled/src/Insight/UserInterfaces/InsightWindow/Widgets/ErrorDialogue/UiFiles/ErrorDialogue.ui">./Insight/UserInterfaces/InsightWindow/Widgets/ErrorDialogue/UiFiles/ErrorDialogue.ui</file>
|
||||||
|
|
||||||
<!-- QT UI stylesheets for Insight -->
|
<!-- QT UI stylesheets for Insight -->
|
||||||
<file alias="/compiled/src/Insight/UserInterfaces/InsightWindow/Stylesheets/InsightWindow.qss">./Insight/UserInterfaces/InsightWindow/Stylesheets/InsightWindow.qss</file>
|
<file alias="/compiled/src/Insight/UserInterfaces/InsightWindow/Stylesheets/InsightWindow.qss">./Insight/UserInterfaces/InsightWindow/Stylesheets/InsightWindow.qss</file>
|
||||||
@@ -29,6 +30,7 @@
|
|||||||
<file alias="/compiled/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/DIP/Stylesheets/DualInlinePackage.qss">./Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/DIP/Stylesheets/DualInlinePackage.qss</file>
|
<file alias="/compiled/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/DIP/Stylesheets/DualInlinePackage.qss">./Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/DIP/Stylesheets/DualInlinePackage.qss</file>
|
||||||
<file alias="/compiled/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/QFP/Stylesheets/QuadFlatPackage.qss">./Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/QFP/Stylesheets/QuadFlatPackage.qss</file>
|
<file alias="/compiled/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/QFP/Stylesheets/QuadFlatPackage.qss">./Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/QFP/Stylesheets/QuadFlatPackage.qss</file>
|
||||||
<file alias="/compiled/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/Stylesheets/TargetRegisterInspectorWindow.qss">./Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/Stylesheets/TargetRegisterInspectorWindow.qss</file>
|
<file alias="/compiled/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/Stylesheets/TargetRegisterInspectorWindow.qss">./Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/Stylesheets/TargetRegisterInspectorWindow.qss</file>
|
||||||
|
<file alias="/compiled/src/Insight/UserInterfaces/InsightWindow/Widgets/ErrorDialogue/Stylesheets/ErrorDialogue.qss">./Insight/UserInterfaces/InsightWindow/Widgets/ErrorDialogue/Stylesheets/ErrorDialogue.qss</file>
|
||||||
|
|
||||||
<!-- Icons for Insight -->
|
<!-- Icons for Insight -->
|
||||||
<file alias="/compiled/src/Insight/UserInterfaces/InsightWindow/Images/BloomIcon.svg">./Insight/UserInterfaces/InsightWindow/Images/BloomIcon.svg</file>
|
<file alias="/compiled/src/Insight/UserInterfaces/InsightWindow/Images/BloomIcon.svg">./Insight/UserInterfaces/InsightWindow/Images/BloomIcon.svg</file>
|
||||||
@@ -44,5 +46,6 @@
|
|||||||
<file alias="/compiled/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegistersPane/Images/target-registers-disabled.svg">./Insight/UserInterfaces/InsightWindow/Widgets/TargetRegistersPane/Images/target-registers-disabled.svg</file>
|
<file alias="/compiled/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegistersPane/Images/target-registers-disabled.svg">./Insight/UserInterfaces/InsightWindow/Widgets/TargetRegistersPane/Images/target-registers-disabled.svg</file>
|
||||||
<file alias="/compiled/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegistersPane/Images/search-registers.svg">./Insight/UserInterfaces/InsightWindow/Widgets/TargetRegistersPane/Images/search-registers.svg</file>
|
<file alias="/compiled/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegistersPane/Images/search-registers.svg">./Insight/UserInterfaces/InsightWindow/Widgets/TargetRegistersPane/Images/search-registers.svg</file>
|
||||||
<file alias="/compiled/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/Images/icon.svg">./Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/Images/icon.svg</file>
|
<file alias="/compiled/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/Images/icon.svg">./Insight/UserInterfaces/InsightWindow/Widgets/TargetRegisterInspector/Images/icon.svg</file>
|
||||||
|
<file alias="/compiled/src/Insight/UserInterfaces/InsightWindow/Widgets/ErrorDialogue/Images/icon.svg">./Insight/UserInterfaces/InsightWindow/Widgets/ErrorDialogue/Images/icon.svg</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
|||||||
Reference in New Issue
Block a user