Beispiel #1
0
        private void execHandler(object sender, EventArgs e)
        {
            var command = sender as OleMenuCommand;

            if (command == null)
            {
                return;
            }

            switch ((CommandId)command.CommandID.ID)
            {
            case CommandId.LaunchDesignerId:
                DefaultEditorsHandler.Instance.StartEditor(DefaultEditor.Kind.Ui);
                break;

            case CommandId.LaunchLinguistId:
                DefaultEditorsHandler.Instance.StartEditor(DefaultEditor.Kind.Ts);
                break;

            case CommandId.OpenProFileId:
                ExtLoader.ImportProFile();
                break;

            case CommandId.ImportPriFileId:
                ExtLoader.ImportPriFile(HelperFunctions.GetSelectedQtProject(Vsix.Instance.Dte));
                break;

            case CommandId.ExportPriFileId:
                ExtLoader.ExportPriFile();
                break;

            case CommandId.ExportProFileId:
                ExtLoader.ExportProFile();
                break;

            case CommandId.CreateNewTsFileId:
                Translation.CreateNewTranslationFile(HelperFunctions.GetSelectedQtProject(Vsix
                                                                                          .Instance.Dte));
                break;

            case CommandId.ConvertToQtId:
            case CommandId.ConvertToQmakeId:
            {
                var caption = SR.GetString("ConvertTitle");
                var text    = SR.GetString("ConvertConfirmation");
                if (MessageBox.Show(text, caption, MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    HelperFunctions.ToggleProjectKind(HelperFunctions.GetSelectedProject(Vsix
                                                                                         .Instance.Dte));
                }
            }
            break;

            case CommandId.ConvertToQtMsBuild:
            {
                QtMsBuildConverter.SolutionToQtMsBuild();
            }
            break;

            case CommandId.QtProjectSettingsId:
            {
                var pro            = HelperFunctions.GetSelectedQtProject(Vsix.Instance.Dte);
                int projectVersion = QtProject.GetFormatVersion(pro);
                if (projectVersion >= Resources.qtMinFormatVersion_Settings)
                {
                    Vsix.Instance.Dte.ExecuteCommand("Project.Properties");
                }
                else if (pro != null)
                {
                    using (var formProjectQtSettings = new FormProjectQtSettings()) {
                        formProjectQtSettings.SetProject(pro);
                        formProjectQtSettings.StartPosition = FormStartPosition.CenterParent;
                        var ww = new MainWinWrapper(Vsix.Instance.Dte);
                        formProjectQtSettings.ShowDialog(ww);
                    }
                }
                else
                {
                    MessageBox.Show(SR.GetString("NoProjectOpened"));
                }
            }
            break;

            case CommandId.ChangeProjectQtVersionId:
            {
                var pro = HelperFunctions.GetSelectedQtProject(Vsix.Instance.Dte);
                if (HelperFunctions.IsQMakeProject(pro))
                {
                    using (var formChangeQtVersion = new FormChangeQtVersion()) {
                        formChangeQtVersion.UpdateContent(ChangeFor.Project);
                        var ww = new MainWinWrapper(Vsix.Instance.Dte);
                        if (formChangeQtVersion.ShowDialog(ww) == DialogResult.OK)
                        {
                            var qtVersion = formChangeQtVersion.GetSelectedQtVersion();
                            HelperFunctions.SetDebuggingEnvironment(pro, "PATH=" + QtVersionManager
                                                                    .The().GetInstallPath(qtVersion) + @"\bin;$(PATH)", true);
                        }
                    }
                }
            }
            break;

            case CommandId.QtOptionsId:
            {
                using (var formQtVersions = new FormVSQtSettings()) {
                    formQtVersions.LoadSettings();
                    formQtVersions.StartPosition = FormStartPosition.CenterParent;
                    var ww = new MainWinWrapper(Vsix.Instance.Dte);
                    if (formQtVersions.ShowDialog(ww) == DialogResult.OK)
                    {
                        formQtVersions.SaveSettings();
                    }
                }
            }
            break;
            }
        }
Beispiel #2
0
        private void execHandler(object sender, EventArgs e)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            var command = sender as OleMenuCommand;

            if (command == null)
            {
                return;
            }

            switch ((CommandId)command.CommandID.ID)
            {
            case CommandId.ImportPriFileProjectId:
                ExtLoader.ImportPriFile(HelperFunctions.GetSelectedQtProject(QtVsToolsPackage.Instance.Dte));
                break;

            case CommandId.ExportPriFileProjectId:
                ExtLoader.ExportPriFile();
                break;

            case CommandId.ExportProFileProjectId:
                ExtLoader.ExportProFile();
                break;

            case CommandId.lUpdateOnProjectId:
                Translation.RunlUpdate(HelperFunctions.GetSelectedQtProject(QtVsToolsPackage.Instance.Dte));
                break;

            case CommandId.lReleaseOnProjectId:
                Translation.RunlRelease(HelperFunctions.GetSelectedQtProject(QtVsToolsPackage.Instance.Dte));
                break;

            case CommandId.ConvertToQtProjectId:
            case CommandId.ConvertToQmakeProjectId: {
                var caption = SR.GetString("ConvertTitle");
                var text    = SR.GetString("ConvertConfirmation");
                if (MessageBox.Show(text, caption, MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    HelperFunctions.ToggleProjectKind(HelperFunctions.GetSelectedProject(QtVsToolsPackage
                                                                                         .Instance.Dte));
                }
            }
            break;

            case CommandId.QtProjectSettingsProjectId: {
                var pro            = HelperFunctions.GetSelectedQtProject(QtVsToolsPackage.Instance.Dte);
                int projectVersion = QtProject.GetFormatVersion(pro);
                if (projectVersion >= Resources.qtMinFormatVersion_Settings)
                {
                    QtVsToolsPackage.Instance.Dte.ExecuteCommand("Project.Properties");
                }
                else if (pro != null)
                {
                    using (var formProjectQtSettings = new FormProjectQtSettings()) {
                        formProjectQtSettings.SetProject(pro);
                        formProjectQtSettings.StartPosition = FormStartPosition.CenterParent;
                        var ww = new MainWinWrapper(QtVsToolsPackage.Instance.Dte);
                        formProjectQtSettings.ShowDialog(ww);
                    }
                }
                else
                {
                    MessageBox.Show(SR.GetString("NoProjectOpened"));
                }
            }
            break;

            case CommandId.ChangeProjectQtVersionProjectId: {
                var pro = HelperFunctions.GetSelectedQtProject(QtVsToolsPackage.Instance.Dte);
                if (HelperFunctions.IsQMakeProject(pro))
                {
                    using (var formChangeQtVersion = new FormChangeQtVersion()) {
                        formChangeQtVersion.UpdateContent(ChangeFor.Project);
                        var ww = new MainWinWrapper(QtVsToolsPackage.Instance.Dte);
                        if (formChangeQtVersion.ShowDialog(ww) == DialogResult.OK)
                        {
                            var qtVersion = formChangeQtVersion.GetSelectedQtVersion();
                            HelperFunctions.SetDebuggingEnvironment(pro, "PATH=" + QtVersionManager
                                                                    .The().GetInstallPath(qtVersion) + @"\bin;$(PATH)", true);
                        }
                    }
                }
            }
            break;

            case CommandId.ProjectConvertToQtMsBuild: {
                QtMsBuildConverter.ProjectToQtMsBuild(
                    HelperFunctions.GetSelectedProject(QtVsToolsPackage.Instance.Dte));
            }
            break;

            case CommandId.ProjectRefreshIntelliSense: {
                var selectedProject = HelperFunctions.GetSelectedProject(QtVsToolsPackage.Instance.Dte);
                var tracker         = QtProjectTracker.Get(selectedProject, selectedProject.FullName);
                QtProjectIntellisense.Refresh(tracker.Project);
            }
            break;
            }
        }
Beispiel #3
0
        private void execHandler(object sender, EventArgs e)
        {
            var command = sender as OleMenuCommand;

            if (command == null)
            {
                return;
            }

            switch ((CommandId)command.CommandID.ID)
            {
            case CommandId.ImportPriFileProjectId:
                ExtLoader.ImportPriFile(HelperFunctions.GetSelectedQtProject(Vsix.Instance.Dte));
                break;

            case CommandId.ExportPriFileProjectId:
                ExtLoader.ExportPriFile();
                break;

            case CommandId.ExportProFileProjectId:
                ExtLoader.ExportProFile();
                break;

            case CommandId.CreateNewTsFileProjectId:
                Translation.CreateNewTranslationFile(HelperFunctions.GetSelectedQtProject(Vsix
                                                                                          .Instance.Dte));
                break;

            case CommandId.lUpdateOnProjectId:
                Translation.RunlUpdate(HelperFunctions.GetSelectedQtProject(Vsix.Instance.Dte));
                break;

            case CommandId.lReleaseOnProjectId:
                Translation.RunlRelease(HelperFunctions.GetSelectedQtProject(Vsix.Instance.Dte));
                break;

            case CommandId.ConvertToQtProjectId:
            case CommandId.ConvertToQmakeProjectId:
            {
                var caption = SR.GetString("ConvertTitle");
                var text    = SR.GetString("ConvertConfirmation");
                if (MessageBox.Show(text, caption, MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    HelperFunctions.ToggleProjectKind(HelperFunctions.GetSelectedProject(Vsix
                                                                                         .Instance.Dte));
                }
            }
            break;

            case CommandId.QtProjectSettingsProjectId:
            {
                var pro = HelperFunctions.GetSelectedQtProject(Vsix.Instance.Dte);
                if (pro != null)
                {
                    using (var formProjectQtSettings = new FormProjectQtSettings()) {
                        formProjectQtSettings.SetProject(pro);
                        formProjectQtSettings.StartPosition = FormStartPosition.CenterParent;
                        var ww = new MainWinWrapper(Vsix.Instance.Dte);
                        formProjectQtSettings.ShowDialog(ww);
                    }
                }
                else
                {
                    MessageBox.Show(SR.GetString("NoProjectOpened"));
                }
            }
            break;

            case CommandId.ChangeProjectQtVersionProjectId:
            {
                var pro = HelperFunctions.GetSelectedQtProject(Vsix.Instance.Dte);
                if (HelperFunctions.IsQMakeProject(pro))
                {
                    using (var formChangeQtVersion = new FormChangeQtVersion()) {
                        formChangeQtVersion.UpdateContent(ChangeFor.Project);
                        var ww = new MainWinWrapper(Vsix.Instance.Dte);
                        if (formChangeQtVersion.ShowDialog(ww) == DialogResult.OK)
                        {
                            var qtVersion = formChangeQtVersion.GetSelectedQtVersion();
                            HelperFunctions.SetDebuggingEnvironment(pro, "PATH=" + QtVersionManager
                                                                    .The().GetInstallPath(qtVersion) + @"\bin;$(PATH)", true);
                        }
                    }
                }
            }
            break;

            case CommandId.ProjectAddNewQtClassProjectId:
            {
                try {
                    var project = HelperFunctions.GetSelectedProject(Vsix.Instance.Dte);
                    if (!HelperFunctions.IsQtProject(project))
                    {
                        return;
                    }

                    var vcProject = project.Object as VCProject;
                    if (vcProject == null)
                    {
                        return;
                    }

                    var loop = true;
                    do
                    {
                        var classWizard = new AddClassWizard();
                        loop = classWizard.Run(Vsix.Instance.Dte, vcProject.Name,
                                               vcProject.ProjectDirectory) == WizardResult.Exception;
                    } while (loop);
                } catch {
                    // Deliberately ignore any kind of exception but close the dialog.
                }
            }
            break;
            }
        }
Beispiel #4
0
        private void execHandler(object sender, EventArgs e)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            var command = sender as OleMenuCommand;

            if (command == null)
            {
                return;
            }

            switch ((CommandId)command.CommandID.ID)
            {
            case CommandId.ViewQtHelpId:
                VsShellUtilities.OpenSystemBrowser("https://www.qt.io/developers");
                break;

            case CommandId.LaunchDesignerId:
                QtVsToolsPackage.Instance.QtDesigner.Start(hideWindow: false);
                break;

            case CommandId.LaunchLinguistId:
                QtVsToolsPackage.Instance.QtLinguist.Start(hideWindow: false);
                break;

            case CommandId.OpenProFileId:
                ExtLoader.ImportProFile();
                break;

            case CommandId.ImportPriFileId:
                ExtLoader.ImportPriFile(HelperFunctions.GetSelectedQtProject(QtVsToolsPackage.Instance.Dte));
                break;

            case CommandId.ExportPriFileId:
                ExtLoader.ExportPriFile();
                break;

            case CommandId.ExportProFileId:
                ExtLoader.ExportProFile();
                break;

            case CommandId.ConvertToQtId:
            case CommandId.ConvertToQmakeId: {
                var caption = SR.GetString("ConvertTitle");
                var text    = SR.GetString("ConvertConfirmation");
                if (MessageBox.Show(text, caption, MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    HelperFunctions.ToggleProjectKind(HelperFunctions.GetSelectedProject(QtVsToolsPackage
                                                                                         .Instance.Dte));
                }
            }
            break;

            case CommandId.ConvertToQtMsBuild: {
                QtMsBuildConverter.SolutionToQtMsBuild();
            }
            break;

            case CommandId.QtProjectSettingsId: {
                var pro            = HelperFunctions.GetSelectedQtProject(QtVsToolsPackage.Instance.Dte);
                int projectVersion = QtProject.GetFormatVersion(pro);
                if (projectVersion >= Resources.qtMinFormatVersion_Settings)
                {
                    QtVsToolsPackage.Instance.Dte.ExecuteCommand("Project.Properties");
                }
                else if (pro != null)
                {
                    using (var formProjectQtSettings = new FormProjectQtSettings()) {
                        formProjectQtSettings.SetProject(pro);
                        formProjectQtSettings.StartPosition = FormStartPosition.CenterParent;
                        var ww = new MainWinWrapper(QtVsToolsPackage.Instance.Dte);
                        formProjectQtSettings.ShowDialog(ww);
                    }
                }
                else
                {
                    MessageBox.Show(SR.GetString("NoProjectOpened"));
                }
            }
            break;

            case CommandId.ChangeProjectQtVersionId: {
                var pro = HelperFunctions.GetSelectedQtProject(QtVsToolsPackage.Instance.Dte);
                if (HelperFunctions.IsQMakeProject(pro))
                {
                    using (var formChangeQtVersion = new FormChangeQtVersion()) {
                        formChangeQtVersion.UpdateContent(ChangeFor.Project);
                        var ww = new MainWinWrapper(QtVsToolsPackage.Instance.Dte);
                        if (formChangeQtVersion.ShowDialog(ww) == DialogResult.OK)
                        {
                            var qtVersion = formChangeQtVersion.GetSelectedQtVersion();
                            HelperFunctions.SetDebuggingEnvironment(pro, "PATH=" + QtVersionManager
                                                                    .The().GetInstallPath(qtVersion) + @"\bin;$(PATH)", true);
                        }
                    }
                }
            }
            break;

            case CommandId.QtOptionsId:
                QtVsToolsPackage.Instance.ShowOptionPage(typeof(Options.QtOptionsPage));
                break;

            case CommandId.QtVersionsId:
                QtVsToolsPackage.Instance.ShowOptionPage(typeof(Options.QtVersionsPage));
                break;
            }
        }