mainwindow.h 2.1 KB

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