-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmainwindow.cpp
More file actions
122 lines (104 loc) · 4.5 KB
/
Copy pathmainwindow.cpp
File metadata and controls
122 lines (104 loc) · 4.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
// Copyright (C) 2023 Jeremy Nieth
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "updater.h"
#include "weatherprovider.h"
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
{
ui->setupUi(this);
clockUpdate();
setStyle(QStyleFactory::create("Fusion"));
setAttribute(Qt::WA_AcceptTouchEvents);
clockTimer = new QTimer(this);
clockTimer->setInterval(1000);
clockTimer->start();
connect(clockTimer, SIGNAL(timeout()), this, SLOT(clockUpdate()));
hourlyTimer = new QTimer(this);
hourlyTimer->setInterval(3600000);
hourlyTimer->start();
connect(hourlyTimer, SIGNAL(timeout()), this, SLOT(eink_full_update()));
epdControl = new EPDControl(this);
connect(epdControl, SIGNAL(brightnessChanged(int)), ui->progressBar, SLOT(setValue(int)));
connect(ui->btnBLightMinus, SIGNAL(pressed()), epdControl, SLOT(decBrightness()));
connect(ui->btnBLightPlus, SIGNAL(pressed()), epdControl, SLOT(incBrightness()));
connect(ui->btnBLightToggle, SIGNAL(pressed()), epdControl, SLOT(toggleBacklight()));
ui->label_6->setAttribute(Qt::WA_TranslucentBackground);
prov = new WeatherProvider();
connect(prov, SIGNAL(weatherReady()), this, SLOT(weatherUpdate()));
}
void MainWindow::paintEvent(QPaintEvent *e)
{
static int i = 0;
qDebug("paintEvent no %d at rect %dx%d, %dx%d", i++, e->rect().topLeft().x(), e->rect().topLeft().y(), e->rect().width(), e->rect().height());
epdControl->queueScreenUpdate(e->rect());
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::clockUpdate()
{
QDateTime time = QDateTime::currentDateTime();
ui->lblClock->setText(time.toString("HH"));
ui->lblClock_2->setText(time.toString("mm"));
ui->lblDate->setText(time.toString("dddd, dd.MM.yyyy"));
}
void MainWindow::weatherUpdate()
{
ui->label_6->setPixmap(prov->getWeatherCurrent().curIcon);
ui->label_7->setText(prov->getWeatherCurrent().curTemp + " °C\n" + prov->getWeatherCurrent().curWeather);
ui->label_8->setText("˄ " + prov->getWeatherCurrent().curHigh + "°C\n˅ " + prov->getWeatherCurrent().curLow + "°C");
}
void MainWindow::on_pushButton_pressed()
{
ui->stackedWidget->setCurrentIndex(0);
ui->pushButton->setStyleSheet("QPushButton {border-width: 14px;}");
ui->pushButton_2->setStyleSheet("QPushButton {border-width: 7px;}");
ui->pushButton_3->setStyleSheet("QPushButton {border-width: 7px;}");
ui->pushButton_4->setStyleSheet("QPushButton {border-width: 7px;}");
ui->pushButton_5->setStyleSheet("QPushButton {border-width: 7px;}");
}
void MainWindow::on_pushButton_2_pressed()
{
ui->stackedWidget->setCurrentIndex(1);
ui->pushButton->setStyleSheet("QPushButton {border-width: 7px;}");
ui->pushButton_2->setStyleSheet("QPushButton {border-width: 14px;}");
ui->pushButton_3->setStyleSheet("QPushButton {border-width: 7px;}");
ui->pushButton_4->setStyleSheet("QPushButton {border-width: 7px;}");
ui->pushButton_5->setStyleSheet("QPushButton {border-width: 7px;}");
}
void MainWindow::on_pushButton_3_pressed()
{
ui->stackedWidget->setCurrentIndex(2);
ui->pushButton->setStyleSheet("QPushButton {border-width: 7px;}");
ui->pushButton_2->setStyleSheet("QPushButton {border-width: 7px;}");
ui->pushButton_3->setStyleSheet("QPushButton {border-width: 14px;}");
ui->pushButton_4->setStyleSheet("QPushButton {border-width: 7px;}");
ui->pushButton_5->setStyleSheet("QPushButton {border-width: 7px;}");
}
void MainWindow::on_pushButton_4_pressed()
{
ui->stackedWidget->setCurrentIndex(3);
ui->pushButton->setStyleSheet("QPushButton {border-width: 7px;}");
ui->pushButton_2->setStyleSheet("QPushButton {border-width: 7px;}");
ui->pushButton_3->setStyleSheet("QPushButton {border-width: 7px;}");
ui->pushButton_4->setStyleSheet("QPushButton {border-width: 14px;}");
ui->pushButton_5->setStyleSheet("QPushButton {border-width: 7px;}");
}
void MainWindow::on_pushButton_5_pressed()
{
ui->stackedWidget->setCurrentIndex(4);
ui->pushButton->setStyleSheet("QPushButton {border-width: 7px;}");
ui->pushButton_2->setStyleSheet("QPushButton {border-width: 7px;}");
ui->pushButton_3->setStyleSheet("QPushButton {border-width: 7px;}");
ui->pushButton_4->setStyleSheet("QPushButton {border-width: 7px;}");
ui->pushButton_5->setStyleSheet("QPushButton {border-width: 14px;}");
}
void MainWindow::on_pushButton_6_pressed()
{
Updater *updater = new Updater(this);
updater->move(50, 100);
updater->show();
}