mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/RRJServer.git
synced 2026-03-28 19:55:48 +03:00
Рефакт интерфейса
This commit is contained in:
@@ -35,6 +35,35 @@ bool DataBaseLMS::createConnection()
|
|||||||
dbSettings.connectionName = "Connection_" + dbSettings.dbName;
|
dbSettings.connectionName = "Connection_" + dbSettings.dbName;
|
||||||
|
|
||||||
db = new QSqlDatabase(QSqlDatabase::addDatabase(dbSettings.dbType, dbSettings.connectionName));
|
db = new QSqlDatabase(QSqlDatabase::addDatabase(dbSettings.dbType, dbSettings.connectionName));
|
||||||
|
|
||||||
|
/*
|
||||||
|
db->setUserName(dbSettings.dbUserName);
|
||||||
|
db->setPassword(dbSettings.dbPassword);
|
||||||
|
//db->setHostName(dbSettings.dbHostName);
|
||||||
|
//db->setPort(dbSettings.dbPort);
|
||||||
|
bool res1 = db->open();
|
||||||
|
|
||||||
|
//Проверка наличия БД
|
||||||
|
QString queryStr = QString("SELECT datname FROM pg_database");
|
||||||
|
QSqlQuery query = QSqlQuery(*db);
|
||||||
|
bool flExist = false;
|
||||||
|
if(queryExec(queryStr, &query))
|
||||||
|
{
|
||||||
|
while (query.next())
|
||||||
|
{//Инструктор
|
||||||
|
QString nameDB = "";
|
||||||
|
nameDB = query.value(0).toString();
|
||||||
|
if(nameDB == dbSettings.dbName)
|
||||||
|
flExist = true;
|
||||||
|
|
||||||
|
nameDB = query.value(1).toString();
|
||||||
|
nameDB = query.value(2).toString();
|
||||||
|
nameDB = query.value(3).toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
db->setDatabaseName(dbSettings.dbName);
|
db->setDatabaseName(dbSettings.dbName);
|
||||||
db->setUserName(dbSettings.dbUserName);
|
db->setUserName(dbSettings.dbUserName);
|
||||||
db->setPassword(dbSettings.dbPassword);
|
db->setPassword(dbSettings.dbPassword);
|
||||||
|
|||||||
@@ -68,9 +68,9 @@ ServerLMSWidget::~ServerLMSWidget()
|
|||||||
loggerThread->quit();
|
loggerThread->quit();
|
||||||
loggerThread->wait();
|
loggerThread->wait();
|
||||||
delete loggerThread;
|
delete loggerThread;
|
||||||
}
|
|
||||||
|
|
||||||
delete providerDBLMS;
|
delete providerDBLMS;
|
||||||
|
}
|
||||||
|
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
@@ -91,12 +91,10 @@ void ServerLMSWidget::changeEvent(QEvent *event)
|
|||||||
dbSettings.dbHostName,
|
dbSettings.dbHostName,
|
||||||
QString::number(dbSettings.dbPort));
|
QString::number(dbSettings.dbPort));
|
||||||
ui->lblDBsettings->setText(strDBsettings);
|
ui->lblDBsettings->setText(strDBsettings);
|
||||||
ui->lblDBisConnected->setPixmap(QPixmap(QStringLiteral(":/resources/icons/circleGreen.png")));
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ui->lblDBsettings->setText("");
|
ui->lblDBsettings->setText("");
|
||||||
ui->lblDBisConnected->setPixmap(QPixmap(QStringLiteral(":/resources/icons/circleGray.png")));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -327,7 +325,7 @@ void ServerLMSWidget::tryConnectionToDB()
|
|||||||
ui->btnStartServer->setEnabled(false);
|
ui->btnStartServer->setEnabled(false);
|
||||||
//QMessageBox::critical(this, tr("Error!"), tr("Database connection error!"));
|
//QMessageBox::critical(this, tr("Error!"), tr("Database connection error!"));
|
||||||
|
|
||||||
emit signal_Tray_ShowMessage(tr("Database connection error!"));
|
emit signal_Tray_ShowMessage(tr("Database connection error!"), QSystemTrayIcon::Critical);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QTranslator>
|
#include <QTranslator>
|
||||||
#include <QMutex>
|
#include <QMutex>
|
||||||
|
#include <QSystemTrayIcon>
|
||||||
|
|
||||||
#include <Systems/Parsers/dataparser.h>
|
#include <Systems/Parsers/dataparser.h>
|
||||||
#include <Systems/sendsystem.h>
|
#include <Systems/sendsystem.h>
|
||||||
@@ -49,6 +50,8 @@ public:
|
|||||||
explicit ServerLMSWidget(QWidget *parent = nullptr);
|
explicit ServerLMSWidget(QWidget *parent = nullptr);
|
||||||
~ServerLMSWidget();
|
~ServerLMSWidget();
|
||||||
|
|
||||||
|
void start();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static const QString languageENG;
|
static const QString languageENG;
|
||||||
static const QString languageRUS;
|
static const QString languageRUS;
|
||||||
@@ -63,7 +66,7 @@ signals:
|
|||||||
void signal_LanguageChanged(QString language);
|
void signal_LanguageChanged(QString language);
|
||||||
|
|
||||||
//сигнал вывода сообщения из трея
|
//сигнал вывода сообщения из трея
|
||||||
void signal_Tray_ShowMessage(QString textMsg);
|
void signal_Tray_ShowMessage(QString textMsg, QSystemTrayIcon::MessageIcon iconMsg = QSystemTrayIcon::Information);
|
||||||
|
|
||||||
void sigRecognize();
|
void sigRecognize();
|
||||||
void sigCalculateFullHash();
|
void sigCalculateFullHash();
|
||||||
@@ -104,8 +107,6 @@ public:
|
|||||||
|
|
||||||
void removeClient(int socketId);
|
void removeClient(int socketId);
|
||||||
|
|
||||||
void start();
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_btnStartServer_clicked();
|
void on_btnStartServer_clicked();
|
||||||
void on_btnStopServer_clicked();
|
void on_btnStopServer_clicked();
|
||||||
|
|||||||
@@ -50,8 +50,9 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||||||
* данного нажатия
|
* данного нажатия
|
||||||
* */
|
* */
|
||||||
connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
|
connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
|
||||||
this, SLOT(slot_IconActivated(QSystemTrayIcon::ActivationReason)));
|
this, SLOT(slot_Activated(QSystemTrayIcon::ActivationReason)));
|
||||||
|
|
||||||
|
slot_Tray_ShowMessage(tr("Starting the server..."));
|
||||||
|
|
||||||
|
|
||||||
serverLMSWidget = new ServerLMSWidget(this);
|
serverLMSWidget = new ServerLMSWidget(this);
|
||||||
@@ -66,14 +67,8 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||||||
qtLanguageTranslator.load(QString("translations/TrayServerLMS_") + serverLMSWidget->getLanguage(), ".");
|
qtLanguageTranslator.load(QString("translations/TrayServerLMS_") + serverLMSWidget->getLanguage(), ".");
|
||||||
qApp->installTranslator(&qtLanguageTranslator);
|
qApp->installTranslator(&qtLanguageTranslator);
|
||||||
|
|
||||||
//this->move(0, 0);
|
|
||||||
//this->showNormal();
|
|
||||||
//this->showMaximized();
|
|
||||||
|
|
||||||
errorCheck();
|
errorCheck();
|
||||||
|
|
||||||
//QThread::sleep(2);
|
|
||||||
|
|
||||||
slot_Menu_HideWindow();
|
slot_Menu_HideWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,7 +89,7 @@ void MainWindow::closeEvent(QCloseEvent * event)
|
|||||||
|
|
||||||
/* Метод, который обрабатывает нажатие на иконку приложения в трее
|
/* Метод, который обрабатывает нажатие на иконку приложения в трее
|
||||||
* */
|
* */
|
||||||
void MainWindow::slot_IconActivated(QSystemTrayIcon::ActivationReason reason)
|
void MainWindow::slot_Activated(QSystemTrayIcon::ActivationReason reason)
|
||||||
{
|
{
|
||||||
switch (reason){
|
switch (reason){
|
||||||
case QSystemTrayIcon::Trigger:
|
case QSystemTrayIcon::Trigger:
|
||||||
@@ -115,6 +110,14 @@ void MainWindow::slot_IconActivated(QSystemTrayIcon::ActivationReason reason)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::slot_MessageClicked()
|
||||||
|
{
|
||||||
|
if(!this->isVisible())
|
||||||
|
{
|
||||||
|
slot_Menu_ShowWindow();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void MainWindow::exit()
|
void MainWindow::exit()
|
||||||
{
|
{
|
||||||
@@ -150,6 +153,8 @@ void MainWindow::errorCheck()
|
|||||||
{
|
{
|
||||||
if(serverLMSWidget->hasError() == 100)
|
if(serverLMSWidget->hasError() == 100)
|
||||||
{
|
{
|
||||||
|
slot_Menu_ShowWindow();
|
||||||
|
|
||||||
QMessageBox msgBox;
|
QMessageBox msgBox;
|
||||||
|
|
||||||
msgBox.setWindowTitle(tr("Error!"));
|
msgBox.setWindowTitle(tr("Error!"));
|
||||||
@@ -164,7 +169,7 @@ void MainWindow::errorCheck()
|
|||||||
if (ret == QMessageBox::Close)
|
if (ret == QMessageBox::Close)
|
||||||
{
|
{
|
||||||
//выключение с задержкой, так как eventLoop инициализируется позже
|
//выключение с задержкой, так как eventLoop инициализируется позже
|
||||||
QTimer::singleShot(1000,this,&MainWindow::exit);
|
QTimer::singleShot(1000,this,&MainWindow::slot_Menu_Exit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -182,11 +187,8 @@ void MainWindow::slot_Menu_HideWindow()
|
|||||||
action_ShowWindow->setEnabled(true);
|
action_ShowWindow->setEnabled(true);
|
||||||
action_HideWindow->setEnabled(false);
|
action_HideWindow->setEnabled(false);
|
||||||
|
|
||||||
QSystemTrayIcon::MessageIcon icon = QSystemTrayIcon::MessageIcon(QSystemTrayIcon::Information);
|
slot_Tray_ShowMessage(tr("The application is minimized to the tray.\n"
|
||||||
trayIcon->showMessage(tr("Server LMS"),
|
"To maximize the application window, click the application icon in the tray."));
|
||||||
tr("The application is minimized to the tray. "
|
|
||||||
"To maximize the application window, click the application icon in the tray."),
|
|
||||||
icon, 100);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::slot_Menu_Exit()
|
void MainWindow::slot_Menu_Exit()
|
||||||
@@ -195,9 +197,9 @@ void MainWindow::slot_Menu_Exit()
|
|||||||
this->close();
|
this->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::slot_Tray_ShowMessage(QString textMsg)
|
void MainWindow::slot_Tray_ShowMessage(QString textMsg, QSystemTrayIcon::MessageIcon iconMsg)
|
||||||
{
|
{
|
||||||
QSystemTrayIcon::MessageIcon icon = QSystemTrayIcon::MessageIcon(QSystemTrayIcon::Warning);
|
QSystemTrayIcon::MessageIcon icon = QSystemTrayIcon::MessageIcon(iconMsg);
|
||||||
trayIcon->showMessage(tr("Server LMS"),
|
trayIcon->showMessage(tr("Server LMS"),
|
||||||
textMsg,
|
textMsg,
|
||||||
icon, 100);
|
icon, 100);
|
||||||
|
|||||||
@@ -41,7 +41,9 @@ public slots:
|
|||||||
void slot_LanguageChanged(QString language);
|
void slot_LanguageChanged(QString language);
|
||||||
|
|
||||||
//Слот нажатия на иконку приложения в трее
|
//Слот нажатия на иконку приложения в трее
|
||||||
void slot_IconActivated(QSystemTrayIcon::ActivationReason reason);
|
void slot_Activated(QSystemTrayIcon::ActivationReason reason);
|
||||||
|
//Слот нажатия на сообщение
|
||||||
|
void slot_MessageClicked();
|
||||||
|
|
||||||
//Слоты нажатия на пункты меню
|
//Слоты нажатия на пункты меню
|
||||||
void slot_Menu_ShowWindow();
|
void slot_Menu_ShowWindow();
|
||||||
@@ -49,7 +51,7 @@ public slots:
|
|||||||
void slot_Menu_Exit();
|
void slot_Menu_Exit();
|
||||||
|
|
||||||
//Слот вывода сообщения из трея
|
//Слот вывода сообщения из трея
|
||||||
void slot_Tray_ShowMessage(QString textMsg);
|
void slot_Tray_ShowMessage(QString textMsg, QSystemTrayIcon::MessageIcon iconMsg = QSystemTrayIcon::Information);
|
||||||
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|||||||
Reference in New Issue
Block a user