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); } }
private void okButton_Click(object sender, EventArgs e) { try { var versionInfo = VersionInformation.Get(pathBox.Text); var generator = versionInfo.GetQMakeConfEntry("MAKEFILE_GENERATOR"); if (generator != "MSVC.NET" && generator != "MSBUILD") { throw new Exception(SR.GetString("AddQtVersionDialog_IncorrectMakefileGenerator", generator)); } QtVersionManager.The().SaveVersion(nameBox.Text, pathBox.Text); DialogResult = DialogResult.OK; Close(); } catch (Exception exception) { Messages.DisplayErrorMessage(exception.Message); } }
private void okButton_Click(object sender, EventArgs e) { bool ok = false; try { if (comboBoxHost.Text == "Windows") { var versionInfo = VersionInformation.Get(pathBox.Text); var generator = versionInfo.GetQMakeConfEntry("MAKEFILE_GENERATOR"); if (generator != "MSVC.NET" && generator != "MSBUILD") { throw new Exception(SR.GetString("AddQtVersionDialog_IncorrectMakefileGenerator", generator)); } ok = QtVersionManager.The().SaveVersion(nameBox.Text, pathBox.Text); } else { string name = nameBox.Text; string access = comboBoxHost.Text == "Linux SSH" ? "SSH" : "WSL"; string path = pathBox.Text; string compiler = compilerBox.Text; if (compiler == "g++") { compiler = string.Empty; } path = string.Format("{0}:{1}:{2}", access, path, compiler); ok = QtVersionManager.The().SaveVersion(name, path, checkPath: false); } } catch (Exception exception) { Messages.PaneMessageSafe(Vsix.Instance.Dte, exception.Message + "\r\n\r\nStacktrace:\r\n" + exception.StackTrace, 5000); } if (ok) { DialogResult = DialogResult.OK; Close(); } else { DialogResult = DialogResult.Cancel; Close(); Messages.DisplayErrorMessage("Error registering Qt version."); } }
public void ProjectFinishedGenerating(Project project) { var qtProject = QtProject.Create(project); QtVSIPSettings.SaveUicDirectory(project, null); QtVSIPSettings.SaveMocDirectory(project, null); QtVSIPSettings.SaveMocOptions(project, null); QtVSIPSettings.SaveRccDirectory(project, null); QtVSIPSettings.SaveLUpdateOnBuild(project); QtVSIPSettings.SaveLUpdateOptions(project, null); QtVSIPSettings.SaveLReleaseOptions(project, null); var vm = QtVersionManager.The(); var qtVersion = vm.GetDefaultVersion(); var vi = VersionInformation.Get(vm.GetInstallPath(qtVersion)); if (vi.GetVSPlatformName() != "Win32") { qtProject.SelectSolutionPlatform(vi.GetVSPlatformName()); } vm.SaveProjectQtVersion(project, qtVersion); qtProject.MarkAsQtProject("v1.0"); qtProject.AddDirectories(); var type = TemplateType.Application | TemplateType.ConsoleSystem; qtProject.WriteProjectBasicConfigurations(type, false); foreach (VCFile file in (IVCCollection)qtProject.VCProject.Files) { qtProject.AdjustWhitespace(file.FullPath); } qtProject.AddModule(QtModule.Main); foreach (var module in data.Modules) { qtProject.AddModule(QtModules.Instance.ModuleIdByName(module)); } qtProject.SetQtEnvironment(qtVersion); qtProject.Finish(); // Collapses all project nodes. }
public void RunStarted(object automation, Dictionary <string, string> replacements, WizardRunKind runKind, object[] customParams) { var serviceProvider = new ServiceProvider(automation as IServiceProvider); var iVsUIShell = serviceProvider.GetService(typeof(SVsUIShell)) as IVsUIShell; iVsUIShell.EnableModeless(0); try { System.IntPtr hwnd; iVsUIShell.GetDialogOwnerHwnd(out hwnd); try { var className = replacements["$safeprojectname$"]; className = Regex.Replace(className, @"[^a-zA-Z0-9_]", string.Empty); className = Regex.Replace(className, @"^[\d-]*\s*", string.Empty); var result = new ClassNameValidationRule().Validate(className, null); if (result != ValidationResult.ValidResult) { className = @"QtGuiApplication"; } data.ClassName = className; data.BaseClass = @"QMainWindow"; data.ClassHeaderFile = className + @".h"; data.ClassSourceFile = className + @".cpp"; data.UiFile = data.ClassName + @".ui"; data.QrcFile = data.ClassName + @".qrc"; var wizard = new WizardWindow(new List <WizardPage> { new IntroPage { Data = data, Header = @"Welcome to the Qt GUI Application Wizard", Message = @"This wizard generates a Qt GUI application project. The " + @"application derives from QApplication and includes an empty " + @"widget." + System.Environment.NewLine + System.Environment.NewLine + "To continue, click Next.", PreviousButtonEnabled = false, NextButtonEnabled = true, FinishButtonEnabled = false, CancelButtonEnabled = true }, new ModulePage { Data = data, Header = @"Welcome to the Qt GUI Application Wizard", Message = @"Select the modules you want to include in your project. The " + @"recommended modules for this project are selected by default.", PreviousButtonEnabled = true, NextButtonEnabled = true, FinishButtonEnabled = false, CancelButtonEnabled = true }, new GuiPage { Data = data, Header = @"Welcome to the Qt GUI Application Wizard", Message = @"This wizard generates a Qt GUI application project. The " + @"application derives from QApplication and includes an empty " + @"widget.", PreviousButtonEnabled = true, NextButtonEnabled = false, FinishButtonEnabled = data.DefaultModules.All(QtModuleInfo.IsInstalled), CancelButtonEnabled = true } }) { Title = @"Qt GUI Application Wizard" }; WindowHelper.ShowModal(wizard, hwnd); if (!wizard.DialogResult.HasValue || !wizard.DialogResult.Value) { throw new System.Exception("Unexpected wizard return value."); } } catch (QtVSException exception) { Messages.DisplayErrorMessage(exception.Message); throw; // re-throw, but keep the original exception stack intact } var version = (automation as DTE).Version; replacements["$ToolsVersion$"] = version; var vm = QtVersionManager.The(); var vi = VersionInformation.Get(vm.GetInstallPath(vm.GetDefaultVersion())); replacements["$Platform$"] = vi.GetVSPlatformName(); replacements["$Keyword$"] = Resources.qtProjectKeyword; replacements["$ProjectGuid$"] = @"{B12702AD-ABFB-343A-A199-8E24837244A3}"; replacements["$PlatformToolset$"] = BuildConfig.PlatformToolset(version); replacements["$classname$"] = data.ClassName; replacements["$baseclass$"] = data.BaseClass; replacements["$sourcefilename$"] = data.ClassSourceFile; replacements["$headerfilename$"] = data.ClassHeaderFile; replacements["$uifilename$"] = data.UiFile; replacements["$precompiledheader$"] = string.Empty; replacements["$precompiledsource$"] = string.Empty; replacements["$DefaultApplicationIcon$"] = string.Empty; replacements["$centralwidget$"] = string.Empty; var strHeaderInclude = data.ClassHeaderFile; if (data.UsePrecompiledHeader) { strHeaderInclude = "stdafx.h\"\r\n#include \"" + data.ClassHeaderFile; replacements["$precompiledheader$"] = "<None Include=\"stdafx.h\" />"; replacements["$precompiledsource$"] = "<None Include=\"stdafx.cpp\" />"; } replacements["$include$"] = strHeaderInclude; replacements["$ui_hdr$"] = "ui_" + Path.GetFileNameWithoutExtension(data.UiFile) + ".h"; replacements["$qrcfilename$"] = data.QrcFile; if (data.BaseClass == "QMainWindow") { replacements["$centralwidget$"] = "\r\n <widget class=\"QMenuBar\" name=\"menuBar\" />" + "\r\n <widget class=\"QToolBar\" name=\"mainToolBar\" />" + "\r\n <widget class=\"QWidget\" name=\"centralWidget\" />" + "\r\n <widget class=\"QStatusBar\" name=\"statusBar\" />"; } if (data.AddDefaultAppIcon) { replacements["$DefaultApplicationIcon$"] = "<None Include=\"gui.ico\" />"; } if (vi.isWinRT()) { replacements["$QtWinRT$"] = "true"; var projDir = replacements["$destinationdirectory$"]; var qmakeTmpDir = Path.Combine(projDir, "qmake_tmp"); Directory.CreateDirectory(qmakeTmpDir); var dummyPro = Path.Combine(qmakeTmpDir, string.Format("{0}.pro", replacements["$projectname$"])); File.WriteAllText(dummyPro, "SOURCES = main.cpp\r\n"); var qmake = new QMake(null, dummyPro, false, vi); qmake.RunQMake(); var assetsDir = Path.Combine(qmakeTmpDir, "assets"); if (Directory.Exists(assetsDir)) { Directory.Move(assetsDir, Path.Combine(projDir, "assets")); } var manifestFile = Path.Combine(qmakeTmpDir, "Package.appxmanifest"); if (File.Exists(manifestFile)) { File.Move(manifestFile, Path.Combine(projDir, "Package.appxmanifest")); } var projFile = Path.Combine(qmakeTmpDir, string.Format("{0}.vcxproj", replacements["$projectname$"])); var proj = MsBuildProject.Load(projFile); replacements["$MinimumVisualStudioVersion$"] = proj.GetProperty("MinimumVisualStudioVersion"); replacements["$ApplicationTypeRevision$"] = proj.GetProperty("ApplicationTypeRevision"); replacements["$WindowsTargetPlatformVersion$"] = proj.GetProperty("WindowsTargetPlatformVersion"); replacements["$isSet_WindowsTargetPlatformVersion$"] = "true"; replacements["$WindowsTargetPlatformMinVersion$"] = proj.GetProperty("WindowsTargetPlatformMinVersion"); replacements["$Link_TargetMachine$"] = proj.GetProperty("Link", "TargetMachine"); Directory.Delete(qmakeTmpDir, true); } #if (VS2017 || VS2015) else { string versionWin10SDK = HelperFunctions.GetWindows10SDKVersion(); if (!string.IsNullOrEmpty(versionWin10SDK)) { replacements["$WindowsTargetPlatformVersion$"] = versionWin10SDK; replacements["$isSet_WindowsTargetPlatformVersion$"] = "true"; } } #endif } catch { try { Directory.Delete(replacements["$destinationdirectory$"]); Directory.Delete(replacements["$solutiondirectory$"]); } catch { } iVsUIShell.EnableModeless(1); throw new WizardBackoutException(); } iVsUIShell.EnableModeless(1); }
public void ProjectFinishedGenerating(Project project) { var qtProject = QtProject.Create(project); QtVSIPSettings.SaveUicDirectory(project, null); QtVSIPSettings.SaveMocDirectory(project, null); QtVSIPSettings.SaveMocOptions(project, null); QtVSIPSettings.SaveRccDirectory(project, null); QtVSIPSettings.SaveLUpdateOnBuild(project); QtVSIPSettings.SaveLUpdateOptions(project, null); QtVSIPSettings.SaveLReleaseOptions(project, null); var vm = QtVersionManager.The(); var qtVersion = vm.GetDefaultVersion(); var vi = VersionInformation.Get(vm.GetInstallPath(qtVersion)); if (vi.GetVSPlatformName() != "Win32") { qtProject.SelectSolutionPlatform(vi.GetVSPlatformName()); } vm.SaveProjectQtVersion(project, qtVersion); qtProject.MarkAsQtProject("v1.0"); qtProject.AddDirectories(); var type = TemplateType.Application | TemplateType.GUISystem; qtProject.WriteProjectBasicConfigurations(type, data.UsePrecompiledHeader); qtProject.AddModule(QtModule.Main); foreach (var module in data.Modules) { qtProject.AddModule(QtModules.Instance.ModuleIdByName(module)); } var vcProject = qtProject.VCProject; var files = vcProject.GetFilesWithItemType(@"None") as IVCCollection; foreach (var vcFile in files) { vcProject.RemoveFile(vcFile); } if (data.UsePrecompiledHeader) { qtProject.AddFileToProject(@"stdafx.cpp", Filters.SourceFiles()); qtProject.AddFileToProject(@"stdafx.h", Filters.HeaderFiles()); } qtProject.AddFileToProject(data.ClassSourceFile, Filters.SourceFiles()); qtProject.AddFileToProject(data.ClassHeaderFile, Filters.HeaderFiles()); qtProject.AddFileToProject(data.UiFile, Filters.FormFiles()); var qrc = qtProject.CreateQrcFile(data.ClassName, data.QrcFile); qtProject.AddFileToProject(qrc, Filters.ResourceFiles()); if (data.AddDefaultAppIcon) { try { var icon = vcProject.ProjectDirectory + "\\" + vcProject.ItemName + ".ico"; if (!File.Exists(icon)) { File.Move(vcProject.ProjectDirectory + "\\gui.ico", icon); var attribs = File.GetAttributes(icon); File.SetAttributes(icon, attribs & (~FileAttributes.ReadOnly)); } var rcFile = vcProject.ProjectDirectory + "\\" + vcProject.ItemName + ".rc"; if (!File.Exists(rcFile)) { FileStream fs = null; try { fs = File.Create(rcFile); using (var sw = new StreamWriter(fs)) { fs = null; sw.WriteLine("IDI_ICON1\t\tICON\t\tDISCARDABLE\t\"" + vcProject.ItemName + ".ico\"" + sw.NewLine); } } finally { if (fs != null) { fs.Dispose(); } } vcProject.AddFile(rcFile); } } catch { } } foreach (VCFile file in (IVCCollection)qtProject.VCProject.Files) { qtProject.AdjustWhitespace(file.FullPath); } qtProject.SetQtEnvironment(qtVersion); qtProject.Finish(); // Collapses all project nodes. }
public void RunStarted(object automation, Dictionary <string, string> replacements, WizardRunKind runKind, object[] customParams) { var serviceProvider = new ServiceProvider(automation as IServiceProvider); var iVsUIShell = serviceProvider.GetService(typeof(SVsUIShell)) as IVsUIShell; iVsUIShell.EnableModeless(0); try { System.IntPtr hwnd; iVsUIShell.GetDialogOwnerHwnd(out hwnd); try { var wizard = new WizardWindow(new List <WizardPage> { new IntroPage { Data = data, Header = @"Welcome to the Qt Console Application Wizard", Message = @"This wizard generates a Qt console application " + @"project. The application derives from QCoreApplication " + @"and does not present a GUI." + System.Environment.NewLine + System.Environment.NewLine + "To continue, click Next.", PreviousButtonEnabled = false, NextButtonEnabled = true, FinishButtonEnabled = false, CancelButtonEnabled = true }, new ModulePage { Data = data, Header = @"Welcome to the Qt Console Application Wizard", Message = @"Select the modules you want to include in your project. The " + @"recommended modules for this project are selected by default.", PreviousButtonEnabled = true, NextButtonEnabled = false, FinishButtonEnabled = QtModuleInfo.IsInstalled(@"QtCore"), CancelButtonEnabled = true } }) { Title = @"Qt Console Application Wizard" }; WindowHelper.ShowModal(wizard, hwnd); if (!wizard.DialogResult.HasValue || !wizard.DialogResult.Value) { throw new System.Exception("Unexpected wizard return value."); } } catch (QtVSException exception) { Messages.DisplayErrorMessage(exception.Message); throw; // re-throw, but keep the original exception stack intact } var version = (automation as DTE).Version; replacements["$ToolsVersion$"] = version; var vm = QtVersionManager.The(); var vi = VersionInformation.Get(vm.GetInstallPath(vm.GetDefaultVersion())); replacements["$Platform$"] = vi.GetVSPlatformName(); replacements["$Keyword$"] = Resources.qtProjectKeyword; replacements["$ProjectGuid$"] = @"{B12702AD-ABFB-343A-A199-8E24837244A3}"; replacements["$PlatformToolset$"] = version.Replace(".", string.Empty); } catch { try { Directory.Delete(replacements["$destinationdirectory$"]); Directory.Delete(replacements["$solutiondirectory$"]); } catch { } iVsUIShell.EnableModeless(1); throw new WizardBackoutException(); } iVsUIShell.EnableModeless(1); }
public void ProjectFinishedGenerating(Project project) { var qtProject = QtProject.Create(project); QtVSIPSettings.SaveUicDirectory(project, null); QtVSIPSettings.SaveMocDirectory(project, null); QtVSIPSettings.SaveMocOptions(project, null); QtVSIPSettings.SaveRccDirectory(project, null); QtVSIPSettings.SaveLUpdateOnBuild(project); QtVSIPSettings.SaveLUpdateOptions(project, null); QtVSIPSettings.SaveLReleaseOptions(project, null); var vm = QtVersionManager.The(); var qtVersion = vm.GetDefaultVersion(); var vi = VersionInformation.Get(vm.GetInstallPath(qtVersion)); if (vi.GetVSPlatformName() != "Win32") { qtProject.SelectSolutionPlatform(vi.GetVSPlatformName()); } vm.SaveProjectQtVersion(project, qtVersion); qtProject.MarkAsQtProject("v1.0"); qtProject.AddDirectories(); var type = TemplateType.GUISystem | (data.CreateStaticLibrary ? TemplateType.StaticLibrary : TemplateType.DynamicLibrary); qtProject.WriteProjectBasicConfigurations(type, data.UsePrecompiledHeader); qtProject.AddModule(QtModule.Main); foreach (var module in data.Modules) { qtProject.AddModule(QtModules.Instance.ModuleIdByName(module)); } var vcProject = qtProject.VCProject; var files = vcProject.GetFilesWithItemType(@"None") as IVCCollection; foreach (var vcFile in files) { vcProject.RemoveFile(vcFile); } if (data.UsePrecompiledHeader) { qtProject.AddFileToProject(@"stdafx.cpp", Filters.SourceFiles()); qtProject.AddFileToProject(@"stdafx.h", Filters.HeaderFiles()); } foreach (VCFile file in (IVCCollection)qtProject.VCProject.Files) { qtProject.AdjustWhitespace(file.FullPath); } qtProject.AddDefine(projectDefine, BuildConfig.Both); if (data.CreateStaticLibrary) { qtProject.AddDefine("BUILD_STATIC", BuildConfig.Both); } qtProject.SetQtEnvironment(qtVersion); qtProject.Finish(); // Collapses all project nodes. }
public void RunStarted(object automation, Dictionary <string, string> replacements, WizardRunKind runKind, object[] customParams) { var serviceProvider = new ServiceProvider(automation as IServiceProvider); var iVsUIShell = serviceProvider.GetService(typeof(SVsUIShell)) as IVsUIShell; iVsUIShell.EnableModeless(0); try { System.IntPtr hwnd; iVsUIShell.GetDialogOwnerHwnd(out hwnd); var safeprojectname = replacements["$safeprojectname$"]; safeprojectname = Regex.Replace(safeprojectname, @"[^a-zA-Z0-9_]", string.Empty); safeprojectname = Regex.Replace(safeprojectname, @"^[\d-]*\s*", string.Empty); var result = new ClassNameValidationRule().Validate(safeprojectname, null); if (result != ValidationResult.ValidResult) { safeprojectname = @"QtClassLibrary"; } try { data.ClassName = safeprojectname; data.ClassHeaderFile = safeprojectname + @".h"; data.ClassSourceFile = safeprojectname + @".cpp"; var wizard = new WizardWindow(new List <WizardPage> { new IntroPage { Data = data, Header = @"Welcome to the Qt Class Library Wizard", Message = @"This wizard generates a Qt Class Library project. The " + @"resulting library is linked dynamically with Qt." + System.Environment.NewLine + System.Environment.NewLine + @"To continue, click Next.", PreviousButtonEnabled = false, NextButtonEnabled = true, FinishButtonEnabled = false, CancelButtonEnabled = true }, new ModulePage { Data = data, Header = @"Welcome to the Qt Class Library Wizard", Message = @"Select the modules you want to include in your project. The " + @"recommended modules for this project are selected by default.", PreviousButtonEnabled = true, NextButtonEnabled = true, FinishButtonEnabled = false, CancelButtonEnabled = true }, new LibraryClassPage { Data = data, Header = @"Welcome to the Qt Class Library Wizard", Message = @"This wizard generates a Qt Class Library project. The " + @"resulting library is linked dynamically with Qt.", PreviousButtonEnabled = true, NextButtonEnabled = false, FinishButtonEnabled = QtModuleInfo.IsInstalled(@"QtCore"), CancelButtonEnabled = true } }) { Title = @"Qt Class Library Wizard" }; WindowHelper.ShowModal(wizard, hwnd); if (!wizard.DialogResult.HasValue || !wizard.DialogResult.Value) { throw new System.Exception(@"Unexpected wizard return value."); } } catch (QtVSException exception) { Messages.DisplayErrorMessage(exception.Message); throw; // re-throw, but keep the original exception stack intact } var version = (automation as DTE).Version; replacements["$ToolsVersion$"] = version; var vm = QtVersionManager.The(); var vi = VersionInformation.Get(vm.GetInstallPath(vm.GetDefaultVersion())); replacements["$Platform$"] = vi.GetVSPlatformName(); replacements["$Keyword$"] = Resources.qtProjectKeyword; replacements["$ProjectGuid$"] = @"{B12702AD-ABFB-343A-A199-8E24837244A3}"; replacements["$PlatformToolset$"] = BuildConfig.PlatformToolset(version); replacements["$classname$"] = data.ClassName; replacements["$sourcefilename$"] = data.ClassSourceFile; replacements["$headerfilename$"] = data.ClassHeaderFile; replacements["$precompiledheader$"] = string.Empty; replacements["$precompiledsource$"] = string.Empty; var strHeaderInclude = data.ClassHeaderFile; if (data.UsePrecompiledHeader) { strHeaderInclude = "stdafx.h\"\r\n#include \"" + data.ClassHeaderFile; replacements["$precompiledheader$"] = "<None Include=\"stdafx.h\" />"; replacements["$precompiledsource$"] = "<None Include=\"stdafx.cpp\" />"; } replacements["$include$"] = strHeaderInclude; replacements["$saveglobal$"] = safeprojectname.ToLower(); projectDefine = safeprojectname.ToUpper() + @"_LIB"; replacements["$pro_lib_define$"] = projectDefine; replacements["$pro_lib_export$"] = safeprojectname.ToUpper() + @"_EXPORT"; if (vi.isWinRT()) { replacements["$QtWinRT$"] = "true"; } #if (VS2017 || VS2015) string versionWin10SDK = HelperFunctions.GetWindows10SDKVersion(); if (!string.IsNullOrEmpty(versionWin10SDK)) { replacements["$WindowsTargetPlatformVersion$"] = versionWin10SDK; replacements["$isSet_WindowsTargetPlatformVersion$"] = "true"; } #endif } catch { try { Directory.Delete(replacements["$destinationdirectory$"]); Directory.Delete(replacements["$solutiondirectory$"]); } catch { } iVsUIShell.EnableModeless(1); throw new WizardBackoutException(); } iVsUIShell.EnableModeless(1); }
public void RunStarted(object automation, Dictionary <string, string> replacements, WizardRunKind runKind, object[] customParams) { var serviceProvider = new ServiceProvider(automation as IServiceProvider); var iVsUIShell = serviceProvider.GetService(typeof(SVsUIShell)) as IVsUIShell; iVsUIShell.EnableModeless(0); try { System.IntPtr hwnd; iVsUIShell.GetDialogOwnerHwnd(out hwnd); try { var className = replacements["$safeprojectname$"]; className = Regex.Replace(className, @"[^a-zA-Z0-9_]", string.Empty); className = Regex.Replace(className, @"^[\d-]*\s*", string.Empty); className = Regex.Replace(className, @"[pP][lL][uU][gG][iI][nN]$", string.Empty); var result = new ClassNameValidationRule().Validate(className, null); if (result != ValidationResult.ValidResult) { className = @"MyDesignerWidget"; } data.ClassName = className; data.BaseClass = @"QWidget"; data.ClassHeaderFile = className + @".h"; data.ClassSourceFile = className + @".cpp"; data.PluginClass = className + @"Plugin"; data.PluginHeaderFile = data.PluginClass + @".h"; data.PluginSourceFile = data.PluginClass + @".cpp"; var wizard = new WizardWindow(new List <WizardPage> { new IntroPage { Data = data, Header = @"Welcome to the Qt Custom Designer Widget", Message = @"This wizard generates a custom designer widget which can be " + @"used in Qt Designer or Visual Studio." + System.Environment.NewLine + System.Environment.NewLine + "To continue, click Next.", PreviousButtonEnabled = false, NextButtonEnabled = true, FinishButtonEnabled = false, CancelButtonEnabled = true }, new ModulePage { Data = data, Header = @"Welcome to the Qt Custom Designer Widget", Message = @"Select the modules you want to include in your project. The " + @"recommended modules for this project are selected by default.", PreviousButtonEnabled = true, NextButtonEnabled = true, FinishButtonEnabled = false, CancelButtonEnabled = true }, new DesignerPage { Data = data, Header = @"Welcome to the Qt Custom Designer Widget", Message = @"This wizard generates a custom designer widget which can be " + @"used in Qt Designer or Visual Studio.", PreviousButtonEnabled = true, NextButtonEnabled = false, FinishButtonEnabled = data.DefaultModules.All(QtModuleInfo.IsInstalled), CancelButtonEnabled = true } }) { Title = @"Qt Custom Designer Widget" }; WindowHelper.ShowModal(wizard, hwnd); if (!wizard.DialogResult.HasValue || !wizard.DialogResult.Value) { throw new System.Exception("Unexpected wizard return value."); } } catch (QtVSException exception) { Messages.DisplayErrorMessage(exception.Message); throw; // re-throw, but keep the original exception stack intact } var version = (automation as DTE).Version; replacements["$ToolsVersion$"] = version; var vm = QtVersionManager.The(); var vi = VersionInformation.Get(vm.GetInstallPath(vm.GetDefaultVersion())); replacements["$Platform$"] = vi.GetVSPlatformName(); replacements["$Keyword$"] = Resources.qtProjectKeyword; replacements["$ProjectGuid$"] = @"{B12702AD-ABFB-343A-A199-8E24837244A3}"; replacements["$PlatformToolset$"] = version.Replace(".", string.Empty); replacements["$classname$"] = data.ClassName; replacements["$baseclass$"] = data.BaseClass; replacements["$sourcefilename$"] = data.ClassSourceFile; replacements["$headerfilename$"] = data.ClassHeaderFile; replacements["$plugin_class$"] = data.PluginClass; replacements["$pluginsourcefilename$"] = data.PluginSourceFile; replacements["$pluginheaderfilename$"] = data.PluginHeaderFile; replacements["$plugin_json$"] = data.PluginClass.ToLower() + @".json"; replacements["$objname$"] = char.ToLower(data.ClassName[0]) + data.ClassName .Substring(1); replacements["$precompiledheader$"] = string.Empty; replacements["$precompiledsource$"] = string.Empty; var strHeaderInclude = data.ClassHeaderFile; if (data.UsePrecompiledHeader) { strHeaderInclude = "stdafx.h\"\r\n#include \"" + data.ClassHeaderFile; replacements["$precompiledheader$"] = "<None Include=\"stdafx.h\" />"; replacements["$precompiledsource$"] = "<None Include=\"stdafx.cpp\" />"; } replacements["$include$"] = strHeaderInclude; } catch { try { Directory.Delete(replacements["$destinationdirectory$"]); Directory.Delete(replacements["$solutiondirectory$"]); } catch { } iVsUIShell.EnableModeless(1); throw new WizardBackoutException(); } iVsUIShell.EnableModeless(1); }
public void RunStarted(object automation, Dictionary <string, string> replacements, WizardRunKind runKind, object[] customParams) { var serviceProvider = new ServiceProvider(automation as IServiceProvider); var iVsUIShell = serviceProvider.GetService(typeof(SVsUIShell)) as IVsUIShell; iVsUIShell.EnableModeless(0); var versionMgr = QtVersionManager.The(); var versionName = versionMgr.GetDefaultVersion(); var versionInfo = VersionInformation.Get(versionMgr.GetInstallPath(versionName)); if (versionInfo.isWinRT()) { MessageBox.Show( string.Format( "The Qt ActiveQt Server project type is not available\r\n" + "for the currently selected Qt version ({0}).", versionName), "Project Type Not Available", MessageBoxButtons.OK, MessageBoxIcon.Error); iVsUIShell.EnableModeless(1); throw new WizardBackoutException(); } try { System.IntPtr hwnd; iVsUIShell.GetDialogOwnerHwnd(out hwnd); try { // midl.exe does not support spaces in project name. Fails while generating the // IDL file (library attribute), e.g. 'library Active QtServer1Lib' is illegal. if (replacements["$safeprojectname$"].Contains(" ")) { throw new QtVSException("Project name shall not contain spaces."); } safeprojectname = replacements["$safeprojectname$"]; var result = new ClassNameValidationRule().Validate(safeprojectname, null); if (result != ValidationResult.ValidResult) { safeprojectname = @"ActiveQtServer"; } data.ClassName = safeprojectname; data.ClassHeaderFile = safeprojectname + @".h"; data.ClassSourceFile = safeprojectname + @".cpp"; data.UiFile = data.ClassName + @".ui"; var wizard = new WizardWindow(new List <WizardPage> { new IntroPage { Data = data, Header = @"Welcome to the Qt ActiveQt Server Wizard", Message = @"This wizard generates a Qt ActiveQt server project. It " + @"creates a simple ActiveQt widget with the required files." + System.Environment.NewLine + System.Environment.NewLine + "To continue, click Next.", PreviousButtonEnabled = false, NextButtonEnabled = true, FinishButtonEnabled = false, CancelButtonEnabled = true }, new ModulePage { Data = data, Header = @"Welcome to the Qt ActiveQt Server Wizard", Message = @"Select the modules you want to include in your project. The " + @"recommended modules for this project are selected by default.", PreviousButtonEnabled = true, NextButtonEnabled = true, FinishButtonEnabled = false, CancelButtonEnabled = true }, new ServerPage { Data = data, Header = @"Welcome to the Qt ActiveQt Server Wizard", Message = @"This wizard generates a Qt ActiveQt server project. It " + @"creates a simple ActiveQt widget with the required files.", PreviousButtonEnabled = true, NextButtonEnabled = false, FinishButtonEnabled = data.DefaultModules.All(QtModuleInfo.IsInstalled), CancelButtonEnabled = true } }) { Title = @"Qt ActiveQt Server Wizard" }; WindowHelper.ShowModal(wizard, hwnd); if (!wizard.DialogResult.HasValue || !wizard.DialogResult.Value) { throw new System.Exception("Unexpected wizard return value."); } } catch (QtVSException exception) { Messages.DisplayErrorMessage(exception.Message); throw; // re-throw, but keep the original exception stack intact } var version = (automation as DTE).Version; replacements["$ToolsVersion$"] = version; replacements["$Platform$"] = versionInfo.GetVSPlatformName(); replacements["$Keyword$"] = Resources.qtProjectKeyword; replacements["$ProjectGuid$"] = @"{B12702AD-ABFB-343A-A199-8E24837244A3}"; replacements["$PlatformToolset$"] = BuildConfig.PlatformToolset(version); replacements["$classname$"] = data.ClassName; replacements["$sourcefilename$"] = data.ClassSourceFile; replacements["$headerfilename$"] = data.ClassHeaderFile; replacements["$uifilename$"] = data.UiFile; replacements["$precompiledheader$"] = string.Empty; replacements["$precompiledsource$"] = string.Empty; var strHeaderInclude = data.ClassHeaderFile; if (data.UsePrecompiledHeader) { strHeaderInclude = "stdafx.h\"\r\n#include \"" + data.ClassHeaderFile; replacements["$precompiledheader$"] = "<None Include=\"stdafx.h\" />"; replacements["$precompiledsource$"] = "<None Include=\"stdafx.cpp\" />"; } replacements["$include$"] = strHeaderInclude; replacements["$ui_hdr$"] = "ui_" + Path.GetFileNameWithoutExtension(data.UiFile) + ".h"; safeprojectname = data.LowerCaseFileNames ? safeprojectname.ToLower() : safeprojectname; replacements["$pro_name$"] = safeprojectname; #if (VS2017 || VS2015) string versionWin10SDK = HelperFunctions.GetWindows10SDKVersion(); if (!string.IsNullOrEmpty(versionWin10SDK)) { replacements["$WindowsTargetPlatformVersion$"] = versionWin10SDK; replacements["$isSet_WindowsTargetPlatformVersion$"] = "true"; } #endif } catch { try { Directory.Delete(replacements["$destinationdirectory$"]); Directory.Delete(replacements["$solutiondirectory$"]); } catch { } iVsUIShell.EnableModeless(1); throw new WizardBackoutException(); } iVsUIShell.EnableModeless(1); }
public void RunStarted(object automation, Dictionary <string, string> replacements, WizardRunKind runKind, object[] customParams) { var serviceProvider = new ServiceProvider(automation as IServiceProvider); var iVsUIShell = serviceProvider.GetService(typeof(SVsUIShell)) as IVsUIShell; iVsUIShell.EnableModeless(0); try { System.IntPtr hwnd; iVsUIShell.GetDialogOwnerHwnd(out hwnd); try { var className = replacements["$safeprojectname$"]; className = Regex.Replace(className, @"[^a-zA-Z0-9_]", string.Empty); className = Regex.Replace(className, @"^[\d-]*\s*", string.Empty); var result = new ClassNameValidationRule().Validate(className, null); if (result != ValidationResult.ValidResult) { className = @"QtGuiApplication"; } data.ClassName = className; data.BaseClass = @"QMainWindow"; data.ClassHeaderFile = className + @".h"; data.ClassSourceFile = className + @".cpp"; data.UiFile = data.ClassName + @".ui"; data.QrcFile = data.ClassName + @".qrc"; var wizard = new WizardWindow(new List <WizardPage> { new IntroPage { Data = data, Header = @"Welcome to the Qt GUI Application Wizard", Message = @"This wizard generates a Qt GUI application project. The " + @"application derives from QApplication and includes an empty " + @"widget." + System.Environment.NewLine + System.Environment.NewLine + "To continue, click Next.", PreviousButtonEnabled = false, NextButtonEnabled = true, FinishButtonEnabled = false, CancelButtonEnabled = true }, new ModulePage { Data = data, Header = @"Welcome to the Qt GUI Application Wizard", Message = @"Select the modules you want to include in your project. The " + @"recommended modules for this project are selected by default.", PreviousButtonEnabled = true, NextButtonEnabled = true, FinishButtonEnabled = false, CancelButtonEnabled = true }, new GuiPage { Data = data, Header = @"Welcome to the Qt GUI Application Wizard", Message = @"This wizard generates a Qt GUI application project. The " + @"application derives from QApplication and includes an empty " + @"widget.", PreviousButtonEnabled = true, NextButtonEnabled = false, FinishButtonEnabled = data.DefaultModules.All(QtModuleInfo.IsInstalled), CancelButtonEnabled = true } }) { Title = @"Qt GUI Application Wizard" }; WindowHelper.ShowModal(wizard, hwnd); if (!wizard.DialogResult.HasValue || !wizard.DialogResult.Value) { throw new System.Exception("Unexpected wizard return value."); } } catch (QtVSException exception) { Messages.DisplayErrorMessage(exception.Message); throw; // re-throw, but keep the original exception stack intact } var version = (automation as DTE).Version; replacements["$ToolsVersion$"] = version; var vm = QtVersionManager.The(); var vi = VersionInformation.Get(vm.GetInstallPath(vm.GetDefaultVersion())); replacements["$Platform$"] = vi.GetVSPlatformName(); replacements["$Keyword$"] = Resources.qtProjectKeyword; replacements["$ProjectGuid$"] = @"{B12702AD-ABFB-343A-A199-8E24837244A3}"; replacements["$PlatformToolset$"] = version.Replace(".", string.Empty); replacements["$classname$"] = data.ClassName; replacements["$baseclass$"] = data.BaseClass; replacements["$sourcefilename$"] = data.ClassSourceFile; replacements["$headerfilename$"] = data.ClassHeaderFile; replacements["$uifilename$"] = data.UiFile; replacements["$precompiledheader$"] = string.Empty; replacements["$precompiledsource$"] = string.Empty; replacements["$DefaultApplicationIcon$"] = string.Empty; replacements["$centralwidget$"] = string.Empty; var strHeaderInclude = data.ClassHeaderFile; if (data.UsePrecompiledHeader) { strHeaderInclude = "stdafx.h\"\r\n#include \"" + data.ClassHeaderFile; replacements["$precompiledheader$"] = "<None Include=\"stdafx.h\" />"; replacements["$precompiledsource$"] = "<None Include=\"stdafx.cpp\" />"; } replacements["$include$"] = strHeaderInclude; replacements["$ui_hdr$"] = "ui_" + Path.GetFileNameWithoutExtension(data.UiFile) + ".h"; replacements["$qrcfilename$"] = data.QrcFile; if (data.BaseClass == "QMainWindow") { replacements["$centralwidget$"] = "\r\n <widget class=\"QMenuBar\" name=\"menuBar\" />" + "\r\n <widget class=\"QToolBar\" name=\"mainToolBar\" />" + "\r\n <widget class=\"QWidget\" name=\"centralWidget\" />" + "\r\n <widget class=\"QStatusBar\" name=\"statusBar\" />"; } if (data.AddDefaultAppIcon) { replacements["$DefaultApplicationIcon$"] = "<None Include=\"gui.ico\" />"; } } catch { try { Directory.Delete(replacements["$destinationdirectory$"]); Directory.Delete(replacements["$solutiondirectory$"]); } catch { } iVsUIShell.EnableModeless(1); throw new WizardBackoutException(); } iVsUIShell.EnableModeless(1); }
public override void SaveSettingsToStorage() { foreach (var versionName in VersionManager.GetVersions()) { try { VersionManager.RemoveVersion(versionName); } catch (Exception exception) { Messages.Print( exception.Message + "\r\n\r\nStacktrace:\r\n" + exception.StackTrace); } } foreach (var version in VersionsTable.Versions) { try { if (version.Host == BuildHost.Windows) { var versionInfo = VersionInformation.Get(version.Path); var generator = versionInfo.GetQMakeConfEntry("MAKEFILE_GENERATOR"); if (generator != "MSVC.NET" && generator != "MSBUILD") { throw new Exception(string.Format( "This Qt version uses an unsupported makefile generator (used: " + "{0}, supported: MSVC.NET, MSBUILD)", generator)); } VersionManager.SaveVersion(version.VersionName, version.Path); } else { string name = version.VersionName; string access = (version.Host == BuildHost.LinuxSSH) ? "SSH" : "WSL"; string path = version.Path; string compiler = version.Compiler; if (compiler == "g++") { compiler = string.Empty; } path = string.Format("{0}:{1}:{2}", access, path, compiler); VersionManager.SaveVersion(name, path, checkPath: false); } } catch (Exception exception) { Messages.Print( exception.Message + "\r\n\r\nStacktrace:\r\n" + exception.StackTrace); } } try { var defaultVersion = VersionsTable.Versions .Where(version => version.IsDefault) .FirstOrDefault(); if (defaultVersion != null) { VersionManager.SaveDefaultVersion(defaultVersion.VersionName); } } catch (Exception exception) { Messages.Print( exception.Message + "\r\n\r\nStacktrace:\r\n" + exception.StackTrace); } if (InfoBarMessages.NoQtVersion.IsOpen && VersionManager.GetVersions()?.Any() == true) { InfoBarMessages.NoQtVersion.Close(); } }