mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/RRJClient.git
synced 2026-03-28 05:25:39 +03:00
feat: first UI update
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
|
||||
#include <QFontDatabase>
|
||||
#include <QMessageBox>
|
||||
#include <QMovie>
|
||||
#include <QPaintEvent>
|
||||
#include <QPainter>
|
||||
#include <QTimer>
|
||||
@@ -14,9 +15,9 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
, ui(new Ui::MainWindow)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
setWindowFlag(Qt::FramelessWindowHint);
|
||||
painting();
|
||||
initialize();
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::initialize()
|
||||
@@ -60,6 +61,7 @@ void MainWindow::initialize()
|
||||
void MainWindow::createObjects()
|
||||
{
|
||||
connectionThread = new QThread;
|
||||
animationThread = new QThread;
|
||||
|
||||
client = new TCPClient;
|
||||
client->moveToThread(connectionThread);
|
||||
@@ -203,9 +205,11 @@ void MainWindow::checkLoginResult(ServerAuthorization *serverAuth)
|
||||
ui->loginWidget->hide();
|
||||
ui->LanguageWidget->hide();
|
||||
ui->settingsButton->hide();
|
||||
|
||||
ui->offlineStartButton->setGeometry(570,510,220,35);
|
||||
ui->offlineStartButton->show();
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
ui->notificationLabel->setText(tr("Неверный логин/пароль"));
|
||||
timer->setInterval(3000);
|
||||
timer->start();
|
||||
@@ -265,6 +269,8 @@ void MainWindow::slotConnectionState(bool flag)
|
||||
ui->notificationLabel->show();
|
||||
QPalette palette = ui->notificationLabel->palette();
|
||||
|
||||
stopLoadingMovie();
|
||||
|
||||
if(flag)
|
||||
{
|
||||
palette.setColor(ui->notificationLabel->foregroundRole(),Qt::green);
|
||||
@@ -280,7 +286,7 @@ void MainWindow::slotConnectionState(bool flag)
|
||||
ui->notificationLabel->setText(tr("Соединение отсутсвует"));
|
||||
ui->offlineWidget->show();
|
||||
ui->offlineStartButton->show();
|
||||
ui->offlineStartButton->setGeometry(300,340,220,35);
|
||||
ui->offlineStartButton->setGeometry(285,340,220,35);
|
||||
ui->settingsButton->show();
|
||||
ui->loginWidget->hide();
|
||||
}
|
||||
@@ -320,7 +326,6 @@ void MainWindow::callUpdateList()
|
||||
sendSystem->sendXMLAnswer(answer);
|
||||
|
||||
updateWidget->initialize(this);
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::bindNotifyWidget(UpdateNotifyWidget *widget)
|
||||
@@ -354,9 +359,6 @@ void MainWindow::on_loginButton_clicked()
|
||||
dataParser->createAuthMessage(autorization);
|
||||
emit sigSendAutorization();
|
||||
|
||||
ui->offlineStartButton->setGeometry(570,510,220,35);
|
||||
ui->offlineStartButton->show();
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::on_updateButton_clicked()
|
||||
@@ -374,13 +376,14 @@ void MainWindow::on_startButton_clicked()
|
||||
|
||||
void MainWindow::on_saveServerButton_clicked()
|
||||
{
|
||||
|
||||
startLoadingAnim();
|
||||
ui->settingsWidget->hide();
|
||||
|
||||
if(client->getIsConnected())
|
||||
{
|
||||
ui->loginWidget->show();
|
||||
ui->offlineStartButton->show();
|
||||
stopLoadingMovie();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -443,6 +446,12 @@ void MainWindow::on_updateListGuideLabel_linkActivated(const QString &link)
|
||||
updateWidget->show();
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::on_exitButton_clicked()
|
||||
{
|
||||
exit(0);
|
||||
}
|
||||
|
||||
void MainWindow::checkUpdate()
|
||||
{
|
||||
ui->loadingProgressBar->setValue(0);
|
||||
@@ -473,26 +482,14 @@ void MainWindow::showUpdateInfo()
|
||||
|
||||
void MainWindow::showCompleteDialogBox(bool flag)
|
||||
{
|
||||
QMessageBox *messageBox = new QMessageBox(this);
|
||||
ui->inlineTextDebug->setText(tr("Загрузка завершена"));
|
||||
movie->start();
|
||||
QTime dieTime= QTime::currentTime().addSecs(10);
|
||||
while (QTime::currentTime() < dieTime)
|
||||
QCoreApplication::processEvents(QEventLoop::AllEvents, 100);
|
||||
movie->stop();
|
||||
|
||||
if(flag)
|
||||
{
|
||||
messageBox->setIcon(QMessageBox::Information);
|
||||
messageBox->setWindowTitle(tr("Информация"));
|
||||
messageBox->addButton(QMessageBox::Ok);
|
||||
messageBox->setStyleSheet("QMessageBox {color: black;}");
|
||||
messageBox->setText(tr("Загрузка завершена"));
|
||||
}
|
||||
else
|
||||
{
|
||||
messageBox->setIcon(QMessageBox::Warning);
|
||||
messageBox->setWindowTitle(tr("Ошибка"));
|
||||
messageBox->addButton(QMessageBox::Ok);
|
||||
messageBox->setText(tr("Произошла ошибка при загрузке"));
|
||||
}
|
||||
|
||||
connect(messageBox,&QMessageBox::accepted,this,&MainWindow::checkUpdate);
|
||||
messageBox->show();
|
||||
checkUpdate();
|
||||
}
|
||||
|
||||
void MainWindow::keyPressEvent(QKeyEvent *event)
|
||||
@@ -511,6 +508,7 @@ void MainWindow::painting()
|
||||
QFontDatabase::addApplicationFont(":/resource/Fonts/Kanit Cyrillic.ttf");
|
||||
QFontDatabase::addApplicationFont(":/resource/Fonts/HelveticaNeue-Medium.ttf");
|
||||
|
||||
//settings
|
||||
QPixmap settingIcon(":resource/Icons/settingWhite.png");
|
||||
QPainter painter;
|
||||
QColor color(45,84,130);
|
||||
@@ -524,6 +522,43 @@ void MainWindow::painting()
|
||||
icon.addPixmap(settingIcon,QIcon::Normal,QIcon::Off);
|
||||
|
||||
ui->settingsButton->setIcon(icon);
|
||||
|
||||
//exit
|
||||
QPixmap crossPixmap(":resource/Icons/crossInCircle.png");
|
||||
QPainter painterCross;
|
||||
|
||||
painter.begin(&crossPixmap);
|
||||
painter.setCompositionMode(QPainter::CompositionMode_SourceIn);
|
||||
painter.fillRect(crossPixmap.rect(),color);
|
||||
painter.end();
|
||||
|
||||
QIcon crossIcon;
|
||||
crossIcon.addPixmap(crossPixmap,QIcon::Normal,QIcon::Off);
|
||||
|
||||
ui->exitButton->setIcon(crossIcon);
|
||||
|
||||
//loading
|
||||
|
||||
movie = new QMovie(":/resource/Icons/762.gif");
|
||||
movieLabel = new QLabel("No movie");
|
||||
movieLabel->setParent(this);
|
||||
movieLabel->setGeometry(367,300,70,70);
|
||||
movieLabel->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum);
|
||||
movieLabel->setMovie(movie);
|
||||
startLoadingAnim();
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::startLoadingAnim()
|
||||
{
|
||||
movie->start();
|
||||
movieLabel->show();
|
||||
}
|
||||
|
||||
void MainWindow::stopLoadingMovie()
|
||||
{
|
||||
movie->stop();
|
||||
movieLabel->hide();
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
@@ -539,3 +574,4 @@ MainWindow::~MainWindow()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user