bool EditorManager::initWithApp(IApplication *app) { if (!IEditorManager::initWithApp(app)) { return false; } m_currentNavigationHistoryPosition = 0; m_widget = new QWidget; m_editorTabWidget = new LiteTabWidget; m_editorTabWidget->tabBar()->setTabsClosable(m_liteApp->settings()->value(LITEAPP_EDITTABSCLOSABLE,true).toBool()); //m_editorTabWidget->tabBar()->setIconSize(LiteApi::getToolBarIconSize()); // m_editorTabWidget->tabBar()->setStyleSheet("QTabBar::tab{border:1px solid} QTabBar::close-button {margin:0px; image: url(:/images/closetool.png); subcontrol-position: left;}" // ); QVBoxLayout *mainLayout = new QVBoxLayout; mainLayout->setMargin(1); mainLayout->setSpacing(1); QToolBar *toolBar = m_editorTabWidget->headerToolBar(); toolBar->setObjectName("toolbar/tabs"); m_liteApp->actionManager()->insertToolBar(toolBar); m_editorTabWidget->headerToolBar()->setAllowedAreas(Qt::TopToolBarArea|Qt::BottomToolBarArea); mainLayout->addWidget(m_editorTabWidget->stackedWidget()); m_widget->setLayout(mainLayout); connect(m_editorTabWidget,SIGNAL(currentChanged(int)),this,SLOT(editorTabChanged(int))); connect(m_editorTabWidget,SIGNAL(tabCloseRequested(int)),this,SLOT(editorTabCloseRequested(int))); connect(m_editorTabWidget,SIGNAL(tabAddRequest()),this,SIGNAL(tabAddRequest())); m_editorTabWidget->stackedWidget()->installEventFilter(this); m_editorTabWidget->tabBar()->installEventFilter(this); m_tabContextMenu = new QMenu; m_tabContextIndex = -1; QAction *closeAct = new QAction(tr("Close"),this); closeAct->setShortcut(QKeySequence("Ctrl+W")); QAction *closeOthersAct = new QAction(tr("Close Others"),this); QAction *closeAllAct = new QAction(tr("Close All"),this); QAction *moveToAct = new QAction(tr("Move To New Window"),this); m_tabContextMenu->addAction(closeAct); m_tabContextMenu->addAction(closeOthersAct); m_tabContextMenu->addAction(closeAllAct); m_tabContextMenu->addSeparator(); m_tabContextMenu->addAction(moveToAct); connect(closeAct,SIGNAL(triggered()),this,SLOT(tabContextClose())); connect(closeOthersAct,SIGNAL(triggered()),this,SLOT(tabContextCloseOthers())); connect(closeAllAct,SIGNAL(triggered()),this,SLOT(tabContextCloseAll())); connect(moveToAct,SIGNAL(triggered()),this,SLOT(moveToNewWindow())); return true; }
LiteTabWidget::LiteTabWidget(QSize iconSize, QObject *parent) : QObject(parent) { m_tabBar = new TabBar; m_tabBar->setExpanding(false); m_tabBar->setDocumentMode(true); m_tabBar->setDrawBase(false); m_tabBar->setUsesScrollButtons(true); m_tabBar->setMovable(true); m_tabBar->setSelectionBehaviorOnRemove(QTabBar::SelectPreviousTab); m_tabToolBar = new QToolBar; m_tabToolBar->setObjectName("toolbar.tabs"); m_tabToolBar->setIconSize(iconSize); m_tabBarWidget = new QWidget; m_addTabAct = new QAction(QIcon("icon:images/addpage.png"),tr("Open a new tab"),this); m_listButton = new QToolButton; m_listButton->setToolTip(tr("List All Tabs")); m_listButton->setIcon(QIcon("icon:images/listpage.png")); m_listButton->setPopupMode(QToolButton::InstantPopup); m_listButton->setStyleSheet( "QToolButton::menu-indicator{image:none;}"); m_closeTabAct = new QAction(QIcon("icon:images/closetool.png"),tr("Close Tab"),this); //m_closeButton = new QToolButton; //m_closeButton->setDefaultAction(m_closeTabAct); QHBoxLayout *layout = new QHBoxLayout; layout->setMargin(0); layout->setSpacing(0); m_tabToolBar->addWidget(m_tabBar); QWidget *dump = new QWidget; dump->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred); m_tabToolBar->addWidget(dump); m_tabToolBar->addWidget(m_listButton); m_tabToolBar->addAction(m_closeTabAct); // layout->addWidget(m_tabBar,1); // layout->addWidget(m_listButton); // layout->addWidget(m_closeButton); layout->addWidget(m_tabToolBar); m_tabBarWidget->setLayout(layout); m_stackedWidget = new QStackedWidget; connect(m_tabBar,SIGNAL(currentChanged(int)),this,SLOT(tabCurrentChanged(int))); connect(m_tabBar,SIGNAL(tabCloseRequested(int)),this,SIGNAL(tabCloseRequested(int))); connect(m_tabBar,SIGNAL(tabMoved(int,int)),this,SLOT(tabMoved(int,int))); connect(m_closeTabAct,SIGNAL(triggered()),this,SLOT(closeCurrentTab())); connect(m_addTabAct,SIGNAL(triggered()),this,SIGNAL(tabAddRequest())); m_listButton->setEnabled(false); }
LiteTabWidget::LiteTabWidget(QSize iconSize, QObject *parent) : QObject(parent) { m_tabBar = new QTabBar; m_tabBar->setExpanding(false); m_tabBar->setDocumentMode(true); m_tabBar->setDrawBase(false); m_tabBar->setUsesScrollButtons(true); m_tabBar->setMovable(true); m_headerToolBar = new QToolBar; m_headerToolBar->setObjectName("toolbar.tabs"); m_headerToolBar->setIconSize(iconSize); m_closeTabAct = new QAction(QIcon("icon:images/closepage.png"),tr("Close tab"),this); m_listButton = new QToolButton(m_headerToolBar); m_listButton->setToolTip(tr("List all tabs")); m_listButton->setIcon(QIcon("icon:images/listpage.png")); m_addTabAct = new QAction(QIcon("icon:images/addpage.png"),tr("Open a new tab"),this); m_listActMenu = new QMenu; m_listActGroup = new QActionGroup(this); m_listButton->setMenu(m_listActMenu); m_listButton->setPopupMode(QToolButton::InstantPopup); m_headerToolBar->addWidget(m_tabBar); QWidget *spacer = new QWidget; spacer->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred); m_headerToolBar->addWidget(spacer); m_headerToolBar->addWidget(m_listButton); m_headerToolBar->addSeparator(); m_headerToolBar->addAction(m_addTabAct); m_headerToolBar->addSeparator(); m_headerToolBar->addAction(m_closeTabAct); m_stackedWidget = new QStackedWidget; connect(m_tabBar,SIGNAL(currentChanged(int)),this,SLOT(tabCurrentChanged(int))); connect(m_tabBar,SIGNAL(tabCloseRequested(int)),this,SIGNAL(tabCloseRequested(int))); connect(m_tabBar,SIGNAL(tabMoved(int,int)),this,SLOT(tabMoved(int,int))); connect(m_closeTabAct,SIGNAL(triggered()),this,SLOT(closeCurrentTab())); connect(m_addTabAct,SIGNAL(triggered()),this,SIGNAL(tabAddRequest())); connect(m_listActGroup,SIGNAL(triggered(QAction*)),this,SLOT(selectListActGroup(QAction*))); m_listButton->setEnabled(false); }
LiteApp::LiteApp() : m_applicationPath(QApplication::applicationDirPath()), m_pluginPath(LiteApp::getPluginPath()), m_resourcePath(LiteApp::getResoucePath()), m_storagePath(LiteApp::getStoragePath()) { QSettings global(m_resourcePath+"/liteapp/config/global.ini",QSettings::IniFormat); bool storeLocal = global.value(LITEIDE_STORELOCAL,false).toBool(); if (storeLocal) { m_settings = new QSettings(m_resourcePath+"/liteapp/config/liteide.ini", QSettings::IniFormat); } else { m_settings = new QSettings(QSettings::IniFormat,QSettings::UserScope,"liteide","liteide",this); } m_extension = new Extension; m_mainwindow = new MainWindow(this); QString style = this->settings()->value(LITEAPP_STYLE,"sidebar").toString(); if (style == "splitter") { SplitWindowStyle *style = new SplitWindowStyle(this,m_mainwindow); m_mainwindow->setWindowStyle(style); } else { SideWindowStyle *style = new SideWindowStyle(this,m_mainwindow); m_mainwindow->setWindowStyle(style); } m_toolWindowManager = new ToolWindowManager; m_htmlWidgetManager = new HtmlWidgetManager; m_actionManager = new ActionManager; m_projectManager = new ProjectManager; m_editorManager = new EditorManager; m_fileManager = new FileManager; m_mimeTypeManager = new MimeTypeManager; m_optionManager = new OptionManager; m_goProxy = new GoProxy(this); m_actionManager->initWithApp(this); m_mainwindow->createToolWindowMenu(); m_toolWindowManager->initWithApp(this); m_mimeTypeManager->initWithApp(this); m_projectManager->initWithApp(this); m_editorManager->initWithApp(this); m_fileManager->initWithApp(this); m_optionManager->initWithApp(this); //m_mainwindow->setCentralWidget(m_editorManager->widget()); m_mainwindow->splitter()->addWidget(m_editorManager->widget()); //m_mainwindow->splitter()->addWidget(m_outputManager->widget()); m_mainwindow->splitter()->setStretchFactor(0,50); //m_mainwindow->setStatusBar(m_outputManager->statusBar()); m_htmlWidgetManager->addFactory(new TextBrowserHtmlWidgetFactory(this)); m_extension->addObject("LiteApi.IMimeTypeManager",m_mimeTypeManager); m_extension->addObject("LiteApi.IProjectManager",m_projectManager); m_extension->addObject("LiteApi.IEditManager",m_editorManager); m_extension->addObject("LiteApi.IOptoinManager",m_optionManager); m_extension->addObject("LiteApi.IToolWindowManager",m_toolWindowManager); m_extension->addObject("LiteApi.QMainWindow",m_mainwindow); m_extension->addObject("LiteApi.QMainWindow.QSplitter",m_mainwindow->splitter()); m_extension->addObject("LiteApi.IHtmlWidgetManager",m_htmlWidgetManager); //add actions connect(m_projectManager,SIGNAL(currentProjectChanged(LiteApi::IProject*)),this,SLOT(currentProjectChanged(LiteApi::IProject*))); connect(m_editorManager,SIGNAL(currentEditorChanged(LiteApi::IEditor*)),m_projectManager,SLOT(currentEditorChanged(LiteApi::IEditor*))); connect(m_editorManager,SIGNAL(currentEditorChanged(LiteApi::IEditor*)),m_mainwindow,SLOT(currentEditorChanged(LiteApi::IEditor*))); connect(m_editorManager,SIGNAL(currentEditorChanged(LiteApi::IEditor*)),this,SLOT(currentEditorChanged(LiteApi::IEditor*))); connect(m_editorManager,SIGNAL(tabAddRequest()),m_fileManager,SLOT(openEditors())); connect(m_editorManager,SIGNAL(editorSaved(LiteApi::IEditor*)),m_fileManager,SLOT(editorSaved(LiteApi::IEditor*))); connect(m_editorManager,SIGNAL(editorCreated(LiteApi::IEditor*)),m_fileManager,SLOT(editorCreated(LiteApi::IEditor*))); connect(m_editorManager,SIGNAL(editorAboutToClose(LiteApi::IEditor*)),m_fileManager,SLOT(editorAboutToClose(LiteApi::IEditor*))); connect(m_editorManager,SIGNAL(doubleClickedTab()),m_mainwindow,SLOT(showOrHideToolWindow())); connect(m_optionManager,SIGNAL(applyOption(QString)),m_fileManager,SLOT(applyOption(QString))); connect(m_optionManager,SIGNAL(applyOption(QString)),m_projectManager,SLOT(applyOption(QString))); connect(m_optionManager,SIGNAL(applyOption(QString)),this,SLOT(applyOption(QString))); QAction *esc = new QAction(tr("Escape"),this); m_actionManager->getActionContext(this,"App")->regAction(esc,"Escape","ESC"); m_mainwindow->addAction(esc); connect(esc,SIGNAL(triggered()),this,SLOT(escape())); createActions(); createMenus(); createToolBars(); m_editorManager->createActions(); m_logOutput = new TextOutput(this); //m_outputManager->addOutuput(m_logOutput,tr("Console")); m_logAct = m_toolWindowManager->addToolWindow(Qt::BottomDockWidgetArea,m_logOutput,"eventlog",tr("Event Log"),true); connect(m_logOutput,SIGNAL(dbclickEvent(QTextCursor)),this,SLOT(dbclickLogOutput(QTextCursor))); m_optionAct = new QAction(tr("Options"),this); m_optionAct->setMenuRole(QAction::PreferencesRole); m_actionManager->insertViewMenu(LiteApi::ViewMenuBrowserPos,m_optionAct); connect(m_optionAct,SIGNAL(triggered()),m_optionManager,SLOT(exec())); this->appendLog("LiteApp","Initializing"); m_liteAppOptionFactory = new LiteAppOptionFactory(this,this); m_optionManager->addFactory(m_liteAppOptionFactory); connect(m_goProxy,SIGNAL(stdoutput(QByteArray)),this,SLOT(goproxyDone(QByteArray))); connect(this,SIGNAL(key_escape()),m_mainwindow,SLOT(hideOutputWindow())); connect(m_mainwindow,SIGNAL(fullScreenStateChanged(bool)),m_fullScreent,SLOT(setChecked(bool))); }
LiteApp::LiteApp() : m_applicationPath(QApplication::applicationDirPath()), m_pluginPath(LiteApp::getPluginPath()), m_resourcePath(LiteApp::getResoucePath()), m_storagePath(LiteApp::getStoragePath()), m_settings(new QSettings(QSettings::IniFormat,QSettings::UserScope,"liteide","liteide",this)), m_extension(new Extension), m_mainwindow(new MainWindow(this)), m_toolWindowManager(new ToolWindowManager), m_htmlWidgetManager(new HtmlWidgetManager), m_actionManager(new ActionManager), m_projectManager(new ProjectManager), m_editorManager(new EditorManager), m_fileManager(new FileManager), m_mimeTypeManager(new MimeTypeManager), m_optionManager(new OptionManager) { m_goProxy = new GoProxy(this); m_actionManager->initWithApp(this); m_toolWindowManager->initWithApp(this); m_mimeTypeManager->initWithApp(this); m_projectManager->initWithApp(this); m_editorManager->initWithApp(this); m_fileManager->initWithApp(this); m_optionManager->initWithApp(this); //m_mainwindow->setCentralWidget(m_editorManager->widget()); m_mainwindow->splitter()->addWidget(m_editorManager->widget()); //m_mainwindow->splitter()->addWidget(m_outputManager->widget()); m_mainwindow->splitter()->setStretchFactor(0,50); //m_mainwindow->setStatusBar(m_outputManager->statusBar()); m_htmlWidgetManager->addFactory(new TextBrowserHtmlWidgetFactory(this)); m_extension->addObject("LiteApi.IMimeTypeManager",m_mimeTypeManager); m_extension->addObject("LiteApi.IProjectManager",m_projectManager); m_extension->addObject("LiteApi.IEditManager",m_editorManager); m_extension->addObject("LiteApi.IOptoinManager",m_optionManager); m_extension->addObject("LiteApi.IToolWindowManager",m_toolWindowManager); m_extension->addObject("LiteApi.QMainWindow",m_mainwindow); m_extension->addObject("LiteApi.QMainWindow.QSplitter",m_mainwindow->splitter()); m_extension->addObject("LiteApi.IHtmlWidgetManager",m_htmlWidgetManager); //add actions connect(m_projectManager,SIGNAL(currentProjectChanged(LiteApi::IProject*)),this,SLOT(currentProjectChanged(LiteApi::IProject*))); connect(m_editorManager,SIGNAL(currentEditorChanged(LiteApi::IEditor*)),m_projectManager,SLOT(currentEditorChanged(LiteApi::IEditor*))); connect(m_editorManager,SIGNAL(currentEditorChanged(LiteApi::IEditor*)),m_mainwindow,SLOT(currentEditorChanged(LiteApi::IEditor*))); connect(m_editorManager,SIGNAL(currentEditorChanged(LiteApi::IEditor*)),this,SLOT(currentEditorChanged(LiteApi::IEditor*))); connect(m_editorManager,SIGNAL(tabAddRequest()),m_fileManager,SLOT(openEditors())); connect(m_editorManager,SIGNAL(editorSaved(LiteApi::IEditor*)),m_fileManager,SLOT(editorSaved(LiteApi::IEditor*))); connect(m_editorManager,SIGNAL(editorCreated(LiteApi::IEditor*)),m_fileManager,SLOT(editorCreated(LiteApi::IEditor*))); connect(m_editorManager,SIGNAL(editorAboutToClose(LiteApi::IEditor*)),m_fileManager,SLOT(editorAboutToClose(LiteApi::IEditor*))); connect(m_editorManager,SIGNAL(doubleClickedTab()),m_mainwindow,SLOT(showOrHideToolWindow())); connect(m_optionManager,SIGNAL(applyOption(QString)),m_fileManager,SLOT(applyOption(QString))); connect(m_optionManager,SIGNAL(applyOption(QString)),m_projectManager,SLOT(applyOption(QString))); QAction *esc = new QAction(tr("Escape"),this); m_actionManager->getActionContext(this,"App")->regAction(esc,"Esacpe","ESC"); connect(esc,SIGNAL(triggered()),this,SLOT(escape())); m_mainwindow->addAction(esc); createActions(); createMenus(); createToolBars(); m_editorManager->createActions(); m_logOutput = new TextOutput(this); //m_outputManager->addOutuput(m_logOutput,tr("Console")); m_logAct = m_toolWindowManager->addToolWindow(Qt::BottomDockWidgetArea,m_logOutput,"eventlog",tr("Event Log"),true); connect(m_logOutput,SIGNAL(dbclickEvent(QTextCursor)),this,SLOT(dbclickLogOutput(QTextCursor))); m_optionAct = m_editorManager->registerBrowser(m_optionManager->browser()); //m_viewMenu->addAction(m_optionAct); m_actionManager->insertViewMenu(LiteApi::ViewMenuBrowserPos,m_optionAct); m_optionManager->setAction(m_optionAct); this->appendLog("LiteApp","Init"); m_liteAppOptionFactory = new LiteAppOptionFactory(this,this); m_optionManager->addFactory(m_liteAppOptionFactory); m_projectManager->addFactory(new FolderProjectFactory(this,this)); connect(m_goProxy,SIGNAL(done(QByteArray,QByteArray)),this,SLOT(goproxyDone(QByteArray,QByteArray))); connect(this,SIGNAL(key_escape()),m_mainwindow,SLOT(hideToolWindow())); connect(m_mainwindow,SIGNAL(fullScreenStateChanged(bool)),m_fullScreent,SLOT(setChecked(bool))); }