src/dialogs.cpp

Sat, 06 Jul 2013 01:59:58 +0300

author
Santeri Piippo <crimsondusk64@gmail.com>
date
Sat, 06 Jul 2013 01:59:58 +0300
changeset 340
3a25593e180b
parent 337
4e05207c76c9
child 370
843b3dbbd849
permissions
-rw-r--r--

Added missing src/src.pro file

198
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
1 /*
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
2 * LDForge: LDraw parts authoring CAD
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2013 Santeri Piippo
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
4 *
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
5 * This program is free software: you can redistribute it and/or modify
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
6 * it under the terms of the GNU General Public License as published by
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
7 * the Free Software Foundation, either version 3 of the License, or
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
8 * (at your option) any later version.
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
9 *
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
10 * This program is distributed in the hope that it will be useful,
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
13 * GNU General Public License for more details.
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
14 *
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
17 */
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
18
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
19 #include <QDialog>
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
20 #include <QLineEdit>
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
21 #include <QSpinBox>
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
22 #include <QDialogButtonBox>
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
23 #include <QFileDialog>
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
24 #include <QLabel>
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
25 #include <QPushButton>
202
a027f6fc6141 Un-templated CheckBoxGroup, moved it and RadioButton into widgets.cpp/widgets.h; removed license text tab because I think LICENSE is enough.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 200
diff changeset
26 #include <QBoxLayout>
211
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 202
diff changeset
27 #include <QGridLayout>
248
4431371f3ffe Added a progress dialog for file loading to respond to desktops while loading files. With large files the no-response policy could be a bad thing. My first real use case of multi-threading...
Santeri Piippo <crimsondusk64@gmail.com>
parents: 226
diff changeset
28 #include <qprogressbar.h>
262
56f8987f4c7c Fixed behavior of mid-button vertex selector, add ability to all-replace and relative moving to replace coords
Santeri Piippo <crimsondusk64@gmail.com>
parents: 259
diff changeset
29 #include <QCheckBox>
198
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
30
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
31 #include "dialogs.h"
202
a027f6fc6141 Un-templated CheckBoxGroup, moved it and RadioButton into widgets.cpp/widgets.h; removed license text tab because I think LICENSE is enough.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 200
diff changeset
32 #include "widgets.h"
198
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
33 #include "gui.h"
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
34 #include "gldraw.h"
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
35 #include "docs.h"
200
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
36 #include "file.h"
198
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
37 #include "dialogs.h"
335
30c11cff511d Converted overlay prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 333
diff changeset
38 #include "ui_overlay.h"
337
4e05207c76c9 Converted ldraw path prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 335
diff changeset
39 #include "ui_ldrawpath.h"
198
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
40
200
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
41 extern_cfg (str, io_ldpath);
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
42
198
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
43 // =============================================================================
335
30c11cff511d Converted overlay prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 333
diff changeset
44 OverlayDialog::OverlayDialog( QWidget* parent, Qt::WindowFlags f ) : QDialog( parent, f )
30c11cff511d Converted overlay prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 333
diff changeset
45 {
30c11cff511d Converted overlay prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 333
diff changeset
46 ui = new Ui_OverlayUI;
30c11cff511d Converted overlay prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 333
diff changeset
47 ui->setupUi( this );
198
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
48
335
30c11cff511d Converted overlay prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 333
diff changeset
49 m_cameraArgs = {
30c11cff511d Converted overlay prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 333
diff changeset
50 { ui->top, GL::Top },
30c11cff511d Converted overlay prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 333
diff changeset
51 { ui->bottom, GL::Bottom },
30c11cff511d Converted overlay prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 333
diff changeset
52 { ui->front, GL::Front },
30c11cff511d Converted overlay prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 333
diff changeset
53 { ui->back, GL::Back },
30c11cff511d Converted overlay prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 333
diff changeset
54 { ui->left, GL::Left },
30c11cff511d Converted overlay prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 333
diff changeset
55 { ui->right, GL::Right }
30c11cff511d Converted overlay prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 333
diff changeset
56 };
198
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
57
335
30c11cff511d Converted overlay prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 333
diff changeset
58 GL::Camera cam = g_win->R()->camera();
198
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
59
335
30c11cff511d Converted overlay prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 333
diff changeset
60 if( cam == GL::Free )
30c11cff511d Converted overlay prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 333
diff changeset
61 cam = GL::Top;
198
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
62
335
30c11cff511d Converted overlay prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 333
diff changeset
63 connect( ui->width, SIGNAL( valueChanged( double )), this, SLOT( slot_dimensionsChanged() ));
30c11cff511d Converted overlay prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 333
diff changeset
64 connect( ui->height, SIGNAL( valueChanged( double )), this, SLOT( slot_dimensionsChanged() ));
30c11cff511d Converted overlay prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 333
diff changeset
65 connect( ui->buttonBox, SIGNAL( helpRequested() ), this, SLOT( slot_help() ));
30c11cff511d Converted overlay prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 333
diff changeset
66 connect( ui->fileSearchButton, SIGNAL( clicked( bool )), this, SLOT( slot_fpath() ));
198
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
67
335
30c11cff511d Converted overlay prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 333
diff changeset
68 slot_dimensionsChanged();
30c11cff511d Converted overlay prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 333
diff changeset
69 fillDefaults( cam );
30c11cff511d Converted overlay prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 333
diff changeset
70 }
30c11cff511d Converted overlay prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 333
diff changeset
71
30c11cff511d Converted overlay prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 333
diff changeset
72 OverlayDialog::~OverlayDialog()
30c11cff511d Converted overlay prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 333
diff changeset
73 {
30c11cff511d Converted overlay prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 333
diff changeset
74 delete ui;
198
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
75 }
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
76
335
30c11cff511d Converted overlay prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 333
diff changeset
77 void OverlayDialog::fillDefaults( int newcam )
30c11cff511d Converted overlay prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 333
diff changeset
78 {
30c11cff511d Converted overlay prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 333
diff changeset
79 overlayMeta& info = g_win->R()->getOverlay( newcam );
30c11cff511d Converted overlay prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 333
diff changeset
80
30c11cff511d Converted overlay prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 333
diff changeset
81 radioDefault<int>( newcam, m_cameraArgs );
198
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
82
335
30c11cff511d Converted overlay prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 333
diff changeset
83 if( info.img != null )
30c11cff511d Converted overlay prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 333
diff changeset
84 {
30c11cff511d Converted overlay prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 333
diff changeset
85 ui->filename->setText( info.fname );
30c11cff511d Converted overlay prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 333
diff changeset
86 ui->originX->setValue( info.ox );
30c11cff511d Converted overlay prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 333
diff changeset
87 ui->originY->setValue( info.oy );
30c11cff511d Converted overlay prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 333
diff changeset
88 ui->width->setValue( info.lw );
30c11cff511d Converted overlay prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 333
diff changeset
89 ui->height->setValue( info.lh );
30c11cff511d Converted overlay prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 333
diff changeset
90 }
30c11cff511d Converted overlay prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 333
diff changeset
91 else
30c11cff511d Converted overlay prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 333
diff changeset
92 {
30c11cff511d Converted overlay prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 333
diff changeset
93 ui->filename->setText( "" );
30c11cff511d Converted overlay prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 333
diff changeset
94 ui->originX->setValue( 0 );
30c11cff511d Converted overlay prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 333
diff changeset
95 ui->originY->setValue( 0 );
30c11cff511d Converted overlay prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 333
diff changeset
96 ui->width->setValue( 0.0f );
30c11cff511d Converted overlay prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 333
diff changeset
97 ui->height->setValue( 0.0f );
30c11cff511d Converted overlay prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 333
diff changeset
98 }
30c11cff511d Converted overlay prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 333
diff changeset
99 }
30c11cff511d Converted overlay prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 333
diff changeset
100
30c11cff511d Converted overlay prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 333
diff changeset
101 str OverlayDialog::fpath() const
30c11cff511d Converted overlay prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 333
diff changeset
102 {
30c11cff511d Converted overlay prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 333
diff changeset
103 return ui->filename->text();
30c11cff511d Converted overlay prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 333
diff changeset
104 }
30c11cff511d Converted overlay prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 333
diff changeset
105
30c11cff511d Converted overlay prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 333
diff changeset
106 ushort OverlayDialog::ofsx() const
30c11cff511d Converted overlay prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 333
diff changeset
107 {
30c11cff511d Converted overlay prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 333
diff changeset
108 return ui->originX->value();
198
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
109 }
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
110
335
30c11cff511d Converted overlay prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 333
diff changeset
111 ushort OverlayDialog::ofsy() const
30c11cff511d Converted overlay prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 333
diff changeset
112 {
30c11cff511d Converted overlay prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 333
diff changeset
113 return ui->originY->value();
30c11cff511d Converted overlay prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 333
diff changeset
114 }
198
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
115
335
30c11cff511d Converted overlay prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 333
diff changeset
116 double OverlayDialog::lwidth() const
30c11cff511d Converted overlay prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 333
diff changeset
117 {
30c11cff511d Converted overlay prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 333
diff changeset
118 return ui->width->value();
30c11cff511d Converted overlay prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 333
diff changeset
119 }
30c11cff511d Converted overlay prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 333
diff changeset
120
30c11cff511d Converted overlay prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 333
diff changeset
121 double OverlayDialog::lheight() const
30c11cff511d Converted overlay prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 333
diff changeset
122 {
30c11cff511d Converted overlay prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 333
diff changeset
123 return ui->height->value();
198
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
124 }
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
125
335
30c11cff511d Converted overlay prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 333
diff changeset
126 int OverlayDialog::camera() const
30c11cff511d Converted overlay prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 333
diff changeset
127 {
30c11cff511d Converted overlay prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 333
diff changeset
128 return radioSwitch<int>( GL::Top, m_cameraArgs );
30c11cff511d Converted overlay prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 333
diff changeset
129 }
30c11cff511d Converted overlay prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 333
diff changeset
130
30c11cff511d Converted overlay prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 333
diff changeset
131 void OverlayDialog::slot_fpath()
30c11cff511d Converted overlay prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 333
diff changeset
132 {
30c11cff511d Converted overlay prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 333
diff changeset
133 ui->filename->setText( QFileDialog::getOpenFileName( null, "Overlay image" ));
198
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
134 }
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
135
335
30c11cff511d Converted overlay prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 333
diff changeset
136 void OverlayDialog::slot_help()
30c11cff511d Converted overlay prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 333
diff changeset
137 {
30c11cff511d Converted overlay prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 333
diff changeset
138 showDocumentation( g_docs_overlays );
30c11cff511d Converted overlay prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 333
diff changeset
139 }
30c11cff511d Converted overlay prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 333
diff changeset
140
30c11cff511d Converted overlay prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 333
diff changeset
141 void OverlayDialog::slot_dimensionsChanged()
30c11cff511d Converted overlay prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 333
diff changeset
142 {
30c11cff511d Converted overlay prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 333
diff changeset
143 bool enable = ( ui->width->value() != 0 ) || ( ui->height->value() != 0 );
30c11cff511d Converted overlay prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 333
diff changeset
144 ui->buttonBox->button( QDialogButtonBox::Ok )->setEnabled( enable );
199
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
145 }
10dd5909a50e Made Qt file includes more proper (<QLineEdit> instead of <qlineedit.h>), merged setContentsDialog.cpp into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
146
258
f9c48d4481e1 Fixed text editing not triggering configuration. So simple..
Santeri Piippo <crimsondusk64@gmail.com>
parents: 251
diff changeset
147 // =================================================================================================
337
4e05207c76c9 Converted ldraw path prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 335
diff changeset
148 LDrawPathDialog::LDrawPathDialog( const bool validDefault, QWidget* parent, Qt::WindowFlags f )
4e05207c76c9 Converted ldraw path prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 335
diff changeset
149 : QDialog( parent, f ), m_validDefault( validDefault )
200
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
150 {
337
4e05207c76c9 Converted ldraw path prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 335
diff changeset
151 ui = new Ui_LDPathUI;
4e05207c76c9 Converted ldraw path prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 335
diff changeset
152 ui->setupUi( this );
4e05207c76c9 Converted ldraw path prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 335
diff changeset
153 ui->status->setText( "---" );
200
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
154
337
4e05207c76c9 Converted ldraw path prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 335
diff changeset
155 if( validDefault )
4e05207c76c9 Converted ldraw path prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 335
diff changeset
156 ui->heading->hide();
4e05207c76c9 Converted ldraw path prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 335
diff changeset
157 else
4e05207c76c9 Converted ldraw path prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 335
diff changeset
158 {
4e05207c76c9 Converted ldraw path prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 335
diff changeset
159 cancelButton()->setText( "Exit" );
4e05207c76c9 Converted ldraw path prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 335
diff changeset
160 cancelButton()->setIcon( getIcon( "exit" ));
200
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
161 }
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
162
337
4e05207c76c9 Converted ldraw path prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 335
diff changeset
163 okButton()->setEnabled( false );
200
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
164
337
4e05207c76c9 Converted ldraw path prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 335
diff changeset
165 connect( ui->path, SIGNAL( textEdited( QString ) ), this, SLOT( slot_tryConfigure() ) );
4e05207c76c9 Converted ldraw path prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 335
diff changeset
166 connect( ui->searchButton, SIGNAL( clicked() ), this, SLOT( slot_findPath() ) );
4e05207c76c9 Converted ldraw path prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 335
diff changeset
167 connect( ui->buttonBox, SIGNAL( rejected() ), this, validDefault ? SLOT( reject() ) : SLOT( slot_exit() ));
200
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
168
337
4e05207c76c9 Converted ldraw path prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 335
diff changeset
169 setPath( io_ldpath );
200
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
170
337
4e05207c76c9 Converted ldraw path prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 335
diff changeset
171 if( validDefault )
4e05207c76c9 Converted ldraw path prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 335
diff changeset
172 slot_tryConfigure();
4e05207c76c9 Converted ldraw path prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 335
diff changeset
173 }
4e05207c76c9 Converted ldraw path prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 335
diff changeset
174
4e05207c76c9 Converted ldraw path prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 335
diff changeset
175 LDrawPathDialog::~LDrawPathDialog()
4e05207c76c9 Converted ldraw path prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 335
diff changeset
176 {
4e05207c76c9 Converted ldraw path prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 335
diff changeset
177 delete ui;
4e05207c76c9 Converted ldraw path prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 335
diff changeset
178 }
4e05207c76c9 Converted ldraw path prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 335
diff changeset
179
4e05207c76c9 Converted ldraw path prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 335
diff changeset
180 QPushButton* LDrawPathDialog::okButton()
4e05207c76c9 Converted ldraw path prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 335
diff changeset
181 {
4e05207c76c9 Converted ldraw path prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 335
diff changeset
182 return ui->buttonBox->button( QDialogButtonBox::Ok );
200
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
183 }
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
184
337
4e05207c76c9 Converted ldraw path prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 335
diff changeset
185 QPushButton* LDrawPathDialog::cancelButton()
4e05207c76c9 Converted ldraw path prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 335
diff changeset
186 {
4e05207c76c9 Converted ldraw path prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 335
diff changeset
187 return ui->buttonBox->button( QDialogButtonBox::Cancel );
200
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
188 }
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
189
337
4e05207c76c9 Converted ldraw path prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 335
diff changeset
190 void LDrawPathDialog::setPath( str path )
4e05207c76c9 Converted ldraw path prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 335
diff changeset
191 {
4e05207c76c9 Converted ldraw path prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 335
diff changeset
192 ui->path->setText( path );
200
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
193 }
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
194
337
4e05207c76c9 Converted ldraw path prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 335
diff changeset
195 str LDrawPathDialog::filename() const
4e05207c76c9 Converted ldraw path prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 335
diff changeset
196 {
4e05207c76c9 Converted ldraw path prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 335
diff changeset
197 return ui->path->text();
200
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
198 }
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
199
337
4e05207c76c9 Converted ldraw path prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 335
diff changeset
200 void LDrawPathDialog::slot_findPath()
4e05207c76c9 Converted ldraw path prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 335
diff changeset
201 {
4e05207c76c9 Converted ldraw path prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 335
diff changeset
202 str newpath = QFileDialog::getExistingDirectory( this, "Find LDraw Path" );
4e05207c76c9 Converted ldraw path prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 335
diff changeset
203
4e05207c76c9 Converted ldraw path prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 335
diff changeset
204 if( newpath.length() > 0 && newpath != filename() )
4e05207c76c9 Converted ldraw path prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 335
diff changeset
205 {
4e05207c76c9 Converted ldraw path prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 335
diff changeset
206 setPath( newpath );
4e05207c76c9 Converted ldraw path prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 335
diff changeset
207 slot_tryConfigure();
200
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
208 }
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
209 }
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
210
337
4e05207c76c9 Converted ldraw path prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 335
diff changeset
211 void LDrawPathDialog::slot_exit()
4e05207c76c9 Converted ldraw path prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 335
diff changeset
212 {
4e05207c76c9 Converted ldraw path prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 335
diff changeset
213 exit( 1 );
200
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
214 }
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
215
337
4e05207c76c9 Converted ldraw path prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 335
diff changeset
216 void LDrawPathDialog::slot_tryConfigure()
4e05207c76c9 Converted ldraw path prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 335
diff changeset
217 {
4e05207c76c9 Converted ldraw path prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 335
diff changeset
218 if( LDPaths::tryConfigure( filename() ) == false )
4e05207c76c9 Converted ldraw path prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 335
diff changeset
219 {
4e05207c76c9 Converted ldraw path prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 335
diff changeset
220 ui->status->setText( fmt( "<span style=\"color:#700; \">%1</span>", LDPaths::getError() ) );
4e05207c76c9 Converted ldraw path prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 335
diff changeset
221 okButton()->setEnabled( false );
200
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
222 return;
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
223 }
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
224
337
4e05207c76c9 Converted ldraw path prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 335
diff changeset
225 ui->status->setText( "<span style=\"color: #270; \">OK!</span>" );
4e05207c76c9 Converted ldraw path prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 335
diff changeset
226 okButton()->setEnabled( true );
200
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
227 }
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
228
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
229 // =============================================================================
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
230 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
5583af82087e Merged new part and LDraw path dialogs into dialogs.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 199
diff changeset
231 // =============================================================================
249
6b2cc2d82ba6 Use QMutex for the thread locking, remove filename from the progress dialog since it's not known anyway
Santeri Piippo <crimsondusk64@gmail.com>
parents: 248
diff changeset
232 OpenProgressDialog::OpenProgressDialog (QWidget* parent, Qt::WindowFlags f) : QDialog (parent, f) {
248
4431371f3ffe Added a progress dialog for file loading to respond to desktops while loading files. With large files the no-response policy could be a bad thing. My first real use case of multi-threading...
Santeri Piippo <crimsondusk64@gmail.com>
parents: 226
diff changeset
233 progressBar = new QProgressBar;
319
d0f41342ef51 Show values in file opening prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 315
diff changeset
234 progressText = new QLabel( "Parsing..." );
248
4431371f3ffe Added a progress dialog for file loading to respond to desktops while loading files. With large files the no-response policy could be a bad thing. My first real use case of multi-threading...
Santeri Piippo <crimsondusk64@gmail.com>
parents: 226
diff changeset
235 setNumLines (0);
4431371f3ffe Added a progress dialog for file loading to respond to desktops while loading files. With large files the no-response policy could be a bad thing. My first real use case of multi-threading...
Santeri Piippo <crimsondusk64@gmail.com>
parents: 226
diff changeset
236 m_progress = 0;
4431371f3ffe Added a progress dialog for file loading to respond to desktops while loading files. With large files the no-response policy could be a bad thing. My first real use case of multi-threading...
Santeri Piippo <crimsondusk64@gmail.com>
parents: 226
diff changeset
237
4431371f3ffe Added a progress dialog for file loading to respond to desktops while loading files. With large files the no-response policy could be a bad thing. My first real use case of multi-threading...
Santeri Piippo <crimsondusk64@gmail.com>
parents: 226
diff changeset
238 QDialogButtonBox* dbb_buttons = new QDialogButtonBox;
4431371f3ffe Added a progress dialog for file loading to respond to desktops while loading files. With large files the no-response policy could be a bad thing. My first real use case of multi-threading...
Santeri Piippo <crimsondusk64@gmail.com>
parents: 226
diff changeset
239 dbb_buttons->addButton (QDialogButtonBox::Cancel);
4431371f3ffe Added a progress dialog for file loading to respond to desktops while loading files. With large files the no-response policy could be a bad thing. My first real use case of multi-threading...
Santeri Piippo <crimsondusk64@gmail.com>
parents: 226
diff changeset
240 connect (dbb_buttons, SIGNAL (rejected ()), this, SLOT (reject ()));
4431371f3ffe Added a progress dialog for file loading to respond to desktops while loading files. With large files the no-response policy could be a bad thing. My first real use case of multi-threading...
Santeri Piippo <crimsondusk64@gmail.com>
parents: 226
diff changeset
241
4431371f3ffe Added a progress dialog for file loading to respond to desktops while loading files. With large files the no-response policy could be a bad thing. My first real use case of multi-threading...
Santeri Piippo <crimsondusk64@gmail.com>
parents: 226
diff changeset
242 QVBoxLayout* layout = new QVBoxLayout (this);
4431371f3ffe Added a progress dialog for file loading to respond to desktops while loading files. With large files the no-response policy could be a bad thing. My first real use case of multi-threading...
Santeri Piippo <crimsondusk64@gmail.com>
parents: 226
diff changeset
243 layout->addWidget (progressText);
4431371f3ffe Added a progress dialog for file loading to respond to desktops while loading files. With large files the no-response policy could be a bad thing. My first real use case of multi-threading...
Santeri Piippo <crimsondusk64@gmail.com>
parents: 226
diff changeset
244 layout->addWidget (progressBar);
4431371f3ffe Added a progress dialog for file loading to respond to desktops while loading files. With large files the no-response policy could be a bad thing. My first real use case of multi-threading...
Santeri Piippo <crimsondusk64@gmail.com>
parents: 226
diff changeset
245 layout->addWidget (dbb_buttons);
4431371f3ffe Added a progress dialog for file loading to respond to desktops while loading files. With large files the no-response policy could be a bad thing. My first real use case of multi-threading...
Santeri Piippo <crimsondusk64@gmail.com>
parents: 226
diff changeset
246 }
4431371f3ffe Added a progress dialog for file loading to respond to desktops while loading files. With large files the no-response policy could be a bad thing. My first real use case of multi-threading...
Santeri Piippo <crimsondusk64@gmail.com>
parents: 226
diff changeset
247
274
d232fe4d88a6 Reworked properties a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 270
diff changeset
248 READ_ACCESSOR (ulong, OpenProgressDialog::numLines) {
d232fe4d88a6 Reworked properties a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 270
diff changeset
249 return m_numLines;
d232fe4d88a6 Reworked properties a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 270
diff changeset
250 }
d232fe4d88a6 Reworked properties a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 270
diff changeset
251
d232fe4d88a6 Reworked properties a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 270
diff changeset
252 SET_ACCESSOR (ulong, OpenProgressDialog::setNumLines) {
d232fe4d88a6 Reworked properties a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 270
diff changeset
253 m_numLines = val;
248
4431371f3ffe Added a progress dialog for file loading to respond to desktops while loading files. With large files the no-response policy could be a bad thing. My first real use case of multi-threading...
Santeri Piippo <crimsondusk64@gmail.com>
parents: 226
diff changeset
254 progressBar->setRange (0, numLines ());
4431371f3ffe Added a progress dialog for file loading to respond to desktops while loading files. With large files the no-response policy could be a bad thing. My first real use case of multi-threading...
Santeri Piippo <crimsondusk64@gmail.com>
parents: 226
diff changeset
255 updateValues ();
4431371f3ffe Added a progress dialog for file loading to respond to desktops while loading files. With large files the no-response policy could be a bad thing. My first real use case of multi-threading...
Santeri Piippo <crimsondusk64@gmail.com>
parents: 226
diff changeset
256 }
4431371f3ffe Added a progress dialog for file loading to respond to desktops while loading files. With large files the no-response policy could be a bad thing. My first real use case of multi-threading...
Santeri Piippo <crimsondusk64@gmail.com>
parents: 226
diff changeset
257
249
6b2cc2d82ba6 Use QMutex for the thread locking, remove filename from the progress dialog since it's not known anyway
Santeri Piippo <crimsondusk64@gmail.com>
parents: 248
diff changeset
258 void OpenProgressDialog::updateValues () {
319
d0f41342ef51 Show values in file opening prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 315
diff changeset
259 progressText->setText( fmt( "Parsing... %1 / %2", progress(), numLines() ));
d0f41342ef51 Show values in file opening prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 315
diff changeset
260 progressBar->setValue( progress() );
248
4431371f3ffe Added a progress dialog for file loading to respond to desktops while loading files. With large files the no-response policy could be a bad thing. My first real use case of multi-threading...
Santeri Piippo <crimsondusk64@gmail.com>
parents: 226
diff changeset
261 }
4431371f3ffe Added a progress dialog for file loading to respond to desktops while loading files. With large files the no-response policy could be a bad thing. My first real use case of multi-threading...
Santeri Piippo <crimsondusk64@gmail.com>
parents: 226
diff changeset
262
249
6b2cc2d82ba6 Use QMutex for the thread locking, remove filename from the progress dialog since it's not known anyway
Santeri Piippo <crimsondusk64@gmail.com>
parents: 248
diff changeset
263 void OpenProgressDialog::updateProgress (int progress) {
248
4431371f3ffe Added a progress dialog for file loading to respond to desktops while loading files. With large files the no-response policy could be a bad thing. My first real use case of multi-threading...
Santeri Piippo <crimsondusk64@gmail.com>
parents: 226
diff changeset
264 m_progress = progress;
4431371f3ffe Added a progress dialog for file loading to respond to desktops while loading files. With large files the no-response policy could be a bad thing. My first real use case of multi-threading...
Santeri Piippo <crimsondusk64@gmail.com>
parents: 226
diff changeset
265 updateValues ();
198
f246725199dc Split some stuff into separate files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
266 }

mercurial