Ejemplo n.º 1
0
 public VSQtSettings()
 {
     newMocDir                    = QtVSIPSettings.GetMocDirectory();
     newMocOptions                = QtVSIPSettings.GetMocOptions();
     newRccDir                    = QtVSIPSettings.GetRccDirectory();
     newUicDir                    = QtVSIPSettings.GetUicDirectory();
     newLUpdateOnBuild            = QtVSIPSettings.GetLUpdateOnBuild();
     newLUpdateOptions            = QtVSIPSettings.GetLUpdateOptions();
     newLReleaseOptions           = QtVSIPSettings.GetLReleaseOptions();
     newAskBeforeCheckoutFile     = QtVSIPSettings.GetAskBeforeCheckoutFile();
     newDisableCheckoutFiles      = QtVSIPSettings.GetDisableCheckoutFiles();
     newDisableAutoMOCStepsUpdate = QtVSIPSettings.GetDisableAutoMocStepsUpdate();
 }
Ejemplo n.º 2
0
 public ProjectQtSettings(EnvDTE.Project proj)
 {
     versionManager     = QtVersionManager.The();
     project            = proj;
     newMocDir          = oldMocDir = QtVSIPSettings.GetMocDirectory(project);
     newMocOptions      = oldMocOptions = QtVSIPSettings.GetMocOptions(project);
     newRccDir          = oldRccDir = QtVSIPSettings.GetRccDirectory(project);
     newUicDir          = oldUicDir = QtVSIPSettings.GetUicDirectory(project);
     newLUpdateOnBuild  = oldLUpdateOnBuild = QtVSIPSettings.GetLUpdateOnBuild(project);
     newLUpdateOptions  = oldLUpdateOptions = QtVSIPSettings.GetLUpdateOptions(project);
     newLReleaseOptions = oldLReleaseOptions = QtVSIPSettings.GetLReleaseOptions(project);
     newQtVersion       = oldQtVersion = versionManager.GetProjectQtVersion(project);
 }
Ejemplo n.º 3
0
        public VSQtSettings()
        {
            newMocDir                    = QtVSIPSettings.GetMocDirectory();
            newMocOptions                = QtVSIPSettings.GetMocOptions();
            newRccDir                    = QtVSIPSettings.GetRccDirectory();
            newUicDir                    = QtVSIPSettings.GetUicDirectory();
            newLUpdateOnBuild            = QtVSIPSettings.GetLUpdateOnBuild();
            newLUpdateOptions            = QtVSIPSettings.GetLUpdateOptions();
            newLReleaseOptions           = QtVSIPSettings.GetLReleaseOptions();
            newAskBeforeCheckoutFile     = QtVSIPSettings.GetAskBeforeCheckoutFile();
            newDisableCheckoutFiles      = QtVSIPSettings.GetDisableCheckoutFiles();
            newDisableAutoMOCStepsUpdate = QtVSIPSettings.GetDisableAutoMocStepsUpdate();

            var settingsManager = new ShellSettingsManager(Vsix.Instance);
            var store           = settingsManager.GetReadOnlySettingsStore(SettingsScope.UserSettings);

#if VS2013
            EnableQmlClassifier = store.GetBoolean(Statics.QmlClassifierPath,
                                                   Statics.QmlClassifierKey, true);
#else
            EnableQmlTextMate = store.GetBoolean(Statics.QmlTextMatePath,
                                                 Statics.QmlTextMateKey, true);
#endif
        }
Ejemplo n.º 4
0
        public static bool RunlUpdate(VCFile vcFile, EnvDTE.Project pro)
        {
            if (!HelperFunctions.IsQtProject(pro))
            {
                return(false);
            }

            string cmdLine = "";
            string options = QtVSIPSettings.GetLUpdateOptions(pro);

            if (!string.IsNullOrEmpty(options))
            {
                cmdLine += options + " ";
            }
            List <string> headers = HelperFunctions.GetProjectFiles(pro, FilesToList.FL_HFiles);
            List <string> sources = HelperFunctions.GetProjectFiles(pro, FilesToList.FL_CppFiles);
            List <string> uifiles = HelperFunctions.GetProjectFiles(pro, FilesToList.FL_UiFiles);

            foreach (string file in headers)
            {
                cmdLine += file + " ";
            }

            foreach (string file in sources)
            {
                cmdLine += file + " ";
            }

            foreach (string file in uifiles)
            {
                cmdLine += file + " ";
            }

            cmdLine += "-ts " + vcFile.RelativePath;

            int    cmdLineLength    = cmdLine.Length + Resources.lupdateCommand.Length + 1;
            string temporaryProFile = null;

            if (cmdLineLength > HelperFunctions.GetMaximumCommandLineLength())
            {
                string codec = "";
                if (!string.IsNullOrEmpty(options))
                {
                    int cc4tr_location = options.IndexOf("-codecfortr", System.StringComparison.CurrentCultureIgnoreCase);
                    if (cc4tr_location != -1)
                    {
                        codec = options.Substring(cc4tr_location).Split(' ')[1];
                        string remove_this = options.Substring(cc4tr_location, "-codecfortr".Length + 1 + codec.Length);
                        options = options.Replace(remove_this, "");
                    }
                }
                VCProject vcPro = (VCProject)pro.Object;
                temporaryProFile = System.IO.Path.GetTempFileName();
                temporaryProFile = System.IO.Path.GetDirectoryName(temporaryProFile) + "\\" +
                                   System.IO.Path.GetFileNameWithoutExtension(temporaryProFile) + ".pro";
                if (System.IO.File.Exists(temporaryProFile))
                {
                    System.IO.File.Delete(temporaryProFile);
                }
                System.IO.StreamWriter sw = new System.IO.StreamWriter(temporaryProFile);
                writeFilesToPro(sw, "HEADERS",
                                ProjectExporter.ConvertFilesToFullPath(headers, vcPro.ProjectDirectory));
                writeFilesToPro(sw, "SOURCES",
                                ProjectExporter.ConvertFilesToFullPath(sources, vcPro.ProjectDirectory));
                writeFilesToPro(sw, "FORMS",
                                ProjectExporter.ConvertFilesToFullPath(uifiles, vcPro.ProjectDirectory));

                List <string> tsFiles = new List <string>(1);
                tsFiles.Add(vcFile.FullPath);
                writeFilesToPro(sw, "TRANSLATIONS", tsFiles);

                if (!string.IsNullOrEmpty(codec))
                {
                    sw.WriteLine("CODECFORTR = " + codec);
                }
                sw.Close();

                cmdLine = "";
                if (!string.IsNullOrEmpty(options))
                {
                    cmdLine += options + " ";
                }
                cmdLine += "\"" + temporaryProFile + "\"";
            }

            bool success = true;

            try
            {
                Messages.PaneMessage(pro.DTE, "--- (lupdate) file: " + vcFile.FullPath);

                HelperFunctions.StartExternalQtApplication(Resources.lupdateCommand, cmdLine,
                                                           ((VCProject)vcFile.project).ProjectDirectory, pro, true, null);
            }
            catch (QtVSException e)
            {
                success = false;
                Messages.DisplayErrorMessage(e.Message);
            }

            if (temporaryProFile != null && System.IO.File.Exists(temporaryProFile))
            {
                System.IO.File.Delete(temporaryProFile);
                temporaryProFile  = temporaryProFile.Substring(0, temporaryProFile.Length - 3);
                temporaryProFile += "TMP";
                if (System.IO.File.Exists(temporaryProFile))
                {
                    System.IO.File.Delete(temporaryProFile);
                }
            }

            return(success);
        }
Ejemplo n.º 5
0
        public static bool RunlUpdate(VCFile vcFile, EnvDTE.Project pro)
        {
            if (vcFile == null || pro == null)
            {
                return(false);
            }

            if (!HelperFunctions.IsQtProject(pro))
            {
                return(false);
            }

            var cmdLine = string.Empty;
            var options = QtVSIPSettings.GetLUpdateOptions(pro);

            if (!string.IsNullOrEmpty(options))
            {
                cmdLine += options + " ";
            }
            var headers = HelperFunctions.GetProjectFiles(pro, FilesToList.FL_HFiles);
            var sources = HelperFunctions.GetProjectFiles(pro, FilesToList.FL_CppFiles);
            var uifiles = HelperFunctions.GetProjectFiles(pro, FilesToList.FL_UiFiles);

            StringBuilder fileNames = new StringBuilder();

            foreach (var file in headers)
            {
                fileNames.AppendLine(file);
            }

            foreach (var file in sources)
            {
                fileNames.AppendLine(file);
            }

            foreach (var file in uifiles)
            {
                fileNames.AppendLine(file);
            }

            var lstFilePath = Path.GetTempFileName();

            File.WriteAllText(lstFilePath, fileNames.ToString());
            cmdLine += string.Format("\"@{0}\" ", lstFilePath);
            cmdLine += "-ts " + vcFile.RelativePath.Quoute();

            var success = true;

            try {
                Messages.PaneMessage(pro.DTE, "--- (lupdate) file: " + vcFile.FullPath);
                StartProcess(Resources.lupdateCommand, cmdLine, (vcFile.project as VCProject)
                             .ProjectDirectory, pro);
            } catch (QtVSException e) {
                success = false;
                Messages.DisplayErrorMessage(e.Message);
            }

            if (File.Exists(lstFilePath))
            {
                File.Delete(lstFilePath);
            }

            return(success);
        }
Ejemplo n.º 6
0
        static void Legacy_RunTranslation(
            BuildAction buildAction,
            QtProject qtProject,
            string tsFile,
            ref string tempFile)
        {
            var qtVersion     = qtProject.GetQtVersion();
            var qtInstallPath = QtVersionManager.The().GetInstallPath(qtVersion);

            if (string.IsNullOrEmpty(qtInstallPath))
            {
                Messages.Print("translation: Error accessing Qt installation");
                return;
            }

            var procInfo = new ProcessStartInfo
            {
                WorkingDirectory       = qtProject.ProjectDir,
                CreateNoWindow         = true,
                UseShellExecute        = false,
                RedirectStandardError  = true,
                RedirectStandardOutput = true,
                Arguments = ""
            };

            switch (buildAction)
            {
            case BuildAction.Update:
                Messages.Print("\r\n--- (lupdate) file: " + tsFile);
                procInfo.FileName = Path.Combine(qtInstallPath, "bin", "lupdate.exe");
                var options = QtVSIPSettings.GetLUpdateOptions();
                if (!string.IsNullOrEmpty(options))
                {
                    procInfo.Arguments += options + " ";
                }
                if (tempFile == null)
                {
                    var inputFiles = GetProjectFiles(qtProject.Project, FilesToList.FL_HFiles)
                                     .Union(GetProjectFiles(qtProject.Project, FilesToList.FL_CppFiles))
                                     .Union(GetProjectFiles(qtProject.Project, FilesToList.FL_UiFiles))
                                     .Union(GetProjectFiles(qtProject.Project, FilesToList.FL_QmlFiles));
                    tempFile = Path.GetTempFileName();
                    File.WriteAllLines(tempFile, inputFiles);
                }
                procInfo.Arguments += string.Format("\"@{0}\" -ts \"{1}\"", tempFile, tsFile);
                break;

            case BuildAction.Release:
                Messages.Print("\r\n--- (lrelease) file: " + tsFile);
                procInfo.FileName = Path.Combine(qtInstallPath, "bin", "lrelease.exe");
                options           = QtVSIPSettings.GetLReleaseOptions();
                if (!string.IsNullOrEmpty(options))
                {
                    procInfo.Arguments += options + " ";
                }
                procInfo.Arguments += string.Format("\"{0}\"", tsFile);
                break;
            }
            using (var proc = Process.Start(procInfo)) {
                proc.OutputDataReceived += (object sender, DataReceivedEventArgs e) =>
                {
                    if (!string.IsNullOrEmpty(e.Data))
                    {
                        Messages.Print(e.Data);
                    }
                };
                proc.ErrorDataReceived += (object sender, DataReceivedEventArgs e) =>
                {
                    if (!string.IsNullOrEmpty(e.Data))
                    {
                        Messages.Print(e.Data);
                    }
                };
                proc.BeginOutputReadLine();
                proc.BeginErrorReadLine();
                proc.WaitForExit();
                switch (proc.ExitCode)
                {
                case 0:
                    Messages.Print("translation: ok");
                    break;

                default:
                    Messages.Print(string.Format("translation: ERROR {0}", proc.ExitCode));
                    break;
                }
            }
        }