xwhatsit util: fix some scaling issues
[jackhill/qmk/firmware.git] / keyboards / xwhatsit / util / util / signal_level.h
1 #ifndef SIGNALLEVELMONITORWINDOW_H
2 #define SIGNALLEVELMONITORWINDOW_H
3
4 #include <QDialog>
5 #include <QGraphicsScene>
6 #include <QJsonDocument>
7 #include "hidthread.h"
8
9 namespace Ui {
10 class SignalLevelMonitorWindow;
11 }
12
13 class SignalLevelMonitorWindow : public QDialog
14 {
15 Q_OBJECT
16
17 public:
18 explicit SignalLevelMonitorWindow(HidThread &thread, QWidget *parent = nullptr);
19 ~SignalLevelMonitorWindow();
20 void loadLayout(QString name);
21
22 protected:
23 void paintEvent(QPaintEvent *event);
24
25 private slots:
26 void on_layoutSel_activated(const QString &arg1);
27 void on_keyboardName(std::string name);
28 void on_signallevel(std::vector<uint16_t>);
29 void on_reportMonitorError(std::string error_message);
30
31 void on_SignalLevelMonitorWindow_finished(int result);
32 void ShowContextMenu(const QPoint &pos);
33
34 private:
35 Ui::SignalLevelMonitorWindow *ui;
36 QGraphicsScene scene;
37 QJsonDocument doc;
38 const struct kbd_def *keyboard;
39 const struct lay_def *current_layout;
40 HidThread &thread;
41 std::vector<std::vector<uint16_t>> signal_level;
42 std::vector<std::vector<uint16_t>> min_signal_level;
43 std::vector<std::vector<uint16_t>> max_signal_level;
44 QColor getColor(uint16_t value, uint16_t mins, uint16_t maxs);
45 void displaySquare(int x, int y, int w, int h, unsigned int col, unsigned int row, uint16_t mins, uint16_t maxs, QPainter &painter);
46 void updateCurrentLayout();
47 void setMinimumSizeUnits(unsigned int width_units_times_8, unsigned int height_units_times_8);
48
49 unsigned int keyboard_width_uis_times_8;
50 unsigned int keyboard_height_uis_times_8;
51 static constexpr double MIN_HORIZONTAL_SCALE = 32;
52 static constexpr double MIN_VERTICAL_SCALE = 42;
53 static const int HORIZONTAL_MARGIN = 10;
54 static const int VERTICAL_MARGIN = 10;
55 };
56
57 #endif // SIGNALLEVELMONITORWINDOW_H