statuswidget.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. #ifndef STATUSWIDGET_H
  2. #define STATUSWIDGET_H
  3. #include <QWidget>
  4. #include <QSettings>
  5. #include <QTime>
  6. #include <QElapsedTimer>
  7. #include <QMap>
  8. #include <QPropertyAnimation>
  9. #include <QGraphicsOpacityEffect>
  10. #include <QLabel>
  11. #include "legacyapplication.h"
  12. #include "models/downloader.h"
  13. #include "models/patchinstaller.h"
  14. namespace Ui {
  15. class StatusWidget;
  16. }
  17. class StatusWidget : public QWidget
  18. {
  19. Q_OBJECT
  20. public:
  21. // States. Higher state value means higher priority on visualisation
  22. enum ToolTipState : int {
  23. E_HINT = 0b1000,
  24. E_PROCESS = 0b0100,
  25. E_INFO = 0b0010,
  26. E_RANDOM = 0b0001
  27. };
  28. explicit StatusWidget(QWidget *parent = 0);
  29. ~StatusWidget();
  30. public slots:
  31. void updateFontsSizes();
  32. void setToolTipMessage(QString message, ToolTipState state);
  33. void unsetToolTipMessage(ToolTipState state);
  34. void show();
  35. void hide();
  36. protected:
  37. void resizeEvent(QResizeEvent *event) override;
  38. private slots:
  39. void onErrorStatusChanged(AppErrorStatus status);
  40. void generateRandomTooltipMessage();
  41. void fadeBetweenToolTips(QString tooltip_id);
  42. void onPatchDownloaderStarted();
  43. void onPatchDownloaderFinished();
  44. void onPatchDownloaderProgressChanged(Downloader::Status status);
  45. void onPatchInstallerStarted();
  46. void onPatchInstallerFinished();
  47. void onPatchInstallerProgressChanged(PatchInstaller::Status status);
  48. void onPatchInstallerVideoProgressChanged(int finished_videos, int total_videos, Downloader::Status status);
  49. void on_game_button_clicked();
  50. void showComponentsStatus();
  51. void hideComponentsStatus();
  52. void onTranslationComponentsNeedToPatch();
  53. void onTranslationComponentsNoNeedToPatch();
  54. private:
  55. void createTooltipMessageWidget(QString tooltip_id);
  56. void updateButtonStatus();
  57. private:
  58. Ui::StatusWidget *ui;
  59. bool all_patch_operations_finished_ = false;
  60. QMap<QString, QLabel*> tooltip_widgets_;
  61. QMap<QString, QGraphicsOpacityEffect*> tooltip_effects_;
  62. QMap<QString, QPropertyAnimation*> tooltip_animations_;
  63. QString current_tooltip_message_;
  64. QElapsedTimer last_statusbar_update_time_;
  65. ToolTipState tooltip_state_ = E_RANDOM;
  66. QMap<ToolTipState, QString> tooltip_messages_;
  67. QGraphicsOpacityEffect* _components_status_opacity_effect;
  68. QPropertyAnimation* _components_status_opacity_animation;
  69. bool _need_to_install_patches = false;
  70. bool _need_to_update = false;
  71. bool _need_to_repair_game_files = false;
  72. bool _need_to_forcely_patch = false;
  73. };
  74. #endif // STATUSWIDGET_H