src/dialogs.cpp

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

mercurial