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

📄 mainwindow.cpp

📁 Linux下的基于X11的图形开发环境。
💻 CPP
📖 第 1 页 / 共 5 页
字号:
 /************************************************************************ Copyright (C) 2000-2002 Trolltech AS.  All rights reserved.**** This file is part of Qt Designer.**** This file may be distributed and/or modified under the terms of the** GNU General Public License version 2 as published by the Free Software** Foundation and appearing in the file LICENSE.GPL included in the** packaging of this file.**** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.**** See http://www.trolltech.com/gpl/ for GPL licensing information.**** Contact info@trolltech.com if any conditions of this licensing are** not clear to you.************************************************************************/#include "designerappiface.h"#include "designerapp.h"#include "mainwindow.h"#include "defs.h"#include "globaldefs.h"#include "formwindow.h"#include "widgetdatabase.h"#include "widgetfactory.h"#include "propertyeditor.h"#include "metadatabase.h"#include "resource.h"#include "config.h"#include "hierarchyview.h"#include "newformimpl.h"#include "workspace.h"#include "about.h"#include "multilineeditorimpl.h"#include "wizardeditorimpl.h"#include "outputwindow.h"#include "actioneditorimpl.h"#include "actiondnd.h"#include "project.h"#include "projectsettingsimpl.h"#include "qwidgetfactory.h"#include "pixmapcollection.h"#include "qcompletionedit.h"#include "sourcefile.h"#include "qcategorywidget.h"#include "widgetaction.h"#include "propertyobject.h"#include <qinputdialog.h>#include <qtoolbar.h>#include <qfeatures.h>#include <qmetaobject.h>#include <qaction.h>#include <qpixmap.h>#include <qworkspace.h>#include <qfiledialog.h>#include <qclipboard.h>#include <qmessagebox.h>#include <qbuffer.h>#include <qdir.h>#include <qstyle.h>#include <qlabel.h>#include <qstatusbar.h>#include <qfile.h>#include <qcheckbox.h>#include <qwhatsthis.h>#include <qwizard.h>#include <qtimer.h>#include <qlistbox.h>#include <qdockwindow.h>#include <qstylefactory.h>#include <qvbox.h>#include <qprocess.h>#include <qsettings.h>#include <qaccel.h>#include <qtooltip.h>#include <qassistantclient.h>#include <stdlib.h>static bool mblockNewForms = FALSE;extern QMap<QWidget*, QString> *qwf_forms;extern QString *qwf_language;extern bool qwf_execute_code;extern bool qwf_stays_on_top;extern void set_splash_status( const QString &txt );extern QObject* qwf_form_object;extern QString *qwf_plugin_dir;/*### static bool tbSettingsRead = FALSE; */MainWindow *MainWindow::self = 0;QString assistantPath(){    QString path = QDir::cleanDirPath( QString( qInstallPathBins() ) +				       QDir::separator() );    return path;}static QString textNoAccel( const QString& text){    QString t = text;    int i;    while ( (i = t.find('&') )>= 0 ) {	t.remove(i,1);    }    return t;}MainWindow::MainWindow( bool asClient, bool single, const QString &plgDir )    : QMainWindow( 0, "designer_mainwindow", WType_TopLevel | (single ? 0 : WDestructiveClose) | WGroupLeader ),      grd( 10, 10 ), sGrid( TRUE ), snGrid( TRUE ), restoreConfig( TRUE ), splashScreen( TRUE ),      fileFilter( tr( "Qt User-Interface Files (*.ui)" ) ), client( asClient ),      previewing( FALSE ), databaseAutoEdit( FALSE ){#ifdef Q_WS_WIN    extern void qInitImages_designerlib();    qInitImages_designerlib();#else    extern void qInitImages_designer();    qInitImages_designer();#endif    self = this;    setPluginDirectory( plgDir );    customWidgetToolBar = customWidgetToolBar2 = 0;    guiStuffVisible = TRUE;    editorsReadOnly = FALSE;    sSignalHandlers = TRUE;    init_colors();    shStartDialog = TRUE;    desInterface = new DesignerInterfaceImpl( this );    desInterface->addRef();    inDebugMode = FALSE;    updateFunctionsTimer = new QTimer( this );    connect( updateFunctionsTimer, SIGNAL( timeout() ),	     this, SLOT( doFunctionsChanged() ) );    set_splash_status( "Loading Plugins..." );    setupPluginManagers();    if ( !single )	qApp->setMainWidget( this );    QWidgetFactory::addWidgetFactory( new CustomWidgetFactory );#ifndef Q_WS_MACX    setIcon( QPixmap::fromMimeSource( "appicon.png" ) );#endif    actionGroupTools = 0;    prefDia = 0;    windowMenu = 0;    hierarchyView = 0;    actionEditor = 0;    currentProject = 0;    wspace = 0;    oWindow = 0;    singleProject = single;    statusBar()->clear();#if defined(QT_NON_COMMERCIAL)    statusBar()->addWidget( new QLabel(tr("Ready - This is the non-commercial version of Qt - "	"For commercial evaluations, use the help menu to register with Trolltech."), statusBar()), 1 );#else    statusBar()->addWidget( new QLabel("Ready", statusBar()), 1 );#endif    set_splash_status( "Setting up GUI..." );    setupMDI();    setupMenuBar();    setupToolbox();    setupFileActions();    setupEditActions();    setupProjectActions();    setupSearchActions();    layoutToolBar = new QToolBar( this, "Layout" );    layoutToolBar->setCloseMode( QDockWindow::Undocked );    addToolBar( layoutToolBar, tr( "Layout" ) );    interpreterPluginManager = 0;    setupToolActions();    setupLayoutActions();    setupPreviewActions();    setupOutputWindow();    setupActionManager();    setupWindowActions();    setupWorkspace();    setupHierarchyView();    setupPropertyEditor();    setupActionEditor();    setupHelpActions();    setupRMBMenus();    connect( this, SIGNAL( projectChanged() ), this, SLOT( emitProjectSignals() ) );    connect( this, SIGNAL( hasActiveWindow(bool) ), this, SLOT( emitProjectSignals() ) );    emit hasActiveForm( FALSE );    emit hasActiveWindow( FALSE );    lastPressWidget = 0;    qApp->installEventFilter( this );    QSize as( qApp->desktop()->size() );    as -= QSize( 30, 30 );    resize( QSize( 1200, 1000 ).boundedTo( as ) );    connect( qApp->clipboard(), SIGNAL( dataChanged() ),	     this, SLOT( clipboardChanged() ) );    clipboardChanged();    layoutChilds = FALSE;    layoutSelected = FALSE;    breakLayout = FALSE;    backPix = TRUE;    set_splash_status( "Loading User Settings..." );    readConfig();    // hack to make WidgetFactory happy (so it knows QWidget and QDialog for resetting properties)    QWidget *w = WidgetFactory::create( WidgetDatabase::idFromClassName( "QWidget" ), this, 0, FALSE );    delete w;    w = WidgetFactory::create( WidgetDatabase::idFromClassName( "QDialog" ), this, 0, FALSE );    delete w;    w = WidgetFactory::create( WidgetDatabase::idFromClassName( "QLabel" ), this, 0, FALSE );    delete w;    w = WidgetFactory::create( WidgetDatabase::idFromClassName( "QTabWidget" ), this, 0, FALSE );    delete w;    w = WidgetFactory::create( WidgetDatabase::idFromClassName( "QFrame" ), this, 0, FALSE );    delete w;    setAppropriate( (QDockWindow*)actionEditor->parentWidget(), FALSE );    actionEditor->parentWidget()->hide();    assistant = new QAssistantClient( assistantPath(), this );    statusBar()->setSizeGripEnabled( TRUE );    set_splash_status( "Initialization Done." );    if ( shStartDialog )	QTimer::singleShot( 0, this, SLOT( showStartDialog() ));}MainWindow::~MainWindow(){    QValueList<Tab>::Iterator tit;    for ( tit = preferenceTabs.begin(); tit != preferenceTabs.end(); ++tit ) {	Tab t = *tit;	delete t.w;    }    for ( tit = projectTabs.begin(); tit != projectTabs.end(); ++tit ) {	Tab t = *tit;	delete t.w;    }    QMap< QAction*, Project* >::Iterator it = projects.begin();    while ( it != projects.end() ) {	Project *p = *it;	++it;	delete p;    }    projects.clear();    delete oWindow;    oWindow = 0;    desInterface->release();    desInterface = 0;    delete actionPluginManager;    delete preferencePluginManager;    delete projectSettingsPluginManager;    delete interpreterPluginManager;    delete templateWizardPluginManager;    delete editorPluginManager;    delete sourceTemplatePluginManager;    MetaDataBase::clearDataBase();    if(self == this)	self = 0;}void MainWindow::setupMDI(){    QVBox *vbox = new QVBox( this );    setCentralWidget( vbox );    vbox->setFrameStyle( QFrame::StyledPanel | QFrame::Sunken );    vbox->setMargin( 1 );    vbox->setLineWidth( 1 );    qworkspace = new QWorkspace( vbox );    qworkspace->setPaletteBackgroundPixmap( QPixmap::fromMimeSource( "background.png" ) );    qworkspace->setScrollBarsEnabled( TRUE );    connect( qworkspace, SIGNAL( windowActivated( QWidget * ) ),	     this, SLOT( activeWindowChanged( QWidget * ) ) );    lastActiveFormWindow = 0;    qworkspace->setAcceptDrops( TRUE );}void MainWindow::setupMenuBar(){    menubar = menuBar();}void MainWindow::setupPropertyEditor(){    QDockWindow *dw = new QDockWindow( QDockWindow::InDock, this );    dw->setResizeEnabled( TRUE );    dw->setCloseMode( QDockWindow::Always );    propertyEditor = new PropertyEditor( dw );    addToolBar( dw, Qt::DockRight );    dw->setWidget( propertyEditor );    dw->setFixedExtentWidth( 250 );    dw->setCaption( tr( "Property Editor/Signal Handlers" ) );    QWhatsThis::add( propertyEditor,		     tr("<b>The Property Editor</b>"			"<p>You can change the appearance and behavior of the selected widget in the "			"property editor.</p>"			"<p>You can set properties for components and forms at design time and see the "			"immediately see the effects of the changes. "			"Each property has its own editor which (depending on the property) can be used "			"to enter "			"new values, open a special dialog, or to select values from a predefined list. "			"Click <b>F1</b> to get detailed help for the selected property.</p>"			"<p>You can resize the columns of the editor by dragging the separators in the "			"list's header.</p>"			"<p><b>Signal Handlers</b></p>"			"<p>In the Signal Handlers tab you can define connections between "			"the signals emitted by widgets and the slots in the form. "			"(These connections can also be made using the connection tool.)" ) );    dw->show();}void MainWindow::setupOutputWindow(){    QDockWindow *dw = new QDockWindow( QDockWindow::InDock, this );    dw->setResizeEnabled( TRUE );    dw->setCloseMode( QDockWindow::Always );    addToolBar( dw, Qt::DockBottom );    oWindow = new OutputWindow( dw );    dw->setWidget( oWindow );    dw->setFixedExtentHeight( 150 );    dw->setCaption( tr( "Output Window" ) );}void MainWindow::setupHierarchyView(){    if ( hierarchyView )	return;    QDockWindow *dw = new QDockWindow( QDockWindow::InDock, this );    dw->setResizeEnabled( TRUE );    dw->setCloseMode( QDockWindow::Always );    hierarchyView = new HierarchyView( dw );    addToolBar( dw, Qt::DockRight );    dw->setWidget( hierarchyView );    dw->setCaption( tr( "Object Explorer" ) );    dw->setFixedExtentWidth( 250 );    QWhatsThis::add( hierarchyView,		     tr("<b>The Object Explorer</b>"			"<p>The Object Explorer provides an overview of the relationships "			"between the widgets in a form. You can use the clipboard functions using "			"a context menu for each item in the view. It is also useful for selecting widgets "			"in forms that have complex layouts.</p>"			"<p>The columns can be resized by dragging the separator in the list's header.</p>"			"<p>The second tab shows all the form's slots, class variables, includes, etc.</p>") );    dw->show();}void MainWindow::setupWorkspace(){    QDockWindow *dw = new QDockWindow( QDockWindow::InDock, this );    dw->setResizeEnabled( TRUE );    dw->setCloseMode( QDockWindow::Always );    QVBox *vbox = new QVBox( dw );

⌨️ 快捷键说明

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