This commit is contained in:
2025-12-05 12:20:47 +03:00
parent 57673d0ee4
commit 05fce073f1
450 changed files with 58 additions and 58 deletions

View File

@@ -0,0 +1,84 @@
#include <QTranslator>
#include "specialmessagebox.h"
#include "ui_specialmessagebox.h"
SpecMsgBox::SpecMsgBox(QWidget *parent, TypeSpecMsgBox type, const QString& text) :
QDialog(parent),
ui(new Ui::SpecialMessageBox)
{
ui->setupUi(this);
this->setObjectName("SpecMsgBox");
this->setWindowFlags(this->windowFlags() & ~Qt::WindowContextHelpButtonHint);
if(type == TypeSpecMsgBox::warningYesNo)
{
ui->lbl_icon->setPixmap(QPixmap(QStringLiteral(":/resources/icons/warning.png")));
this->setWindowTitle(tr("Attention!"));
}
else if(type == TypeSpecMsgBox::warningClose)
{
ui->lbl_icon->setPixmap(QPixmap(QStringLiteral(":/resources/icons/warning.png")));
this->setWindowTitle(tr("Attention!"));
ui->btnNo->setVisible(false);
ui->btnYes->setText(tr("Close"));
}
else if(type == TypeSpecMsgBox::criticalClose)
{
ui->lbl_icon->setPixmap(QPixmap(QStringLiteral(":/resources/icons/critical.png")));
this->setWindowTitle(tr("Error!"));
ui->btnNo->setVisible(false);
ui->btnYes->setText(tr("Close"));
}
else if(type == TypeSpecMsgBox::infoOk)
{
ui->lbl_icon->setPixmap(QPixmap(QStringLiteral(":/resources/icons/info.png")));
this->setWindowTitle(tr("Information"));
ui->btnNo->setVisible(false);
ui->btnYes->setText(tr("Ok"));
}
ui->lblText->setText(text);
}
SpecMsgBox::~SpecMsgBox()
{
delete ui;
}
int SpecMsgBox::WarningYesNo(QWidget *parent, const QString &text)
{
return SpecMsgBox::work(parent, TypeSpecMsgBox::warningYesNo, text);
}
int SpecMsgBox::WarningClose(QWidget *parent, const QString &text)
{
return SpecMsgBox::work(parent, TypeSpecMsgBox::warningClose, text);
}
int SpecMsgBox::CriticalClose(QWidget *parent, const QString &text)
{
return SpecMsgBox::work(parent, TypeSpecMsgBox::criticalClose, text);
}
int SpecMsgBox::InfoOk(QWidget *parent, const QString &text)
{
return SpecMsgBox::work(parent, TypeSpecMsgBox::infoOk, text);
}
int SpecMsgBox::work(QWidget *parent, TypeSpecMsgBox type, const QString& text)
{
SpecMsgBox *msgBox = new SpecMsgBox(parent, type, text);
return msgBox->exec();
}
void SpecMsgBox::on_btnYes_clicked()
{
this->accept();
}
void SpecMsgBox::on_btnNo_clicked()
{
this->reject();
}

View File

@@ -0,0 +1,46 @@
#ifndef SPECIALMESSAGEBOX_H
#define SPECIALMESSAGEBOX_H
#include <QDialog>
#include "instructorsAndTrainees_global.h"
namespace Ui {
class SpecialMessageBox;
}
class INSTRUCTORSANDTRAINEES_EXPORT SpecMsgBox : public QDialog
{
Q_OBJECT
public:
enum TypeSpecMsgBox {
warningYesNo,
warningClose,
criticalClose,
infoOk
};
private:
explicit SpecMsgBox(QWidget *parent, TypeSpecMsgBox type, const QString& text);
public:
~SpecMsgBox();
public:
static int WarningYesNo(QWidget *parent, const QString& text);
static int WarningClose(QWidget *parent, const QString& text);
static int CriticalClose(QWidget *parent, const QString& text);
static int InfoOk(QWidget *parent, const QString& text);
private:
static int work(QWidget *parent, TypeSpecMsgBox type, const QString& text);
private slots:
void on_btnYes_clicked();
void on_btnNo_clicked();
private:
Ui::SpecialMessageBox *ui;
};
#endif // SPECIALMESSAGEBOX_H

View File

@@ -0,0 +1,116 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>SpecialMessageBox</class>
<widget class="QDialog" name="SpecialMessageBox">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>100</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_Text">
<item>
<widget class="QLabel" name="lbl_icon">
<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="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="resources.qrc">:/resources/icons/circleGray.png</pixmap>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lblText">
<property name="text">
<string>text</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_Btn">
<item>
<widget class="QPushButton" name="btnYes">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Yes</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnNo">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>No</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
<resources>
<include location="resources.qrc"/>
</resources>
<connections/>
</ui>