UAVSettingsImportExportFactory::UAVSettingsImportExportFactory(QObject *parent) : QObject(parent) { // Add Menu entry Core::ActionManager *am = Core::ICore::instance()->actionManager(); Core::ActionContainer *ac = am->actionContainer(Core::Constants::M_FILE); Core::Command *cmd = am->registerAction(new QAction(this), "UAVSettingsImportExportPlugin.UAVSettingsExport", QList<int>() << Core::Constants::C_GLOBAL_ID); cmd->setDefaultKeySequence(QKeySequence("Ctrl+E")); cmd->action()->setText(tr("Export UAV Settings...")); ac->addAction(cmd, Core::Constants::G_FILE_SAVE); connect(cmd->action(), SIGNAL(triggered(bool)), this, SLOT(exportUAVSettings())); cmd = am->registerAction(new QAction(this), "UAVSettingsImportExportPlugin.UAVSettingsImport", QList<int>() << Core::Constants::C_GLOBAL_ID); cmd->setDefaultKeySequence(QKeySequence("Ctrl+I")); cmd->action()->setText(tr("Import UAV Settings...")); ac->addAction(cmd, Core::Constants::G_FILE_SAVE); connect(cmd->action(), SIGNAL(triggered(bool)), this, SLOT(importUAVSettings())); ac = am->actionContainer(Core::Constants::M_HELP); cmd = am->registerAction(new QAction(this), "UAVSettingsImportExportPlugin.UAVDataExport", QList<int>() << Core::Constants::C_GLOBAL_ID); cmd->action()->setText(tr("Export UAV Data...")); ac->addAction(cmd, Core::Constants::G_HELP_HELP); connect(cmd->action(), SIGNAL(triggered(bool)), this, SLOT(exportUAVData())); }
CMakeManager::CMakeManager(CMakeSettingsPage *cmakeSettingsPage) : m_settingsPage(cmakeSettingsPage) { ProjectExplorer::ProjectExplorerPlugin *projectExplorer = ProjectExplorer::ProjectExplorerPlugin::instance(); connect(projectExplorer, SIGNAL(aboutToShowContextMenu(ProjectExplorer::Project*, ProjectExplorer::Node*)), this, SLOT(updateContextMenu(ProjectExplorer::Project*, ProjectExplorer::Node*))); Core::ActionManager *am = Core::ICore::instance()->actionManager(); Core::ActionContainer *mbuild = am->actionContainer(ProjectExplorer::Constants::M_BUILDPROJECT); Core::ActionContainer *mproject = am->actionContainer(ProjectExplorer::Constants::M_PROJECTCONTEXT); Core::ActionContainer *msubproject = am->actionContainer(ProjectExplorer::Constants::M_SUBPROJECTCONTEXT); const Core::Context projectContext(CMakeProjectManager::Constants::PROJECTCONTEXT); m_runCMakeAction = new QAction(QIcon(), tr("Run CMake"), this); Core::Command *command = am->registerAction(m_runCMakeAction, Constants::RUNCMAKE, projectContext); command->setAttribute(Core::Command::CA_Hide); mbuild->addAction(command, ProjectExplorer::Constants::G_BUILD_PROJECT); connect(m_runCMakeAction, SIGNAL(triggered()), this, SLOT(runCMake())); m_runCMakeActionContextMenu = new QAction(QIcon(), tr("Run CMake"), this); command = am->registerAction(m_runCMakeActionContextMenu, Constants::RUNCMAKECONTEXTMENU, projectContext); command->setAttribute(Core::Command::CA_Hide); mproject->addAction(command, ProjectExplorer::Constants::G_PROJECT_BUILD); msubproject->addAction(command, ProjectExplorer::Constants::G_PROJECT_BUILD); connect(m_runCMakeActionContextMenu, SIGNAL(triggered()), this, SLOT(runCMakeContextMenu())); }
void DoNothingPlugin::createMenuItems() { // Fetch the action manager Core::ActionManager* am = Core::ICore::instance()->actionManager(); // Create a command for "About DoNothing" Core::Command* cmd = am->registerAction(new QAction(this), "DoNothingPlugin.AboutDoNothingItem", QList<int>() << Core::Constants::C_GLOBAL_ID); cmd->action()->setText("About DoNothing"); // Add the command "Do Nothing" in the beginning of Help menu am->actionContainer(Core::Constants::M_HELP)->addAction(cmd); // Since menu-items are QActions, we can connect to their triggered(bool) or // toggled(bool) signal and respond to trigger/toggled events connect(cmd->action(), SIGNAL(triggered(bool)), this, SLOT(about())); // Create a command for "About DoNothing 2" Core::Command* cmd2 = am->registerAction(new QAction(this), "DoNothingPlugin.AboutDoNothing2Item", QList<int>() << Core::Constants::C_GLOBAL_ID); cmd2->action()->setText("About DoNothing 2"); // Insert the "DoNothing 2" item before "About Plugins..." QMenu* helpMenu = am->actionContainer(Core::Constants::M_HELP)->menu(); QAction* aboutPluginsAction = am->command(Core::Constants::ABOUT_PLUGINS)->action(); helpMenu->insertAction(aboutPluginsAction, cmd2->action()); // Connect the action connect(cmd2->action(), SIGNAL(triggered(bool)), this, SLOT(about())); }
void QtTestPlugin::extensionsInitialized() { ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); Core::ICore *core = Core::ICore::instance(); Core::ActionManager *am = core->actionManager(); m_messageOutputWindow = new TestOutputWindow(); pm->addObject(m_messageOutputWindow); m_testResultsWindow = TestResultsWindow::instance(); connect(m_testResultsWindow, SIGNAL(stopTest()), this, SLOT(stopTesting())); connect(m_testResultsWindow, SIGNAL(retryFailedTests(QStringList)), this, SLOT(retryTests(QStringList))); connect(TestExecuter::instance(), SIGNAL(testStarted()), m_testResultsWindow, SLOT(onTestStarted())); connect(TestExecuter::instance(), SIGNAL(testStop()), m_testResultsWindow, SLOT(onTestStopped())); connect(TestExecuter::instance(), SIGNAL(testFinished()), m_testResultsWindow, SLOT(onTestFinished())); pm->addObject(m_testResultsWindow); connect(testResultsPane(), SIGNAL(defectSelected(TestCaseRec)), this, SLOT(onDefectSelected(TestCaseRec))); // Add context menu to CPP editor Core::ActionContainer *mcontext = am->actionContainer(CppEditor::Constants::M_CONTEXT); m_contextMenu->init(mcontext->menu(), 2, this); // Add context menu to JS editor mcontext = am->actionContainer(QmlJSEditor::Constants::M_CONTEXT); m_contextMenu->init(mcontext->menu(), 2, this); // Add a Test menu to the menu bar Core::ActionContainer* ac = am->createMenu("QtTestPlugin.TestMenu"); ac->menu()->setTitle(tr("&Test")); m_contextMenu->init(ac->menu(), 0, 0); // Insert the "Test" menu between "Window" and "Help". QMenu *windowMenu = am->actionContainer(Core::Constants::M_TOOLS)->menu(); QMenuBar *menuBar = am->actionContainer(Core::Constants::MENU_BAR)->menuBar(); menuBar->insertMenu(windowMenu->menuAction(), ac->menu()); ProjectExplorer::ProjectExplorerPlugin *explorer = ProjectExplorer::ProjectExplorerPlugin::instance(); connect(explorer->session(), SIGNAL(startupProjectChanged(ProjectExplorer::Project*)), this, SLOT(onStartupProjectChanged(ProjectExplorer::Project *))); connect(core->progressManager(), SIGNAL(allTasksFinished(QString)), this, SLOT(onAllTasksFinished(QString))); connect(explorer->session(), SIGNAL(aboutToRemoveProject(ProjectExplorer::Project *)), this, SLOT(onProjectRemoved(ProjectExplorer::Project *))); m_contextMenu->init(0, 3, this); }
bool DoNothingPlugin::initialize(const QStringList& args, QString *errMsg) { Q_UNUSED(args); Q_UNUSED(errMsg); // Fetch the action manager Core::ActionManager* am = Core::ICore::instance()->actionManager(); // Create a DoNothing menu Core::ActionContainer* ac = am->createMenu("DoNothingPlugin.DoNothingMenu"); ac->menu()->setTitle("DoNothing"); // Create a command for "DoNothing". QAction *action = new QAction(tr("DoNothing"),this); Core::Command* cmd = am->registerAction(action, QLatin1String("DoNothingPlugin.DoNothing"), Core::Context(Core::Constants::C_GLOBAL)); // Add DoNothing menu to the menubar am->actionContainer(Core::Constants::M_TOOLS)->addMenu(ac, Core::Constants::G_DEFAULT_THREE); // Add the "DoNothing" action to the DoNothing menu ac->addAction(cmd); // Connect the action connect(action, SIGNAL(triggered(bool)), this, SLOT(performAction())); return true; }
bool ImportExportPlugin::initialize(const QStringList& args, QString *errMsg) { Q_UNUSED(args); Q_UNUSED(errMsg); // Add Menu entry Core::ActionManager* am = Core::ICore::instance()->actionManager(); Core::ActionContainer* ac = am->actionContainer(Core::Constants::M_FILE); Core::Command* cmd = am->registerAction(new QAction(this), "ImportExportPlugin.ImportExport", QList<int>() << Core::Constants::C_GLOBAL_ID); cmd->setDefaultKeySequence(QKeySequence("Ctrl+S")); cmd->action()->setText(tr("GCS Settings Import/Export...")); // ac->menu()->addSeparator(); // ac->appendGroup("ImportExport"); // ac->addAction(cmd, "ImportExport"); ac->addAction(cmd, Core::Constants::G_FILE_SAVE); connect(cmd->action(), SIGNAL(triggered(bool)), this, SLOT(importExport())); return true; }
void FindPlugin::setupMenu() { Core::ActionManager *am = Core::ICore::instance()->actionManager(); Core::ActionContainer *medit = am->actionContainer(Core::Constants::M_EDIT); Core::ActionContainer *mfind = am->createMenu(Constants::M_FIND); medit->addMenu(mfind, Core::Constants::G_EDIT_FIND); mfind->menu()->setTitle(tr("&Find/Replace")); mfind->appendGroup(Constants::G_FIND_CURRENTDOCUMENT); mfind->appendGroup(Constants::G_FIND_FILTERS); mfind->appendGroup(Constants::G_FIND_FLAGS); mfind->appendGroup(Constants::G_FIND_ACTIONS); Core::Context globalcontext(Core::Constants::C_GLOBAL); Core::Command *cmd; QAction *separator; separator = new QAction(this); separator->setSeparator(true); cmd = am->registerAction(separator, "Find.Sep.Flags", globalcontext); mfind->addAction(cmd, Constants::G_FIND_FLAGS); separator = new QAction(this); separator->setSeparator(true); cmd = am->registerAction(separator, "Find.Sep.Actions", globalcontext); mfind->addAction(cmd, Constants::G_FIND_ACTIONS); Core::ActionContainer *mfindadvanced = am->createMenu(Constants::M_FIND_ADVANCED); mfindadvanced->menu()->setTitle(tr("Advanced Find")); mfind->addMenu(mfindadvanced, Constants::G_FIND_FILTERS); d->m_openFindDialog = new QAction(tr("Open Advanced Find..."), this); d->m_openFindDialog->setIconText(tr("Advanced...")); cmd = am->registerAction(d->m_openFindDialog, Constants::ADVANCED_FIND, globalcontext); cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+F"))); mfindadvanced->addAction(cmd); connect(d->m_openFindDialog, SIGNAL(triggered()), this, SLOT(openFindFilter())); }
/** * Add Logging plugin to File menu */ bool LoggingPlugin::initialize(const QStringList& args, QString *errMsg) { Q_UNUSED(args); Q_UNUSED(errMsg); loggingThread = NULL; // Add Menu entry Core::ActionManager* am = Core::ICore::instance()->actionManager(); Core::ActionContainer* ac = am->actionContainer(Core::Constants::M_TOOLS); // Command to start logging Core::Command* cmd = am->registerAction(new QAction(this), "LoggingPlugin.Logging", QList<int>() << Core::Constants::C_GLOBAL_ID); cmd->setDefaultKeySequence(QKeySequence("Ctrl+L")); cmd->action()->setText("Start logging..."); ac->menu()->addSeparator(); ac->appendGroup("Logging"); ac->addAction(cmd, "Logging"); connect(cmd->action(), SIGNAL(triggered(bool)), this, SLOT(toggleLogging())); mf = new LoggingGadgetFactory(this); addAutoReleasedObject(mf); // Map signal from end of replay to replay stopped connect(getLogfile(),SIGNAL(replayFinished()), this, SLOT(replayStopped())); return true; }
void FindPlugin::setupFilterMenuItems() { Core::ActionManager *am = Core::ICore::instance()->actionManager(); QList<IFindFilter*> findInterfaces = ExtensionSystem::PluginManager::instance()->getObjects<IFindFilter>(); Core::Command *cmd; Core::Context globalcontext(Core::Constants::C_GLOBAL); Core::ActionContainer *mfindadvanced = am->actionContainer(Constants::M_FIND_ADVANCED); d->m_filterActions.clear(); bool haveEnabledFilters = false; foreach (IFindFilter *filter, findInterfaces) { QAction *action = new QAction(QLatin1String(" ") + filter->displayName(), this); bool isEnabled = filter->isEnabled(); if (isEnabled) haveEnabledFilters = true; action->setEnabled(isEnabled); action->setData(qVariantFromValue(filter)); cmd = am->registerAction(action, Core::Id(QLatin1String("FindFilter.")+filter->id()), globalcontext); cmd->setDefaultKeySequence(filter->defaultShortcut()); mfindadvanced->addAction(cmd); d->m_filterActions.insert(filter, action); connect(action, SIGNAL(triggered(bool)), this, SLOT(openFindFilter())); connect(filter, SIGNAL(changed()), this, SLOT(filterChanged())); }
ActionManager::ActionManager(QObject *parent) : QObject(parent), runAction(new QAction(QIcon(":/icons/images/run.png"), tr("Run tests"), this)), waitAction(new QAction(QIcon(":/icons/images/stop.png"), tr("Stop coverage execution"), this)), renderAction(new QAction(QIcon(":/icons/images/render.png"), tr("Show code coverage"), this)) { renderAction->setCheckable(true); // Add action to menu Core::ActionManager *pluginActionManager = Core::ICore::actionManager(); Core::Command *runCommand = pluginActionManager->registerAction(runAction, RUN_ACTION_ID, Core::Context(Core::Constants::C_GLOBAL)); Core::Command *renderCommand = pluginActionManager->registerAction(renderAction, RENDER_ACTION_ID, Core::Context(Core::Constants::C_GLOBAL)); runCommand->setKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_E); renderCommand->setKeySequence(Qt::CTRL + Qt::Key_H); Core::ActionContainer *menu = pluginActionManager->createMenu(MENU_ID); menu->menu()->setTitle(tr("CodeCoverage")); menu->addAction(runCommand); menu->addAction(renderCommand); pluginActionManager->actionContainer(Core::Constants::M_TOOLS)->addMenu(menu); // Add action as icon to left bar Core::ModeManager *modeManager = Core::ModeManager::instance(); modeManager->addAction(runAction, RUN_ACTION_PRIORITY); modeManager->addAction(waitAction, WAIT_ACTION_PRIORITY); }
bool CppToolsPlugin::initialize(const QStringList &arguments, QString *error) { Q_UNUSED(arguments) Q_UNUSED(error) qRegisterMetaType<CppTools::CppCodeStyleSettings>("CppTools::CppCodeStyleSettings"); Core::ICore *core = Core::ICore::instance(); Core::ActionManager *am = core->actionManager(); m_settings = new CppToolsSettings(this); // force registration of cpp tools settings // Objects m_modelManager = new CppModelManager(this); Core::VcsManager *vcsManager = core->vcsManager(); Core::FileManager *fileManager = core->fileManager(); connect(vcsManager, SIGNAL(repositoryChanged(QString)), m_modelManager, SLOT(updateModifiedSourceFiles())); connect(fileManager, SIGNAL(filesChangedInternally(QStringList)), m_modelManager, SLOT(updateSourceFiles(QStringList))); addAutoReleasedObject(m_modelManager); addAutoReleasedObject(new CppCompletionAssistProvider); addAutoReleasedObject(new CppLocatorFilter(m_modelManager)); addAutoReleasedObject(new CppClassesFilter(m_modelManager)); addAutoReleasedObject(new CppFunctionsFilter(m_modelManager)); addAutoReleasedObject(new CppCurrentDocumentFilter(m_modelManager, core->editorManager())); addAutoReleasedObject(new CompletionSettingsPage); addAutoReleasedObject(new CppFileSettingsPage(m_fileSettings)); addAutoReleasedObject(new SymbolsFindFilter(m_modelManager)); addAutoReleasedObject(new CppCodeStyleSettingsPage); TextEditor::CodeStylePreferencesManager::instance()->registerFactory( new CppTools::CppCodeStylePreferencesFactory()); // Menus Core::ActionContainer *mtools = am->actionContainer(Core::Constants::M_TOOLS); Core::ActionContainer *mcpptools = am->createMenu(CppTools::Constants::M_TOOLS_CPP); QMenu *menu = mcpptools->menu(); menu->setTitle(tr("&C++")); menu->setEnabled(true); mtools->addMenu(mcpptools); // Actions Core::Context context(CppEditor::Constants::C_CPPEDITOR); QAction *switchAction = new QAction(tr("Switch Header/Source"), this); Core::Command *command = am->registerAction(switchAction, Constants::SWITCH_HEADER_SOURCE, context, true); command->setDefaultKeySequence(QKeySequence(Qt::Key_F4)); mcpptools->addAction(command); connect(switchAction, SIGNAL(triggered()), this, SLOT(switchHeaderSource())); return true; }
void DoNothingPlugin::createMenus() { // Fetch the action manager Core::ActionManager* am = Core::ICore::instance()->actionManager(); // Create a DoNothing menu Core::ActionContainer* ac = am->createMenu("DoNothingPlugin.DoNothingMenu"); ac->menu()->setTitle(tr("DoNothing")); // Create a command for "About DoNothing". Core::Command* cmd = am->registerAction(new QAction(this), "DoNothingPlugin.AboutDoNothing", QList<int>() << 0); cmd->action()->setText("About DoNothing"); // Add DoNothing menu to the beginning of the menu bar am->actionContainer(Core::Constants::MENU_BAR)->addMenu(ac); // Add the "About DoNothing" action to the DoNothing menu ac->addAction(cmd); // Connect the action connect(cmd->action(), SIGNAL(triggered(bool)), this, SLOT(about())); // Create a DoNothing2 menu Core::ActionContainer* ac2 = am->createMenu("DoNothingPlugin.DoNothing2Menu"); ac2->menu()->setTitle(tr("DoNothing2")); // Create a command for "About DoNothing 2". Core::Command* cmd2 = am->registerAction(new QAction(this), "DoNothingPlugin.AboutDoNothing2", QList<int>() << 0); cmd2->action()->setText("About DoNothing 2"); // Insert the "DoNothing" menu between "Window" and "Help". QMenu* helpMenu = am->actionContainer(Core::Constants::M_HELP)->menu(); QMenuBar* menuBar = am->actionContainer(Core::Constants::MENU_BAR)->menuBar(); menuBar->insertMenu(helpMenu->menuAction(), ac2->menu()); // Add the "About DoNothing 2" action to the DoNothing2 menu ac2->addAction(cmd2); // Connect the action connect(cmd2->action(), SIGNAL(triggered(bool)), this, SLOT(about())); }
void ProFileEditorWidget::contextMenuEvent(QContextMenuEvent *e) { QMenu *menu = new QMenu(); Core::ActionManager *am = Core::ICore::actionManager(); Core::ActionContainer *mcontext = am->actionContainer(Qt4ProjectManager::Constants::M_CONTEXT); QMenu *contextMenu = mcontext->menu(); foreach (QAction *action, contextMenu->actions()) menu->addAction(action); appendStandardContextMenuActions(menu); menu->exec(e->globalPos()); delete menu; }
bool DoNothingPlugin::initialize(const QStringList &args, QString *errorMessage) { Q_UNUSED(args); Q_UNUSED(errorMessage); // Fetch the action manager Core::ActionManager *am = Core::ICore::instance()->actionManager(); // Create a command for "DoNothing". QAction *action = new QAction(tr("DoNothing"),this); Core::Command *cmd = am->registerAction(action, "DoNothingPlugin.DoNothing", Core::Context(Core::Constants::C_GLOBAL)); // Add the "DoNothing" action to the tools menu am->actionContainer(Core::Constants::M_TOOLS)->addAction(cmd, Core::Constants::G_DEFAULT_THREE); return true; }
/*! Initializes the plugin. Returns true on success. Plugins want to register objects with the plugin manager here. \a errorMessage can be used to pass an error message to the plugin system, if there was any. */ bool HelloWorldPlugin::initialize(const QStringList &arguments, QString *errorMessage) { Q_UNUSED(arguments) Q_UNUSED(errorMessage) // Get the primary access point to the workbench. Core::ICore *core = Core::ICore::instance(); // Create a unique context for our own view, that will be used for the // menu entry later. Core::Context context("HelloWorld.MainView"); // Create an action to be triggered by a menu entry QAction *helloWorldAction = new QAction(tr("Say \"&Hello World!\""), this); connect(helloWorldAction, SIGNAL(triggered()), SLOT(sayHelloWorld())); // Register the action with the action manager Core::ActionManager *actionManager = core->actionManager(); Core::Command *command = actionManager->registerAction( helloWorldAction, "HelloWorld.HelloWorldAction", context); // Create our own menu to place in the Tools menu Core::ActionContainer *helloWorldMenu = actionManager->createMenu("HelloWorld.HelloWorldMenu"); QMenu *menu = helloWorldMenu->menu(); menu->setTitle(tr("&Hello World")); menu->setEnabled(true); // Add the Hello World action command to the menu helloWorldMenu->addAction(command); // Request the Tools menu and add the Hello World menu to it Core::ActionContainer *toolsMenu = actionManager->actionContainer(Core::Constants::M_TOOLS); toolsMenu->addMenu(helloWorldMenu); // Add a mode with a push button based on BaseMode. Like the BaseView, // it will unregister itself from the plugin manager when it is deleted. Core::IMode *helloMode = new HelloMode; addAutoReleasedObject(helloMode); return true; }
/** * Add KmlExport option to the tools menu */ bool KmlExportPlugin::initialize(const QStringList& args, QString *errMsg) { Q_UNUSED(args); Q_UNUSED(errMsg); // Add Menu entry Core::ActionManager* am = Core::ICore::instance()->actionManager(); Core::ActionContainer* ac = am->actionContainer(Core::Constants::M_TOOLS); // Command to convert log file to KML exportToKmlCmd = am->registerAction(new QAction(this), "KmlExport.ExportToKML", QList<int>() << Core::Constants::C_GLOBAL_ID); exportToKmlCmd->action()->setText("Export logfile to KML"); ac->menu()->addSeparator(); ac->appendGroup("KML Export"); ac->addAction(exportToKmlCmd, "KML Export"); connect(exportToKmlCmd->action(), SIGNAL(triggered(bool)), this, SLOT(exportToKML())); return true; }
Core::IUAVGadget* ConfigGadgetFactory::createGadget(QWidget *parent) { gadgetWidget = new ConfigGadgetWidget(parent); // Add Menu entry Core::ActionManager* am = Core::ICore::instance()->actionManager(); Core::ActionContainer* ac = am->actionContainer(Core::Constants::M_TOOLS); Core::Command* cmd = am->registerAction(new QAction(this), "ConfigPlugin.ShowInputWizard", QList<int>() << Core::Constants::C_GLOBAL_ID); cmd->action()->setText(tr("Radio Setup Wizard")); Core::ModeManager::instance()->addAction(cmd, 1); ac->appendGroup("Wizard"); ac->addAction(cmd, "Wizard"); connect(cmd->action(), SIGNAL(triggered(bool)), this, SLOT(startInputWizard())); return new ConfigGadget(QString("ConfigGadget"), gadgetWidget, parent); }
bool ConfigPlugin::initialize(const QStringList& args, QString *errMsg) { Q_UNUSED(args); Q_UNUSED(errMsg); cf = new ConfigGadgetFactory(this); addAutoReleasedObject(cf); // Add Menu entry to erase all settings Core::ActionManager* am = Core::ICore::instance()->actionManager(); Core::ActionContainer* ac = am->actionContainer(Core::Constants::M_TOOLS); // Command to erase all settings from the board cmd = am->registerAction(new QAction(this), "ConfigPlugin.EraseAll", QList<int>() << Core::Constants::C_GLOBAL_ID); cmd->action()->setText(tr("Erase all settings from board...")); ac->menu()->addSeparator(); ac->appendGroup("Utilities"); ac->addAction(cmd, "Utilities"); connect(cmd->action(), SIGNAL(triggered(bool)), this, SLOT(eraseAllSettings())); // ********************* // Listen to autopilot connection events ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); TelemetryManager* telMngr = pm->getObject<TelemetryManager>(); connect(telMngr, SIGNAL(connected()), this, SLOT(onAutopilotConnect())); connect(telMngr, SIGNAL(disconnected()), this, SLOT(onAutopilotDisconnect())); // And check whether by any chance we are not already connected if (telMngr->isConnected()) onAutopilotConnect(); return true; }
bool RfmBindWizardPlugin::initialize(const QStringList & args, QString *errMsg) { Q_UNUSED(args); Q_UNUSED(errMsg); // Add Menu entry Core::ActionManager *am = Core::ICore::instance()->actionManager(); Core::ActionContainer *ac = am->actionContainer(Core::Constants::M_TOOLS); Core::Command *cmd = am->registerAction(new QAction(this), "RfmBindWizardPlugin.ShowBindWizard", QList<int>() << Core::Constants::C_GLOBAL_ID); cmd->action()->setText(tr("Rfm Bind Wizard")); Core::ModeManager::instance()->addAction(cmd, 1); ac->menu()->addSeparator(); ac->appendGroup("Bind Wizard"); ac->addAction(cmd, "Bind Wizard"); connect(cmd->action(), SIGNAL(triggered(bool)), this, SLOT(showBindWizard())); return true; }
void FormEditorW::setupActions() { Core::ActionManager *am = Core::ICore::actionManager(); Core::Command *command; //menus Core::ActionContainer *medit = am->actionContainer(Core::Constants::M_EDIT); Core::ActionContainer *mtools = am->actionContainer(Core::Constants::M_TOOLS); Core::ActionContainer *mformtools = am->createMenu(M_FORMEDITOR); mformtools->menu()->setTitle(tr("For&m Editor")); mtools->addMenu(mformtools); //overridden actions bindShortcut(am->registerAction(m_fwm->actionUndo(), Core::Constants::UNDO, m_contexts), m_fwm->actionUndo()); bindShortcut(am->registerAction(m_fwm->actionRedo(), Core::Constants::REDO, m_contexts), m_fwm->actionRedo()); bindShortcut(am->registerAction(m_fwm->actionCut(), Core::Constants::CUT, m_contexts), m_fwm->actionCut()); bindShortcut(am->registerAction(m_fwm->actionCopy(), Core::Constants::COPY, m_contexts), m_fwm->actionCopy()); bindShortcut(am->registerAction(m_fwm->actionPaste(), Core::Constants::PASTE, m_contexts), m_fwm->actionPaste()); bindShortcut(am->registerAction(m_fwm->actionSelectAll(), Core::Constants::SELECTALL, m_contexts), m_fwm->actionSelectAll()); m_actionPrint = new QAction(this); bindShortcut(am->registerAction(m_actionPrint, Core::Constants::PRINT, m_contexts), m_actionPrint); connect(m_actionPrint, SIGNAL(triggered()), this, SLOT(print())); //'delete' action. Do not set a shortcut as Designer handles // the 'Delete' key by event filter. Setting a shortcut triggers // buggy behaviour on Mac (Pressing Delete in QLineEdit removing the widget). command = am->registerAction(m_fwm->actionDelete(), Core::Id("FormEditor.Edit.Delete"), m_contexts); bindShortcut(command, m_fwm->actionDelete()); command->setAttribute(Core::Command::CA_Hide); medit->addAction(command, Core::Constants::G_EDIT_COPYPASTE); m_actionGroupEditMode = new QActionGroup(this); m_actionGroupEditMode->setExclusive(true); connect(m_actionGroupEditMode, SIGNAL(triggered(QAction*)), this, SLOT(activateEditMode(QAction*))); m_modeActionSeparator = new QAction(this); m_modeActionSeparator->setSeparator(true); command = am->registerAction(m_modeActionSeparator, Core::Id("FormEditor.Sep.ModeActions"), m_contexts); medit->addAction(command, Core::Constants::G_EDIT_OTHER); m_toolActionIds.push_back(Core::Id("FormEditor.WidgetEditor")); createEditModeAction(m_actionGroupEditMode, m_contexts, am, medit, tr("Edit Widgets"), m_toolActionIds.back(), EditModeWidgetEditor, QLatin1String("widgettool.png"), tr("F3")); m_toolActionIds.push_back(Core::Id("FormEditor.SignalsSlotsEditor")); createEditModeAction(m_actionGroupEditMode, m_contexts, am, medit, tr("Edit Signals/Slots"), m_toolActionIds.back(), EditModeSignalsSlotEditor, QLatin1String("signalslottool.png"), tr("F4")); m_toolActionIds.push_back(Core::Id("FormEditor.BuddyEditor")); createEditModeAction(m_actionGroupEditMode, m_contexts, am, medit, tr("Edit Buddies"), m_toolActionIds.back(), EditModeBuddyEditor, QLatin1String("buddytool.png")); m_toolActionIds.push_back(Core::Id("FormEditor.TabOrderEditor")); createEditModeAction(m_actionGroupEditMode, m_contexts, am, medit, tr("Edit Tab Order"), m_toolActionIds.back(), EditModeTabOrderEditor, QLatin1String("tabordertool.png")); //tool actions m_toolActionIds.push_back(Core::Id("FormEditor.LayoutHorizontally")); const QString horizLayoutShortcut = osMac ? tr("Meta+H") : tr("Ctrl+H"); addToolAction(m_fwm->actionHorizontalLayout(), am, m_contexts, m_toolActionIds.back(), mformtools, horizLayoutShortcut); m_toolActionIds.push_back(Core::Id("FormEditor.LayoutVertically")); const QString vertLayoutShortcut = osMac ? tr("Meta+L") : tr("Ctrl+L"); addToolAction(m_fwm->actionVerticalLayout(), am, m_contexts, m_toolActionIds.back(), mformtools, vertLayoutShortcut); m_toolActionIds.push_back(Core::Id("FormEditor.SplitHorizontal")); addToolAction(m_fwm->actionSplitHorizontal(), am, m_contexts, m_toolActionIds.back(), mformtools); m_toolActionIds.push_back(Core::Id("FormEditor.SplitVertical")); addToolAction(m_fwm->actionSplitVertical(), am, m_contexts, m_toolActionIds.back(), mformtools); m_toolActionIds.push_back(Core::Id("FormEditor.LayoutForm")); addToolAction(m_fwm->actionFormLayout(), am, m_contexts, m_toolActionIds.back(), mformtools); m_toolActionIds.push_back(Core::Id("FormEditor.LayoutGrid")); const QString gridShortcut = osMac ? tr("Meta+G") : tr("Ctrl+G"); addToolAction(m_fwm->actionGridLayout(), am, m_contexts, m_toolActionIds.back(), mformtools, gridShortcut); m_toolActionIds.push_back(Core::Id("FormEditor.LayoutBreak")); addToolAction(m_fwm->actionBreakLayout(), am, m_contexts, m_toolActionIds.back(), mformtools); m_toolActionIds.push_back(Core::Id("FormEditor.LayoutAdjustSize")); const QString adjustShortcut = osMac ? tr("Meta+J") : tr("Ctrl+J"); addToolAction(m_fwm->actionAdjustSize(), am, m_contexts, m_toolActionIds.back(), mformtools, adjustShortcut); m_toolActionIds.push_back(Core::Id("FormEditor.SimplifyLayout")); addToolAction(m_fwm->actionSimplifyLayout(), am, m_contexts, m_toolActionIds.back(), mformtools); createSeparator(this, am, m_contexts, mformtools, Core::Id("FormEditor.Menu.Tools.Separator1")); addToolAction(m_fwm->actionLower(), am, m_contexts, Core::Id("FormEditor.Lower"), mformtools); addToolAction(m_fwm->actionRaise(), am, m_contexts, Core::Id("FormEditor.Raise"), mformtools); // Commands that do not go into the editor toolbar createSeparator(this, am, m_contexts, mformtools, Core::Id("FormEditor.Menu.Tools.Separator2")); #if QT_VERSION >= 0x050000 m_actionPreview = m_fwm->action(QDesignerFormWindowManagerInterface::DefaultPreviewAction); #else m_actionPreview = m_fwm->actionDefaultPreview(); #endif QTC_ASSERT(m_actionPreview, return); addToolAction(m_actionPreview, am, m_contexts, Core::Id("FormEditor.Preview"), mformtools, tr("Alt+Shift+R")); // Preview in style... #if QT_VERSION >= 0x050000 m_actionGroupPreviewInStyle = m_fwm->actionGroup(QDesignerFormWindowManagerInterface::StyledPreviewActionGroup); #else m_actionGroupPreviewInStyle = m_fwm->actionGroupPreviewInStyle(); #endif Core::ActionContainer *previewAC = createPreviewStyleMenu(am, m_actionGroupPreviewInStyle); m_previewInStyleMenu = previewAC->menu(); mformtools->addMenu(previewAC); setPreviewMenuEnabled(false); // Form settings createSeparator(this, am, m_contexts, medit, Core::Id("FormEditor.Edit.Separator2"), Core::Constants::G_EDIT_OTHER); createSeparator(this, am, m_contexts, mformtools, Core::Id("FormEditor.Menu.Tools.Separator3")); m_actionSwitchSource = new QAction(tr("Switch Source/Form"), this); connect(m_actionSwitchSource, SIGNAL(triggered()), this, SLOT(switchSourceForm())); // Switch form/source in editor/design contexts. Core::Context switchContexts = m_contexts; switchContexts.add(Core::Constants::C_EDITORMANAGER); addToolAction(m_actionSwitchSource, am, switchContexts, Core::Id("FormEditor.FormSwitchSource"), mformtools, tr("Shift+F4")); createSeparator(this, am, m_contexts, mformtools, Core::Id("FormEditor.Menu.Tools.Separator4")); #if QT_VERSION >= 0x050000 QAction *actionFormSettings = m_fwm->action(QDesignerFormWindowManagerInterface::FormWindowSettingsDialogAction); #else QAction *actionFormSettings = m_fwm->actionShowFormWindowSettingsDialog(); #endif addToolAction(actionFormSettings, am, m_contexts, Core::Id("FormEditor.FormSettings"), mformtools); createSeparator(this, am, m_contexts, mformtools, Core::Id("FormEditor.Menu.Tools.Separator5")); m_actionAboutPlugins = new QAction(tr("About Qt Designer plugins...."), this); addToolAction(m_actionAboutPlugins, am, m_contexts, Core::Id("FormEditor.AboutPlugins"), mformtools); connect(m_actionAboutPlugins, SIGNAL(triggered()), m_fwm, #if QT_VERSION >= 0x050000 SLOT(showPluginDialog()) #else SLOT(aboutPlugins()) #endif ); m_actionAboutPlugins->setEnabled(false); // FWM connect(m_fwm, SIGNAL(activeFormWindowChanged(QDesignerFormWindowInterface*)), this, SLOT(activeFormWindowChanged(QDesignerFormWindowInterface*))); }
bool CodepasterPlugin::initialize(const QStringList &arguments, QString *error_message) { Q_UNUSED(arguments) Q_UNUSED(error_message) // Create the globalcontext list to register actions accordingly Core::Context globalcontext(Core::Constants::C_GLOBAL); // Create the settings Page m_settings->fromSettings(Core::ICore::instance()->settings()); SettingsPage *settingsPage = new SettingsPage(m_settings); addAutoReleasedObject(settingsPage); // Create the protocols and append them to the Settings const QSharedPointer<NetworkAccessManagerProxy> networkAccessMgrProxy(new NetworkAccessManagerProxy); Protocol *protos[] = { new PasteBinDotComProtocol(networkAccessMgrProxy), new PasteBinDotCaProtocol(networkAccessMgrProxy), new CodePasterProtocol(networkAccessMgrProxy), new FileShareProtocol }; const int count = sizeof(protos) / sizeof(Protocol *); for(int i = 0; i < count; ++i) { connect(protos[i], SIGNAL(pasteDone(QString)), this, SLOT(finishPost(QString))); connect(protos[i], SIGNAL(fetchDone(QString,QString,bool)), this, SLOT(finishFetch(QString,QString,bool))); settingsPage->addProtocol(protos[i]->name()); if (protos[i]->hasSettings()) addAutoReleasedObject(protos[i]->settingsPage()); m_protocols.append(protos[i]); } //register actions Core::ActionManager *actionManager = ICore::instance()->actionManager(); Core::ActionContainer *toolsContainer = actionManager->actionContainer(Core::Constants::M_TOOLS); Core::ActionContainer *cpContainer = actionManager->createMenu(Core::Id("CodePaster")); cpContainer->menu()->setTitle(tr("&Code Pasting")); toolsContainer->addMenu(cpContainer); Core::Command *command; m_postEditorAction = new QAction(tr("Paste Snippet..."), this); command = actionManager->registerAction(m_postEditorAction, "CodePaster.Post", globalcontext); command->setDefaultKeySequence(QKeySequence(tr("Alt+C,Alt+P"))); connect(m_postEditorAction, SIGNAL(triggered()), this, SLOT(postEditor())); cpContainer->addAction(command); m_postClipboardAction = new QAction(tr("Paste Clipboard..."), this); command = actionManager->registerAction(m_postClipboardAction, "CodePaster.PostClipboard", globalcontext); connect(m_postClipboardAction, SIGNAL(triggered()), this, SLOT(postClipboard())); cpContainer->addAction(command); m_fetchAction = new QAction(tr("Fetch Snippet..."), this); command = actionManager->registerAction(m_fetchAction, "CodePaster.Fetch", globalcontext); command->setDefaultKeySequence(QKeySequence(tr("Alt+C,Alt+F"))); connect(m_fetchAction, SIGNAL(triggered()), this, SLOT(fetch())); cpContainer->addAction(command); connect(Core::EditorManager::instance(), SIGNAL(currentEditorChanged(Core::IEditor*)), this, SLOT(updateActions())); updateActions(); return true; }
bool GLSLEditorPlugin::initialize(const QStringList & /*arguments*/, QString *error_message) { Core::ICore *core = Core::ICore::instance(); if (!core->mimeDatabase()->addMimeTypes(QLatin1String(":/glsleditor/GLSLEditor.mimetypes.xml"), error_message)) return false; parseGlslFile(QLatin1String("glsl_120.frag"), &m_glsl_120_frag); parseGlslFile(QLatin1String("glsl_120.vert"), &m_glsl_120_vert); parseGlslFile(QLatin1String("glsl_120_common.glsl"), &m_glsl_120_common); parseGlslFile(QLatin1String("glsl_es_100.frag"), &m_glsl_es_100_frag); parseGlslFile(QLatin1String("glsl_es_100.vert"), &m_glsl_es_100_vert); parseGlslFile(QLatin1String("glsl_es_100_common.glsl"), &m_glsl_es_100_common); // m_modelManager = new ModelManager(this); // addAutoReleasedObject(m_modelManager); addAutoReleasedObject(new GLSLHoverHandler(this)); Core::Context context(GLSLEditor::Constants::C_GLSLEDITOR_ID); m_editor = new GLSLEditorFactory(this); addObject(m_editor); addAutoReleasedObject(new GLSLCompletionAssistProvider); m_actionHandler = new TextEditor::TextEditorActionHandler(GLSLEditor::Constants::C_GLSLEDITOR_ID, TextEditor::TextEditorActionHandler::Format | TextEditor::TextEditorActionHandler::UnCommentSelection | TextEditor::TextEditorActionHandler::UnCollapseAll); m_actionHandler->initializeActions(); Core::ActionManager *am = core->actionManager(); Core::ActionContainer *contextMenu = am->createMenu(GLSLEditor::Constants::M_CONTEXT); Core::ActionContainer *glslToolsMenu = am->createMenu(Core::Id(Constants::M_TOOLS_GLSL)); glslToolsMenu->setOnAllDisabledBehavior(Core::ActionContainer::Hide); QMenu *menu = glslToolsMenu->menu(); //: GLSL sub-menu in the Tools menu menu->setTitle(tr("GLSL")); am->actionContainer(Core::Constants::M_TOOLS)->addMenu(glslToolsMenu); Core::Command *cmd = 0; // Insert marker for "Refactoring" menu: Core::Context globalContext(Core::Constants::C_GLOBAL); Core::Command *sep = createSeparator(am, this, globalContext, Constants::SEPARATOR1); sep->action()->setObjectName(Constants::M_REFACTORING_MENU_INSERTION_POINT); contextMenu->addAction(sep); contextMenu->addAction(createSeparator(am, this, globalContext, Constants::SEPARATOR2)); cmd = am->command(TextEditor::Constants::UN_COMMENT_SELECTION); contextMenu->addAction(cmd); error_message->clear(); Core::FileIconProvider *iconProvider = Core::FileIconProvider::instance(); Core::MimeDatabase *mimeDatabase = Core::ICore::instance()->mimeDatabase(); iconProvider->registerIconOverlayForMimeType(QIcon(QLatin1String(":/glsleditor/images/glslfile.png")), mimeDatabase->findByType(QLatin1String(GLSLEditor::Constants::GLSL_MIMETYPE))); iconProvider->registerIconOverlayForMimeType(QIcon(QLatin1String(":/glsleditor/images/glslfile.png")), mimeDatabase->findByType(QLatin1String(GLSLEditor::Constants::GLSL_MIMETYPE_VERT))); iconProvider->registerIconOverlayForMimeType(QIcon(QLatin1String(":/glsleditor/images/glslfile.png")), mimeDatabase->findByType(QLatin1String(GLSLEditor::Constants::GLSL_MIMETYPE_FRAG))); iconProvider->registerIconOverlayForMimeType(QIcon(QLatin1String(":/glsleditor/images/glslfile.png")), mimeDatabase->findByType(QLatin1String(GLSLEditor::Constants::GLSL_MIMETYPE_VERT_ES))); iconProvider->registerIconOverlayForMimeType(QIcon(QLatin1String(":/glsleditor/images/glslfile.png")), mimeDatabase->findByType(QLatin1String(GLSLEditor::Constants::GLSL_MIMETYPE_FRAG_ES))); Core::BaseFileWizardParameters fragWizardParameters(Core::IWizard::FileWizard); fragWizardParameters.setCategory(QLatin1String(Constants::WIZARD_CATEGORY_GLSL)); fragWizardParameters.setDisplayCategory(QCoreApplication::translate("GLSLEditor", Constants::WIZARD_TR_CATEGORY_GLSL)); fragWizardParameters.setDescription (tr("Creates a fragment shader in the OpenGL/ES 2.0 Shading " "Language (GLSL/ES). Fragment shaders generate the final " "pixel colors for triangles, points and lines rendered " "with OpenGL.")); fragWizardParameters.setDisplayName(tr("Fragment Shader (OpenGL/ES 2.0)")); fragWizardParameters.setId(QLatin1String("F.GLSL")); addAutoReleasedObject(new GLSLFileWizard(fragWizardParameters, GLSLFileWizard::FragmentShaderES, core)); Core::BaseFileWizardParameters vertWizardParameters(Core::IWizard::FileWizard); vertWizardParameters.setCategory(QLatin1String(Constants::WIZARD_CATEGORY_GLSL)); vertWizardParameters.setDisplayCategory(QCoreApplication::translate("GLSLEditor", Constants::WIZARD_TR_CATEGORY_GLSL)); vertWizardParameters.setDescription (tr("Creates a vertex shader in the OpenGL/ES 2.0 Shading " "Language (GLSL/ES). Vertex shaders transform the " "positions, normals and texture co-ordinates of " "triangles, points and lines rendered with OpenGL.")); vertWizardParameters.setDisplayName(tr("Vertex Shader (OpenGL/ES 2.0)")); vertWizardParameters.setId(QLatin1String("G.GLSL")); addAutoReleasedObject(new GLSLFileWizard(vertWizardParameters, GLSLFileWizard::VertexShaderES, core)); fragWizardParameters.setDescription (tr("Creates a fragment shader in the Desktop OpenGL Shading " "Language (GLSL). Fragment shaders generate the final " "pixel colors for triangles, points and lines rendered " "with OpenGL.")); fragWizardParameters.setDisplayName(tr("Fragment Shader (Desktop OpenGL)")); fragWizardParameters.setId(QLatin1String("J.GLSL")); addAutoReleasedObject(new GLSLFileWizard(fragWizardParameters, GLSLFileWizard::FragmentShaderDesktop, core)); vertWizardParameters.setDescription (tr("Creates a vertex shader in the Desktop OpenGL Shading " "Language (GLSL). Vertex shaders transform the " "positions, normals and texture co-ordinates of " "triangles, points and lines rendered with OpenGL.")); vertWizardParameters.setDisplayName(tr("Vertex Shader (Desktop OpenGL)")); vertWizardParameters.setId(QLatin1String("K.GLSL")); addAutoReleasedObject(new GLSLFileWizard(vertWizardParameters, GLSLFileWizard::VertexShaderDesktop, core)); return true; }
bool QmlJSEditorPlugin::initialize(const QStringList & /*arguments*/, QString *error_message) { Core::ICore *core = Core::ICore::instance(); if (!core->mimeDatabase()->addMimeTypes(QLatin1String(":/qmljseditor/QmlJSEditor.mimetypes.xml"), error_message)) return false; m_modelManager = new ModelManager(this); addAutoReleasedObject(m_modelManager); QList<int> context; context << core->uniqueIDManager()->uniqueIdentifier(QmlJSEditor::Constants::C_QMLJSEDITOR_ID) << core->uniqueIDManager()->uniqueIdentifier(QmlDesigner::Constants::C_QT_QUICK_TOOLS_MENU); m_editor = new QmlJSEditorFactory(this); addObject(m_editor); #ifdef QTCREATOR_WITH_QML Core::BaseFileWizardParameters wizardParameters(Core::IWizard::FileWizard); wizardParameters.setCategory(QLatin1String(Core::Constants::WIZARD_CATEGORY_QT)); wizardParameters.setDisplayCategory(QCoreApplication::translate("Core", Core::Constants::WIZARD_TR_CATEGORY_QT)); wizardParameters.setDescription(tr("Creates a Qt QML file.")); wizardParameters.setDisplayName(tr("Qt QML File")); wizardParameters.setId(QLatin1String("Q.Qml")); addAutoReleasedObject(new QmlFileWizard(wizardParameters, core)); #endif m_actionHandler = new TextEditor::TextEditorActionHandler(QmlJSEditor::Constants::C_QMLJSEDITOR_ID, TextEditor::TextEditorActionHandler::Format | TextEditor::TextEditorActionHandler::UnCommentSelection | TextEditor::TextEditorActionHandler::UnCollapseAll); m_actionHandler->initializeActions(); Core::ActionManager *am = core->actionManager(); Core::ActionContainer *contextMenu = am->createMenu(QmlJSEditor::Constants::M_CONTEXT); Core::ActionContainer *mtools = am->actionContainer(Core::Constants::M_TOOLS); Core::ActionContainer *menuQtQuick = am->createMenu(Constants::M_QTQUICK); menuQtQuick->menu()->setTitle(tr("Qt Quick")); mtools->addMenu(menuQtQuick); m_actionPreview = new QAction("&Preview", this); QList<int> toolsMenuContext = QList<int>() << core->uniqueIDManager()->uniqueIdentifier(QmlDesigner::Constants::C_QT_QUICK_TOOLS_MENU); Core::Command *cmd = addToolAction(m_actionPreview, am, toolsMenuContext, QLatin1String("QtQuick.Preview"), menuQtQuick, tr("Ctrl+Alt+R")); connect(cmd->action(), SIGNAL(triggered()), SLOT(openPreview())); m_previewRunner = new QmlJSPreviewRunner(this); QAction *followSymbolUnderCursorAction = new QAction(tr("Follow Symbol Under Cursor"), this); cmd = am->registerAction(followSymbolUnderCursorAction, Constants::FOLLOW_SYMBOL_UNDER_CURSOR, context); cmd->setDefaultKeySequence(QKeySequence(Qt::Key_F2)); connect(followSymbolUnderCursorAction, SIGNAL(triggered()), this, SLOT(followSymbolUnderCursor())); contextMenu->addAction(cmd); cmd = am->command(TextEditor::Constants::AUTO_INDENT_SELECTION); contextMenu->addAction(cmd); cmd = am->command(TextEditor::Constants::UN_COMMENT_SELECTION); contextMenu->addAction(cmd); CodeCompletion *completion = new CodeCompletion(m_modelManager); addAutoReleasedObject(completion); addAutoReleasedObject(new HoverHandler); // Set completion settings and keep them up to date TextEditor::TextEditorSettings *textEditorSettings = TextEditor::TextEditorSettings::instance(); completion->setCompletionSettings(textEditorSettings->completionSettings()); connect(textEditorSettings, SIGNAL(completionSettingsChanged(TextEditor::CompletionSettings)), completion, SLOT(setCompletionSettings(TextEditor::CompletionSettings))); error_message->clear(); Core::FileIconProvider *iconProvider = Core::FileIconProvider::instance(); iconProvider->registerIconOverlayForSuffix(QIcon(":/qmljseditor/images/qmlfile.png"), "qml"); return true; }
bool CppPlugin::initialize(const QStringList & /*arguments*/, QString *errorMessage) { Core::ICore *core = Core::ICore::instance(); if (!core->mimeDatabase()->addMimeTypes(QLatin1String(":/cppeditor/CppEditor.mimetypes.xml"), errorMessage)) return false; addAutoReleasedObject(new CppEditorFactory(this)); addAutoReleasedObject(new CppHoverHandler); addAutoReleasedObject(new CppOutlineWidgetFactory); addAutoReleasedObject(new CppTypeHierarchyFactory); addAutoReleasedObject(new CppSnippetProvider); m_quickFixCollector = new CppQuickFixCollector; addAutoReleasedObject(m_quickFixCollector); CppQuickFixCollector::registerQuickFixes(this); CppFileWizard::BaseFileWizardParameters wizardParameters(Core::IWizard::FileWizard); wizardParameters.setCategory(QLatin1String(Constants::WIZARD_CATEGORY)); wizardParameters.setDisplayCategory(QCoreApplication::translate(Constants::WIZARD_CATEGORY, Constants::WIZARD_TR_CATEGORY)); wizardParameters.setDisplayName(tr("C++ Class")); wizardParameters.setId(QLatin1String("A.Class")); wizardParameters.setKind(Core::IWizard::ClassWizard); wizardParameters.setDescription(tr("Creates a C++ header and a source file for a new class that you can add to a C++ project.")); addAutoReleasedObject(new CppClassWizard(wizardParameters, core)); wizardParameters.setKind(Core::IWizard::FileWizard); wizardParameters.setDescription(tr("Creates a C++ source file that you can add to a C++ project.")); wizardParameters.setDisplayName(tr("C++ Source File")); wizardParameters.setId(QLatin1String("B.Source")); addAutoReleasedObject(new CppFileWizard(wizardParameters, Source, core)); wizardParameters.setDescription(tr("Creates a C++ header file that you can add to a C++ project.")); wizardParameters.setDisplayName(tr("C++ Header File")); wizardParameters.setId(QLatin1String("C.Header")); addAutoReleasedObject(new CppFileWizard(wizardParameters, Header, core)); Core::Context context(CppEditor::Constants::C_CPPEDITOR); Core::ActionManager *am = core->actionManager(); Core::ActionContainer *contextMenu= am->createMenu(CppEditor::Constants::M_CONTEXT); Core::Command *cmd; Core::ActionContainer *cppToolsMenu = am->actionContainer(Core::Id(CppTools::Constants::M_TOOLS_CPP)); QAction *jumpToDefinition = new QAction(tr("Follow Symbol Under Cursor"), this); cmd = am->registerAction(jumpToDefinition, Constants::JUMP_TO_DEFINITION, context, true); cmd->setDefaultKeySequence(QKeySequence(Qt::Key_F2)); connect(jumpToDefinition, SIGNAL(triggered()), this, SLOT(jumpToDefinition())); contextMenu->addAction(cmd); cppToolsMenu->addAction(cmd); QAction *switchDeclarationDefinition = new QAction(tr("Switch Between Method Declaration/Definition"), this); cmd = am->registerAction(switchDeclarationDefinition, Constants::SWITCH_DECLARATION_DEFINITION, context, true); cmd->setDefaultKeySequence(QKeySequence("Shift+F2")); connect(switchDeclarationDefinition, SIGNAL(triggered()), this, SLOT(switchDeclarationDefinition())); contextMenu->addAction(cmd); cppToolsMenu->addAction(cmd); m_findUsagesAction = new QAction(tr("Find Usages"), this); cmd = am->registerAction(m_findUsagesAction, Constants::FIND_USAGES, context); cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+U"))); connect(m_findUsagesAction, SIGNAL(triggered()), this, SLOT(findUsages())); contextMenu->addAction(cmd); cppToolsMenu->addAction(cmd); m_openTypeHierarchyAction = new QAction(tr("Open Type Hierarchy"), this); cmd = am->registerAction(m_openTypeHierarchyAction, Constants::OPEN_TYPE_HIERARCHY, context); cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+T"))); connect(m_openTypeHierarchyAction, SIGNAL(triggered()), this, SLOT(openTypeHierarchy())); contextMenu->addAction(cmd); cppToolsMenu->addAction(cmd); // Refactoring sub-menu Core::Context globalContext(Core::Constants::C_GLOBAL); Core::Command *sep = createSeparator(am, this, globalContext, Constants::SEPARATOR2); sep->action()->setObjectName(Constants::M_REFACTORING_MENU_INSERTION_POINT); contextMenu->addAction(sep); contextMenu->addAction(createSeparator(am, this, globalContext, Constants::SEPARATOR3)); m_renameSymbolUnderCursorAction = new QAction(tr("Rename Symbol Under Cursor"), this); cmd = am->registerAction(m_renameSymbolUnderCursorAction, Constants::RENAME_SYMBOL_UNDER_CURSOR, context); cmd->setDefaultKeySequence(QKeySequence("CTRL+SHIFT+R")); connect(m_renameSymbolUnderCursorAction, SIGNAL(triggered()), this, SLOT(renameSymbolUnderCursor())); cppToolsMenu->addAction(cmd); // Update context in global context cppToolsMenu->addAction(createSeparator(am, this, globalContext, CppEditor::Constants::SEPARATOR4)); m_updateCodeModelAction = new QAction(tr("Update Code Model"), this); cmd = am->registerAction(m_updateCodeModelAction, Core::Id(Constants::UPDATE_CODEMODEL), globalContext); CPlusPlus::CppModelManagerInterface *cppModelManager = CPlusPlus::CppModelManagerInterface::instance(); connect(m_updateCodeModelAction, SIGNAL(triggered()), cppModelManager, SLOT(updateModifiedSourceFiles())); cppToolsMenu->addAction(cmd); m_actionHandler = new TextEditor::TextEditorActionHandler(CppEditor::Constants::C_CPPEDITOR, TextEditor::TextEditorActionHandler::Format | TextEditor::TextEditorActionHandler::UnCommentSelection | TextEditor::TextEditorActionHandler::UnCollapseAll); m_actionHandler->initializeActions(); contextMenu->addAction(createSeparator(am, this, context, CppEditor::Constants::SEPARATOR)); cmd = am->command(TextEditor::Constants::AUTO_INDENT_SELECTION); contextMenu->addAction(cmd); cmd = am->command(TextEditor::Constants::UN_COMMENT_SELECTION); contextMenu->addAction(cmd); connect(core->progressManager(), SIGNAL(taskStarted(QString)), this, SLOT(onTaskStarted(QString))); connect(core->progressManager(), SIGNAL(allTasksFinished(QString)), this, SLOT(onAllTasksFinished(QString))); connect(core->editorManager(), SIGNAL(currentEditorChanged(Core::IEditor*)), SLOT(currentEditorChanged(Core::IEditor*))); readSettings(); return true; }
QWidget *QmlProfilerTool::createWidgets() { // Analyzer::AnalyzerManager *analyzerMgr = Analyzer::AnalyzerManager::instance(); // Utils::FancyMainWindow *mw = analyzerMgr->mainWindow(); QWidget *mw = this; d->m_traceWindow = new TraceWindow(mw); d->m_traceWindow->reset(d->m_client); connect(d->m_traceWindow, SIGNAL(gotoSourceLocation(QString,int)),this, SLOT(gotoSourceLocation(QString,int))); connect(d->m_traceWindow, SIGNAL(timeChanged(qreal)), this, SLOT(updateTimer(qreal))); d->m_statistics = new QmlProfilerEventStatistics(mw); d->m_eventsView = new QmlProfilerEventsView(mw, d->m_statistics); d->m_eventsView->setViewType(QmlProfilerEventsView::EventsView); connect(d->m_traceWindow, SIGNAL(range(int,int,int,qint64,qint64,QStringList,QString,int)), d->m_statistics, SLOT(addRangedEvent(int,int,int,qint64,qint64,QStringList,QString,int))); connect(d->m_traceWindow, SIGNAL(viewUpdated()), d->m_statistics, SLOT(complete())); connect(d->m_eventsView, SIGNAL(gotoSourceLocation(QString,int)), this, SLOT(gotoSourceLocation(QString,int))); d->m_calleeView = new QmlProfilerEventsView(mw, d->m_statistics); d->m_calleeView->setViewType(QmlProfilerEventsView::CalleesView); connect(d->m_calleeView, SIGNAL(gotoSourceLocation(QString,int)), this, SLOT(gotoSourceLocation(QString,int))); d->m_callerView = new QmlProfilerEventsView(mw, d->m_statistics); d->m_callerView->setViewType(QmlProfilerEventsView::CallersView); connect(d->m_callerView, SIGNAL(gotoSourceLocation(QString,int)), this, SLOT(gotoSourceLocation(QString,int))); #if 0 Core::ICore *core = Core::ICore::instance(); Core::ActionManager *am = core->actionManager(); Core::ActionContainer *manalyzer = am->actionContainer(Analyzer::Constants::M_DEBUG_ANALYZER); const Core::Context globalcontext(Core::Constants::C_GLOBAL); d->m_attachAction = new QAction(tr("Attach..."), manalyzer); Core::Command *command = am->registerAction(d->m_attachAction, Constants::ATTACH, globalcontext); command->setAttribute(Core::Command::CA_UpdateText); //manalyzer->addAction(command, Analyzer::Constants::G_ANALYZER_STARTSTOP); connect(d->m_attachAction, SIGNAL(triggered()), this, SLOT(attach())); updateAttachAction(false); QDockWidget *eventsDock = AnalyzerManager::createDockWidget (this, tr("Events"), d->m_eventsView, Qt::BottomDockWidgetArea); QDockWidget *timelineDock = AnalyzerManager::createDockWidget (this, tr("Timeline"), d->m_traceWindow, Qt::BottomDockWidgetArea); QDockWidget *calleeDock = AnalyzerManager::createDockWidget (this, tr("Callees"), d->m_calleeView, Qt::BottomDockWidgetArea); QDockWidget *callerDock = AnalyzerManager::createDockWidget (this, tr("Callers"), d->m_callerView, Qt::BottomDockWidgetArea); mw->splitDockWidget(mw->toolBarDockWidget(), eventsDock, Qt::Vertical); mw->tabifyDockWidget(eventsDock, timelineDock); mw->tabifyDockWidget(timelineDock, calleeDock); mw->tabifyDockWidget(calleeDock, callerDock); #endif QTabWidget *tabWidget = new QTabWidget; tabWidget->addTab(d->m_eventsView, tr("Events")); tabWidget->addTab(d->m_traceWindow, tr("Timeline")); tabWidget->addTab(d->m_calleeView, tr("Callees")); tabWidget->addTab(d->m_callerView, tr("Callers")); // // Toolbar // QWidget *toolbarWidget = new QWidget; toolbarWidget->setObjectName(QLatin1String("QmlProfilerToolBarWidget")); QHBoxLayout *layout = new QHBoxLayout; layout->setMargin(0); layout->setSpacing(0); d->m_recordButton = new QToolButton(toolbarWidget); // icon and tooltip set in setRecording(), called later d->m_recordButton->setCheckable(true); connect(d->m_recordButton,SIGNAL(toggled(bool)), this, SLOT(setRecording(bool))); d->m_recordButton->setChecked(true); layout->addWidget(d->m_recordButton); d->m_clearButton = new QToolButton(toolbarWidget); d->m_clearButton->setIcon(QIcon(QLatin1String(":/qmlprofiler/clean_pane_small.png"))); d->m_clearButton->setToolTip(tr("Discard data")); connect(d->m_clearButton,SIGNAL(clicked()), this, SLOT(clearDisplay())); layout->addWidget(d->m_clearButton); QLabel *timeLabel = new QLabel(tr("Elapsed: 0 s")); QPalette palette = timeLabel->palette(); palette.setColor(QPalette::WindowText, Qt::white); timeLabel->setPalette(palette); timeLabel->setIndent(10); connect(this, SIGNAL(setTimeLabel(QString)), timeLabel, SLOT(setText(QString))); layout->addWidget(timeLabel); toolbarWidget->setLayout(layout); QVBoxLayout *mainLayout = new QVBoxLayout(this); mainLayout->addWidget(toolbarWidget); mainLayout->addWidget(tabWidget); return toolbarWidget; }
bool QmlJSEditorPlugin::initialize(const QStringList & /*arguments*/, QString *error_message) { Core::ICore *core = Core::ICore::instance(); if (!core->mimeDatabase()->addMimeTypes(QLatin1String(":/qmljseditor/QmlJSEditor.mimetypes.xml"), error_message)) return false; m_modelManager = QmlJS::ModelManagerInterface::instance(); addAutoReleasedObject(new QmlJSSnippetProvider); Core::Context context(QmlJSEditor::Constants::C_QMLJSEDITOR_ID); m_editor = new QmlJSEditorFactory(this); addObject(m_editor); Core::BaseFileWizardParameters qmlWizardParameters(Core::IWizard::FileWizard); qmlWizardParameters.setCategory(QLatin1String(Constants::WIZARD_CATEGORY_QML)); qmlWizardParameters.setDisplayCategory(QCoreApplication::translate("QmlJsEditor", Constants::WIZARD_TR_CATEGORY_QML)); qmlWizardParameters.setDescription(tr("Creates a QML file.")); qmlWizardParameters.setDisplayName(tr("QML File")); qmlWizardParameters.setId(QLatin1String("Q.Qml")); addAutoReleasedObject(new QmlFileWizard(qmlWizardParameters, core)); Core::BaseFileWizardParameters jsWizardParameters(Core::IWizard::FileWizard); jsWizardParameters.setCategory(QLatin1String(Constants::WIZARD_CATEGORY_QML)); jsWizardParameters.setDisplayCategory(QCoreApplication::translate("QmlJsEditor", Constants::WIZARD_TR_CATEGORY_QML)); jsWizardParameters.setDescription(tr("Creates a JavaScript file.")); jsWizardParameters.setDisplayName(tr("JS File")); jsWizardParameters.setId(QLatin1String("Z.Js")); addAutoReleasedObject(new JsFileWizard(jsWizardParameters, core)); m_actionHandler = new TextEditor::TextEditorActionHandler(QmlJSEditor::Constants::C_QMLJSEDITOR_ID, TextEditor::TextEditorActionHandler::Format | TextEditor::TextEditorActionHandler::UnCommentSelection | TextEditor::TextEditorActionHandler::UnCollapseAll); m_actionHandler->initializeActions(); Core::ActionManager *am = core->actionManager(); Core::ActionContainer *contextMenu = am->createMenu(QmlJSEditor::Constants::M_CONTEXT); Core::ActionContainer *qmlToolsMenu = am->createMenu(Core::Id(Constants::M_TOOLS_QML)); qmlToolsMenu->setOnAllDisabledBehavior(Core::ActionContainer::Hide); QMenu *menu = qmlToolsMenu->menu(); //: QML sub-menu in the Tools menu menu->setTitle(tr("QML")); am->actionContainer(Core::Constants::M_TOOLS)->addMenu(qmlToolsMenu); Core::Command *cmd; QAction *followSymbolUnderCursorAction = new QAction(tr("Follow Symbol Under Cursor"), this); cmd = am->registerAction(followSymbolUnderCursorAction, Constants::FOLLOW_SYMBOL_UNDER_CURSOR, context); cmd->setDefaultKeySequence(QKeySequence(Qt::Key_F2)); connect(followSymbolUnderCursorAction, SIGNAL(triggered()), this, SLOT(followSymbolUnderCursor())); contextMenu->addAction(cmd); qmlToolsMenu->addAction(cmd); QAction *findUsagesAction = new QAction(tr("Find Usages"), this); cmd = am->registerAction(findUsagesAction, Constants::FIND_USAGES, context); cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+U"))); connect(findUsagesAction, SIGNAL(triggered()), this, SLOT(findUsages())); contextMenu->addAction(cmd); qmlToolsMenu->addAction(cmd); QAction *showQuickToolbar = new QAction(tr("Show Qt Quick Toolbar"), this); cmd = am->registerAction(showQuickToolbar, Constants::SHOW_QT_QUICK_HELPER, context); #ifdef Q_WS_MACX cmd->setDefaultKeySequence(QKeySequence(Qt::META + Qt::ALT + Qt::Key_Space)); #else cmd->setDefaultKeySequence(QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_Space)); #endif connect(showQuickToolbar, SIGNAL(triggered()), this, SLOT(showContextPane())); contextMenu->addAction(cmd); qmlToolsMenu->addAction(cmd); // Insert marker for "Refactoring" menu: Core::Context globalContext(Core::Constants::C_GLOBAL); Core::Command *sep = createSeparator(am, this, globalContext, Constants::SEPARATOR1); sep->action()->setObjectName(Constants::M_REFACTORING_MENU_INSERTION_POINT); contextMenu->addAction(sep); contextMenu->addAction(createSeparator(am, this, globalContext, Constants::SEPARATOR2)); cmd = am->command(TextEditor::Constants::AUTO_INDENT_SELECTION); contextMenu->addAction(cmd); cmd = am->command(TextEditor::Constants::UN_COMMENT_SELECTION); contextMenu->addAction(cmd); CodeCompletion *completion = new CodeCompletion(m_modelManager); addAutoReleasedObject(completion); addAutoReleasedObject(new HoverHandler); // Set completion settings and keep them up to date TextEditor::TextEditorSettings *textEditorSettings = TextEditor::TextEditorSettings::instance(); completion->setCompletionSettings(textEditorSettings->completionSettings()); connect(textEditorSettings, SIGNAL(completionSettingsChanged(TextEditor::CompletionSettings)), completion, SLOT(setCompletionSettings(TextEditor::CompletionSettings))); error_message->clear(); Core::FileIconProvider *iconProvider = Core::FileIconProvider::instance(); iconProvider->registerIconOverlayForSuffix(QIcon(QLatin1String(":/qmljseditor/images/qmlfile.png")), "qml"); m_quickFixCollector = new QmlJSQuickFixCollector; addAutoReleasedObject(m_quickFixCollector); QmlJSQuickFixCollector::registerQuickFixes(this); addAutoReleasedObject(new QmlJSOutlineWidgetFactory); m_qmlTaskManager = new QmlTaskManager; addAutoReleasedObject(m_qmlTaskManager); connect(m_modelManager, SIGNAL(documentChangedOnDisk(QmlJS::Document::Ptr)), m_qmlTaskManager, SLOT(documentChangedOnDisk(QmlJS::Document::Ptr))); connect(m_modelManager, SIGNAL(aboutToRemoveFiles(QStringList)), m_qmlTaskManager, SLOT(documentsRemoved(QStringList))); addAutoReleasedObject(new QuickToolBar); addAutoReleasedObject(new Internal::QuickToolBarSettingsPage); connect(core->editorManager(), SIGNAL(currentEditorChanged(Core::IEditor*)), SLOT(currentEditorChanged(Core::IEditor*))); return true; }
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))); }
FindToolBar::FindToolBar(FindPlugin *plugin, CurrentDocumentFind *currentDocumentFind) : m_plugin(plugin), m_currentDocumentFind(currentDocumentFind), m_findCompleter(new QCompleter(this)), m_replaceCompleter(new QCompleter(this)), m_enterFindStringAction(0), m_findNextAction(0), m_findPreviousAction(0), m_replaceAction(0), m_replaceNextAction(0), m_replacePreviousAction(0), m_findIncrementalTimer(this), m_findStepTimer(this), m_useFakeVim(false), m_eventFiltersInstalled(false) { //setup ui m_ui.setupUi(this); // compensate for a vertically expanding spacer below the label m_ui.replaceLabel->setMinimumHeight(m_ui.replaceEdit->sizeHint().height()); delete m_ui.replaceButtonsWidget->layout(); Utils::FlowLayout *flowlayout = new Utils::FlowLayout(m_ui.replaceButtonsWidget, 0, 3, 3); flowlayout->addWidget(m_ui.replaceButton); flowlayout->addWidget(m_ui.replaceNextButton); flowlayout->addWidget(m_ui.replaceAllButton); m_ui.replaceButtonsWidget->setLayout(flowlayout); setFocusProxy(m_ui.findEdit); setProperty("topBorder", true); setSingleRow(false); m_ui.findEdit->setAttribute(Qt::WA_MacShowFocusRect, false); m_ui.replaceEdit->setAttribute(Qt::WA_MacShowFocusRect, false); connect(m_ui.findEdit, SIGNAL(editingFinished()), this, SLOT(invokeResetIncrementalSearch())); m_ui.close->setIcon(QIcon(QLatin1String(Core::Constants::ICON_CLOSE_DOCUMENT))); connect(m_ui.close, SIGNAL(clicked()), this, SLOT(hideAndResetFocus())); m_findCompleter->setModel(m_plugin->findCompletionModel()); m_replaceCompleter->setModel(m_plugin->replaceCompletionModel()); m_ui.findEdit->setCompleter(m_findCompleter); m_ui.replaceEdit->setCompleter(m_replaceCompleter); QMenu *lineEditMenu = new QMenu(m_ui.findEdit); m_ui.findEdit->setButtonMenu(Utils::FancyLineEdit::Left, lineEditMenu); m_ui.findEdit->setButtonVisible(Utils::FancyLineEdit::Left, true); m_ui.findEdit->setPlaceholderText(QString()); m_ui.replaceEdit->setPlaceholderText(QString()); connect(m_ui.findEdit, SIGNAL(textChanged(QString)), this, SLOT(invokeFindIncremental())); connect(m_ui.findEdit, SIGNAL(returnPressed()), this, SLOT(invokeFindEnter())); connect(m_ui.replaceEdit, SIGNAL(returnPressed()), this, SLOT(invokeReplaceEnter())); QAction *shiftEnterAction = new QAction(m_ui.findEdit); shiftEnterAction->setShortcut(QKeySequence(tr("Shift+Enter"))); shiftEnterAction->setShortcutContext(Qt::WidgetShortcut); connect(shiftEnterAction, SIGNAL(triggered()), this, SLOT(invokeFindPrevious())); m_ui.findEdit->addAction(shiftEnterAction); QAction *shiftReturnAction = new QAction(m_ui.findEdit); shiftReturnAction->setShortcut(QKeySequence(tr("Shift+Return"))); shiftReturnAction->setShortcutContext(Qt::WidgetShortcut); connect(shiftReturnAction, SIGNAL(triggered()), this, SLOT(invokeFindPrevious())); m_ui.findEdit->addAction(shiftReturnAction); QAction *shiftEnterReplaceAction = new QAction(m_ui.replaceEdit); shiftEnterReplaceAction->setShortcut(QKeySequence(tr("Shift+Enter"))); shiftEnterReplaceAction->setShortcutContext(Qt::WidgetShortcut); connect(shiftEnterReplaceAction, SIGNAL(triggered()), this, SLOT(invokeReplacePrevious())); m_ui.replaceEdit->addAction(shiftEnterReplaceAction); QAction *shiftReturnReplaceAction = new QAction(m_ui.replaceEdit); shiftReturnReplaceAction->setShortcut(QKeySequence(tr("Shift+Return"))); shiftReturnReplaceAction->setShortcutContext(Qt::WidgetShortcut); connect(shiftReturnReplaceAction, SIGNAL(triggered()), this, SLOT(invokeReplacePrevious())); m_ui.replaceEdit->addAction(shiftReturnReplaceAction); // need to make sure QStringList is registered as metatype QMetaTypeId<QStringList>::qt_metatype_id(); // register actions Core::Context globalcontext(Core::Constants::C_GLOBAL); Core::ActionManager *am = Core::ICore::actionManager(); Core::ActionContainer *mfind = am->actionContainer(Constants::M_FIND); Core::Command *cmd; m_ui.advancedButton->setDefaultAction(am->command(Constants::ADVANCED_FIND)->action()); QIcon icon = QIcon::fromTheme(QLatin1String("edit-find-replace")); m_findInDocumentAction = new QAction(icon, tr("Find/Replace"), this); cmd = am->registerAction(m_findInDocumentAction, Constants::FIND_IN_DOCUMENT, globalcontext); cmd->setDefaultKeySequence(QKeySequence::Find); mfind->addAction(cmd, Constants::G_FIND_CURRENTDOCUMENT); connect(m_findInDocumentAction, SIGNAL(triggered()), this, SLOT(openFind())); if (QApplication::clipboard()->supportsFindBuffer()) { m_enterFindStringAction = new QAction(tr("Enter Find String"), this); cmd = am->registerAction(m_enterFindStringAction, "Find.EnterFindString", globalcontext); cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+E"))); mfind->addAction(cmd, Constants::G_FIND_ACTIONS); connect(m_enterFindStringAction, SIGNAL(triggered()), this, SLOT(putSelectionToFindClipboard())); connect(QApplication::clipboard(), SIGNAL(findBufferChanged()), this, SLOT(updateFromFindClipboard())); } m_findNextAction = new QAction(tr("Find Next"), this); cmd = am->registerAction(m_findNextAction, Constants::FIND_NEXT, globalcontext); cmd->setDefaultKeySequence(QKeySequence::FindNext); mfind->addAction(cmd, Constants::G_FIND_ACTIONS); connect(m_findNextAction, SIGNAL(triggered()), this, SLOT(invokeFindNext())); m_ui.findNextButton->setDefaultAction(cmd->action()); m_findPreviousAction = new QAction(tr("Find Previous"), this); cmd = am->registerAction(m_findPreviousAction, Constants::FIND_PREVIOUS, globalcontext); cmd->setDefaultKeySequence(QKeySequence::FindPrevious); mfind->addAction(cmd, Constants::G_FIND_ACTIONS); connect(m_findPreviousAction, SIGNAL(triggered()), this, SLOT(invokeFindPrevious())); m_ui.findPreviousButton->setDefaultAction(cmd->action()); m_findNextSelectedAction = new QAction(tr("Find Next (Selected)"), this); cmd = am->registerAction(m_findNextSelectedAction, Constants::FIND_NEXT_SELECTED, globalcontext); cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+F3"))); mfind->addAction(cmd, Constants::G_FIND_ACTIONS); connect(m_findNextSelectedAction, SIGNAL(triggered()), this, SLOT(findNextSelected())); m_findPreviousSelectedAction = new QAction(tr("Find Previous (Selected)"), this); cmd = am->registerAction(m_findPreviousSelectedAction, Constants::FIND_PREV_SELECTED, globalcontext); cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+F3"))); mfind->addAction(cmd, Constants::G_FIND_ACTIONS); connect(m_findPreviousSelectedAction, SIGNAL(triggered()), this, SLOT(findPreviousSelected())); m_replaceAction = new QAction(tr("Replace"), this); cmd = am->registerAction(m_replaceAction, Constants::REPLACE, globalcontext); cmd->setDefaultKeySequence(QKeySequence()); mfind->addAction(cmd, Constants::G_FIND_ACTIONS); connect(m_replaceAction, SIGNAL(triggered()), this, SLOT(invokeReplace())); m_ui.replaceButton->setDefaultAction(cmd->action()); m_replaceNextAction = new QAction(tr("Replace && Find"), this); m_replaceNextAction->setIconText(tr("Replace && Find")); // work around bug in Qt that kills ampersands in tool button cmd = am->registerAction(m_replaceNextAction, Constants::REPLACE_NEXT, globalcontext); cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+="))); mfind->addAction(cmd, Constants::G_FIND_ACTIONS); connect(m_replaceNextAction, SIGNAL(triggered()), this, SLOT(invokeReplaceNext())); m_ui.replaceNextButton->setDefaultAction(cmd->action()); m_replacePreviousAction = new QAction(tr("Replace && Find Previous"), this); cmd = am->registerAction(m_replacePreviousAction, Constants::REPLACE_PREVIOUS, globalcontext); // shortcut removed, clashes with Ctrl++ on many keyboard layouts //cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+="))); mfind->addAction(cmd, Constants::G_FIND_ACTIONS); connect(m_replacePreviousAction, SIGNAL(triggered()), this, SLOT(invokeReplacePrevious())); m_replaceAllAction = new QAction(tr("Replace All"), this); cmd = am->registerAction(m_replaceAllAction, Constants::REPLACE_ALL, globalcontext); mfind->addAction(cmd, Constants::G_FIND_ACTIONS); connect(m_replaceAllAction, SIGNAL(triggered()), this, SLOT(invokeReplaceAll())); m_ui.replaceAllButton->setDefaultAction(cmd->action()); m_caseSensitiveAction = new QAction(tr("Case Sensitive"), this); m_caseSensitiveAction->setIcon(QIcon(QLatin1String(":/find/images/casesensitively.png"))); m_caseSensitiveAction->setCheckable(true); m_caseSensitiveAction->setChecked(false); cmd = am->registerAction(m_caseSensitiveAction, Constants::CASE_SENSITIVE, globalcontext); mfind->addAction(cmd, Constants::G_FIND_FLAGS); connect(m_caseSensitiveAction, SIGNAL(triggered(bool)), this, SLOT(setCaseSensitive(bool))); lineEditMenu->addAction(m_caseSensitiveAction); m_wholeWordAction = new QAction(tr("Whole Words Only"), this); m_wholeWordAction->setIcon(QIcon(QLatin1String(":/find/images/wholewords.png"))); m_wholeWordAction->setCheckable(true); m_wholeWordAction->setChecked(false); cmd = am->registerAction(m_wholeWordAction, Constants::WHOLE_WORDS, globalcontext); mfind->addAction(cmd, Constants::G_FIND_FLAGS); connect(m_wholeWordAction, SIGNAL(triggered(bool)), this, SLOT(setWholeWord(bool))); lineEditMenu->addAction(m_wholeWordAction); m_regularExpressionAction = new QAction(tr("Use Regular Expressions"), this); m_regularExpressionAction->setIcon(QIcon(QLatin1String(":/find/images/regexp.png"))); m_regularExpressionAction->setCheckable(true); m_regularExpressionAction->setChecked(false); cmd = am->registerAction(m_regularExpressionAction, Constants::REGULAR_EXPRESSIONS, globalcontext); mfind->addAction(cmd, Constants::G_FIND_FLAGS); connect(m_regularExpressionAction, SIGNAL(triggered(bool)), this, SLOT(setRegularExpressions(bool))); lineEditMenu->addAction(m_regularExpressionAction); connect(m_currentDocumentFind, SIGNAL(candidateChanged()), this, SLOT(adaptToCandidate())); connect(m_currentDocumentFind, SIGNAL(changed()), this, SLOT(updateToolBar())); updateToolBar(); m_findIncrementalTimer.setSingleShot(true); m_findStepTimer.setSingleShot(true); connect(&m_findIncrementalTimer, SIGNAL(timeout()), this, SLOT(invokeFindIncremental())); connect(&m_findStepTimer, SIGNAL(timeout()), this, SLOT(invokeFindStep())); }
FindToolBar::FindToolBar(FindPlugin *plugin, CurrentDocumentFind *currentDocumentFind) : m_plugin(plugin), m_currentDocumentFind(currentDocumentFind), m_findCompleter(new QCompleter(this)), m_replaceCompleter(new QCompleter(this)), m_enterFindStringAction(0), m_findNextAction(0), m_findPreviousAction(0), m_replaceNextAction(0), m_widget(new QWidget) { //setup ui m_ui.setupUi(m_widget); addWidget(m_widget); setFocusProxy(m_ui.findEdit); setProperty("topBorder", true); m_ui.findEdit->setAttribute(Qt::WA_MacShowFocusRect, false); m_ui.replaceEdit->setAttribute(Qt::WA_MacShowFocusRect, false); connect(m_ui.findEdit, SIGNAL(editingFinished()), this, SLOT(invokeResetIncrementalSearch())); QWidget *spacerItem = new QWidget; spacerItem->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum); addWidget(spacerItem); QToolButton *close = new QToolButton; close->setProperty("type", QLatin1String("dockbutton")); close->setIcon(QIcon(":/core/images/closebutton.png")); connect(close, SIGNAL(clicked()), this, SLOT(hideAndResetFocus())); addWidget(close); m_ui.findPreviousButton->setProperty("type", QLatin1String("dockbutton")); m_ui.findNextButton->setProperty("type", QLatin1String("dockbutton")); m_ui.replacePreviousButton->setProperty("type", QLatin1String("dockbutton")); m_ui.replaceNextButton->setProperty("type", QLatin1String("dockbutton")); m_ui.replaceAllButton->setProperty("type", QLatin1String("dockbutton")); m_findCompleter->setModel(m_plugin->findCompletionModel()); m_replaceCompleter->setModel(m_plugin->replaceCompletionModel()); m_ui.findEdit->setCompleter(m_findCompleter); m_findCompleter->popup()->installEventFilter(this); m_ui.replaceEdit->setCompleter(m_replaceCompleter); m_ui.findEdit->setSide(qApp->layoutDirection() == Qt::LeftToRight ? Core::Utils::FancyLineEdit::Right : Core::Utils::FancyLineEdit::Left); QMenu *lineEditMenu = new QMenu(m_ui.findEdit); m_ui.findEdit->setMenu(lineEditMenu); m_ui.findEdit->installEventFilter(this); m_ui.replaceEdit->installEventFilter(this); m_widget->installEventFilter(this); connect(m_ui.findEdit, SIGNAL(textChanged(const QString&)), this, SLOT(invokeFindIncremental())); connect(m_ui.findEdit, SIGNAL(returnPressed()), this, SLOT(invokeFindEnter())); connect(m_ui.replaceEdit, SIGNAL(returnPressed()), this, SLOT(invokeReplaceEnter())); QAction *shiftEnterAction = new QAction(m_ui.findEdit); shiftEnterAction->setShortcut(QKeySequence("Shift+Enter")); shiftEnterAction->setShortcutContext(Qt::WidgetShortcut); connect(shiftEnterAction, SIGNAL(triggered()), this, SLOT(invokeFindPrevious())); m_ui.findEdit->addAction(shiftEnterAction); QAction *shiftReturnAction = new QAction(m_ui.findEdit); shiftReturnAction->setShortcut(QKeySequence("Shift+Return")); shiftReturnAction->setShortcutContext(Qt::WidgetShortcut); connect(shiftReturnAction, SIGNAL(triggered()), this, SLOT(invokeFindPrevious())); m_ui.findEdit->addAction(shiftReturnAction); QAction *shiftEnterReplaceAction = new QAction(m_ui.replaceEdit); shiftEnterReplaceAction->setShortcut(QKeySequence("Shift+Enter")); shiftEnterReplaceAction->setShortcutContext(Qt::WidgetShortcut); connect(shiftEnterReplaceAction, SIGNAL(triggered()), this, SLOT(invokeReplacePrevious())); m_ui.replaceEdit->addAction(shiftEnterReplaceAction); QAction *shiftReturnReplaceAction = new QAction(m_ui.replaceEdit); shiftReturnReplaceAction->setShortcut(QKeySequence("Shift+Return")); shiftReturnReplaceAction->setShortcutContext(Qt::WidgetShortcut); connect(shiftReturnReplaceAction, SIGNAL(triggered()), this, SLOT(invokeReplacePrevious())); m_ui.replaceEdit->addAction(shiftReturnReplaceAction); // need to make sure QStringList is registered as metatype QMetaTypeId<QStringList>::qt_metatype_id(); //register actions QList<int> globalcontext; globalcontext << Core::Constants::C_GLOBAL_ID; Core::ActionManager *am = Core::ICore::instance()->actionManager(); Core::ActionContainer *mfind = am->actionContainer(Constants::M_FIND); Core::Command *cmd; m_findInDocumentAction = new QAction(tr("Current Document"), this); cmd = am->registerAction(m_findInDocumentAction, Constants::FIND_IN_DOCUMENT, globalcontext); cmd->setDefaultKeySequence(QKeySequence::Find); mfind->addAction(cmd, Constants::G_FIND_CURRENTDOCUMENT); connect(m_findInDocumentAction, SIGNAL(triggered()), this, SLOT(openFind())); if (QApplication::clipboard()->supportsFindBuffer()) { m_enterFindStringAction = new QAction(tr("Enter Find String"), this); cmd = am->registerAction(m_enterFindStringAction, tr("Find.EnterFindString"), globalcontext); cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+E"))); mfind->addAction(cmd, Constants::G_FIND_ACTIONS); connect(m_enterFindStringAction, SIGNAL(triggered()), this, SLOT(putSelectionToFindClipboard())); connect(QApplication::clipboard(), SIGNAL(findBufferChanged()), this, SLOT(updateFromFindClipboard())); } m_findNextAction = new QAction(tr("Find Next"), this); cmd = am->registerAction(m_findNextAction, Constants::FIND_NEXT, globalcontext); cmd->setDefaultKeySequence(QKeySequence::FindNext); mfind->addAction(cmd, Constants::G_FIND_ACTIONS); connect(m_findNextAction, SIGNAL(triggered()), this, SLOT(invokeFindNext())); m_ui.findNextButton->setDefaultAction(cmd->action()); m_findPreviousAction = new QAction(tr("Find Previous"), this); cmd = am->registerAction(m_findPreviousAction, Constants::FIND_PREVIOUS, globalcontext); cmd->setDefaultKeySequence(QKeySequence::FindPrevious); mfind->addAction(cmd, Constants::G_FIND_ACTIONS); connect(m_findPreviousAction, SIGNAL(triggered()), this, SLOT(invokeFindPrevious())); m_ui.findPreviousButton->setDefaultAction(cmd->action()); m_replaceNextAction = new QAction(tr("Replace && Find Next"), this); cmd = am->registerAction(m_replaceNextAction, Constants::REPLACE_NEXT, globalcontext); cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+="))); mfind->addAction(cmd, Constants::G_FIND_ACTIONS); connect(m_replaceNextAction, SIGNAL(triggered()), this, SLOT(invokeReplaceNext())); m_ui.replaceNextButton->setDefaultAction(cmd->action()); m_replacePreviousAction = new QAction(tr("Replace && Find Previous"), this); cmd = am->registerAction(m_replacePreviousAction, Constants::REPLACE_PREVIOUS, globalcontext); // shortcut removed, clashes with Ctrl++ on many keyboard layouts //cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+="))); mfind->addAction(cmd, Constants::G_FIND_ACTIONS); connect(m_replacePreviousAction, SIGNAL(triggered()), this, SLOT(invokeReplacePrevious())); m_ui.replacePreviousButton->setDefaultAction(cmd->action()); m_replaceAllAction = new QAction(tr("Replace All"), this); cmd = am->registerAction(m_replaceAllAction, Constants::REPLACE_ALL, globalcontext); mfind->addAction(cmd, Constants::G_FIND_ACTIONS); connect(m_replaceAllAction, SIGNAL(triggered()), this, SLOT(invokeReplaceAll())); m_ui.replaceAllButton->setDefaultAction(cmd->action()); m_caseSensitiveAction = new QAction(tr("Case Sensitive"), this); m_caseSensitiveAction->setIcon(QIcon(":/find/images/casesensitively.png")); m_caseSensitiveAction->setCheckable(true); m_caseSensitiveAction->setChecked(false); cmd = am->registerAction(m_caseSensitiveAction, Constants::CASE_SENSITIVE, globalcontext); mfind->addAction(cmd, Constants::G_FIND_FLAGS); connect(m_caseSensitiveAction, SIGNAL(triggered(bool)), m_plugin, SLOT(setCaseSensitive(bool))); lineEditMenu->addAction(m_caseSensitiveAction); m_wholeWordAction = new QAction(tr("Whole Words Only"), this); m_wholeWordAction->setIcon(QIcon(":/find/images/wholewords.png")); m_wholeWordAction->setCheckable(true); m_wholeWordAction->setChecked(false); cmd = am->registerAction(m_wholeWordAction, Constants::WHOLE_WORDS, globalcontext); mfind->addAction(cmd, Constants::G_FIND_FLAGS); connect(m_wholeWordAction, SIGNAL(triggered(bool)), m_plugin, SLOT(setWholeWord(bool))); lineEditMenu->addAction(m_wholeWordAction); connect(m_currentDocumentFind, SIGNAL(changed()), this, SLOT(updateActions())); updateActions(); updateIcons(); connect(m_plugin, SIGNAL(findFlagsChanged()), this, SLOT(findFlagsChanged())); }
void TextEditorActionHandler::createActions() { #if 0 m_undoAction = registerNewAction(QLatin1String(Core::Constants::UNDO), this, SLOT(undoAction()), tr("&Undo")); m_redoAction = registerNewAction(QLatin1String(Core::Constants::REDO), this, SLOT(redoAction()), tr("&Redo")); m_copyAction = registerNewAction(QLatin1String(Core::Constants::COPY), this, SLOT(copyAction())); m_cutAction = registerNewAction(QLatin1String(Core::Constants::CUT), this, SLOT(cutAction())); m_pasteAction = registerNewAction(QLatin1String(Core::Constants::PASTE), this, SLOT(pasteAction())); m_selectAllAction = registerNewAction(QLatin1String(Core::Constants::SELECTALL), this, SLOT(selectAllAction())); m_gotoAction = registerNewAction(QLatin1String(Core::Constants::GOTO), this, SLOT(gotoAction())); m_printAction = registerNewAction(QLatin1String(Core::Constants::PRINT), this, SLOT(printAction())); Core::ActionManager *am = Core::ICore::instance()->actionManager(); Core::ActionContainer *medit = am->actionContainer(Core::Constants::M_EDIT); Core::ActionContainer *advancedMenu = am->actionContainer(Core::Constants::M_EDIT_ADVANCED); m_selectEncodingAction = new QAction(tr("Select Encoding..."), this); Core::Command *command = am->registerAction(m_selectEncodingAction, Constants::SELECT_ENCODING, m_contextId); connect(m_selectEncodingAction, SIGNAL(triggered()), this, SLOT(selectEncoding())); medit->addAction(command, Core::Constants::G_EDIT_OTHER); m_formatAction = new QAction(tr("Auto-&indent Selection"), this); command = am->registerAction(m_formatAction, TextEditor::Constants::AUTO_INDENT_SELECTION, m_contextId); command->setDefaultKeySequence(QKeySequence(tr("Ctrl+I"))); advancedMenu->addAction(command, Core::Constants::G_EDIT_FORMAT); connect(m_formatAction, SIGNAL(triggered(bool)), this, SLOT(formatAction())); #ifdef Q_WS_MAC QString modifier = tr("Meta"); #else QString modifier = tr("Ctrl"); #endif m_rewrapParagraphAction = new QAction(tr("&Rewrap Paragraph"), this); command = am->registerAction(m_rewrapParagraphAction, TextEditor::Constants::REWRAP_PARAGRAPH, m_contextId); command->setDefaultKeySequence(QKeySequence(tr("%1+E, R").arg(modifier))); advancedMenu->addAction(command, Core::Constants::G_EDIT_FORMAT); connect(m_rewrapParagraphAction, SIGNAL(triggered(bool)), this, SLOT(rewrapParagraphAction())); m_visualizeWhitespaceAction = new QAction(tr("&Visualize Whitespace"), this); m_visualizeWhitespaceAction->setCheckable(true); command = am->registerAction(m_visualizeWhitespaceAction, TextEditor::Constants::VISUALIZE_WHITESPACE, m_contextId); command->setDefaultKeySequence(QKeySequence(tr("%1+E, %2+V").arg(modifier, modifier))); advancedMenu->addAction(command, Core::Constants::G_EDIT_FORMAT); connect(m_visualizeWhitespaceAction, SIGNAL(triggered(bool)), this, SLOT(setVisualizeWhitespace(bool))); m_cleanWhitespaceAction = new QAction(tr("Clean Whitespace"), this); command = am->registerAction(m_cleanWhitespaceAction, TextEditor::Constants::CLEAN_WHITESPACE, m_contextId); advancedMenu->addAction(command, Core::Constants::G_EDIT_FORMAT); connect(m_cleanWhitespaceAction, SIGNAL(triggered()), this, SLOT(cleanWhitespace())); m_textWrappingAction = new QAction(tr("Enable Text &Wrapping"), this); m_textWrappingAction->setCheckable(true); command = am->registerAction(m_textWrappingAction, TextEditor::Constants::TEXT_WRAPPING, m_contextId); command->setDefaultKeySequence(QKeySequence(tr("%1+E, %2+W").arg(modifier, modifier))); advancedMenu->addAction(command, Core::Constants::G_EDIT_FORMAT); connect(m_textWrappingAction, SIGNAL(triggered(bool)), this, SLOT(setTextWrapping(bool))); m_unCommentSelectionAction = new QAction(tr("(Un)Comment &Selection"), this); command = am->registerAction(m_unCommentSelectionAction, Constants::UN_COMMENT_SELECTION, m_contextId); command->setDefaultKeySequence(QKeySequence(tr("Ctrl+/"))); connect(m_unCommentSelectionAction, SIGNAL(triggered()), this, SLOT(unCommentSelection())); advancedMenu->addAction(command, Core::Constants::G_EDIT_FORMAT); m_cutLineAction = new QAction(tr("Cut &Line"), this); command = am->registerAction(m_cutLineAction, Constants::CUT_LINE, m_contextId); command->setDefaultKeySequence(QKeySequence(tr("Shift+Del"))); connect(m_cutLineAction, SIGNAL(triggered()), this, SLOT(cutLine())); m_deleteLineAction = new QAction(tr("Delete &Line"), this); command = am->registerAction(m_deleteLineAction, Constants::DELETE_LINE, m_contextId); connect(m_deleteLineAction, SIGNAL(triggered()), this, SLOT(deleteLine())); m_collapseAction = new QAction(tr("Collapse"), this); command = am->registerAction(m_collapseAction, Constants::COLLAPSE, m_contextId); command->setDefaultKeySequence(QKeySequence(tr("Ctrl+<"))); connect(m_collapseAction, SIGNAL(triggered()), this, SLOT(collapse())); advancedMenu->addAction(command, Core::Constants::G_EDIT_COLLAPSING); m_expandAction = new QAction(tr("Expand"), this); command = am->registerAction(m_expandAction, Constants::EXPAND, m_contextId); command->setDefaultKeySequence(QKeySequence(tr("Ctrl+>"))); connect(m_expandAction, SIGNAL(triggered()), this, SLOT(expand())); advancedMenu->addAction(command, Core::Constants::G_EDIT_COLLAPSING); m_unCollapseAllAction = new QAction(tr("(Un)&Collapse All"), this); command = am->registerAction(m_unCollapseAllAction, Constants::UN_COLLAPSE_ALL, m_contextId); connect(m_unCollapseAllAction, SIGNAL(triggered()), this, SLOT(unCollapseAll())); advancedMenu->addAction(command, Core::Constants::G_EDIT_COLLAPSING); m_increaseFontSizeAction = new QAction(tr("Increase Font Size"), this); command = am->registerAction(m_increaseFontSizeAction, Constants::INCREASE_FONT_SIZE, m_contextId); command->setDefaultKeySequence(QKeySequence(tr("Ctrl++"))); connect(m_increaseFontSizeAction, SIGNAL(triggered()), this, SLOT(increaseFontSize())); advancedMenu->addAction(command, Core::Constants::G_EDIT_FONT); m_decreaseFontSizeAction = new QAction(tr("Decrease Font Size"), this); command = am->registerAction(m_decreaseFontSizeAction, Constants::DECREASE_FONT_SIZE, m_contextId); command->setDefaultKeySequence(QKeySequence(tr("Ctrl+-"))); connect(m_decreaseFontSizeAction, SIGNAL(triggered()), this, SLOT(decreaseFontSize())); advancedMenu->addAction(command, Core::Constants::G_EDIT_FONT); m_gotoBlockStartAction = new QAction(tr("Goto Block Start"), this); command = am->registerAction(m_gotoBlockStartAction, Constants::GOTO_BLOCK_START, m_contextId); command->setDefaultKeySequence(QKeySequence(tr("Ctrl+["))); connect(m_gotoBlockStartAction, SIGNAL(triggered()), this, SLOT(gotoBlockStart())); advancedMenu->addAction(command, Core::Constants::G_EDIT_BLOCKS); m_gotoBlockEndAction = new QAction(tr("Goto Block End"), this); command = am->registerAction(m_gotoBlockEndAction, Constants::GOTO_BLOCK_END, m_contextId); command->setDefaultKeySequence(QKeySequence(tr("Ctrl+]"))); connect(m_gotoBlockEndAction, SIGNAL(triggered()), this, SLOT(gotoBlockEnd())); advancedMenu->addAction(command, Core::Constants::G_EDIT_BLOCKS); m_gotoBlockStartWithSelectionAction = new QAction(tr("Goto Block Start With Selection"), this); command = am->registerAction(m_gotoBlockStartWithSelectionAction, Constants::GOTO_BLOCK_START_WITH_SELECTION, m_contextId); command->setDefaultKeySequence(QKeySequence(tr("Ctrl+{"))); connect(m_gotoBlockStartWithSelectionAction, SIGNAL(triggered()), this, SLOT(gotoBlockStartWithSelection())); m_gotoBlockEndWithSelectionAction = new QAction(tr("Goto Block End With Selection"), this); command = am->registerAction(m_gotoBlockEndWithSelectionAction, Constants::GOTO_BLOCK_END_WITH_SELECTION, m_contextId); command->setDefaultKeySequence(QKeySequence(tr("Ctrl+}"))); connect(m_gotoBlockEndWithSelectionAction, SIGNAL(triggered()), this, SLOT(gotoBlockEndWithSelection())); m_selectBlockUpAction= new QAction(tr("Select Block Up"), this); command = am->registerAction(m_selectBlockUpAction, Constants::SELECT_BLOCK_UP, m_contextId); command->setDefaultKeySequence(QKeySequence(tr("Ctrl+U"))); connect(m_selectBlockUpAction, SIGNAL(triggered()), this, SLOT(selectBlockUp())); advancedMenu->addAction(command, Core::Constants::G_EDIT_BLOCKS); m_selectBlockDownAction= new QAction(tr("Select Block Down"), this); command = am->registerAction(m_selectBlockDownAction, Constants::SELECT_BLOCK_DOWN, m_contextId); connect(m_selectBlockDownAction, SIGNAL(triggered()), this, SLOT(selectBlockDown())); advancedMenu->addAction(command, Core::Constants::G_EDIT_BLOCKS); m_moveLineUpAction= new QAction(tr("Move Line Up"), this); command = am->registerAction(m_moveLineUpAction, Constants::MOVE_LINE_UP, m_contextId); command->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+Up"))); connect(m_moveLineUpAction, SIGNAL(triggered()), this, SLOT(moveLineUp())); m_moveLineDownAction= new QAction(tr("Move Line Down"), this); command = am->registerAction(m_moveLineDownAction, Constants::MOVE_LINE_DOWN, m_contextId); command->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+Down"))); connect(m_moveLineDownAction, SIGNAL(triggered()), this, SLOT(moveLineDown())); m_copyLineUpAction= new QAction(tr("Copy Line Up"), this); command = am->registerAction(m_copyLineUpAction, Constants::COPY_LINE_UP, m_contextId); command->setDefaultKeySequence(QKeySequence(tr("Ctrl+Alt+Up"))); connect(m_copyLineUpAction, SIGNAL(triggered()), this, SLOT(copyLineUp())); m_copyLineDownAction= new QAction(tr("Copy Line Down"), this); command = am->registerAction(m_copyLineDownAction, Constants::COPY_LINE_DOWN, m_contextId); command->setDefaultKeySequence(QKeySequence(tr("Ctrl+Alt+Down"))); connect(m_copyLineDownAction, SIGNAL(triggered()), this, SLOT(copyLineDown())); #endif }