本文整理汇总了C++中IDesktopPlatform类的典型用法代码示例。如果您正苦于以下问题:C++ IDesktopPlatform类的具体用法?C++ IDesktopPlatform怎么用?C++ IDesktopPlatform使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了IDesktopPlatform类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OpenFiles
/**** @param Title The title of the dialog
* @param FileTypes Filter for which file types are accepted and should be shown
* @param InOutLastPath Keep track of the last location from which the user attempted an import
* @param DialogMode Multiple items vs single item.
* @param OutOpenFilenames The list of filenames that the user attempted to open
*
* @return true if the dialog opened successfully and the user accepted; false otherwise.
*/
bool OpenFiles( const FString& Title, const FString& FileTypes, FString& InOutLastPath, EFileDialogFlags::Type DialogMode, TArray<FString>& OutOpenFilenames )
{
IDesktopPlatform* DesktopPlatform = FDesktopPlatformModule::Get();
bool bOpened = false;
if ( DesktopPlatform )
{
bOpened = DesktopPlatform->OpenFileDialog(
ChooseParentWindowHandle(),
Title,
InOutLastPath,
TEXT(""),
FileTypes,
DialogMode,
OutOpenFilenames
);
}
bOpened = (OutOpenFilenames.Num() > 0);
if ( bOpened )
{
// User successfully chose a file; remember the path for the next time the dialog opens.
InOutLastPath = OutOpenFilenames[0];
}
return bOpened;
}
示例2: GetTarget
FReply SLocalizationDashboardTargetRow::ExportAll()
{
ULocalizationTarget* const LocalizationTarget = GetTarget();
IDesktopPlatform* DesktopPlatform = FDesktopPlatformModule::Get();
if (LocalizationTarget && DesktopPlatform)
{
void* ParentWindowWindowHandle = NULL;
const TSharedPtr<SWindow> ParentWindow = FSlateApplication::Get().FindWidgetWindow(AsShared());
if (ParentWindow.IsValid() && ParentWindow->GetNativeWindow().IsValid())
{
ParentWindowWindowHandle = ParentWindow->GetNativeWindow()->GetOSWindowHandle();
}
const FString DefaultPath = FPaths::ConvertRelativePathToFull(LocalizationConfigurationScript::GetDataDirectory(LocalizationTarget->Settings));
FText DialogTitle;
{
FFormatNamedArguments FormatArguments;
FormatArguments.Add(TEXT("TargetName"), FText::FromString(LocalizationTarget->Settings.Name));
DialogTitle = FText::Format(LOCTEXT("ExportAllTranslationsForTargetDialogTitleFormat", "Export All Translations for {TargetName} to Directory"), FormatArguments);
}
// Prompt the user for the directory
FString OutputDirectory;
if (DesktopPlatform->OpenDirectoryDialog(ParentWindowWindowHandle, DialogTitle.ToString(), DefaultPath, OutputDirectory))
{
LocalizationCommandletTasks::ExportTarget(ParentWindow.ToSharedRef(), LocalizationTarget->Settings, TOptional<FString>(OutputDirectory));
}
}
return FReply::Handled();
}
示例3: HandleBrowseButtonClicked
FReply SSessionLauncherDeployRepositorySettings::HandleBrowseButtonClicked( )
{
IDesktopPlatform* DesktopPlatform = FDesktopPlatformModule::Get();
if ( DesktopPlatform )
{
void* ParentWindowWindowHandle = NULL;
FString FolderName;
const FString Title = LOCTEXT("RepositoryBrowseTitle", "Choose a repository location").ToString();
const bool bFolderSelected = DesktopPlatform->OpenDirectoryDialog(
0,
Title,
RepositoryPathTextBox->GetText().ToString(),
FolderName
);
if ( bFolderSelected )
{
if ( !FolderName.EndsWith(TEXT("/")) )
{
FolderName += TEXT("/");
}
RepositoryPathTextBox->SetText(FText::FromString(FolderName));
ILauncherProfilePtr SelectedProfile = Model->GetSelectedProfile();
if(SelectedProfile.IsValid())
{
SelectedProfile->SetPackageDirectory(FolderName);
}
}
}
return FReply::Handled();
}
示例4: ExecuteExportAsJSON
void FAssetTypeActions_DataTable::ExecuteExportAsJSON(TArray< TWeakObjectPtr<UObject> > Objects)
{
IDesktopPlatform* DesktopPlatform = FDesktopPlatformModule::Get();
const void* ParentWindowWindowHandle = FSlateApplication::Get().FindBestParentWindowHandleForDialogs(nullptr);
for (auto ObjIt = Objects.CreateConstIterator(); ObjIt; ++ObjIt)
{
auto DataTable = Cast<UDataTable>((*ObjIt).Get());
if (DataTable)
{
const FText Title = FText::Format(LOCTEXT("DataTable_ExportJSONDialogTitle", "Export '{0}' as JSON..."), FText::FromString(*DataTable->GetName()));
const FString CurrentFilename = DataTable->AssetImportData->GetFirstFilename();
const FString FileTypes = TEXT("Data Table JSON (*.json)|*.json");
TArray<FString> OutFilenames;
DesktopPlatform->SaveFileDialog(
ParentWindowWindowHandle,
Title.ToString(),
(CurrentFilename.IsEmpty()) ? TEXT("") : FPaths::GetPath(CurrentFilename),
(CurrentFilename.IsEmpty()) ? TEXT("") : FPaths::GetBaseFilename(CurrentFilename) + TEXT(".json"),
FileTypes,
EFileDialogFlags::None,
OutFilenames
);
if (OutFilenames.Num() > 0)
{
FFileHelper::SaveStringToFile(DataTable->GetTableAsJSON(EDataTableExportFlags::UsePrettyPropertyNames | EDataTableExportFlags::UsePrettyEnumNames | EDataTableExportFlags::UseJsonObjectsForStructs), *OutFilenames[0]);
}
}
}
}
示例5: SearchForExport
void UJanusExporterTool::SearchForExport()
{
// If not prompting individual files, prompt the user to select a target directory.
IDesktopPlatform* DesktopPlatform = FDesktopPlatformModule::Get();
void* ParentWindowWindowHandle = NULL;
IMainFrameModule& MainFrameModule = FModuleManager::LoadModuleChecked<IMainFrameModule>(TEXT("MainFrame"));
const TSharedPtr<SWindow>& MainFrameParentWindow = MainFrameModule.GetParentWindow();
if (MainFrameParentWindow.IsValid() && MainFrameParentWindow->GetNativeWindow().IsValid())
{
ParentWindowWindowHandle = MainFrameParentWindow->GetNativeWindow()->GetOSWindowHandle();
}
FString FolderName;
const FString Title = NSLOCTEXT("UnrealEd", "ChooseADirectory", "Choose A Directory").ToString();
const bool bFolderSelected = DesktopPlatform->OpenDirectoryDialog(
ParentWindowWindowHandle,
Title,
ExportPath,
FolderName
);
if (bFolderSelected)
{
ExportPath = FolderName.Append("//");
}
}
示例6: SaveFile
/**** @param Title The title of the dialog
* @param FileTypes Filter for which file types are accepted and should be shown
* @param InOutLastPath Keep track of the last location from which the user attempted an import
* @param DefaultFile Default file name to use for saving.
* @param OutOpenFilenames The list of filenames that the user attempted to open
*
* @return true if the dialog opened successfully and the user accepted; false otherwise.
*/
bool SaveFile( const FString& Title, const FString& FileTypes, FString& InOutLastPath, const FString& DefaultFile, FString& OutFilename )
{
OutFilename = FString();
IDesktopPlatform* DesktopPlatform = FDesktopPlatformModule::Get();
bool bFileChosen = false;
TArray<FString> OutFilenames;
if (DesktopPlatform)
{
bFileChosen = DesktopPlatform->SaveFileDialog(
ChooseParentWindowHandle(),
Title,
InOutLastPath,
DefaultFile,
FileTypes,
EFileDialogFlags::None,
OutFilenames
);
}
bFileChosen = (OutFilenames.Num() > 0);
if (bFileChosen)
{
// User successfully chose a file; remember the path for the next time the dialog opens.
InOutLastPath = OutFilenames[0];
OutFilename = OutFilenames[0];
}
return bFileChosen;
}
示例7: HandleSaveCommandExecute
void SVisualLogger::HandleSaveCommandExecute()
{
TArray<TSharedPtr<class STimeline> > OutTimelines;
MainView->GetTimelines(OutTimelines, true);
if (OutTimelines.Num() == 0)
{
MainView->GetTimelines(OutTimelines);
}
if (OutTimelines.Num())
{
// Prompt the user for the filenames
TArray<FString> SaveFilenames;
IDesktopPlatform* DesktopPlatform = FDesktopPlatformModule::Get();
bool bSaved = false;
if (DesktopPlatform)
{
void* ParentWindowWindowHandle = NULL;
IMainFrameModule& MainFrameModule = FModuleManager::LoadModuleChecked<IMainFrameModule>(TEXT("MainFrame"));
const TSharedPtr<SWindow>& MainFrameParentWindow = MainFrameModule.GetParentWindow();
if (MainFrameParentWindow.IsValid() && MainFrameParentWindow->GetNativeWindow().IsValid())
{
ParentWindowWindowHandle = MainFrameParentWindow->GetNativeWindow()->GetOSWindowHandle();
}
const FString DefaultBrowsePath = FString::Printf(TEXT("%slogs/"), *FPaths::GameSavedDir());
bSaved = DesktopPlatform->SaveFileDialog(
ParentWindowWindowHandle,
LOCTEXT("NewProjectBrowseTitle", "Choose a project location").ToString(),
DefaultBrowsePath,
TEXT(""),
LogVisualizer::SaveFileTypes,
EFileDialogFlags::None,
SaveFilenames
);
}
if (bSaved)
{
if (SaveFilenames.Num() > 0)
{
TArray<FVisualLogDevice::FVisualLogEntryItem> FrameCache;
for (auto CurrentItem : OutTimelines)
{
FrameCache.Append(CurrentItem->GetEntries());
}
if (FrameCache.Num())
{
FArchive* FileArchive = IFileManager::Get().CreateFileWriter(*SaveFilenames[0]);
FVisualLoggerHelpers::Serialize(*FileArchive, FrameCache);
FileArchive->Close();
delete FileArchive;
FileArchive = NULL;
}
}
}
}
}
示例8: PickFile
bool FRealSenseInspectorCustomization::PickFile(FString& OutPath, const void* ParentWindow, const FString& Title, const FString& Filter, bool SaveFlag)
{
IDesktopPlatform* DesktopPlatform = FDesktopPlatformModule::Get();
if (DesktopPlatform)
{
TArray<FString> OutFiles;
if (SaveFlag)
{
auto DefaultPath = FEditorDirectories::Get().GetLastDirectory(ELastDirectory::GENERIC_SAVE);
if (DesktopPlatform->SaveFileDialog(ParentWindow, Title, DefaultPath, TEXT(""), Filter, EFileDialogFlags::None, OutFiles))
{
OutPath = OutFiles[0];
return true;
}
}
else
{
auto DefaultPath = FEditorDirectories::Get().GetLastDirectory(ELastDirectory::GENERIC_OPEN);
if (DesktopPlatform->OpenFileDialog(ParentWindow, Title, DefaultPath, TEXT(""), Filter, EFileDialogFlags::None, OutFiles))
{
OutPath = OutFiles[0];
return true;
}
}
}
return false;
}
示例9: HandleBrowseButtonClicked
FReply SProjectLauncherDeployRepositorySettings::HandleBrowseButtonClicked( )
{
IDesktopPlatform* DesktopPlatform = FDesktopPlatformModule::Get();
if ( DesktopPlatform )
{
TSharedPtr<SWindow> ParentWindow = FSlateApplication::Get().FindWidgetWindow(AsShared());
void* ParentWindowHandle = (ParentWindow.IsValid() && ParentWindow->GetNativeWindow().IsValid()) ? ParentWindow->GetNativeWindow()->GetOSWindowHandle() : nullptr;
FString FolderName;
const bool bFolderSelected = DesktopPlatform->OpenDirectoryDialog(
ParentWindowHandle,
LOCTEXT("RepositoryBrowseTitle", "Choose a repository location").ToString(),
RepositoryPathTextBox->GetText().ToString(),
FolderName
);
if ( bFolderSelected )
{
if ( !FolderName.EndsWith(TEXT("/")) )
{
FolderName += TEXT("/");
}
RepositoryPathTextBox->SetText(FText::FromString(FolderName));
ILauncherProfilePtr SelectedProfile = Model->GetSelectedProfile();
if(SelectedProfile.IsValid())
{
SelectedProfile->SetPackageDirectory(FolderName);
}
}
}
return FReply::Handled();
}
示例10: ShowStorePageForPlugin
void SAuthorizingPlugin::ShowStorePageForPlugin()
{
IDesktopPlatform* DesktopPlatform = FDesktopPlatformModule::Get();
if ( DesktopPlatform != nullptr )
{
FOpenLauncherOptions StorePageOpen(FString(TEXT("/ue/marketplace/content/")) + PluginOfferId);
DesktopPlatform->OpenLauncher(StorePageOpen);
}
}
示例11: HandleLoadCommandExecute
void SVisualLogger::HandleLoadCommandExecute()
{
FArchive Ar;
TArray<FVisualLogDevice::FVisualLogEntryItem> RecordedLogs;
TArray<FString> OpenFilenames;
IDesktopPlatform* DesktopPlatform = FDesktopPlatformModule::Get();
bool bOpened = false;
if (DesktopPlatform)
{
void* ParentWindowWindowHandle = NULL;
IMainFrameModule& MainFrameModule = FModuleManager::LoadModuleChecked<IMainFrameModule>(TEXT("MainFrame"));
const TSharedPtr<SWindow>& MainFrameParentWindow = MainFrameModule.GetParentWindow();
if (MainFrameParentWindow.IsValid() && MainFrameParentWindow->GetNativeWindow().IsValid())
{
ParentWindowWindowHandle = MainFrameParentWindow->GetNativeWindow()->GetOSWindowHandle();
}
const FString DefaultBrowsePath = FString::Printf(TEXT("%slogs/"), *FPaths::GameSavedDir());
bOpened = DesktopPlatform->OpenFileDialog(
ParentWindowWindowHandle,
LOCTEXT("OpenProjectBrowseTitle", "Open Project").ToString(),
DefaultBrowsePath,
TEXT(""),
LogVisualizer::LoadFileTypes,
EFileDialogFlags::None,
OpenFilenames
);
}
if (bOpened && OpenFilenames.Num() > 0)
{
OnNewWorld(nullptr);
for (int FilenameIndex = 0; FilenameIndex < OpenFilenames.Num(); ++FilenameIndex)
{
FString CurrentFileName = OpenFilenames[FilenameIndex];
const bool bIsBinaryFile = CurrentFileName.Find(TEXT(".bvlog")) != INDEX_NONE;
if (bIsBinaryFile)
{
FArchive* FileAr = IFileManager::Get().CreateFileReader(*CurrentFileName);
FVisualLoggerHelpers::Serialize(*FileAr, RecordedLogs);
FileAr->Close();
delete FileAr;
FileAr = NULL;
for (FVisualLogDevice::FVisualLogEntryItem& CurrentItem : RecordedLogs)
{
OnNewLogEntry(CurrentItem);
}
}
}
}
}
示例12: Submit
FReply FCrashReportClient::SubmitAndRestart()
{
Submit();
// Check for processes that were started from the Launcher using -EpicPortal on the command line
bool bRunFromLauncher = FParse::Param(*FPrimaryCrashProperties::Get()->RestartCommandLine, TEXT("EPICPORTAL"));
const FString CrashedAppPath = ErrorReport.FindCrashedAppPath();
bool bLauncherRestarted = false;
if (bRunFromLauncher)
{
// We'll restart Launcher-run processes by having the installed Launcher handle it
IDesktopPlatform* DesktopPlatform = FDesktopPlatformModule::Get();
if (DesktopPlatform != nullptr)
{
// Split the path so we can format it as a URI
TArray<FString> PathArray;
CrashedAppPath.Replace(TEXT("//"), TEXT("/")).ParseIntoArray(PathArray, TEXT("/"), false); // WER saves this out on Windows with double slashes as the separator for some reason.
FString CrashedAppPathUri;
// Exclude the last item (the filename). The Launcher currently expects an installed application folder.
for (int32 ItemIndex = 0; ItemIndex < PathArray.Num() - 1; ItemIndex++)
{
FString& PathItem = PathArray[ItemIndex];
CrashedAppPathUri += FPlatformHttp::UrlEncode(PathItem);
CrashedAppPathUri += TEXT("/");
}
CrashedAppPathUri.RemoveAt(CrashedAppPathUri.Len() - 1);
// Re-run the application via the Launcher
FOpenLauncherOptions OpenOptions(FString::Printf(TEXT("apps/%s"), *CrashedAppPathUri));
OpenOptions.bSilent = true;
if (DesktopPlatform->OpenLauncher(OpenOptions))
{
bLauncherRestarted = true;
}
}
}
if (!bLauncherRestarted)
{
// Launcher didn't restart the process so start it ourselves
const FString CommandLineArguments = FPrimaryCrashProperties::Get()->RestartCommandLine;
FPlatformProcess::CreateProc(*CrashedAppPath, *CommandLineArguments, true, false, false, NULL, 0, NULL, NULL);
}
return FReply::Handled();
}
示例13: OpenFileDialog
void AFilePickerCharacter::OpenFileDialog(const FString& DialogTitle, const FString& DefaultPath, const FString& FileTypes, TArray<FString>& OutFileNames)
{
if (GEngine)
{
if (GEngine->GameViewport)
{
void* ParentWindowHandle = GEngine->GameViewport->GetWindow()->GetNativeWindow()->GetOSWindowHandle();
IDesktopPlatform* DesktopPlatform = FDesktopPlatformModule::Get();
if (DesktopPlatform)
{
//Opening the file picker!
uint32 SelectionFlag = 0; //A value of 0 represents single file selection while a value of 1 represents multiple file selection
DesktopPlatform->OpenFileDialog(ParentWindowHandle, DialogTitle, DefaultPath, FString(""), FileTypes, SelectionFlag, OutFileNames);
}
}
}
}
示例14: GenerateProjectFiles
bool GenerateProjectFiles(const FString& ProjectFileName)
{
IDesktopPlatform* DesktopPlatform = FDesktopPlatformModule::Get();
// Check it's a code project
FString SourceDir = FPaths::GetPath(ProjectFileName) / TEXT("Source");
if(!IPlatformFile::GetPlatformPhysical().DirectoryExists(*SourceDir))
{
FPlatformMisc::MessageBoxExt(EAppMsgType::Ok, TEXT("This project does not have any source code. You need to add C++ source files to the project from the Editor before you can generate project files."), TEXT("Error"));
return false;
}
// Get the engine root directory
FString RootDir;
if (!GetValidatedEngineRootDir(ProjectFileName, RootDir))
{
return false;
}
// Build the argument list
FString Arguments = TEXT("-game");
if (FDesktopPlatformModule::Get()->IsSourceDistribution(RootDir))
{
Arguments += TEXT(" -engine");
}
// Start capturing the log output
FStringOutputDevice LogCapture;
LogCapture.SetAutoEmitLineTerminator(true);
GLog->AddOutputDevice(&LogCapture);
// Generate project files
FFeedbackContext* Warn = DesktopPlatform->GetNativeFeedbackContext();
bool bResult = DesktopPlatform->GenerateProjectFiles(RootDir, ProjectFileName, Warn);
GLog->RemoveOutputDevice(&LogCapture);
// Display an error dialog if we failed
if(!bResult)
{
FPlatformInstallation::ErrorDialog(TEXT("Failed to generate project files."), LogCapture);
return false;
}
return true;
}
示例15: ExecuteExportAsCSV
void FAssetTypeActions_CurveTable::ExecuteExportAsCSV(TArray< TWeakObjectPtr<UObject> > Objects)
{
IDesktopPlatform* DesktopPlatform = FDesktopPlatformModule::Get();
void* ParentWindowWindowHandle = nullptr;
IMainFrameModule& MainFrameModule = FModuleManager::LoadModuleChecked<IMainFrameModule>(TEXT("MainFrame"));
const TSharedPtr<SWindow>& MainFrameParentWindow = MainFrameModule.GetParentWindow();
if ( MainFrameParentWindow.IsValid() && MainFrameParentWindow->GetNativeWindow().IsValid() )
{
ParentWindowWindowHandle = MainFrameParentWindow->GetNativeWindow()->GetOSWindowHandle();
}
for (auto ObjIt = Objects.CreateConstIterator(); ObjIt; ++ObjIt)
{
auto CurTable = Cast<UCurveTable>((*ObjIt).Get());
if (CurTable)
{
const FText Title = FText::Format(LOCTEXT("CurveTable_ExportCSVDialogTitle", "Export '{0}' as CSV..."), FText::FromString(*CurTable->GetName()));
const FString CurrentFilename = (CurTable->ImportPath.IsEmpty()) ? TEXT("") : FReimportManager::ResolveImportFilename(CurTable->ImportPath, CurTable);
const FString FileTypes = TEXT("Curve Table CSV (*.csv)|*.csv");
TArray<FString> OutFilenames;
DesktopPlatform->SaveFileDialog(
ParentWindowWindowHandle,
Title.ToString(),
(CurrentFilename.IsEmpty()) ? TEXT("") : FPaths::GetPath(CurrentFilename),
(CurrentFilename.IsEmpty()) ? TEXT("") : FPaths::GetBaseFilename(CurrentFilename) + TEXT(".csv"),
FileTypes,
EFileDialogFlags::None,
OutFilenames
);
if (OutFilenames.Num() > 0)
{
FFileHelper::SaveStringToFile(CurTable->GetTableAsCSV(), *OutFilenames[0]);
}
}
}
}