mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-03-28 07:47:03 -05:00
impr: Various small ssh provider improvements
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <hex/helpers/utils.hpp>
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
#include <toasts/toast_notification.hpp>
|
||||
|
||||
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", "");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<hex::plugin::remote::SSHProvider>();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user