private void UpdateListBox(string defaultQtVersionDir)
 {
     listView.Items.Clear();
     foreach (string version in versionManager.GetVersions())
     {
         string path = null;
         if (defaultQtVersionDir != null && version == "$(DefaultQtVersion)")
         {
             path = defaultQtVersionDir;
         }
         else
         {
             path = versionManager.GetInstallPath(version);
         }
         if (path == null && version != "$(QTDIR)")
         {
             continue;
         }
         ListViewItem itm = new ListViewItem();
         itm.Tag  = version;
         itm.Text = version;
         itm.SubItems.Add(path);
         listView.Items.Add(itm);
     }
 }
Exemple #2
0
        public static void ImportProFile()
        {
            QtVersionManager vm        = QtVersionManager.The();
            string           qtVersion = vm.GetDefaultVersion();
            string           qtDir     = vm.GetInstallPath(qtVersion);

            if (qtDir == null)
            {
                Messages.DisplayErrorMessage(SR.GetString("CannotFindQMake"));
                return;
            }
#if (VS2010 || VS2012 || VS2013)
            VersionInformation vi = new VersionInformation(qtDir);
            if (vi.qtMajor < 5)
            {
#if VS2010
                Messages.DisplayErrorMessage(SR.GetString("NoVS2010Support"));
#elif VS2012
                Messages.DisplayErrorMessage(SR.GetString("NoVS2012Support"));
#else
                Messages.DisplayErrorMessage(SR.GetString("NoVS2013Support"));
#endif
                return;
            }
#endif
            if (Connect._applicationObject != null)
            {
                ProjectImporter proFileImporter = new ProjectImporter(Connect._applicationObject);
                proFileImporter.ImportProFile(qtVersion);
            }
        }
Exemple #3
0
        private static System.Diagnostics.Process getQtApplicationProcess(string applicationName,
                                                                          string arguments,
                                                                          string workingDir,
                                                                          string givenQtDir)
        {
            if (!applicationName.ToLower().EndsWith(".exe"))
            {
                applicationName += ".exe";
            }

            System.Diagnostics.Process process = new System.Diagnostics.Process();
            process.StartInfo.Arguments   = arguments;
            process.StartInfo.WindowStyle = ProcessWindowStyle.Normal;

            if (givenQtDir != null && givenQtDir.Length > 0)
            {
                process.StartInfo.FileName         = givenQtDir + "\\bin\\" + applicationName;
                process.StartInfo.WorkingDirectory = workingDir;
            }
            if (!File.Exists(process.StartInfo.FileName) &&
                HelperFunctions.GetSelectedQtProject(Connect._applicationObject) != null)
            {   // Try to find apllication in project's Qt dir first
                string           path = null;
                QtVersionManager vm   = QtVersionManager.The();
                Project          prj  = HelperFunctions.GetSelectedQtProject(Connect._applicationObject);
                if (prj != null)
                {
                    path = vm.GetInstallPath(prj);
                }
                if (path != null)
                {
                    process.StartInfo.FileName         = path + "\\bin\\" + applicationName;
                    process.StartInfo.WorkingDirectory = workingDir;
                }
            }

            if (!File.Exists(process.StartInfo.FileName)) // Try with Path
            {
                process.StartInfo.FileName = HelperFunctions.FindFileInPATH(applicationName);
                if (workingDir != null)
                {
                    process.StartInfo.WorkingDirectory = workingDir;
                }
            }

            if (!File.Exists(process.StartInfo.FileName)) // try to start application of the default Qt version
            {
                QtVersionManager vm    = QtVersionManager.The();
                string           qtDir = vm.GetInstallPath(vm.GetDefaultVersion());
                process.StartInfo.FileName         = qtDir + "\\bin\\" + applicationName;
                process.StartInfo.WorkingDirectory = qtDir + "\\bin";
            }

            if (!File.Exists(process.StartInfo.FileName))
            {
                return(null);
            }

            return(process);
        }
Exemple #4
0
        private static string ResolveEnvironmentVariables(string str, EnvDTE.Project project)
        {
            string          env = null;
            string          val = null;
            Regex           reg = new Regex(@"\$\(([^\s\(\)]+)\)");
            MatchCollection col = reg.Matches(str);

            for (int i = 0; i < col.Count; ++i)
            {
                env = col[i].Groups[1].ToString();
                if (env == "QTDIR")
                {
                    QtVersionManager vm = QtVersionManager.The();
                    val = vm.GetInstallPath(project);
                    if (val == null)
                    {
                        val = System.Environment.GetEnvironmentVariable(env);
                    }
                }
                else
                {
                    val = System.Environment.GetEnvironmentVariable(env);
                }
                if (val == null)
                {
                    return(null);
                }
                str = str.Replace("$(" + env + ")", val);
            }
            return(str);
        }
Exemple #5
0
        private void InitModules()
        {
            QtVersionManager versionManager = QtVersionManager.The();
            string           qtVersion      = qtProject.GetQtVersion();
            string           install_path   = versionManager.GetInstallPath(qtVersion);

            for (int i = 0; i < moduleMap.Count; ++i)
            {
                ModuleMapItem item = moduleMap[i];
                item.initialValue     = qtProject.HasModule(item.moduleId);
                item.checkbox.Checked = item.initialValue;
                moduleMap[i]          = item;

                // Disable if module not installed
                QtModuleInfo info          = QtModules.Instance.ModuleInformation(item.moduleId);
                string       libraryPrefix = info.LibraryPrefix;
                if (libraryPrefix.StartsWith("Qt"))
                {
                    libraryPrefix = "Qt5" + libraryPrefix.Substring(2);
                }
                string             full_path = install_path + "\\lib\\" + libraryPrefix + ".lib";
                System.IO.FileInfo fi        = new System.IO.FileInfo(full_path);
                item.checkbox.Enabled = fi.Exists;
                if (fi.Exists == false)
                {
                    // Don't disable item if qtVersion not available
                    if (qtVersion != null)
                    {
                        item.checkbox.Checked = false;
                    }
                }
            }
        }
Exemple #6
0
        public static void ImportPriFile(EnvDTE.Project project, string fileName)
        {
            VCProject vcproj;

            if (!HelperFunctions.IsQtProject(project))
            {
                return;
            }

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

            QtVersionManager vm    = QtVersionManager.The();
            string           qtDir = vm.GetInstallPath(vm.GetDefaultVersion());

            if (qtDir == null)
            {
                Messages.DisplayErrorMessage(SR.GetString("CannotFindQMake"));
                return;
            }

            FileInfo priFileInfo = new FileInfo(fileName);

            QMakeWrapper qmake = new QMakeWrapper();

            qmake.setQtDir(qtDir);
            if (qmake.readFile(priFileInfo.FullName))
            {
                bool          flat      = qmake.isFlat();
                List <string> priFiles  = ResolveFilesFromQMake(qmake.sourceFiles(), project, priFileInfo.DirectoryName);
                List <string> projFiles = HelperFunctions.GetProjectFiles(project, FilesToList.FL_CppFiles);
                projFiles = ProjectExporter.ConvertFilesToFullPath(projFiles, vcproj.ProjectDirectory);
                ProjectExporter.SyncIncludeFiles(vcproj, priFiles, projFiles, project.DTE, flat, Filters.SourceFiles());

                priFiles  = ResolveFilesFromQMake(qmake.headerFiles(), project, priFileInfo.DirectoryName);
                projFiles = HelperFunctions.GetProjectFiles(project, FilesToList.FL_HFiles);
                projFiles = ProjectExporter.ConvertFilesToFullPath(projFiles, vcproj.ProjectDirectory);
                ProjectExporter.SyncIncludeFiles(vcproj, priFiles, projFiles, project.DTE, flat, Filters.HeaderFiles());

                priFiles  = ResolveFilesFromQMake(qmake.formFiles(), project, priFileInfo.DirectoryName);
                projFiles = HelperFunctions.GetProjectFiles(project, FilesToList.FL_UiFiles);
                projFiles = ProjectExporter.ConvertFilesToFullPath(projFiles, vcproj.ProjectDirectory);
                ProjectExporter.SyncIncludeFiles(vcproj, priFiles, projFiles, project.DTE, flat, Filters.FormFiles());

                priFiles  = ResolveFilesFromQMake(qmake.resourceFiles(), project, priFileInfo.DirectoryName);
                projFiles = HelperFunctions.GetProjectFiles(project, FilesToList.FL_Resources);
                projFiles = ProjectExporter.ConvertFilesToFullPath(projFiles, vcproj.ProjectDirectory);
                ProjectExporter.SyncIncludeFiles(vcproj, priFiles, projFiles, project.DTE, flat, Filters.ResourceFiles());
            }
            else
            {
                Messages.PaneMessage(project.DTE, "--- (Importing .pri file) file: "
                                     + priFileInfo + " could not be read.");
            }
        }
Exemple #7
0
 void SolutionEvents_ProjectAdded(Project project)
 {
     if (HelperFunctions.IsQMakeProject(project))
     {
         RegisterVCProjectEngineEvents(project);
         VCProject vcpro  = project.Object as VCProject;
         VCFilter  filter = null;
         foreach (VCFilter f in vcpro.Filters as IVCCollection)
         {
             if (f.Name == Filters.HeaderFiles().Name)
             {
                 filter = f;
                 break;
             }
         }
         if (filter != null)
         {
             foreach (VCFile file in filter.Files as IVCCollection)
             {
                 foreach (VCFileConfiguration config in file.FileConfigurations as IVCCollection)
                 {
                     VCCustomBuildTool tool = HelperFunctions.GetCustomBuildTool(config);
                     if (tool != null && tool.CommandLine != null && tool.CommandLine.Contains("moc.exe"))
                     {
                         Regex           reg     = new Regex("[^ ^\n]+moc\\.exe");
                         MatchCollection matches = reg.Matches(tool.CommandLine);
                         string          qtDir   = null;
                         if (matches.Count != 1)
                         {
                             QtVersionManager vm = QtVersionManager.The();
                             qtDir = vm.GetInstallPath(vm.GetDefaultVersion());
                         }
                         else
                         {
                             qtDir = matches[0].ToString();
                             qtDir = qtDir.Remove(qtDir.LastIndexOf("\\"));
                             qtDir = qtDir.Remove(qtDir.LastIndexOf("\\"));
                         }
                         qtDir = qtDir.Replace("_(QTDIR)", "$(QTDIR)");
                         HelperFunctions.SetDebuggingEnvironment(project, "PATH=" + qtDir + "\\bin;$(PATH)", false);
                     }
                 }
             }
         }
     }
 }
Exemple #8
0
        private void changeProjectQtVersion(object sender, EventArgs e)
        {
            var project = HelperFunctions.GetSelectedProject(VSPackage.dte);

            if (project != null && HelperFunctions.IsQMakeProject(project))
            {
                if (formChangeQtVersion == null)
                {
                    formChangeQtVersion = new FormChangeQtVersion();
                }
                formChangeQtVersion.UpdateContent(ChangeFor.Project);
                var ww = new MainWinWrapper(VSPackage.dte);
                if (formChangeQtVersion.ShowDialog(ww) == DialogResult.OK)
                {
                    string           qtVersion = formChangeQtVersion.GetSelectedQtVersion();
                    QtVersionManager vm        = QtVersionManager.The();
                    string           qtPath    = vm.GetInstallPath(qtVersion);
                    HelperFunctions.SetDebuggingEnvironment(project, "PATH=" + qtPath + "\\bin;$(PATH)", true);
                }
            }
        }
Exemple #9
0
 private void UpdateListBox(string defaultQtVersionDir)
 {
     listView.Items.Clear();
     foreach (var version in QtVersionManager.The().GetVersions())
     {
         string path     = null;
         string compiler = "msvc";
         if (defaultQtVersionDir != null && version == "$(DefaultQtVersion)")
         {
             path = defaultQtVersionDir;
         }
         else
         {
             path = versionManager.GetInstallPath(version);
         }
         if (path == null && version != "$(QTDIR)")
         {
             continue;
         }
         if (path.StartsWith("SSH:") || path.StartsWith("WSL:"))
         {
             var linuxPaths = path.Split(':');
             compiler = "g++";
             path     = string.Format("[{0}] {1}", linuxPaths[0], linuxPaths[1]);
             if (linuxPaths.Length > 2 && !string.IsNullOrEmpty(linuxPaths[2]))
             {
                 compiler = linuxPaths[2];
             }
         }
         var itm = new ListViewItem();
         itm.Tag  = version;
         itm.Text = version;
         itm.SubItems.Add(path);
         itm.SubItems.Add(compiler);
         listView.Items.Add(itm);
     }
 }
Exemple #10
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);
            }
        }