-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmainwindow.cpp
96 lines (73 loc) · 1.99 KB
/
mainwindow.cpp
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
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "veniceservice.h"
#include <memory>
#include <QFileDialog>
#include <iostream>
#include <QtCore/qtimer.h>
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
{
ui->setupUi(this);
}
MainWindow::~MainWindow()
{
delete ui;
if(veniceService != nullptr)
{
delete veniceService;
}
}
void MainWindow::setMainApplication(QApplication *application)
{
this->mainApplication = application;
}
void MainWindow::on_sendFileButton_clicked()
{
QString filePath= ui->selectedSendFileLineEdit->text();
if(!filePath.isEmpty())
{
veniceService = new VeniceService(this, filePath.toStdString());
//We associated the signal aboutToQuit with a lamba function that stop the service as slot
this->connect(this->mainApplication, &QApplication::aboutToQuit, veniceService, [=]{
veniceService->quit();
veniceService->wait(5000);});
veniceService->start();
ui->sendFileButton->setEnabled(false);
}
}
void MainWindow::doPopup()
{
}
void MainWindow::on_browseSendFileButton_clicked()
{
QString fileName = QFileDialog::getOpenFileName(this,
tr("Open File"), QDir::homePath(), tr(""));
if(!fileName.isEmpty())
{
ui->selectedSendFileLineEdit->setText(fileName);
ui->sendFileButton->setEnabled(true);
}
}
void MainWindow::on_receiveFileButton_clicked()
{
}
void MainWindow::on_bleSendRadioButton_clicked()
{
if(ui->bleSendRadioButton->isChecked())
ui->wifiSendRadioButton->setEnabled(true);
else
{
ui->wifiSendRadioButton->setEnabled(false);
ui->wifiSendRadioButton->setChecked(false);
ui->browseSendFileButton->setEnabled(false);
}
}
void MainWindow::on_wifiSendRadioButton_clicked()
{
if(ui->wifiSendRadioButton->isChecked())
ui->browseSendFileButton->setEnabled(true);
else
ui->browseSendFileButton->setEnabled(false);
}