User Account avatar extension

(Missing support for jpg in ScalableBitmap)
This commit is contained in:
David Kocik 2024-03-25 10:18:30 +01:00
parent 600086df56
commit d289b11950
4 changed files with 6 additions and 3 deletions

View File

@ -77,7 +77,7 @@ std::string UserAccount::get_shared_session_key()
boost::filesystem::path UserAccount::get_avatar_path(bool logged) const
{
if (logged) {
const std::string filename = "prusaslicer-avatar-" + m_instance_hash + ".png";
const std::string filename = "prusaslicer-avatar-" + m_instance_hash + m_avatar_extension;
return boost::filesystem::path(wxStandardPaths::Get().GetTempDir().utf8_str().data()) / filename;
} else {
return boost::filesystem::path(resources_dir()) / "icons" / "user.svg";
@ -143,6 +143,8 @@ bool UserAccount::on_user_id_success(const std::string data, std::string& out_us
out_username = public_username;
// equeue GET with avatar url
if (m_account_user_data.find("avatar") != m_account_user_data.end()) {
const boost::filesystem::path server_file(m_account_user_data["avatar"]);
m_avatar_extension = server_file.extension().string();
enqueue_avatar_action();
}
else {

View File

@ -86,6 +86,7 @@ private:
std::map<std::string, std::string> m_account_user_data;
std::string m_username;
size_t m_fail_counter { 0 };
std::string m_avatar_extension;
// first string is "printer_type" code from Connect edpoints
const std::map<std::string, std::string> printer_type_and_name_table = {

View File

@ -337,7 +337,7 @@ void UserAccountCommunication::enqueue_test_connection()
wakeup_session_thread();
}
void UserAccountCommunication::enqueue_avatar_action(const std::string url)
void UserAccountCommunication::enqueue_avatar_action(const std::string& url)
{
{
std::lock_guard<std::mutex> lock(m_session_mutex);

View File

@ -44,7 +44,7 @@ public:
void enqueue_connect_user_data_action();
#endif
void enqueue_connect_printers_action();
void enqueue_avatar_action(const std::string url);
void enqueue_avatar_action(const std::string& url);
void enqueue_test_connection();
// Callbacks - called from UI after receiving Event from Session thread. Some might use Session thread.