2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 14:45:14 +00:00

Show choose file box over the passport panel.

This commit is contained in:
John Preston
2018-04-17 19:19:34 +04:00
parent 6c2a39f1fc
commit 67ea175fc6
21 changed files with 170 additions and 47 deletions

View File

@@ -95,7 +95,10 @@ void SuggestPhotoFile(
}
template <typename Callback>
void ShowChoosePhotoBox(PeerId peerForCrop, Callback &&callback) {
void ShowChoosePhotoBox(
QPointer<QWidget> parent,
PeerId peerForCrop,
Callback &&callback) {
auto imgExtensions = cImgExtensions();
auto filter = qsl("Image files (*")
+ imgExtensions.join(qsl(" *"))
@@ -108,6 +111,7 @@ void ShowChoosePhotoBox(PeerId peerForCrop, Callback &&callback) {
SuggestPhotoFile(result, peerForCrop, std::move(callback));
};
FileDialog::GetOpenPath(
parent,
lang(lng_choose_image),
filter,
std::move(handleChosenPhoto));
@@ -470,7 +474,7 @@ void UserpicButton::changePhotoLazy() {
auto callback = base::lambda_guarded(
this,
[this](QImage &&image) { setImage(std::move(image)); });
ShowChoosePhotoBox(_peerForCrop, std::move(callback));
ShowChoosePhotoBox(this, _peerForCrop, std::move(callback));
}
void UserpicButton::uploadNewPeerPhoto() {
@@ -482,7 +486,7 @@ void UserpicButton::uploadNewPeerPhoto() {
_peer->id
);
});
ShowChoosePhotoBox(_peerForCrop, std::move(callback));
ShowChoosePhotoBox(this, _peerForCrop, std::move(callback));
}
void UserpicButton::openPeerPhoto() {