From 946c0caf78ae1c92b7464bcf191ffe512a1b0e88 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Mon, 22 Jan 2024 13:32:20 +0100 Subject: [PATCH] TopBar: Added user name to "Login" button + Deleted unused names for mode button --- src/slic3r/GUI/MainFrame.cpp | 6 ++++++ src/slic3r/GUI/MainFrame.hpp | 2 ++ src/slic3r/GUI/Plater.cpp | 3 +++ src/slic3r/GUI/TopBar.cpp | 16 ++++++++++------ 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/src/slic3r/GUI/MainFrame.cpp b/src/slic3r/GUI/MainFrame.cpp index 25de6b95cd..beb016b902 100644 --- a/src/slic3r/GUI/MainFrame.cpp +++ b/src/slic3r/GUI/MainFrame.cpp @@ -904,6 +904,12 @@ void MainFrame::set_monitor_tab_url(const wxString& url) m_monitor_webview->load_default_url(); } +void Slic3r::GUI::MainFrame::refresh_auth_menu() +{ + // Update User name in TopBar + dynamic_cast(m_tabpanel)->GetTopBarItemsCtrl()->UpdateAuthMenu(); +} + void MainFrame::add_created_tab(Tab* panel, const std::string& bmp_name /*= ""*/) { panel->create_preset_tab(); diff --git a/src/slic3r/GUI/MainFrame.hpp b/src/slic3r/GUI/MainFrame.hpp index 83382fb5a9..fdc27083e8 100644 --- a/src/slic3r/GUI/MainFrame.hpp +++ b/src/slic3r/GUI/MainFrame.hpp @@ -223,6 +223,8 @@ public: void set_monitor_tab_url(const wxString& url); bool get_monitor_tab_added() const { return m_monitor_webview_added; } + void refresh_auth_menu(); + PrintHostQueueDialog* printhost_queue_dlg() { return m_printhost_queue_dlg; } Plater* m_plater { nullptr }; diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 13582375ec..a481d77459 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -901,6 +901,9 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame) std::string text = format(_u8L("Logged as %1%."), username); this->notification_manager->close_notification_of_type(NotificationType::PrusaAuthUserID); this->notification_manager->push_notification(NotificationType::PrusaAuthUserID, NotificationManager::NotificationLevel::ImportantNotificationLevel, text); + + // Update User name in TopBar + this->main_frame->refresh_auth_menu(); } else { // TODO } diff --git a/src/slic3r/GUI/TopBar.cpp b/src/slic3r/GUI/TopBar.cpp index 6828463cba..9073fe0089 100644 --- a/src/slic3r/GUI/TopBar.cpp +++ b/src/slic3r/GUI/TopBar.cpp @@ -128,10 +128,7 @@ void TopBarItemsCtrl::ButtonWithPopup::SetLabel(const wxString& label) static wxString get_workspace_name(Slic3r::ConfigOptionMode mode) { return mode == Slic3r::ConfigOptionMode::comSimple ? _L("Beginners") : - mode == Slic3r::ConfigOptionMode::comAdvanced ? _L("Regulars") : _L("Josef Prusa"); - - return mode == Slic3r::ConfigOptionMode::comSimple ? _L("Beginner workspace") : - mode == Slic3r::ConfigOptionMode::comAdvanced ? _L("Regular workspace") : _L("Josef Prusa's workspace"); + mode == Slic3r::ConfigOptionMode::comAdvanced ? _L("Regulars") : _L("Experts"); } void TopBarItemsCtrl::ApplyWorkspacesMenu() @@ -189,8 +186,14 @@ void TopBarItemsCtrl::UpdateAuthMenu() m_login_menu_item->SetBitmap(user_account->is_logged() ? *get_bmp_bundle("logout", 16) : *get_bmp_bundle("login", 16)); } + const wxString user_name = user_account->is_logged() ? from_u8(user_account->get_username()) : _L("Anonymus"); if (m_user_menu_item) - m_user_menu_item->SetItemLabel(user_account->is_logged() ? from_u8(user_account->get_username()) : _L("Anonymus")); + m_user_menu_item->SetItemLabel(user_name); + + m_auth_btn->SetLabel(user_name); + m_auth_btn->SetBitmapMargins(0, 0); + // m_auth_btn->SetBitmap_("icon_name"); + m_auth_btn->Refresh(); } void TopBarItemsCtrl::CreateSearch() @@ -264,7 +267,8 @@ TopBarItemsCtrl::TopBarItemsCtrl(wxWindow *parent) : // create Auth menu CreateAuthMenu(); - m_auth_btn = new ButtonWithPopup(this, "user", 35); +// m_auth_btn = new ButtonWithPopup(this, "user", 35); + m_auth_btn = new ButtonWithPopup(this, _L("Anonymus"), "user"); right_sizer->Add(m_auth_btn, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxRIGHT | wxLEFT, m_btn_margin); m_auth_btn->Bind(wxEVT_BUTTON, [this](wxCommandEvent& event) {