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

📄 mainwindow.cpp

📁 Qt/Embedded是一个多平台的C++图形用户界面应用程序框架
💻 CPP
📖 第 1 页 / 共 5 页
字号:
}void MainWindow::editLayoutContainerHorizontal(){    if ( !formWindow() )	return;    QWidget *w = formWindow()->mainContainer();    QWidgetList l( formWindow()->selectedWidgets() );    if ( l.count() == 1 )	w = l.first();    if ( w )	formWindow()->layoutHorizontalContainer( w );}void MainWindow::editLayoutContainerVertical(){    if ( !formWindow() )	return;    QWidget *w = formWindow()->mainContainer();    QWidgetList l( formWindow()->selectedWidgets() );    if ( l.count() == 1 )	w = l.first();    if ( w )	formWindow()->layoutVerticalContainer( w  );}void MainWindow::editLayoutContainerGrid(){    if ( !formWindow() )	return;    QWidget *w = formWindow()->mainContainer();    QWidgetList l( formWindow()->selectedWidgets() );    if ( l.count() == 1 )	w = l.first();    if ( w )	formWindow()->layoutGridContainer( w  );}void MainWindow::editBreakLayout(){    if ( !formWindow() || !breakLayout )	return;    QWidget *w = formWindow()->mainContainer();    if ( formWindow()->currentWidget() )	w = formWindow()->currentWidget();    if ( WidgetFactory::layoutType( w ) != WidgetFactory::NoLayout ||	 w->parentWidget() && WidgetFactory::layoutType( w->parentWidget() ) != WidgetFactory::NoLayout ) {	formWindow()->breakLayout( w );	return;    } else {	QWidgetList widgets = formWindow()->selectedWidgets();	for ( w = widgets.first(); w; w = widgets.next() ) {	    if ( WidgetFactory::layoutType( w ) != WidgetFactory::NoLayout ||		 w->parentWidget() && WidgetFactory::layoutType( w->parentWidget() ) != WidgetFactory::NoLayout )		break;	}	if ( w ) {	    formWindow()->breakLayout( w );	    return;	}    }    w = formWindow()->mainContainer();    if ( WidgetFactory::layoutType( w ) != WidgetFactory::NoLayout ||	 w->parentWidget() && WidgetFactory::layoutType( w->parentWidget() ) != WidgetFactory::NoLayout )	formWindow()->breakLayout( w );}void MainWindow::editAccels(){    if ( !formWindow() )	return;    formWindow()->checkAccels();}void MainWindow::editSlots(){    if ( !formWindow() )	return;    statusBar()->message( tr( "Edit slots of current form..." ) );    EditSlots dlg( this, formWindow() );    dlg.exec();    statusBar()->clear();}void MainWindow::editConnections(){    if ( !formWindow() )	return;    statusBar()->message( tr( "Edit connections in current form..." ) );    ConnectionViewer dlg( this, formWindow() );    dlg.exec();    statusBar()->clear();}void MainWindow::editFormSettings(){    if ( !formWindow() )	return;    statusBar()->message( tr( "Edit settings of current form..." ) );    FormSettings dlg( this, formWindow() );    dlg.exec();    statusBar()->clear();}void MainWindow::editPreferences(){    statusBar()->message( tr( "Edit preferences..." ) );    Preferences *dia = new Preferences( this, 0, TRUE );    prefDia = dia;    connect( dia->helpButton, SIGNAL( clicked() ), MainWindow::self, SLOT( showDialogHelp() ) );    dia->buttonColor->setEditor( StyledButton::ColorEditor );    dia->buttonPixmap->setEditor( StyledButton::PixmapEditor );    dia->checkBoxShowGrid->setChecked( sGrid );    dia->checkBoxGrid->setChecked( snGrid );    dia->spinGridX->setValue( grid().x() );    dia->spinGridY->setValue( grid().y() );    dia->checkBoxWorkspace->setChecked( restoreConfig );    dia->checkBoxBigIcons->setChecked( usesBigPixmaps() );    dia->checkBoxBigIcons->hide(); // ##### disabled for now    dia->checkBoxTextLabels->setChecked( usesTextLabel() );    dia->buttonColor->setColor( workspace->backgroundColor() );    if ( workspace->backgroundPixmap() )	dia->buttonPixmap->setPixmap( *workspace->backgroundPixmap() );    if ( backPix )	dia->radioPixmap->setChecked( TRUE );    else	dia->radioColor->setChecked( TRUE );    dia->checkBoxSplash->setChecked( splashScreen );    dia->editDocPath->setText( docPath );    connect( dia->buttonDocPath, SIGNAL( clicked() ),	     this, SLOT( chooseDocPath() ) );    if ( dia->exec() == QDialog::Accepted ) {	setSnapGrid( dia->checkBoxGrid->isChecked() );	setShowGrid( dia->checkBoxShowGrid->isChecked() );	setGrid( QPoint( dia->spinGridX->value(),			 dia->spinGridY->value() ) );	restoreConfig = dia->checkBoxWorkspace->isChecked();	setUsesBigPixmaps( FALSE /*dia->checkBoxBigIcons->isChecked()*/ ); // ### disable for now	setUsesTextLabel( dia->checkBoxTextLabels->isChecked() );	if ( help ) {	    help->setUsesBigPixmaps( FALSE /*dia->checkBoxBigIcons->isChecked()*/ ); // ### same here	    help->setUsesTextLabel( dia->checkBoxTextLabels->isChecked() );	}	if ( dia->radioPixmap->isChecked() && dia->buttonPixmap->pixmap() ) {	    workspace->setBackgroundPixmap( *dia->buttonPixmap->pixmap() );	    backPix = TRUE;	} else {	    workspace->setBackgroundColor( dia->buttonColor->color() );	    backPix = FALSE;	}	splashScreen = dia->checkBoxSplash->isChecked();	docPath = dia->editDocPath->text();    }    delete dia;    prefDia = 0;    statusBar()->clear();}QWidget* MainWindow::previewFormInternal( QStyle* style, QPalette* palet ){    QApplication::setOverrideCursor( WaitCursor );    if ( currentTool() == ORDER_TOOL )	resetTool();    FormWindow *fw = formWindow();    if ( !fw )	return 0;    QCString s;    QBuffer buffer( s );    buffer.open( IO_WriteOnly );    Resource resource( this );    resource.setWidget( fw );    QValueList<Resource::Image> images;    resource.save( &buffer, FALSE, &images );    buffer.close();    buffer.open( IO_ReadOnly );    Resource preview( style, palet );    if ( preview.load( &buffer, &images ) && preview.widget() ) {	preview.widget()->move( fw->mapToGlobal( QPoint(0,0) ) );	((MainWindow*)preview.widget() )->setWFlags( WDestructiveClose );	QApplication::restoreOverrideCursor();	return preview.widget();    }    QApplication::restoreOverrideCursor();    return 0;}void MainWindow::previewForm(){    QWidget* w = previewFormInternal();    if ( w )	w->show();}void MainWindow::previewFormMotif(){    static QMotifStyle* style = 0;    if ( !style )	style = new QMotifStyle;    QPalette p( QColor( 192, 192, 192 ) );    QWidget* w = previewFormInternal( style, &p );    if (! w )	return;    w->show();}void MainWindow::previewFormWindows(){    static QWindowsStyle* style = 0;    if ( !style )	style = new QWindowsStyle;    QPalette p( QColor( 212, 208, 200 ) );    QWidget* w = previewFormInternal( style, &p );    if ( w )	w->show();}void MainWindow::previewFormPlatinum(){    static QPlatinumStyle* style = 0;    if ( !style )	style = new QPlatinumStyle;    QPalette p( QColor( 220, 220, 220 ) );    QWidget* w = previewFormInternal( style, &p );    if ( w )	w->show();}void MainWindow::previewFormCDE(){    static QCDEStyle* style = 0;    if ( !style )	style = new QCDEStyle;    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 );    QWidget* w = previewFormInternal( style, &p );    if ( !w )	return;    w->setFont( QFont( "times", QApplication::font().pointSize() ) );    w->show();}void MainWindow::previewFormSGI(){    static QSGIStyle* style = 0;    if ( !style )	style = new QSGIStyle;    QPalette p( QColor( 220, 220, 220 ) );    QWidget* w = previewFormInternal( style, &p );    if ( !w )	return;    QFont font( QApplication::font() );    font.setPointSize( 14 );    w->setFont( font );    w->show();}void MainWindow::previewFormMotifPlus(){    static QMotifPlusStyle* style = 0;    if ( !style )	style = new QMotifPlusStyle;    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);    QWidget* w = previewFormInternal( style, &pal );    if (! w )	return;    w->show();}static void correctGeometry( QWidget *wid, QWidget *workspace ){    int x = wid->parentWidget()->x(), y = wid->parentWidget()->y();    if ( wid->parentWidget()->x() > workspace->width() )	x = QMAX( 0, workspace->width() - wid->parentWidget()->width() );    if ( wid->parentWidget()->y() > workspace->height() )	x = QMAX( 0, workspace->height() - wid->parentWidget()->height() );    wid->parentWidget()->move( x, y );    int w = wid->parentWidget()->width(), h = wid->parentWidget()->

⌨️ 快捷键说明

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