zz_addObjectDialog.cpp

changeset 39
110669124caf
child 40
215b9f8f0cd7
equal deleted inserted replaced
38:20f5eaae8425 39:110669124caf
1 /*
2 * LDForge: LDraw parts authoring CAD
3 * Copyright (C) 2013 Santeri `arezey` 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 <qgridlayout.h>
20 #include "gui.h"
21 #include "zz_addObjectDialog.h"
22 #include "file.h"
23
24 // =============================================================================
25 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
26 // =============================================================================
27 AddObjectDialog::AddObjectDialog (const LDObjectType_e type, QWidget* parent) :
28 QDialog (parent)
29 {
30 qTypeIcon = new QLabel;
31 qTypeIcon->setPixmap (QPixmap (g_saObjTypeIcons[type]));
32
33 qCommentLine = new QLineEdit;
34
35 IMPLEMENT_DIALOG_BUTTONS
36
37 QGridLayout* layout = new QGridLayout;
38 layout->addWidget (qTypeIcon, 0, 0);
39 layout->addWidget (qCommentLine, 0, 1);
40 layout->addWidget (qButtons, 1, 1);
41
42 setLayout (layout);
43 setWindowTitle (str::mkfmt (APPNAME_DISPLAY " - new %s",
44 g_saObjTypeNames[type]).chars());
45
46 setWindowIcon (QIcon (g_saObjTypeIcons[type]));
47 }
48
49 // =============================================================================
50 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
51 // =============================================================================
52 void AddObjectDialog::staticDialog (const LDObjectType_e type, ForgeWindow* window) {
53 AddObjectDialog dlg (type, window);
54
55 if (dlg.exec ()) {
56 switch (type) {
57 case OBJ_Comment:
58 {
59 LDComment* comm = new LDComment;
60 comm->zText = dlg.qCommentLine->text ();
61 g_CurrentFile->addObject (comm);
62 window->refresh ();
63 break;
64 }
65 default:
66 break;
67 }
68 }
69 }

mercurial