mirror of
https://github.com/antopilo/Nuake.git
synced 2026-09-04 11:35:06 +03:00
NK-111 - Copy Menu in Context Menu
This commit is contained in:
@@ -162,10 +162,29 @@ namespace Nuake
|
||||
}
|
||||
}
|
||||
|
||||
if (ImGui::BeginMenu("Copy"))
|
||||
{
|
||||
ImGui::Separator();
|
||||
|
||||
if (ImGui::MenuItem("Full Path"))
|
||||
{
|
||||
OS::CopyToClipboard(file->GetAbsolutePath());
|
||||
}
|
||||
|
||||
if (ImGui::MenuItem("File Name"))
|
||||
{
|
||||
OS::CopyToClipboard(file->GetName());
|
||||
}
|
||||
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
|
||||
if(file->GetExtension() != ".project")
|
||||
{
|
||||
ImGui::Separator();
|
||||
|
||||
// TODO: Add to a 'Edit' menu with File Rename, etc.
|
||||
|
||||
if (ImGui::MenuItem("Delete"))
|
||||
{
|
||||
if(FileSystem::RemoveFile(file->GetAbsolutePath()) != 0)
|
||||
|
||||
@@ -1,11 +1,40 @@
|
||||
#include "OS.h"
|
||||
#include "src/Window.h"
|
||||
|
||||
#define GLFW_EXPOSE_NATIVE_WIN32
|
||||
#include "GLFW/glfw3.h"
|
||||
#include "GLFW/glfw3native.h"
|
||||
|
||||
#include <chrono>
|
||||
#include <Windows.h>
|
||||
#include <chrono>
|
||||
|
||||
using namespace Nuake;
|
||||
|
||||
int OS::GetTime()
|
||||
void OS::CopyToClipboard(const std::string& value)
|
||||
{
|
||||
auto glob = GlobalAlloc(GMEM_FIXED, 512);
|
||||
memcpy(glob, value.data(), value.size());
|
||||
OpenClipboard(glfwGetWin32Window(Window::Get()->GetHandle()));
|
||||
EmptyClipboard();
|
||||
SetClipboardData(CF_TEXT, glob);
|
||||
CloseClipboard();
|
||||
}
|
||||
|
||||
std::string OS::GetFromClipboard()
|
||||
{
|
||||
OpenClipboard(nullptr);
|
||||
HANDLE hData = GetClipboardData(CF_TEXT);
|
||||
|
||||
char* pszText = static_cast<char*>(GlobalLock(hData));
|
||||
std::string text(pszText);
|
||||
|
||||
GlobalUnlock(hData);
|
||||
CloseClipboard();
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
int OS::GetTime()
|
||||
{
|
||||
return static_cast<int>(std::chrono::system_clock::now().time_since_epoch().count());
|
||||
}
|
||||
|
||||
@@ -7,6 +7,8 @@ namespace Nuake
|
||||
class OS
|
||||
{
|
||||
public:
|
||||
static void CopyToClipboard(const std::string& value);
|
||||
static std::string GetFromClipboard();
|
||||
static int GetTime();
|
||||
static void OpenIn(const std::string& filePath);
|
||||
static void ShowInFileExplorer(const std::string& filePath);
|
||||
|
||||
Reference in New Issue
Block a user