mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/RRJServer.git
synced 2026-03-28 19:55:48 +03:00
rename0
This commit is contained in:
117
Server/settings/dialogcheckdb.cpp
Normal file
117
Server/settings/dialogcheckdb.cpp
Normal file
@@ -0,0 +1,117 @@
|
||||
#include <QMessageBox>
|
||||
#include <QProcess>
|
||||
#include <QFile>
|
||||
#include "dialogcheckdb.h"
|
||||
#include "ui_dialogcheckdb.h"
|
||||
|
||||
DialogCheckDB::DialogCheckDB(ProviderDBLMS* providerDBLMS, QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::DialogCheckDB),
|
||||
providerDBLMS(providerDBLMS),
|
||||
resDriver(false),
|
||||
resUser(false),
|
||||
resDB(false)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
ui->btnRepare->setObjectName("btnRepare");
|
||||
|
||||
ui->btnRepare->setEnabled(false);
|
||||
|
||||
check();
|
||||
}
|
||||
|
||||
DialogCheckDB::~DialogCheckDB()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void DialogCheckDB::check()
|
||||
{
|
||||
resDriver = false;
|
||||
resUser = false;
|
||||
resDB = false;
|
||||
|
||||
resDriver = providerDBLMS->checkDriverQPSQLavailable();
|
||||
if(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")));
|
||||
}
|
||||
|
||||
resUser = providerDBLMS->checkUserLMSexist();
|
||||
if(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")));
|
||||
}
|
||||
|
||||
resDB = providerDBLMS->checkDataBaseLMSexist();
|
||||
if(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(!resDriver || !resUser || !resDB)
|
||||
{
|
||||
ui->btnRepare->setEnabled(true);
|
||||
}
|
||||
else
|
||||
ui->btnRepare->setEnabled(false);
|
||||
}
|
||||
|
||||
void DialogCheckDB::on_btnRepare_clicked()
|
||||
{
|
||||
if(!resDriver)
|
||||
{
|
||||
QMessageBox::critical(this, tr("Error!"), tr("Install PostgreSQL."));
|
||||
this->reject();
|
||||
return;
|
||||
}
|
||||
|
||||
if(!resUser)
|
||||
{
|
||||
if(!providerDBLMS->createUser())
|
||||
{
|
||||
check();
|
||||
QMessageBox::critical(this, tr("Error!"), tr("Failed to create user!"));
|
||||
this->reject();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if(!resDB)
|
||||
{
|
||||
if(!providerDBLMS->createDB())
|
||||
{
|
||||
check();
|
||||
QMessageBox::critical(this, tr("Error!"), tr("Failed to create Database!"));
|
||||
this->reject();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
check();
|
||||
|
||||
if(resDriver && resUser && resDB)
|
||||
{
|
||||
QMessageBox::information(this, tr("Completed!"), tr("The database has been successfully restored!"));
|
||||
this->accept();
|
||||
}
|
||||
}
|
||||
36
Server/settings/dialogcheckdb.h
Normal file
36
Server/settings/dialogcheckdb.h
Normal file
@@ -0,0 +1,36 @@
|
||||
#ifndef DIALOGCHECKDB_H
|
||||
#define DIALOGCHECKDB_H
|
||||
|
||||
#include <QDialog>
|
||||
#include "providerdblms.h"
|
||||
|
||||
namespace Ui {
|
||||
class DialogCheckDB;
|
||||
}
|
||||
|
||||
class DialogCheckDB : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DialogCheckDB(ProviderDBLMS* providerDBLMS, QWidget *parent = nullptr);
|
||||
~DialogCheckDB();
|
||||
|
||||
private slots:
|
||||
void on_btnRepare_clicked();
|
||||
|
||||
private:
|
||||
void check();
|
||||
void prepareRestoreDBscript();
|
||||
|
||||
private:
|
||||
Ui::DialogCheckDB *ui;
|
||||
|
||||
ProviderDBLMS* providerDBLMS;
|
||||
|
||||
bool resDriver;
|
||||
bool resUser;
|
||||
bool resDB;
|
||||
};
|
||||
|
||||
#endif // DIALOGCHECKDB_H
|
||||
286
Server/settings/dialogcheckdb.ui
Normal file
286
Server/settings/dialogcheckdb.ui
Normal file
@@ -0,0 +1,286 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>DialogCheckDB</class>
|
||||
<widget class="QDialog" name="DialogCheckDB">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>250</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Database</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_Main">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_Driver">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_Driver">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>170</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Driver PostgreSQL</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lblDriverRes">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_1">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lblDriverResIco">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<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="../InstructorsAndTrainees/InstructorsAndTrainees.qrc">:/resources/icons/circleGray.png</pixmap>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_User">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_User">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>170</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>User</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lblUserRes">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lblUserResIco">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<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="../InstructorsAndTrainees/InstructorsAndTrainees.qrc">:/resources/icons/circleGray.png</pixmap>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_DB">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_DB">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>170</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Database</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lblDBRes">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lblDBResIco">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<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="../InstructorsAndTrainees/InstructorsAndTrainees.qrc">:/resources/icons/circleGray.png</pixmap>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_Result"/>
|
||||
</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_Ctrl">
|
||||
<item>
|
||||
<widget class="QToolButton" name="btnRepare">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>58</width>
|
||||
<height>58</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Repare</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../InstructorsAndTrainees/InstructorsAndTrainees.qrc">
|
||||
<normaloff>:/resources/icons/procedure.png</normaloff>:/resources/icons/procedure.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>32</width>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolButtonStyle">
|
||||
<enum>Qt::ToolButtonTextUnderIcon</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="../InstructorsAndTrainees/InstructorsAndTrainees.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
360
Server/settings/dialogsettingstray.cpp
Normal file
360
Server/settings/dialogsettingstray.cpp
Normal file
@@ -0,0 +1,360 @@
|
||||
#include <QXmlStreamReader>
|
||||
#include <QMessageBox>
|
||||
#include "dialogsettingstray.h"
|
||||
#include "Systems/tools.h"
|
||||
#include "ui_dialogsettingstray.h"
|
||||
#include "dialogcheckdb.h"
|
||||
#include "dialogauthorization.h"
|
||||
|
||||
DialogSettingsTray::DialogSettingsTray(ProviderDBLMS* providerDBLMS, QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::DialogSettingsTray),
|
||||
settings(nullptr),
|
||||
providerDBLMS(providerDBLMS),
|
||||
flSettingsServerChanged(false)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
ui->btnSave->setObjectName("btnSave");
|
||||
ui->btnCheckDB->setObjectName("btnCheckDB");
|
||||
ui->btnUpdateDocs->setObjectName("btnUpdateDocs");
|
||||
ui->checkLocalhost->setObjectName("checkLocalhost");
|
||||
|
||||
#ifndef PROJECT_TYPE_DEBUG
|
||||
ui->checkLocalhost->setEnabled(false);
|
||||
#endif
|
||||
|
||||
/* Создаем строку для регулярного выражения */
|
||||
QString ipRange = "(?:[0-1]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])";
|
||||
/* Создаем регулярное выражение с применением строки, как
|
||||
* повторяющегося элемента
|
||||
*/
|
||||
QRegExp ipRegex ("^" + ipRange
|
||||
+ "\\." + ipRange
|
||||
+ "\\." + ipRange
|
||||
+ "\\." + ipRange + "$");
|
||||
/* Создаем Валидатор регулярного выражения с применением
|
||||
* созданного регулярного выражения
|
||||
*/
|
||||
QRegExpValidator *ipValidator = new QRegExpValidator(ipRegex, this);
|
||||
/* Устанавливаем Валидатор на QLineEdit */
|
||||
ui->editHostName->setValidator(ipValidator);
|
||||
|
||||
settings = new ServerDBSettings();
|
||||
|
||||
//Задаём два пункта с текстом локалей в комбобоксе
|
||||
ui->cmbLanguage->addItems(QStringList() << "English" << "Русский");
|
||||
|
||||
//Скрываем пароль
|
||||
ui->editPassword->setEchoMode(QLineEdit::EchoMode::Password);
|
||||
|
||||
if(loadSettings(settings))
|
||||
{
|
||||
if(settings->Language == "ENG")
|
||||
ui->cmbLanguage->setCurrentText("English");
|
||||
else
|
||||
ui->cmbLanguage->setCurrentText("Русский");
|
||||
|
||||
ui->editNameDB->setText(settings->NameDB);
|
||||
|
||||
if(settings->HostName == "localhost")
|
||||
{
|
||||
ui->checkLocalhost->setChecked(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->checkLocalhost->setChecked(false);
|
||||
}
|
||||
ui->editHostName->setText(settings->HostName);
|
||||
|
||||
ui->editPort->setText(settings->Port);
|
||||
ui->editUserName->setText(settings->UserName);
|
||||
ui->editPassword->setText(settings->Password);
|
||||
|
||||
ui->btnSave->setEnabled(false);
|
||||
ui->btnCheckDB->setEnabled(true);
|
||||
flSettingsServerChanged = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->checkLocalhost->setChecked(true);
|
||||
//ui->editHostName->setEnabled(true);
|
||||
ui->editPort->setEnabled(true);
|
||||
ui->editNameDB->setEnabled(true);
|
||||
ui->editUserName->setEnabled(true);
|
||||
ui->editPassword->setEnabled(true);
|
||||
|
||||
ui->btnSave->setEnabled(false);
|
||||
|
||||
ui->btnSave->setEnabled(false);
|
||||
ui->btnCheckDB->setEnabled(false);
|
||||
flSettingsServerChanged = false;
|
||||
}
|
||||
}
|
||||
|
||||
DialogSettingsTray::~DialogSettingsTray()
|
||||
{
|
||||
delete ui;
|
||||
delete settings;
|
||||
}
|
||||
|
||||
ServerDBSettings DialogSettingsTray::getSettings()
|
||||
{
|
||||
return *settings;
|
||||
}
|
||||
|
||||
bool DialogSettingsTray::loadSettings(ServerDBSettings *settings)
|
||||
{
|
||||
QFile file(settingsName);
|
||||
if(! file.open(QIODevice::ReadOnly))
|
||||
return false;
|
||||
|
||||
QXmlStreamReader xmlReader(&file);
|
||||
|
||||
while (!xmlReader.atEnd()){
|
||||
|
||||
if(xmlReader.isStartElement()){
|
||||
|
||||
if(xmlReader.name() == "DataBaseSettings")
|
||||
{
|
||||
|
||||
foreach(const QXmlStreamAttribute &attr, xmlReader.attributes()){
|
||||
QString name = attr.name().toString();
|
||||
QString value = attr.value().toString();
|
||||
|
||||
if(name == "Type"){
|
||||
settings->Type = value;
|
||||
}
|
||||
|
||||
if(name == "Name"){
|
||||
settings->NameDB = value;
|
||||
}
|
||||
|
||||
if(name == "UserName"){
|
||||
settings->UserName = value;
|
||||
}
|
||||
|
||||
if(name == "Password"){
|
||||
settings->Password = value;
|
||||
}
|
||||
|
||||
if(name == "HostName"){
|
||||
settings->HostName = value;
|
||||
}
|
||||
|
||||
if(name == "Port"){
|
||||
settings->Port = value;
|
||||
}
|
||||
|
||||
if(name == "Language"){
|
||||
settings->Language = value;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
xmlReader.readNext();
|
||||
}
|
||||
|
||||
file.close();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DialogSettingsTray::saveSettings()
|
||||
{
|
||||
QFile file(settingsName);
|
||||
|
||||
if(! file.open(QIODevice::WriteOnly))
|
||||
return false;
|
||||
|
||||
QXmlStreamWriter xmlWriter(&file);
|
||||
|
||||
xmlWriter.setAutoFormatting(true);
|
||||
xmlWriter.writeStartDocument();
|
||||
|
||||
xmlWriter.writeStartElement("ServerSettingsContainer");
|
||||
xmlWriter.writeStartElement("DataBaseSettings");
|
||||
|
||||
xmlWriter.writeAttribute("Type", settings->Type);
|
||||
xmlWriter.writeAttribute("Name", settings->NameDB);
|
||||
xmlWriter.writeAttribute("UserName", settings->UserName);
|
||||
xmlWriter.writeAttribute("Password", settings->Password);
|
||||
xmlWriter.writeAttribute("HostName", settings->HostName);
|
||||
xmlWriter.writeAttribute("Port", settings->Port);
|
||||
xmlWriter.writeAttribute("Language", settings->Language);
|
||||
|
||||
xmlWriter.writeEndElement();
|
||||
xmlWriter.writeEndElement();
|
||||
|
||||
xmlWriter.writeEndDocument();
|
||||
|
||||
file.close();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void DialogSettingsTray::on_btnSave_clicked()
|
||||
{
|
||||
if(ui->cmbLanguage->currentText() == QStringLiteral("English"))
|
||||
{
|
||||
settings->Language = "ENG";
|
||||
}
|
||||
else
|
||||
{
|
||||
settings->Language = "RUS";
|
||||
}
|
||||
|
||||
settings->NameDB = ui->editNameDB->text();
|
||||
settings->HostName = ui->editHostName->text();
|
||||
settings->Port = ui->editPort->text();
|
||||
settings->UserName = ui->editUserName->text();
|
||||
settings->Password = ui->editPassword->text();
|
||||
|
||||
saveSettings();
|
||||
|
||||
ui->btnCheckDB->setEnabled(true);
|
||||
|
||||
this->accept();
|
||||
}
|
||||
|
||||
void DialogSettingsTray::on_cmbLanguage_currentIndexChanged(int index)
|
||||
{
|
||||
ui->btnSave->setEnabled(true);
|
||||
}
|
||||
|
||||
void DialogSettingsTray::on_DialogSettingsTray_accepted()
|
||||
{
|
||||
QString language;
|
||||
|
||||
if(settings->Language == "ENG")
|
||||
language = QString("en_EN");
|
||||
else
|
||||
language = QString("ru_RU");
|
||||
|
||||
emit signal_LanguageChanged(language);
|
||||
}
|
||||
|
||||
void DialogSettingsTray::on_editNameDB_textChanged(const QString &arg1)
|
||||
{
|
||||
ui->btnSave->setEnabled(true);
|
||||
ui->btnCheckDB->setEnabled(false);
|
||||
flSettingsServerChanged = true;
|
||||
}
|
||||
|
||||
void DialogSettingsTray::on_editHostName_textChanged(const QString &arg1)
|
||||
{
|
||||
ui->btnSave->setEnabled(true);
|
||||
ui->btnCheckDB->setEnabled(false);
|
||||
flSettingsServerChanged = true;
|
||||
}
|
||||
|
||||
void DialogSettingsTray::on_editPort_textChanged(const QString &arg1)
|
||||
{
|
||||
ui->btnSave->setEnabled(true);
|
||||
ui->btnCheckDB->setEnabled(false);
|
||||
flSettingsServerChanged = true;
|
||||
}
|
||||
|
||||
void DialogSettingsTray::on_editUserName_textChanged(const QString &arg1)
|
||||
{
|
||||
ui->btnSave->setEnabled(true);
|
||||
ui->btnCheckDB->setEnabled(false);
|
||||
flSettingsServerChanged = true;
|
||||
}
|
||||
|
||||
void DialogSettingsTray::on_editPassword_textChanged(const QString &arg1)
|
||||
{
|
||||
ui->btnSave->setEnabled(true);
|
||||
ui->btnCheckDB->setEnabled(false);
|
||||
flSettingsServerChanged = true;
|
||||
}
|
||||
|
||||
void DialogSettingsTray::on_checkLocalhost_stateChanged(int arg1)
|
||||
{
|
||||
if(arg1)
|
||||
{
|
||||
ui->editHostName->setText("localhost");
|
||||
ui->editHostName->setEnabled(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->editHostName->setText("0.0.0.0");
|
||||
ui->editHostName->setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
void DialogSettingsTray::on_btnCheckDB_clicked()
|
||||
{
|
||||
//Проверяем, установлен ли PostgreSQL
|
||||
if(!providerDBLMS->checkDriverQPSQLavailable())
|
||||
{
|
||||
QMessageBox::critical(this, tr("Error!"), tr("Driver PostgreSQL is not installed!"));
|
||||
return;
|
||||
}
|
||||
|
||||
//Запрос Логина и Пароля Суперюзера PostgreSQL (postgres)
|
||||
QString UserNamePostgres;
|
||||
QString PasswordPostgres;
|
||||
|
||||
DialogAuthorization dlg(this);
|
||||
dlg.setWindowTitle(tr("Superuser PostgreSQL authorization"));
|
||||
dlg.setWindowFlags(dlg.windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||
dlg.setStyleSheet(this->styleSheet());
|
||||
dlg.setLogin("postgres");
|
||||
dlg.setPassword("");
|
||||
|
||||
switch( dlg.exec() )
|
||||
{
|
||||
case QDialog::Accepted:
|
||||
{
|
||||
UserNamePostgres = dlg.getLogin();
|
||||
PasswordPostgres = dlg.getPassword();
|
||||
|
||||
break;
|
||||
}
|
||||
case QDialog::Rejected:
|
||||
return;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
if(providerDBLMS->setUserPasswordPostgres(UserNamePostgres, PasswordPostgres))
|
||||
{
|
||||
DialogCheckDB dlgCheckDB(providerDBLMS, this);
|
||||
dlgCheckDB.setWindowFlags(dlgCheckDB.windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||
|
||||
switch( dlgCheckDB.exec() )
|
||||
{
|
||||
case QDialog::Accepted:
|
||||
ui->btnSave->setEnabled(true);
|
||||
flSettingsServerChanged = true;
|
||||
break;
|
||||
case QDialog::Rejected:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(settings->HostName == "localhost")
|
||||
QMessageBox::critical(this, tr("Error!"), tr("Error connecting to PostgreSQL!") + "\n\n" +
|
||||
tr("Possible reasons:") + "\n" +
|
||||
tr("*superuser PostgreSQL login or password is incorrect;") + "\n" +
|
||||
tr("*Port is incorrect."));
|
||||
else
|
||||
QMessageBox::critical(this, tr("Error!"), tr("Error connecting to PostgreSQL!") + "\n\n" +
|
||||
tr("Possible reasons:") + "\n" +
|
||||
tr("*superuser PostgreSQL login or password is incorrect;") + "\n" +
|
||||
tr("*Port is incorrect;") + "\n" +
|
||||
tr("*file 'pg_hba.conf' does not contain an entry for the IP address:") + settings->HostName + ".");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void DialogSettingsTray::on_btnUpdateDocs_clicked()
|
||||
{
|
||||
emit signal_UpdateDocs();
|
||||
}
|
||||
79
Server/settings/dialogsettingstray.h
Normal file
79
Server/settings/dialogsettingstray.h
Normal file
@@ -0,0 +1,79 @@
|
||||
#ifndef DIALOGSETTINGSTRAY_H
|
||||
#define DIALOGSETTINGSTRAY_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QTranslator>
|
||||
#include <QEvent>
|
||||
#include "providerdblms.h"
|
||||
|
||||
class ServerDBSettings{
|
||||
public:
|
||||
QString Type;
|
||||
QString NameDB;
|
||||
QString UserName;
|
||||
QString Password;
|
||||
QString HostName;
|
||||
QString Port;
|
||||
QString Language;
|
||||
};
|
||||
|
||||
namespace Ui {
|
||||
class DialogSettingsTray;
|
||||
}
|
||||
|
||||
class DialogSettingsTray : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DialogSettingsTray(ProviderDBLMS* providerDBLMS, QWidget *parent = nullptr);
|
||||
~DialogSettingsTray();
|
||||
|
||||
ServerDBSettings getSettings();
|
||||
|
||||
bool settingsDBisChanged(){ return flSettingsServerChanged;}
|
||||
|
||||
static bool loadSettings(ServerDBSettings *settings);
|
||||
|
||||
signals:
|
||||
//сигнал об изменении языка интерфейса
|
||||
void signal_LanguageChanged(QString language);
|
||||
void signal_UpdateDocs();
|
||||
|
||||
private slots:
|
||||
void on_btnSave_clicked();
|
||||
|
||||
void on_cmbLanguage_currentIndexChanged(int index);
|
||||
|
||||
void on_DialogSettingsTray_accepted();
|
||||
|
||||
void on_editNameDB_textChanged(const QString &arg1);
|
||||
|
||||
void on_editHostName_textChanged(const QString &arg1);
|
||||
|
||||
void on_editPort_textChanged(const QString &arg1);
|
||||
|
||||
void on_editUserName_textChanged(const QString &arg1);
|
||||
|
||||
void on_editPassword_textChanged(const QString &arg1);
|
||||
|
||||
void on_btnCheckDB_clicked();
|
||||
|
||||
void on_checkLocalhost_stateChanged(int arg1);
|
||||
|
||||
void on_btnUpdateDocs_clicked();
|
||||
|
||||
private:
|
||||
bool saveSettings();
|
||||
|
||||
private:
|
||||
Ui::DialogSettingsTray *ui;
|
||||
|
||||
ServerDBSettings *settings;
|
||||
|
||||
ProviderDBLMS* providerDBLMS;
|
||||
|
||||
bool flSettingsServerChanged;
|
||||
};
|
||||
|
||||
#endif // DIALOGSETTINGSTRAY_H
|
||||
365
Server/settings/dialogsettingstray.ui
Normal file
365
Server/settings/dialogsettingstray.ui
Normal file
@@ -0,0 +1,365 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>DialogSettingsTray</class>
|
||||
<widget class="QDialog" name="DialogSettingsTray">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>550</width>
|
||||
<height>400</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Settings</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_Main">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_Main">
|
||||
<property name="title">
|
||||
<string>Main</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_Main">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_Language">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_Language">
|
||||
<property name="text">
|
||||
<string>Language</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>
|
||||
<item>
|
||||
<widget class="QComboBox" name="cmbLanguage"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Line" name="line">
|
||||
<property name="lineWidth">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_DB">
|
||||
<property name="title">
|
||||
<string>Database</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="0">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_DB">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_Local">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_Local">
|
||||
<property name="text">
|
||||
<string>Local</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkLocalhost">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_HostName">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_IP">
|
||||
<property name="text">
|
||||
<string>IP address</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="editHostName">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>170</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_Port">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_Port">
|
||||
<property name="text">
|
||||
<string>Port</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="editPort">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>70</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_NameDB">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_NameDB">
|
||||
<property name="text">
|
||||
<string>Database name</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="editNameDB">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>170</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_UserName">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_UserName">
|
||||
<property name="text">
|
||||
<string>User name</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="editUserName">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>170</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_Password">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_Password">
|
||||
<property name="text">
|
||||
<string>User password</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="editPassword">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>170</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_Save">
|
||||
<item>
|
||||
<widget class="QToolButton" name="btnSave">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>58</width>
|
||||
<height>58</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Save</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../InstructorsAndTrainees/InstructorsAndTrainees.qrc">
|
||||
<normaloff>:/resources/icons/circleGreen.png</normaloff>:/resources/icons/circleGreen.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>32</width>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolButtonStyle">
|
||||
<enum>Qt::ToolButtonTextUnderIcon</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_Additional">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Additional</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_4">
|
||||
<item row="0" column="0">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_Additional">
|
||||
<item>
|
||||
<widget class="QToolButton" name="btnCheckDB">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>58</width>
|
||||
<height>58</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Check DB</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../ServerLMS.qrc">
|
||||
<normaloff>:/resources/icons/checkDB.png</normaloff>:/resources/icons/checkDB.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>32</width>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolButtonStyle">
|
||||
<enum>Qt::ToolButtonTextUnderIcon</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_2">
|
||||
<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>
|
||||
<widget class="QToolButton" name="btnUpdateDocs">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>80</width>
|
||||
<height>58</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Update Docs</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../InstructorsAndTrainees/InstructorsAndTrainees.qrc">
|
||||
<normaloff>:/resources/icons/exchange.png</normaloff>:/resources/icons/exchange.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>32</width>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolButtonStyle">
|
||||
<enum>Qt::ToolButtonTextUnderIcon</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="../../InstructorsAndTrainees/InstructorsAndTrainees.qrc"/>
|
||||
<include location="../ServerLMS.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
Reference in New Issue
Block a user