diff --git a/src/dialogs/choosefiledialog.cpp b/src/dialogs/choosefiledialog.cpp index 13534fa..4bf7151 100644 --- a/src/dialogs/choosefiledialog.cpp +++ b/src/dialogs/choosefiledialog.cpp @@ -1,53 +1,53 @@ /* Atelier KDE Printer Host for 3D Printing Copyright (C) <2017> Author: Lays Rodrigues - laysrodriguessilva@gmail.com - + Chris Rizzitello - rizzitello@kde.org 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(); const int padding = 30; listWigdet->setMinimumWidth(fontMetrics().height()/2 * padding); QStringList files_list; foreach(const auto &file, files){ files_list.append(file.toLocalFile()); } listWigdet->addItems(files_list); - connect(listWigdet, &QListWidget::currentTextChanged, [ this ](const QString& t){ - m_choosen_file = t; + connect(listWigdet, &QListWidget::currentRowChanged, [ this, &files ](const int t){ + m_choosen_file = files.at(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); } -const QString& ChooseFileDialog::choosenFile() +const QUrl ChooseFileDialog::choosenFile() { return m_choosen_file; } diff --git a/src/dialogs/choosefiledialog.h b/src/dialogs/choosefiledialog.h index 592ad6a..0a0d7e4 100644 --- a/src/dialogs/choosefiledialog.h +++ b/src/dialogs/choosefiledialog.h @@ -1,33 +1,34 @@ /* Atelier KDE Printer Host for 3D Printing Copyright (C) <2017> Author: Lays Rodrigues - laysrodriguessilva@gmail.com + Chris Rizzitello - rizzitello@kde.org 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 class ChooseFileDialog : public QDialog { Q_OBJECT public: ChooseFileDialog(QWidget *parent=nullptr, QList files = QList()); virtual ~ChooseFileDialog() {} - const QString& choosenFile(); + const QUrl choosenFile(); private: - QString m_choosen_file; + QUrl m_choosen_file; };