Thu, 09 Feb 2017 21:04:33 +0200
Moved dialogs.cpp to dialogs/externalprogrampathdialog.cpp
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1 | /* |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
2 | * LDForge: LDraw parts authoring CAD |
1072 | 3 | * Copyright (C) 2013 - 2017 Teemu Piippo |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
4 | * |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
5 | * This program is free software: you can redistribute it and/or modify |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
6 | * it under the terms of the GNU General Public License as published by |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
7 | * the Free Software Foundation, either version 3 of the License, or |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
8 | * (at your option) any later version. |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
9 | * |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
10 | * This program is distributed in the hope that it will be useful, |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
13 | * GNU General Public License for more details. |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
14 | * |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
15 | * You should have received a copy of the GNU General Public License |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
17 | */ |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
18 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
19 | #include <QFileDialog> |
1116
3b1d2cc6603e
Moved dialogs.cpp to dialogs/externalprogrampathdialog.cpp
Teemu Piippo <teemu@hecknology.net>
parents:
1115
diff
changeset
|
20 | #include "externalprogrampathdialog.h" |
3b1d2cc6603e
Moved dialogs.cpp to dialogs/externalprogrampathdialog.cpp
Teemu Piippo <teemu@hecknology.net>
parents:
1115
diff
changeset
|
21 | #include "configdialog.h" |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
22 | #include "ui_extprogpath.h" |
1116
3b1d2cc6603e
Moved dialogs.cpp to dialogs/externalprogrampathdialog.cpp
Teemu Piippo <teemu@hecknology.net>
parents:
1115
diff
changeset
|
23 | #include "../mainwindow.h" |
3b1d2cc6603e
Moved dialogs.cpp to dialogs/externalprogrampathdialog.cpp
Teemu Piippo <teemu@hecknology.net>
parents:
1115
diff
changeset
|
24 | #include "../glRenderer.h" |
3b1d2cc6603e
Moved dialogs.cpp to dialogs/externalprogrampathdialog.cpp
Teemu Piippo <teemu@hecknology.net>
parents:
1115
diff
changeset
|
25 | #include "../documentation.h" |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
26 | |
1115
117e4880666e
Cleaned up ExternalProgramPathDialog
Teemu Piippo <teemu@hecknology.net>
parents:
1100
diff
changeset
|
27 | /* |
117e4880666e
Cleaned up ExternalProgramPathDialog
Teemu Piippo <teemu@hecknology.net>
parents:
1100
diff
changeset
|
28 | * Constructs a new external program path dialog. |
117e4880666e
Cleaned up ExternalProgramPathDialog
Teemu Piippo <teemu@hecknology.net>
parents:
1100
diff
changeset
|
29 | */ |
117e4880666e
Cleaned up ExternalProgramPathDialog
Teemu Piippo <teemu@hecknology.net>
parents:
1100
diff
changeset
|
30 | ExternalProgramPathDialog::ExternalProgramPathDialog(QString programName, QWidget* parent, Qt::WindowFlags flags) : |
117e4880666e
Cleaned up ExternalProgramPathDialog
Teemu Piippo <teemu@hecknology.net>
parents:
1100
diff
changeset
|
31 | QDialog {parent, flags}, |
117e4880666e
Cleaned up ExternalProgramPathDialog
Teemu Piippo <teemu@hecknology.net>
parents:
1100
diff
changeset
|
32 | ui {*new Ui_ExtProgPath} |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
33 | { |
1115
117e4880666e
Cleaned up ExternalProgramPathDialog
Teemu Piippo <teemu@hecknology.net>
parents:
1100
diff
changeset
|
34 | ui.setupUi (this); |
117e4880666e
Cleaned up ExternalProgramPathDialog
Teemu Piippo <teemu@hecknology.net>
parents:
1100
diff
changeset
|
35 | QString labelText = ui.programLabel->text(); |
117e4880666e
Cleaned up ExternalProgramPathDialog
Teemu Piippo <teemu@hecknology.net>
parents:
1100
diff
changeset
|
36 | labelText.replace("<PROGRAM>", programName); |
117e4880666e
Cleaned up ExternalProgramPathDialog
Teemu Piippo <teemu@hecknology.net>
parents:
1100
diff
changeset
|
37 | ui.programLabel->setText(labelText); |
117e4880666e
Cleaned up ExternalProgramPathDialog
Teemu Piippo <teemu@hecknology.net>
parents:
1100
diff
changeset
|
38 | connect(ui.findPathButton, SIGNAL(clicked (bool)), this, SLOT(findPath())); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
39 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
40 | |
1115
117e4880666e
Cleaned up ExternalProgramPathDialog
Teemu Piippo <teemu@hecknology.net>
parents:
1100
diff
changeset
|
41 | /* |
117e4880666e
Cleaned up ExternalProgramPathDialog
Teemu Piippo <teemu@hecknology.net>
parents:
1100
diff
changeset
|
42 | * Destructs the UI pointer when the dialog is deleted. |
117e4880666e
Cleaned up ExternalProgramPathDialog
Teemu Piippo <teemu@hecknology.net>
parents:
1100
diff
changeset
|
43 | */ |
117e4880666e
Cleaned up ExternalProgramPathDialog
Teemu Piippo <teemu@hecknology.net>
parents:
1100
diff
changeset
|
44 | ExternalProgramPathDialog::~ExternalProgramPathDialog() |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
45 | { |
1115
117e4880666e
Cleaned up ExternalProgramPathDialog
Teemu Piippo <teemu@hecknology.net>
parents:
1100
diff
changeset
|
46 | delete &ui; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
47 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
48 | |
1115
117e4880666e
Cleaned up ExternalProgramPathDialog
Teemu Piippo <teemu@hecknology.net>
parents:
1100
diff
changeset
|
49 | /* |
117e4880666e
Cleaned up ExternalProgramPathDialog
Teemu Piippo <teemu@hecknology.net>
parents:
1100
diff
changeset
|
50 | * Handler for the button in the dialog, shows a modal dialog for the user to locate the program. |
117e4880666e
Cleaned up ExternalProgramPathDialog
Teemu Piippo <teemu@hecknology.net>
parents:
1100
diff
changeset
|
51 | */ |
117e4880666e
Cleaned up ExternalProgramPathDialog
Teemu Piippo <teemu@hecknology.net>
parents:
1100
diff
changeset
|
52 | void ExternalProgramPathDialog::findPath() |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
53 | { |
1115
117e4880666e
Cleaned up ExternalProgramPathDialog
Teemu Piippo <teemu@hecknology.net>
parents:
1100
diff
changeset
|
54 | QString path = QFileDialog::getOpenFileName(nullptr, "", "", ConfigDialog::externalProgramPathFilter); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
55 | |
662
2f1bd9112408
- use the keyword 'not' in place of the exclamation mark for operator!, this is clearer. also converted uses of '== false' to this.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
56 | if (not path.isEmpty()) |
1115
117e4880666e
Cleaned up ExternalProgramPathDialog
Teemu Piippo <teemu@hecknology.net>
parents:
1100
diff
changeset
|
57 | ui.path->setText(path); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
58 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
59 | |
1115
117e4880666e
Cleaned up ExternalProgramPathDialog
Teemu Piippo <teemu@hecknology.net>
parents:
1100
diff
changeset
|
60 | /* |
117e4880666e
Cleaned up ExternalProgramPathDialog
Teemu Piippo <teemu@hecknology.net>
parents:
1100
diff
changeset
|
61 | * Returns the path specified by the user in this dialog. |
117e4880666e
Cleaned up ExternalProgramPathDialog
Teemu Piippo <teemu@hecknology.net>
parents:
1100
diff
changeset
|
62 | */ |
117e4880666e
Cleaned up ExternalProgramPathDialog
Teemu Piippo <teemu@hecknology.net>
parents:
1100
diff
changeset
|
63 | QString ExternalProgramPathDialog::path() const |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
64 | { |
1115
117e4880666e
Cleaned up ExternalProgramPathDialog
Teemu Piippo <teemu@hecknology.net>
parents:
1100
diff
changeset
|
65 | return ui.path->text(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
66 | } |