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

📄 mainwindow.cpp

📁 Linux下的基于X11的图形开发环境。
💻 CPP
📖 第 1 页 / 共 5 页
字号:
	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.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() || !qworkspace->activeWindow()->inherits( "SourceEditor" ) ) )	fw->setFocus();}void MainWindow::resetTool(){    actionPointerTool->setOn( TRUE );}void MainWindow::updateProperties( QObject * ){    if ( propertyEditor )	propertyEditor->refetchData();}bool MainWindow::eventFilter( QObject *o, QEvent *e ){    if ( !o || !e || !o->isWidgetType() )	return QMainWindow::eventFilter( o, e );    QWidget *w = 0;    bool passiveInteractor;    QWidget *ed = 0;    switch ( e->type() ) {    case QEvent::AccelOverride:	if ( ( (QKeyEvent*)e )->key() == Key_F1 &&	     ( ( (QKeyEvent*)e )->state() & ShiftButton ) != ShiftButton ) {	    w = (QWidget*)o;	    while ( w ) {		if ( w->inherits( "PropertyList" ) )		    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() &&		 qWorkspace()->activeWindow()->inherits( "SourceEditor" ) ) {		( (QKeyEvent*)e )->ignore();		return TRUE;	    }	}	break;    case QEvent::ContextMenu:    case QEvent::MouseButtonPress:	if ( o->inherits( "QDesignerPopupMenu" ) )	    break;	if ( o && currentTool() == POINTER_TOOL && ( o->inherits( "QDesignerMenuBar" ) ||		    o->inherits( "QDesignerToolBar" ) ||		    ( o->inherits( "QComboBox") || o->inherits( "QToolButton" ) || o->inherits( "QDesignerToolBarSeparator" ) ) &&		    o->parent() && o->parent()->inherits( "QDesignerToolBar" ) ) ) {	    QWidget *w = (QWidget*)o;	    if ( w->inherits( "QToolButton" ) || w->inherits( "QComboBox" ) || w->inherits( "QDesignerToolBarSeparator" ) )		w = w->parentWidget();	    QWidget *pw = w->parentWidget();	    while ( pw ) {		if ( pw->inherits( "FormWindow" ) ) {		    ( (FormWindow*)pw )->emitShowProperties( w );		    if ( !o->inherits( "QDesignerToolBar" ) )			return !o->inherits( "QToolButton" ) && !o->inherits( "QMenuBar" ) &&			    !o->inherits( "QComboBox" ) && !o->inherits( "QDesignerToolBarSeparator" );		}		pw = pw->parentWidget();	    }	}	if ( o && ( o->inherits( "QDesignerToolBar" ) || o->inherits( "QDockWindowHandle" ) )	     && e->type() == QEvent::ContextMenu )	    break;	if ( isAToolBarChild( o ) && currentTool() != CONNECT_TOOL )	    break;	if ( o && o->inherits( "QSizeGrip" ) )	    break;	if ( !( w = isAFormWindowChild( o ) ) || o->inherits( "SizeHandle" ) || o->inherits( "OrderIndicator" ) )	    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 )	    return TRUE;	return !passiveInteractor;    case QEvent::MouseButtonRelease:	lastPressWidget = 0;	if ( isAToolBarChild( o )  && currentTool() != CONNECT_TOOL )	    break;	if ( o && o->inherits( "QSizeGrip" ) )	    break;	if ( !( w = isAFormWindowChild( o ) ) || o->inherits( "SizeHandle" ) || o->inherits( "OrderIndicator" ) )	    break;	passiveInteractor = WidgetFactory::isPassiveInteractor( o );	if ( !passiveInteractor )	    ( (FormWindow*)w )->handleMouseRelease( (QMouseEvent*)e, ( (FormWindow*)w )->designerWidget( o ) );	if ( passiveInteractor ) {	    selectionChanged();	    QTimer::singleShot( 0, formWindow(), SLOT( visibilityChanged() ) );	}	return !passiveInteractor;    case QEvent::MouseMove:	if ( isAToolBarChild( o ) && currentTool() != CONNECT_TOOL )	    break;	w = isAFormWindowChild( o );	if ( lastPressWidget != (QWidget*)o && w &&	     !o->inherits( "SizeHandle" ) && !o->inherits( "OrderIndicator" ) &&	     !o->inherits( "QPopupMenu" ) && !o->inherits( "QMenuBar" ) &&	     !o->inherits( "QSizeGrip" ) )	    return TRUE;	if ( o && o->inherits( "QSizeGrip" ) )	    break;	if ( lastPressWidget != (QWidget*)o ||	     ( !w || o->inherits( "SizeHandle" ) || o->inherits( "OrderIndicator" ) ) )	    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 ( qWorkspace()->activeWindow() && qWorkspace()->activeWindow()->inherits( "SourceEditor" ) ) {		qWorkspace()->activeWindow()->setFocus();		return TRUE;	    }	}	if ( !( w = isAFormWindowChild( o ) ) || o->inherits( "SizeHandle" ) || o->inherits( "OrderIndicator" ) )	    break;	( (FormWindow*)w )->handleKeyPress( (QKeyEvent*)e, ( (FormWindow*)w )->designerWidget( o ) );	if ( ((QKeyEvent*)e)->isAccepted() )	    return TRUE;	break;    case QEvent::MouseButtonDblClick:	if ( !( w = isAFormWindowChild( o ) ) || o->inherits( "SizeHandle" ) || o->inherits( "OrderIndicator" ) ) {	    if ( o && o->inherits( "QToolButton" ) && ( ( QToolButton*)o )->isOn() &&		 o->parent() && o->parent()->inherits( "QToolBar" ) && 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 ) ) || o->inherits( "SizeHandle" ) || o->inherits( "OrderIndicator" ) )	    break;	( (FormWindow*)w )->handleKeyRelease( (QKeyEvent*)e, ( (FormWindow*)w )->designerWidget( o ) );	if ( ((QKeyEvent*)e)->isAccepted() )	    return TRUE;	break;    case QEvent::Hide:	if ( !( w = isAFormWindowChild( o ) ) || o->inherits( "SizeHandle" ) || o->inherits( "OrderIndicator" ) )	    break;	if ( ( (FormWindow*)w )->isWidgetSelected( (QWidget*)o ) )	    ( (FormWindow*)w )->selectWidget( (QWidget*)o, FALSE );	break;    case QEvent::Enter:    case QEvent::Leave:	if ( !( w = isAFormWindowChild( o ) ) || o->inherits( "SizeHandle" ) || o->inherits( "OrderIndicator" ) || o->inherits( "QDesignerMenuBar" ) )	    break;	return TRUE;    case QEvent::Resize:    case QEvent::Move:	if ( !( w = isAFormWindowChild( o ) ) || o->inherits( "SizeHandle" ) || o->inherits( "OrderIndicator" ) )	    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 =		    MetaDataBase::fakeProperty( lastActiveFormWindow, "database" ).toStringList();		lastActiveFormWindow->project()->closeDatabase( lst[ 0 ] );	    }	}	break;    case QEvent::DragEnter:	if ( o == qWorkspace() || o == workspace() || o == workspace()->viewport() ) {	    workspace()->contentsDragEnterEvent( (QDragEnterEvent*)e );	    return TRUE;	}	break;    case QEvent::DragMove:	if ( o == qWorkspace() || o == workspace() || o == workspace()->viewport() ) {	    workspace()->contentsDragMoveEvent( (QDragMoveEvent*)e );	    return TRUE;	}	break;    case QEvent::Drop:	if ( o == qWorkspace() || o == workspace() || o == workspace()->viewport() ) {	    workspace()->contentsDropEvent( (QDropEvent*)e );	    return TRUE;	}	break;    case QEvent::Show:	if ( o != this )	    break;	if ( ((QShowEvent*)e)->spontaneous() )	    break;	QApplication::sendPostedEvents( qworkspace, QEvent::ChildInserted );	showEvent( (QShowEvent*)e );	checkTempFiles();	return TRUE;    case QEvent::Wheel:	if ( !( w = isAFormWindowChild( o ) ) || o->inherits( "SizeHandle" ) || o->inherits( "OrderIndicator" ) )	    break;	return TRUE;    case QEvent::FocusIn:	if ( !o->inherits( "FormWindow" ) && isAFormWindowChild( o ) )	    return TRUE;	if ( qworkspace->activeWindow() &&	     qworkspace->activeWindow()->inherits( "SourceEditor" ) )	    ed = (QWidget*)qworkspace->activeWindow()->child( 0, "Editor" );	if ( o != ed && ( o->inherits( "Editor" ) || o->inherits( "FormWindow" ) ) ) {	    // QCustomEvent( 9999 ) is used by QListView to end in-place	    // editing. In the case that one edits e.g. a class variable in	    // the form definition view and clicks on another form in the	    // designer, the in-place editor receives a focus out event. This	    // event posts a QCustomEvent( 9999 ) to QListView to end in-place	    // editing, which triggers a FormDefinitionView::save(). To make	    // sure that we save() before the new active formwindow is set,	    // post queued custom events of that type now.	    // BUT: We must not do that of we click on the editor	    // which is currently active already anyway. This crashes	    // for some reason, which I couldn't find. That's why	    // there is the o != ed condition in the if statement	    // above	    if ( hierarchyView->formDefinitionView()->isRenaming() )		QApplication::sendPostedEvents( hierarchyView->formDefinitionView()->						child( 0, "QLineEdit" ) , 9999 );	}	if ( o->inherits( "Editor" ) ) {	    QWidget *w = (QWidget*)o;	    while ( w ) {		if ( w->inherits( "SourceEditor" ) )		    break;		w = w->parentWidget( TRUE );	    }	    if ( w && w->inherits( "SourceEditor" ) )		( (SourceEditor*)w )->checkTimeStamp();

⌨️ 快捷键说明

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