📄 mainwindow.cpp
字号:
QCompletionEdit *edit = new QCompletionEdit( vbox ); QToolTip::add( edit, tr( "Start typing the buffer you want to switch to here (ALT+B)" ) ); QAccel *a = new QAccel( this ); a->connectItem( a->insertItem( ALT + Key_B ), edit, SLOT( setFocus() ) ); wspace = new Workspace( vbox, this ); wspace->setBufferEdit( edit ); wspace->setCurrentProject( currentProject ); addToolBar( dw, Qt::DockRight ); dw->setWidget( vbox ); dw->setCaption( tr( "Project Overview" ) ); QWhatsThis::add( wspace, tr("<b>The Project Overview Window</b>" "<p>The Project Overview Window displays all the current " "project, including forms and source files.</p>" "<p>Use the search field to rapidly switch between files.</p>")); dw->setFixedExtentHeight( 100 ); dw->show();}void MainWindow::setupActionEditor(){ QDockWindow *dw = new QDockWindow( QDockWindow::OutsideDock, this, 0 ); addDockWindow( dw, Qt::DockTornOff ); dw->setResizeEnabled( TRUE ); dw->setCloseMode( QDockWindow::Always ); actionEditor = new ActionEditor( dw ); dw->setWidget( actionEditor ); actionEditor->show(); dw->setCaption( tr( "Action Editor" ) ); QWhatsThis::add( actionEditor, tr("<b>The Action Editor</b>" "<p>The Action Editor is used to add actions and action groups to " "a form, and to connect actions to slots. Actions and action " "groups can be dragged into menus and into toolbars, and may " "feature keyboard shortcuts and tooltips. If actions have pixmaps " "these are displayed on toolbar buttons and besides their names in " "menus.</p>" ) ); dw->hide(); setAppropriate( dw, FALSE );}void MainWindow::setupToolbox(){ QDockWindow *dw = new QDockWindow( QDockWindow::InDock, this ); dw->setResizeEnabled( TRUE ); dw->setCloseMode( QDockWindow::Always ); addToolBar( dw, Qt::DockLeft ); toolBox = new QCategoryWidget( dw ); dw->setWidget( toolBox ); dw->setFixedExtentWidth( 160 ); dw->setCaption( tr( "Toolbox" ) ); dw->show(); setDockEnabled( dw, Qt::DockTop, FALSE ); setDockEnabled( dw, Qt::DockBottom, FALSE ); commonWidgetsToolBar = new QToolBar( "Common Widgets", 0, toolBox, FALSE, "Common Widgets" ); commonWidgetsToolBar->setFrameStyle( QFrame::NoFrame ); commonWidgetsToolBar->setOrientation( Qt::Vertical ); toolBox->addCategory( "Common Widgets", commonWidgetsToolBar );}void MainWindow::setupRMBMenus(){ rmbWidgets = new QPopupMenu( this ); actionEditCut->addTo( rmbWidgets ); actionEditCopy->addTo( rmbWidgets ); actionEditPaste->addTo( rmbWidgets ); actionEditDelete->addTo( rmbWidgets );#if 0 rmbWidgets->insertSeparator(); actionEditLower->addTo( rmbWidgets ); actionEditRaise->addTo( rmbWidgets );#endif rmbWidgets->insertSeparator(); actionEditAdjustSize->addTo( rmbWidgets ); actionEditHLayout->addTo( rmbWidgets ); actionEditVLayout->addTo( rmbWidgets ); actionEditGridLayout->addTo( rmbWidgets ); actionEditSplitHorizontal->addTo( rmbWidgets ); actionEditSplitVertical->addTo( rmbWidgets ); actionEditBreakLayout->addTo( rmbWidgets ); rmbWidgets->insertSeparator(); if ( !singleProjectMode() ) actionEditConnections->addTo( rmbWidgets ); actionEditSource->addTo( rmbWidgets ); rmbFormWindow = new QPopupMenu( this ); actionEditPaste->addTo( rmbFormWindow ); actionEditSelectAll->addTo( rmbFormWindow ); actionEditAccels->addTo( rmbFormWindow ); rmbFormWindow->insertSeparator(); actionEditAdjustSize->addTo( rmbFormWindow ); actionEditHLayout->addTo( rmbFormWindow ); actionEditVLayout->addTo( rmbFormWindow ); actionEditGridLayout->addTo( rmbFormWindow ); actionEditBreakLayout->addTo( rmbFormWindow ); rmbFormWindow->insertSeparator(); if ( !singleProjectMode() ) { actionEditFunctions->addTo( rmbFormWindow ); actionEditConnections->addTo( rmbFormWindow ); } actionEditSource->addTo( rmbFormWindow ); rmbFormWindow->insertSeparator(); actionEditFormSettings->addTo( rmbFormWindow );}void MainWindow::toolSelected( QAction* action ){ actionCurrentTool = action; emit currentToolChanged(); if ( formWindow() ) formWindow()->commandHistory()->emitUndoRedo();}int MainWindow::currentTool() const{ if ( !actionCurrentTool ) return POINTER_TOOL; return QString::fromLatin1(actionCurrentTool->name()).toInt();}void MainWindow::runProjectPrecondition(){ for ( SourceEditor *e = sourceEditors.first(); e; e = sourceEditors.next() ) { e->save(); e->saveBreakPoints(); } fileSaveProject(); if ( currentTool() == ORDER_TOOL ) resetTool(); //oWindow->parentWidget()->show(); oWindow->clearErrorMessages(); oWindow->clearDebug(); oWindow->showDebugTab(); previewing = TRUE;}void MainWindow::runProjectPostcondition( QObjectList *l ){ inDebugMode = TRUE; debuggingForms = *l; enableAll( FALSE ); for ( SourceEditor *e2 = sourceEditors.first(); e2; e2 = sourceEditors.next() ) { if ( e2->project() == currentProject ) e2->editorInterface()->setMode( EditorInterface::Debugging ); }}QWidget* MainWindow::previewFormInternal( QStyle* style, QPalette* palet ){ qwf_execute_code = FALSE; for ( SourceEditor *e = sourceEditors.first(); e; e = sourceEditors.next() ) e->save(); if ( currentTool() == ORDER_TOOL ) resetTool(); FormWindow *fw = formWindow(); if ( !fw ) return 0; QStringList databases; QPtrDictIterator<QWidget> wit( *fw->widgets() ); while ( wit.current() ) { QStringList lst = MetaDataBase::fakeProperty( wit.current(), "database" ).toStringList(); if ( !lst.isEmpty() ) databases << lst [ 0 ]; ++wit; } if ( fw->project() ) { QStringList::ConstIterator it; for ( it = databases.begin(); it != databases.end(); ++it ) fw->project()->openDatabase( *it, FALSE ); } QApplication::setOverrideCursor( WaitCursor ); QCString s; QBuffer buffer( s ); buffer.open( IO_WriteOnly ); Resource resource( this ); resource.setWidget( fw ); QValueList<Resource::Image> images; resource.save( &buffer ); buffer.close(); buffer.open( IO_ReadOnly ); QWidget *w = QWidgetFactory::create( &buffer ); if ( w ) { previewedForm = w; if ( palet ) { if ( style ) style->polish( *palet ); w->setPalette( *palet ); } if ( style ) w->setStyle( style ); QObjectList *l = w->queryList( "QWidget" ); for ( QObject *o = l->first(); o; o = l->next() ) { if ( style ) ( (QWidget*)o )->setStyle( style ); } delete l; w->move( fw->mapToGlobal( QPoint(0,0) ) ); ((MainWindow*)w )->setWFlags( WDestructiveClose ); previewing = TRUE; w->show(); previewing = FALSE; QApplication::restoreOverrideCursor(); return w; } QApplication::restoreOverrideCursor(); return 0;}void MainWindow::previewForm(){ QWidget* w = previewFormInternal(); if ( w ) w->show();}void MainWindow::previewForm( const QString & style ){ QStyle* st = QStyleFactory::create( style ); QWidget* w = 0; if ( style == "Motif" ) { QPalette p( QColor( 192, 192, 192 ) ); w = previewFormInternal( st, &p ); } else if ( style == "Windows" ) { QPalette p( QColor( 212, 208, 200 ) ); w = previewFormInternal( st, &p ); } else if ( style == "Platinum" ) { QPalette p( QColor( 220, 220, 220 ) ); w = previewFormInternal( st, &p ); } else if ( style == "CDE" ) { QPalette p( QColor( 75, 123, 130 ) ); p.setColor( QPalette::Active, QColorGroup::Base, QColor( 55, 77, 78 ) ); p.setColor( QPalette::Inactive, QColorGroup::Base, QColor( 55, 77, 78 ) ); p.setColor( QPalette::Disabled, QColorGroup::Base, QColor( 55, 77, 78 ) ); p.setColor( QPalette::Active, QColorGroup::Highlight, Qt::white ); p.setColor( QPalette::Active, QColorGroup::HighlightedText, QColor( 55, 77, 78 ) ); p.setColor( QPalette::Inactive, QColorGroup::Highlight, Qt::white ); p.setColor( QPalette::Inactive, QColorGroup::HighlightedText, QColor( 55, 77, 78 ) ); p.setColor( QPalette::Disabled, QColorGroup::Highlight, Qt::white ); p.setColor( QPalette::Disabled, QColorGroup::HighlightedText, QColor( 55, 77, 78 ) ); p.setColor( QPalette::Active, QColorGroup::Foreground, Qt::white ); p.setColor( QPalette::Active, QColorGroup::Text, Qt::white ); p.setColor( QPalette::Active, QColorGroup::ButtonText, Qt::white ); p.setColor( QPalette::Inactive, QColorGroup::Foreground, Qt::white ); p.setColor( QPalette::Inactive, QColorGroup::Text, Qt::white ); p.setColor( QPalette::Inactive, QColorGroup::ButtonText, Qt::white ); p.setColor( QPalette::Disabled, QColorGroup::Foreground, Qt::lightGray ); p.setColor( QPalette::Disabled, QColorGroup::Text, Qt::lightGray ); p.setColor( QPalette::Disabled, QColorGroup::ButtonText, Qt::lightGray ); w = previewFormInternal( st, &p ); } else if ( style == "SGI" ) { QPalette p( QColor( 220, 220, 220 ) ); w = previewFormInternal( st, &p ); } else if ( style == "MotifPlus" ) { QColor gtkfg(0x00, 0x00, 0x00); QColor gtkdf(0x75, 0x75, 0x75); QColor gtksf(0xff, 0xff, 0xff); QColor gtkbs(0xff, 0xff, 0xff); QColor gtkbg(0xd6, 0xd6, 0xd6); QColor gtksl(0x00, 0x00, 0x9c); QColorGroup active(gtkfg, // foreground gtkbg, // button gtkbg.light(), // light gtkbg.dark(142), // dark gtkbg.dark(110), // mid gtkfg, // text gtkfg, // bright text gtkbs, // base gtkbg), // background disabled(gtkdf, // foreground gtkbg, // button gtkbg.light(), // light gtkbg.dark(156), // dark gtkbg.dark(110), // mid gtkdf, // text gtkdf, // bright text gtkbs, // base gtkbg); // background QPalette pal(active, disabled, active); pal.setColor(QPalette::Active, QColorGroup::Highlight, gtksl); pal.setColor(QPalette::Active, QColorGroup::HighlightedText, gtksf); pal.setColor(QPalette::Inactive, QColorGroup::Highlight, gtksl); pal.setColor(QPalette::Inactive, QColorGroup::HighlightedText, gtksf); pal.setColor(QPalette::Disabled, QColorGroup::Highlight, gtksl); pal.setColor(QPalette::Disabled, QColorGroup::HighlightedText, gtkdf); w = previewFormInternal( st, &pal ); } else { w = previewFormInternal( st ); } if ( !w ) return; w->insertChild( st ); w->show();}void MainWindow::helpContents(){ QWidget *focusWidget = qApp->focusWidget(); bool showClassDocu = TRUE; while ( focusWidget ) { if ( focusWidget->isA( "PropertyList" ) ) { showClassDocu = FALSE; break; } focusWidget = focusWidget->parentWidget(); } QString source = "designer-manual.html"; if ( propertyDocumentation.isEmpty() ) { QString indexFile = documentationPath() + "/propertyindex"; QFile f( indexFile ); if ( f.open( IO_ReadOnly ) ) { QTextStream ts( &f ); while ( !ts.eof() ) { QString s = ts.readLine(); int from = s.find( "\"" ); if ( from == -1 ) continue; int to = s.findRev( "\"" ); if ( to == -1 ) continue; propertyDocumentation[ s.mid( from + 1, to - from - 1 ) ] = s.mid( to + 2 ) + "-prop"; } f.close(); } } if ( propertyEditor->widget() && !showClassDocu ) { if ( !propertyEditor->currentProperty().isEmpty() ) { QMetaObject* mo = propertyEditor->metaObjectOfCurrentProperty(); QString s; QString cp = propertyEditor->currentProperty(); if ( cp == "layoutMargin" ) { source = propertyDocumentation[ "QLayout/margin" ]; } else if ( cp == "layoutSpacing" ) { source = propertyDocumentation[ "QLayout/spacing" ]; } else if ( cp == "toolTip" ) { source = "qtooltip.html#details"; } else if ( mo && qstrcmp( mo->className(), "Spacer" ) == 0 ) { if ( cp != "name" ) source = "qsizepolicy.html#SizeType"; else source = propertyDocumentation[ "QObject/name" ]; } else { while ( mo && !propertyDocumentation.contains( ( s = QString( mo->className() ) + "/" + cp ) ) ) mo = mo->superClass(); if ( mo ) source = "p:" + propertyDocumentation[s]; } } QString classname = WidgetFactory::classNameOf( propertyEditor->widget() ); if ( source.isEmpty() || source == "designer-manual.html" ) { if ( classname.lower() == "spacer" ) source = "qspaceritem.html#details"; else if ( classname == "QLayoutWidget" ) source = "layout.html"; else source = QString( WidgetFactory::classNameOf( propertyEditor->widget() ) ).lower() + ".html#details"; } } else if ( propertyEditor->widget() ) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -