OutputWindow::OutputWindow(Core::Context context, QWidget *parent) : QPlainTextEdit(parent) , m_formatter(0) , m_enforceNewline(false) , m_scrollToBottom(false) , m_linksActive(true) , m_mousePressed(false) , m_maxLineCount(100000) { setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); //setCenterOnScroll(false); setFrameShape(QFrame::NoFrame); setMouseTracking(true); Core::ICore *core = Core::ICore::instance(); m_outputWindowContext = new Core::IContext; m_outputWindowContext->setContext(context); m_outputWindowContext->setWidget(this); core->addContextObject(m_outputWindowContext); QAction *undoAction = new QAction(this); QAction *redoAction = new QAction(this); QAction *cutAction = new QAction(this); QAction *copyAction = new QAction(this); QAction *pasteAction = new QAction(this); QAction *selectAllAction = new QAction(this); Core::ActionManager *am = core->actionManager(); am->registerAction(undoAction, Core::Constants::UNDO, context); am->registerAction(redoAction, Core::Constants::REDO, context); am->registerAction(cutAction, Core::Constants::CUT, context); am->registerAction(copyAction, Core::Constants::COPY, context); am->registerAction(pasteAction, Core::Constants::PASTE, context); am->registerAction(selectAllAction, Core::Constants::SELECTALL, context); connect(undoAction, SIGNAL(triggered()), this, SLOT(undo())); connect(redoAction, SIGNAL(triggered()), this, SLOT(redo())); connect(cutAction, SIGNAL(triggered()), this, SLOT(cut())); connect(copyAction, SIGNAL(triggered()), this, SLOT(copy())); connect(pasteAction, SIGNAL(triggered()), this, SLOT(paste())); connect(selectAllAction, SIGNAL(triggered()), this, SLOT(selectAll())); connect(this, SIGNAL(undoAvailable(bool)), undoAction, SLOT(setEnabled(bool))); connect(this, SIGNAL(redoAvailable(bool)), redoAction, SLOT(setEnabled(bool))); connect(this, SIGNAL(copyAvailable(bool)), cutAction, SLOT(setEnabled(bool))); // OutputWindow never read-only connect(this, SIGNAL(copyAvailable(bool)), copyAction, SLOT(setEnabled(bool))); undoAction->setEnabled(false); redoAction->setEnabled(false); cutAction->setEnabled(false); copyAction->setEnabled(false); }
OutputWindow::OutputWindow(QWidget *parent) : QPlainTextEdit(parent) , m_enforceNewline(false) , m_scrollToBottom(false) { setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); //setCenterOnScroll(false); setWindowTitle(tr("Application Output Window")); setWindowIcon(QIcon(":/qt4projectmanager/images/window.png")); setFrameShape(QFrame::NoFrame); setMouseTracking(true); static uint usedIds = 0; Core::ICore *core = Core::ICore::instance(); QList<int> context; context << core->uniqueIDManager()->uniqueIdentifier(QString(Constants::C_APP_OUTPUT) + QString().setNum(usedIds++)); m_outputWindowContext = new Core::BaseContext(this, context); core->addContextObject(m_outputWindowContext); QAction *undoAction = new QAction(this); QAction *redoAction = new QAction(this); QAction *cutAction = new QAction(this); QAction *copyAction = new QAction(this); QAction *pasteAction = new QAction(this); QAction *selectAllAction = new QAction(this); Core::ActionManager *am = core->actionManager(); am->registerAction(undoAction, Core::Constants::UNDO, context); am->registerAction(redoAction, Core::Constants::REDO, context); am->registerAction(cutAction, Core::Constants::CUT, context); am->registerAction(copyAction, Core::Constants::COPY, context); am->registerAction(pasteAction, Core::Constants::PASTE, context); am->registerAction(selectAllAction, Core::Constants::SELECTALL, context); connect(undoAction, SIGNAL(triggered()), this, SLOT(undo())); connect(redoAction, SIGNAL(triggered()), this, SLOT(redo())); connect(cutAction, SIGNAL(triggered()), this, SLOT(cut())); connect(copyAction, SIGNAL(triggered()), this, SLOT(copy())); connect(pasteAction, SIGNAL(triggered()), this, SLOT(paste())); connect(selectAllAction, SIGNAL(triggered()), this, SLOT(selectAll())); connect(this, SIGNAL(undoAvailable(bool)), undoAction, SLOT(setEnabled(bool))); connect(this, SIGNAL(redoAvailable(bool)), redoAction, SLOT(setEnabled(bool))); connect(this, SIGNAL(copyAvailable(bool)), cutAction, SLOT(setEnabled(bool))); // OutputWindow never read-only connect(this, SIGNAL(copyAvailable(bool)), copyAction, SLOT(setEnabled(bool))); undoAction->setEnabled(false); redoAction->setEnabled(false); cutAction->setEnabled(false); copyAction->setEnabled(false); }
void BauhausPlugin::createDesignModeWidget() { Core::ICore *creatorCore = Core::ICore::instance(); Core::ActionManager *actionManager = creatorCore->actionManager(); m_editorManager = creatorCore->editorManager(); Core::ActionContainer *editMenu = actionManager->actionContainer(Core::Constants::M_EDIT); m_mainWidget = new DesignModeWidget; m_context = new DesignModeContext(m_mainWidget); creatorCore->addContextObject(m_context); Core::Context qmlDesignerMainContext(Constants::C_QMLDESIGNER); Core::Context qmlDesignerFormEditorContext(Constants::C_QMLFORMEDITOR); Core::Context qmlDesignerNavigatorContext(Constants::C_QMLNAVIGATOR); // Revert to saved actionManager->registerAction(m_revertToSavedAction, Core::Constants::REVERTTOSAVED, qmlDesignerMainContext); connect(m_revertToSavedAction, SIGNAL(triggered()), m_editorManager, SLOT(revertToSaved())); //Save actionManager->registerAction(m_saveAction, Core::Constants::SAVE, qmlDesignerMainContext); connect(m_saveAction, SIGNAL(triggered()), m_editorManager, SLOT(saveFile())); //Save As actionManager->registerAction(m_saveAsAction, Core::Constants::SAVEAS, qmlDesignerMainContext); connect(m_saveAsAction, SIGNAL(triggered()), m_editorManager, SLOT(saveFileAs())); //Close Editor actionManager->registerAction(m_closeCurrentEditorAction, Core::Constants::CLOSE, qmlDesignerMainContext); connect(m_closeCurrentEditorAction, SIGNAL(triggered()), m_editorManager, SLOT(closeEditor())); //Close All actionManager->registerAction(m_closeAllEditorsAction, Core::Constants::CLOSEALL, qmlDesignerMainContext); connect(m_closeAllEditorsAction, SIGNAL(triggered()), m_editorManager, SLOT(closeAllEditors())); //Close All Others Action actionManager->registerAction(m_closeOtherEditorsAction, Core::Constants::CLOSEOTHERS, qmlDesignerMainContext); connect(m_closeOtherEditorsAction, SIGNAL(triggered()), m_editorManager, SLOT(closeOtherEditors())); // Undo / Redo actionManager->registerAction(m_mainWidget->undoAction(), Core::Constants::UNDO, qmlDesignerMainContext); actionManager->registerAction(m_mainWidget->redoAction(), Core::Constants::REDO, qmlDesignerMainContext); Core::Command *command; //GoIntoComponent command = actionManager->registerAction(m_mainWidget->goIntoComponentAction(), Constants::GO_INTO_COMPONENT, qmlDesignerMainContext); command->setDefaultKeySequence(QKeySequence(Qt::Key_F2)); //Edit Menu command = actionManager->registerAction(m_mainWidget->deleteAction(), QmlDesigner::Constants::DELETE, qmlDesignerFormEditorContext); command = actionManager->registerAction(m_mainWidget->deleteAction(), QmlDesigner::Constants::DELETE, qmlDesignerNavigatorContext); command->setDefaultKeySequence(QKeySequence::Delete); command->setAttribute(Core::Command::CA_Hide); // don't show delete in other modes editMenu->addAction(command, Core::Constants::G_EDIT_COPYPASTE); command = actionManager->registerAction(m_mainWidget->cutAction(), Core::Constants::CUT, qmlDesignerFormEditorContext); command = actionManager->registerAction(m_mainWidget->cutAction(), Core::Constants::CUT, qmlDesignerNavigatorContext); command->setDefaultKeySequence(QKeySequence::Cut); editMenu->addAction(command, Core::Constants::G_EDIT_COPYPASTE); command = actionManager->registerAction(m_mainWidget->copyAction(), Core::Constants::COPY, qmlDesignerFormEditorContext); command = actionManager->registerAction(m_mainWidget->copyAction(), Core::Constants::COPY, qmlDesignerNavigatorContext); command->setDefaultKeySequence(QKeySequence::Copy); editMenu->addAction(command, Core::Constants::G_EDIT_COPYPASTE); command = actionManager->registerAction(m_mainWidget->pasteAction(), Core::Constants::PASTE, qmlDesignerFormEditorContext); command = actionManager->registerAction(m_mainWidget->pasteAction(), Core::Constants::PASTE, qmlDesignerNavigatorContext); command->setDefaultKeySequence(QKeySequence::Paste); editMenu->addAction(command, Core::Constants::G_EDIT_COPYPASTE); command = actionManager->registerAction(m_mainWidget->selectAllAction(), Core::Constants::SELECTALL, qmlDesignerFormEditorContext); command = actionManager->registerAction(m_mainWidget->selectAllAction(), Core::Constants::SELECTALL, qmlDesignerNavigatorContext); command->setDefaultKeySequence(QKeySequence::SelectAll); editMenu->addAction(command, Core::Constants::G_EDIT_SELECTALL); Core::ActionContainer *viewsMenu = actionManager->actionContainer(Core::Constants::M_WINDOW_VIEWS); command = actionManager->registerAction(m_mainWidget->toggleLeftSidebarAction(), Constants::TOGGLE_LEFT_SIDEBAR, qmlDesignerMainContext); command->setAttribute(Core::Command::CA_Hide); command->setDefaultKeySequence(QKeySequence("Ctrl+Alt+0")); viewsMenu->addAction(command); command = actionManager->registerAction(m_mainWidget->toggleRightSidebarAction(), Constants::TOGGLE_RIGHT_SIDEBAR, qmlDesignerMainContext); command->setAttribute(Core::Command::CA_Hide); command->setDefaultKeySequence(QKeySequence("Ctrl+Alt+Shift+0")); viewsMenu->addAction(command); command = actionManager->registerAction(m_mainWidget->restoreDefaultViewAction(), Constants::RESTORE_DEFAULT_VIEW, qmlDesignerMainContext); command->setAttribute(Core::Command::CA_Hide); viewsMenu->addAction(command); command = actionManager->registerAction(m_mainWidget->hideSidebarsAction(), Core::Constants::TOGGLE_SIDEBAR, qmlDesignerMainContext); #ifdef Q_OS_MACX // add second shortcut to trigger delete QAction *deleteAction = new QAction(m_mainWidget); deleteAction->setShortcut(QKeySequence(QLatin1String("Backspace"))); connect(deleteAction, SIGNAL(triggered()), m_mainWidget->deleteAction(), SIGNAL(triggered())); m_mainWidget->addAction(deleteAction); #endif // Q_OS_MACX connect(m_editorManager, SIGNAL(currentEditorChanged(Core::IEditor*)), this, SLOT(updateEditor(Core::IEditor*))); connect(m_editorManager, SIGNAL(editorsClosed(QList<Core::IEditor*>)), this, SLOT(textEditorsClosed(QList<Core::IEditor*>))); connect(creatorCore, SIGNAL(contextChanged(Core::IContext*,Core::Context)), this, SLOT(contextChanged(Core::IContext*,Core::Context))); }