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

📄 mainwindow.cpp

📁 Qt/Embedded是一个多平台的C++图形用户界面应用程序框架
💻 CPP
📖 第 1 页 / 共 5 页
字号:
    actionEditRedo->addTo( tb );    tb->addSeparator();    actionEditCut->addTo( tb );    actionEditCopy->addTo( tb );    actionEditPaste->addTo( tb );#if 0    tb->addSeparator();    actionEditLower->addTo( tb );    actionEditRaise->addTo( tb );#endif    QPopupMenu *menu = new QPopupMenu( this );    menubar->insertItem( tr( "&Edit" ), menu );    actionEditUndo->addTo( menu );    actionEditRedo->addTo( menu );    menu->insertSeparator();    actionEditCut->addTo( menu );    actionEditCopy->addTo( menu );    actionEditPaste->addTo( menu );    actionEditDelete->addTo( menu );    actionEditSelectAll->addTo( menu );    actionEditAccels->addTo( menu );#if 0    menu->insertSeparator();    actionEditLower->addTo( menu );    actionEditRaise->addTo( menu );#endif    menu->insertSeparator();    actionEditSlots->addTo( menu );    actionEditConnections->addTo( menu );    actionEditFormSettings->addTo( menu );    menu->insertSeparator();    actionEditPreferences->addTo( menu );}void MainWindow::setupLayoutActions(){    if ( !actionGroupTools ) {	actionGroupTools = new QActionGroup( this );	actionGroupTools->setExclusive( TRUE );	connect( actionGroupTools, SIGNAL( selected(QAction*) ), this, SLOT( toolSelected(QAction*) ) );    }    actionEditAdjustSize = new QAction( tr( "Adjust Size" ), createIconSet("adjustsize.xpm"),					tr( "Adjust &Size" ), CTRL + Key_J, this, 0 );    actionEditAdjustSize->setStatusTip(tr("Adjusts the size of the selected widget") );    actionEditAdjustSize->setWhatsThis(tr("<b>Adjust the size</b>"					  "<p>Calculates an appropriate size for the selected widget. This function "					  "is disabled if the widget is part of a layout, and the layout will "					  "control the widget\'s geometry.</p>") );    connect( actionEditAdjustSize, SIGNAL( activated() ), this, SLOT( editAdjustSize() ) );    actionEditAdjustSize->setEnabled( FALSE );    actionEditHLayout = new QAction( tr( "Lay Out Horizontally" ), createIconSet("edithlayout.xpm"),				     tr( "Lay Out &Horizontally" ), CTRL + Key_H, this, 0 );    actionEditHLayout->setStatusTip(tr("Lays out the selected widgets horizontally") );    actionEditHLayout->setWhatsThis(tr("<b>Layout widgets horizontally</b>"				       "<p>The selected widgets will be laid out horizontally. "				       "If only one widget is selected, its child-widgets will be laid out.</p>") );    connect( actionEditHLayout, SIGNAL( activated() ), this, SLOT( editLayoutHorizontal() ) );    actionEditHLayout->setEnabled( FALSE );    actionEditVLayout = new QAction( tr( "Lay Out Vertically" ), createIconSet("editvlayout.xpm"),				     tr( "Lay Out &Vertically" ), CTRL + Key_L, this, 0 );    actionEditVLayout->setStatusTip(tr("Lays out the selected widgets vertically") );    actionEditVLayout->setWhatsThis(tr("<b>Layout widgets vertically</b>"				       "<p>The selected widgets will be laid out vertically. "				       "If only one widget is selected, its child-widgets will be laid out.</p>") );    connect( actionEditVLayout, SIGNAL( activated() ), this, SLOT( editLayoutVertical() ) );    actionEditVLayout->setEnabled( FALSE );    actionEditGridLayout = new QAction( tr( "Lay Out in a Grid" ), createIconSet("editgrid.xpm"),					tr( "Lay Out in a &Grid" ), CTRL + Key_G, this, 0 );    actionEditGridLayout->setStatusTip(tr("Lays out the selected widgets in a grid") );    actionEditGridLayout->setWhatsThis(tr("<b>Layout widgets in a grid</b>"					  "<p>The selected widgets will be laid out in a grid."					  "If only one widget is selected, its child-widgets will be laid out.</p>") );    connect( actionEditGridLayout, SIGNAL( activated() ), this, SLOT( editLayoutGrid() ) );    actionEditGridLayout->setEnabled( FALSE );    actionEditBreakLayout = new QAction( tr( "Break Layout" ), createIconSet("editbreaklayout.xpm"),					 tr( "&Break Layout" ), CTRL + Key_B, this, 0 );    actionEditBreakLayout->setStatusTip(tr("Breaks the selected layout") );    actionEditBreakLayout->setWhatsThis(tr("<b>Break the layout</b>"					   "<p>The selected layout or the layout of the selected widget "					   "will be removed.</p>") );    connect( actionEditBreakLayout, SIGNAL( activated() ), this, SLOT( editBreakLayout() ) );    int id = WidgetDatabase::idFromClassName( "Spacer" );    QAction* a = new QAction( actionGroupTools, QString::number( id ).latin1() );    a->setToggleAction( TRUE );    a->setText( WidgetDatabase::className( id ) );    a->setMenuText( tr( "Add ") + WidgetDatabase::className( id ) );    a->setIconSet( WidgetDatabase::iconSet( id ) );    a->setToolTip( WidgetDatabase::toolTip( id ) );    a->setStatusTip( tr( "Insert a %1").arg(WidgetDatabase::toolTip( id )) );    a->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 ) ));    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 );    actionEditBreakLayout->addTo( layoutToolBar );    layoutToolBar->addSeparator();    a->addTo( layoutToolBar );    QPopupMenu *menu = new QPopupMenu( this );    menubar->insertItem( tr( "&Layout" ), menu );    actionEditAdjustSize->addTo( menu );    menu->insertSeparator();    actionEditHLayout->addTo( menu );    actionEditVLayout->addTo( menu );    actionEditGridLayout->addTo( menu );    actionEditBreakLayout->addTo( menu );    menu->insertSeparator();    a->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.xpm"), tr("&Pointer"),  Key_F2,				     actionGroupTools, QString::number(POINTER_TOOL).latin1(), TRUE );    actionPointerTool->setStatusTip( tr("Selects the pointer tool") );    actionPointerTool->setWhatsThis( tr("<b>The pointer tool</b>"					"<p>The default tool used to select and move widgets on your form. "					"For some widgets, a double-click opens a dialog where you can enter "					"the value for the basic property. A context menu with often used "					"commands is available for all form elements.</p>") );    actionConnectTool = new QAction( tr("Connect Signal/Slots"), createIconSet("connecttool.xpm"),				     tr("&Connect Signal/Slots"),  Key_F3,				     actionGroupTools, QString::number(CONNECT_TOOL).latin1(), TRUE );    actionConnectTool->setStatusTip( tr("Selects the connection tool") );    actionConnectTool->setWhatsThis( tr("<b>Connect signals and slots</b>"					"<p>Create a connection by dragging with the LMB from the widget "					"emitting a signal to the receiver, and connect the signal and slot "					"in the opening dialog.</p>"					"<p>Double click on this tool to keep it selected.</p>") );    actionOrderTool = new QAction( tr("Tab Order"), createIconSet("ordertool.xpm"),				   tr("Tab &Order"),  Key_F4,				   actionGroupTools, QString::number(ORDER_TOOL).latin1(), TRUE );    actionOrderTool->setStatusTip( tr("Selects the tab order tool") );    actionOrderTool->setWhatsThis( tr("<b>Change the tab order</b>"				      "<p>Click on one widget after the other to change the order in which "				      "they receive the keyboard focus. A double-click on an item will make "				      "it the first item in the chain and restart the ordering.</p>") );#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 Tools toolbar</b>%1" ).arg(tr(toolbarHelp).arg("")) );					    addToolBar( tb, tr( "Tools" ), QMainWindow::Top, TRUE );    actionPointerTool->addTo( tb );    actionConnectTool->addTo( tb );    actionOrderTool->addTo( tb );    QPopupMenu *mmenu = new QPopupMenu( this );    menubar->insertItem( tr( "&Tools" ), mmenu );    actionPointerTool->addTo( mmenu );    actionConnectTool->addTo( mmenu );    actionOrderTool->addTo( mmenu );    mmenu->insertSeparator();    customWidgetToolBar = 0;    customWidgetMenu = 0;    actionToolsCustomWidget = new QAction( tr("Custom Widgets"),					   createIconSet( "customwidget.xpm" ), tr("Edit &Custom Widgets..."), 0, this, 0 );    actionToolsCustomWidget->setStatusTip( tr("Opens a dialog to change the custom widgets") );    actionToolsCustomWidget->setWhatsThis( tr("<b>Change custom widgets</b>"					      "<p>You can add your own widgets into forms by providing classname "					      "and name of the header file. You can add properties as well as "					      "signals and slots to integrate them into the designer, "					      "and provide a pixmap which will be used to represent the widget on the form.</p>") );    connect( actionToolsCustomWidget, SIGNAL( activated() ), this, SLOT( toolsCustomWidget() ) );    for ( int j = 0; j < WidgetDatabase::numWidgetGroups(); ++j ) {	QString grp = WidgetDatabase::widgetGroup( j );	if ( !WidgetDatabase::isGroupVisible( grp ) )	    continue;#if defined(HAVE_KDE)	KToolBar *tb = new KToolBar( this );	tb->setFullSize( FALSE );#else	QToolBar *tb = new QToolBar( this );#endif	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 );	QPopupMenu *menu = new QPopupMenu( this );	mmenu->insertItem( grp, menu );		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	    QAction* a = new QAction( actionGroupTools, QString::number( i ).latin1() );	    a->setToggleAction( TRUE );	    if ( WidgetDatabase::className( i )[0] == 'Q' )		a->setText( WidgetDatabase::className( i ).mid(1) );	    else		a->setText( WidgetDatabase::className( i ) );	    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 );	}    }    if ( !customWidgetToolBar ) {#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 Custom Widgets toolbar</b>%1"				 "<p>Select <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" );	customWidgetToolBar = tb;	QPopupMenu *menu = new QPopupMenu( this );	mmenu->insertItem( "Custom", menu );	customWidgetMenu = menu;	customWidgetToolBar->hide();	actionToolsCustomWidget->addTo( customWidgetMenu );	customWidgetMenu->insertSeparator();    }    resetTool();}void MainWindow::setupFileActions(){#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 File toolbar</b>%1" ).arg(tr(toolbarHelp).arg("")) );    addToolBar( tb, tr( "File" ) );    QPopupMenu *menu = new QPopupMenu( this );    menubar->insertItem( tr( "&File" ), menu );    QAction *a = 0;    a = new QAction( this, 0 );    a->setText( tr( "New" ) );    a->setMenuText( tr( "&New" ) );    a->setIconSet( createIconSet("filenew.xpm") );    a->setAccel( CTRL + Key_N );    a->setStatusTip( tr( "Creates a new form" ) );    a->setWhatsThis( tr("<b>Create a new form</b>"		        "<p>Select a template for the new form or start with an empty form.</p>") );    connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) );    a->addTo( tb );    a->addTo( menu );    a = new QAction( this, 0 );    a->setText( tr( "Open" ) );    a->setMenuText( tr( "&Open..." ) );    a->setIconSet( createIconSet("fileopen.xpm") );    a->setAccel( CTRL + Key_O );    a->setStatusTip( tr( "Opens an existing form") );    a->setWhatsThis( tr("<b>Open a User-Interface (ui) file</b>"			"<p>Use the filedialog to select the file you want to "			"open. You can also use Drag&Drop to open multiple files.</p>") );    connect( a, SIGNAL( activated() ), this, SLOT( fileOpen() ) );    a->addTo( tb );    a->addTo( menu );    a = new QAction( this, 0 );    a->setText( tr( "Save" ) );    a->setMenuText( tr( "&Save" ) );    a->setIconSet( createIconSet("filesave.xpm") );    a->setAccel( CTRL + Key_S );    a->setStatusTip( tr( "Saves the current form" ) );    a->setWhatsThis( tr("<b>Save the current form</b>"			"<p>A filedialog will open if there is no filename already "			"provided, otherwise the old name will be used.</p>") );    connect( a, SIGNAL( activated() ), this, SLOT( fileSave() ) );    connect( this, SIGNAL( hasActiveForm(bool) ), a, SLOT( setEnabled(bool) ) );#if 0 // #### Reggie: I don't like it    connect( this, SIGNAL( formModified(bool) ), a, SLOT( setEnabled(bool) ) );#endif    menu->insertSeparator();    a->addTo( tb );    a->addTo( menu );    a = new QAction( this, 0 );    a->setText( tr( "Save As" ) );    a->setMenuText( tr( "Save &As..." ) );

⌨️ 快捷键说明

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