示例#1
0
        public static void ImportProFile()
        {
            var manager   = QtVersionManager.The();
            var qtVersion = manager.GetDefaultVersion();
            var qtDir     = manager.GetInstallPath(qtVersion);

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

            var info = new VersionInformation(qtDir);

            if (info.qtMajor < 5)
            {
                Messages.DisplayErrorMessage(SR.GetString("NoVS2015Support"));
                return;
            }

            if (VSPackage.dte != null)
            {
                var importer = new ProjectImporter(VSPackage.dte);
                importer.ImportProFile(qtVersion);
            }
        }
示例#2
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;
                    }
                }
            }
        }
示例#3
0
        private static string ResolveEnvironmentVariables(string str, EnvDTE.Project project)
        {
            string env = null;
            string val = null;
            var    reg = new Regex(@"\$\(([^\s\(\)]+)\)");
            var    col = reg.Matches(str);

            for (var i = 0; i < col.Count; ++i)
            {
                env = col[i].Groups[1].ToString();
                if (env == "QTDIR")
                {
                    var 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);
        }
示例#4
0
        public static void ImportProFile()
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            var vm        = QtVersionManager.The();
            var qtVersion = vm.GetDefaultVersion();
            var qtDir     = vm.GetInstallPath(qtVersion);

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

            if (vi.qtMajor < 5)
            {
                Messages.DisplayErrorMessage(SR.GetString("NoVSSupport"));
                return;
            }
            if (QtVsToolsPackage.Instance.Dte != null)
            {
                var proFileImporter = new ProjectImporter(QtVsToolsPackage.Instance.Dte);
                proFileImporter.ImportProFile(qtVersion);
            }
        }
示例#5
0
        private void SetupDefaultVersionComboBox(string version)
        {
            var currentItem = defaultCombo.Text;

            if (version != null)
            {
                currentItem = version;
            }
            defaultCombo.Items.Clear();

            foreach (var v in QtVersionManager.The().GetVersions())
            {
                if (v == "$(DefaultQtVersion)")
                {
                    continue;
                }
                defaultCombo.Items.Add(v);
            }

            if (defaultCombo.Items.Count > 0)
            {
                if (defaultCombo.Items.Contains(currentItem))
                {
                    defaultCombo.Text = currentItem;
                }
                else
                {
                    defaultCombo.Text = (string)defaultCombo.Items[0];
                }
            }
            else
            {
                defaultCombo.Text = string.Empty;
            }
        }
        private List <string> getQtLibs(string qtVersion)
        {
            List <string> modulesNames = new List <string>();

            if (qtVersion == null)
            {
                //throw new ArgumentNullException("qtVersion");
                return(modulesNames);
            }

            try
            {
                var versionManager = QtVersionManager.The();
                var installPath    = versionManager.GetInstallPath(qtVersion);
                var libPath        = installPath + @"\lib\";
                var libs           = System.IO.Directory.GetFiles(libPath, "*.lib");//*Qt5
                var listLibs       = new List <string>(libs);
                foreach (var item in libs)
                {
                    //Exclude Debug version libs
                    if (item.Contains("d.lib") &&
                        listLibs.Contains(item.Replace("d.lib", ".lib")))
                    {
                        continue;
                    }

                    modulesNames.Add(item);
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show("getQtLibs() Exception: " + exception.Message);
            }
            return(modulesNames);
        }
示例#7
0
        void debugStartEvents_BeforeExecute(string Guid, int ID, object CustomIn, object CustomOut, ref bool CancelDefault)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            var debugger = dte.Debugger;

            if (debugger != null && debugger.CurrentMode != dbgDebugMode.dbgDesignMode)
            {
                return;
            }
            var selectedProject = HelperFunctions.GetSelectedQtProject(dte);

            if (selectedProject != null)
            {
                if (QtProject.GetFormatVersion(selectedProject) >= Resources.qtMinFormatVersion_Settings)
                {
                    return;
                }
                var qtProject = QtProject.Create(selectedProject);
                if (qtProject != null)
                {
                    qtProject.SetQtEnvironment();

                    var qtVersion   = qtProject.GetQtVersion();
                    var versionInfo = QtVersionManager.The().GetVersionInfo(qtVersion);
                    if (!string.IsNullOrEmpty(versionInfo.Namespace()))
                    {
                        QtVsToolsPackage.Instance.CopyNatvisFiles(versionInfo.Namespace());
                    }
                }
            }
        }
示例#8
0
        public FormVSQtSettings()
        {
            InitializeComponent();
            versionManager = QtVersionManager.The();

            columnVersionName.Text       = SR.GetString("BuildOptionsPage_Name");
            columnVersionPath.Text       = SR.GetString("BuildOptionsPage_Path");
            addButton.Text               = SR.GetString("Add");
            deleteButton.Text            = SR.GetString("Delete");
            label2.Text                  = SR.GetString("BuildOptionsPage_DefaultQtVersion");
            okButton.Text                = SR.GetString("OK");
            cancelButton.Text            = SR.GetString("Cancel");
            tabControl1.TabPages[0].Text = SR.GetString("BuildOptionsPage_Title");
            tabControl1.TabPages[1].Text = SR.GetString("QtDefaultSettings");

            SetupDefaultVersionComboBox(null);
            UpdateListBox();

            vsQtSettings = new VSQtSettings();
            optionsPropertyGrid.SelectedObject = vsQtSettings;
            vsQtSettings.PropertyChanged      += OnSettingsChanged;

            KeyPress += FormQtVersions_KeyPress;
            Shown    += FormQtVersions_Shown;
        }
示例#9
0
        public FormVSQtSettings()
        {
            InitializeComponent();
            versionManager = QtVersionManager.The();

            listView.Columns.Add(SR.GetString("BuildOptionsPage_Name"), 100,
                                 HorizontalAlignment.Left);
            listView.Columns.Add(SR.GetString("BuildOptionsPage_Path"), 180,
                                 HorizontalAlignment.Left);
            addButton.Text               = SR.GetString("Add");
            deleteButton.Text            = SR.GetString("Delete");
            label2.Text                  = SR.GetString("BuildOptionsPage_DefaultQtVersion");
            okButton.Text                = SR.GetString("OK");
            cancelButton.Text            = SR.GetString("Cancel");
            tabControl1.TabPages[0].Text = SR.GetString("BuildOptionsPage_Title");
            tabControl1.TabPages[1].Text = SR.GetString("QtDefaultSettings");

            SetupDefaultVersionComboBox(null);
            UpdateListBox();
            FormBorderStyle = FormBorderStyle.FixedDialog;

            vsQtSettings = new VSQtSettings();
            optionsPropertyGrid.SelectedObject = vsQtSettings;
            vsQtSettings.PropertyChanged      += OnSettingsChanged;

            KeyPress += FormQtVersions_KeyPress;
            Shown    += FormQtVersions_Shown;
        }
示例#10
0
 private void UpdateListBox(string defaultQtVersionDir)
 {
     listView.Items.Clear();
     foreach (var version in QtVersionManager.The().GetVersions())
     {
         string path = null;
         if (defaultQtVersionDir != null && version == "$(DefaultQtVersion)")
         {
             path = defaultQtVersionDir;
         }
         else
         {
             path = versionManager.GetInstallPath(version);
         }
         if (path == null && version != "$(QTDIR)")
         {
             continue;
         }
         var itm = new ListViewItem();
         itm.Tag  = version;
         itm.Text = version;
         itm.SubItems.Add(path);
         listView.Items.Add(itm);
     }
 }
示例#11
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);
        }
示例#12
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);
            }
        }
示例#13
0
文件: Vsix.cs 项目: wencan002/vstools
        /// <summary>
        /// Initialization of the package; this method is called right after the package is sited,
        /// so this is the place where you can put all the initialization code that rely on services
        /// provided by VisualStudio.
        /// </summary>
        protected override void Initialize()
        {
            Instance = this;
            base.Initialize();

            Dte = (this as IServiceProvider).GetService(typeof(DTE)) as DTE;

            // determine the package installation directory
            var uri = new Uri(System.Reflection.Assembly.GetExecutingAssembly().EscapedCodeBase);

            PkgInstallPath = Path.GetDirectoryName(Uri.UnescapeDataString(uri.AbsolutePath)) + @"\";

            var vm    = QtVersionManager.The();
            var error = string.Empty;

            if (vm.HasInvalidVersions(out error))
            {
                Messages.DisplayErrorMessage(error);
            }
            eventHandler = new DteEventsHandler(Dte);

            QtMainMenu.Initialize(this);
            QtSolutionContextMenu.Initialize(this);
            QtProjectContextMenu.Initialize(this);
            QtItemContextMenu.Initialize(this);
            DefaultEditorsHandler.Initialize(Dte);
            QtHelpMenu.Initialize(this);

            try {
                CopyTextMateLanguageFiles();
                UpdateDefaultEditors(Mode.Startup);
            } catch (Exception e) {
                MessageBox.Show(e.Message + "\r\n\r\nStacktrace:\r\n" + e.StackTrace);
            }
        }
示例#14
0
        private bool GetQtProjectAndDirectory(string tool, out string qtDir)
        {
            var qtVersion = "$(DefaultQtVersion)";
            var project   = HelperFunctions.GetSelectedQtProject(dte);

            if (project == null)
            {
                project = HelperFunctions.GetSelectedProject(dte);
                if (project != null && HelperFunctions.IsQMakeProject(project))
                {
                    var qmakeQtDir = HelperFunctions.GetQtDirFromQMakeProject(project);
                    qtVersion = QtVersionManager.The().GetQtVersionFromInstallDir(qmakeQtDir);
                }
            }
            else
            {
                qtVersion = QtVersionManager.The().GetProjectQtVersion(project);
            }

            qtDir = HelperFunctions.FindQtDirWithTools(tool, qtVersion);
            if (string.IsNullOrEmpty(qtDir))
            {
                MessageBox.Show(SR.GetString("NoDefaultQtVersionError"), SR.GetString("Resources_QtVsTools"));
            }
            return(!string.IsNullOrEmpty(qtDir));
        }
示例#15
0
        void OnLoaded(object sender, RoutedEventArgs e)
        {
            Loaded -= OnLoaded;

            var qtModules = QtModules.Instance.GetAvailableModuleInformation()
                            .Where((QtModuleInfo mi) => mi.Selectable)
                            .Select((QtModuleInfo mi) => new Module()
            {
                Name       = mi.Name,
                Id         = mi.proVarQT,
                IsSelected = Data.DefaultModules.Contains(mi.LibraryPrefix),
                IsReadOnly = Data.DefaultModules.Contains(mi.LibraryPrefix),
            });

            qtVersionList = new[] { QT_VERSION_DEFAULT, QT_VERSION_BROWSE }
            .Union(QtVersionManager.The().GetVersions());

            if (defaultQtVersionInfo == null)
            {
                Validate();
                return;
            }

            defaultConfigs = new CloneableList <Config> {
                new Config {
                    Name          = "Debug",
                    IsDebug       = true,
                    QtVersion     = defaultQtVersionInfo,
                    QtVersionName = defaultQtVersionInfo.name,
                    Target        = defaultQtVersionInfo.isWinRT()
                        ? ProjectTargets.WindowsStore.Cast <string>()
                        : ProjectTargets.Windows.Cast <string>(),
                    Platform = defaultQtVersionInfo.is64Bit()
                        ? ProjectPlatforms.X64.Cast <string>()
                        : ProjectPlatforms.Win32.Cast <string>(),
                    Modules = qtModules.ToDictionary((Module m) => m.Name),
                },
                new Config {
                    Name          = "Release",
                    IsDebug       = false,
                    QtVersion     = defaultQtVersionInfo,
                    QtVersionName = defaultQtVersionInfo.name,
                    Target        = defaultQtVersionInfo.isWinRT()
                        ? ProjectTargets.WindowsStore.Cast <string>()
                        : ProjectTargets.Windows.Cast <string>(),
                    Platform = defaultQtVersionInfo.is64Bit()
                        ? ProjectPlatforms.X64.Cast <string>()
                        : ProjectPlatforms.Win32.Cast <string>(),
                    Modules = qtModules.ToDictionary((Module m) => m.Name),
                }
            };
            currentConfigs          = defaultConfigs.Clone();
            ConfigTable.ItemsSource = currentConfigs;

            initialNextButtonIsEnabled   = NextButton.IsEnabled;
            initialFinishButtonIsEnabled = FinishButton.IsEnabled;

            Validate();
        }
示例#16
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"));
            }
        }
示例#17
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.");
            }
        }
示例#18
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.
            }

            Project project = null;

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

            if (QtProject.GetFormatVersion(project) >= Resources.qtMinFormatVersion_Settings)
            {
                return;
            }

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

            if (qtVersion == null)
            {
                Messages.DisplayCriticalErrorMessage(SR.GetString("ProjectQtVersionNotFoundError", projectName, projectConfig, 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, true);
            if (QtVSIPSettings.GetLUpdateOnBuild(project))
            {
                Translation.RunlUpdate(project);
            }
        }
示例#19
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"));
            }
        }
示例#20
0
 public void VsMainWindowActivated()
 {
     if (QtVersionManager.The().GetVersions()?.Length == 0)
     {
         InfoBarMessages.NoQtVersion.Show();
     }
     if (TestVersionInstalled())
     {
         InfoBarMessages.NotifyInstall.Show();
     }
 }
        public FormVSQtSettings()
        {
            InitializeComponent();

            foreach (var control in Controls)
            {
                ComboBox comboBox = control as ComboBox;
                if (comboBox != null)
                {
                    comboBox.Resize += (sender, e) =>
                    {
                        if (!comboBox.Focused)
                        {
                            comboBox.SelectionLength = 0;
                        }
                    };
                }
            }

            versionManager = QtVersionManager.The();

            this.Text = SR.GetString("VSQtOptionsButtonText");
            listView.Columns.Add(SR.GetString("BuildOptionsPage_Name"), 100, HorizontalAlignment.Left);
            listView.Columns.Add(SR.GetString("BuildOptionsPage_Path"), 260, HorizontalAlignment.Left);
            addButton.Text               = SR.GetString(SR.Add);
            deleteButton.Text            = SR.GetString(SR.Delete);
            labelX86.Text                = SR.GetString("BuildOptionsPage_DefaultQtX86Version");
            labelX64.Text                = SR.GetString("BuildOptionsPage_DefaultQtX64Version");
            labelWinCE.Text              = SR.GetString("BuildOptionsPage_WinCEQtVersion");
            okButton.Text                = SR.GetString("OK");
            cancelButton.Text            = SR.GetString("Cancel");
            tabControl1.TabPages[0].Text = SR.GetString("BuildOptionsPage_Title");
            tabControl1.TabPages[1].Text = SR.GetString("QtDefaultSettings");

#if !ENABLE_WINCE
            // Just hide the Windows CE specific combobox and occupy the released screen space.
            labelWinCE.Hide();
            winCECombo.Hide();
            tableLayoutPanel2.RowCount -= 1;
            tableLayoutPanel2.RowStyles.RemoveAt(tableLayoutPanel2.RowCount);
#endif

            SetupVersionComboBox(defaultX86Combo, null, new VIBoolPredicate(isDesktopQt));
            SetupVersionComboBox(defaultX64Combo, null, new VIBoolPredicate(isDesktopQt));
            SetupWinCEVersionComboBox(null);
            UpdateListBox();

            vsQtSettings = new VSQtSettings();
            optionsPropertyGrid.SelectedObject = vsQtSettings;

            this.KeyPress += new KeyPressEventHandler(this.FormQtVersions_KeyPress);
            this.Shown    += new EventHandler(FormQtVersions_Shown);
        }
 private void deleteButton_Click(object sender, EventArgs e)
 {
     QtVersionManager.The().ClearVersionCache();
     foreach (ListViewItem itm in listView.SelectedItems)
     {
         string name = itm.Text;
         versionManager.RemoveVersion(name);
         listView.Items.Remove(itm);
         SetupDefaultVersionComboBox(null);
         SetupWinCEVersionComboBox(null);
     }
 }
示例#23
0
        void SolutionEvents_ProjectAdded(Project project)
        {
            if (HelperFunctions.IsQMakeProject(project))
            {
                RegisterVCProjectEngineEvents(project);
                var      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)
                        {
                            var tool = HelperFunctions.GetCustomBuildTool(config);
                            if (tool == null)
                            {
                                continue;
                            }

                            var commandLine = tool.CommandLine;
                            if (!string.IsNullOrEmpty(commandLine) && commandLine.Contains("moc.exe"))
                            {
                                var    matches = Regex.Matches(commandLine, "[^ ^\n]+moc\\.(exe\"|exe)");
                                string qtDir;
                                if (matches.Count != 1)
                                {
                                    var vm = QtVersionManager.The();
                                    qtDir = vm.GetInstallPath(vm.GetDefaultVersion());
                                }
                                else
                                {
                                    qtDir = matches[0].ToString().Trim('"');
                                    qtDir = qtDir.Remove(qtDir.LastIndexOf('\\'));
                                    qtDir = qtDir.Remove(qtDir.LastIndexOf('\\'));
                                }
                                qtDir = qtDir.Replace("_(QTDIR)", "$(QTDIR)");
                                HelperFunctions.SetDebuggingEnvironment(project, "PATH="
                                                                        + Path.Combine(qtDir, "bin") + ";$(PATH)", false);
                            }
                        }
                    }
                }
            }
        }
示例#24
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);
 }
示例#25
0
        private void okButton_Click(object sender, EventArgs e)
        {
            QtVersionManager   vm          = QtVersionManager.The();
            VersionInformation versionInfo = null;

            try
            {
                versionInfo = new VersionInformation(pathBox.Text);
            }
            catch (Exception exception)
            {
                if (nameBox.Text == "$(QTDIR)")
                {
                    string defaultVersion = vm.GetDefaultVersion();
                    versionInfo = vm.GetVersionInfo(defaultVersion);
                }
                else
                {
                    Messages.DisplayErrorMessage(exception.Message);
                    return;
                }
            }

            if (versionInfo.IsWinCEVersion())
            {
                // check whether we have an SDK installed for this platform
                string platformName = versionInfo.GetVSPlatformName();
                if (!HelperFunctions.IsPlatformAvailable(VSPackage.dte, platformName))
                {
                    MessageBox.Show(SR.GetString("AddQtVersionDialog_PlatformNotFoundError", platformName),
                                    null, MessageBoxButtons.OK,
                                    MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
                    return;
                }
            }

            string makefileGenerator = versionInfo.GetQMakeConfEntry("MAKEFILE_GENERATOR");

            if (makefileGenerator != "MSVC.NET" && makefileGenerator != "MSBUILD" &&
                makefileGenerator != "MSVC.NETMSBUILD")
            {
                MessageBox.Show(SR.GetString("AddQtVersionDialog_IncorrectMakefileGenerator", makefileGenerator),
                                null, MessageBoxButtons.OK,
                                MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
                return;
            }
            vm.SaveVersion(nameBox.Text, pathBox.Text);
            DialogResult = DialogResult.OK;
            Close();
        }
示例#26
0
 private void addButton_Click(object sender, EventArgs e)
 {
     VersionInformation.Clear();
     QtVersionManager.The().ClearVersionCache();
     using (var dia = new AddQtVersionDialog()) {
         dia.StartPosition = FormStartPosition.CenterParent;
         var ww = new MainWinWrapper(Vsix.Instance.Dte);
         if (dia.ShowDialog(ww) == DialogResult.OK)
         {
             UpdateListBox();
             SetupDefaultVersionComboBox(null);
         }
     }
 }
示例#27
0
        private void changeSolutionQtVersion(object sender, EventArgs e)
        {
            var manager = QtVersionManager.The();

            if (formChangeQtVersion == null)
            {
                formChangeQtVersion = new FormChangeQtVersion();
            }
            formChangeQtVersion.UpdateContent(ChangeFor.Solution);
            if (formChangeQtVersion.ShowDialog() == DialogResult.OK)
            {
                var newQtVersion = formChangeQtVersion.GetSelectedQtVersion();
                if (newQtVersion != null)
                {
                    string currentPlatform = null;
                    try {
                        //SolutionConfiguration config = VSPackage.dte.Solution.SolutionBuild.ActiveConfiguration;
                        //SolutionConfiguration2 config2 = config as SolutionConfiguration2;
                        //currentPlatform = config2.PlatformName;
                        Project       prj    = VSPackage.dte.Solution.Projects.Item(1);
                        Configuration config = prj.ConfigurationManager.ActiveConfiguration;
                        currentPlatform = config.PlatformName;
                    }
                    catch {
                    }
                    if (string.IsNullOrEmpty(currentPlatform))
                    {
                        return;
                    }


                    foreach (var project in HelperFunctions.ProjectsInSolution(VSPackage.dte))
                    {
                        if (HelperFunctions.IsQtProject(project))
                        {
                            string OldQtVersion = manager.GetProjectQtVersion(project, currentPlatform);
                            if (OldQtVersion == null)
                            {
                                OldQtVersion = manager.GetDefaultVersion();
                            }

                            var qtProject         = QtProject.Create(project);
                            var newProjectCreated = false;
                            qtProject.ChangeQtVersion(OldQtVersion, newQtVersion, ref newProjectCreated);
                        }
                    }
                    manager.SaveSolutionQtVersion(VSPackage.dte.Solution, newQtVersion);
                }
            }
        }
示例#28
0
        private void InitModules()
        {
            var versionManager = QtVersionManager.The();
            var qtVersion      = qtProject.GetQtVersion();
            var installPath    = versionManager.GetInstallPath(qtVersion);

            var modulesList = getQtLibs(qtProject.GetQtVersion());

            //var projectModules = new List<string>();
            for (int i = 0; i < moduleMap.Count; ++i)
            {
                var item = moduleMap[i];
                item.initialValue     = qtProject.HasModule(item.moduleId);
                item.checkbox.Checked = item.initialValue;
                moduleMap[i]          = item;

                // Disable if module not installed
                var info          = QtModules.Instance.ModuleInformation(item.moduleId);
                var libraryPrefix = info.LibraryPrefix;
                if (libraryPrefix.StartsWith("Qt"))
                {
                    libraryPrefix = "Qt5" + libraryPrefix.Substring(2);
                }
                var fullPath = installPath + "\\lib\\" + libraryPrefix + ".lib";
                var isExists = System.IO.File.Exists(fullPath);
                item.checkbox.Enabled = isExists;
                //foreach (var module in modulesList)
                //{
                //    if (comparePath(fullPath, module) && item.initialValue && isExists)
                //    {
                //        projectModules.Add(module);
                //    }
                //}
                // Don't disable item if qtVersion not available
                if (!isExists && qtVersion != null)
                {
                    item.checkbox.Checked = false;
                }
            }

            var projectLibs = getUsedLibs(qtProject.Project);

            modulesListBox.Items.Clear();
            foreach (var item in modulesList)
            {
                var libName = System.IO.Path.GetFileName(item);
                modulesListBox.Items.Add(libraryPathToName(item), projectLibs.Contains(libName));
            }
        }
        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);
        }
        private void addButton_Click(object sender, EventArgs e)
        {
            QtVersionManager.The().ClearVersionCache();
            AddQtVersionDialog dia = new AddQtVersionDialog();

            dia.StartPosition = FormStartPosition.CenterParent;
            MainWinWrapper ww = new MainWinWrapper(Connect._applicationObject);

            if (dia.ShowDialog(ww) == DialogResult.OK)
            {
                UpdateListBox();
                SetupDefaultVersionComboBox(null);
                SetupWinCEVersionComboBox(null);
            }
        }