Thu, 09 Feb 2017 21:01:12 +0200
Cleaned up ExternalProgramPathDialog
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> |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
20 | #include "dialogs.h" |
962
a4b463a7ee82
Rename MainWindow files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
958
diff
changeset
|
21 | #include "mainwindow.h" |
1115
117e4880666e
Cleaned up ExternalProgramPathDialog
Teemu Piippo <teemu@hecknology.net>
parents:
1100
diff
changeset
|
22 | #include "dialogs/configdialog.h" |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
23 | #include "glRenderer.h" |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
24 | #include "documentation.h" |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
25 | #include "dialogs.h" |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
26 | #include "ui_overlay.h" |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
27 | #include "ui_extprogpath.h" |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
28 | |
1115
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 | * Constructs a new external program path dialog. |
117e4880666e
Cleaned up ExternalProgramPathDialog
Teemu Piippo <teemu@hecknology.net>
parents:
1100
diff
changeset
|
31 | */ |
117e4880666e
Cleaned up ExternalProgramPathDialog
Teemu Piippo <teemu@hecknology.net>
parents:
1100
diff
changeset
|
32 | ExternalProgramPathDialog::ExternalProgramPathDialog(QString programName, QWidget* parent, Qt::WindowFlags flags) : |
117e4880666e
Cleaned up ExternalProgramPathDialog
Teemu Piippo <teemu@hecknology.net>
parents:
1100
diff
changeset
|
33 | QDialog {parent, flags}, |
117e4880666e
Cleaned up ExternalProgramPathDialog
Teemu Piippo <teemu@hecknology.net>
parents:
1100
diff
changeset
|
34 | ui {*new Ui_ExtProgPath} |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
35 | { |
1115
117e4880666e
Cleaned up ExternalProgramPathDialog
Teemu Piippo <teemu@hecknology.net>
parents:
1100
diff
changeset
|
36 | ui.setupUi (this); |
117e4880666e
Cleaned up ExternalProgramPathDialog
Teemu Piippo <teemu@hecknology.net>
parents:
1100
diff
changeset
|
37 | QString labelText = ui.programLabel->text(); |
117e4880666e
Cleaned up ExternalProgramPathDialog
Teemu Piippo <teemu@hecknology.net>
parents:
1100
diff
changeset
|
38 | labelText.replace("<PROGRAM>", programName); |
117e4880666e
Cleaned up ExternalProgramPathDialog
Teemu Piippo <teemu@hecknology.net>
parents:
1100
diff
changeset
|
39 | ui.programLabel->setText(labelText); |
117e4880666e
Cleaned up ExternalProgramPathDialog
Teemu Piippo <teemu@hecknology.net>
parents:
1100
diff
changeset
|
40 | connect(ui.findPathButton, SIGNAL(clicked (bool)), this, SLOT(findPath())); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
41 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
42 | |
1115
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 | * Destructs the UI pointer when the dialog is deleted. |
117e4880666e
Cleaned up ExternalProgramPathDialog
Teemu Piippo <teemu@hecknology.net>
parents:
1100
diff
changeset
|
45 | */ |
117e4880666e
Cleaned up ExternalProgramPathDialog
Teemu Piippo <teemu@hecknology.net>
parents:
1100
diff
changeset
|
46 | ExternalProgramPathDialog::~ExternalProgramPathDialog() |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
47 | { |
1115
117e4880666e
Cleaned up ExternalProgramPathDialog
Teemu Piippo <teemu@hecknology.net>
parents:
1100
diff
changeset
|
48 | delete &ui; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
49 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
50 | |
1115
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 | * 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
|
53 | */ |
117e4880666e
Cleaned up ExternalProgramPathDialog
Teemu Piippo <teemu@hecknology.net>
parents:
1100
diff
changeset
|
54 | void ExternalProgramPathDialog::findPath() |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
55 | { |
1115
117e4880666e
Cleaned up ExternalProgramPathDialog
Teemu Piippo <teemu@hecknology.net>
parents:
1100
diff
changeset
|
56 | QString path = QFileDialog::getOpenFileName(nullptr, "", "", ConfigDialog::externalProgramPathFilter); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
57 | |
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
|
58 | if (not path.isEmpty()) |
1115
117e4880666e
Cleaned up ExternalProgramPathDialog
Teemu Piippo <teemu@hecknology.net>
parents:
1100
diff
changeset
|
59 | ui.path->setText(path); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
60 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
61 | |
1115
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 | * Returns the path specified by the user in this dialog. |
117e4880666e
Cleaned up ExternalProgramPathDialog
Teemu Piippo <teemu@hecknology.net>
parents:
1100
diff
changeset
|
64 | */ |
117e4880666e
Cleaned up ExternalProgramPathDialog
Teemu Piippo <teemu@hecknology.net>
parents:
1100
diff
changeset
|
65 | QString ExternalProgramPathDialog::path() const |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
66 | { |
1115
117e4880666e
Cleaned up ExternalProgramPathDialog
Teemu Piippo <teemu@hecknology.net>
parents:
1100
diff
changeset
|
67 | return ui.path->text(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
68 | } |