1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
|
/**********************************************************************
**
** Copyright (C) 2000-2008 Trolltech ASA. All rights reserved.
**
** This file is part of Qt Designer.
**
** This file may be used under the terms of the GNU General
** Public License versions 2.0 or 3.0 as published by the Free
** Software Foundation and appearing in the files LICENSE.GPL2
** and LICENSE.GPL3 included in the packaging of this file.
** Alternatively you may (at your option) use any later version
** of the GNU General Public License if such license has been
** publicly approved by Trolltech ASA (or its successors, if any)
** and the KDE Free Qt Foundation.
**
** Please review the following information to ensure GNU General
** Public Licensing requirements will be met:
** http://trolltech.com/products/qt/licenses/licensing/opensource/.
** If you are unsure which license is appropriate for your use, please
** review the following information:
** http://trolltech.com/products/qt/licenses/licensing/licensingoverview
** or contact the sales department at sales@trolltech.com.
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with
** the Software.
**
** This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted
** herein.
**
**********************************************************************/
void MainWindowWizardBase::init()
{
dIface = 0;
dfw = 0;
widget = 0;
setHelpEnabled( menuToolbarPage, FALSE );
setHelpEnabled( toolbarsPage, FALSE );
setHelpEnabled( finishPage, FALSE );
setFinishEnabled( finishPage, TRUE );
}
void MainWindowWizardBase::destroy()
{
if ( dIface )
dIface->release();
}
void MainWindowWizardBase::currentSettingChanged()
{
bool appr = checkFileToolbar->isChecked() || checkEditToolbar->isChecked() || checkHelpToolbar->isChecked();
setAppropriate( toolbarsPage, appr );
}
void MainWindowWizardBase::setupToolbarPage()
{
if ( checkFileToolbar->isChecked() )
comboToolbar->insertItem( tr( "File" ) );
if ( checkEditToolbar->isChecked() )
comboToolbar->insertItem( tr( "Edit" ) );
if ( checkHelpToolbar->isChecked() )
comboToolbar->insertItem( tr( "Help" ) );
}
void MainWindowWizardBase::toolbarActionDown()
{
if ( listToolbar->currentItem() < 0 || listToolbar->currentItem() >= (int)listToolbar->count() - 1 )
return;
int next = listToolbar->currentItem() + 1;
QString tmp = listToolbar->text( next );
listToolbar->changeItem( listToolbar->text( next - 1 ), next );
listToolbar->changeItem( tmp, next - 1 );
listToolbar->setCurrentItem( next );
}
void MainWindowWizardBase::toolbarActionUp()
{
if ( listToolbar->currentItem() < 1 || listToolbar->currentItem() > (int)listToolbar->count() - 1 )
return;
int prev = listToolbar->currentItem() - 1;
QString tmp = listToolbar->text( prev );
listToolbar->changeItem( listToolbar->text( prev + 1 ), prev );
listToolbar->changeItem( tmp, prev + 1 );
listToolbar->setCurrentItem( prev );
}
void MainWindowWizardBase::toolbarAddAction()
{
if ( listToolbarActions->text( listToolbarActions->currentItem() ).isEmpty() )
return;
listToolbar->insertItem( listToolbarActions->text( listToolbarActions->currentItem() ) );
listToolbar->setCurrentItem( listToolbar->count() - 1 );
listToolbarActions->setCurrentItem( listToolbarActions->currentItem() + 1 );
}
void MainWindowWizardBase::toolbarRemoveAction()
{
listToolbar->removeItem( listToolbar->currentItem() );
}
static void devNull( QtMsgType, const char * )
{
}
void MainWindowWizardBase::accept()
{
if ( !dfw || !dIface || !widget ) {
QWizard::accept();
return;
}
setFinishEnabled( finishPage, FALSE );
QPixmap pix;
QDict<QAction> actions;
QPtrList<QAction> usedActions;
QtMsgHandler oldMsgHandler = qInstallMsgHandler( devNull );
getPixmap( "filenew", pix );
QAction *fileNewAction = dfw->createAction( tr( "New" ), pix, tr( "&New" ), CTRL + Key_N, 0, "fileNewAction" );
actions.insert( tr( "New" ), fileNewAction );
getPixmap( "fileopen", pix );
QAction *fileOpenAction = dfw->createAction( tr( "Open" ), pix, tr( "&Open..." ), CTRL + Key_O, 0, "fileOpenAction" );
actions.insert( tr( "Open" ), fileOpenAction );
getPixmap( "filesave", pix );
QAction *fileSaveAction = dfw->createAction( tr( "Save" ), pix, tr( "&Save" ), CTRL + Key_S, 0, "fileSaveAction" );
actions.insert( tr( "Save" ), fileSaveAction );
QAction *fileSaveAsAction = dfw->createAction( tr( "Save As" ), QIconSet(), tr( "Save &As..." ), 0, 0, "fileSaveAsAction" );
actions.insert( tr( "Save As" ), fileSaveAsAction );
getPixmap( "print", pix );
QAction *filePrintAction = dfw->createAction( tr( "Print" ), pix, tr( "&Print..." ), CTRL + Key_P, 0, "filePrintAction" );
actions.insert( tr( "Print" ), filePrintAction );
QAction *fileExitAction = dfw->createAction( tr( "Exit" ), QIconSet(), tr( "E&xit" ), 0, 0, "fileExitAction" );
actions.insert( tr( "Exit" ), fileExitAction );
getPixmap( "undo", pix );
QAction *editUndoAction = dfw->createAction( tr( "Undo" ), pix, tr( "&Undo" ), CTRL + Key_Z, 0, "editUndoAction" );
actions.insert( tr( "Undo" ), editUndoAction );
getPixmap( "redo", pix );
QAction *editRedoAction = dfw->createAction( tr( "Redo" ), pix, tr( "&Redo" ), CTRL + Key_Y, 0, "editRedoAction" );
actions.insert( tr( "Redo" ), editRedoAction );
getPixmap( "editcut", pix );
QAction *editCutAction = dfw->createAction( tr( "Cut" ), pix, tr( "Cu&t" ), CTRL + Key_X, 0, "editCutAction" );
actions.insert( tr( "Cut" ), editCutAction );
getPixmap( "editcopy", pix );
QAction *editCopyAction = dfw->createAction( tr( "Copy" ), pix, tr( "&Copy" ), CTRL + Key_C, 0, "editCopyAction" );
actions.insert( tr( "Copy" ), editCopyAction );
getPixmap( "editpaste", pix );
QAction *editPasteAction = dfw->createAction( tr( "Paste" ), pix, tr( "&Paste" ), CTRL + Key_V, 0, "editPasteAction" );
actions.insert( tr( "Paste" ), editPasteAction );
getPixmap( "searchfind", pix );
QAction *editFindAction = dfw->createAction( tr( "Find" ), pix, tr( "&Find..." ), CTRL + Key_F, 0, "editFindAction" );
actions.insert( tr( "Find" ), editFindAction );
QAction *helpAboutAction = dfw->createAction( tr( "About" ), QIconSet(), tr( "&About" ), 0, 0, "helpAboutAction" );
actions.insert( tr( "About" ), helpAboutAction );
QAction *helpContentsAction = dfw->createAction( tr( "Contents" ), QIconSet(), tr( "&Contents..." ), 0, 0, "helpContentsAction" );
actions.insert( tr( "Contents" ), helpContentsAction );
QAction *helpIndexAction = dfw->createAction( tr( "Index" ), QIconSet(), tr( "&Index..." ), 0, 0, "helpIndexAction" );
actions.insert( tr( "Index" ), helpIndexAction );
if ( checkFileMenu->isChecked() ) {
dfw->addMenu( "&File", "fileMenu" );
dfw->addMenuAction( "fileMenu", fileNewAction );
dfw->addMenuAction( "fileMenu", fileOpenAction );
dfw->addMenuAction( "fileMenu", fileSaveAction );
dfw->addMenuAction( "fileMenu", fileSaveAsAction );
dfw->addMenuSeparator( "fileMenu" );
dfw->addMenuAction( "fileMenu", filePrintAction );
dfw->addMenuSeparator( "fileMenu" );
dfw->addMenuAction( "fileMenu", fileExitAction );
dfw->addAction( fileNewAction );
dfw->addAction( fileOpenAction );
dfw->addAction( fileSaveAction );
dfw->addAction( fileSaveAsAction );
dfw->addAction( filePrintAction );
dfw->addAction( fileExitAction );
usedActions.append( fileNewAction );
usedActions.append( fileOpenAction );
usedActions.append( fileSaveAction );
usedActions.append( fileSaveAsAction );
usedActions.append( filePrintAction );
usedActions.append( fileExitAction );
}
if ( checkEditMenu->isChecked() ) {
dfw->addMenu( "&Edit", "editMenu" );
dfw->addMenuAction( "editMenu", editUndoAction );
dfw->addMenuAction( "editMenu", editRedoAction );
dfw->addMenuSeparator( "editMenu" );
dfw->addMenuAction( "editMenu", editCutAction );
dfw->addMenuAction( "editMenu", editCopyAction );
dfw->addMenuAction( "editMenu", editPasteAction );
dfw->addMenuSeparator( "editMenu" );
dfw->addMenuAction( "editMenu", editFindAction );
dfw->addAction( editUndoAction );
dfw->addAction( editRedoAction );
dfw->addAction( editCutAction );
dfw->addAction( editCopyAction );
dfw->addAction( editPasteAction );
dfw->addAction( editFindAction );
usedActions.append( editUndoAction );
usedActions.append( editRedoAction );
usedActions.append( editCutAction );
usedActions.append( editCopyAction );
usedActions.append( editPasteAction );
usedActions.append( editFindAction );
}
if ( checkHelpMenu->isChecked() ) {
dfw->addMenu( "&Help", "helpMenu" );
dfw->addMenuAction( "helpMenu", helpContentsAction );
dfw->addMenuAction( "helpMenu", helpIndexAction );
dfw->addMenuSeparator( "helpMenu" );
dfw->addMenuAction( "helpMenu", helpAboutAction );
dfw->addAction( helpContentsAction );
dfw->addAction( helpIndexAction );
dfw->addAction( helpAboutAction );
usedActions.append( helpIndexAction );
usedActions.append( helpContentsAction );
usedActions.append( helpAboutAction );
}
if ( listToolbar->count() > 0 && appropriate( toolbarsPage ) ) {
dfw->addToolBar( "Tools", "toolBar" );
for ( int i = 0; i < (int)listToolbar->count(); ++i ) {
if ( listToolbar->text( i ) == tr( "<Separator>" ) ) {
dfw->addToolBarSeparator( "toolBar" );
continue;
}
QAction *a = actions.find( listToolbar->text( i ) );
if ( !a )
continue;
dfw->addToolBarAction( "toolBar", a );
dfw->addAction( a );
if ( usedActions.findRef( a ) == -1 )
usedActions.append( a );
}
}
for ( QAction *ac = usedActions.first(); ac; ac = usedActions.next() ) {
if ( ( QString( ac->name() ).find( "file" ) != -1 && checkCreateConnectionsFile->isChecked() ) ||
( QString( ac->name() ).find( "edit" ) != -1 && checkCreateConnectionsEdit->isChecked() ) ||
( QString( ac->name() ).find( "help" ) != -1 && checkCreateConnectionsHelp->isChecked() ) ) {
QString slot = ac->name();
slot.remove( slot.length() - 6, 6 );
slot += "()";
dfw->addFunction( slot.latin1(), "virtual", "public", "slot", dIface->currentProject()->language(), "void" );
dfw->addConnection( ac, "activated()", widget, slot );
}
}
qInstallMsgHandler( oldMsgHandler );
QWizard::accept();
}
void MainWindowWizardBase::currentToolbarChanged( const QString & s )
{
if ( s == tr( "File" ) ) {
listToolbarActions->clear();
listToolbarActions->insertItem( tr( "New" ) );
listToolbarActions->insertItem( tr( "Open" ) );
listToolbarActions->insertItem( tr( "Save" ) );
listToolbarActions->insertItem( tr( "Save As" ) );
listToolbarActions->insertItem( tr( "Print" ) );
listToolbarActions->insertItem( tr( "Exit" ) );
} else if ( s == tr( "Edit" ) ) {
listToolbarActions->clear();
listToolbarActions->insertItem( tr( "Undo" ) );
listToolbarActions->insertItem( tr( "Redo" ) );
listToolbarActions->insertItem( tr( "Cut" ) );
listToolbarActions->insertItem( tr( "Copy" ) );
listToolbarActions->insertItem( tr( "Paste" ) );
listToolbarActions->insertItem( tr( "Find" ) );
} else if ( s == tr( "Help" ) ) {
listToolbarActions->clear();
listToolbarActions->insertItem( tr( "Contents" ) );
listToolbarActions->insertItem( tr( "Index" ) );
listToolbarActions->insertItem( tr( "About" ) );
}
listToolbarActions->insertItem( "<Separator>" );
listToolbarActions->setCurrentItem( 0 );
}
void MainWindowWizardBase::getPixmap( const QString & n, QPixmap & pix )
{
QString name = n + ".png";
pix = QPixmap::fromMimeSource( name );
DesignerProject *pro = dIface->currentProject();
if ( !pro || pro->projectName() == "<No Project>" )
return;
pro->pixmapCollection()->addPixmap( pix, n, FALSE );
}
void MainWindowWizardBase::pageSelected( const QString & )
{
if ( currentPage() == toolbarsPage ) {
comboToolbar->clear();
setupToolbarPage();
listToolbarActions->clear();
currentToolbarChanged( comboToolbar->text( comboToolbar->currentItem() ) );
}
}
void MainWindowWizardBase::setAppInterface( QUnknownInterface * iface, DesignerFormWindow * fw, QWidget * w )
{
DesignerInterface *d = 0;
iface->queryInterface( IID_Designer, (QUnknownInterface**)&d );
dIface = d;
dfw = fw;
widget = w;
}
|