diff --git a/src/gui/assets/localization/localization.h b/src/gui/assets/localization/localization.h index 5372074..55acf27 100644 --- a/src/gui/assets/localization/localization.h +++ b/src/gui/assets/localization/localization.h @@ -185,6 +185,8 @@ static std::vector enable_daemon = { static std::vector takes_effect_after_restart = { reinterpret_cast(u8"重启后生效"), "Takes effect after restart"}; +static std::vector select_file = { + reinterpret_cast(u8"选择文件"), "Select File"}; #if _WIN32 static std::vector minimize_to_tray = { reinterpret_cast(u8"退出时最小化到系统托盘:"), diff --git a/src/gui/panels/remote_peer_panel.cpp b/src/gui/panels/remote_peer_panel.cpp index c7d7bd7..7c7eaa4 100644 --- a/src/gui/panels/remote_peer_panel.cpp +++ b/src/gui/panels/remote_peer_panel.cpp @@ -190,11 +190,11 @@ int Render::ConnectTo(const std::string& remote_id, const char* password, props->params_.user_id = props->local_id_.c_str(); props->peer_ = CreatePeer(&props->params_); - props->control_window_width_ = title_bar_height_ * 8.0f; + props->control_window_width_ = title_bar_height_ * 9.0f; props->control_window_height_ = title_bar_height_ * 1.3f; props->control_window_min_width_ = title_bar_height_ * 0.65f; props->control_window_min_height_ = title_bar_height_ * 1.3f; - props->control_window_max_width_ = title_bar_height_ * 8.0f; + props->control_window_max_width_ = title_bar_height_ * 9.0f; props->control_window_max_height_ = title_bar_height_ * 6.0f; if (!props->peer_) { diff --git a/src/gui/render.cpp b/src/gui/render.cpp index 25677bc..56bf940 100644 --- a/src/gui/render.cpp +++ b/src/gui/render.cpp @@ -1340,8 +1340,8 @@ void Render::MainLoop() { remote_action.i.host_name_size = host_name.size(); std::string msg = remote_action.to_json(); - int ret = - SendDataFrame(peer_, msg.data(), msg.size(), data_label_.c_str()); + int ret = SendDataFrame(peer_, msg.data(), msg.size(), + data_label_.c_str(), false); FreeRemoteAction(remote_action); if (0 == ret) { need_to_send_host_info_ = false; diff --git a/src/gui/render_callback.cpp b/src/gui/render_callback.cpp index 2c5e692..96259b6 100644 --- a/src/gui/render_callback.cpp +++ b/src/gui/render_callback.cpp @@ -30,7 +30,7 @@ int Render::SendKeyCommand(int key_code, bool is_down) { std::string msg = remote_action.to_json(); if (props->peer_) { SendDataFrame(props->peer_, msg.c_str(), msg.size(), - props->data_label_.c_str()); + props->data_label_.c_str(), false); } } } @@ -101,7 +101,7 @@ int Render::ProcessMouseEvent(const SDL_Event& event) { std::string msg = remote_action.to_json(); if (props->peer_) { SendDataFrame(props->peer_, msg.c_str(), msg.size(), - props->data_label_.c_str()); + props->data_label_.c_str(), false); } } else if (SDL_EVENT_MOUSE_WHEEL == event.type && last_mouse_event.button.x >= props->stream_render_rect_.x && @@ -148,7 +148,7 @@ int Render::ProcessMouseEvent(const SDL_Event& event) { std::string msg = remote_action.to_json(); if (props->peer_) { SendDataFrame(props->peer_, msg.c_str(), msg.size(), - props->data_label_.c_str()); + props->data_label_.c_str(), false); } } } @@ -485,12 +485,12 @@ void Render::OnConnectionStatusCb(ConnectionStatus status, const char* user_id, render->need_to_send_host_info_ = true; render->start_screen_capturer_ = true; render->start_speaker_capturer_ = true; -#ifdef CROSSDESK_DEBUG + // #ifdef CROSSDESK_DEBUG render->start_mouse_controller_ = false; render->start_keyboard_capturer_ = false; -#else + // #else render->start_mouse_controller_ = true; -#endif + // #endif if (std::all_of(render->connection_status_.begin(), render->connection_status_.end(), [](const auto& kv) { return kv.first.find("web") != std::string::npos; diff --git a/src/gui/toolbars/control_bar.cpp b/src/gui/toolbars/control_bar.cpp index b8a54ae..b29326c 100644 --- a/src/gui/toolbars/control_bar.cpp +++ b/src/gui/toolbars/control_bar.cpp @@ -2,9 +2,22 @@ #include "localization.h" #include "rd_log.h" #include "render.h" +#include "tinyfiledialogs.h" namespace crossdesk { +std::string OpenFileDialog(std::string title) { + const char* path = tinyfd_openFileDialog(title.c_str(), + "", // default path + 0, // number of filters + nullptr, // filters + nullptr, // filter description + 0 // no multiple selection + ); + + return path ? path : ""; +} + int CountDigits(int number) { if (number == 0) return 1; return (int)std::floor(std::log10(std::abs(number))) + 1; @@ -41,14 +54,14 @@ int Render::ControlBar(std::shared_ptr& props) { if (props->control_bar_expand_) { ImGui::SetCursorPosX(props->is_control_bar_in_left_ ? props->control_window_width_ * 1.03f - : props->control_window_width_ * 0.2f); + : props->control_window_width_ * 0.17f); ImDrawList* draw_list = ImGui::GetWindowDrawList(); if (!props->is_control_bar_in_left_) { draw_list->AddLine( - ImVec2(ImGui::GetCursorScreenPos().x - button_height * 0.56f, + ImVec2(ImGui::GetCursorScreenPos().x - button_height * 0.5f, ImGui::GetCursorScreenPos().y + button_height * 0.2f), - ImVec2(ImGui::GetCursorScreenPos().x - button_height * 0.56f, + ImVec2(ImGui::GetCursorScreenPos().x - button_height * 0.5f, ImGui::GetCursorScreenPos().y + button_height * 0.8f), IM_COL32(178, 178, 178, 255), 2.0f); } @@ -74,7 +87,7 @@ int Render::ControlBar(std::shared_ptr& props) { if (props->connection_status_ == ConnectionStatus::Connected) { std::string msg = remote_action.to_json(); SendDataFrame(props->peer_, msg.c_str(), msg.size(), - props->data_label_.c_str()); + props->data_label_.c_str(), false); } } props->display_selectable_hovered_ = ImGui::IsWindowHovered(); @@ -155,7 +168,7 @@ int Render::ControlBar(std::shared_ptr& props) { remote_action.a = props->audio_capture_button_pressed_; std::string msg = remote_action.to_json(); SendDataFrame(props->peer_, msg.c_str(), msg.size(), - props->data_label_.c_str()); + props->data_label_.c_str(), false); } } @@ -175,6 +188,18 @@ int Render::ControlBar(std::shared_ptr& props) { line_thickness); } + ImGui::SameLine(); + std::string open_folder = ICON_FA_FOLDER_OPEN; + if (ImGui::Button(open_folder.c_str(), + ImVec2(button_width, button_height))) { + std::string title = + localization::select_file[localization_language_index_]; + std::string path = OpenFileDialog(title); + if (!path.empty()) { + LOG_INFO("Selected file: {}", path.c_str()); + } + } + ImGui::SameLine(); // net traffic stats button bool button_color_style_pushed = false; @@ -238,9 +263,9 @@ int Render::ControlBar(std::shared_ptr& props) { if (props->is_control_bar_in_left_) { draw_list->AddLine( - ImVec2(ImGui::GetCursorScreenPos().x + button_height * 0.2f, + ImVec2(ImGui::GetCursorScreenPos().x + button_height * 0.13f, ImGui::GetCursorScreenPos().y + button_height * 0.2f), - ImVec2(ImGui::GetCursorScreenPos().x + button_height * 0.2f, + ImVec2(ImGui::GetCursorScreenPos().x + button_height * 0.13f, ImGui::GetCursorScreenPos().y + button_height * 0.8f), IM_COL32(178, 178, 178, 255), 2.0f); } @@ -250,7 +275,7 @@ int Render::ControlBar(std::shared_ptr& props) { float expand_button_pos_x = props->control_bar_expand_ ? (props->is_control_bar_in_left_ - ? props->control_window_width_ * 1.91f + ? props->control_window_width_ * 1.917f : props->control_window_width_ * 0.03f) : (props->is_control_bar_in_left_ ? props->control_window_width_ * 1.02f diff --git a/src/gui/windows/server_settings_window.cpp b/src/gui/windows/server_settings_window.cpp index 0acbbf5..a5caaf7 100644 --- a/src/gui/windows/server_settings_window.cpp +++ b/src/gui/windows/server_settings_window.cpp @@ -230,6 +230,7 @@ int Render::SelfHostedServerWindow() { // ShowSimpleFileBrowser(); // } + { ImGui::AlignTextToFramePadding(); if (ImGui::Button(localization::reset_cert_fingerprint diff --git a/submodules/minirtc b/submodules/minirtc index f981044..6db742f 160000 --- a/submodules/minirtc +++ b/submodules/minirtc @@ -1 +1 @@ -Subproject commit f9810444ee59374e1e136bd614eb55b780508c0d +Subproject commit 6db742ffa34d346201ebf7684971a37ab3d62889 diff --git a/xmake.lua b/xmake.lua index 1fd1ebb..3b19f54 100644 --- a/xmake.lua +++ b/xmake.lua @@ -33,6 +33,7 @@ add_requires("imgui v1.92.1-docking", {configs = {sdl3 = true, sdl3_renderer = t add_requires("openssl3 3.3.2", {system = false}) add_requires("nlohmann_json 3.11.3") add_requires("cpp-httplib v0.26.0", {configs = {ssl = true}}) +add_requires("tinyfiledialogs 3.15.1") if is_os("windows") then add_requires("libyuv", "miniaudio 0.11.21") @@ -170,7 +171,7 @@ target("version_checker") target("gui") set_kind("object") - add_packages("libyuv") + add_packages("libyuv", "tinyfiledialogs") add_defines("CROSSDESK_VERSION=\"" .. (get_config("CROSSDESK_VERSION") or "Unknown") .. "\"") add_deps("rd_log", "common", "assets", "config_center", "minirtc", "path_manager", "screen_capturer", "speaker_capturer",