refact struct projects

This commit is contained in:
2025-11-06 23:56:52 +03:00
parent c021421118
commit fd8fcd5c1d
22 changed files with 31 additions and 22 deletions

View File

@@ -0,0 +1,56 @@
#include <QTranslator>
#include "specialmessagebox.h"
#include "ui_specialmessagebox.h"
SpecialMessageBox::SpecialMessageBox(QWidget *parent, TypeSpecMsgBox type, const QString& text) :
QDialog(parent),
ui(new Ui::SpecialMessageBox)
{
ui->setupUi(this);
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::critical)
{
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::info)
{
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);
}
SpecialMessageBox::~SpecialMessageBox()
{
delete ui;
}
void SpecialMessageBox::on_btnYes_clicked()
{
this->accept();
}
void SpecialMessageBox::on_btnNo_clicked()
{
this->reject();
}

View File

@@ -0,0 +1,35 @@
#ifndef SPECIALMESSAGEBOX_H
#define SPECIALMESSAGEBOX_H
#include <QDialog>
namespace Ui {
class SpecialMessageBox;
}
class SpecialMessageBox : public QDialog
{
Q_OBJECT
public:
enum TypeSpecMsgBox {
warningYesNo,
warningClose,
critical,
info
};
public:
explicit SpecialMessageBox(QWidget *parent, TypeSpecMsgBox type, const QString& text);
~SpecialMessageBox();
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>