示例#1
0
        public static void loadAssistant()
        {
            string qtVersion = null;

            QtVersionManager vm = QtVersionManager.The(HelperFunctions.GetSolutionPlaformName(Connect._applicationObject.Solution));

            Project prj = HelperFunctions.GetSelectedQtProject(Connect._applicationObject);

            if (prj != null)
            {
                vm.SetPlatform(prj.ConfigurationManager.ActiveConfiguration.PlatformName);
                qtVersion = vm.GetProjectQtVersion(prj);
                if (qtVersion == null)
                {
                    qtVersion = vm.GetSolutionQtVersion(Connect._applicationObject.Solution);
                }
            }
            else
            {
                prj = HelperFunctions.GetSelectedProject(Connect._applicationObject);
                if (prj != null && HelperFunctions.IsQMakeProject(prj))
                {
                    string qmakeQtDir = HelperFunctions.GetQtDirFromQMakeProject(prj);
                    qtVersion = vm.GetQtVersionFromInstallDir(qmakeQtDir);
                }
                if (qtVersion == null)
                {
                    qtVersion = vm.GetSolutionQtVersion(Connect._applicationObject.Solution);
                }
            }

            string qtDir = HelperFunctions.FindQtDirWithTools("assistant", qtVersion);

            if (qtDir == null || qtDir.Length == 0)
            {
                MessageBox.Show(SR.GetString("NoDefaultQtVersionError"),
                                Resources.msgBoxCaption);
                return;
            }

            try
            {
                string workingDir = qtDir;
                string arguments  = null;
                string options    = QtVSIPSettings.GetAssistantOptions(prj);
                if (options != null && options != "")
                {
                    arguments = options;
                }
                System.Diagnostics.Process tmp = getQtApplicationProcess("assistant", arguments, workingDir, qtDir);
                tmp.Start();
            }
            catch
            {
                MessageBox.Show(SR.GetString("QtAppNotFoundErrorMessage", "Qt Assistant"),
                                SR.GetString("QtAppNotFoundErrorTitle", "Assistant"));
            }
        }
示例#2
0
        public static void loadLinguist(string fileName)
        {
            Project          prj       = HelperFunctions.GetSelectedQtProject(Connect._applicationObject);
            string           qtVersion = null;
            QtVersionManager vm        = QtVersionManager.The();

            if (prj != null)
            {
                qtVersion = vm.GetProjectQtVersion(prj);
            }
            else
            {
                prj = HelperFunctions.GetSelectedProject(Connect._applicationObject);
                if (prj != null && HelperFunctions.IsQMakeProject(prj))
                {
                    string qmakeQtDir = HelperFunctions.GetQtDirFromQMakeProject(prj);
                    qtVersion = vm.GetQtVersionFromInstallDir(qmakeQtDir);
                }
            }
            string qtDir = HelperFunctions.FindQtDirWithTools("linguist", qtVersion);

            if (qtDir == null || qtDir.Length == 0)
            {
                MessageBox.Show(SR.GetString("NoDefaultQtVersionError"),
                                Resources.msgBoxCaption);
                return;
            }

            try
            {
                string workingDir = null;
                string arguments  = null;
                if (fileName != null)
                {
                    workingDir = Path.GetDirectoryName(fileName);
                    arguments  = fileName;
                    if (!arguments.StartsWith("\""))
                    {
                        arguments = "\"" + arguments;
                    }
                    if (!arguments.EndsWith("\""))
                    {
                        arguments += "\"";
                    }
                }

                System.Diagnostics.Process tmp = getQtApplicationProcess("linguist", arguments, workingDir, qtDir);
                tmp.Start();
            }
            catch
            {
                MessageBox.Show(SR.GetString("QtAppNotFoundErrorMessage", "Qt Linguist"),
                                SR.GetString("QtAppNotFoundErrorTitle", "Linguist"));
            }
        }
示例#3
0
        public void OnBuildProjConfigBegin(string projectName, string projectConfig, string platform, string solutionConfig)
        {
            if (currentBuildAction != vsBuildAction.vsBuildActionBuild &&
                currentBuildAction != vsBuildAction.vsBuildActionRebuildAll)
            {
                return;     // Don't do anything, if we're not building.
            }

            EnvDTE.Project project = null;
            foreach (EnvDTE.Project p in HelperFunctions.ProjectsInSolution(dte))
            {
                if (p.UniqueName == projectName)
                {
                    project = p;
                    break;
                }
            }
            if (project == null || !HelperFunctions.IsQtProject(project))
            {
                return;
            }

            QtProject        qtpro          = QtProject.Create(project);
            QtVersionManager versionManager = QtVersionManager.The();
            string           qtVersion      = versionManager.GetProjectQtVersion(project, platform);

            if (qtVersion == null)
            {
                Messages.DisplayCriticalErrorMessage(SR.GetString("ProjectQtVersionNotFoundError", platform));
                dte.ExecuteCommand("Build.Cancel", "");
                return;
            }

            if (!QtVSIPSettings.GetDisableAutoMocStepsUpdate())
            {
                if (qtpro.ConfigurationRowNamesChanged)
                {
                    qtpro.UpdateMocSteps(QtVSIPSettings.GetMocDirectory(project));
                }
            }

            // Solution config is given to function to get QTDIR property
            // set correctly also during batch build
            qtpro.SetQtEnvironment(qtVersion, solutionConfig);
            if (QtVSIPSettings.GetLUpdateOnBuild(project))
            {
                Translation.RunlUpdate(project);
            }
        }
        public QtVersionDialog(EnvDTE.DTE dte)
        {
            dteObj = dte;
            QtVersionManager vM = QtVersionManager.The();

            InitializeComponent();

            this.cancelButton.Text = SR.GetString(SR.Cancel);
            this.okButton.Text     = SR.GetString(SR.OK);
            this.groupBox1.Text    = SR.GetString("QtVersionDialog_BoxTitle");
            this.Text = SR.GetString("QtVersionDialog_Title");

            this.versionComboBox.Items.AddRange(vM.GetVersions());
            if (this.versionComboBox.Items.Count > 0)
            {
                string defVersion = vM.GetSolutionQtVersion(dteObj.Solution);
                if (defVersion != null && defVersion.Length > 0)
                {
                    this.versionComboBox.Text = defVersion;
                }
                else if (dte.Solution != null && HelperFunctions.ProjectsInSolution(dte) != null)
                {
                    IEnumerator prjEnum = HelperFunctions.ProjectsInSolution(dte).GetEnumerator();
                    prjEnum.Reset();
                    if (prjEnum.MoveNext())
                    {
                        EnvDTE.Project prj = prjEnum.Current as EnvDTE.Project;
                        defVersion = vM.GetProjectQtVersion(prj);
                    }
                }
                if (defVersion != null && defVersion.Length > 0)
                {
                    this.versionComboBox.Text = defVersion;
                }
                else
                {
                    this.versionComboBox.Text = (string)this.versionComboBox.Items[0];
                }
            }

            //if (SR.LanguageName == "ja")
            //{
            //    this.cancelButton.Location = new System.Drawing.Point(224, 72);
            //    this.cancelButton.Size = new Size(80, 22);
            //    this.okButton.Location = new System.Drawing.Point(138, 72);
            //    this.okButton.Size = new Size(80, 22);
            //}
            this.KeyPress += new KeyPressEventHandler(this.QtVersionDialog_KeyPress);
        }
        public void UpdateContent(ChangeFor change)
        {
            lbQtVersions.Items.Clear();
            QtVersionManager vm = QtVersionManager.The();

            foreach (string versionName in vm.GetVersions())
            {
                lbQtVersions.Items.Add(versionName);
            }
            lbQtVersions.Items.Add("$(DefaultQtVersion)");
            string qtVer = null;

            if (change == ChangeFor.Solution)
            {
                qtVer = vm.GetSolutionQtVersion(Connect._applicationObject.Solution);
                if (qtVer == null)
                {
                    qtVer = vm.GetDefaultVersion();
                }
                if (qtVer != null)
                {
                    lbQtVersions.SelectedItem = qtVer;
                }
                this.Text = SR.GetString("SolutionQtVersion");
            }
            else
            {
                Project pro = HelperFunctions.GetSelectedProject(Connect._applicationObject);
                qtVer = vm.GetProjectQtVersion(pro);
                if (qtVer == null)
                {
                    qtVer = vm.GetDefaultVersion();
                }
                if (qtVer != null)
                {
                    lbQtVersions.SelectedItem = qtVer;
                }
                this.Text = SR.GetString("ProjectQtVersion");
            }
        }
示例#6
0
        public void loadDesigner(string fileName)
        {
            Project          prj       = HelperFunctions.GetSelectedQtProject(Connect._applicationObject);
            string           qtVersion = null;
            QtVersionManager vm        = QtVersionManager.The();

            if (prj != null)
            {
                qtVersion = vm.GetProjectQtVersion(prj);
            }
            else
            {
                prj = HelperFunctions.GetSelectedProject(Connect._applicationObject);
                if (prj != null && HelperFunctions.IsQMakeProject(prj))
                {
                    string qmakeQtDir = HelperFunctions.GetQtDirFromQMakeProject(prj);
                    qtVersion = vm.GetQtVersionFromInstallDir(qmakeQtDir);
                }
            }
            string qtDir = HelperFunctions.FindQtDirWithTools("designer", qtVersion);

            if (qtDir == null || qtDir.Length == 0)
            {
                MessageBox.Show(SR.GetString("NoDefaultQtVersionError"),
                                Resources.msgBoxCaption);
                return;
            }

            try
            {
                if (!designerDict.ContainsKey(qtDir) || designerDict[qtDir].process.HasExited)
                {
                    string workingDir, formFile;
                    if (fileName == null)
                    {
                        formFile   = "";
                        workingDir = (prj == null) ? null : Path.GetDirectoryName(prj.FullName);
                    }
                    else
                    {
                        formFile   = fileName;
                        workingDir = Path.GetDirectoryName(fileName);
                        if (!formFile.StartsWith("\""))
                        {
                            formFile = "\"" + formFile;
                        }
                        if (!formFile.EndsWith("\""))
                        {
                            formFile += "\"";
                        }
                    }

                    string launchCMD = "-server " + formFile;
                    System.Diagnostics.Process tmp = getQtApplicationProcess("designer", launchCMD, workingDir, qtDir);
                    tmp.StartInfo.UseShellExecute        = false;
                    tmp.StartInfo.RedirectStandardOutput = true;
                    tmp.OutputDataReceived += new DataReceivedEventHandler(designerOutputHandler);
                    tmp.Start();
                    tmp.BeginOutputReadLine();
                    try
                    {
                        portFound.WaitOne(5000, false);
                    }
                    catch (Exception e)
                    {
                        MessageBox.Show(e.Message);
                    }
                    tmp.WaitForInputIdle();
                    DesignerData data;
                    data.process = tmp;
                    data.port    = designerPort;
                    portFound.Reset();
                    designerDict[qtDir] = data;
                }
                else if (fileName != null)
                {
                    try
                    {
                        TcpClient c = new TcpClient("127.0.0.1", designerDict[qtDir].port);
                        System.Text.UTF8Encoding enc = new System.Text.UTF8Encoding();
                        byte[] bArray = enc.GetBytes(fileName + "\n");
                        Stream stream = c.GetStream();
                        stream.Write(bArray, 0, bArray.Length);
                        c.Close();
                        stream.Close();
                    }
                    catch
                    {
                        Messages.DisplayErrorMessage(SR.GetString("DesignerAddError"));
                    }
                }
            }
            catch
            {
                MessageBox.Show(SR.GetString("QtAppNotFoundErrorMessage", "Qt Designer"),
                                SR.GetString("QtAppNotFoundErrorTitle", "Designer"));
                return;
            }
            try
            {
                if ((int)designerDict[qtDir].process.MainWindowHandle == 0)
                {
                    System.Diagnostics.Process prc = System.Diagnostics.Process.GetProcessById(designerDict[qtDir].process.Id);
                    if ((int)prc.MainWindowHandle != 0)
                    {
                        DesignerData data;
                        data.process        = prc;
                        data.port           = designerDict[qtDir].port;
                        designerDict[qtDir] = data;
                    }
                }
                SwitchToThisWindow(designerDict[qtDir].process.MainWindowHandle, true);
            }
            catch
            {
                // silent
            }
        }
示例#7
0
        public void Exec(string commandName,
                         EnvDTE.vsCommandExecOption executeOption,
                         ref object varIn,
                         ref object varOut,
                         ref bool handled)
        {
            try
            {
                handled = false;
                if (executeOption == EnvDTE.vsCommandExecOption.vsCommandExecOptionDoDefault)
                {
                    switch (commandName)
                    {
                    case Res.LaunchDesignerFullCommand:
                        handled = true;
                        extLoader.loadDesigner(null);
                        break;

                    case Res.LaunchLinguistFullCommand:
                        handled = true;
                        ExtLoader.loadLinguist(null);
                        break;

                    case Res.LaunchAssistantFullCommand:
                        handled = true;
                        ExtLoader.loadAssistant();
                        break;

                    case Res.ImportProFileFullCommand:
                        handled = true;
                        ExtLoader.ImportProFile();
                        break;

                    case Res.ImportPriFileFullCommand:
                        handled = true;
                        ExtLoader.ImportPriFile(HelperFunctions.GetSelectedQtProject(_applicationObject));
                        break;

                    case Res.ExportPriFileFullCommand:
                        handled = true;
                        ExtLoader.ExportPriFile();
                        break;

                    case Res.ExportProFileFullCommand:
                        handled = true;
                        ExtLoader.ExportProFile();
                        break;

                    case Res.ChangeSolutionQtVersionFullCommand:
                        QtVersionManager vManager = QtVersionManager.The();
                        if (formChangeQtVersion == null)
                        {
                            formChangeQtVersion = new FormChangeQtVersion();
                        }
                        formChangeQtVersion.UpdateContent(ChangeFor.Solution);
                        if (formChangeQtVersion.ShowDialog() == DialogResult.OK)
                        {
                            string newQtVersion = formChangeQtVersion.GetSelectedQtVersion();
                            if (newQtVersion != null)
                            {
                                string currentPlatform = null;
                                try
                                {
                                    SolutionConfiguration  config  = _applicationObject.Solution.SolutionBuild.ActiveConfiguration;
                                    SolutionConfiguration2 config2 = config as SolutionConfiguration2;
                                    currentPlatform = config2.PlatformName;
                                }
                                catch
                                {
                                }
                                if (string.IsNullOrEmpty(currentPlatform))
                                {
                                    return;
                                }

                                vManager.SetPlatform(currentPlatform);

                                foreach (Project project in HelperFunctions.ProjectsInSolution(_applicationObject))
                                {
                                    if (HelperFunctions.IsQt5Project(project))
                                    {
                                        string OldQtVersion = vManager.GetProjectQtVersion(project, currentPlatform);
                                        if (OldQtVersion == null)
                                        {
                                            OldQtVersion = vManager.GetDefaultVersion();
                                        }

                                        QtProject qtProject         = QtProject.Create(project);
                                        bool      newProjectCreated = false;
                                        qtProject.ChangeQtVersion(OldQtVersion, newQtVersion, ref newProjectCreated);
                                    }
                                }
                                vManager.SaveSolutionQtVersion(_applicationObject.Solution, newQtVersion);
                            }
                        }
                        break;

                    case Res.ProjectQtSettingsFullCommand:
                        handled = true;
                        EnvDTE.DTE dte = _applicationObject;
                        Project    pro = HelperFunctions.GetSelectedQtProject(dte);
                        if (pro != null)
                        {
                            if (formProjectQtSettings == null)
                            {
                                formProjectQtSettings = new FormProjectQtSettings();
                            }
                            formProjectQtSettings.SetProject(pro);
                            formProjectQtSettings.StartPosition = FormStartPosition.CenterParent;
                            MainWinWrapper ww = new MainWinWrapper(dte);
                            formProjectQtSettings.ShowDialog(ww);
                        }
                        else
                        {
                            MessageBox.Show(SR.GetString("NoProjectOpened"));
                        }
                        break;

                    case Res.ChangeProjectQtVersionFullCommand:
                        handled = true;
                        dte     = _applicationObject;
                        pro     = HelperFunctions.GetSelectedProject(dte);
                        if (pro != null && HelperFunctions.IsQMakeProject(pro))
                        {
                            if (formChangeQtVersion == null)
                            {
                                formChangeQtVersion = new FormChangeQtVersion();
                            }
                            formChangeQtVersion.UpdateContent(ChangeFor.Project);
                            MainWinWrapper ww = new MainWinWrapper(dte);
                            if (formChangeQtVersion.ShowDialog(ww) == DialogResult.OK)
                            {
                                string           qtVersion = formChangeQtVersion.GetSelectedQtVersion();
                                QtVersionManager vm        = QtVersionManager.The();
                                string           qtPath    = vm.GetInstallPath(qtVersion);
                                HelperFunctions.SetDebuggingEnvironment(pro, "PATH=" + qtPath + "\\bin;$(PATH)", true);
                            }
                        }
                        break;

                    case Res.VSQtOptionsFullCommand:
                        handled = true;
                        if (formQtVersions == null)
                        {
                            formQtVersions = new FormVSQtSettings();
                            formQtVersions.LoadSettings();
                        }
                        formQtVersions.StartPosition = FormStartPosition.CenterParent;
                        MainWinWrapper mww = new MainWinWrapper(_applicationObject);
                        if (formQtVersions.ShowDialog(mww) == DialogResult.OK)
                        {
                            formQtVersions.SaveSettings();
                        }
                        break;

                    case Res.CreateNewTranslationFileFullCommand:
                        handled = true;
                        pro     = HelperFunctions.GetSelectedQtProject(_applicationObject);
                        Translation.CreateNewTranslationFile(pro);
                        break;

                    case Res.CommandBarName + ".Connect.lupdate":
                        handled = true;
                        Translation.RunlUpdate(HelperFunctions.GetSelectedFiles(_applicationObject),
                                               HelperFunctions.GetSelectedQtProject(_applicationObject));
                        break;

                    case Res.CommandBarName + ".Connect.lrelease":
                        handled = true;
                        Translation.RunlRelease(HelperFunctions.GetSelectedFiles(_applicationObject));
                        break;

                    case Res.lupdateProjectFullCommand:
                        handled = true;
                        pro     = HelperFunctions.GetSelectedQtProject(Connect._applicationObject);
                        Translation.RunlUpdate(pro);
                        break;

                    case Res.lreleaseProjectFullCommand:
                        handled = true;
                        pro     = HelperFunctions.GetSelectedQtProject(Connect._applicationObject);
                        Translation.RunlRelease(pro);
                        break;

                    case Res.lupdateSolutionFullCommand:
                        handled = true;
                        Translation.RunlUpdate(Connect._applicationObject.Solution);
                        break;

                    case Res.lreleaseSolutionFullCommand:
                        handled = true;
                        Translation.RunlRelease(Connect._applicationObject.Solution);
                        break;

                    case Res.ConvertToQtFullCommand:
                    case Res.ConvertToQMakeFullCommand:
                        if (MessageBox.Show(SR.GetString("ConvertConfirmation"), SR.GetString("ConvertTitle"), MessageBoxButtons.YesNo) == DialogResult.Yes)
                        {
                            handled = true;
                            dte     = _applicationObject;
                            pro     = HelperFunctions.GetSelectedProject(dte);
                            HelperFunctions.ToggleProjectKind(pro);
                        }
                        break;
                    }
                }
            }
            catch (System.Exception e)
            {
                MessageBox.Show(e.Message + "\r\n\r\nStacktrace:\r\n" + e.StackTrace);
            }
        }