Added custom Informational Dialog
This commit is contained in:
parent
4ffd10d8a5
commit
a809a96d5d
|
@ -0,0 +1,89 @@
|
|||
|
||||
#include "dialogmsg.h"
|
||||
#include "ui_dialogmsg.h"
|
||||
|
||||
#include "modules/exceptions.h"
|
||||
|
||||
#include <QSize>
|
||||
#include <QIcon>
|
||||
#include <QPixmap>
|
||||
|
||||
|
||||
DialogMsg::DialogMsg(const QString& title, const QString& text, const QString& additional, const int& type, QWidget* parent ) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::DialogMsg)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
// icon
|
||||
switch (type) {
|
||||
case 0:
|
||||
// info message
|
||||
this->ui->label_Icon->setPixmap( QPixmap(":/icons/icons/dialog_info.png") );
|
||||
break;
|
||||
case 1:
|
||||
// warning message
|
||||
this->ui->label_Icon->setPixmap( QPixmap(":/icons/icons/dialog_warn.png") );
|
||||
break;
|
||||
case 2:
|
||||
// error message, change the icon
|
||||
this->ui->label_Icon->setPixmap( QPixmap(":/icons/icons/dialog_err.png") );
|
||||
break;
|
||||
default:
|
||||
// shouldn't be here
|
||||
throw GenericException("Unexpected dialog type: "+ type);
|
||||
}
|
||||
|
||||
// insert the given text
|
||||
this->ui->label_Title->setText( title );
|
||||
this->ui->label_Message->setText( text );
|
||||
|
||||
// additional info, hide by default
|
||||
this->ui->frame_Additional->setVisible( false );
|
||||
if ( additional.size() == 0 ) {
|
||||
this->ui->button_ShowAdditional->setEnabled( false );
|
||||
this->ui->button_ShowAdditional->setVisible( false );
|
||||
} else {
|
||||
this->ui->text_Additional->setText( additional );
|
||||
}
|
||||
|
||||
// adjust the initial size
|
||||
this->adjustSize();
|
||||
}
|
||||
|
||||
DialogMsg::~DialogMsg()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
||||
void DialogMsg::on_button_ShowAdditional_clicked()
|
||||
{
|
||||
this->additional_shown = ! this->additional_shown;
|
||||
// set additional info visibility
|
||||
this->ui->frame_Additional->setVisible( this->additional_shown );
|
||||
// set the icon
|
||||
QIcon icon;
|
||||
if ( this->additional_shown ) {
|
||||
icon = QIcon(":/icons/icons/up.png");
|
||||
// resize
|
||||
this->initial_height = this->height();
|
||||
if ( this->additional_height > 0 ) {
|
||||
this->resize( this->width(), this->additional_height );
|
||||
} else {
|
||||
this->resize( this->width(), this->height()+100 );
|
||||
}
|
||||
} else {
|
||||
icon = QIcon(":/icons/icons/down.png");
|
||||
this->additional_height = this->height();
|
||||
this->resize( this->width(), this->initial_height );
|
||||
}
|
||||
this->ui->button_ShowAdditional->setIcon( icon );
|
||||
}
|
||||
|
||||
|
||||
void DialogMsg::on_button_Ok_clicked()
|
||||
{
|
||||
this->done( 1 );
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
#ifndef DIALOGMSG_H
|
||||
#define DIALOGMSG_H
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
namespace Ui {
|
||||
class DialogMsg;
|
||||
}
|
||||
|
||||
class DialogMsg : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DialogMsg( const QString& title, const QString& text, const QString& additional, const int& type, QWidget *parent=nullptr );
|
||||
~DialogMsg();
|
||||
|
||||
private slots:
|
||||
void on_button_ShowAdditional_clicked();
|
||||
|
||||
void on_button_Ok_clicked();
|
||||
|
||||
private:
|
||||
Ui::DialogMsg *ui;
|
||||
|
||||
bool additional_shown = false;
|
||||
|
||||
int initial_height = 0;
|
||||
int additional_height = 0;
|
||||
};
|
||||
|
||||
#endif // DIALOGMSG_H
|
|
@ -0,0 +1,242 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>DialogMsg</class>
|
||||
<widget class="QDialog" name="DialogMsg">
|
||||
<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_warn.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_Additional">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QTextBrowser" name="text_Additional">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>24</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Metropolis</family>
|
||||
<pointsize>11</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="openLinks">
|
||||
<bool>false</bool>
|
||||
</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>
|
||||
<widget class="QPushButton" name="button_ShowAdditional">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>32</width>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>32</width>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../resources/resources.qrc">
|
||||
<normaloff>:/icons/icons/down.png</normaloff>:/icons/icons/down.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>32</width>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<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_Ok">
|
||||
<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>Ok</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="../../resources/resources.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
Loading…
Reference in New Issue