1 /**
2  * Copyright (C) Francesco Fusco. All rights reserved.
3  * License: https://github.com/Fushko/gammy#license
4  */
5 
6 #ifndef MAINWINDOW_H
7 #define MAINWINDOW_H
8 
9 #include <QHelpEvent>
10 #include <QMainWindow>
11 #include <QSystemTrayIcon>
12 #include <QAbstractSlider>
13 
14 #include "component.h"
15 #include "mediator.h"
16 
17 namespace Ui {
18 class MainWindow;
19 }
20 
21 class MainWindow : public QMainWindow, public Component
22 {
23 	Q_OBJECT
24 
25 public:
26 	explicit MainWindow();
27 	~MainWindow();
28 
29 	bool prev_gamma = false;
30 	void init();
31 	void setTempSlider(int);
32 	void setBrtSlider(int);
33 	void setPollingRange(int, int);
34 	void shutdown();
35 
36 private slots:
37 	void trayIconActivated(QSystemTrayIcon::ActivationReason reason);
38 
39 	void on_brtSlider_actionTriggered(int action);
40 	void on_tempSlider_actionTriggered(int action);
41 
42 	void on_brtSlider_valueChanged(int val);
43 	void on_tempSlider_valueChanged(int val);
44 
45 	void on_brRange_lowerValueChanged(int val);
46 	void on_brRange_upperValueChanged(int val);
47 	void on_offsetSlider_valueChanged(int val);
48 	void on_speedSlider_valueChanged(int val);
49 
50 	void on_thresholdSlider_valueChanged(int val);
51 	void on_pollingSlider_valueChanged(int val);
52 	void on_extendBr_clicked(bool checked);
53 	void on_autoBrtCheck_toggled(bool checked);
54 	void on_autoTempCheck_toggled(bool checked);
55 	void on_pushButton_clicked();
56 
57 	void on_advBrSettingsBtn_toggled(bool checked);
58 	void wakeupSlot(bool);
59 private:
60 	Ui::MainWindow  *ui;
61 	QSystemTrayIcon *tray_icon;
62 	QMenu *createTrayMenu();
63 
64 	bool listenWakeupSignal();
65 	void setWindowProperties(QIcon &icon);
66 	void setLabels();
67 	void setSliders();
68 	void toggleBrtSliders(bool show);
69 	void toggleBrtSlidersRange(bool);
70 	void updateBrtLabel(int);
71 	void updateTempLabel(int);
72 	void closeEvent(QCloseEvent *);
73 	void setPos();
74 	void savePos();
75 	void restoreDefaultBrt();
76 	void restoreDefaultTemp();
77 
78 	void createTrayIcon(QIcon &icon);
79 	void checkTray();
80 	bool systray_available = false;
81 
82 	QAction *tray_wnd_toggle;
83 	const QString show_txt = "Show Gammy";
84 	const QString hide_txt = "Hide Gammy";
85 
86 	QAction *tray_brt_toggle;
87 	QAction *tray_temp_toggle;
88 
89 	// Height values
90 	const int wnd_h_min                 = 170;
91 	const int wnd_h_min_auto_brt_on     = 282;
92 	const int c_wdgt_h_max              = 170;
93 	const int c_wdgt_h_max_auto_brt_on  = 445;
94 };
95 
96 #endif // MAINWINDOW_H
97