Added custom Discard-Ignore-Abort choice Dialog

This commit is contained in:
Valentino Orlandi 2022-10-05 21:21:37 +02:00
parent 0a3f9833b0
commit 3f20392d75
Signed by: elB4RTO
GPG Key ID: 1719E976DB2D4E71
3 changed files with 311 additions and 0 deletions

View File

@ -0,0 +1,53 @@
#include "dialogdia.h"
#include "ui_dialogdia.h"
DialogDia::DialogDia( const QString& title, const QString& text, const bool& ignore, const bool& discard, const bool& abort, QWidget *parent ) :
QDialog(parent),
ui(new Ui::DialogDia)
{
ui->setupUi(this);
// (un)set the button if needed
if ( !ignore ) {
this->ui->button_IGNORE->setEnabled( false );
this->ui->button_IGNORE->setVisible( false );
}
if ( !discard ) {
this->ui->button_DISCARD->setEnabled( false );
this->ui->button_DISCARD->setVisible( false );
}
if ( !abort ) {
this->ui->button_ABORT->setEnabled( false );
this->ui->button_ABORT->setVisible( false );
}
// insert the given title and text
this->ui->label_Title->setText( title );
this->ui->label_Message->setText( text );
// adjust the initial size
this->adjustSize();
}
DialogDia::~DialogDia()
{
delete ui;
}
void DialogDia::on_button_IGNORE_clicked()
{
this->done( 2 );
}
void DialogDia::on_button_DISCARD_clicked()
{
this->done( 1 );
}
void DialogDia::on_button_ABORT_clicked()
{
this->done( 0 );
}

View File

@ -0,0 +1,29 @@
#ifndef DIALOGDIA_H
#define DIALOGDIA_H
#include <QDialog>
namespace Ui {
class DialogDia;
}
class DialogDia : public QDialog
{
Q_OBJECT
public:
explicit DialogDia( const QString& title, const QString& text, const bool& ignore=true, const bool& discard=true, const bool& abort=true, QWidget *parent=nullptr );
~DialogDia();
private slots:
void on_button_IGNORE_clicked();
void on_button_DISCARD_clicked();
void on_button_ABORT_clicked();
private:
Ui::DialogDia *ui;
};
#endif // DIALOGDIA_H

View File

@ -0,0 +1,229 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DialogDia</class>
<widget class="QDialog" name="DialogDia">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>512</width>
<height>256</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>512</width>
<height>192</height>
</size>
</property>
<property name="font">
<font>
<family>Metropolis</family>
<pointsize>13</pointsize>
</font>
</property>
<property name="windowIcon">
<iconset resource="../../resources/resources.qrc">
<normaloff>:/logo/logo/logdoctor.svg</normaloff>:/logo/logo/logdoctor.svg</iconset>
</property>
<property name="modal">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QFrame" name="frame_Message">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="topMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="0" rowspan="3">
<widget class="QLabel" name="label_Icon">
<property name="minimumSize">
<size>
<width>64</width>
<height>64</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>64</width>
<height>64</height>
</size>
</property>
<property name="pixmap">
<pixmap resource="../../resources/resources.qrc">:/icons/icons/dialog_quest.png</pixmap>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="label_Title">
<property name="minimumSize">
<size>
<width>0</width>
<height>64</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>64</height>
</size>
</property>
<property name="font">
<font>
<family>Metropolis</family>
<pointsize>13</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="indent">
<number>8</number>
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<widget class="QLabel" name="label_Message">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>24</height>
</size>
</property>
<property name="font">
<font>
<family>Metropolis</family>
<pointsize>13</pointsize>
</font>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="margin">
<number>4</number>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QFrame" name="frame_Buttons">
<property name="minimumSize">
<size>
<width>0</width>
<height>48</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>48</height>
</size>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>333</width>
<height>27</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="button_IGNORE">
<property name="minimumSize">
<size>
<width>96</width>
<height>32</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>96</width>
<height>32</height>
</size>
</property>
<property name="text">
<string>Ignore</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="button_DISCARD">
<property name="minimumSize">
<size>
<width>96</width>
<height>32</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>96</width>
<height>32</height>
</size>
</property>
<property name="text">
<string>Discard</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="button_ABORT">
<property name="minimumSize">
<size>
<width>96</width>
<height>32</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>96</width>
<height>32</height>
</size>
</property>
<property name="text">
<string>Abort</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="../../resources/resources.qrc"/>
</resources>
<connections/>
</ui>