diff --git a/src/dialogs/CMakeLists.txt b/src/dialogs/CMakeLists.txt index 43441c3..060a3f7 100644 --- a/src/dialogs/CMakeLists.txt +++ b/src/dialogs/CMakeLists.txt @@ -1,6 +1,7 @@ set(dialogs_SRCS profilesdialog.cpp connectsettingsdialog.cpp + choosefiledialog.cpp ) add_library(AtelierDialogs STATIC ${dialogs_SRCS}) target_link_libraries(AtelierDialogs Qt5::Widgets Qt5::SerialPort KF5::Solid KF5::I18n) diff --git a/src/dialogs/choosefiledialog.cpp b/src/dialogs/choosefiledialog.cpp new file mode 100644 index 0000000..44ba64d --- /dev/null +++ b/src/dialogs/choosefiledialog.cpp @@ -0,0 +1,56 @@ +/* Atelier KDE Printer Host for 3D Printing + Copyright (C) <2017> + Author: Lays Rodrigues - laysrodriguessilva@gmail.com + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ +#include "choosefiledialog.h" +#include +#include +#include +#include +#include + +ChooseFileDialog::ChooseFileDialog(QWidget *parent, QList files) : + QDialog(parent) +{ + auto layout = new QVBoxLayout; + auto label = new QLabel(i18n("Choose a file to print: ")); + auto listWigdet = new QListWidget(); + QStringList files_list; + foreach(auto &file, files){ + files_list.append(file.toLocalFile()); + } + listWigdet->addItems(files_list); + connect(listWigdet, &QListWidget::currentTextChanged, [=](QString t){ + m_choosen_file = t; + }); + auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); + connect(buttonBox, &QDialogButtonBox::accepted, this, &ChooseFileDialog::accept); + connect(buttonBox, &QDialogButtonBox::rejected, this, &ChooseFileDialog::reject); + layout->addWidget(label); + layout->addWidget(listWigdet); + layout->addWidget(buttonBox); + setLayout(layout); +} + +ChooseFileDialog::~ChooseFileDialog() +{ +} + +const QString& ChooseFileDialog::choosenFile() +{ + return m_choosen_file; +} + diff --git a/src/dialogs/choosefiledialog.h b/src/dialogs/choosefiledialog.h new file mode 100644 index 0000000..814b00f --- /dev/null +++ b/src/dialogs/choosefiledialog.h @@ -0,0 +1,36 @@ +/* Atelier KDE Printer Host for 3D Printing + Copyright (C) <2017> + Author: Lays Rodrigues - laysrodriguessilva@gmail.com + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ +#pragma once + +#include +#include +#include + +/** + * @todo write docs + */ +class ChooseFileDialog : public QDialog +{ + Q_OBJECT +public: + ChooseFileDialog(QWidget *parent=nullptr, QList files = QList()); + ~ChooseFileDialog(); + const QString& choosenFile(); +private: + QString m_choosen_file; +};