mainwindow.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. #ifndef MAINWINDOW_H
  2. #define MAINWINDOW_H
  3. #include <QMainWindow>
  4. #include <QPropertyAnimation>
  5. #include <QTimer>
  6. #include <QPixmap>
  7. #include <QBitmap>
  8. #include "statuswidget.h"
  9. #include "rusificationwidget.h"
  10. #include "settingswidget.h"
  11. #include "newswidget.h"
  12. #include "helpwidget.h"
  13. namespace Ui {
  14. class MainWindow;
  15. }
  16. class MenuEntry;
  17. class LegacyApp;
  18. class MainWindow : public QMainWindow
  19. {
  20. Q_OBJECT
  21. struct PixmapObertka{
  22. QPixmap* pixmap;
  23. };
  24. public:
  25. explicit MainWindow(LegacyApp *app = 0, QWidget *parent = 0);
  26. void Init();
  27. void changeFontSizeRecursive(size_t percent, QWidget* widget);
  28. ~MainWindow();
  29. protected:
  30. void mouseMoveEvent(QMouseEvent *event) override;
  31. void mousePressEvent(QMouseEvent *event) override;
  32. void resizeEvent(QResizeEvent *event) override;
  33. private slots:
  34. void randomChangeBackground();
  35. void on_menuentry_1_common_clicked();
  36. void on_menuentry_2_common_clicked();
  37. void on_menuentry_3_common_clicked();
  38. void on_menuentry_4_common_clicked();
  39. void on_menuentry_5_common_clicked();
  40. void onHoverMenuentry();
  41. void on_closeButton_clicked();
  42. void on_minimizeButton_clicked();
  43. private:
  44. void setupWindowBackgroundAndMask();
  45. void setupMenuHoverWidget();
  46. void moveMenuHoverWidget(MenuEntry* target);
  47. void checkMenuIsHovered();
  48. void hideAllContentWidgets();
  49. private:
  50. LegacyApp *app;
  51. Ui::MainWindow *ui;
  52. QWidget* menuHoverWidget;
  53. QPropertyAnimation* menuHoverWidgetAnimation;
  54. QPropertyAnimation* menuHoverWidgetScaleAnimation;
  55. QTimer menu_hover_checker_timer;
  56. QPoint dragPosition;
  57. StatusWidget *status_frame;
  58. RusificationWidget *rusification_frame;
  59. SettingsWidget *settings_frame;
  60. NewsWidget *news_frame;
  61. HelpWidget *help_frame;
  62. QPixmap *background;
  63. QPixmap *next_pixmap {nullptr};
  64. QPixmap current_bg;
  65. QBitmap current_mask;
  66. QTimer background_update_timer;
  67. QTimer fade_animation_timer;
  68. double next_pixmap_opacity;
  69. const int MAX_PIXMAP_ID = 9;
  70. const size_t common_font_size = 15;
  71. const size_t title_font_size = 17;
  72. const size_t supertitle_font_size = 32;
  73. const size_t bigbutton_font_size = 22;
  74. };
  75. #endif // MAINWINDOW_H