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

📄 mainwindow.cpp

📁 Trolltech公司发布的基于C++图形开发环境
💻 CPP
📖 第 1 页 / 共 5 页
字号:
	    } 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() ) {	source = QString( WidgetFactory::classNameOf( propertyEditor->widget() ) ).lower() + ".html#details";    }    if ( !source.isEmpty() )	assistant->showPage( documentationPath() + source );}void MainWindow::helpManual(){    assistant->showPage( documentationPath() + "/designer-manual.html" );}void MainWindow::helpAbout(){    AboutDialog dlg( this, 0, TRUE );    if ( singleProjectMode() ) {	dlg.aboutPixmap->setText( "" );	dlg.aboutVersion->setText( "" );	dlg.aboutCopyright->setText( "" );	LanguageInterface *iface = MetaDataBase::languageInterface( eProject->language() );	dlg.aboutLicense->setText( iface->aboutText() );    }    dlg.aboutVersion->setText(QString("Version ") + QString(QT_VERSION_STR));    dlg.resize( dlg.width(), dlg.layout()->heightForWidth(dlg.width()) );    dlg.exec();}void MainWindow::helpAboutQt(){    QMessageBox::aboutQt( this, "Qt Designer" );}#if defined(_WS_WIN_)#include <qt_windows.h>#include <qprocess.h>#endifvoid MainWindow::helpRegister(){#if defined(_WS_WIN_)    HKEY key;    HKEY subkey;    long res;    DWORD type;    DWORD size = 255;    QString command;    QString sub( "htmlfile\\shell" );#if defined(UNICODE)    if ( QApplication::winVersion() & Qt::WV_NT_based ) {	unsigned char data[256];	res = RegOpenKeyExW( HKEY_CLASSES_ROOT, NULL, 0, KEY_READ, &key );	res = RegOpenKeyExW( key, (TCHAR*)sub.ucs2(), 0, KEY_READ, &subkey );	res = RegQueryValueExW( subkey, NULL, NULL, &type, data, &size );	command = qt_winQString( data ) + "\\command";	size = 255;	res = RegOpenKeyExW( subkey, (TCHAR*)command.ucs2(), 0, KEY_READ, &subkey );	res = RegQueryValueExW( subkey, NULL, NULL, &type, data, &size );	command = qt_winQString( data );    } else#endif    {	unsigned char data[256];	res = RegOpenKeyExA( HKEY_CLASSES_ROOT, NULL, 0, KEY_READ, &key );	res = RegOpenKeyExA( key, sub.local8Bit(), 0, KEY_READ, &subkey );	res = RegQueryValueExA( subkey, NULL, NULL, &type, data, &size );	command = QString::fromLocal8Bit( (const char*) data ) + "\\command";	size = 255;	res = RegOpenKeyExA( subkey, command.local8Bit(), 0, KEY_READ, &subkey );	res = RegQueryValueExA( subkey, NULL, NULL, &type, data, &size );	command = QString::fromLocal8Bit( (const char*) data );    }    res = RegCloseKey( subkey );    res = RegCloseKey( key );    QProcess process( command + " www.trolltech.com/products/download/eval/evaluation.html" );    if ( !process.start() )	QMessageBox::information( this, "Register Qt", "Launching your web browser failed.\n"	"To register Qt, point your browser to www.trolltech.com/products/download/eval/evaluation.html" );#endif}void MainWindow::showProperties( QObject *o ){    if ( !o->isWidgetType() ) {	propertyEditor->setWidget( o, lastActiveFormWindow );	if ( lastActiveFormWindow )	    hierarchyView->setFormWindow( lastActiveFormWindow, lastActiveFormWindow->mainContainer() );	else	    hierarchyView->setFormWindow( 0, 0 );	return;    }    QWidget *w = (QWidget*)o;    setupHierarchyView();    FormWindow *fw = (FormWindow*)isAFormWindowChild( w );    if ( fw ) {	if ( fw->numSelectedWidgets() > 1 ) {	    QWidgetList wl = fw->selectedWidgets();	    if ( wl.first() != w ) {		wl.removeRef( w );		wl.insert( 0, w );	    }	    propertyEditor->setWidget( new PropertyObject( wl ), fw );	} else {	    propertyEditor->setWidget( w, fw );	}	hierarchyView->setFormWindow( fw, w );    } else {	propertyEditor->setWidget( 0, 0 );	hierarchyView->setFormWindow( 0, 0 );    }    if ( currentTool() == POINTER_TOOL && fw &&	 ( !qworkspace->activeWindow() || !::qt_cast<SourceEditor*>(qworkspace->activeWindow()) ) )	fw->setFocus();}void MainWindow::resetTool(){    actionPointerTool->setOn( TRUE );}void MainWindow::updateProperties( QObject * ){    if ( propertyEditor )	propertyEditor->refetchData();}bool MainWindow::eventFilter( QObject *o, QEvent *e ){    if ( ::qt_cast<MenuBarEditor*>(o) || ::qt_cast<PopupMenuEditor*>(o) ||	 ( o &&	   ( ::qt_cast<MenuBarEditor*>(o->parent()) ||	     ::qt_cast<PopupMenuEditor*>(o->parent()) ) ) ) {	if ( e->type() == QEvent::Accel && ::qt_cast<PopupMenuEditor*>(o) ) {	    return TRUE; // consume accel events 	} else if ( e->type() == QEvent::MouseButtonPress && ::qt_cast<MenuBarEditor*>(o) ) {	    QPoint pos = ((QMouseEvent*)e)->pos();	    MenuBarEditor *m = ::qt_cast<MenuBarEditor*>(o);	    showProperties( o );	    if ( m->findItem( pos ) >= m->count() )		m->setFocus();	} else if ( e->type() == QEvent::MouseButtonPress && ::qt_cast<PopupMenuEditor*>(o) ) {	    PopupMenuEditor *m = ::qt_cast<PopupMenuEditor*>(o);	    PopupMenuEditorItem *i = m->at( ((QMouseEvent*)e)->pos() );	    if ( m->find( i->action() ) != -1 && !i->isSeparator() )		showProperties( i->action() );	}	return QMainWindow::eventFilter( o, e );    }    if ( !o || !e || !o->isWidgetType() )	return QMainWindow::eventFilter( o, e );    QWidget *w = 0;    bool passiveInteractor;    switch ( e->type() ) {    case QEvent::AccelOverride:	if ( ( (QKeyEvent*)e )->key() == Key_F1 &&	     ( ( (QKeyEvent*)e )->state() & ShiftButton ) != ShiftButton ) {	    w = (QWidget*)o;	    while ( w ) {		if ( ::qt_cast<PropertyList*>(w) )		    break;		w = w->parentWidget( TRUE );	    }	    if ( w ) {		propertyEditor->propertyList()->showCurrentWhatsThis();		( (QKeyEvent*)e )->accept();		return TRUE;	    }	}	break;    case QEvent::Accel:	if ( ( ( (QKeyEvent*)e )->key() == Key_A ||	       ( (QKeyEvent*)e )->key() == Key_E ) &&	     ( (QKeyEvent*)e )->state() & ControlButton ) {	    if ( qWorkspace()->activeWindow() &&		 ::qt_cast<SourceEditor*>(qWorkspace()->activeWindow()) ) {		( (QKeyEvent*)e )->ignore();		return TRUE;	    }	}	break;    case QEvent::ContextMenu:    case QEvent::MouseButtonPress:	if ( o && currentTool() == POINTER_TOOL &&	     ( ::qt_cast<MenuBarEditor*>(o) ||	       ::qt_cast<PopupMenuEditor*>(o) ||	       ::qt_cast<QDesignerToolBar*>(o) ||	       ( ::qt_cast<QComboBox*>(o) ||		 ::qt_cast<QToolButton*>(o) ||		 ::qt_cast<QDesignerToolBarSeparator*>(o) ) &&	       o->parent()	       && ( ::qt_cast<QDesignerToolBar*>(o->parent())		   || ::qt_cast<QDesignerWidgetStack*>(o->parent())) ) ) {	    QWidget *w = (QWidget*)o;	    if ( ::qt_cast<QToolButton*>(w) ||		 ::qt_cast<QComboBox*>(w) ||		 ::qt_cast<PopupMenuEditor*>(w) ||		 ::qt_cast<QDesignerToolBarSeparator*>(w) )		w = w->parentWidget();	    QWidget *pw = w->parentWidget();	    while ( pw ) {		if ( ::qt_cast<FormWindow*>(pw) ) {		    ( (FormWindow*)pw )->emitShowProperties( w );		    if ( !::qt_cast<QDesignerToolBar*>(o) )			return ( !::qt_cast<QToolButton*>(o) &&				 !::qt_cast<MenuBarEditor*>(o) &&				 !::qt_cast<QComboBox*>(o) &&				 !::qt_cast<QDesignerToolBarSeparator*>(o) );		}		pw = pw->parentWidget();	    }	}	if ( o && ( ::qt_cast<QDesignerToolBar*>(o) || o->inherits("QDockWindowHandle") )	     && e->type() == QEvent::ContextMenu )	    break;	if ( isAToolBarChild( o ) && currentTool() != CONNECT_TOOL && currentTool() != BUDDY_TOOL )	    break;	if ( ::qt_cast<QSizeGrip*>(o) )	    break;	if ( !( w = isAFormWindowChild( o ) ) ||	     ::qt_cast<SizeHandle*>(o) ||	     ::qt_cast<OrderIndicator*>(o) )	    break;	if ( !w->hasFocus() )	    w->setFocus();	passiveInteractor = WidgetFactory::isPassiveInteractor( o );	if ( !passiveInteractor || currentTool() != ORDER_TOOL ) {	    if( e->type() == QEvent::ContextMenu ) {		( (FormWindow*)w )->handleContextMenu( (QContextMenuEvent*)e,						       ( (FormWindow*)w )->designerWidget( o ) );		return TRUE;	    } else {		( (FormWindow*)w )->handleMousePress( (QMouseEvent*)e,						      ( (FormWindow*)w )->designerWidget( o ) );	    }	}	lastPressWidget = (QWidget*)o;	if ( passiveInteractor )	    QTimer::singleShot( 0, formWindow(), SLOT( visibilityChanged() ) );	if ( currentTool() == CONNECT_TOOL || currentTool() == BUDDY_TOOL )	    return TRUE;	return !passiveInteractor;    case QEvent::MouseButtonRelease:	lastPressWidget = 0;	if ( isAToolBarChild( o )  && currentTool() != CONNECT_TOOL && currentTool() != BUDDY_TOOL )	    break;	if ( ::qt_cast<QSizeGrip*>(o) )	    break;	if ( !( w = isAFormWindowChild( o ) ) ||	     ::qt_cast<SizeHandle*>(o) ||	     ::qt_cast<OrderIndicator*>(o) )	    break;	passiveInteractor = WidgetFactory::isPassiveInteractor( o );	if ( !passiveInteractor )	    ( (FormWindow*)w )->handleMouseRelease( (QMouseEvent*)e,						    ( (FormWindow*)w )->designerWidget( o ) );	if ( passiveInteractor ) {	    QTimer::singleShot( 0, this, SLOT( selectionChanged() ) );	    QTimer::singleShot( 0, formWindow(), SLOT( visibilityChanged() ) );	}	return !passiveInteractor;    case QEvent::MouseMove:	if ( isAToolBarChild( o ) && currentTool() != CONNECT_TOOL && currentTool() != BUDDY_TOOL )	    break;	w = isAFormWindowChild( o );	if ( lastPressWidget != (QWidget*)o && w &&	     !::qt_cast<SizeHandle*>(o) && !::qt_cast<OrderIndicator*>(o) &&	     !::qt_cast<PopupMenuEditor*>(o) && !::qt_cast<QMenuBar*>(o) &&	     !::qt_cast<QSizeGrip*>(o) )	    return TRUE;	if ( o && ::qt_cast<QSizeGrip*>(o) )	    break;	if ( lastPressWidget != (QWidget*)o ||	     ( !w || ::qt_cast<SizeHandle*>(o) ) ||	       ::qt_cast<OrderIndicator*>(o) )	    break;	passiveInteractor = WidgetFactory::isPassiveInteractor( o );	if ( !passiveInteractor )	    ( (FormWindow*)w )->handleMouseMove( (QMouseEvent*)e,						 ( (FormWindow*)w )->designerWidget( o ) );	return !passiveInteractor;    case QEvent::KeyPress:	if ( ( (QKeyEvent*)e )->key() == Key_Escape && currentTool() != POINTER_TOOL ) {	    resetTool();	    return FALSE;	}	if ( ( (QKeyEvent*)e )->key() == Key_Escape && incrementalSearch->hasFocus() ) {	    if ( ::qt_cast<SourceEditor*>(qWorkspace()->activeWindow()) ) {		qWorkspace()->activeWindow()->setFocus();		return TRUE;	    }	}	if ( !( w = isAFormWindowChild( o ) ) ||	     ::qt_cast<SizeHandle*>(o) ||	     ::qt_cast<OrderIndicator*>(o) )	    break;	( (FormWindow*)w )->handleKeyPress( (QKeyEvent*)e, ( (FormWindow*)w )->designerWidget( o ) );	if ( ((QKeyEvent*)e)->isAccepted() )	    return TRUE;	break;    case QEvent::MouseButtonDblClick:	if ( !( w = isAFormWindowChild( o ) ) ||	     ::qt_cast<SizeHandle*>(o) ||	     ::qt_cast<OrderIndicator*>(o) ) {	    if ( ::qt_cast<QToolButton*>(o) && ((QToolButton*)o)->isOn() &&		 o->parent() && ::qt_cast<QToolBar*>(o->parent()) && formWindow() )		formWindow()->setToolFixed();	    break;	}	if ( currentTool() == ORDER_TOOL ) {	    ( (FormWindow*)w )->handleMouseDblClick( (QMouseEvent*)e,						     ( (FormWindow*)w )->designerWidget( o ) );	    return TRUE;	}	if ( !WidgetFactory::isPassiveInteractor( o ) && ( (FormWindow*)w )->formFile() )	    return openEditor( ( (FormWindow*)w )->designerWidget( o ), (FormWindow*)w );	return TRUE;    case QEvent::KeyRelease:	if ( !( w = isAFormWindowChild( o ) ) ||	     ::qt_cast<SizeHandle*>(o) ||	     ::qt_cast<OrderIndicator*>(o) )	    break;	( (FormWindow*)w )->handleKeyRelease( (QKeyEvent*)e, ( (FormWindow*)w )->designerWidget( o ) );	if ( ((QKeyEvent*)e)->isAccepted() )	    return TRUE;	break;    case QEvent::Hide:	if ( !( w = isAFormWindowChild( o ) ) ||	     ::qt_cast<SizeHandle*>(o) ||	     ::qt_cast<OrderIndicator*>(o) )	    break;	if ( ( (FormWindow*)w )->isWidgetSelected( (QWidget*)o ) )	    ( (FormWindow*)w )->selectWidget( (QWidget*)o, FALSE );	break;    case QEvent::Enter:    case QEvent::Leave:	if ( !( w = isAFormWindowChild( o ) ) ||	     ::qt_cast<SizeHandle*>(o) ||	     ::qt_cast<OrderIndicator*>(o) ||	     ::qt_cast<MenuBarEditor*>(o) )	    break;	return TRUE;    case QEvent::Resize:    case QEvent::Move:	if ( !( w = isAFormWindowChild( o ) ) ||	     ::qt_cast<SizeHandle*>(o) ||	     ::qt_cast<OrderIndicator*>(o) )	    break;	if ( WidgetFactory::layoutType( (QWidget*)o->parent() ) != WidgetFactory::NoLayout ) {	    ( (FormWindow*)w )->updateSelection( (QWidget*)o );	    if ( e->type() != QEvent::Resize )		( (FormWindow*)w )->updateChildSelections( (QWidget*)o );	}	break;    case QEvent::Close:	if ( o->isWidgetType() && (QWidget*)o == (QWidget*)previewedForm ) {	    if ( lastActiveFormWindow && lastActiveFormWindow->project() ) {		QStringList lst =

⌨️ 快捷键说明

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