Changeset View
Changeset View
Standalone View
Standalone View
testclient/widgets/sdwidget.cpp
- This file was added.
1 | /* AtCore Test Client | ||||
---|---|---|---|---|---|
2 | Copyright (C) <2018> | ||||
3 | Author: Chris Rizzitello - rizzitello@kde.org | ||||
4 | | ||||
5 | This program is free software: you can redistribute it and/or modify | ||||
6 | it under the terms of the GNU General Public License as published by | ||||
7 | the Free Software Foundation, either version 3 of the License, or | ||||
8 | (at your option) any later version. | ||||
9 | | ||||
10 | This program is distributed in the hope that it will be useful, | ||||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
13 | GNU General Public License for more details. | ||||
14 | | ||||
15 | You should have received a copy of the GNU General Public License | ||||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||||
17 | */ | ||||
18 | #include <QGroupBox> | ||||
19 | #include <QHBoxLayout> | ||||
20 | #include <QPushButton> | ||||
21 | #include <QVBoxLayout> | ||||
22 | | ||||
23 | #include "sdwidget.h" | ||||
24 | | ||||
25 | SdWidget::SdWidget(QWidget *parent) : | ||||
26 | QWidget(parent) | ||||
27 | { | ||||
28 | auto hBoxLayout = new QHBoxLayout; | ||||
29 | | ||||
30 | auto newButton = new QPushButton(tr("Get List")); | ||||
31 | hBoxLayout->addWidget(newButton); | ||||
32 | connect(newButton, &QPushButton::clicked, [this] { | ||||
33 | emit(requestSdList()); | ||||
34 | }); | ||||
35 | | ||||
36 | newButton = new QPushButton(tr("Print Selected")); | ||||
37 | hBoxLayout->addWidget(newButton); | ||||
38 | connect(newButton, &QPushButton::clicked, [this] { | ||||
39 | emit(printSdFile(listSdFiles->currentItem()->text())); | ||||
40 | }); | ||||
41 | | ||||
42 | newButton = new QPushButton(tr("Delete Selected")); | ||||
43 | hBoxLayout->addWidget(newButton); | ||||
44 | connect(newButton, &QPushButton::clicked, [this] { | ||||
45 | emit(deleteSdFile(listSdFiles->currentItem()->text())); | ||||
46 | listSdFiles->setCurrentRow(-1); | ||||
47 | }); | ||||
48 | | ||||
49 | auto groupFiles = new QGroupBox(tr("Files On Sd Card")); | ||||
50 | listSdFiles = new QListWidget; | ||||
51 | auto groupLayout = new QVBoxLayout; | ||||
52 | groupLayout->addWidget(listSdFiles); | ||||
53 | groupFiles->setLayout(groupLayout); | ||||
54 | | ||||
55 | auto mainLayout = new QVBoxLayout; | ||||
56 | mainLayout->addItem(hBoxLayout); | ||||
57 | mainLayout->addWidget(groupFiles); | ||||
58 | | ||||
59 | setLayout(mainLayout); | ||||
60 | } | ||||
61 | | ||||
62 | void SdWidget::updateFilelist(const QStringList &fileList) | ||||
63 | { | ||||
64 | listSdFiles->clear(); | ||||
65 | listSdFiles->addItems(fileList); | ||||
66 | } |