mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/RRJServer.git
synced 2026-03-27 19:45:43 +03:00
Рефакт интерфейса
This commit is contained in:
@@ -35,6 +35,35 @@ bool DataBaseLMS::createConnection()
|
||||
dbSettings.connectionName = "Connection_" + dbSettings.dbName;
|
||||
|
||||
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->setUserName(dbSettings.dbUserName);
|
||||
db->setPassword(dbSettings.dbPassword);
|
||||
|
||||
@@ -68,9 +68,9 @@ ServerLMSWidget::~ServerLMSWidget()
|
||||
loggerThread->quit();
|
||||
loggerThread->wait();
|
||||
delete loggerThread;
|
||||
}
|
||||
|
||||
delete providerDBLMS;
|
||||
delete providerDBLMS;
|
||||
}
|
||||
|
||||
delete ui;
|
||||
}
|
||||
@@ -91,12 +91,10 @@ void ServerLMSWidget::changeEvent(QEvent *event)
|
||||
dbSettings.dbHostName,
|
||||
QString::number(dbSettings.dbPort));
|
||||
ui->lblDBsettings->setText(strDBsettings);
|
||||
ui->lblDBisConnected->setPixmap(QPixmap(QStringLiteral(":/resources/icons/circleGreen.png")));
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->lblDBsettings->setText("");
|
||||
ui->lblDBisConnected->setPixmap(QPixmap(QStringLiteral(":/resources/icons/circleGray.png")));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -327,7 +325,7 @@ void ServerLMSWidget::tryConnectionToDB()
|
||||
ui->btnStartServer->setEnabled(false);
|
||||
//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
|
||||
{
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <QMap>
|
||||
#include <QTranslator>
|
||||
#include <QMutex>
|
||||
#include <QSystemTrayIcon>
|
||||
|
||||
#include <Systems/Parsers/dataparser.h>
|
||||
#include <Systems/sendsystem.h>
|
||||
@@ -49,6 +50,8 @@ public:
|
||||
explicit ServerLMSWidget(QWidget *parent = nullptr);
|
||||
~ServerLMSWidget();
|
||||
|
||||
void start();
|
||||
|
||||
public:
|
||||
static const QString languageENG;
|
||||
static const QString languageRUS;
|
||||
@@ -63,7 +66,7 @@ signals:
|
||||
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 sigCalculateFullHash();
|
||||
@@ -104,8 +107,6 @@ public:
|
||||
|
||||
void removeClient(int socketId);
|
||||
|
||||
void start();
|
||||
|
||||
private slots:
|
||||
void on_btnStartServer_clicked();
|
||||
void on_btnStopServer_clicked();
|
||||
|
||||
@@ -50,8 +50,9 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
* данного нажатия
|
||||
* */
|
||||
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);
|
||||
@@ -66,14 +67,8 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
qtLanguageTranslator.load(QString("translations/TrayServerLMS_") + serverLMSWidget->getLanguage(), ".");
|
||||
qApp->installTranslator(&qtLanguageTranslator);
|
||||
|
||||
//this->move(0, 0);
|
||||
//this->showNormal();
|
||||
//this->showMaximized();
|
||||
|
||||
errorCheck();
|
||||
|
||||
//QThread::sleep(2);
|
||||
|
||||
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){
|
||||
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()
|
||||
{
|
||||
@@ -150,6 +153,8 @@ void MainWindow::errorCheck()
|
||||
{
|
||||
if(serverLMSWidget->hasError() == 100)
|
||||
{
|
||||
slot_Menu_ShowWindow();
|
||||
|
||||
QMessageBox msgBox;
|
||||
|
||||
msgBox.setWindowTitle(tr("Error!"));
|
||||
@@ -164,7 +169,7 @@ void MainWindow::errorCheck()
|
||||
if (ret == QMessageBox::Close)
|
||||
{
|
||||
//выключение с задержкой, так как 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_HideWindow->setEnabled(false);
|
||||
|
||||
QSystemTrayIcon::MessageIcon icon = QSystemTrayIcon::MessageIcon(QSystemTrayIcon::Information);
|
||||
trayIcon->showMessage(tr("Server LMS"),
|
||||
tr("The application is minimized to the tray. "
|
||||
"To maximize the application window, click the application icon in the tray."),
|
||||
icon, 100);
|
||||
slot_Tray_ShowMessage(tr("The application is minimized to the tray.\n"
|
||||
"To maximize the application window, click the application icon in the tray."));
|
||||
}
|
||||
|
||||
void MainWindow::slot_Menu_Exit()
|
||||
@@ -195,9 +197,9 @@ void MainWindow::slot_Menu_Exit()
|
||||
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"),
|
||||
textMsg,
|
||||
icon, 100);
|
||||
|
||||
@@ -41,7 +41,9 @@ public slots:
|
||||
void slot_LanguageChanged(QString language);
|
||||
|
||||
//Слот нажатия на иконку приложения в трее
|
||||
void slot_IconActivated(QSystemTrayIcon::ActivationReason reason);
|
||||
void slot_Activated(QSystemTrayIcon::ActivationReason reason);
|
||||
//Слот нажатия на сообщение
|
||||
void slot_MessageClicked();
|
||||
|
||||
//Слоты нажатия на пункты меню
|
||||
void slot_Menu_ShowWindow();
|
||||
@@ -49,7 +51,7 @@ public slots:
|
||||
void slot_Menu_Exit();
|
||||
|
||||
//Слот вывода сообщения из трея
|
||||
void slot_Tray_ShowMessage(QString textMsg);
|
||||
void slot_Tray_ShowMessage(QString textMsg, QSystemTrayIcon::MessageIcon iconMsg = QSystemTrayIcon::Information);
|
||||
|
||||
|
||||
signals:
|
||||
|
||||
Reference in New Issue
Block a user