[feat] use confirm window to confirm recent connections deletion

This commit is contained in:
dijunkun
2024-11-11 10:49:07 +08:00
parent b6671bdbe7
commit f9347cbd49
7 changed files with 41651 additions and 41509 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -1,3 +1,12 @@
/*
* @Author: DI JUNKUN
* @Date: 2024-11-11
* Copyright (c) 2024 by DI JUNKUN, All Rights Reserved.
*/
#ifndef _FA_REGULAR_400_H_
#define _FA_REGULAR_400_H_
unsigned char fa_regular_400_ttf[] = {
0x00, 0x01, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x80, 0x00, 0x03, 0x00, 0x20,
0x4f, 0x53, 0x2f, 0x32, 0x5f, 0x6e, 0x5e, 0x5e, 0x00, 0x00, 0x01, 0x28,
@@ -5653,6 +5662,7 @@ unsigned char fa_regular_400_ttf[] = {
0x62, 0x65, 0x61, 0x6d, 0x10, 0x73, 0x74, 0x61, 0x72, 0x2d, 0x68, 0x61,
0x6c, 0x66, 0x2d, 0x73, 0x74, 0x72, 0x6f, 0x6b, 0x65, 0x0d, 0x66, 0x61,
0x63, 0x65, 0x2d, 0x73, 0x75, 0x72, 0x70, 0x72, 0x69, 0x73, 0x65, 0x0a,
0x66, 0x61, 0x63, 0x65, 0x2d, 0x74, 0x69, 0x72, 0x65, 0x64, 0x00, 0x00
};
0x66, 0x61, 0x63, 0x65, 0x2d, 0x74, 0x69, 0x72, 0x65, 0x64, 0x00, 0x00};
unsigned int fa_regular_400_ttf_len = 67860;
#endif

View File

@@ -1,3 +1,12 @@
/*
* @Author: DI JUNKUN
* @Date: 2024-11-11
* Copyright (c) 2024 by DI JUNKUN, All Rights Reserved.
*/
#ifndef _FA_SOLID_900_H_
#define _FA_SOLID_900_H_
unsigned char fa_solid_900_ttf[] = {
0x00, 0x01, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x80, 0x00, 0x03, 0x00, 0x20,
0x4f, 0x53, 0x2f, 0x32, 0x61, 0x6b, 0x62, 0x53, 0x00, 0x00, 0x01, 0x28,
@@ -35026,6 +35035,7 @@ unsigned char fa_solid_900_ttf[] = {
0x73, 0x65, 0x05, 0x72, 0x61, 0x64, 0x69, 0x6f, 0x0c, 0x72, 0x65, 0x63,
0x6f, 0x72, 0x64, 0x2d, 0x76, 0x69, 0x6e, 0x79, 0x6c, 0x0d, 0x77, 0x61,
0x6c, 0x6b, 0x69, 0x65, 0x2d, 0x74, 0x61, 0x6c, 0x6b, 0x69, 0x65, 0x07,
0x63, 0x61, 0x72, 0x61, 0x76, 0x61, 0x6e, 0x00
};
0x63, 0x61, 0x72, 0x61, 0x76, 0x61, 0x6e, 0x00};
unsigned int fa_solid_900_ttf_len = 420332;
#endif

View File

@@ -82,6 +82,8 @@ static std::vector<std::string> no_such_id = {u8"无此ID", "No such ID"};
static std::vector<std::string> about = {u8"关于", "About"};
static std::vector<std::string> version = {u8"版本", "Version"};
static std::vector<std::string> confirm_delete_connection = {
u8"确认删除此连接", "Confirm to delete this connection"};
} // namespace localization
#endif

View File

@@ -139,7 +139,7 @@ int Render::ConnectionStatusWindow() {
// ok
if (ImGui::Button(
localization::ok[localization_language_index_].c_str()) ||
ImGui::IsKeyPressed(ImGuiKey_Escape)) {
ImGui::IsKeyPressed(ImGuiKey_Enter)) {
show_connection_status_window_ = false;
}
}

View File

@@ -136,8 +136,13 @@ int Render::ShowRecentConnections() {
xmake + "##RecentConnectionDelete" +
std::to_string(delete_button_pos.x);
if (ImGui::SmallButton(recent_connection_delete_button_name.c_str())) {
show_confirm_delete_connection_ = true;
}
if (delete_connection_) {
if (!thumbnail_.DeleteThumbnail(pos.first)) {
reload_recent_connections_ = true;
delete_connection_ = false;
}
}
ImGui::SetWindowFontScale(1.0f);
@@ -146,5 +151,67 @@ int Render::ShowRecentConnections() {
ImGui::EndChild();
if (show_confirm_delete_connection_) {
ConfirmDeleteConnection();
}
return 0;
}
int Render::ConfirmDeleteConnection() {
const ImGuiViewport* viewport = ImGui::GetMainViewport();
ImGui::SetNextWindowPos(ImVec2((viewport->WorkSize.x - viewport->WorkPos.x -
connection_status_window_width_) /
2,
(viewport->WorkSize.y - viewport->WorkPos.y -
connection_status_window_height_) /
2));
ImGui::SetNextWindowSize(ImVec2(connection_status_window_width_,
connection_status_window_height_));
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 3.0f);
ImGui::PushStyleColor(ImGuiCol_WindowBg, ImVec4(1.0, 1.0, 1.0, 1.0));
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 1.0f);
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 5.0f);
ImGui::Begin("ConfirmDeleteConnectionWindow", nullptr,
ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse |
ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoTitleBar |
ImGuiWindowFlags_NoSavedSettings);
ImGui::PopStyleVar(2);
ImGui::PopStyleColor();
ImGui::SetWindowFontScale(0.5f);
std::string text =
localization::confirm_delete_connection[localization_language_index_];
ImGui::SetCursorPosX(connection_status_window_width_ * 6 / 19);
ImGui::SetCursorPosY(connection_status_window_height_ * 2 / 3);
// ok
if (ImGui::Button(localization::ok[localization_language_index_].c_str()) ||
ImGui::IsKeyPressed(ImGuiKey_Enter)) {
delete_connection_ = true;
show_confirm_delete_connection_ = false;
}
ImGui::SameLine();
// cancel
if (ImGui::Button(
localization::cancel[localization_language_index_].c_str()) ||
ImGui::IsKeyPressed(ImGuiKey_Escape)) {
delete_connection_ = false;
show_confirm_delete_connection_ = false;
}
auto window_width = ImGui::GetWindowSize().x;
auto window_height = ImGui::GetWindowSize().y;
auto text_width = ImGui::CalcTextSize(text.c_str()).x;
ImGui::SetCursorPosX((window_width - text_width) * 0.5f);
ImGui::SetCursorPosY(window_height * 0.2f);
ImGui::Text(text.c_str());
ImGui::SetWindowFontScale(1.0f);
ImGui::End();
ImGui::PopStyleVar();
return 0;
}

View File

@@ -59,6 +59,7 @@ class Render {
int DestroyStreamWindowContext();
int DrawMainWindow();
int DrawStreamWindow();
int ConfirmDeleteConnection();
public:
static void OnReceiveVideoBufferCb(const XVideoFrame *video_frame,
@@ -275,6 +276,8 @@ class Render {
bool control_window_width_is_changing_ = false;
bool reload_recent_connections_ = true;
bool hostname_sent_ = false;
bool show_confirm_delete_connection_ = false;
bool delete_connection_ = false;
double copy_start_time_ = 0;
double regenerate_password_start_time_ = 0;