📄 mainwindow.cpp
字号:
a->setStatusTip( tr( "Saves the current form with a new filename" ) ); a->setWhatsThis( tr( "Save the current form with a new filename" ) ); connect( a, SIGNAL( activated() ), this, SLOT( fileSaveAs() ) ); connect( this, SIGNAL( hasActiveForm(bool) ), a, SLOT( setEnabled(bool) ) ); a->addTo( menu ); a = new QAction( this, 0 ); a->setText( tr( "Save All" ) ); a->setMenuText( tr( "Sa&ve All" ) ); a->setStatusTip( tr( "Saves all open forms" ) ); a->setWhatsThis( tr( "Save all open forms" ) ); connect( a, SIGNAL( activated() ), this, SLOT( fileSaveAll() ) ); connect( this, SIGNAL( hasActiveForm(bool) ), a, SLOT( setEnabled(bool) ) ); a->addTo( menu ); menu->insertSeparator(); a = new QAction( this, 0 ); a->setText( tr( "Create Template" ) ); a->setMenuText( tr( "&Create Template..." ) ); a->setStatusTip( tr( "Creates a new template" ) ); a->setWhatsThis( tr( "Creates a new template" ) ); connect( a, SIGNAL( activated() ), this, SLOT( fileCreateTemplate() ) ); a->addTo( menu ); menu->insertSeparator(); a = new QAction( this, 0 ); a->setText( tr( "Exit" ) ); a->setMenuText( tr( "E&xit" ) ); a->setStatusTip( tr( "Quits the application and prompts to save changed forms" ) ); a->setWhatsThis( tr( "<b>Exit the designer</b>" "<p>The Qt Designer will ask if you want to save changed forms before " "the application closes.</p>") ); connect( a, SIGNAL( activated() ), qApp, SLOT( closeAllWindows() ) ); a->addTo( menu );}void MainWindow::setupPreviewActions(){ QAction* a = 0; QPopupMenu *menu = new QPopupMenu( this ); menubar->insertItem( tr( "&Preview" ), menu ); a = new QAction( tr( "Preview Form" ), createIconSet("previewform.xpm"), tr( "Preview &Form" ), 0, this, 0 ); a->setAccel( CTRL + Key_T ); a->setStatusTip( tr("Opens a preview") ); a->setWhatsThis( tr("<b>Open a preview</b>" "<p>Use the preview to test the design and " "signal-slot connections of the current form.</p>") ); connect( a, SIGNAL( activated() ), this, SLOT( previewForm() ) ); connect( this, SIGNAL( hasActiveForm(bool) ), a, SLOT( setEnabled(bool) ) ); a->addTo( menu ); menu->insertSeparator(); a = new QAction( tr( "Preview Form in Motif Style" ), createIconSet("previewform.xpm"), tr( "Preview Form in &Motif Style" ), 0, this, 0 ); a->setStatusTip( tr("Opens a preview in Motif style") ); a->setWhatsThis( tr("<b>Open a preview in Motif style.</b>" "<p>Use the preview to test the design and signal-slot " "connections of the form. The preview will use the Motif " "Look&Feel used as the default style on most UNIX-Systems.</p>") ); connect( a, SIGNAL( activated() ), this, SLOT( previewFormMotif() ) ); connect( this, SIGNAL( hasActiveForm(bool) ), a, SLOT( setEnabled(bool) ) ); a->addTo( menu ); a = new QAction( tr( "Preview Form in Windows Style" ), createIconSet("previewform.xpm"), tr( "Preview Form in &Windows Style" ), 0, this, 0 ); a->setStatusTip( tr("Opens a preview in Windows style") ); a->setWhatsThis( tr("<b>Open a preview in Windows style.</b>" "<p>Use the preview to test the design and signal-slot " "connections of the form. The preview will use the Windows " "Look&Feel used as the default style on Windows-Systems.</p>") ); connect( a, SIGNAL( activated() ), this, SLOT( previewFormWindows() ) ); connect( this, SIGNAL( hasActiveForm(bool) ), a, SLOT( setEnabled(bool) ) ); a->addTo( menu ); a = new QAction( tr( "Preview Form in Platinum Style" ), createIconSet("previewform.xpm"), tr( "Preview Form in &Platinum Style" ), 0, this, 0 ); a->setStatusTip( tr("Opens a preview in Platinum style") ); a->setWhatsThis( tr("<b>Open a preview in Platinum style.</b>" "<p>Use the preview to test the design and signal-slot " "connections of the form. The preview will use the Platinum " "Look&Feel resembling a Macinosh-like GUI style.</p>") ); connect( a, SIGNAL( activated() ), this, SLOT( previewFormPlatinum() ) ); connect( this, SIGNAL( hasActiveForm(bool) ), a, SLOT( setEnabled(bool) ) ); a->addTo( menu ); a = new QAction( tr( "Preview Form in CDE Style" ), createIconSet("previewform.xpm"), tr( "Preview Form in &CDE Style" ), 0, this, 0 ); a->setStatusTip( tr("Opens a preview in CDE style") ); a->setWhatsThis( tr("<b>Open a preview in CDE style.</b>" "<p>Use the preview to test the design and signal-slot " "connections of the form. The preview will use the CDE " "Look&Feel which is similar to some versions of the " "Common Desktop Environment.</p>") ); connect( a, SIGNAL( activated() ), this, SLOT( previewFormCDE() ) ); connect( this, SIGNAL( hasActiveForm(bool) ), a, SLOT( setEnabled(bool) ) ); a->addTo( menu ); a = new QAction( tr( "Preview Form in SGI Style" ), createIconSet("previewform.xpm"), tr( "Preview Form in &SGI Style" ), 0, this, 0 ); a->setStatusTip( tr("Opens a preview in SGI style") ); a->setWhatsThis( tr("<b>Open a preview in SGI style.</b>" "<p>Use the preview to test the design and signal-slot " "connections of the form. The preview will use the Motif " "Look&Feel used as the default style on SGI-systems.</p>") ); connect( a, SIGNAL( activated() ), this, SLOT( previewFormSGI() ) ); connect( this, SIGNAL( hasActiveForm(bool) ), a, SLOT( setEnabled(bool) ) ); a->addTo( menu ); a = new QAction( tr( "Preview Form in Motif Plus Style" ), createIconSet("previewform.xpm"), tr( "Preview Form in Motif &Plus Style" ), 0, this, 0 ); a->setStatusTip( tr("Opens a preview in Motif Plus style") ); a->setWhatsThis( tr("<b>Open a preview in Motif Plus style.</b>" "<p>Use the preview to test the design and signal-slot " "connections of the form. The preview will use an advanced " "Motif Look&Feel as used by the GIMP toolkit (GTK) on Linux.</p>") ); connect( a, SIGNAL( activated() ), this, SLOT( previewFormMotifPlus() ) ); connect( this, SIGNAL( hasActiveForm(bool) ), a, SLOT( setEnabled(bool) ) ); a->addTo( menu );}void MainWindow::setupWindowActions(){ if ( !actionWindowPropertyEditor ) { actionWindowPropertyEditor = new QAction( tr( "Property Editor" ), tr( "Property &Editor" ), 0, this, 0, TRUE ); actionWindowPropertyEditor->setStatusTip( tr("Toggles the Property Editor") ); actionWindowPropertyEditor->setWhatsThis( tr("<b>Toggle the Property Editor</b>" "<p>Use the property editor to change the attributes of the " "widgets in your form.</p>") ); connect( actionWindowPropertyEditor, SIGNAL( toggled(bool) ), this, SLOT( windowPropertyEditor(bool) ) ); actionWindowHierarchyView = new QAction( tr( "Object Hierarchy" ), tr( "Object &Hierarchy" ), 0, this, 0, TRUE ); actionWindowHierarchyView->setStatusTip( tr("Toggles the Object Hierarchy view") ); actionWindowHierarchyView->setWhatsThis( tr("<b>Toggle the Object Hierarchy view</b>" "<p>The object hierarchy gives a quick overview about the relations " "between the widgets in your form.</p>") ); connect( actionWindowHierarchyView, SIGNAL( toggled(bool) ), this, SLOT( windowHierarchyView(bool) ) ); actionWindowFormList = new QAction( tr( "Form List" ), tr( "&Form List" ), 0, this, 0, TRUE ); actionWindowFormList->setStatusTip( tr("Toggles the Form List") ); actionWindowFormList->setWhatsThis( tr("<b>Toggle the Form List</b>" "<p>The Form List displays the filenames of all open forms, and a flag indicates " "which forms have been changed.</p>") ); connect( actionWindowFormList, SIGNAL( toggled(bool) ), this, SLOT( windowFormList(bool) ) ); actionWindowTile = new QAction( tr( "Tile" ), tr( "&Tile" ), 0, this ); actionWindowTile->setStatusTip( tr("Arranges all windows tiled") ); actionWindowTile->setWhatsThis( tr("Arrange all windows tiled") ); connect( actionWindowTile, SIGNAL( activated() ), workspace, SLOT( tile() ) ); actionWindowCascade = new QAction( tr( "Cascade" ), tr( "&Cascade" ), 0, this ); actionWindowCascade->setStatusTip( tr("Arrange all windows cascaded") ); actionWindowCascade->setWhatsThis( tr("Arrange all windows cascaded") ); connect( actionWindowCascade, SIGNAL( activated() ), workspace, SLOT( cascade() ) ); actionWindowClose = new QAction( tr( "Close" ), tr( "Cl&ose" ), CTRL + Key_F4, this ); actionWindowClose->setStatusTip( tr( "Closes the active window") ); actionWindowClose->setWhatsThis( tr( "Close the active window") ); connect( actionWindowClose, SIGNAL( activated() ), workspace, SLOT( closeActiveWindow() ) ); actionWindowCloseAll = new QAction( tr( "Close All" ), tr( "Close Al&l" ), 0, this ); actionWindowCloseAll->setStatusTip( tr( "Closes all form windows") ); actionWindowCloseAll->setWhatsThis( tr( "Close all form windows") ); connect( actionWindowCloseAll, SIGNAL( activated() ), this, SLOT( closeAllForms() ) ); actionWindowNext = new QAction( tr( "Next" ), tr( "Ne&xt" ), CTRL + Key_F6, this ); actionWindowNext->setStatusTip( tr( "Activates the next window" ) ); actionWindowNext->setWhatsThis( tr( "Activate the next window" ) ); connect( actionWindowNext, SIGNAL( activated() ), workspace, SLOT( activateNextWindow() ) ); actionWindowPrevious = new QAction( tr( "Previous" ), tr( "Pre&vious" ), CTRL + SHIFT + Key_F6, this ); actionWindowPrevious->setStatusTip( tr( "Activates the previous window" ) ); actionWindowPrevious->setWhatsThis( tr( "Activate the previous window" ) ); connect( actionWindowPrevious, SIGNAL( activated() ), workspace, SLOT( activatePreviousWindow() ) ); } if ( !windowMenu ) { windowMenu = new QPopupMenu( this ); menubar->insertItem( tr( "&Window" ), windowMenu ); connect( windowMenu, SIGNAL( aboutToShow() ), this, SLOT( setupWindowActions() ) ); } else { windowMenu->clear(); } actionWindowClose->addTo( windowMenu ); actionWindowCloseAll->addTo( windowMenu ); windowMenu->insertSeparator(); actionWindowNext->addTo( windowMenu ); actionWindowPrevious->addTo( windowMenu ); windowMenu->insertSeparator(); actionWindowTile->addTo( windowMenu ); actionWindowCascade->addTo( windowMenu ); windowMenu->insertSeparator(); actionWindowPropertyEditor->addTo( windowMenu ); actionWindowHierarchyView->addTo( windowMenu ); actionWindowFormList->addTo( windowMenu ); QWidgetList windows = workspace->windowList(); if ( windows.count() && formWindow() ) windowMenu->insertSeparator(); int j = 0; for ( int i = 0; i < int( windows.count() ); ++i ) { QWidget *w = windows.at( i ); if ( !w->inherits( "FormWindow" ) ) continue; j++; QString itemText; if ( j < 10 ) itemText = QString("&%1 ").arg( j ); itemText += w->name(); int id = windowMenu->insertItem( itemText, this, SLOT( windowsMenuActivated( int ) ) ); windowMenu->setItemParameter( id, i ); windowMenu->setItemChecked( id, workspace->activeWindow() == windows.at( i ) ); }}void MainWindow::setupHelpActions(){ actionHelpContents = new QAction( tr( "Contents" ), tr( "&Contents" ), Key_F1, this, 0 ); actionHelpContents->setStatusTip( tr("Opens the online help") ); actionHelpContents->setWhatsThis( tr("<b>Open the online help</b>" "<p>Use the online help to get detailed information " "about selected components. Press the F1 key to open " "context sensitive help on the selected item or property.</p>") ); connect( actionHelpContents, SIGNAL( activated() ), this, SLOT( helpContents() ) ); actionHelpManual = new QAction( tr( "Manual" ), tr( "&Manual" ), CTRL + Key_M, this, 0 ); actionHelpManual->setStatusTip( tr("Opens the Qt Designer manual") ); actionHelpManual->setWhatsThis( tr("<b>Open the Qt Designer manual</b>" "<p>Use the Qt Designer Manual to get help about how to use the Qt Designer.</p>") ); connect( actionHelpManual, SIGNAL( activated() ), this, SLOT( helpManual() ) ); actionHelpAbout = new QAction( tr("About"), QPixmap(), tr("&About..."), 0, this, 0 ); actionHelpAbout->setStatusTip( tr("Displays information about this product") ); actionHelpAbout->setWhatsThis( tr("Get information about this product") ); connect( actionHelpAbout, SIGNAL( activated() ), this, SLOT( helpAbout() ) ); actionHelpAboutQt = new QAction( tr("About Qt"), QPixmap(), tr("About &Qt..."), 0, this, 0 ); actionHelpAboutQt->setStatusTip( tr("Displays information about the Qt Toolkit") ); actionHelpAboutQt->setWhatsThis( tr("Get information about the Qt Toolkit") ); connect( actionHelpAboutQt, SIGNAL( activated() ), this, SLOT( helpAboutQt() ) ); actionHelpWhatsThis = new QAction( tr("What's This?"), QIconSet( whatsthis_image, whatsthis_image ), tr("What's This?"), SHIFT + Key_F1, this, 0 ); actionHelpWhatsThis->setStatusTip( tr("\"What's This?\" context sensitive help") ); actionHelpWhatsThis->setWhatsThis( tr("<b>That's me!</b>" "<p>In What's This?-Mode, the mouse cursor shows an arrow with a questionmark, " "and you can click on the interface elements to get a short " "description of what they do and how to use them. In dialogs, " "this feature can be accessed using the context help button in the titlebar.</p>") ); connect( actionHelpWhatsThis, SIGNAL( activated() ), this, SLOT( whatsThis() ) );#if defined(HAVE_KDE) KToolBar *tb = new KToolBar( this ); tb->setFullSize( FALSE );#else QToolBar *tb = new QToolBar( this );#endif QWhatsThis::add( tb, tr( "<b>The Help toolbar</b>%1" ).arg(tr(toolbarHelp).arg("") )); addToolBar( tb, tr( "Help" ) ); actionHelpWhatsThis->addTo( tb ); QPopupMenu *menu = new QPopupMenu( this ); menubar->insertSeparator(); menubar->insertItem( tr( "&Help" ), menu ); actionHelpContents->addTo( menu ); actionHelpManual->addTo( menu ); menu->insertSeparator(); actionHelpAbout->addTo( menu ); actionHelpAboutQt->addTo( menu ); menu->insertSeparator(); actionHelpWhatsThis->addTo( menu );}void MainWindow::setupPropertyEditor(){ propertyEditor = new PropertyEditor( workspace ); propertyEditor->resize( 300, 600 ); QWhatsThis::add( propertyEditor, tr("<b>The Property Editor</b>" "<p>You can change the appearance and behaviour of the selected widget in the " "property editor.</p>" "<p>You can set properties for components and forms at design time and see the " "changes immediately. Each property has its own editor which you can use to enter " "new values, open a special dialog or select values from a predefined list. " "Use <b>F1</b> to get detailed help for the selected property.</p>" "<p>You can resize the columns of the editor by dragging the separators of the list " "header.</p>") ); propGeom = QRect( 0, 0, 300, 600 ); connect( propertyEditor, SIGNAL( hidden() ), this, SLOT( propertyEditorHidden() ) ); actionWindowPropertyEditor->setOn( TRUE );}void MainWindow::setupHierarchyView(){ if ( hierarchyView ) return; hierarchyView = new HierarchyView( workSpace() ); hierarchyView->setCaption( tr( "Object Hierarchy" ) ); hierarchyView->resize( 300, 500 ); hvGeom = QRect( -1, -1, 300, 500 ); QWhatsThis::add( hierarchyView, tr("<b>The Hierarchy View</b>" "<p>The object hierarchy gives a quick overview about the relations " "between the widgets in your form. You can use the clipboard functions using " "a context menu for each item in the view.</p>" "<p>The columns can be resized by dragging the separator in the list header.</p>" ) ); connect( hierarchyView, SIGNAL( hidden() ), this, SLOT( hierarchyViewHidden() ) ); actionWindowHierarchyView->setOn( FALSE ); hierarchyView->hide();}void MainWindow::setupFormList(){ formList = new FormList( workSpace(), this ); formList->setCaption( tr( "Forms" ) ); formList->resize( 600, 300 ); flGeom = QRect( -1, -1, 600, 300 ); QWhatsThis::add( formList, tr("<b>The Form List</b>" "<p>The Form List displays the filenames of all open forms, and a flag indicates " "which forms have been changed.</p>" "<p>The columns can be resized by dragging the separator in the list header.</p>") ); connect( formList, SIGNAL( hidden() ), this, SLOT( formListHidden() ) ); actionWindowFormList->setOn( FALSE ); formList->hide();}void MainWindow::setupRMBMenus(){ rmbWidgets = new QPopupMenu( this ); actionEditCut->addTo( rmbWidgets ); actionEditCopy->addTo( rmbWidgets ); actionEditPaste->addTo( rmbWidgets ); actionEditDelete->addTo( rmbWidgets );#if 0 rmbWidgets->insertSeparator();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -