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

📄 mainimpl.cpp

📁 用Qt4编写的linux IDE开发环境
💻 CPP
📖 第 1 页 / 共 5 页
字号:
/** This file is part of QDevelop, an open-source cross-platform IDE* Copyright (C) 2006  Jean-Luc Biord** This program is free software; you can redistribute it and/or modify* it under the terms of the GNU General Public License as published by* the Free Software Foundation; either version 2 of the License, or* (at your option) any later version.** This program is distributed in the hope that it will be useful,* but WITHOUT ANY WARRANTY; without even the implied warranty of* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the* GNU General Public License for more details.** You should have received a copy of the GNU General Public License* along with this program; if not, write to the Free Software* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA** Contact e-mail: Jean-Luc Biord <jl.biord@free.fr>* Program URL   : http://qdevelop.org**/#define QD qDebug() << __FILE__ << __LINE__ << ":"//#include "mainimpl.h"#include "editor.h"#include "build.h"#include "debug.h"#include "ui_about.h"#include "ui_warning.h"#include "parametersimpl.h"#include "findfileimpl.h"#include "openfileimpl.h"#include "shortcutsimpl.h"#include "projectmanager.h"#include "assistant.h"#include "designer.h"#include "optionsimpl.h"#include "newprojectimpl.h"#include "cpphighlighter.h"#include "tabwidget.h"#include "stackimpl.h"#include "toolscontrolimpl.h"#include "InitCompletion.h"#include "pluginsinterfaces.h"#include "misc.h"//#include <QFileDialog>#include <QGridLayout>#include <QTreeWidget>#include <QTreeWidgetItem>#include <QDebug>#include <QFile>#include <QDir>#include <QProcess>#include <QListWidget>#include <QListWidgetItem>#include <QMessageBox>#include <QToolButton>#include <QCloseEvent>#include <QFileInfo>#include <QSettings>#include <QLineEdit>#include <QMenu>#include <QActionGroup>#include <QTimer>#include <QString>#include <QScrollArea>#include <QLibraryInfo>#include <QHeaderView>#include <QInputDialog>#include <QPluginLoader>//#define PROJECT_NAME "QDevelop"#define VERSION "0.25"MainImpl::MainImpl(QWidget * parent)        : QMainWindow(parent){    setupUi(this);    setStatusBar( false );    m_saveBeforeBuild = true;    m_restoreOnStart = true;    m_projectManager = 0;    m_debug = 0;    m_debugAfterBuild = ExecuteNone;    m_buildAfterDebug = false;    m_checkEnvironmentOnStartup = true;    m_endLine = Default;    m_tabSpaces = false;    m_autoCompletion = true;    m_autobrackets = true;    m_match = true;    m_highlightCurrentLine = true;    m_backgroundColor = Qt::white;    m_textColor = Qt::black;    m_promptBeforeQuit = false;    m_currentLineColor = QColor(215,252,255);    m_matchingColor = Qt::red;    m_findInFiles = 0;    m_stack = 0;    m_intervalUpdatingClasses = 5;    m_showTreeClasses = true;    m_completion = 0;    m_projectsDirectory = QDir::homePath();    m_closeButtonInTabs = false;    m_assistant = 0;    m_designer = 0;    crossButton = 0;    m_pluginsDirectory = "";    m_includeDirectory = QLibraryInfo::location( QLibraryInfo::HeadersPath );    m_documentationDirectory = QLibraryInfo::location( QLibraryInfo::DocumentationPath );    m_configureCompletionNeeded = false;    m_mibCodec = 106; // UTF-8 by default    m_buildQtDatabase = 0;    m_buildQtDatabaseAsked = false;    m_displayEditorToolbars = true;    m_displayWhiteSpaces = true;    m_automaticCompilation = true;    //    m_formatPreprocessorText.setForeground(QColor(0,128,0));    m_formatQtText.setForeground(Qt::blue);    m_formatSingleComments.setForeground(Qt::red);    m_formatMultilineComments.setForeground(Qt::red);    m_formatQuotationText.setForeground(Qt::darkGreen);    m_formatMethods.setForeground(Qt::black);    m_formatKeywords.setForeground(Qt::blue);    tableLocalVariables->verticalHeader()->hide();    tableOtherVariables->verticalHeader()->hide();    separatorOtherFile = toolBarEdit->addSeparator();    separatorOtherFile->setVisible(false);    actionOtherFile = new QAction(this);    actionOtherFile->setVisible(false);    toolBarEdit->addAction(actionOtherFile);#ifdef WIN32    m_font = QFont("Courier New", 10);#else    m_font = QFont("Monospace", 10);#endif    m_tabStopWidth = 4;    m_lineNumbers = m_selectionBorder = m_autoIndent = m_cppHighlighter = true;    //    m_tabEditors = new TabWidget( this );    connect(m_tabEditors, SIGNAL(currentChanged(int)), this, SLOT(slotCurrentTabChanged(int)) );    connect(m_tabEditors, SIGNAL(currentChanged(int)), this, SLOT(slotUpdateOtherFileActions()) );    //    //    setCentralWidget( m_tabEditors );    //    m_assistant = new Assistant();    m_designer = new Designer();    //    treeFiles->setColumnCount(1);    treeFiles->setHeaderLabels(QStringList(""));    //    treeClasses->setColumnCount(1);    treeClasses->setHeaderLabels(QStringList(""));    treeClasses->setMainImpl( this );    //    menuView->addSeparator();    menuView->addAction(dockExplorer->toggleViewAction());    menuView->addAction(dockOutputs->toggleViewAction());    menuView->addAction(dockCallsStack->toggleViewAction());    menuView->addAction(dockRegisters->toggleViewAction());    menuView->addSeparator();    //    menuToolbar->addAction(toolBarFiles->toggleViewAction());    menuToolbar->addAction(toolBarEdit->toggleViewAction());    menuToolbar->addAction(toolBarBuild->toggleViewAction());    //    for (int i = 0; i < maxRecentsFiles; ++i)    {        actionsRecentsFiles[i] = new QAction(this);        menuLastsFiles->addAction(actionsRecentsFiles[i]);        actionsRecentsFiles[i]->setVisible(false);        connect(actionsRecentsFiles[i], SIGNAL(triggered()),this, SLOT(slotOpenRecentFile()));    }    updateActionsRecentsFiles();    //    for (int i = 0; i < maxRecentsProjects; ++i)    {        actionsProjetsRecents[i] = new QAction(this);        menuLastsProjects->addAction(actionsProjetsRecents[i]);        actionsProjetsRecents[i]->setVisible(false);        connect(actionsProjetsRecents[i], SIGNAL(triggered()),this, SLOT(slotOpenRecentProject()));    }    updateActionsRecentsProjects();    createConnections();    setMouseTracking( true );    //    dockExplorer->setFloating( false );    dockOutputs->setFloating( false );    dockCallsStack->setFloating( false );    //    dockExplorer->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);    addDockWidget(Qt::LeftDockWidgetArea, dockExplorer);    //    m_stack = new StackImpl(this, callStacks);    //    treeClasses->setCtagsName( m_ctagsName );    logBuild->setMainImpl( this );}//MainImpl::~MainImpl(){    if ( m_completion )    {        m_completion->terminate();        m_completion->wait();        delete m_completion;        m_completion = 0;    }    if( m_buildQtDatabase )    {    	m_buildQtDatabase->setStopRequired();    	m_buildQtDatabase->wait();    	delete m_buildQtDatabase;    	m_buildQtDatabase = 0;   	}}//convenient functions to access editor tabsEditor * MainImpl::currentEditor(){	Editor *editor = 0;	int currentIndex = m_tabEditors->currentIndex();	if( currentIndex != -1 )		editor = (Editor*) (m_tabEditors->widget( currentIndex ));    return editor;}Editor * MainImpl::givenEditor(int i){    return (Editor*) (m_tabEditors->widget(i));}//void MainImpl::renameEditor(QString oldName, QString newName){    foreach(Editor *editor, allEditors() )    {        if ( editor->filename() == oldName)        {            editor->setFilename( newName );            slotModifiedEditor(editor, editor->isModified() );            editor->save();            break;        }    }}//void MainImpl::configureCompletion(QString projectDirectory){    QString QTDIR;    QStringList includes;    includes << projectDirectory;    m_completion->setCtagsCmdPath( ctagsName() );    m_completion->addIncludes( includes, projectDirectory);    m_configureCompletionNeeded = false;}//void MainImpl::gotoFileInProject(QString& filename){    if ( !m_projectManager )        return;    tabExplorer->setCurrentIndex(0);    m_projectManager->setCurrentItem(filename);}//void MainImpl::setCrossButton(bool activate){    if (crossButton && !activate)    {        crossButton->hide();    }    else if ( activate )    {        if ( !crossButton )        {            crossButton = new QToolButton(m_tabEditors);            crossButton->setIcon( QIcon(":/toolbar/images/cross.png") );            connect(crossButton, SIGNAL(clicked()), this, SLOT(slotCloseCurrentTab()) );            crossButton->setGeometry(0,0,32,32);            m_tabEditors->setCornerWidget(crossButton);        }        crossButton->show();    }    m_tabEditors->setCloseButtonInTabs( !activate );}//void MainImpl::slotOtherFile(){    Editor *editor = currentEditor();    if ( editor  )        editor->slotOtherFile();}//void MainImpl::createConnections(){    connect(actionAboutQt, SIGNAL(triggered()), qApp, SLOT(aboutQt()) );    connect(actionAbout, SIGNAL(triggered()), this, SLOT(slotAbout()) );    connect(actionNewProject, SIGNAL(triggered()), this, SLOT(slotNewProject()) );    connect(actionOpen, SIGNAL(triggered()), this, SLOT(slotOpen()) );    connect(actionOpenProject, SIGNAL(triggered()), this, SLOT(slotOpenProject()) );    connect(actionSaveFile, SIGNAL(triggered()), this, SLOT(slotSaveFile()) );    connect(actionSaveAll, SIGNAL(triggered()), this, SLOT(slotSaveAll()) );    connect(actionSaveFileAs, SIGNAL(triggered()), this, SLOT(slotSaveFileAs()) );    connect(actionCompile, SIGNAL(triggered()), this, SLOT(slotCompile()) );    connect(actionBuild, SIGNAL(triggered()), this, SLOT(slotBuild()) );    connect(actionRebuild, SIGNAL(triggered()), this, SLOT(slotRebuild()) );    connect(actionQmake, SIGNAL(triggered()), this, SLOT(slotQmake()) );    connect(actionStopBuild, SIGNAL(triggered()), this, SLOT(slotStopBuild()) );    connect(actionClean, SIGNAL(triggered()), this, SLOT(slotClean()) );    connect(actionCut, SIGNAL(triggered()), this, SLOT(slotCut()) );    connect(actionCopy, SIGNAL(triggered()), this, SLOT(slotCopy()) );    connect(actionPaste, SIGNAL(triggered()), this, SLOT(slotPaste()) );    connect(actionUndo, SIGNAL(triggered()), this, SLOT(slotUndo()) );    connect(actionIndent, SIGNAL(triggered()), this, SLOT(slotIndent()) );    connect(actionUnindent, SIGNAL(triggered()), this, SLOT(slotUnindent()) );    connect(actionSelectAll, SIGNAL(triggered()), this, SLOT(slotSelectAll()) );    connect(actionRedo, SIGNAL(triggered()), this, SLOT(slotRedo()) );    connect(actionFind, SIGNAL(triggered()), this, SLOT(slotFind()) );    connect(actionReplace, SIGNAL(triggered()), this, SLOT(slotReplace()) );    connect(actionGotoLine, SIGNAL(triggered()), this, SLOT(slotGotoLine()) );    connect(actionFindContinue, SIGNAL(triggered()), this, SLOT(slotFindContinue()) );    connect(actionFindPrevious, SIGNAL(triggered()), this, SLOT(slotFindPrevious()) );    connect(actionCloseAllFiles, SIGNAL(triggered()), this, SLOT(slotCloseAllFiles()) );    connect(actionCloseProject, SIGNAL(triggered()), this, SLOT(slotCloseProject()) );    connect(actionOptions, SIGNAL(triggered()), this, SLOT(slotOptions()) );    connect(actionConfigureShortcuts, SIGNAL(triggered()), this, SLOT(slotShortcuts()) );    connect(actionCompleteCode, SIGNAL(triggered()), this, SLOT(slotCompleteCode()) );    connect(actionFindInFiles, SIGNAL(triggered()), this, SLOT(slotFindInFiles()) );    connect(actionNewFile, SIGNAL(triggered()), this, SLOT(slotNewFile()) );    connect(actionToggleComment, SIGNAL(triggered()), this, SLOT(slotToggleComment()) );    connect(actionComment, SIGNAL(triggered()), this, SLOT(slotComment()) );    connect(actionUncomment, SIGNAL(triggered()), this, SLOT(slotUncomment()) );    connect(actionParameters, SIGNAL(triggered()), this, SLOT(slotParameters()) );    connect(actionGotoMatchingBracket, SIGNAL(triggered()), this, SLOT(slotGotoMatchingBracket()) );    connect(addDebugVariable, SIGNAL(clicked()), this, SLOT(slotAddDebugVariable()) );    connect(removeDebugVariable, SIGNAL(clicked()), this, SLOT(slotRemoveDebugVariable()) );    connect(actionPrint, SIGNAL(triggered()), this, SLOT(slotPrint()) );    connect(actionGotoDeclaration, SIGNAL(triggered()), this, SLOT(slotGotoDeclaration()) );    connect(actionGotoImplementation, SIGNAL(triggered()), this, SLOT(slotGotoImplementation()) );    connect(actionMethodsList, SIGNAL(triggered()), this, SLOT(slotMethodsList()) );    connect(actionNextWarningError, SIGNAL(triggered()), this, SLOT(slotNextWarningError()) );    connect(actionPreviousWarningError, SIGNAL(triggered()), this, SLOT(slotPreviousWarningError()) );    connect(actionClearAllWarningsErrors, SIGNAL(triggered()), this, SLOT(slotClearAllWarningsErrors()) );    //    connect(actionExternalTools, SIGNAL(triggered()), this, SLOT(slotToolsControl()) );    connect(actionCloseCurrentEditor, SIGNAL(triggered()), this, SLOT(slotCloseCurrentTab()) );    actionCloseCurrentEditor->setShortcutContext( Qt::ApplicationShortcut );    connect(actionPreviousTab, SIGNAL(triggered()), this, SLOT(slotPreviousTab()) );    actionPreviousTab->setShortcutContext( Qt::ApplicationShortcut );    connect(actionNextTab, SIGNAL(triggered()), this, SLOT(slotNextTab()) );    actionNextTab->setShortcutContext( Qt::ApplicationShortcut );    connect(actionsetFocusToEditor, SIGNAL(triggered()), this, SLOT(slotSetFocusToEditor()) );

⌨️ 快捷键说明

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