Browse Source

Gui improvements

Ivan Arkhipov 5 years ago
parent
commit
43cf1850dd

+ 6 - 0
src/Legacy/widgets/mainwindow.cpp

@@ -345,6 +345,11 @@ void MainWindow::updateFontSizes()
 }
 
 void MainWindow::on_closeButton_clicked()
+{
+    close();
+}
+
+void MainWindow::closeEvent(QCloseEvent *event)
 {
     if (show_warning_on_close) {
         auto result = QMessageBox::question(this, "Подтвердите действие", "Внимание! В настоящий момент выполняются процессы установки/обновления.\n"
@@ -356,6 +361,7 @@ void MainWindow::on_closeButton_clicked()
     } else {
         qApp->quit();
     }
+    event->ignore();
 }
 
 void MainWindow::on_minimizeButton_clicked()

+ 4 - 0
src/Legacy/widgets/mainwindow.h

@@ -8,6 +8,7 @@
 #include <QBitmap>
 #include <QGraphicsBlurEffect>
 #include <QFont>
+#include <QCloseEvent>
 #include <QMutex>
 #include <QMutexLocker>
 
@@ -34,6 +35,9 @@ public:
     ~MainWindow();
     int getLastDialogResult();
 
+protected:
+    virtual void closeEvent(QCloseEvent *event) override;
+
 public slots:
     void showMessageDialog(QObject* emitter, QString message, QString ok_button_text = "Ок", QString cancel_button_text = "Отмена");
     void updateFontSizes();

+ 74 - 26
src/Legacy/widgets/statuswidget.cpp

@@ -133,7 +133,7 @@ void StatusWidget::resizeEvent(QResizeEvent *)
     ui->server_status_tooltip->resize(QSize(365, 114) * coefficient);
 
     ui->patches_status->move(QPoint(38, 13) * coefficient);
-    ui->patches_status->resize(QSize(365, 114) * coefficient);
+    ui->patches_status->resize(QSize(385, 114) * coefficient);
 
     updateFontsSizes();
 }
@@ -200,34 +200,21 @@ void StatusWidget::onPatchOperationsFinished()
 void StatusWidget::onDownloadTotalStatusChanged(Downloader::Status status)
 {
     last_download_status_ = status;
-    
-    QString text = "Выполнение операций...";
-    if (last_download_status_.running) {
-        text += "\nЗагрузка данных: " + QString::number(last_download_status_.percent, 'f', 1) + "%, осталось примерно: " + Downloader::getElapsedTimeFormatted(last_download_status_.elapsed_time);
-    }
-    
-    if (last_install_status_.process != Patch::CurrentProcess::E_FINISHED) {
-        text += "\nПрименение патчей: " + QString::number(last_install_status_.percent + 100.0 * (last_install_status_.current_part - 1) / (100 * last_install_status_.total_parts), 'f', 1) + "%";
-    }
-
-    ui->progress_label->setText(text);
+    updateStatusBar();
+//        qDebug() << "Download total status: \n" <<
+//                    "    cur_speed = " << Downloader::getSpeedFormatted(status.current_speed) << "\n" <<
+//                    "    avg_speed = " << Downloader::getSpeedFormatted(status.average_speed) << "\n" <<
+//                    "    percent = " << status.percent << "\n" <<
+//                    "    total size = " << Downloader::getSizeFormatted(status.total_bytes) << "\n" <<
+//                    "    downloaded size = " << Downloader::getSizeFormatted(status.downloaded_bytes) << "\n" <<
+//                    "    elapsed time = " << status.elapsed_time << "\n\n";
 
 }
 
 void StatusWidget::onInstallTotalStatusChanged(Patch::InstallationStatus status)
 {
     last_install_status_ = status;
-
-    QString text = "Выполнение операций...";
-    if (last_download_status_.running) {
-        text += "\nЗагрузка данных: " + QString::number(last_download_status_.percent, 'f', 1) + "%, осталось примерно: " + Downloader::getElapsedTimeFormatted(last_download_status_.elapsed_time);
-    }
-
-    if (last_install_status_.process != Patch::CurrentProcess::E_FINISHED) {
-        text += "\nПрименение патчей: " + QString::number(last_install_status_.percent + 100.0 * (last_install_status_.current_part - 1) / (100 * last_install_status_.total_parts), 'f', 1) + "%";
-    }
-
-    ui->progress_label->setText(text);
+    updateStatusBar();
 }
 
 void StatusWidget::onPatchOperationStarted(QString operation_name, Patch *patch)
@@ -238,10 +225,24 @@ void StatusWidget::onPatchOperationStarted(QString operation_name, Patch *patch)
         return;
     }
 
-    patch_status_label->setText(operation_name);
+    QString text = "";
+    if (operation_name == "checkForUpdates") {
+        text = "Поиск и проверка обновлений...";
+    }
+    if (operation_name == "download") {
+        text = "Проверка файлов данных...";
+    }
+    if (operation_name == "install") {
+        text = "Ожидание начала установки...";
+    }
+    if (operation_name == "apply") {
+        text = "Ожидание начала применения...";
+    }
+
+    patch_status_label->setText(text);
 }
 
-void StatusWidget::onPatchOperationFinished(QString operation_name, Patch *patch)
+void StatusWidget::onPatchOperationFinished(QString operation_name, Patch *patch, bool result)
 {
     QLabel* patch_status_label = findChild<QLabel*>(patch->getPatchName().toLower() + "_status");
     if (!patch_status_label) {
@@ -249,17 +250,64 @@ void StatusWidget::onPatchOperationFinished(QString operation_name, Patch *patch
         return;
     }
 
-    patch_status_label->setText("Завершено");
+    if (result) {
+        patch_status_label->setText("Все операции завершены");
+        QString install_date;
+        if (!(install_date = Settings::getValue("UpdateDates/" + patch->getPatchName()).toString()).isEmpty()) {
+            patch_status_label->setText("Патч версии от " + install_date);
+        }
+    } else {
+        patch_status_label->setText("Операция завершилась с ошибкой");
+    }
 }
 
 void StatusWidget::onPatchDownloadStatusChanged(Patch *patch, Downloader::Status status)
 {
+    QString label_name = patch->getPatchName().toLower() + "_status";
+    QLabel *label = findChild<QLabel*>(label_name);
+    if (!label) {
+        qDebug() << "Error, cannot find child of StatusWidget with name " + label_name;
+        return;
+    }
 
+    label->setText("Загрузка " + QString::number(status.percent, 'f', 1) + "% (" + Downloader::getSizeFormatted(status.downloaded_bytes) + " / "
+                   + Downloader::getSizeFormatted(status.total_bytes) + ")");
 }
 
 void StatusWidget::onPatchInstallStatusChanged(Patch *patch, Patch::InstallationStatus status)
 {
+    QString label_name = patch->getPatchName().toLower() + "_status";
+    QLabel *label = findChild<QLabel*>(label_name);
+    if (!label) {
+        qDebug() << "Error, cannot find child of StatusWidget with name " + label_name;
+        return;
+    }
 
+    if (status.process == Patch::CurrentProcess::E_INSTALL) {
+        label->setText("Установка (" + QString::number(status.current_part) + " из " + QString::number(status.total_parts) + ") " + QString::number(status.percent, 'f', 1));
+    }
+}
+
+void StatusWidget::updateStatusBar()
+{
+    if (last_progress_update_time.elapsed() > 1000) {
+        QString text = "Выполнение операций...";
+        if (last_download_status_.running) {
+            text += "\nЗагрузка данных: " + QString::number(last_download_status_.percent, 'f', 1) + "% ("
+                    + Downloader::getSizeFormatted(last_download_status_.downloaded_bytes) + "/"
+                    + Downloader::getSizeFormatted(last_download_status_.total_bytes) + ", "
+                    + Downloader::getSpeedFormatted(last_download_status_.current_speed) + ")\n"
+                    + "Осталось примерно: " + Downloader::getElapsedTimeFormatted(last_download_status_.elapsed_time);
+        }
+
+        if (last_install_status_.process != Patch::CurrentProcess::E_FINISHED) {
+            text += "\nПрименение патчей: " + QString::number(last_install_status_.percent + 100.0 * (last_install_status_.current_part - 1) / (100 * last_install_status_.total_parts), 'f', 1) + "%";
+        }
+
+        ui->progress_label->setText(text);
+        ui->progressBar->setValue(last_download_status_.percent * 0.85 + last_install_status_.percent * 0.15);
+        last_progress_update_time.restart();
+    }
 }
 
 

+ 4 - 1
src/Legacy/widgets/statuswidget.h

@@ -43,10 +43,13 @@ private slots:
     void onInstallTotalStatusChanged(Patch::InstallationStatus status);
     
     void onPatchOperationStarted(QString operation_name, Patch* patch);
-    void onPatchOperationFinished(QString operation_name, Patch* patch);
+    void onPatchOperationFinished(QString operation_name, Patch* patch, bool result);
     void onPatchDownloadStatusChanged(Patch* patch, Downloader::Status status);
     void onPatchInstallStatusChanged(Patch* patch, Patch::InstallationStatus status);
 
+private:
+    void updateStatusBar();
+
 private:
     Downloader::Status last_download_status_;
     Patch::InstallationStatus last_install_status_;

+ 36 - 44
src/Legacy/widgets/statuswidget.ui

@@ -247,9 +247,9 @@ border-image: url(:/characters/galadriel_with_text.png);
    <widget class="QWidget" name="patches_status" native="true">
     <property name="geometry">
      <rect>
-      <x>38</x>
+      <x>50</x>
       <y>13</y>
-      <width>365</width>
+      <width>344</width>
       <height>114</height>
      </rect>
     </property>
@@ -272,21 +272,8 @@ border-image: url(:/characters/galadriel_with_text.png);
      <property name="verticalSpacing">
       <number>5</number>
      </property>
-     <item row="0" column="1" rowspan="4">
-      <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 row="0" column="0">
-      <widget class="QLabel" name="textspatch_label">
+     <item row="0" column="1">
+      <widget class="QLabel" name="textspatch_status">
        <property name="sizePolicy">
         <sizepolicy hsizetype="Fixed" vsizetype="Preferred">
          <horstretch>0</horstretch>
@@ -300,12 +287,12 @@ border-image: url(:/characters/galadriel_with_text.png);
         </font>
        </property>
        <property name="text">
-        <string>Тексты:</string>
+        <string>поиск и проверка обновлений...</string>
        </property>
       </widget>
      </item>
-     <item row="0" column="2">
-      <widget class="QLabel" name="textspatch_status">
+     <item row="1" column="0">
+      <widget class="QLabel" name="graphicspatch_label">
        <property name="sizePolicy">
         <sizepolicy hsizetype="Fixed" vsizetype="Preferred">
          <horstretch>0</horstretch>
@@ -319,12 +306,12 @@ border-image: url(:/characters/galadriel_with_text.png);
         </font>
        </property>
        <property name="text">
-        <string>получение информации...</string>
+        <string>Картинки:</string>
        </property>
       </widget>
      </item>
-     <item row="1" column="0">
-      <widget class="QLabel" name="graphicspatch_label">
+     <item row="0" column="0">
+      <widget class="QLabel" name="textspatch_label">
        <property name="sizePolicy">
         <sizepolicy hsizetype="Fixed" vsizetype="Preferred">
          <horstretch>0</horstretch>
@@ -338,12 +325,12 @@ border-image: url(:/characters/galadriel_with_text.png);
         </font>
        </property>
        <property name="text">
-        <string>Картинки:</string>
+        <string>Тексты:</string>
        </property>
       </widget>
      </item>
-     <item row="1" column="2">
-      <widget class="QLabel" name="graphicspatch_status">
+     <item row="2" column="1">
+      <widget class="QLabel" name="soundspatch_status">
        <property name="sizePolicy">
         <sizepolicy hsizetype="Fixed" vsizetype="Preferred">
          <horstretch>0</horstretch>
@@ -361,8 +348,8 @@ border-image: url(:/characters/galadriel_with_text.png);
        </property>
       </widget>
      </item>
-     <item row="2" column="2">
-      <widget class="QLabel" name="soundspatch_status">
+     <item row="2" column="0">
+      <widget class="QLabel" name="soundspatch_label">
        <property name="sizePolicy">
         <sizepolicy hsizetype="Fixed" vsizetype="Preferred">
          <horstretch>0</horstretch>
@@ -376,12 +363,12 @@ border-image: url(:/characters/galadriel_with_text.png);
         </font>
        </property>
        <property name="text">
-        <string>получение информации...</string>
+        <string>Озвучка:</string>
        </property>
       </widget>
      </item>
-     <item row="2" column="0">
-      <widget class="QLabel" name="soundspatch_label">
+     <item row="1" column="1">
+      <widget class="QLabel" name="graphicspatch_status">
        <property name="sizePolicy">
         <sizepolicy hsizetype="Fixed" vsizetype="Preferred">
          <horstretch>0</horstretch>
@@ -395,12 +382,12 @@ border-image: url(:/characters/galadriel_with_text.png);
         </font>
        </property>
        <property name="text">
-        <string>Озвучка:</string>
+        <string>получение информации...</string>
        </property>
       </widget>
      </item>
-     <item row="3" column="0">
-      <widget class="QLabel" name="videospatch_label">
+     <item row="3" column="1">
+      <widget class="QLabel" name="videospatch_status">
        <property name="sizePolicy">
         <sizepolicy hsizetype="Fixed" vsizetype="Preferred">
          <horstretch>0</horstretch>
@@ -414,12 +401,12 @@ border-image: url(:/characters/galadriel_with_text.png);
         </font>
        </property>
        <property name="text">
-        <string>Ролики:</string>
+        <string>получение информации...</string>
        </property>
       </widget>
      </item>
-     <item row="3" column="2">
-      <widget class="QLabel" name="videospatch_status">
+     <item row="3" column="0">
+      <widget class="QLabel" name="videospatch_label">
        <property name="sizePolicy">
         <sizepolicy hsizetype="Fixed" vsizetype="Preferred">
          <horstretch>0</horstretch>
@@ -433,18 +420,18 @@ border-image: url(:/characters/galadriel_with_text.png);
         </font>
        </property>
        <property name="text">
-        <string>получение информации...</string>
+        <string>Ролики:</string>
        </property>
       </widget>
      </item>
-     <item row="0" column="3" rowspan="4">
+     <item row="0" column="2" rowspan="4">
       <spacer name="horizontalSpacer_2">
        <property name="orientation">
         <enum>Qt::Horizontal</enum>
        </property>
        <property name="sizeHint" stdset="0">
         <size>
-         <width>40</width>
+         <width>0</width>
          <height>20</height>
         </size>
        </property>
@@ -481,6 +468,11 @@ border-image: url(:/characters/galadriel_with_text.png);
      <bool>true</bool>
     </property>
    </widget>
+   <zorder>weekly_code_tooltip_1</zorder>
+   <zorder>news_tooltip</zorder>
+   <zorder>weekly_code_tooltip_2</zorder>
+   <zorder>server_status_tooltip</zorder>
+   <zorder>patches_status</zorder>
   </widget>
   <widget class="QPushButton" name="game_button">
    <property name="geometry">
@@ -550,9 +542,9 @@ QPushButton#game_button:disabled {
   <widget class="QLabel" name="progress_label">
    <property name="geometry">
     <rect>
-     <x>330</x>
+     <x>329</x>
      <y>390</y>
-     <width>380</width>
+     <width>381</width>
      <height>90</height>
     </rect>
    </property>
@@ -577,7 +569,7 @@ QPushButton#game_button:disabled {
     <set>Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft</set>
    </property>
    <property name="wordWrap">
-    <bool>true</bool>
+    <bool>false</bool>
    </property>
   </widget>
   <widget class="QProgressBar" name="progressBar">
@@ -620,7 +612,7 @@ margin-bottom:7px;
     <number>100</number>
    </property>
    <property name="value">
-    <number>0</number>
+    <number>1</number>
    </property>
    <property name="textVisible">
     <bool>false</bool>