summaryrefslogtreecommitdiff
path: root/metawatch/metawatchdigitalsimulatorform.cpp
blob: 04d6482866da0e4a1fc0966267d1168192e40d9a (plain)
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
#include <QtCore/QDebug>
#include <QtGui/QFileDialog>

#include "metawatchdigitalsimulatorform.h"
#include "ui_metawatchdigitalsimulatorform.h"

using namespace sowatch;

MetaWatchDigitalSimulatorForm::MetaWatchDigitalSimulatorForm(QWidget* parent) :
    QMainWindow(parent),
    ui(new Ui::MetaWatchDigitalSimulatorForm)
{
    ui->setupUi(this);
}

MetaWatchDigitalSimulatorForm::~MetaWatchDigitalSimulatorForm()
{
    delete ui;
}

void MetaWatchDigitalSimulatorForm::refreshScreen(const QPixmap& pixmap)
{
	ui->lblDisplay->setPixmap(pixmap);
	ui->lblDisplay->update();
}

void MetaWatchDigitalSimulatorForm::btnAPressed()
{
	emit buttonPressed(0);
}

void MetaWatchDigitalSimulatorForm::btnAReleased()
{
	emit buttonReleased(0);
}

void MetaWatchDigitalSimulatorForm::btnBPressed()
{
	emit buttonPressed(1);
}

void MetaWatchDigitalSimulatorForm::btnBReleased()
{
	emit buttonReleased(1);
}

void MetaWatchDigitalSimulatorForm::btnCPressed()
{
	emit buttonPressed(2);
}

void MetaWatchDigitalSimulatorForm::btnCReleased()
{
	emit buttonReleased(2);
}

void MetaWatchDigitalSimulatorForm::btnDPressed()
{
	emit buttonPressed(3);
}

void MetaWatchDigitalSimulatorForm::btnDReleased()
{
	emit buttonReleased(3);
}

void MetaWatchDigitalSimulatorForm::btnEPressed()
{
	emit buttonPressed(4);
}

void MetaWatchDigitalSimulatorForm::btnEReleased()
{
	emit buttonReleased(4);
}

void MetaWatchDigitalSimulatorForm::btnFPressed()
{
	emit buttonPressed(5);
}

void MetaWatchDigitalSimulatorForm::btnFReleased()
{
	emit buttonReleased(5);
}

void MetaWatchDigitalSimulatorForm::on_actionCaptureScreen_triggered()
{
	QString fileName = QFileDialog::getSaveFileName(this, tr("Save capture"), QString(), tr("Images (*.png)"));
	if (fileName.isEmpty()) {
		return;
	}
	if (!fileName.endsWith(".png")) {
		fileName.append(".png");
	}
	qDebug() << "Saving to" << fileName;
	ui->lblDisplay->pixmap()->save(fileName, "PNG");
}

void MetaWatchDigitalSimulatorForm::on_actionQuit_triggered()
{
    QApplication::quit();
}