numlockmanager.h 2.3 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. #define MY_APP_NAME "NumLockManager"
  16. #define MY_APP_PATH QDir::toNativeSeparators(QCoreApplication::applicationFilePath())
  17. QT_BEGIN_NAMESPACE
  18. namespace Ui { class NumLockManager; }
  19. QT_END_NAMESPACE
  20. class NumLockManager : public QMainWindow
  21. {
  22. Q_OBJECT
  23. public:
  24. NumLockManager(QWidget *parent = nullptr);
  25. ~NumLockManager() { delete ui; }
  26. private:
  27. Ui::NumLockManager *ui;
  28. StatusShow * ss = new StatusShow();
  29. ModeThread * mode = new ModeThread();
  30. Config config;
  31. QSettings * settings = new QSettings("HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", QSettings::NativeFormat);
  32. QSystemTrayIcon * tray_icon = new QSystemTrayIcon(this);
  33. QIcon tray_icon_off = QIcon("src/icons/num_lock_icon_off.png");
  34. QIcon tray_icon_on = QIcon("src/icons/num_lock_icon_on.png");
  35. QIcon icon_check_false = QIcon("src/icons/check_radio_c_0.png");
  36. QIcon icon_check_true = QIcon("src/icons/check_radio_c_1.png");
  37. QIcon icon_radio_false = QIcon("src/icons/check_radio_r_0.png");
  38. QIcon icon_radio_true = QIcon("src/icons/check_radio_r_1.png");
  39. QMenu * menu = new QMenu();
  40. QAction * action_autostart = new QAction();
  41. QAction * action_mode_0 = new QAction();
  42. QAction * action_mode_1 = new QAction();
  43. QAction * action_mode_2 = new QAction();
  44. QAction * action_about = new QAction();
  45. QAction * action_exit = new QAction();
  46. QAction * actions[6] = {action_autostart, action_mode_0, action_mode_1, action_mode_2, action_about ,action_exit};
  47. QAction * actions_mode[3] = {action_mode_0, action_mode_1, action_mode_2};
  48. void set_mode(int index);
  49. public slots:
  50. void icon_activated(QSystemTrayIcon::ActivationReason reason) {Q_UNUSED(reason); menu->exec(QCursor::pos()); }
  51. void getStatus(bool status);
  52. void set_menu_hz(QAction * action);
  53. protected:
  54. void closeEvent(QCloseEvent *event) override{ event->ignore(); hide(); }
  55. };
  56. #endif // NUMLOCKMANAGER_H