MCPcopy Create free account
hub / github.com/RGAA-Software/GoDesk / ShowSelectAvatarDialog

Method ShowSelectAvatarDialog

src/render_panel/gr_workspace.cpp:715–743  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

713 }
714
715 void GrWorkspace::ShowSelectAvatarDialog() {
716 auto desktop_path = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation);
717 auto image_path = TcDialogUtil::SelectImage(tcTr("id_select_image"), desktop_path, nullptr);
718 if (image_path.isEmpty()) {
719 return;
720 }
721 QPixmap image = ImageCropperDialog::getCroppedImage(image_path, 600, 400, CropperShape::CIRCLE);
722 if (image.isNull()) {
723 return;
724 }
725
726 auto avatar_path = settings_->GetGrDataCachePath() + "/" + grApp->GetUserManager()->GetUserId() + "_avatar.jpg";
727 image.save(avatar_path.c_str());
728
729 if (!File::Exists(avatar_path)) {
730 LOGE("Crop image failed, file not exists: {}", avatar_path);
731 return;
732 }
733
734 auto size = File::Size(avatar_path);
735 if (size < 0 || size >= 10 * 1024 * 1024) {
736 LOGE("Image size invalid: {}", size);
737 return;
738 }
739
740 if (user_mgr_->UpdateAvatar(avatar_path)) {
741 LoadAvatar();
742 }
743 }
744
745 void GrWorkspace::UpdateUserInfo() {
746 UpdateUsername();

Callers

nothing calls this directly

Calls 4

GetGrDataCachePathMethod · 0.80
GetUserIdMethod · 0.80
GetUserManagerMethod · 0.80
UpdateAvatarMethod · 0.80

Tested by

no test coverage detected