⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mainwindowactions.cpp

📁 这个是Linux的qt源代码
💻 CPP
📖 第 1 页 / 共 5 页
字号:
    a = new QAction( this, 0 );    a->setText( tr( "Close" ) );    a->setMenuText( tr( "&Close" ) );    a->setStatusTip( tr( "Closes the current project or document" ) );    a->setWhatsThis(whatsThisFrom( "File|Close" ) );    connect( a, SIGNAL( activated() ), this, SLOT( fileClose() ) );    connect( this, SIGNAL( hasActiveWindowOrProject(bool) ), a, SLOT( setEnabled(bool) ) );    if ( !singleProject ) {	a->addTo( fileMenu );	fileMenu->insertSeparator();    }    a = new QAction( this, 0 );    actionFileSave = a;    a->setText( tr( "Save" ) );    a->setMenuText( tr( "&Save" ) );    a->setIconSet( createIconSet("designer_filesave.png") );    a->setAccel( CTRL + Key_S );    a->setStatusTip( tr( "Saves the current project or document" ) );    a->setWhatsThis(whatsThisFrom( "File|Save" ) );    connect( a, SIGNAL( activated() ), this, SLOT( fileSave() ) );    connect( this, SIGNAL( hasActiveWindowOrProject(bool) ), a, SLOT( setEnabled(bool) ) );    a->addTo( tb );    a->addTo( fileMenu );    a = new QAction( this, 0 );    a->setText( tr( "Save As" ) );    a->setMenuText( tr( "Save &As..." ) );    a->setStatusTip( tr( "Saves the current form with a new filename" ) );    a->setWhatsThis( whatsThisFrom( "File|Save As" ) );    connect( a, SIGNAL( activated() ), this, SLOT( fileSaveAs() ) );    connect( this, SIGNAL( hasActiveWindow(bool) ), a, SLOT( setEnabled(bool) ) );    if ( !singleProject )	a->addTo( fileMenu );    a = new QAction( this, 0 );    a->setText( tr( "Save All" ) );    a->setMenuText( tr( "Sa&ve All" ) );    a->setStatusTip( tr( "Saves all open documents" ) );    a->setWhatsThis( whatsThisFrom( "File|Save All" ) );    connect( a, SIGNAL( activated() ), this, SLOT( fileSaveAll() ) );    connect( this, SIGNAL( hasActiveWindowOrProject(bool) ), a, SLOT( setEnabled(bool) ) );    if ( !singleProject ) {	a->addTo( fileMenu );	fileMenu->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( whatsThisFrom( "File|Create Template" ) );    connect( a, SIGNAL( activated() ), this, SLOT( fileCreateTemplate() ) );    if ( !singleProject )	a->addTo( fileMenu );    if ( !singleProject )	fileMenu->insertSeparator();    recentlyFilesMenu = new QPopupMenu( this );    recentlyProjectsMenu = new QPopupMenu( this );    if ( !singleProject ) {	fileMenu->insertItem( tr( "Recently opened files " ), recentlyFilesMenu );	fileMenu->insertItem( tr( "Recently opened projects" ), recentlyProjectsMenu );    }    connect( recentlyFilesMenu, SIGNAL( aboutToShow() ),	     this, SLOT( setupRecentlyFilesMenu() ) );    connect( recentlyProjectsMenu, SIGNAL( aboutToShow() ),	     this, SLOT( setupRecentlyProjectsMenu() ) );    connect( recentlyFilesMenu, SIGNAL( activated( int ) ),	     this, SLOT( recentlyFilesMenuActivated( int ) ) );    connect( recentlyProjectsMenu, SIGNAL( activated( int ) ),	     this, SLOT( recentlyProjectsMenuActivated( int ) ) );    if ( !singleProject )	fileMenu->insertSeparator();    a = new QAction( this, 0 );    actionFileExit = a;    if  ( !singleProjectMode() ) {	a->setText( tr( "Exit" ) );	a->setMenuText( tr( "E&xit" ) );	a->setStatusTip( tr( "Quits the application and prompts to save any changed forms, source files or project settings" ) );	a->setWhatsThis( whatsThisFrom( "File|Exit" ) );    } else {	a->setText( tr( "Close" ) );	a->setMenuText( tr( "&Close" ) );    }    connect( a, SIGNAL( activated() ), this, SLOT( fileQuit() ) );    a->addTo( fileMenu );}void MainWindow::setupProjectActions(){    projectMenu = new QPopupMenu( this, "Project" );    menubar->insertItem( tr( "Pr&oject" ), projectMenu );    QActionGroup *ag = new QActionGroup( this, 0 );    ag->setText( tr( "Active Project" ) );    ag->setMenuText( tr( "Active Project" ) );    ag->setExclusive( TRUE );    ag->setUsesDropDown( TRUE );    connect( ag, SIGNAL( selected( QAction * ) ), this, SLOT( projectSelected( QAction * ) ) );    connect( ag, SIGNAL( selected( QAction * ) ), this, SIGNAL( projectChanged() ) );    QAction *a = new QAction( tr( "<No Project>" ), tr( "<No Project>" ), 0, ag, 0, TRUE );    eProject = new Project( "", tr( "<No Project>" ), projectSettingsPluginManager, TRUE );    projects.insert( a, eProject );    a->setOn( TRUE );    ag->addTo( projectMenu );    ag->addTo( projectToolBar );    actionGroupProjects = ag;    if ( !singleProject )	projectMenu->insertSeparator();    a = new QAction( tr( "Add File" ), QPixmap(), tr( "&Add File..." ), 0, this, 0 );    a->setStatusTip( tr("Adds a file to the current project") );    a->setWhatsThis( whatsThisFrom( "Project|Add File" ) );    connect( a, SIGNAL( activated() ), this, SLOT( projectInsertFile() ) );    a->setEnabled( FALSE );    connect( this, SIGNAL( hasNonDummyProject(bool) ), a, SLOT( setEnabled(bool) ) );    if ( !singleProject )	a->addTo( projectMenu );    QAction* actionEditPixmapCollection = new QAction( tr( "Image Collection..." ), QPixmap(),					  tr( "&Image Collection..." ), 0, this, 0 );    actionEditPixmapCollection->setStatusTip( tr("Opens a dialog for editing the current project's image collection") );    actionEditPixmapCollection->setWhatsThis( whatsThisFrom( "Project|Image Collection" ) );    connect( actionEditPixmapCollection, SIGNAL( activated() ), this, SLOT( editPixmapCollection() ) );    actionEditPixmapCollection->setEnabled( FALSE );    connect( this, SIGNAL( hasNonDummyProject(bool) ), actionEditPixmapCollection, SLOT( setEnabled(bool) ) );    actionEditPixmapCollection->addTo( projectMenu );#ifndef QT_NO_SQL    QAction* actionEditDatabaseConnections = new QAction( tr( "Database Connections..." ), QPixmap(),						 tr( "&Database Connections..." ), 0, this, 0 );    actionEditDatabaseConnections->setStatusTip( tr("Opens a dialog for editing the current project's database connections") );    actionEditDatabaseConnections->setWhatsThis( whatsThisFrom( "Project|Database Connections" ) );    connect( actionEditDatabaseConnections, SIGNAL( activated() ), this, SLOT( editDatabaseConnections() ) );    //actionEditDatabaseConnections->setEnabled( FALSE );    //connect( this, SIGNAL( hasNonDummyProject(bool) ), actionEditDatabaseConnections, SLOT( setEnabled(bool) ) );    if ( !singleProject )	actionEditDatabaseConnections->addTo( projectMenu );#endif    QAction* actionEditProjectSettings = new QAction( tr( "Project Settings..." ), QPixmap(),					  tr( "&Project Settings..." ), 0, this, 0 );    actionEditProjectSettings->setStatusTip( tr("Opens a dialog to change the project's settings") );    actionEditProjectSettings->setWhatsThis( whatsThisFrom( "Project|Project Settings" ) );    connect( actionEditProjectSettings, SIGNAL( activated() ), this, SLOT( editProjectSettings() ) );    actionEditProjectSettings->setEnabled( FALSE );    connect( this, SIGNAL( hasNonDummyProject(bool) ), actionEditProjectSettings, SLOT( setEnabled(bool) ) );    actionEditProjectSettings->addTo( projectMenu );}void MainWindow::setupPreviewActions(){    QAction* a = 0;    QPopupMenu *menu = new QPopupMenu( this, "Preview" );    layoutMenu = menu;    menubar->insertItem( tr( "&Preview" ), menu, toolsMenuId + 2 );    a = new QAction( tr( "Preview Form" ), QPixmap(), tr( "Preview &Form" ), 0, this, 0 );    a->setAccel( CTRL + Key_T );    a->setStatusTip( tr("Opens a preview") );    a->setWhatsThis( whatsThisFrom( "Preview|Preview Form" ) );    connect( a, SIGNAL( activated() ), this, SLOT( previewForm() ) );    connect( this, SIGNAL( hasActiveForm(bool) ), a, SLOT( setEnabled(bool) ) );    a->addTo( menu );    menu->insertSeparator();    QSignalMapper *mapper = new QSignalMapper( this );    connect( mapper, SIGNAL(mapped(const QString&)), this, SLOT(previewForm(const QString&)) );    QStringList styles = QStyleFactory::keys();    for ( QStringList::Iterator it = styles.begin(); it != styles.end(); ++it ) {	QString info;	if ( *it == "Motif" )	    info = tr( "The preview will use the Motif look and feel which is used as the default style on most UNIX systems." );	else if ( *it == "Windows" )	    info = tr( "The preview will use the Windows look and feel." );	else if ( *it == "Platinum" )	    info = tr( "The preview will use the Platinum look and feel which is similar to the Macinosh GUI style." );	else if ( *it == "CDE" )	    info = tr( "The preview will use the CDE look and feel which is similar to some versions of the Common Desktop Environment." );	else if ( *it == "SGI" )	    info = tr( "The preview will use the Motif look and feel which is used as the default style on SGI systems." );	else if ( *it == "MotifPlus" )	    info = tr( "The preview will use the advanced Motif look and feel used by the GIMP toolkit (GTK) on Linux." );	a = new QAction( tr( "Preview Form in %1 Style" ).arg( *it ), QPixmap(),					 tr( "... in %1 Style" ).arg( *it ), 0, this, 0 );	a->setStatusTip( tr("Opens a preview in %1 style").arg( *it ) );	a->setWhatsThis( tr("<b>Open a preview in %1 style.</b>"			"<p>Use the preview to test the design and "			"signal-slot connections of the current form. %2</p>").arg( *it ).arg( info ) );	mapper->setMapping( a, *it );	connect( a, SIGNAL(activated()), mapper, SLOT(map()) );	connect( this, SIGNAL( hasActiveForm(bool) ), a, SLOT( setEnabled(bool) ) );	a->addTo( menu );    }}void MainWindow::setupWindowActions(){    static bool windowActionsSetup = FALSE;    if ( !windowActionsSetup ) {	windowActionsSetup = TRUE;	actionWindowTile = new QAction( tr( "Tile" ), tr( "&Tile" ), 0, this );	actionWindowTile->setStatusTip( tr("Tiles the windows so that they are all visible") );	actionWindowTile->setWhatsThis( whatsThisFrom( "Window|Tile" ) );	connect( actionWindowTile, SIGNAL( activated() ), qworkspace, SLOT( tile() ) );	actionWindowCascade = new QAction( tr( "Cascade" ), tr( "&Cascade" ), 0, this );	actionWindowCascade->setStatusTip( tr("Cascades the windows so that all their title bars are visible") );	actionWindowCascade->setWhatsThis( whatsThisFrom( "Window|Cascade" ) );	connect( actionWindowCascade, SIGNAL( activated() ), qworkspace, SLOT( cascade() ) );	actionWindowClose = new QAction( tr( "Close" ), tr( "Cl&ose" ), CTRL + Key_F4, this );	actionWindowClose->setStatusTip( tr( "Closes the active window") );	actionWindowClose->setWhatsThis( whatsThisFrom( "Window|Close" ) );	connect( actionWindowClose, SIGNAL( activated() ), qworkspace, SLOT( closeActiveWindow() ) );	actionWindowCloseAll = new QAction( tr( "Close All" ), tr( "Close Al&l" ), 0, this );	actionWindowCloseAll->setStatusTip( tr( "Closes all form windows") );	actionWindowCloseAll->setWhatsThis( whatsThisFrom( "Window|Close All" ) );	connect( actionWindowCloseAll, SIGNAL( activated() ), qworkspace, SLOT( closeAllWindows() ) );	actionWindowNext = new QAction( tr( "Next" ), tr( "Ne&xt" ), CTRL + Key_F6, this );	actionWindowNext->setStatusTip( tr( "Activates the next window" ) );	actionWindowNext->setWhatsThis( whatsThisFrom( "Window|Next" ) );	connect( actionWindowNext, SIGNAL( activated() ), qworkspace, SLOT( activateNextWindow() ) );	actionWindowPrevious = new QAction( tr( "Previous" ), tr( "Pre&vious" ), CTRL + SHIFT + Key_F6, this );	actionWindowPrevious->setStatusTip( tr( "Activates the previous window" ) );	actionWindowPrevious->setWhatsThis( whatsThisFrom( "Window|Previous" ) );	connect( actionWindowPrevious, SIGNAL( activated() ), qworkspace, SLOT( activatePreviousWindow() ) );    }    if ( !windowMenu ) {	windowMenu = new QPopupMenu( this, "Window" );	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();    windowMenu->insertItem( tr( "Vie&ws" ), createDockWindowMenu( NoToolBars ) );    windowMenu->insertItem( tr( "Tool&bars" ), createDockWindowMenu( OnlyToolBars ) );    QWidgetList windows = qworkspace->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" ) && !w->inherits( "SourceEditor" ) )	    continue;	if ( w->inherits( "FormWindow" ) && ( ( (FormWindow*)w )->isFake() ) )	    continue;	j++;	QString itemText;	if ( j < 10 )	    itemText = QString("&%1 ").arg( j );	if ( w->inherits( "FormWindow" ) )	    itemText += w->name();	else	    itemText += w->caption();	int id = windowMenu->insertItem( itemText, this, SLOT( windowsMenuActivated( int ) ) );	windowMenu->setItemParameter( id, i );	windowMenu->setItemChecked( id, qworkspace->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( whatsThisFrom( "Help|Contents" ) );    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( whatsThisFrom( "Help|Manual" ) );    connect( actionHelpManual, SIGNAL( activated() ), this, SLOT( helpManual() ) );    actionHelpAbout = new QAction( tr("About"), QPixmap(), tr("&About"), 0, this, 0 );    actionHelpAbout->setStatusTip( tr("Displays information about Qt Designer") );    actionHelpAbout->setWhatsThis( whatsThisFrom( "Help|About" ) );    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( whatsThisFrom( "Help|About Qt" ) );    connect( actionHelpAboutQt, SIGNAL( activated() ), this, SLOT( helpAboutQt() ) );#if defined(QT_NON_COMMERCIAL)    actionHelpRegister = new QAction( tr("Register Qt"), QPixmap(), tr("&Register Qt..."), 0, this, 0 );    actionHelpRegister->setStatusTip( tr("Opens a web browser at the evaluation form on www.trolltech.com") );    actionHelpRegister->setWhatsThis( tr("Register with Trolltech") );    connect( actionHelpRegister, SIGNAL( activated() ), this, SLOT( helpRegister() ) );#endif    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( whatsThisFrom( "Help|What's This?" ) );    connect( actionHelpWhatsThis, SIGNAL( activated() ), this, SLOT( whatsThis() ) );    QToolBar *tb = new QToolBar( this, "Help" );    tb->setCloseMode( QDockWindow::Undocked );    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, "Help" );    menubar->insertSeparator();    menubar->insertItem( tr( "&Help" ), menu );    actionHelpContents->addTo( menu );    actionHelpManual->addTo( menu );    menu->insertSeparator();    actionHelpAbout->addTo( menu );    actionHelpAboutQt->addTo( menu );#if defined(QT_NON_COMMERCIAL)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -