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

📄 mainwindowactions.cpp

📁 Linux下的基于X11的图形开发环境。
💻 CPP
📖 第 1 页 / 共 5 页
字号:
    actionEditBreakLayout = new QAction( tr( "Break Layout" ), createIconSet("editbreaklayout.png"),					 tr( "&Break Layout" ), CTRL + Key_B, this, 0 );    actionEditBreakLayout->setStatusTip(tr("Breaks the selected layout") );    actionEditBreakLayout->setWhatsThis( whatsThisFrom( "Layout|Break Layout" ) );    connect( actionEditBreakLayout, SIGNAL( activated() ), this, SLOT( editBreakLayout() ) );    actionEditBreakLayout->setEnabled( FALSE );    int id = WidgetDatabase::idFromClassName( "Spacer" );    actionInsertSpacer = new WidgetAction( "Layout", actionGroupTools, QString::number( id ).latin1() );    actionInsertSpacer->setToggleAction( TRUE );    actionInsertSpacer->setText( WidgetDatabase::className( id ) );    actionInsertSpacer->setMenuText( tr( "Add ") + WidgetDatabase::className( id ) );    actionInsertSpacer->setIconSet( WidgetDatabase::iconSet( id ) );    actionInsertSpacer->setToolTip( WidgetDatabase::toolTip( id ) );    actionInsertSpacer->setStatusTip( tr( "Insert a %1").arg(WidgetDatabase::toolTip( id )) );    actionInsertSpacer->setWhatsThis( QString("<b>A %1</b><p>%2</p>"			     "<p>Click to insert a single %3,"			     "or double click to keep the tool selected.")	.arg(WidgetDatabase::toolTip( id ))	.arg(WidgetDatabase::whatsThis( id ))	.arg(WidgetDatabase::toolTip( id ) ));    actionInsertSpacer->addTo( commonWidgetsToolBar );    commonWidgetsPage.append( actionInsertSpacer );    QWidget *w;    commonWidgetsToolBar->setStretchableWidget( ( w = new QWidget( commonWidgetsToolBar ) ) );    w->setBackgroundMode( commonWidgetsToolBar->backgroundMode() );    QWhatsThis::add( layoutToolBar, tr( "<b>The Layout toolbar</b>%1" ).arg(tr(toolbarHelp).arg("")) );    actionEditAdjustSize->addTo( layoutToolBar );    layoutToolBar->addSeparator();    actionEditHLayout->addTo( layoutToolBar );    actionEditVLayout->addTo( layoutToolBar );    actionEditGridLayout->addTo( layoutToolBar );    actionEditSplitHorizontal->addTo( layoutToolBar );    actionEditSplitVertical->addTo( layoutToolBar );    actionEditBreakLayout->addTo( layoutToolBar );    layoutToolBar->addSeparator();    actionInsertSpacer->addTo( layoutToolBar );    QPopupMenu *menu = new QPopupMenu( this, "Layout" );    layoutMenu = menu;    menubar->insertItem( tr( "&Layout" ), menu, toolsMenuId + 1 );    actionEditAdjustSize->addTo( menu );    menu->insertSeparator();    actionEditHLayout->addTo( menu );    actionEditVLayout->addTo( menu );    actionEditGridLayout->addTo( menu );    actionEditSplitHorizontal->addTo( menu );    actionEditSplitVertical->addTo( menu );    actionEditBreakLayout->addTo( menu );    menu->insertSeparator();    actionInsertSpacer->addTo( menu );}void MainWindow::setupToolActions(){    if ( !actionGroupTools ) {	actionGroupTools = new QActionGroup( this );	actionGroupTools->setExclusive( TRUE );	connect( actionGroupTools, SIGNAL( selected(QAction*) ),		 this, SLOT( toolSelected(QAction*) ) );    }    actionPointerTool = new QAction( tr("Pointer"), createIconSet("pointer.png"),				     tr("&Pointer"),  Key_F2,				     actionGroupTools,				     QString::number(POINTER_TOOL).latin1(), TRUE );    actionPointerTool->setStatusTip( tr("Selects the pointer tool") );    actionPointerTool->setWhatsThis( whatsThisFrom( "Tools|Pointer" ) );    actionConnectTool = new QAction( tr("Connect Signal/Slots"),				     createIconSet("connecttool.png"),				     tr("&Connect Signal/Slots"),				     singleProjectMode() ? 0 : Key_F3,				     actionGroupTools,				     QString::number(CONNECT_TOOL).latin1(), TRUE );    actionConnectTool->setStatusTip( tr("Selects the connection tool") );    actionConnectTool->setWhatsThis( whatsThisFrom( "Tools|Connect Signals and Slots" ) );    actionOrderTool = new QAction( tr("Tab Order"), createIconSet("ordertool.png"),				   tr("Tab &Order"),  Key_F4,				   actionGroupTools,				   QString::number(ORDER_TOOL).latin1(), TRUE );    actionOrderTool->setStatusTip( tr("Selects the tab order tool") );    actionOrderTool->setWhatsThis( whatsThisFrom( "Tools|Tab Order" ) );    actionBuddyTool = new QAction( tr( "Set Buddy" ), createIconSet( "setbuddy.png" ),				   tr( "Set &Buddy" ), Key_F5,				   actionGroupTools, QString::number( BUDDY_TOOL ).latin1(),				   TRUE );    actionBuddyTool->setStatusTip( tr( "Sets a buddy to a label" ) );    actionBuddyTool->setWhatsThis( whatsThisFrom( "Tools|Set Buddy" ) );    QToolBar *tb = new QToolBar( this, "Tools" );    tb->setCloseMode( QDockWindow::Undocked );    toolsToolBar = tb;    QWhatsThis::add( tb, tr( "<b>The Tools toolbar</b>%1" ).arg(tr(toolbarHelp).arg("")) );    addToolBar( tb, tr( "Tools" ), QMainWindow::DockTop, FALSE );    actionPointerTool->addTo( tb );    if ( !singleProjectMode() )	actionConnectTool->addTo( tb );    actionOrderTool->addTo( tb );    actionBuddyTool->addTo( tb );    QPopupMenu *mmenu = new QPopupMenu( this, "Tools" );    toolsMenu = mmenu;    toolsMenuId = 100;    menubar->insertItem( tr( "&Tools" ), mmenu, toolsMenuId );    toolsMenuIndex = menubar->indexOf( toolsMenuId );    actionPointerTool->addTo( mmenu );    if ( !singleProjectMode() )	actionConnectTool->addTo( mmenu );    actionOrderTool->addTo( mmenu );    actionBuddyTool->addTo( mmenu );    mmenu->insertSeparator();    customWidgetToolBar = 0;    customWidgetMenu = 0;    actionToolsCustomWidget = new QAction( tr("Custom Widgets"),					   createIconSet( "customwidget.png" ),					   tr("Edit &Custom Widgets..."), 0, this, 0 );    actionToolsCustomWidget->setStatusTip( tr("Opens a dialog to add and change "					      "custom widgets") );    actionToolsCustomWidget->setWhatsThis( whatsThisFrom( "Tools|Custom|Edit Custom"							  "Widgets" ) );    connect( actionToolsCustomWidget, SIGNAL( activated() ),	     this, SLOT( toolsCustomWidget() ) );    for ( int j = 0; j < WidgetDatabase::numWidgetGroups(); ++j ) {	QString grp = WidgetDatabase::widgetGroup( j );	if ( !WidgetDatabase::isGroupVisible( grp ) ||	     WidgetDatabase::isGroupEmpty( grp ) )	    continue;	QToolBar *tb = new QToolBar( this, grp.latin1() );	tb->setCloseMode( QDockWindow::Undocked );	widgetToolBars.append( tb );	bool plural = grp[(int)grp.length()-1] == 's';	if ( plural ) {	    QWhatsThis::add( tb, tr( "<b>The %1</b>%2" ).arg(grp).arg(tr(toolbarHelp).				arg( tr(" Click on a button to insert a single widget, "				"or double click to insert multiple %1.") ).arg(grp)) );	} else {	    QWhatsThis::add( tb, tr( "<b>The %1 Widgets</b>%2" ).arg(grp).arg(tr(toolbarHelp).				arg( tr(" Click on a button to insert a single %1 widget, "				"or double click to insert multiple widgets.") ).arg(grp)) );	}	addToolBar( tb, grp );	tb->hide();	QPopupMenu *menu = new QPopupMenu( this, grp.latin1() );	mmenu->insertItem( grp, menu );	QToolBar *tb2 = new QToolBar( grp, 0, toolBox, FALSE, grp.latin1() );	tb2->setFrameStyle( QFrame::NoFrame );	tb2->setOrientation( Qt::Vertical );	toolBox->addCategory( grp, tb2 );	if ( grp == "Custom" ) {	    if ( !customWidgetMenu )		actionToolsCustomWidget->addTo( menu );	    else		menu->insertSeparator();	    customWidgetMenu = menu;	    customWidgetToolBar = tb;	}	for ( int i = 0; i < WidgetDatabase::count(); ++i ) {	    if ( WidgetDatabase::group( i ) != grp )		continue; // only widgets, i.e. not forms and temp stuff	    WidgetAction* a =		new WidgetAction( grp, actionGroupTools, QString::number( i ).latin1() );	    a->setToggleAction( TRUE );	    QString atext = WidgetDatabase::className( i );	    if ( atext[0] == 'Q' )		atext = atext.mid(1);	    while ( atext.length() && atext[0] >= 'a' && atext[0] <= 'z' )		atext = atext.mid(1);	    if ( atext.isEmpty() )		atext = WidgetDatabase::className( i );	    a->setText( atext );	    QString ttip = WidgetDatabase::toolTip( i );	    a->setIconSet( WidgetDatabase::iconSet( i ) );	    a->setToolTip( ttip );	    if ( !WidgetDatabase::isWhatsThisLoaded() )		WidgetDatabase::loadWhatsThis( documentationPath() );	    a->setStatusTip( tr( "Insert a %1").arg(WidgetDatabase::className( i )) );	    QString whats = QString("<b>A %1</b>").arg( WidgetDatabase::className( i ) );	    if ( !WidgetDatabase::whatsThis( i ).isEmpty() )	    whats += QString("<p>%1</p>").arg(WidgetDatabase::whatsThis( i ));	    a->setWhatsThis( whats+ tr("<p>Double click on this tool to keep it selected.</p>") );	    if ( grp != "KDE" )		a->addTo( tb );	    a->addTo( menu );	    a->addTo( tb2 );	    if ( WidgetDatabase::isCommon( i ) ) {		a->addTo( commonWidgetsToolBar );		commonWidgetsPage.append( a );	    }	}	QWidget *w;	tb2->setStretchableWidget( ( w = new QWidget( tb2 ) ) );	w->setBackgroundMode( tb2->backgroundMode() );    }    if ( !customWidgetToolBar ) {	QToolBar *tb = new QToolBar( this, "Custom Widgets" );	tb->setCloseMode( QDockWindow::Undocked );	QWhatsThis::add( tb, tr( "<b>The Custom Widgets toolbar</b>%1"				 "<p>Click <b>Edit Custom Widgets...</b>"				 "in the <b>Tools|Custom</b> menu to "				 "add and change custom widgets</p>" ).			 arg(tr(toolbarHelp).			     arg( tr(" Click on the buttons to insert a single widget, "				     "or double click to insert multiple widgets.") )) );	addToolBar( tb, "Custom" );	tb->hide();	widgetToolBars.append( tb );	customWidgetToolBar = tb;	QPopupMenu *menu = new QPopupMenu( this, "Custom Widgets" );	mmenu->insertItem( "Custom", menu );	customWidgetMenu = menu;	customWidgetToolBar->hide();	actionToolsCustomWidget->addTo( customWidgetMenu );	customWidgetMenu->insertSeparator();	QToolBar *tb2 = new QToolBar( "Custom Widgets", 0,				      toolBox, FALSE, "Custom Widgets" );	tb2->setOrientation( Qt::Vertical );	tb2->setFrameStyle( QFrame::NoFrame );	toolBox->addCategory( "Custom Widgets", tb2 );	customWidgetToolBar2 = tb2;    }    QAction *a = new QAction( tr( "Configure Toolbox" ), tr( "Configure Toolbox..." ), 0, this );    a->setStatusTip( tr( "Opens a dialog to configure the common "					       "widgets page of the toolbox") );    connect( a, SIGNAL( activated() ), this, SLOT( toolsConfigure() ) );    mmenu->insertSeparator();    a->addTo( mmenu );    resetTool();}void MainWindow::setupFileActions(){    QToolBar* tb  = new QToolBar( this, "File" );    tb->setCloseMode( QDockWindow::Undocked );    projectToolBar = tb;    QWhatsThis::add( tb, tr( "<b>The File toolbar</b>%1" ).arg(tr(toolbarHelp).arg("")) );    addToolBar( tb, tr( "File" ) );    fileMenu = new QPopupMenu( this, "File" );    menubar->insertItem( tr( "&File" ), fileMenu );    QAction *a = 0;    if ( !singleProject ) {	a = new QAction( this, 0 );	a->setText( tr( "New" ) );	a->setToolTip( tr( "New Dialog or File" ) );	a->setMenuText( tr( "&New..." ) );	a->setIconSet( createIconSet("filenew.png") );	a->setAccel( CTRL + Key_N );	a->setStatusTip( tr( "Creates a new project, form or source file." ) );	a->setWhatsThis( whatsThisFrom( "File|New" ) );	connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) );	a->addTo( tb );	a->addTo( fileMenu );    } else {	actionGroupNew = new QActionGroup( this, 0, FALSE );	 a = actionGroupNew;	( (QActionGroup*)a )->setUsesDropDown( TRUE );	a->setText( tr( "New" ) );	a->setMenuText( tr( "&New..." ) );	a->setIconSet( createIconSet("form.png") );	a->setStatusTip( tr( "Creates a new dialog or file" ) );	a->setWhatsThis( whatsThisFrom( "File|New" ) );	QAction *newForm = new QAction( a, 0 );	newForm->setText( tr( "New Dialog" ) );	newForm->setMenuText( tr( "&Dialog..." ) );	newForm->setIconSet( createIconSet("form.png") );	newForm->setAccel( CTRL + Key_N );	newForm->setStatusTip( tr( "Creates a new dialog." ) );	connect( newForm, SIGNAL( activated() ), this, SLOT( fileNewDialog() ) );	QAction *newFile = new QAction( a, 0 );	newFile->setText( tr( "New File" ) );	newFile->setMenuText( tr( "&File..." ) );	newFile->setIconSet( createIconSet("filenew.png") );	newFile->setAccel( ALT + Key_N );	newFile->setStatusTip( tr( "Creates a new file." ) );	connect( newFile, SIGNAL( activated() ), this, SLOT( fileNewFile() ) );	actionNewFile = newFile;	a->addTo( tb );	a->addTo( fileMenu );	fileMenu->insertSeparator();    }    a = new QAction( this, 0 );    a->setText( tr( "Open" ) );    a->setMenuText( tr( "&Open..." ) );    a->setIconSet( createIconSet("fileopen.png") );    a->setAccel( CTRL + Key_O );    a->setStatusTip( tr( "Opens an existing project, form or source file ") );    a->setWhatsThis( whatsThisFrom( "File|Open" ) );    connect( a, SIGNAL( activated() ), this, SLOT( fileOpen() ) );    if ( !singleProject ) {	a->addTo( tb );	a->addTo( fileMenu );	fileMenu->insertSeparator();    }    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("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 );

⌨️ 快捷键说明

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