Skip to content

Commit

Permalink
Merge pull request #101 from its5Q/dev
Browse files Browse the repository at this point in the history
(Platform) Fixed pasting with non-text contents, fixed opening files in associated apps.
  • Loading branch information
innerviewer committed Dec 5, 2023
2 parents 5953dc7 + 59aad11 commit df66c0e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
1 change: 0 additions & 1 deletion Engine/Core/libs/Utils/inc/Utils/Platform/Platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ namespace SR_UTILS_NS::Platform {
SR_DLL_EXPORT extern bool IsExists(const Path& path);
SR_DLL_EXPORT extern bool FileIsHidden(const Path& path);
SR_DLL_EXPORT extern std::list<Path> GetInDirectory(const Path& dir, Path::Type type);
SR_DLL_EXPORT extern void OpenInNativeFileExplorer(const Path& dir);
}

#endif //SR_ENGINE_UTILS_PLATFORM_H
10 changes: 5 additions & 5 deletions Engine/Core/libs/Utils/src/Utils/Platform/PlatformWindows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,11 +217,14 @@ namespace SR_UTILS_NS::Platform {
}

std::string GetClipboardText() {
std::string text;
std::string text{};

if (OpenClipboard(NULL)) {
HANDLE hData = GetClipboardData(CF_TEXT);

if (hData == nullptr)
return text;

const uint64_t size = GlobalSize(hData);
if (size > 0) {
char *pszText = static_cast<char *>(GlobalLock(hData));
Expand Down Expand Up @@ -324,9 +327,6 @@ namespace SR_UTILS_NS::Platform {
#endif
}

void OpenWithAssociatedApp(const Path &filepath) {
system(filepath.ToString().c_str());
}

bool Copy(const Path &from, const Path &to) {
if (from.IsFile()) {
Expand Down Expand Up @@ -481,7 +481,7 @@ namespace SR_UTILS_NS::Platform {
return view.size() >= 2 && view[1] == ':';
}

void OpenInNativeFileExplorer(const Path &path){
void OpenWithAssociatedApp(const Path &path){
ShellExecuteA(NULL, "open", path.ToString().c_str(), NULL, NULL, SW_SHOWDEFAULT);
}

Expand Down
2 changes: 1 addition & 1 deletion Engine/Core/src/Core/GUI/FileBrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ namespace SR_CORE_NS::GUI {
m_dirtySelectedDir = true;
}
if (ImGui::Selectable("Open in native Explorer")) {
SR_UTILS_NS::Platform::OpenInNativeFileExplorer(m_selectedDir);
SR_UTILS_NS::Platform::OpenWithAssociatedApp(m_selectedDir);
}
if (ImGui::Selectable("Refresh")) {
m_dirtySelectedDir = true;
Expand Down

0 comments on commit df66c0e

Please sign in to comment.