Sat, 24 Mar 2018 15:54:41 +0200
MainWindow now stores its state in the config file so its state and geometry is preserved across instances
954
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1 | /* |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
2 | * LDForge: LDraw parts authoring CAD |
1326 | 3 | * Copyright (C) 2013 - 2018 Teemu Piippo |
954
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
4 | * |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
5 | * This program is free software: you can redistribute it and/or modify |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
6 | * it under the terms of the GNU General Public License as published by |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
7 | * the Free Software Foundation, either version 3 of the License, or |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
8 | * (at your option) any later version. |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
9 | * |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
10 | * This program is distributed in the hope that it will be useful, |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
13 | * GNU General Public License for more details. |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
14 | * |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
15 | * You should have received a copy of the GNU General Public License |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
17 | */ |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
18 | |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
19 | #include <QLineEdit> |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
20 | #include <QRadioButton> |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
21 | #include <QCheckBox> |
1145
02264bf0108d
Renamed ldDocument.cpp → lddocument.cpp
Teemu Piippo <teemu@hecknology.net>
parents:
1117
diff
changeset
|
22 | #include "../lddocument.h" |
954
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
23 | #include "newpartdialog.h" |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
24 | #include "ui_newpartdialog.h" |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
25 | |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
26 | NewPartDialog::NewPartDialog (QWidget *parent) : |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
27 | QDialog (parent), |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
28 | ui (*new Ui_NewPart) |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
29 | { |
1312 | 30 | this->ui.setupUi (this); |
954
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
31 | |
1323
05b3e173c900
Config is now a namespace
Teemu Piippo <teemu@hecknology.net>
parents:
1312
diff
changeset
|
32 | QString authortext = config::defaultName(); |
954
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
33 | |
1323
05b3e173c900
Config is now a namespace
Teemu Piippo <teemu@hecknology.net>
parents:
1312
diff
changeset
|
34 | if (not config::defaultUser().isEmpty()) |
05b3e173c900
Config is now a namespace
Teemu Piippo <teemu@hecknology.net>
parents:
1312
diff
changeset
|
35 | authortext.append(format(" [%1]", config::defaultUser())); |
954
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
36 | |
1312 | 37 | this->ui.author->setText (authortext); |
1323
05b3e173c900
Config is now a namespace
Teemu Piippo <teemu@hecknology.net>
parents:
1312
diff
changeset
|
38 | this->ui.useCaLicense->setChecked (config::useCaLicense()); |
954
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
39 | } |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
40 | |
1312 | 41 | NewPartDialog::~NewPartDialog() |
954
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
42 | { |
1312 | 43 | delete &this->ui; |
44 | } | |
954
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
45 | |
1312 | 46 | Winding NewPartDialog::winding() const |
47 | { | |
48 | if (this->ui.windingCcw->isChecked()) | |
49 | return CounterClockwise; | |
50 | else if (this->ui.windingCw->isChecked()) | |
51 | return Clockwise; | |
52 | else | |
53 | return NoWinding; | |
954
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
54 | } |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
55 | |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
56 | bool NewPartDialog::useCaLicense() const |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
57 | { |
1312 | 58 | return this->ui.useCaLicense->isChecked(); |
954
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
59 | } |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
60 | |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
61 | QString NewPartDialog::author() const |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
62 | { |
1312 | 63 | return this->ui.author->text(); |
954
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
64 | } |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
65 | |
1312 | 66 | QString NewPartDialog::description() const |
954
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
67 | { |
1312 | 68 | return this->ui.title->text(); |
954
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
69 | } |
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
70 | |
1312 | 71 | void NewPartDialog::fillHeader (LDDocument* document) const |
954
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
72 | { |
1312 | 73 | document->header.description = this->description(); |
74 | document->header.type = LDHeader::Part; | |
75 | document->header.author = this->author(); | |
954
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
76 | |
1312 | 77 | if (this->useCaLicense()) |
78 | document->header.license = LDHeader::CaLicense; | |
79 | else | |
80 | document->header.license = LDHeader::UnspecifiedLicense; | |
1028
5877e49e9a28
Moved PreferredLicenseText into HierarchyElement and made the config pointer be passed to LDPaths. Now I can finally remove the Config global pointer.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1017
diff
changeset
|
81 | |
1312 | 82 | document->setWinding(this->winding()); |
954
7feaa1a3c438
Refactor the new part dialog into a new class
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
83 | } |