numlockmanager.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #ifndef NUMLOCKMANAGER_H
  2. #define NUMLOCKMANAGER_H
  3. #include <QMainWindow>
  4. #include <QSystemTrayIcon>
  5. #include <QMenu>
  6. #include <QAction>
  7. #include <QSettings>
  8. #include <QThread>
  9. #include <QDir>
  10. #include <QCloseEvent>
  11. #include "statusshow.h"
  12. #include "modethread.h"
  13. #include "config.h"
  14. #include "ui_numlockmanager.h"
  15. #include "autostart.h"
  16. QT_BEGIN_NAMESPACE
  17. namespace Ui { class NumLockManager; }
  18. QT_END_NAMESPACE
  19. class NumLockManager : public QMainWindow
  20. {
  21. Q_OBJECT
  22. public:
  23. NumLockManager(QWidget *parent = nullptr);
  24. ~NumLockManager() { delete ui; }
  25. private:
  26. Ui::NumLockManager *ui;
  27. StatusShow * ss = new StatusShow();
  28. ModeThread * mode = new ModeThread();
  29. Config config;
  30. Autostart * autostart = new Autostart();
  31. QSystemTrayIcon * tray_icon = new QSystemTrayIcon(this);
  32. QIcon tray_icon_off = QIcon(QCoreApplication::applicationDirPath() + "/src/icons/num_lock_icon_off.png");
  33. QIcon tray_icon_on = QIcon(QCoreApplication::applicationDirPath() + "/src/icons/num_lock_icon_on.png");
  34. QIcon icon_check_false = QIcon(QCoreApplication::applicationDirPath() + "/src/icons/check_radio_c_0.png");
  35. QIcon icon_check_true = QIcon(QCoreApplication::applicationDirPath() + "/src/icons/check_radio_c_1.png");
  36. QIcon icon_radio_false = QIcon(QCoreApplication::applicationDirPath() + "/src/icons/check_radio_r_0.png");
  37. QIcon icon_radio_true = QIcon(QCoreApplication::applicationDirPath() + "/src/icons/check_radio_r_1.png");
  38. QMenu * menu = new QMenu();
  39. QAction * action_autostart = new QAction();
  40. QAction * action_mode_0 = new QAction();
  41. QAction * action_mode_1 = new QAction();
  42. QAction * action_mode_2 = new QAction();
  43. QAction * action_about = new QAction();
  44. QAction * action_exit = new QAction();
  45. QAction * actions[6] = {action_autostart, action_mode_0, action_mode_1, action_mode_2, action_about ,action_exit};
  46. QAction * actions_mode[3] = {action_mode_0, action_mode_1, action_mode_2};
  47. void set_mode(int index);
  48. public slots:
  49. void icon_activated(QSystemTrayIcon::ActivationReason reason) {Q_UNUSED(reason); menu->exec(QCursor::pos()); }
  50. void getStatus(bool status);
  51. void set_menu_hz(QAction * action);
  52. protected:
  53. void closeEvent(QCloseEvent *event) override{ event->ignore(); hide(); }
  54. };
  55. #endif // NUMLOCKMANAGER_H