Changeset View
Changeset View
Standalone View
Standalone View
src/dialogs/choosefiledialog.cpp
1 | /* Atelier KDE Printer Host for 3D Printing | 1 | /* Atelier KDE Printer Host for 3D Printing | ||
---|---|---|---|---|---|
2 | Copyright (C) <2017> | 2 | Copyright (C) <2017> | ||
3 | Author: Lays Rodrigues - laysrodriguessilva@gmail.com | 3 | Author: Lays Rodrigues - laysrodriguessilva@gmail.com | ||
4 | 4 | Chris Rizzitello - rizzitello@kde.org | |||
5 | This program is free software: you can redistribute it and/or modify | 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 | 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 | 7 | the Free Software Foundation, either version 3 of the License, or | ||
8 | (at your option) any later version. | 8 | (at your option) any later version. | ||
9 | 9 | | |||
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 | ||
Show All 17 Lines | 27 | { | |||
30 | auto listWigdet = new QListWidget(); | 30 | auto listWigdet = new QListWidget(); | ||
31 | const int padding = 30; | 31 | const int padding = 30; | ||
32 | listWigdet->setMinimumWidth(fontMetrics().height()/2 * padding); | 32 | listWigdet->setMinimumWidth(fontMetrics().height()/2 * padding); | ||
33 | QStringList files_list; | 33 | QStringList files_list; | ||
34 | foreach(const auto &file, files){ | 34 | foreach(const auto &file, files){ | ||
35 | files_list.append(file.toLocalFile()); | 35 | files_list.append(file.toLocalFile()); | ||
36 | } | 36 | } | ||
37 | listWigdet->addItems(files_list); | 37 | listWigdet->addItems(files_list); | ||
38 | connect(listWigdet, &QListWidget::currentTextChanged, [ this ](const QString& t){ | 38 | connect(listWigdet, &QListWidget::currentRowChanged, [ this, &files ](const int t){ | ||
39 | m_choosen_file = t; | 39 | m_choosen_file = files.at(t); | ||
40 | }); | 40 | }); | ||
41 | auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); | 41 | auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); | ||
42 | connect(buttonBox, &QDialogButtonBox::accepted, this, &ChooseFileDialog::accept); | 42 | connect(buttonBox, &QDialogButtonBox::accepted, this, &ChooseFileDialog::accept); | ||
43 | connect(buttonBox, &QDialogButtonBox::rejected, this, &ChooseFileDialog::reject); | 43 | connect(buttonBox, &QDialogButtonBox::rejected, this, &ChooseFileDialog::reject); | ||
44 | layout->addWidget(label); | 44 | layout->addWidget(label); | ||
45 | layout->addWidget(listWigdet); | 45 | layout->addWidget(listWigdet); | ||
46 | layout->addWidget(buttonBox); | 46 | layout->addWidget(buttonBox); | ||
47 | setLayout(layout); | 47 | setLayout(layout); | ||
48 | } | 48 | } | ||
49 | 49 | | |||
50 | const QString& ChooseFileDialog::choosenFile() | 50 | const QUrl ChooseFileDialog::choosenFile() | ||
51 | { | 51 | { | ||
52 | return m_choosen_file; | 52 | return m_choosen_file; | ||
53 | } | 53 | } |