numlockmanager/numlockmanager.h

70 lines
2.4 KiB
C
Raw Normal View History

2023-09-01 14:13:41 +00:00
#ifndef NUMLOCKMANAGER_H
#define NUMLOCKMANAGER_H
#include <QMainWindow>
#include <QSystemTrayIcon>
#include <QMenu>
#include <QAction>
#include <QSettings>
#include <QThread>
#include <QDir>
#include <QCloseEvent>
#include "statusshow.h"
#include "modethread.h"
#include "config.h"
#include "ui_numlockmanager.h"
#include "autostart.h"
QT_BEGIN_NAMESPACE
namespace Ui { class NumLockManager; }
QT_END_NAMESPACE
class NumLockManager : public QMainWindow
{
Q_OBJECT
public:
NumLockManager(QWidget *parent = nullptr);
~NumLockManager() { delete ui; }
private:
Ui::NumLockManager *ui;
StatusShow * ss = new StatusShow();
ModeThread * mode = new ModeThread();
Config config;
Autostart * autostart = new Autostart();
QSystemTrayIcon * tray_icon = new QSystemTrayIcon(this);
QIcon tray_icon_off = QIcon(QCoreApplication::applicationDirPath() + "/src/icons/num_lock_icon_off.png");
QIcon tray_icon_on = QIcon(QCoreApplication::applicationDirPath() + "/src/icons/num_lock_icon_on.png");
QIcon icon_check_false = QIcon(QCoreApplication::applicationDirPath() + "/src/icons/check_radio_c_0.png");
QIcon icon_check_true = QIcon(QCoreApplication::applicationDirPath() + "/src/icons/check_radio_c_1.png");
QIcon icon_radio_false = QIcon(QCoreApplication::applicationDirPath() + "/src/icons/check_radio_r_0.png");
QIcon icon_radio_true = QIcon(QCoreApplication::applicationDirPath() + "/src/icons/check_radio_r_1.png");
QMenu * menu = new QMenu();
QAction * action_autostart = new QAction();
QAction * action_mode_0 = new QAction();
QAction * action_mode_1 = new QAction();
QAction * action_mode_2 = new QAction();
QAction * action_about = new QAction();
QAction * action_exit = new QAction();
QAction * actions[6] = {action_autostart, action_mode_0, action_mode_1, action_mode_2, action_about ,action_exit};
QAction * actions_mode[3] = {action_mode_0, action_mode_1, action_mode_2};
void set_mode(int index);
public slots:
void icon_activated(QSystemTrayIcon::ActivationReason reason) {Q_UNUSED(reason); menu->exec(QCursor::pos()); }
void getStatus(bool status);
void set_menu_hz(QAction * action);
protected:
void closeEvent(QCloseEvent *event) override{ event->ignore(); hide(); }
};
#endif // NUMLOCKMANAGER_H