mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/RRJServer.git
synced 2026-03-28 19:55:48 +03:00
154 lines
3.8 KiB
C++
154 lines
3.8 KiB
C++
#include <QMessageBox>
|
|
#include <QProcess>
|
|
#include <QFile>
|
|
#include <QResizeEvent>
|
|
#include "specialmessagebox.h"
|
|
#include "dialogcheckdb.h"
|
|
#include "ui_dialogcheckdb.h"
|
|
|
|
DialogCheckDB::DialogCheckDB(ProviderDBLMS* providerDBLMS, QWidget *parent) :
|
|
QDialog(parent),
|
|
ui(new Ui::DialogCheckDB),
|
|
waitAnimationWidget(nullptr),
|
|
providerDBLMS(providerDBLMS)
|
|
{
|
|
ui->setupUi(this);
|
|
|
|
connect(this, &DialogCheckDB::signal_CheckDB, providerDBLMS, &ProviderDBLMS::slot_CheckDB);
|
|
connect(providerDBLMS, &ProviderDBLMS::signal_CheckDBResult, this, &DialogCheckDB::slot_CheckDBResult);
|
|
|
|
connect(this, &DialogCheckDB::signal_RepareDB, providerDBLMS, &ProviderDBLMS::slot_RepareDB);
|
|
connect(providerDBLMS, &ProviderDBLMS::signal_RepareDBResult, this, &DialogCheckDB::slot_RepareDBResult);
|
|
|
|
|
|
waitAnimationWidget = new WaitAnimationWidget;
|
|
QMovie *movie = new QMovie(":/resources/icons/762.gif");
|
|
waitAnimationWidget->setParent(this);
|
|
waitAnimationWidget->initialize(movie,this);
|
|
|
|
ui->btnRepare->setObjectName("btnRepare");
|
|
|
|
ui->btnRepare->setEnabled(false);
|
|
}
|
|
|
|
DialogCheckDB::~DialogCheckDB()
|
|
{
|
|
if(waitAnimationWidget)
|
|
{
|
|
waitAnimationWidget->hideWithStop();
|
|
delete waitAnimationWidget;
|
|
}
|
|
|
|
delete ui;
|
|
}
|
|
|
|
void DialogCheckDB::initialize()
|
|
{
|
|
check();
|
|
}
|
|
|
|
void DialogCheckDB::resizeEvent(QResizeEvent *event)
|
|
{
|
|
QSize size = event->size();
|
|
waitAnimationWidget->resize(size);
|
|
}
|
|
|
|
void DialogCheckDB::check()
|
|
{
|
|
waitAnimationWidget->showWithPlay();
|
|
|
|
emit signal_CheckDB();
|
|
|
|
return;
|
|
}
|
|
|
|
void DialogCheckDB::on_btnRepare_clicked()
|
|
{
|
|
waitAnimationWidget->showWithPlay();
|
|
|
|
if(!checkResult.resDriver)
|
|
{
|
|
SpecMsgBox::CriticalClose(this, tr("Install PostgreSQL."));
|
|
this->reject();
|
|
return;
|
|
}
|
|
|
|
emit signal_RepareDB(checkResult);
|
|
}
|
|
|
|
void DialogCheckDB::slot_CheckDBResult(CheckResult result)
|
|
{
|
|
checkResult = result;
|
|
|
|
if(result.resDriver)
|
|
{
|
|
ui->lblDriverRes->setText(tr("Installed"));
|
|
ui->lblDriverResIco->setPixmap(QPixmap(QStringLiteral(":/resources/icons/circleGreen.png")));
|
|
}
|
|
else
|
|
{
|
|
ui->lblDriverRes->setText(tr("Not installed"));
|
|
ui->lblDriverResIco->setPixmap(QPixmap(QStringLiteral(":/resources/icons/circleRed.png")));
|
|
}
|
|
|
|
if(result.resUser)
|
|
{
|
|
ui->lblUserRes->setText(tr("Exist"));
|
|
ui->lblUserResIco->setPixmap(QPixmap(QStringLiteral(":/resources/icons/circleGreen.png")));
|
|
}
|
|
else
|
|
{
|
|
ui->lblUserRes->setText(tr("Not exist"));
|
|
ui->lblUserResIco->setPixmap(QPixmap(QStringLiteral(":/resources/icons/circleRed.png")));
|
|
}
|
|
|
|
if(result.resDB)
|
|
{
|
|
ui->lblDBRes->setText(tr("Exist"));
|
|
ui->lblDBResIco->setPixmap(QPixmap(QStringLiteral(":/resources/icons/circleGreen.png")));
|
|
}
|
|
else
|
|
{
|
|
ui->lblDBRes->setText(tr("Not exist"));
|
|
ui->lblDBResIco->setPixmap(QPixmap(QStringLiteral(":/resources/icons/circleRed.png")));
|
|
}
|
|
|
|
if(!result.resDriver || !result.resUser || !result.resDB)
|
|
{
|
|
ui->btnRepare->setEnabled(true);
|
|
}
|
|
else
|
|
ui->btnRepare->setEnabled(false);
|
|
|
|
waitAnimationWidget->hideWithStop();
|
|
}
|
|
|
|
void DialogCheckDB::slot_RepareDBResult(CheckResult result)
|
|
{
|
|
checkResult = result;
|
|
|
|
if(!checkResult.resUser)
|
|
{
|
|
slot_CheckDBResult(checkResult);
|
|
SpecMsgBox::CriticalClose(this, tr("Failed to create user!"));
|
|
this->reject();
|
|
return;
|
|
}
|
|
|
|
if(!checkResult.resDB)
|
|
{
|
|
slot_CheckDBResult(checkResult);
|
|
SpecMsgBox::CriticalClose(this, tr("Failed to create Database!"));
|
|
this->reject();
|
|
return;
|
|
}
|
|
|
|
check();
|
|
|
|
if(checkResult.resDriver && checkResult.resUser && checkResult.resDB)
|
|
{
|
|
SpecMsgBox::InfoOk(this, tr("The database has been successfully restored!"));
|
|
this->accept();
|
|
}
|
|
}
|