1
/**********************************************************************
2
** Copyright (C) 2000-2001 Trolltech AS. All rights reserved.
4
** This file is part of Qt Designer.
6
** This file may be distributed and/or modified under the terms of the
7
** GNU General Public License version 2 as published by the Free Software
8
** Foundation and appearing in the file LICENSE.GPL included in the
9
** packaging of this file.
11
** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
12
** licenses may use this file in accordance with the Qt Commercial License
13
** Agreement provided with the Software.
15
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
18
** See http://www.trolltech.com/gpl/ for GPL licensing information.
19
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
20
** information about Qt Commercial License Agreements.
22
** Contact info@trolltech.com if any conditions of this licensing are
25
**********************************************************************/
27
#include "mainwindow.h"
29
#include <kiconloader.h>
30
#include <kfiledialog.h>
35
#include <qwhatsthis.h>
36
#include <qpopupmenu.h>
38
#include <qlineedit.h>
40
#include <qapplication.h>
41
#include <qsignalmapper.h>
42
#include <qstylefactory.h>
43
#include <qworkspace.h>
44
#include <qmessagebox.h>
45
#include <qstatusbar.h>
47
#include <qclipboard.h>
48
#include <qcombobox.h>
50
#include <qinputdialog.h>
51
#include <qdatetimeedit.h>
52
#include <qtextedit.h>
56
#include "widgetdatabase.h"
57
#include "widgetfactory.h"
58
#include "preferences.h"
59
#include "formwindow.h"
60
#include "newformimpl.h"
62
#include "projectsettingsimpl.h"
63
#include "workspace.h"
64
#include "createtemplate.h"
65
#include "hierarchyview.h"
66
#include "editfunctionsimpl.h"
67
#include "finddialog.h"
68
#include "replacedialog.h"
69
#include "gotolinedialog.h"
70
#include "formsettingsimpl.h"
71
#include "pixmapcollectioneditor.h"
72
#include "styledbutton.h"
73
#include "customwidgeteditorimpl.h"
75
#include "dbconnectionsimpl.h"
76
#include "dbconnectionimpl.h"
78
#include "widgetaction.h"
80
#include "startdialogimpl.h"
81
#include "designerappiface.h"
82
#include "connectiondialog.h"
83
#include "configtoolboxdialog.h"
84
#include "designeraction.h"
86
#include "kdevdesigner_part.h"
88
static const char * whatsthis_image[] = {
110
const QString toolbarHelp = "<p>Toolbars contain a number of buttons to "
111
"provide quick access to often used functions.%1"
112
"<br>Click on the toolbar handle to hide the toolbar, "
113
"or drag and place the toolbar to a different location.</p>";
115
static QIconSet createIconSet( const QString &name )
117
QIconSet ic( BarIcon( "" + name, KDevDesignerPartFactory::instance() ) );
118
QString prefix = "designer_";
119
int right = name.length() - prefix.length();
120
ic.setPixmap( BarIcon( prefix + "d_" + name.right( right ), KDevDesignerPartFactory::instance() ),
121
QIconSet::Small, QIconSet::Disabled );
125
void MainWindow::setupEditActions()
127
actionEditUndo = new DesignerAction( i18n("Undo"), createIconSet( "designer_undo.png" ),i18n("&Undo: Not Available"), CTRL + Key_Z, this, 0 );
128
actionEditUndo->setStatusTip( i18n( "Undoes the last action" ) );
129
actionEditUndo->setWhatsThis( whatsThisFrom( "Edit|Undo" ) );
130
connect( actionEditUndo, SIGNAL( activated() ), this, SLOT( editUndo() ) );
131
actionEditUndo->setEnabled( FALSE );
133
actionEditRedo = new DesignerAction( i18n( "Redo" ), createIconSet("designer_redo.png"), i18n( "&Redo: Not Available" ), CTRL + Key_Y, this, 0 );
134
actionEditRedo->setStatusTip( i18n( "Redoes the last undone operation") );
135
actionEditRedo->setWhatsThis( whatsThisFrom( "Edit|Redo" ) );
136
connect( actionEditRedo, SIGNAL( activated() ), this, SLOT( editRedo() ) );
137
actionEditRedo->setEnabled( FALSE );
139
actionEditCut = new DesignerAction( i18n( "Cut" ), createIconSet("designer_editcut.png"), i18n( "Cu&t" ), CTRL + Key_X, this, 0 );
140
actionEditCut->setStatusTip( i18n( "Cuts the selected widgets and puts them on the clipboard" ) );
141
actionEditCut->setWhatsThis( whatsThisFrom( "Edit|Cut" ) );
142
connect( actionEditCut, SIGNAL( activated() ), this, SLOT( editCut() ) );
143
actionEditCut->setEnabled( FALSE );
145
actionEditCopy = new DesignerAction( i18n( "Copy" ), createIconSet("designer_editcopy.png"), i18n( "&Copy" ), CTRL + Key_C, this, 0 );
146
actionEditCopy->setStatusTip( i18n( "Copies the selected widgets to the clipboard" ) );
147
actionEditCopy->setWhatsThis( whatsThisFrom( "Edit|Copy" ) );
148
connect( actionEditCopy, SIGNAL( activated() ), this, SLOT( editCopy() ) );
149
actionEditCopy->setEnabled( FALSE );
151
actionEditPaste = new DesignerAction( i18n( "Paste" ), createIconSet("designer_editpaste.png"), i18n( "&Paste" ), CTRL + Key_V, this, 0 );
152
actionEditPaste->setStatusTip( i18n( "Pastes the clipboard's contents" ) );
153
actionEditPaste->setWhatsThis( whatsThisFrom( "Edit|Paste" ) );
154
connect( actionEditPaste, SIGNAL( activated() ), this, SLOT( editPaste() ) );
155
actionEditPaste->setEnabled( FALSE );
157
actionEditDelete = new DesignerAction( i18n( "Delete" ), QPixmap(), i18n( "&Delete" ), Key_Delete, this, 0 );
158
actionEditDelete->setStatusTip( i18n( "Deletes the selected widgets" ) );
159
actionEditDelete->setWhatsThis( whatsThisFrom( "Edit|Delete" ) );
160
connect( actionEditDelete, SIGNAL( activated() ), this, SLOT( editDelete() ) );
161
actionEditDelete->setEnabled( FALSE );
163
QAction *macDelete = new DesignerAction( i18n( "Delete" ), QPixmap(), i18n( "&Delete" ), Key_Backspace, this, 0 );
164
connect( macDelete, SIGNAL( activated() ), this, SLOT( editDelete() ) );
167
actionEditSelectAll = new DesignerAction( i18n( "Select All" ), QPixmap(), i18n( "Select &All" ), CTRL + Key_A, this, 0 );
168
actionEditSelectAll->setStatusTip( i18n( "Selects all widgets" ) );
169
actionEditSelectAll->setWhatsThis( whatsThisFrom( "Edit|Select All" ) );
170
connect( actionEditSelectAll, SIGNAL( activated() ), this, SLOT( editSelectAll() ) );
171
actionEditSelectAll->setEnabled( TRUE );
173
actionEditRaise = new DesignerAction( i18n( "Bring to Front" ), createIconSet("designer_editraise.png"), i18n( "Bring to &Front" ), 0, this, 0 );
174
actionEditRaise->setStatusTip( i18n( "Raises the selected widgets" ) );
175
actionEditRaise->setWhatsThis( i18n( "Raises the selected widgets" ) );
176
connect( actionEditRaise, SIGNAL( activated() ), this, SLOT( editRaise() ) );
177
actionEditRaise->setEnabled( FALSE );
179
actionEditLower = new DesignerAction( i18n( "Send to Back" ), createIconSet("designer_editlower.png"), i18n( "Send to &Back" ), 0, this, 0 );
180
actionEditLower->setStatusTip( i18n( "Lowers the selected widgets" ) );
181
actionEditLower->setWhatsThis( i18n( "Lowers the selected widgets" ) );
182
connect( actionEditLower, SIGNAL( activated() ), this, SLOT( editLower() ) );
183
actionEditLower->setEnabled( FALSE );
185
actionEditAccels = new DesignerAction( i18n( "Check Accelerators" ), QPixmap(),
186
i18n( "Chec&k Accelerators" ), ALT + Key_R, this, 0 );
187
actionEditAccels->setStatusTip( i18n("Checks if the accelerators used in the form are unique") );
188
actionEditAccels->setWhatsThis( whatsThisFrom( "Edit|Check Accelerator" ) );
189
connect( actionEditAccels, SIGNAL( activated() ), this, SLOT( editAccels() ) );
190
connect( this, SIGNAL( hasActiveForm(bool) ), actionEditAccels, SLOT( setEnabled(bool) ) );
192
actionEditFunctions = new DesignerAction( i18n( "Slots" ), createIconSet("designer_editslots.png"),
193
i18n( "S&lots..." ), 0, this, 0 );
194
actionEditFunctions->setStatusTip( i18n("Opens a dialog for editing slots") );
195
actionEditFunctions->setWhatsThis( whatsThisFrom( "Edit|Slots" ) );
196
connect( actionEditFunctions, SIGNAL( activated() ), this, SLOT( editFunctions() ) );
197
connect( this, SIGNAL( hasActiveForm(bool) ), actionEditFunctions, SLOT( setEnabled(bool) ) );
199
actionEditConnections = new DesignerAction( i18n( "Connections" ), createIconSet("designer_connecttool.png"),
200
i18n( "Co&nnections..." ), 0, this, 0 );
201
actionEditConnections->setStatusTip( i18n("Opens a dialog for editing connections") );
202
actionEditConnections->setWhatsThis( whatsThisFrom( "Edit|Connections" ) );
203
connect( actionEditConnections, SIGNAL( activated() ), this, SLOT( editConnections() ) );
204
connect( this, SIGNAL( hasActiveForm(bool) ), actionEditConnections, SLOT( setEnabled(bool) ) );
206
actionEditSource = new DesignerAction( i18n( "Source" ), QIconSet(),
207
i18n( "&Source..." ), CTRL + Key_E, this, 0 );
208
actionEditSource->setStatusTip( i18n("Opens an editor to edit the form's source code") );
209
actionEditSource->setWhatsThis( whatsThisFrom( "Edit|Source" ) );
210
connect( actionEditSource, SIGNAL( activated() ), this, SLOT( editSource() ) );
211
connect( this, SIGNAL( hasActiveForm(bool) ), actionEditSource, SLOT( setEnabled(bool) ) );
213
actionEditFormSettings = new DesignerAction( i18n( "Form Settings" ), QPixmap(),
214
i18n( "&Form Settings..." ), 0, this, 0 );
215
actionEditFormSettings->setStatusTip( i18n("Opens a dialog to change the form's settings") );
216
actionEditFormSettings->setWhatsThis( whatsThisFrom( "Edit|Form Settings" ) );
217
connect( actionEditFormSettings, SIGNAL( activated() ), this, SLOT( editFormSettings() ) );
218
connect( this, SIGNAL( hasActiveForm(bool) ), actionEditFormSettings, SLOT( setEnabled(bool) ) );
220
actionEditPreferences = new DesignerAction( i18n( "Preferences" ), QPixmap(),
221
i18n( "Preferences..." ), 0, this, 0 );
222
actionEditPreferences->setStatusTip( i18n("Opens a dialog to change preferences") );
223
actionEditPreferences->setWhatsThis( whatsThisFrom( "Edit|Preferences" ) );
224
connect( actionEditPreferences, SIGNAL( activated() ), this, SLOT( editPreferences() ) );
226
/* QToolBar *tb = new QToolBar( this, "Edit" );
227
tb->setCloseMode( QDockWindow::Undocked );
228
QWhatsThis::add( tb, i18n( "<b>The Edit toolbar</b>%1").arg(i18n(toolbarHelp).arg("")) );
229
addToolBar( tb, i18n( "Edit" ) );
230
actionEditUndo->addTo( tb );
231
actionEditRedo->addTo( tb );
233
actionEditCut->addTo( tb );
234
actionEditCopy->addTo( tb );
235
actionEditPaste->addTo( tb );*/
238
actionEditLower->addTo( tb );
239
actionEditRaise->addTo( tb );
242
QPopupMenu *menu = new QPopupMenu( this, "Edit" );
243
connect( menu, SIGNAL( aboutToShow() ), this, SLOT( updateEditorUndoRedo() ) );
244
menubar->insertItem( i18n( "&Edit" ), menu );
245
actionEditUndo->addTo( menu );
246
actionEditRedo->addTo( menu );
247
menu->insertSeparator();
248
actionEditCut->addTo( menu );
249
actionEditCopy->addTo( menu );
250
actionEditPaste->addTo( menu );
251
actionEditDelete->addTo( menu );
252
actionEditSelectAll->addTo( menu );
253
actionEditAccels->addTo( menu );
255
menu->insertSeparator();
256
actionEditLower->addTo( menu );
257
actionEditRaise->addTo( menu );
259
menu->insertSeparator();
260
if ( !singleProjectMode() ) {
261
actionEditFunctions->addTo( menu );
262
actionEditConnections->addTo( menu );
264
actionEditFormSettings->addTo( menu );
265
menu->insertSeparator();
266
actionEditPreferences->addTo( menu );
269
void MainWindow::setupSearchActions()
271
actionSearchFind = new DesignerAction( i18n( "Find" ), createIconSet( "designer_searchfind.png" ),
272
i18n( "&Find..." ), CTRL + Key_F, this, 0 );
273
connect( actionSearchFind, SIGNAL( activated() ), this, SLOT( searchFind() ) );
274
actionSearchFind->setEnabled( FALSE );
275
actionSearchFind->setWhatsThis( whatsThisFrom( "Search|Find" ) );
277
actionSearchIncremetal = new DesignerAction( i18n( "Find Incremental" ), QIconSet(),
278
i18n( "Find &Incremental" ), ALT + Key_I, this, 0 );
279
connect( actionSearchIncremetal, SIGNAL( activated() ), this, SLOT( searchIncremetalFindMenu() ) );
280
actionSearchIncremetal->setEnabled( FALSE );
281
actionSearchIncremetal->setWhatsThis( whatsThisFrom( "Search|Find Incremental" ) );
283
actionSearchReplace = new DesignerAction( i18n( "Replace" ), QIconSet(),
284
i18n( "&Replace..." ), CTRL + Key_R, this, 0 );
285
connect( actionSearchReplace, SIGNAL( activated() ), this, SLOT( searchReplace() ) );
286
actionSearchReplace->setEnabled( FALSE );
287
actionSearchReplace->setWhatsThis( whatsThisFrom( "Search|Replace" ) );
289
actionSearchGotoLine = new DesignerAction( i18n( "Goto Line" ), QIconSet(),
290
i18n( "&Goto Line..." ), ALT + Key_G, this, 0 );
291
connect( actionSearchGotoLine, SIGNAL( activated() ), this, SLOT( searchGotoLine() ) );
292
actionSearchGotoLine->setEnabled( FALSE );
293
actionSearchGotoLine->setWhatsThis( whatsThisFrom( "Search|Goto line" ) );
295
/* QToolBar *tb = new QToolBar( this, "Search" );
296
tb->setCloseMode( QDockWindow::Undocked );
297
addToolBar( tb, i18n( "Search" ) );
299
actionSearchFind->addTo( tb );*/
300
incrementalSearch = new QLineEdit( 0 );
301
incrementalSearch->hide();
302
QToolTip::add( incrementalSearch, i18n( "Incremental search (Alt+I)" ) );
303
connect( incrementalSearch, SIGNAL( textChanged( const QString & ) ),
304
this, SLOT( searchIncremetalFind() ) );
305
connect( incrementalSearch, SIGNAL( returnPressed() ),
306
this, SLOT( searchIncremetalFindNext() ) );
307
incrementalSearch->setEnabled( FALSE );
309
QPopupMenu *menu = new QPopupMenu( this, "Search" );
310
menubar->insertItem( i18n( "&Search" ), menu );
311
actionSearchFind->addTo( menu );
312
actionSearchIncremetal->addTo( menu );
313
actionSearchReplace->addTo( menu );
314
menu->insertSeparator();
315
actionSearchGotoLine->addTo( menu );
318
void MainWindow::setupLayoutActions()
320
if ( !actionGroupTools ) {
321
actionGroupTools = new QActionGroup( this );
322
actionGroupTools->setExclusive( TRUE );
323
connect( actionGroupTools, SIGNAL( selected(QAction*) ), this, SLOT( toolSelected(QAction*) ) );
326
actionEditAdjustSize = new DesignerAction( i18n( "Adjust Size" ), createIconSet("designer_adjustsize.png"),
327
i18n( "Adjust &Size" ), CTRL + Key_J, this, 0 );
328
actionEditAdjustSize->setStatusTip(i18n("Adjusts the size of the selected widget") );
329
actionEditAdjustSize->setWhatsThis( whatsThisFrom( "Layout|Adjust Size" ) );
330
connect( actionEditAdjustSize, SIGNAL( activated() ), this, SLOT( editAdjustSize() ) );
331
actionEditAdjustSize->setEnabled( FALSE );
333
actionEditHLayout = new DesignerAction( i18n( "Lay Out Horizontally" ), createIconSet("designer_edithlayout.png"),
334
i18n( "Lay Out &Horizontally" ), CTRL + Key_H, this, 0 );
335
actionEditHLayout->setStatusTip(i18n("Lays out the selected widgets horizontally") );
336
actionEditHLayout->setWhatsThis( whatsThisFrom( "Layout|Lay Out Horizontally" ) );
337
connect( actionEditHLayout, SIGNAL( activated() ), this, SLOT( editLayoutHorizontal() ) );
338
actionEditHLayout->setEnabled( FALSE );
340
actionEditVLayout = new DesignerAction( i18n( "Lay Out Vertically" ), createIconSet("designer_editvlayout.png"),
341
i18n( "Lay Out &Vertically" ), CTRL + Key_L, this, 0 );
342
actionEditVLayout->setStatusTip(i18n("Lays out the selected widgets vertically") );
343
actionEditVLayout->setWhatsThis( whatsThisFrom( "Layout|Lay Out Vertically" ) );
344
connect( actionEditVLayout, SIGNAL( activated() ), this, SLOT( editLayoutVertical() ) );
345
actionEditVLayout->setEnabled( FALSE );
347
actionEditGridLayout = new DesignerAction( i18n( "Lay Out in a Grid" ), createIconSet("designer_editgrid.png"),
348
i18n( "Lay Out in a &Grid" ), CTRL + Key_G, this, 0 );
349
actionEditGridLayout->setStatusTip(i18n("Lays out the selected widgets in a grid") );
350
actionEditGridLayout->setWhatsThis( whatsThisFrom( "Layout|Lay Out in a Grid" ) );
351
connect( actionEditGridLayout, SIGNAL( activated() ), this, SLOT( editLayoutGrid() ) );
352
actionEditGridLayout->setEnabled( FALSE );
354
actionEditSplitHorizontal = new DesignerAction( i18n( "Lay Out Horizontally (in Splitter)" ), createIconSet("designer_editvlayoutsplit.png"),
355
i18n( "Lay Out Horizontally (in S&plitter)" ), 0, this, 0 );
356
actionEditSplitHorizontal->setStatusTip(i18n("Lays out the selected widgets horizontally in a splitter") );
357
actionEditSplitHorizontal->setWhatsThis( whatsThisFrom( "Layout|Lay Out Horizontally (in Splitter)" ) );
358
connect( actionEditSplitHorizontal, SIGNAL( activated() ), this, SLOT( editLayoutHorizontalSplit() ) );
359
actionEditSplitHorizontal->setEnabled( FALSE );
361
actionEditSplitVertical = new DesignerAction( i18n( "Lay Out Vertically (in Splitter)" ), createIconSet("designer_edithlayoutsplit.png"),
362
i18n( "Lay Out Vertically (in Sp&litter)" ), 0, this, 0 );
363
actionEditSplitVertical->setStatusTip(i18n("Lays out the selected widgets vertically in a splitter") );
364
actionEditSplitVertical->setWhatsThis( whatsThisFrom( "Layout|Lay Out Vertically (in Splitter)" ) );
365
connect( actionEditSplitVertical, SIGNAL( activated() ), this, SLOT( editLayoutVerticalSplit() ) );
366
actionEditSplitVertical->setEnabled( FALSE );
368
actionEditBreakLayout = new DesignerAction( i18n( "Break Layout" ), createIconSet("designer_editbreaklayout.png"),
369
i18n( "&Break Layout" ), CTRL + Key_B, this, 0 );
370
actionEditBreakLayout->setStatusTip(i18n("Breaks the selected layout") );
371
actionEditBreakLayout->setWhatsThis( whatsThisFrom( "Layout|Break Layout" ) );
372
connect( actionEditBreakLayout, SIGNAL( activated() ), this, SLOT( editBreakLayout() ) );
373
actionEditBreakLayout->setEnabled( FALSE );
375
int id = WidgetDatabase::idFromClassName( "Spacer" );
376
actionInsertSpacer = new WidgetAction( i18n( "Layout" ), actionGroupTools, QString::number( id ).latin1() );
377
actionInsertSpacer->setToggleAction( TRUE );
378
actionInsertSpacer->setText( WidgetDatabase::className( id ) );
379
actionInsertSpacer->setMenuText( i18n( "Add %1").arg( WidgetDatabase::className( id ) ) );
380
actionInsertSpacer->setIconSet( WidgetDatabase::iconSet( id ) );
381
actionInsertSpacer->setToolTip( WidgetDatabase::toolTip( id ) );
382
actionInsertSpacer->setStatusTip( i18n( "Insert a %1").arg(WidgetDatabase::toolTip( id )) );
383
actionInsertSpacer->setWhatsThis( i18n("<b>A %1</b><p>%2</p>"
384
"<p>Click to insert a single %3,"
385
"or double click to keep the tool selected.")
386
.arg(WidgetDatabase::toolTip( id ))
387
.arg(WidgetDatabase::whatsThis( id ))
388
.arg(WidgetDatabase::toolTip( id ) ));
390
actionInsertSpacer->addTo( commonWidgetsToolBar );
391
commonWidgetsPage.append( actionInsertSpacer );
393
commonWidgetsToolBar->setStretchableWidget( ( w = new QWidget( commonWidgetsToolBar ) ) );
394
w->setBackgroundMode( commonWidgetsToolBar->backgroundMode() );
395
QWhatsThis::add( layoutToolBar, i18n( "<b>The Layout toolbar</b>%1" ).arg(i18n(toolbarHelp).arg("")) );
396
actionEditAdjustSize->addTo( layoutToolBar );
397
layoutToolBar->addSeparator();
398
actionEditHLayout->addTo( layoutToolBar );
399
actionEditVLayout->addTo( layoutToolBar );
400
actionEditGridLayout->addTo( layoutToolBar );
401
actionEditSplitHorizontal->addTo( layoutToolBar );
402
actionEditSplitVertical->addTo( layoutToolBar );
403
actionEditBreakLayout->addTo( layoutToolBar );
404
layoutToolBar->addSeparator();
405
actionInsertSpacer->addTo( layoutToolBar );
407
QPopupMenu *menu = new QPopupMenu( this, "Layout" );
409
menubar->insertItem( i18n( "&Layout" ), menu, toolsMenuId + 1 );
410
actionEditAdjustSize->addTo( menu );
411
menu->insertSeparator();
412
actionEditHLayout->addTo( menu );
413
actionEditVLayout->addTo( menu );
414
actionEditGridLayout->addTo( menu );
415
actionEditSplitHorizontal->addTo( menu );
416
actionEditSplitVertical->addTo( menu );
417
actionEditBreakLayout->addTo( menu );
418
menu->insertSeparator();
419
actionInsertSpacer->addTo( menu );
422
void MainWindow::setupToolActions()
424
if ( !actionGroupTools ) {
425
actionGroupTools = new QActionGroup( this );
426
actionGroupTools->setExclusive( TRUE );
427
connect( actionGroupTools, SIGNAL( selected(QAction*) ),
428
this, SLOT( toolSelected(QAction*) ) );
431
actionPointerTool = new DesignerAction( i18n("Pointer"), createIconSet("designer_pointer.png"),
432
i18n("&Pointer"), Key_F2,
434
QString::number(POINTER_TOOL).latin1(), TRUE );
435
actionPointerTool->setStatusTip( i18n("Selects the pointer tool") );
436
actionPointerTool->setWhatsThis( whatsThisFrom( "Tools|Pointer" ) );
438
actionConnectTool = new DesignerAction( i18n("Connect Signal/Slots"),
439
createIconSet("designer_connecttool.png"),
440
i18n("&Connect Signal/Slots"),
441
singleProjectMode() ? 0 : Key_F3,
443
QString::number(CONNECT_TOOL).latin1(), TRUE );
444
actionConnectTool->setStatusTip( i18n("Selects the connection tool") );
445
actionConnectTool->setWhatsThis( whatsThisFrom( "Tools|Connect Signals and Slots" ) );
447
actionOrderTool = new DesignerAction( i18n("Tab Order"), createIconSet("designer_ordertool.png"),
448
i18n("Tab &Order"), Key_F4,
450
QString::number(ORDER_TOOL).latin1(), TRUE );
451
actionOrderTool->setStatusTip( i18n("Selects the tab order tool") );
452
actionOrderTool->setWhatsThis( whatsThisFrom( "Tools|Tab Order" ) );
454
actionBuddyTool = new DesignerAction( i18n( "Set Buddy" ), createIconSet( "designer_setbuddy.png" ),
455
i18n( "Set &Buddy" ), Key_F12,
456
actionGroupTools, QString::number( BUDDY_TOOL ).latin1(),
458
actionBuddyTool->setStatusTip( i18n( "Sets a buddy to a label" ) );
459
actionBuddyTool->setWhatsThis( whatsThisFrom( "Tools|Set Buddy" ) );
461
QToolBar *tb = new QToolBar( this, "Tools" );
462
tb->setCloseMode( QDockWindow::Undocked );
464
QWhatsThis::add( tb, i18n( "<b>The Tools toolbar</b>%1" ).arg(i18n(toolbarHelp).arg("")) );
466
addToolBar( tb, i18n( "Tools" ), QMainWindow::DockTop, FALSE );
467
actionPointerTool->addTo( tb );
468
if ( !singleProjectMode() )
469
actionConnectTool->addTo( tb );
470
actionOrderTool->addTo( tb );
471
actionBuddyTool->addTo( tb );
473
QPopupMenu *mmenu = new QPopupMenu( this, "Tools" );
476
menubar->insertItem( i18n( "&Tools" ), mmenu, toolsMenuId );
477
toolsMenuIndex = menubar->indexOf( toolsMenuId );
478
actionPointerTool->addTo( mmenu );
479
if ( !singleProjectMode() )
480
actionConnectTool->addTo( mmenu );
481
actionOrderTool->addTo( mmenu );
482
actionBuddyTool->addTo( mmenu );
483
mmenu->insertSeparator();
485
customWidgetToolBar = 0;
486
customWidgetMenu = 0;
488
actionToolsCustomWidget = new DesignerAction( i18n("Custom Widgets"),
489
createIconSet( "designer_customwidget.png" ),
490
i18n("Edit &Custom Widgets..."), 0, this, 0 );
491
actionToolsCustomWidget->setStatusTip( i18n("Opens a dialog to add and change "
493
actionToolsCustomWidget->setWhatsThis( whatsThisFrom( "Tools|Custom|Edit Custom"
495
connect( actionToolsCustomWidget, SIGNAL( activated() ),
496
this, SLOT( toolsCustomWidget() ) );
498
for ( int j = 0; j < WidgetDatabase::numWidgetGroups(); ++j ) {
499
QString grp = WidgetDatabase::widgetGroup( j );
500
if ( !WidgetDatabase::isGroupVisible( grp ) ||
501
WidgetDatabase::isGroupEmpty( grp ) )
503
QToolBar *tb = new QToolBar( this, grp.latin1() );
504
tb->setCloseMode( QDockWindow::Undocked );
505
widgetToolBars.append( tb );
506
bool plural = grp[(int)grp.length()-1] == 's';
508
QWhatsThis::add( tb, i18n( "<b>The %1</b>%2" ).arg(grp).arg(i18n(toolbarHelp).
509
arg( i18n(" Click on a button to insert a single widget, "
510
"or double click to insert multiple %1.") ).arg(grp)) );
512
QWhatsThis::add( tb, i18n( "<b>The %1 Widgets</b>%2" ).arg(grp).arg(i18n(toolbarHelp).
513
arg( i18n(" Click on a button to insert a single %1 widget, "
514
"or double click to insert multiple widgets.") ).arg(grp)) );
516
addToolBar( tb, grp );
518
QPopupMenu *menu = new QPopupMenu( this, grp.latin1() );
519
mmenu->insertItem( grp, menu );
521
QToolBar *tb2 = new QToolBar( grp, 0, toolBox, FALSE, grp.latin1() );
522
tb2->setFrameStyle( QFrame::NoFrame );
523
tb2->setOrientation( Qt::Vertical );
524
tb2->setBackgroundMode( PaletteBase );
525
toolBox->addItem( tb2, grp );
527
if ( grp == "Custom" ) {
528
if ( !customWidgetMenu )
529
actionToolsCustomWidget->addTo( menu );
531
menu->insertSeparator();
532
customWidgetMenu = menu;
533
customWidgetToolBar = tb;
536
for ( int i = 0; i < WidgetDatabase::count(); ++i ) {
537
if ( WidgetDatabase::group( i ) != grp )
538
continue; // only widgets, i.e. not forms and temp stuff
540
new WidgetAction( grp, actionGroupTools, QString::number( i ).latin1() );
541
a->setToggleAction( TRUE );
542
QString atext = WidgetDatabase::className( i );
543
if ( atext[0] == 'Q' )
544
atext = atext.mid(1);
545
while ( atext.length() && atext[0] >= 'a' && atext[0] <= 'z' )
546
atext = atext.mid(1);
547
if ( atext.isEmpty() )
548
atext = WidgetDatabase::className( i );
550
QString ttip = WidgetDatabase::toolTip( i );
551
a->setIconSet( WidgetDatabase::iconSet( i ) );
552
a->setToolTip( ttip );
553
if ( !WidgetDatabase::isWhatsThisLoaded() )
554
WidgetDatabase::loadWhatsThis( documentationPath() );
555
a->setStatusTip( i18n( "Insert a %1").arg(WidgetDatabase::className( i )) );
557
QString whats = i18n("<b>A %1</b>").arg( WidgetDatabase::className( i ) );
558
if ( !WidgetDatabase::whatsThis( i ).isEmpty() )
559
whats += QString("<p>%1</p>").arg(WidgetDatabase::whatsThis( i ));
560
a->setWhatsThis( whats+ i18n("<p>Double click on this tool to keep it selected.</p>") );
566
if ( WidgetDatabase::isCommon( i ) ) {
567
a->addTo( commonWidgetsToolBar );
568
commonWidgetsPage.append( a );
572
tb2->setStretchableWidget( ( w = new QWidget( tb2 ) ) );
573
w->setBackgroundMode( tb2->backgroundMode() );
576
if ( !customWidgetToolBar ) {
577
QToolBar *tb = new QToolBar( this, "Custom Widgets" );
578
tb->setCloseMode( QDockWindow::Undocked );
579
QWhatsThis::add( tb, i18n( "<b>The Custom Widgets toolbar</b>%1"
580
"<p>Click <b>Edit Custom Widgets...</b>"
581
"in the <b>Tools|Custom</b> menu to "
582
"add and change custom widgets</p>" ).
583
arg(i18n(toolbarHelp).
584
arg( i18n(" Click on the buttons to insert a single widget, "
585
"or double click to insert multiple widgets.") )) );
586
addToolBar( tb, i18n( "Custom" ) );
588
widgetToolBars.append( tb );
589
customWidgetToolBar = tb;
590
QPopupMenu *menu = new QPopupMenu( this, "Custom Widgets" );
591
mmenu->insertItem( "Custom", menu );
592
customWidgetMenu = menu;
593
customWidgetToolBar->hide();
594
actionToolsCustomWidget->addTo( customWidgetMenu );
595
customWidgetMenu->insertSeparator();
596
QToolBar *tb2 = new QToolBar( "Custom Widgets", 0,
597
toolBox, FALSE, "Custom Widgets" );
598
tb2->setBackgroundMode(PaletteBase);
599
tb2->setOrientation( Qt::Vertical );
600
tb2->setFrameStyle( QFrame::NoFrame );
601
toolBox->addItem( tb2, "Custom Widgets" );
602
customWidgetToolBar2 = tb2;
605
QAction *a = new DesignerAction( i18n( "Configure Toolbox" ), i18n( "Configure Toolbox..." ), 0, this );
606
a->setStatusTip( i18n( "Opens a dialog to configure the common "
607
"widgets page of the toolbox") );
608
connect( a, SIGNAL( activated() ), this, SLOT( toolsConfigure() ) );
609
mmenu->insertSeparator();
614
void MainWindow::setupFileActions()
616
QToolBar* tb = new QToolBar( this, "File" );
617
tb->setCloseMode( QDockWindow::Undocked );
620
QWhatsThis::add( tb, i18n( "<b>The File toolbar</b>%1" ).arg(i18n(toolbarHelp).arg("")) );
621
addToolBar( tb, i18n( "File" ) );
622
fileMenu = new QPopupMenu( this, "File" );
623
menubar->insertItem( i18n( "&File" ), fileMenu );
625
DesignerAction *a = 0;
627
if ( !singleProject ) {
628
DesignerAction *a = new DesignerAction( this, 0 );
629
a->setText( i18n( "New" ) );
630
a->setToolTip( i18n( "New dialog or file" ) );
631
a->setMenuText( i18n( "&New..." ) );
632
a->setIconSet( createIconSet("designer_filenew.png") );
633
a->setAccel( CTRL + Key_N );
634
a->setStatusTip( i18n( "Creates a new project, form or source file." ) );
635
a->setWhatsThis( whatsThisFrom( "File|New" ) );
636
connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) );
638
a->addTo( fileMenu );
641
actionGroupNew = new QActionGroup( this, 0, FALSE );
642
QActionGroup* a = actionGroupNew;
643
( (QActionGroup*)a )->setUsesDropDown( TRUE );
644
a->setText( i18n( "New" ) );
645
a->setMenuText( i18n( "&New..." ) );
646
a->setIconSet( createIconSet("designer_form.png") );
647
a->setStatusTip( i18n( "Creates a new dialog or file" ) );
648
a->setWhatsThis( whatsThisFrom( "File|New" ) );
650
QAction *newForm = new DesignerAction( a, 0 );
651
newForm->setText( i18n( "New Dialog" ) );
652
newForm->setMenuText( i18n( "&Dialog..." ) );
653
newForm->setIconSet( createIconSet("designer_form.png") );
654
newForm->setAccel( CTRL + Key_N );
655
newForm->setStatusTip( i18n( "Creates a new dialog." ) );
656
connect( newForm, SIGNAL( activated() ), this, SLOT( fileNewDialog() ) );
658
DesignerAction *newFile = new DesignerAction( a, 0 );
659
newFile->setText( i18n( "New File" ) );
660
newFile->setMenuText( i18n( "&File..." ) );
661
newFile->setIconSet( createIconSet("designer_filenew.png") );
662
newFile->setAccel( ALT + Key_N );
663
newFile->setStatusTip( i18n( "Creates a new file." ) );
664
connect( newFile, SIGNAL( activated() ), this, SLOT( fileNewFile() ) );
665
actionNewFile = newFile;
668
a->addTo( fileMenu );
670
fileMenu->insertSeparator();
673
a = new DesignerAction( this, 0 );
674
a->setText( i18n( "Open" ) );
675
a->setMenuText( i18n( "&Open..." ) );
676
a->setIconSet( createIconSet("designer_fileopen.png") );
677
a->setAccel( CTRL + Key_O );
678
a->setStatusTip( i18n( "Opens an existing project, form or source file ") );
679
a->setWhatsThis( whatsThisFrom( "File|Open" ) );
680
connect( a, SIGNAL( activated() ), this, SLOT( fileOpen() ) );
681
if ( !singleProject ) {
683
a->addTo( fileMenu );
684
fileMenu->insertSeparator();
688
a = new DesignerAction( this, 0 );
690
a->setText( i18n( "Close" ) );
691
a->setMenuText( i18n( "&Close" ) );
692
a->setStatusTip( i18n( "Closes the current project or document" ) );
693
a->setWhatsThis(whatsThisFrom( "File|Close" ) );
694
connect( a, SIGNAL( activated() ), this, SLOT( fileClose() ) );
695
connect( this, SIGNAL( hasActiveWindowOrProject(bool) ), a, SLOT( setEnabled(bool) ) );
696
if ( !singleProject ) {
697
a->addTo( fileMenu );
698
fileMenu->insertSeparator();
701
a = new DesignerAction( this, 0 );
703
a->setText( i18n( "Save" ) );
704
a->setMenuText( i18n( "&Save" ) );
705
a->setIconSet( createIconSet("designer_filesave.png") );
706
a->setAccel( CTRL + Key_S );
707
a->setStatusTip( i18n( "Saves the current project or document" ) );
708
a->setWhatsThis(whatsThisFrom( "File|Save" ) );
709
connect( a, SIGNAL( activated() ), this, SLOT( fileSave() ) );
710
connect( this, SIGNAL( hasActiveWindowOrProject(bool) ), a, SLOT( setEnabled(bool) ) );
712
a->addTo( fileMenu );
714
a = new DesignerAction( this, 0 );
715
actionFileSaveAs = a;
716
a->setText( i18n( "Save As" ) );
717
a->setMenuText( i18n( "Save &As..." ) );
718
a->setStatusTip( i18n( "Saves the current form with a new filename" ) );
719
a->setWhatsThis( whatsThisFrom( "File|Save As" ) );
720
connect( a, SIGNAL( activated() ), this, SLOT( fileSaveAs() ) );
721
connect( this, SIGNAL( hasActiveWindow(bool) ), a, SLOT( setEnabled(bool) ) );
722
if ( !singleProject )
723
a->addTo( fileMenu );
725
a = new DesignerAction( this, 0 );
726
actionFileSaveAll = a;
727
a->setText( i18n( "Save All" ) );
728
a->setMenuText( i18n( "Sa&ve All" ) );
729
a->setStatusTip( i18n( "Saves all open documents" ) );
730
a->setWhatsThis( whatsThisFrom( "File|Save All" ) );
731
connect( a, SIGNAL( activated() ), this, SLOT( fileSaveAll() ) );
732
connect( this, SIGNAL( hasActiveWindowOrProject(bool) ), a, SLOT( setEnabled(bool) ) );
733
if ( !singleProject ) {
734
a->addTo( fileMenu );
735
fileMenu->insertSeparator();
738
a = new DesignerAction( this, 0 );
739
a->setText( i18n( "Create Template" ) );
740
a->setMenuText( i18n( "Create &Template..." ) );
741
a->setStatusTip( i18n( "Creates a new template" ) );
742
a->setWhatsThis( whatsThisFrom( "File|Create Template" ) );
743
connect( a, SIGNAL( activated() ), this, SLOT( fileCreateTemplate() ) );
744
if ( !singleProject )
745
a->addTo( fileMenu );
747
if ( !singleProject )
748
fileMenu->insertSeparator();
750
recentlyFilesMenu = new QPopupMenu( this );
751
recentlyProjectsMenu = new QPopupMenu( this );
753
if ( !singleProject ) {
754
fileMenu->insertItem( i18n( "Recently Opened Files " ), recentlyFilesMenu );
755
fileMenu->insertItem( i18n( "Recently Opened Projects" ), recentlyProjectsMenu );
758
connect( recentlyFilesMenu, SIGNAL( aboutToShow() ),
759
this, SLOT( setupRecentlyFilesMenu() ) );
760
connect( recentlyProjectsMenu, SIGNAL( aboutToShow() ),
761
this, SLOT( setupRecentlyProjectsMenu() ) );
762
connect( recentlyFilesMenu, SIGNAL( activated( int ) ),
763
this, SLOT( recentlyFilesMenuActivated( int ) ) );
764
connect( recentlyProjectsMenu, SIGNAL( activated( int ) ),
765
this, SLOT( recentlyProjectsMenuActivated( int ) ) );
767
if ( !singleProject )
768
fileMenu->insertSeparator();
770
a = new DesignerAction( this, 0 );
772
if ( !singleProjectMode() ) {
773
a->setText( i18n( "Exit" ) );
774
a->setMenuText( i18n( "E&xit" ) );
775
a->setStatusTip( i18n( "Quits the application and prompts to save any changed forms, source files or project settings" ) );
776
a->setWhatsThis( whatsThisFrom( "File|Exit" ) );
778
a->setText( i18n( "Close" ) );
779
a->setMenuText( i18n( "&Close" ) );
781
connect( a, SIGNAL( activated() ), this, SLOT( fileQuit() ) );
782
a->addTo( fileMenu );
785
void MainWindow::setupProjectActions()
787
projectMenu = new QPopupMenu( this, "Project" );
788
menubar->insertItem( i18n( "Pr&oject" ), projectMenu );
790
QActionGroup *ag = new QActionGroup( this, 0 );
791
ag->setText( i18n( "Active Project" ) );
792
ag->setMenuText( i18n( "Active Project" ) );
793
ag->setExclusive( TRUE );
794
ag->setUsesDropDown( TRUE );
795
connect( ag, SIGNAL( selected( QAction * ) ), this, SLOT( projectSelected( QAction * ) ) );
796
connect( ag, SIGNAL( selected( QAction * ) ), this, SIGNAL( projectChanged() ) );
797
DesignerAction *a = new DesignerAction( i18n( "<No Project>" ), i18n( "<No Project>" ), 0, ag, 0, TRUE );
798
eProject = new Project( "", i18n( "<No Project>" ), projectSettingsPluginManager, TRUE );
799
projects.insert( a, eProject );
801
ag->addTo( projectMenu );
802
ag->addTo( projectToolBar );
803
actionGroupProjects = ag;
805
if ( !singleProject )
806
projectMenu->insertSeparator();
808
a = new DesignerAction( i18n( "Add File" ), QPixmap(), i18n( "&Add File..." ), 0, this, 0 );
809
actionProjectAddFile = a;
810
a->setStatusTip( i18n("Adds a file to the current project") );
811
a->setWhatsThis( whatsThisFrom( "Project|Add File" ) );
812
connect( a, SIGNAL( activated() ), this, SLOT( projectInsertFile() ) );
813
a->setEnabled( FALSE );
814
connect( this, SIGNAL( hasNonDummyProject(bool) ), a, SLOT( setEnabled(bool) ) );
815
if ( !singleProject )
816
a->addTo( projectMenu );
818
actionEditPixmapCollection = new DesignerAction( i18n( "Image Collection..." ), QPixmap(),
819
i18n( "&Image Collection..." ), 0, this, 0 );
820
actionEditPixmapCollection->setStatusTip( i18n("Opens a dialog for editing the current project's image collection") );
821
actionEditPixmapCollection->setWhatsThis( whatsThisFrom( "Project|Image Collection" ) );
822
connect( actionEditPixmapCollection, SIGNAL( activated() ), this, SLOT( editPixmapCollection() ) );
823
actionEditPixmapCollection->setEnabled( FALSE );
824
connect( this, SIGNAL( hasNonDummyProject(bool) ), actionEditPixmapCollection, SLOT( setEnabled(bool) ) );
825
actionEditPixmapCollection->addTo( projectMenu );
828
actionEditDatabaseConnections = new DesignerAction( i18n( "Database Connections..." ), QPixmap(),
829
i18n( "&Database Connections..." ), 0, this, 0 );
830
actionEditDatabaseConnections->setStatusTip( i18n("Opens a dialog for editing the current project's database connections") );
831
actionEditDatabaseConnections->setWhatsThis( whatsThisFrom( "Project|Database Connections" ) );
832
connect( actionEditDatabaseConnections, SIGNAL( activated() ), this, SLOT( editDatabaseConnections() ) );
833
//actionEditDatabaseConnections->setEnabled( FALSE );
834
//connect( this, SIGNAL( hasNonDummyProject(bool) ), actionEditDatabaseConnections, SLOT( setEnabled(bool) ) );
835
if ( !singleProject )
836
actionEditDatabaseConnections->addTo( projectMenu );
839
actionEditProjectSettings = new DesignerAction( i18n( "Project Settings..." ), QPixmap(),
840
i18n( "&Project Settings..." ), 0, this, 0 );
841
actionEditProjectSettings->setStatusTip( i18n("Opens a dialog to change the project's settings") );
842
actionEditProjectSettings->setWhatsThis( whatsThisFrom( "Project|Project Settings" ) );
843
connect( actionEditProjectSettings, SIGNAL( activated() ), this, SLOT( editProjectSettings() ) );
844
actionEditProjectSettings->setEnabled( FALSE );
845
connect( this, SIGNAL( hasNonDummyProject(bool) ), actionEditProjectSettings, SLOT( setEnabled(bool) ) );
846
actionEditProjectSettings->addTo( projectMenu );
850
void MainWindow::setupPreviewActions()
852
DesignerAction* a = 0;
853
QPopupMenu *menu = new QPopupMenu( this, "Preview" );
855
menubar->insertItem( i18n( "&Preview" ), menu, toolsMenuId + 2 );
857
a = new DesignerAction( i18n( "Preview Form" ), QPixmap(), i18n( "Preview &Form" ), 0, this, 0 );
859
a->setAccel( CTRL + Key_T );
860
a->setStatusTip( i18n("Opens a preview") );
861
a->setWhatsThis( whatsThisFrom( "Preview|Preview Form" ) );
862
connect( a, SIGNAL( activated() ), this, SLOT( previewForm() ) );
863
connect( this, SIGNAL( hasActiveForm(bool) ), a, SLOT( setEnabled(bool) ) );
866
menu->insertSeparator();
868
QSignalMapper *mapper = new QSignalMapper( this );
869
connect( mapper, SIGNAL(mapped(const QString&)), this, SLOT(previewForm(const QString&)) );
870
QStringList styles = QStyleFactory::keys();
871
for ( QStringList::Iterator it = styles.begin(); it != styles.end(); ++it ) {
873
if ( *it == "Motif" )
874
info = i18n( "The preview will use the Motif look and feel which is used as the default style on most UNIX systems." );
875
else if ( *it == "Windows" )
876
info = i18n( "The preview will use the Windows look and feel." );
877
else if ( *it == "Platinum" )
878
info = i18n( "The preview will use the Platinum look and feel which is similar to the Macintosh GUI style." );
879
else if ( *it == "CDE" )
880
info = i18n( "The preview will use the CDE look and feel which is similar to some versions of the Common Desktop Environment." );
881
else if ( *it == "SGI" )
882
info = i18n( "The preview will use the Motif look and feel which is used as the default style on SGI systems." );
883
else if ( *it == "MotifPlus" )
884
info = i18n( "The preview will use the advanced Motif look and feel used by the GIMP toolkit (GTK) on Linux." );
886
a = new DesignerAction( i18n( "Preview Form in %1 Style" ).arg( *it ), QPixmap(),
887
i18n( "... in %1 Style" ).arg( *it ), 0, this, 0 );
888
a->setStatusTip( i18n("Opens a preview in %1 style").arg( *it ) );
889
a->setWhatsThis( i18n("<b>Open a preview in %1 style.</b>"
890
"<p>Use the preview to test the design and "
891
"signal-slot connections of the current form. %2</p>").arg( *it ).arg( info ) );
892
mapper->setMapping( a, *it );
893
connect( a, SIGNAL(activated()), mapper, SLOT(map()) );
894
connect( this, SIGNAL( hasActiveForm(bool) ), a, SLOT( setEnabled(bool) ) );
899
void MainWindow::setupWindowActions()
901
/* static bool windowActionsSetup = FALSE;
902
if ( !windowActionsSetup ) {
903
windowActionsSetup = TRUE;
905
actionWindowTile = new DesignerAction( i18n( "Tile" ), i18n( "&Tile" ), 0, this );
906
actionWindowTile->setStatusTip( i18n("Tiles the windows so that they are all visible") );
907
actionWindowTile->setWhatsThis( whatsThisFrom( "Window|Tile" ) );
908
connect( actionWindowTile, SIGNAL( activated() ), qworkspace, SLOT( tile() ) );
909
actionWindowCascade = new DesignerAction( i18n( "Cascade" ), i18n( "&Cascade" ), 0, this );
910
actionWindowCascade->setStatusTip( i18n("Cascades the windows so that all their title bars are visible") );
911
actionWindowCascade->setWhatsThis( whatsThisFrom( "Window|Cascade" ) );
912
connect( actionWindowCascade, SIGNAL( activated() ), qworkspace, SLOT( cascade() ) );
914
actionWindowClose = new DesignerAction( i18n( "Close" ), i18n( "Cl&ose" ), CTRL + Key_F4, this );
915
actionWindowClose->setStatusTip( i18n( "Closes the active window") );
916
actionWindowClose->setWhatsThis( whatsThisFrom( "Window|Close" ) );
917
connect( actionWindowClose, SIGNAL( activated() ), qworkspace, SLOT( closeActiveWindow() ) );
919
actionWindowCloseAll = new DesignerAction( i18n( "Close All" ), i18n( "Close Al&l" ), 0, this );
920
actionWindowCloseAll->setStatusTip( i18n( "Closes all form windows") );
921
actionWindowCloseAll->setWhatsThis( whatsThisFrom( "Window|Close All" ) );
922
connect( actionWindowCloseAll, SIGNAL( activated() ), qworkspace, SLOT( closeAllWindows() ) );
924
actionWindowNext = new DesignerAction( i18n( "Next" ), i18n( "Ne&xt" ), CTRL + Key_F6, this );
925
actionWindowNext->setStatusTip( i18n( "Activates the next window" ) );
926
actionWindowNext->setWhatsThis( whatsThisFrom( "Window|Next" ) );
927
connect( actionWindowNext, SIGNAL( activated() ), qworkspace, SLOT( activateNextWindow() ) );
929
actionWindowPrevious = new DesignerAction( i18n( "Previous" ), i18n( "Pre&vious" ), CTRL + SHIFT + Key_F6, this );
930
actionWindowPrevious->setStatusTip( i18n( "Activates the previous window" ) );
931
actionWindowPrevious->setWhatsThis( whatsThisFrom( "Window|Previous" ) );
932
connect( actionWindowPrevious, SIGNAL( activated() ), qworkspace, SLOT( activatePreviousWindow() ) );
936
windowMenu = new QPopupMenu( this, "Window" );
937
menubar->insertItem( i18n( "&Window" ), windowMenu );
938
connect( windowMenu, SIGNAL( aboutToShow() ),
939
this, SLOT( setupWindowActions() ) );
944
actionWindowClose->addTo( windowMenu );
945
actionWindowCloseAll->addTo( windowMenu );
946
windowMenu->insertSeparator();
947
actionWindowNext->addTo( windowMenu );
948
actionWindowPrevious->addTo( windowMenu );
949
windowMenu->insertSeparator();
950
actionWindowTile->addTo( windowMenu );
951
actionWindowCascade->addTo( windowMenu );
952
windowMenu->insertSeparator();
953
windowMenu->insertItem( i18n( "Vie&ws" ), createDockWindowMenu( NoToolBars ) );
954
windowMenu->insertItem( i18n( "Tool&bars" ), createDockWindowMenu( OnlyToolBars ) );
955
QWidgetList windows = qworkspace->windowList();
956
if ( windows.count() && formWindow() )
957
windowMenu->insertSeparator();
959
for ( int i = 0; i < int( windows.count() ); ++i ) {
960
QWidget *w = windows.at( i );
961
if ( !::qt_cast<FormWindow*>(w) && !::qt_cast<SourceEditor*>(w) )
963
if ( ::qt_cast<FormWindow*>(w) && ( ( (FormWindow*)w )->isFake() ) )
968
itemText = QString("&%1 ").arg( j );
969
if ( ::qt_cast<FormWindow*>(w) )
970
itemText += w->name();
972
itemText += w->caption();
974
int id = windowMenu->insertItem( itemText, this, SLOT( windowsMenuActivated( int ) ) );
975
windowMenu->setItemParameter( id, i );
976
windowMenu->setItemChecked( id, qworkspace->activeWindow() == windows.at( i ) );
980
void MainWindow::setupHelpActions()
982
actionHelpContents = new DesignerAction( i18n( "Contents" ), i18n( "&Contents" ), Key_F1, this, 0 );
983
actionHelpContents->setStatusTip( i18n("Opens the online help") );
984
actionHelpContents->setWhatsThis( whatsThisFrom( "Help|Contents" ) );
985
connect( actionHelpContents, SIGNAL( activated() ), this, SLOT( helpContents() ) );
987
actionHelpManual = new DesignerAction( i18n( "Manual" ), i18n( "&Manual" ), CTRL + Key_M, this, 0 );
988
actionHelpManual->setStatusTip( i18n("Opens the Qt Designer manual") );
989
actionHelpManual->setWhatsThis( whatsThisFrom( "Help|Manual" ) );
990
connect( actionHelpManual, SIGNAL( activated() ), this, SLOT( helpManual() ) );
992
actionHelpAbout = new DesignerAction( i18n("About"), QPixmap(), i18n("&About"), 0, this, 0 );
993
actionHelpAbout->setStatusTip( i18n("Displays information about Qt Designer") );
994
actionHelpAbout->setWhatsThis( whatsThisFrom( "Help|About" ) );
995
connect( actionHelpAbout, SIGNAL( activated() ), this, SLOT( helpAbout() ) );
997
actionHelpAboutQt = new DesignerAction( i18n("About Qt"), QPixmap(), i18n("About &Qt"), 0, this, 0 );
998
actionHelpAboutQt->setStatusTip( i18n("Displays information about the Qt Toolkit") );
999
actionHelpAboutQt->setWhatsThis( whatsThisFrom( "Help|About Qt" ) );
1000
connect( actionHelpAboutQt, SIGNAL( activated() ), this, SLOT( helpAboutQt() ) );
1002
#if 0 //defined(QT_NON_COMMERCIAL)
1003
// ### not used anymore -- should be deleted?
1004
actionHelpRegister = new DesignerAction( i18n("Register Qt"), QPixmap(), i18n("&Register Qt..."), 0, this, 0 );
1005
actionHelpRegister->setStatusTip( i18n("Opens a web browser at the evaluation form on www.trolltech.com") );
1006
actionHelpRegister->setWhatsThis( i18n("Register with Trolltech") );
1007
connect( actionHelpRegister, SIGNAL( activated() ), this, SLOT( helpRegister() ) );
1010
actionHelpWhatsThis = new DesignerAction( i18n("What's This?"), QIconSet( whatsthis_image, whatsthis_image ),
1011
i18n("What's This?"), SHIFT + Key_F1, this, 0 );
1012
actionHelpWhatsThis->setStatusTip( i18n("\"What's This?\" context sensitive help") );
1013
actionHelpWhatsThis->setWhatsThis( whatsThisFrom( "Help|What's This?" ) );
1014
connect( actionHelpWhatsThis, SIGNAL( activated() ), this, SLOT( whatsThis() ) );
1016
/* QToolBar *tb = new QToolBar( this, "Help" );
1017
tb->setCloseMode( QDockWindow::Undocked );
1018
QWhatsThis::add( tb, i18n( "<b>The Help toolbar</b>%1" ).arg(i18n(toolbarHelp).arg("") ));
1019
addToolBar( tb, i18n( "Help" ) );
1020
actionHelpWhatsThis->addTo( tb );*/
1022
QPopupMenu *menu = new QPopupMenu( this, "Help" );
1023
menubar->insertSeparator();
1024
menubar->insertItem( i18n( "&Help" ), menu );
1025
actionHelpContents->addTo( menu );
1026
actionHelpManual->addTo( menu );
1027
menu->insertSeparator();
1028
actionHelpAbout->addTo( menu );
1029
actionHelpAboutQt->addTo( menu );
1030
#if 0 //defined(QT_NON_COMMERCIAL)
1031
// ### not used anymore -- should be deleted?
1032
actionHelpRegister->addTo( menu );
1035
menu->insertSeparator();
1036
actionHelpWhatsThis->addTo( menu );
1039
void MainWindow::fileNew()
1041
statusMessage( i18n( "Create a new project, form or source file...") );
1042
NewForm dlg( this, projectNames(), currentProject->projectName(), templatePath() );
1044
statusBar()->clear();
1047
void MainWindow::fileNewDialog()
1049
static int forms = 0;
1050
QString n = "Dialog" + QString::number( ++forms );
1051
while ( currentProject->findFormFile( n + ".ui" ) )
1052
n = "Dialog" + QString::number( ++forms );
1054
FormFile *ff = new FormFile( n + ".ui", FALSE, currentProject );
1055
fw = new FormWindow( ff, MainWindow::self, MainWindow::self->qWorkspace(), n );
1056
ff->setModified( TRUE );
1057
currentProject->setModified( TRUE );
1058
workspace()->update();
1059
fw->setProject( currentProject );
1060
MetaDataBase::addEntry( fw );
1061
QWidget *w = WidgetFactory::create( WidgetDatabase::idFromClassName( "QDialog" ), fw, n.latin1() );
1062
fw->setMainContainer( w );
1063
fw->setCaption( n );
1064
fw->resize( 600, 480 );
1065
insertFormWindow( fw );
1066
fw->killAccels( fw );
1067
fw->project()->setModified( TRUE );
1069
fw->setSavePixmapInProject( TRUE );
1070
fw->setSavePixmapInline( FALSE );
1073
void MainWindow::fileNewFile()
1075
QString name = QInputDialog::getText( i18n( "Name of File" ), i18n( "Enter the name of the new source file:" ) );
1076
if ( name.isEmpty() )
1078
if ( name.right( 3 ) != ".qs" )
1080
SourceFile *f = new SourceFile( name, FALSE, currentProject );
1081
MainWindow::self->editSource( f );
1082
f->setModified( TRUE );
1083
currentProject->setModified( TRUE );
1084
workspace()->update();
1087
void MainWindow::fileQuit()
1090
if ( !singleProjectMode() )
1091
qApp->closeAllWindows();
1094
void MainWindow::fileClose()
1096
if ( !currentProject->isDummy() ) {
1099
QWidget *w = qworkspace->activeWindow();
1101
if ( ::qt_cast<FormWindow*>(w) )
1102
( (FormWindow*)w )->formFile()->close();
1103
else if ( ::qt_cast<SourceEditor*>(w) )
1104
( (SourceEditor*)w )->close();
1110
void MainWindow::fileCloseProject()
1112
if ( currentProject->isDummy() )
1114
Project *pro = currentProject;
1116
QAction* lastValid = 0;
1117
for ( QMap<QAction*, Project* >::Iterator it = projects.begin(); it != projects.end(); ++it ) {
1118
if ( it.data() == pro ) {
1123
lastValid = it.key();
1126
if ( pro->isModified() ) {
1127
switch ( QMessageBox::warning( this, i18n( "Save Project Settings" ),
1128
i18n( "Save changes to '%1'?" ).arg( pro->fileName() ),
1129
i18n( "&Yes" ), i18n( "&No" ), i18n( "&Cancel" ), 0, 2 ) ) {
1133
case 1: // don't save
1142
QWidgetList windows = qWorkspace()->windowList();
1143
qWorkspace()->blockSignals( TRUE );
1144
QWidgetListIt wit( windows );
1145
while ( wit.current() ) {
1146
QWidget *w = wit.current();
1148
if ( ::qt_cast<FormWindow*>(w) ) {
1149
if ( ( (FormWindow*)w )->project() == pro ) {
1150
if ( ( (FormWindow*)w )->formFile()->editor() )
1151
windows.removeRef( ( (FormWindow*)w )->formFile()->editor() );
1152
if ( !( (FormWindow*)w )->formFile()->close() )
1155
} else if ( ::qt_cast<SourceEditor*>(w) ) {
1156
if ( !( (SourceEditor*)w )->close() )
1160
hierarchyView->clear();
1161
windows = qWorkspace()->windowList();
1162
qWorkspace()->blockSignals( FALSE );
1163
actionGroupProjects->removeChild( a );
1164
projects.remove( a );
1168
projectSelected( lastValid );
1169
statusMessage( i18n( "Selected project '%1'" ).arg( currentProject->projectName() ) );
1171
if ( !windows.isEmpty() ) {
1172
for ( QWidget *w = windows.first(); w; w = windows.next() ) {
1173
if ( !::qt_cast<FormWindow*>(w) )
1176
activeWindowChanged( w );
1180
emit hasActiveWindow( FALSE );
1181
emit hasActiveForm( FALSE );
1182
updateUndoRedo( FALSE, FALSE, QString::null, QString::null );
1187
void MainWindow::fileOpen() // as called by the menu
1189
fileOpen( "", "", "", FALSE );
1192
void MainWindow::projectInsertFile()
1197
void MainWindow::fileOpen( const QString &filter, const QString &extension, const QString &fn, bool inProject )
1199
statusMessage( i18n( "Open a file...") );
1201
QPluginManager<ImportFilterInterface> manager( IID_ImportFilter, QApplication::libraryPaths(), pluginDirectory() );
1203
Project* project = inProject ? currentProject : eProject;
1205
QStringList additionalSources;
1208
QStringList filterlist;
1209
if ( filter.isEmpty() ) {
1211
filterlist << i18n( "*.ui *.pro|Designer Files" );
1212
filterlist << i18n( "*.ui|Qt User-Interface Files" );
1214
filterlist << i18n( "*.pro|QMAKE Project Files" );
1215
QStringList list = manager.featureList();
1216
for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it )
1218
LanguageInterface *iface = MetaDataBase::languageInterface( project->language() );
1220
filterlist += iface->fileFilterList();
1221
additionalSources += iface->fileExtensionList();
1223
filterlist << i18n( "*|All Files" );
1225
filterlist << filter;
1228
QString filters = filterlist.join( "\n" );
1230
QStringList filenames;
1231
if ( fn.isEmpty() ) {
1233
QString f = KFileDialog::getOpenFileName( QString::null, filters, this, /*0,*/
1234
i18n("Open" )/*, &lastOpenFilter */);
1237
filenames = KFileDialog::getOpenFileNames( QString::null, filters, this, /*0,*/
1238
i18n("Add")/*, &lastOpenFilter */);
1244
for ( QStringList::Iterator fit = filenames.begin(); fit != filenames.end(); ++fit ) {
1245
QString filename = *fit;
1246
if ( !filename.isEmpty() ) {
1247
QFileInfo fi( filename );
1249
if ( fi.extension( FALSE ) == "pro" && ( extension.isEmpty() || extension.find( ";pro" ) != -1 ) ) {
1250
addRecentlyOpened( filename, recentlyProjects );
1251
openProject( filename );
1252
} else if ( fi.extension( FALSE ) == "ui" && ( extension.isEmpty() || extension.find( ";ui" ) != -1 ) ) {
1254
setCurrentProject( eProject );
1255
openFormWindow( filename );
1256
addRecentlyOpened( filename, recentlyFiles );
1257
} else if ( !extension.isEmpty() && extension.find( ";" + fi.extension( FALSE ) ) != -1 ||
1258
additionalSources.find( fi.extension( FALSE ) ) != additionalSources.end() ) {
1259
SourceFile *sf = project->findSourceFile( project->makeRelative( filename ) );
1261
sf = new SourceFile( project->makeRelative( filename ), FALSE, project );
1263
} else if ( extension.isEmpty() ) {
1265
for ( QStringList::Iterator it2 = filterlist.begin(); it2 != filterlist.end(); ++it2 ) {
1266
if ( (*it2).contains( "." + fi.extension( FALSE ), FALSE ) ) {
1272
ImportFilterInterface* iface = 0;
1273
manager.queryInterface( filter, &iface );
1275
statusMessage( i18n( "No import filter is available to import '%1'").
1276
arg( filename )/*, 3000*/ );
1279
statusMessage( i18n( "Importing '%1' using import filter ...").arg( filename ) );
1280
QStringList list = iface->import( filter, filename );
1282
if ( list.isEmpty() ) {
1283
statusMessage( i18n( "Nothing to load in '%1'").arg( filename )/*, 3000*/ );
1287
setCurrentProject( eProject );
1288
addRecentlyOpened( filename, recentlyFiles );
1289
for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
1290
openFormWindow( *it, FALSE );
1291
QFile::remove( *it );
1293
statusBar()->clear();
1300
FormWindow *MainWindow::openFormWindow( const QString &filename, bool validFileName, FormFile *ff )
1302
if ( filename.isEmpty() )
1305
bool makeNew = FALSE;
1307
if ( !QFile::exists( filename ) ) {
1310
QFile f( filename );
1311
f.open( IO_ReadOnly );
1312
QTextStream ts( &f );
1313
makeNew = ts.read().length() < 2;
1318
formWindow()->setFileName( filename );
1319
return formWindow();
1322
statusMessage( i18n( "Reading file '%1'...").arg( filename ) );
1323
FormFile *ff2 = currentProject->findFormFile( currentProject->makeRelative(filename) );
1324
if ( ff2 && ff2->formWindow() ) {
1325
ff2->formWindow()->setFocus();
1326
return ff2->formWindow();
1331
QApplication::setOverrideCursor( WaitCursor );
1332
Resource resource( this );
1334
ff = new FormFile( currentProject->makeRelative( filename ), FALSE, currentProject );
1335
bool b = resource.load( ff ) && (FormWindow*)resource.widget();
1336
if ( !validFileName && resource.widget() )
1337
( (FormWindow*)resource.widget() )->setFileName( QString::null );
1338
QApplication::restoreOverrideCursor();
1340
rebuildCustomWidgetGUI();
1341
statusMessage( i18n( "Loaded file '%1'").arg( filename )/*, 3000 */);
1343
statusMessage( i18n( "Failed to load file '%1'").arg( filename )/*, 5000 */);
1344
QMessageBox::information( this, i18n("Load File"), i18n("Could not load file '%1'.").arg( filename ) );
1347
return (FormWindow*)resource.widget();
1350
bool MainWindow::fileSave()
1353
if ( !currentProject->isDummy() )
1354
return fileSaveProject();
1355
return fileSaveForm();
1358
bool MainWindow::fileSaveForm()
1360
for ( SourceEditor *e = sourceEditors.first(); e; e = sourceEditors.next() ) {
1361
if ( e->object() == formWindow() || e == qWorkspace()->activeWindow() ) {
1368
QWidget *w = qWorkspace()->activeWindow();
1370
if ( ::qt_cast<SourceEditor*>(w) ) {
1371
SourceEditor *se = (SourceEditor*)w;
1372
if ( se->formWindow() )
1373
fw = se->formWindow();
1374
else if ( se->sourceFile() ) {
1375
se->sourceFile()->save();
1383
if ( !fw || !fw->formFile()->save() )
1385
QApplication::restoreOverrideCursor();
1389
bool MainWindow::fileSaveProject()
1391
currentProject->save();
1392
statusMessage( i18n( "Project '%1' saved.").arg( currentProject->projectName() )/*, 3000 */);
1396
bool MainWindow::fileSaveAs()
1398
statusMessage( i18n( "Enter a filename..." ) );
1400
QWidget *w = qworkspace->activeWindow();
1403
if ( ::qt_cast<FormWindow*>(w) )
1404
return ( (FormWindow*)w )->formFile()->saveAs();
1405
else if ( ::qt_cast<SourceEditor*>(w) )
1406
return ( (SourceEditor*)w )->saveAs();
1410
void MainWindow::fileSaveAll()
1412
for ( QMap<QAction*, Project* >::Iterator it = projects.begin(); it != projects.end(); ++it )
1416
void MainWindow::fileCreateTemplate()
1418
CreateTemplate dia( this, 0, TRUE );
1421
for ( i = 0; i < WidgetDatabase::count(); ++i ) {
1422
if ( WidgetDatabase::isForm( i ) && WidgetDatabase::group( i ) != "Temp") {
1423
dia.listClass->insertItem( WidgetDatabase::className( i ) );
1426
for ( i = 0; i < WidgetDatabase::count(); ++i ) {
1427
if ( WidgetDatabase::isContainer( i ) && !WidgetDatabase::isForm(i) &&
1428
WidgetDatabase::className( i ) != "QTabWidget" && WidgetDatabase::group( i ) != "Temp" ) {
1429
dia.listClass->insertItem( WidgetDatabase::className( i ) );
1433
QPtrList<MetaDataBase::CustomWidget> *lst = MetaDataBase::customWidgets();
1434
for ( MetaDataBase::CustomWidget *w = lst->first(); w; w = lst->next() ) {
1435
if ( w->isContainer )
1436
dia.listClass->insertItem( w->className );
1439
dia.editName->setText( i18n( "NewTemplate" ) );
1440
connect( dia.buttonCreate, SIGNAL( clicked() ),
1441
this, SLOT( createNewTemplate() ) );
1445
void MainWindow::createNewTemplate()
1447
CreateTemplate *dia = (CreateTemplate*)sender()->parent();
1448
QString fn = dia->editName->text();
1449
QString cn = dia->listClass->currentText();
1450
if ( fn.isEmpty() || cn.isEmpty() ) {
1451
QMessageBox::information( this, i18n( "Create Template" ), i18n( "Could not create the template." ) );
1455
QStringList templRoots;
1456
const char *qtdir = getenv( "QTDIR" );
1458
templRoots << qtdir;
1459
templRoots << qInstallPathData();
1460
if(qtdir) //try the tools/designer directory last!
1461
templRoots << (QString(qtdir) + "/tools/designer");
1463
for ( QStringList::Iterator it = templRoots.begin(); it != templRoots.end(); ++it ) {
1464
if ( QFile::exists( (*it) + "/templates/" )) {
1465
QString tmpfn = (*it) + "/templates/" + fn + ".ui";
1467
if(f.open(IO_WriteOnly))
1471
if ( !f.isOpen() ) {
1472
QMessageBox::information( this, i18n( "Create Template" ), i18n( "Could not create the template." ) );
1475
QTextStream ts( &f );
1477
ts << "<!DOCTYPE UI><UI>" << endl;
1478
ts << "<widget>" << endl;
1479
ts << "<class>" << cn << "</class>" << endl;
1480
ts << "<property stdset=\"1\">" << endl;
1481
ts << " <name>name</name>" << endl;
1482
ts << " <cstring>" << cn << "Form</cstring>" << endl;
1483
ts << "</property>" << endl;
1484
ts << "<property stdset=\"1\">" << endl;
1485
ts << " <name>geometry</name>" << endl;
1486
ts << " <rect>" << endl;
1487
ts << " <width>300</width>" << endl;
1488
ts << " <height>400</height>" << endl;
1489
ts << " </rect>" << endl;
1490
ts << "</property>" << endl;
1491
ts << "</widget>" << endl;
1492
ts << "</UI>" << endl;
1494
dia->editName->setText( i18n( "NewTemplate" ) );
1499
void MainWindow::editUndo()
1501
if ( qWorkspace()->activeWindow() &&
1502
::qt_cast<SourceEditor*>(qWorkspace()->activeWindow()) ) {
1503
( (SourceEditor*)qWorkspace()->activeWindow() )->editUndo();
1507
formWindow()->undo();
1510
void MainWindow::editRedo()
1512
if ( qWorkspace()->activeWindow() &&
1513
::qt_cast<SourceEditor*>(qWorkspace()->activeWindow()) ) {
1514
( (SourceEditor*)qWorkspace()->activeWindow() )->editRedo();
1518
formWindow()->redo();
1521
void MainWindow::editCut()
1523
if ( qWorkspace()->activeWindow() &&
1524
::qt_cast<SourceEditor*>(qWorkspace()->activeWindow()) ) {
1525
( (SourceEditor*)qWorkspace()->activeWindow() )->editCut();
1532
void MainWindow::editCopy()
1534
if ( qWorkspace()->activeWindow() &&
1535
::qt_cast<SourceEditor*>(qWorkspace()->activeWindow()) ) {
1536
( (SourceEditor*)qWorkspace()->activeWindow() )->editCopy();
1540
qApp->clipboard()->setText( formWindow()->copy() );
1543
void MainWindow::editPaste()
1545
if ( qWorkspace()->activeWindow() &&
1546
::qt_cast<SourceEditor*>(qWorkspace()->activeWindow()) ) {
1547
( (SourceEditor*)qWorkspace()->activeWindow() )->editPaste();
1550
if ( !formWindow() )
1553
QWidget *w = formWindow()->mainContainer();
1554
QWidgetList l( formWindow()->selectedWidgets() );
1555
if ( l.count() == 1 ) {
1557
if ( WidgetFactory::layoutType( w ) != WidgetFactory::NoLayout ||
1558
( !WidgetDatabase::isContainer( WidgetDatabase::idFromClassName( WidgetFactory::classNameOf( w ) ) ) &&
1559
w != formWindow()->mainContainer() ) )
1560
w = formWindow()->mainContainer();
1563
if ( w && WidgetFactory::layoutType( w ) == WidgetFactory::NoLayout ) {
1564
formWindow()->paste( qApp->clipboard()->text(), WidgetFactory::containerOfWidget( w ) );
1565
hierarchyView->widgetInserted( 0 );
1566
formWindow()->commandHistory()->setModified( TRUE );
1568
QMessageBox::information( this, i18n( "Paste Error" ),
1569
i18n( "Cannot paste widgets. Designer could not find a container\n"
1570
"to paste into which does not contain a layout. Break the layout\n"
1571
"of the container you want to paste into and select this container\n"
1572
"and then paste again." ) );
1576
void MainWindow::editDelete()
1579
formWindow()->deleteWidgets();
1582
void MainWindow::editSelectAll()
1584
if ( qWorkspace()->activeWindow() &&
1585
::qt_cast<SourceEditor*>(qWorkspace()->activeWindow()) ) {
1586
( (SourceEditor*)qWorkspace()->activeWindow() )->editSelectAll();
1590
formWindow()->selectAll();
1594
void MainWindow::editLower()
1597
formWindow()->lowerWidgets();
1600
void MainWindow::editRaise()
1603
formWindow()->raiseWidgets();
1606
void MainWindow::editAdjustSize()
1609
formWindow()->editAdjustSize();
1612
void MainWindow::editLayoutHorizontal()
1615
editLayoutContainerHorizontal();
1616
else if ( layoutSelected && formWindow() )
1617
formWindow()->layoutHorizontal();
1620
void MainWindow::editLayoutVertical()
1623
editLayoutContainerVertical();
1624
else if ( layoutSelected && formWindow() )
1625
formWindow()->layoutVertical();
1628
void MainWindow::editLayoutHorizontalSplit()
1631
; // no way to do that
1632
else if ( layoutSelected && formWindow() )
1633
formWindow()->layoutHorizontalSplit();
1636
void MainWindow::editLayoutVerticalSplit()
1639
; // no way to do that
1640
else if ( layoutSelected && formWindow() )
1641
formWindow()->layoutVerticalSplit();
1644
void MainWindow::editLayoutGrid()
1647
editLayoutContainerGrid();
1648
else if ( layoutSelected && formWindow() )
1649
formWindow()->layoutGrid();
1652
void MainWindow::editLayoutContainerVertical()
1654
if ( !formWindow() )
1656
QWidget *w = formWindow()->mainContainer();
1657
QWidgetList l( formWindow()->selectedWidgets() );
1658
if ( l.count() == 1 )
1661
formWindow()->layoutVerticalContainer( w );
1664
void MainWindow::editLayoutContainerHorizontal()
1666
if ( !formWindow() )
1668
QWidget *w = formWindow()->mainContainer();
1669
QWidgetList l( formWindow()->selectedWidgets() );
1670
if ( l.count() == 1 )
1673
formWindow()->layoutHorizontalContainer( w );
1676
void MainWindow::editLayoutContainerGrid()
1678
if ( !formWindow() )
1680
QWidget *w = formWindow()->mainContainer();
1681
QWidgetList l( formWindow()->selectedWidgets() );
1682
if ( l.count() == 1 )
1685
formWindow()->layoutGridContainer( w );
1688
void MainWindow::editBreakLayout()
1690
if ( !formWindow() || !breakLayout )
1692
QWidget *w = formWindow()->mainContainer();
1693
if ( formWindow()->currentWidget() )
1694
w = formWindow()->currentWidget();
1695
if ( WidgetFactory::layoutType( w ) != WidgetFactory::NoLayout ||
1696
w->parentWidget() && WidgetFactory::layoutType( w->parentWidget() ) != WidgetFactory::NoLayout ) {
1697
formWindow()->breakLayout( w );
1700
QWidgetList widgets = formWindow()->selectedWidgets();
1701
for ( w = widgets.first(); w; w = widgets.next() ) {
1702
if ( WidgetFactory::layoutType( w ) != WidgetFactory::NoLayout ||
1703
w->parentWidget() && WidgetFactory::layoutType( w->parentWidget() ) != WidgetFactory::NoLayout )
1707
formWindow()->breakLayout( w );
1712
w = formWindow()->mainContainer();
1713
if ( WidgetFactory::layoutType( w ) != WidgetFactory::NoLayout ||
1714
w->parentWidget() && WidgetFactory::layoutType( w->parentWidget() ) != WidgetFactory::NoLayout )
1715
formWindow()->breakLayout( w );
1718
void MainWindow::editAccels()
1720
if ( !formWindow() )
1722
formWindow()->checkAccels();
1725
void MainWindow::editFunctions()
1727
if ( !formWindow() )
1730
statusMessage( i18n( "Edit the current form's slots..." ) );
1731
EditFunctions dlg( this, formWindow(), TRUE );
1733
statusBar()->clear();
1736
void MainWindow::editConnections()
1738
if ( !formWindow() )
1741
statusMessage( i18n( "Edit the current form's connections..." ) );
1742
ConnectionDialog dlg( this );
1745
statusBar()->clear();
1748
SourceEditor *MainWindow::editSource()
1750
if ( !formWindow() )
1752
return formWindow()->formFile()->showEditor();
1755
SourceEditor *MainWindow::openSourceEditor()
1757
if ( !formWindow() )
1760
QString lang = currentProject->language();
1761
if ( !MetaDataBase::hasEditor( lang ) ) {
1762
QMessageBox::information( this, i18n( "Edit Source" ),
1763
i18n( "There is no plugin for editing %1 code installed.\n"
1764
"Note: Plugins are not available in static Qt configurations." ).arg( lang ) );
1768
SourceEditor *editor = 0;
1769
for ( SourceEditor *e = sourceEditors.first(); e; e = sourceEditors.next() ) {
1770
if ( e->language() == lang && e->formWindow() == formWindow() ) {
1777
editor = createSourceEditor( formWindow(), formWindow()->project(), lang );
1781
SourceEditor *MainWindow::editSource( SourceFile *f )
1783
QString lang = currentProject->language();
1784
if ( !MetaDataBase::hasEditor( lang ) ) {
1785
QMessageBox::information( this, i18n( "Edit Source" ),
1786
i18n( "There is no plugin for editing %1 code installed.\n"
1787
"Note: Plugins are not available in static Qt configurations." ).arg( lang ) );
1791
SourceEditor *editor = 0;
1793
editor = f->editor();
1795
editor = createSourceEditor( f, currentProject, lang );
1796
editor->setActiveWindow();
1801
SourceEditor *MainWindow::createSourceEditor( QObject *object, Project *project,
1802
const QString &lang, const QString &func,
1805
SourceEditor *editor = 0;
1806
EditorInterface *eIface = 0;
1807
editorPluginManager->queryInterface( lang, &eIface );
1810
LanguageInterface *lIface = MetaDataBase::languageInterface( lang );
1813
QApplication::setOverrideCursor( WaitCursor );
1814
editor = new SourceEditor( qWorkspace(), eIface, lIface );
1818
editor->setLanguage( lang );
1819
sourceEditors.append( editor );
1820
QApplication::restoreOverrideCursor();
1822
if ( editor->object() != object )
1823
editor->setObject( object, project );
1824
else if ( rereadSource )
1825
editor->refresh( FALSE );
1829
if ( !func.isEmpty() )
1830
editor->setFunction( func );
1831
emit editorChanged();
1836
void MainWindow::editFormSettings()
1838
if ( !formWindow() )
1841
statusMessage( i18n( "Edit the current form's settings..." ) );
1842
FormSettings dlg( this, formWindow() );
1844
statusBar()->clear();
1847
void MainWindow::editProjectSettings()
1849
openProjectSettings( currentProject );
1850
wspace->setCurrentProject( currentProject );
1853
void MainWindow::editPixmapCollection()
1855
PixmapCollectionEditor dia( this, 0, TRUE );
1856
dia.setProject( currentProject );
1860
void MainWindow::editDatabaseConnections()
1863
DatabaseConnectionsEditor dia( currentProject, this, 0, TRUE );
1868
void MainWindow::editPreferences()
1870
statusMessage( i18n( "Edit preferences..." ) );
1871
Preferences *dia = new Preferences( this, 0, TRUE );
1873
connect( dia->helpButton, SIGNAL( clicked() ), MainWindow::self, SLOT( showDialogHelp() ) );
1874
dia->buttonColor->setEditor( StyledButton::ColorEditor );
1875
dia->buttonPixmap->setEditor( StyledButton::PixmapEditor );
1876
dia->groupBoxGrid->setChecked( sGrid );
1877
dia->checkBoxSnapGrid->setChecked( snGrid );
1878
dia->spinGridX->setValue( grid().x() );
1879
dia->spinGridY->setValue( grid().y() );
1880
dia->checkBoxWorkspace->setChecked( restoreConfig );
1881
dia->checkBoxTextLabels->setChecked( usesTextLabel() );
1882
dia->buttonColor->setColor( qworkspace->backgroundColor() );
1883
QString pluginPaths = QApplication::libraryPaths().join("\n");
1884
dia->textEditPluginPaths->setText(pluginPaths);
1885
if ( qworkspace->backgroundPixmap() )
1886
dia->buttonPixmap->setPixmap( *qworkspace->backgroundPixmap() );
1888
dia->radioPixmap->setChecked( TRUE );
1890
dia->radioColor->setChecked( TRUE );
1891
dia->checkBoxSplash->setChecked( splashScreen );
1892
dia->checkAutoEdit->setChecked( !databaseAutoEdit );
1893
dia->checkBoxStartDialog->setChecked( shStartDialog );
1894
dia->checkBoxAutoSave->setChecked( autoSaveEnabled );
1895
int h = autoSaveInterval / 3600;
1896
int m = ( autoSaveInterval - h * 3600 ) / 60;
1897
int s = autoSaveInterval - ( h * 3600 + m * 60 );
1899
dia->timeEditAutoSave->setTime( t );
1901
SenderObject *senderObject = new SenderObject( designerInterface() );
1902
QValueList<Tab>::Iterator it;
1903
for ( it = preferenceTabs.begin(); it != preferenceTabs.end(); ++it ) {
1905
dia->tabWidget->addTab( t.w, t.title );
1907
connect( dia->buttonOk, SIGNAL( clicked() ), senderObject, SLOT( emitAcceptSignal() ) );
1908
connect( senderObject, SIGNAL( acceptSignal( QUnknownInterface * ) ), t.receiver, t.accept_slot );
1909
connect( senderObject, SIGNAL( initSignal( QUnknownInterface * ) ), t.receiver, t.init_slot );
1910
senderObject->emitInitSignal();
1911
disconnect( senderObject, SIGNAL( initSignal( QUnknownInterface * ) ), t.receiver, t.init_slot );
1915
if ( dia->exec() == QDialog::Accepted ) {
1916
setSnapGrid( dia->checkBoxSnapGrid->isChecked() );
1917
setShowGrid( dia->groupBoxGrid->isChecked() );
1918
setGrid( QPoint( dia->spinGridX->value(),
1919
dia->spinGridY->value() ) );
1920
restoreConfig = dia->checkBoxWorkspace->isChecked();
1921
setUsesTextLabel( dia->checkBoxTextLabels->isChecked() );
1922
if (dia->textEditPluginPaths->isModified()) {
1923
pluginPaths = dia->textEditPluginPaths->text();
1924
QApplication::setLibraryPaths(QStringList::split("\n", pluginPaths));
1925
savePluginPaths = TRUE;
1928
if ( dia->radioPixmap->isChecked() && dia->buttonPixmap->pixmap() ) {
1929
qworkspace->setBackgroundPixmap( *dia->buttonPixmap->pixmap() );
1932
qworkspace->setBackgroundColor( dia->buttonColor->color() );
1935
splashScreen = dia->checkBoxSplash->isChecked();
1936
databaseAutoEdit = !dia->checkAutoEdit->isChecked();
1937
shStartDialog = dia->checkBoxStartDialog->isChecked();
1938
autoSaveEnabled = dia->checkBoxAutoSave->isChecked();
1939
QTime time = dia->timeEditAutoSave->time();
1940
autoSaveInterval = time.hour() * 3600 + time.minute() * 60 + time.second();
1941
if ( autoSaveEnabled )
1942
autoSaveTimer->start( autoSaveInterval * 1000 );
1944
autoSaveTimer->stop();
1946
delete senderObject;
1947
for ( it = preferenceTabs.begin(); it != preferenceTabs.end(); ++it ) {
1949
dia->tabWidget->removePage( t.w );
1950
t.w->reparent( 0, QPoint(0,0), FALSE );
1953
for ( SourceEditor *e = sourceEditors.first(); e; e = sourceEditors.next() )
1958
statusBar()->clear();
1961
void MainWindow::searchFind()
1963
if ( !qWorkspace()->activeWindow() ||
1964
!::qt_cast<SourceEditor*>(qWorkspace()->activeWindow()) )
1968
findDialog = new FindDialog( this, 0, FALSE );
1970
findDialog->raise();
1971
findDialog->setEditor( ( (SourceEditor*)qWorkspace()->activeWindow() )->editorInterface(),
1972
( (SourceEditor*)qWorkspace()->activeWindow() )->object() );
1973
findDialog->comboFind->setFocus();
1974
findDialog->comboFind->lineEdit()->selectAll();
1977
void MainWindow::searchIncremetalFindMenu()
1979
incrementalSearch->selectAll();
1980
incrementalSearch->setFocus();
1983
void MainWindow::searchIncremetalFind()
1985
if ( !qWorkspace()->activeWindow() ||
1986
!::qt_cast<SourceEditor*>(qWorkspace()->activeWindow()) )
1989
( (SourceEditor*)qWorkspace()->activeWindow() )->editorInterface()->find( incrementalSearch->text(),
1990
FALSE, FALSE, TRUE, FALSE );
1993
void MainWindow::searchIncremetalFindNext()
1995
if ( !qWorkspace()->activeWindow() ||
1996
!::qt_cast<SourceEditor*>(qWorkspace()->activeWindow()) )
1999
( (SourceEditor*)qWorkspace()->activeWindow() )->editorInterface()->find( incrementalSearch->text(),
2000
FALSE, FALSE, TRUE, TRUE );
2003
void MainWindow::searchReplace()
2005
if ( !qWorkspace()->activeWindow() ||
2006
!::qt_cast<SourceEditor*>(qWorkspace()->activeWindow()) )
2009
if ( !replaceDialog )
2010
replaceDialog = new ReplaceDialog( this, 0, FALSE );
2011
replaceDialog->show();
2012
replaceDialog->raise();
2013
replaceDialog->setEditor( ( (SourceEditor*)qWorkspace()->activeWindow() )->editorInterface(),
2014
( (SourceEditor*)qWorkspace()->activeWindow() )->object() );
2015
replaceDialog->comboFind->setFocus();
2016
replaceDialog->comboFind->lineEdit()->selectAll();
2019
void MainWindow::searchGotoLine()
2021
if ( !qWorkspace()->activeWindow() ||
2022
!::qt_cast<SourceEditor*>(qWorkspace()->activeWindow()) )
2025
if ( !gotoLineDialog )
2026
gotoLineDialog = new GotoLineDialog( this, 0, FALSE );
2027
gotoLineDialog->show();
2028
gotoLineDialog->raise();
2029
gotoLineDialog->setEditor( ( (SourceEditor*)qWorkspace()->activeWindow() )->editorInterface() );
2030
gotoLineDialog->spinLine->setFocus();
2031
gotoLineDialog->spinLine->setMinValue( 1 );
2032
gotoLineDialog->spinLine->setMaxValue( ( (SourceEditor*)qWorkspace()->activeWindow() )->numLines() );
2033
gotoLineDialog->spinLine->selectAll();
2036
void MainWindow::toolsCustomWidget()
2038
statusMessage( i18n( "Edit custom widgets..." ) );
2039
CustomWidgetEditor edit( this, this );
2041
rebuildCustomWidgetGUI();
2042
statusBar()->clear();
2045
void MainWindow::toolsConfigure()
2047
ConfigToolboxDialog dlg( this );
2048
if ( dlg.exec() != QDialog::Accepted )
2050
rebuildCommonWidgetsToolBoxPage();
2053
void MainWindow::showStartDialog()
2055
if ( singleProjectMode() )
2057
for ( int i = 1; i < qApp->argc(); ++i ) {
2058
QString arg = qApp->argv()[i];
2059
if ( arg[0] != '-' )
2062
StartDialog *sd = new StartDialog( this, templatePath() );
2063
sd->setRecentlyFiles( recentlyFiles );
2064
sd->setRecentlyProjects( recentlyProjects );
2066
shStartDialog = sd->showDialogInFuture();