diff --git a/lib/libimhex/source/ui/imgui_imhex_extensions.cpp b/lib/libimhex/source/ui/imgui_imhex_extensions.cpp index 57517ea82..2d622525d 100644 --- a/lib/libimhex/source/ui/imgui_imhex_extensions.cpp +++ b/lib/libimhex/source/ui/imgui_imhex_extensions.cpp @@ -1312,8 +1312,9 @@ namespace ImGuiExt { ImGui::PushID(label); - const auto buttonSize = ImGui::CalcTextSize("...") + ImGui::GetStyle().FramePadding * 2; - ImGui::PushItemWidth(ImGui::CalcItemWidth() - buttonSize.x - ImGui::GetStyle().FramePadding.x); + const auto framePadding = ImGui::GetStyle().FramePadding.x; + const auto buttonSize = ImVec2(ImGui::CalcTextSize("...").x + framePadding * 2, ImGui::GetFrameHeight()); + ImGui::PushItemWidth(ImGui::CalcItemWidth() - buttonSize.x - framePadding); std::string string = wolv::util::toUTF8String(path); if (ImGui::InputText("##pathInput", string, ImGuiInputTextFlags_AutoSelectAll)) { path = std::u8string(string.begin(), string.end()); @@ -1321,7 +1322,7 @@ namespace ImGuiExt { } ImGui::PopItemWidth(); - ImGui::SameLine(); + ImGui::SameLine(0, framePadding); if (ImGui::Button("...", buttonSize)) { hex::fs::openFileBrowser(hex::fs::DialogMode::Open, validExtensions, [&](const std::fs::path &pickedPath) { diff --git a/plugins/remote/include/content/providers/ssh_provider.hpp b/plugins/remote/include/content/providers/ssh_provider.hpp index ba3b79c75..9fc314f98 100644 --- a/plugins/remote/include/content/providers/ssh_provider.hpp +++ b/plugins/remote/include/content/providers/ssh_provider.hpp @@ -43,7 +43,7 @@ namespace hex::plugin::remote { int m_port = 22; std::string m_username; std::string m_password; - std::string m_privateKeyPath; + std::fs::path m_privateKeyPath; std::string m_keyPassphrase; AuthMethod m_authMethod = AuthMethod::Password; diff --git a/plugins/remote/source/content/providers/ssh_provider.cpp b/plugins/remote/source/content/providers/ssh_provider.cpp index 676b174b4..c617611fd 100644 --- a/plugins/remote/source/content/providers/ssh_provider.cpp +++ b/plugins/remote/source/content/providers/ssh_provider.cpp @@ -7,6 +7,7 @@ #include #include +#include namespace hex::plugin::remote { @@ -84,7 +85,7 @@ namespace hex::plugin::remote { } if (ImGui::BeginTabItem("hex.plugin.remote.ssh_provider.key_file"_lang)) { m_authMethod = AuthMethod::KeyFile; - ImGui::InputText("hex.plugin.remote.ssh_provider.key_file"_lang, m_privateKeyPath); + ImGuiExt::InputFilePicker("hex.plugin.remote.ssh_provider.key_file"_lang, m_privateKeyPath, {}); ImGui::InputText("hex.plugin.remote.ssh_provider.passphrase"_lang, m_keyPassphrase, ImGuiInputTextFlags_Password); ImGui::EndTabItem(); } @@ -103,7 +104,7 @@ namespace hex::plugin::remote { m_sftpClient = std::move(client); } } catch (const std::exception& e) { - log::error("Failed to connect to SSH server: {}", e.what()); + ui::ToastError::open(hex::format("Failed to connect to SSH server: {}", e.what())); return false; } } @@ -137,7 +138,7 @@ namespace hex::plugin::remote { ImGui::TableNextColumn(); ImGui::Selectable(entry.name.c_str(), m_remoteFilePath.filename() == entry.name, ImGuiSelectableFlags_NoAutoClosePopups); if (ImGui::IsItemHovered() && ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left)) { - m_selectedFile = entry.isRegularFile(); + m_selectedFile = !entry.isDirectory(); m_remoteFilePath /= entry.name; } } @@ -182,7 +183,4 @@ namespace hex::plugin::remote { m_remoteFilePath = settings.value("remoteFilePath", ""); } - - - -} \ No newline at end of file +} diff --git a/plugins/remote/source/plugin_remote.cpp b/plugins/remote/source/plugin_remote.cpp index 0b54b1f8c..69abaef7f 100644 --- a/plugins/remote/source/plugin_remote.cpp +++ b/plugins/remote/source/plugin_remote.cpp @@ -17,6 +17,9 @@ IMHEX_PLUGIN_SETUP("Remote", "WerWolv", "Reading data from remote servers") { hex::ContentRegistry::Language::addLocalization(nlohmann::json::parse(romfs::get(path).string())); hex::plugin::remote::SFTPClient::init(); + AT_FINAL_CLEANUP { + hex::plugin::remote::SFTPClient::exit(); + }; hex::ContentRegistry::Provider::add(); }