zz_setContentsDialog.cpp

Tue, 19 Mar 2013 17:21:51 +0200

author
Santeri Piippo <crimsondusk64@gmail.com>
date
Tue, 19 Mar 2013 17:21:51 +0200
changeset 34
d99006de6261
parent 32
5d22b7ecf110
child 39
110669124caf
permissions
-rw-r--r--

Added main color configuration option, not implemented yet

30
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
diff changeset
1 /*
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
diff changeset
2 * LDForge: LDraw parts authoring CAD
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
diff changeset
3 * Copyright (C) 2013 Santeri `arezey` Piippo
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
diff changeset
4 *
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
diff changeset
5 * This program is free software: you can redistribute it and/or modify
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
diff changeset
6 * it under the terms of the GNU General Public License as published by
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
diff changeset
7 * the Free Software Foundation, either version 3 of the License, or
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
diff changeset
8 * (at your option) any later version.
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
diff changeset
9 *
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
diff changeset
10 * This program is distributed in the hope that it will be useful,
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
diff changeset
13 * GNU General Public License for more details.
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
diff changeset
14 *
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
diff changeset
15 * You should have received a copy of the GNU General Public License
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
diff changeset
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
diff changeset
17 */
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
diff changeset
18
15
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
19 #include <QAbstractButton>
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
20 #include <qboxlayout.h>
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
21 #include "zz_setContentsDialog.h"
26
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 25
diff changeset
22 #include "file.h"
15
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
23 #include "gui.h"
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
24
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
25 // =============================================================================
30
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
diff changeset
26 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
15
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
27 // =============================================================================
30
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
diff changeset
28 SetContentsDialog::SetContentsDialog (LDObject* obj, QWidget* parent) : QDialog(parent) {
15
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
29 setWindowTitle (APPNAME_DISPLAY ": Set Contents");
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
30
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
31 qContentsLabel = new QLabel ("Set contents:", parent);
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
32
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
33 qContents = new QLineEdit (parent);
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
34 qContents->setText (obj->getContents ().chars());
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
35 qContents->setWhatsThis ("The LDraw code of this object. The code written "
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
36 "here is expected to be valid LDraw code, invalid code here results "
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
37 "the object being turned into an error object. Please do refer to the "
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
38 "<a href=\"http://www.ldraw.org/article/218.html\">official file format "
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
39 "standard</a> for further information.");
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
40 qContents->setMinimumWidth (384);
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
41
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
42 qOKCancel = new QDialogButtonBox (QDialogButtonBox::Ok | QDialogButtonBox::Cancel,
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
43 Qt::Horizontal, parent);
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
44
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
45 connect (qOKCancel, SIGNAL (accepted ()), this, SLOT (accept ()));
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
46 connect (qOKCancel, SIGNAL (rejected ()), this, SLOT (reject ()));
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
47 /*
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
48 connect (qOKCancel, SIGNAL (clicked (QAbstractButton*)), this, SLOT (slot_handleButtons (QAbstractButton*)));
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
49 */
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
50
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
51 QVBoxLayout* layout = new QVBoxLayout;
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
52 layout->addWidget (qContentsLabel);
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
53 layout->addWidget (qContents);
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
54 layout->addWidget (qOKCancel);
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
55 setLayout (layout);
30
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
diff changeset
56
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
diff changeset
57 setWindowTitle (APPNAME_DISPLAY " - setting contents");
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
diff changeset
58 setWindowIcon (QIcon ("icons/set-contents.png"));
15
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
59 }
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
60
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
61 // =============================================================================
30
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
diff changeset
62 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
15
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
63 // =============================================================================
30
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
diff changeset
64 void SetContentsDialog::slot_handleButtons (QAbstractButton* qButton) {
15
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
65 qButton = qButton;
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
66 }
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
67
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
68 // =============================================================================
30
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
diff changeset
69 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
15
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
70 // =============================================================================
30
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
diff changeset
71 void SetContentsDialog::staticDialog (LDObject* obj, ForgeWindow* parent) {
15
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
72 if (!obj)
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
73 return;
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
74
30
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
diff changeset
75 SetContentsDialog dlg (obj, parent);
15
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
76 if (dlg.exec ()) {
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
77 LDObject* oldobj = obj;
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
78
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
79 // Reinterpret it from the text of the input field
25
c74bb88f537d Deleted scanner.cpp (don't need it), merged model.cpp into io.cpp. Renamed LDForgeWindow to just ForgeWindow since I want the LD* prefix only be given to LDObject derivatives.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 22
diff changeset
80 obj = parseLine (dlg.qContents->text ().toStdString ().c_str ());
29
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 26
diff changeset
81 oldobj->replace (obj);
15
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
82
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
83 // Rebuild stuff after this
32
5d22b7ecf110 Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents: 30
diff changeset
84 parent->refresh ();
15
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
85 }
a78ccb3976b6 oops, forgot the new dialog files out
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
86 }

mercurial