Example #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"));
            }
        }
Example #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"));
            }
        }
Example #3
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
            }
        }