Changeset View
Changeset View
Standalone View
Standalone View
src/widgets/sdwidget.cpp
Show All 9 Lines | 1 | /* AtCore Test Client | |||
---|---|---|---|---|---|
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. | ||
14 | 14 | | |||
15 | You should have received a copy of the GNU General Public License | 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/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | */ | 17 | */ | ||
18 | #include <QFileDialog> | ||||
18 | #include <QGroupBox> | 19 | #include <QGroupBox> | ||
19 | #include <QHBoxLayout> | 20 | #include <QHBoxLayout> | ||
20 | #include <QPushButton> | 21 | #include <QPushButton> | ||
21 | #include <QVBoxLayout> | 22 | #include <QVBoxLayout> | ||
22 | 23 | | |||
23 | #include "sdwidget.h" | 24 | #include "sdwidget.h" | ||
24 | 25 | | |||
25 | SdWidget::SdWidget(QWidget *parent) : | 26 | SdWidget::SdWidget(QWidget *parent) : | ||
Show All 11 Lines | 28 | { | |||
37 | hBoxLayout->addWidget(newButton); | 38 | hBoxLayout->addWidget(newButton); | ||
38 | connect(newButton, &QPushButton::clicked, this, [this] { | 39 | connect(newButton, &QPushButton::clicked, this, [this] { | ||
39 | if (listSdFiles->currentRow() != -1) | 40 | if (listSdFiles->currentRow() != -1) | ||
40 | { | 41 | { | ||
41 | emit printSdFile(listSdFiles->currentItem()->text()); | 42 | emit printSdFile(listSdFiles->currentItem()->text()); | ||
42 | } | 43 | } | ||
43 | }); | 44 | }); | ||
44 | 45 | | |||
46 | newButton = new QPushButton(tr("Send File")); | ||||
47 | hBoxLayout->addWidget(newButton); | ||||
48 | connect(newButton, &QPushButton::clicked, this, [this] { | ||||
49 | static QString filter = tr("GCode Files(*.gco *.gcode)"); | ||||
50 | QString fileName = QFileDialog::getOpenFileName( | ||||
51 | this | ||||
52 | , tr("Write file to SD") | ||||
53 | , QDir::homePath() | ||||
54 | , tr("All Files(*.*);;GCode Files(*.gco *.gcode)") | ||||
55 | , &filter | ||||
56 | ); | ||||
57 | if (!fileName.isEmpty() && QFileInfo(fileName).isReadable()) | ||||
58 | { | ||||
59 | emit writeSdFile(fileName); | ||||
60 | } | ||||
61 | }); | ||||
62 | | ||||
45 | newButton = new QPushButton(tr("Delete Selected")); | 63 | newButton = new QPushButton(tr("Delete Selected")); | ||
46 | hBoxLayout->addWidget(newButton); | 64 | hBoxLayout->addWidget(newButton); | ||
47 | connect(newButton, &QPushButton::clicked, this, [this] { | 65 | connect(newButton, &QPushButton::clicked, this, [this] { | ||
48 | if (listSdFiles->currentRow() != -1) | 66 | if (listSdFiles->currentRow() != -1) | ||
49 | { | 67 | { | ||
50 | emit deleteSdFile(listSdFiles->currentItem()->text()); | 68 | emit deleteSdFile(listSdFiles->currentItem()->text()); | ||
51 | listSdFiles->setCurrentRow(-1); | 69 | listSdFiles->setCurrentRow(-1); | ||
52 | } | 70 | } | ||
Show All 20 Lines |