source: trunk/tools/designer/plugins/wizards/mainwindowwizard.ui.h

Last change on this file was 197, checked in by rudi, 14 years ago

Added QtDesigner

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