|
1 /* |
|
2 * LDForge: LDraw parts authoring CAD |
|
3 * Copyright (C) 2013 - 2017 Teemu Piippo |
|
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 |
|
19 #include <QFileDialog> |
|
20 #include "externalprogrampathdialog.h" |
|
21 #include "configdialog.h" |
|
22 #include "ui_extprogpath.h" |
|
23 #include "../mainwindow.h" |
|
24 #include "../glRenderer.h" |
|
25 #include "../documentation.h" |
|
26 |
|
27 /* |
|
28 * Constructs a new external program path dialog. |
|
29 */ |
|
30 ExternalProgramPathDialog::ExternalProgramPathDialog(QString programName, QWidget* parent, Qt::WindowFlags flags) : |
|
31 QDialog {parent, flags}, |
|
32 ui {*new Ui_ExtProgPath} |
|
33 { |
|
34 ui.setupUi (this); |
|
35 QString labelText = ui.programLabel->text(); |
|
36 labelText.replace("<PROGRAM>", programName); |
|
37 ui.programLabel->setText(labelText); |
|
38 connect(ui.findPathButton, SIGNAL(clicked (bool)), this, SLOT(findPath())); |
|
39 } |
|
40 |
|
41 /* |
|
42 * Destructs the UI pointer when the dialog is deleted. |
|
43 */ |
|
44 ExternalProgramPathDialog::~ExternalProgramPathDialog() |
|
45 { |
|
46 delete &ui; |
|
47 } |
|
48 |
|
49 /* |
|
50 * Handler for the button in the dialog, shows a modal dialog for the user to locate the program. |
|
51 */ |
|
52 void ExternalProgramPathDialog::findPath() |
|
53 { |
|
54 QString path = QFileDialog::getOpenFileName(nullptr, "", "", ConfigDialog::externalProgramPathFilter); |
|
55 |
|
56 if (not path.isEmpty()) |
|
57 ui.path->setText(path); |
|
58 } |
|
59 |
|
60 /* |
|
61 * Returns the path specified by the user in this dialog. |
|
62 */ |
|
63 QString ExternalProgramPathDialog::path() const |
|
64 { |
|
65 return ui.path->text(); |
|
66 } |