mirror of
https://github.com/vale981/tdesktop
synced 2025-03-05 09:41:41 -05:00
Fix save dialog in macOS for streamed videos.
This commit is contained in:
parent
883d6dcede
commit
17baac710e
5 changed files with 33 additions and 15 deletions
|
@ -729,6 +729,12 @@ QWidget *Application::getFileDialogParent() {
|
|||
: nullptr;
|
||||
}
|
||||
|
||||
void Application::notifyFileDialogShown(bool shown) {
|
||||
if (_mediaView) {
|
||||
_mediaView->notifyFileDialogShown(shown);
|
||||
}
|
||||
}
|
||||
|
||||
void Application::checkMediaViewActivation() {
|
||||
if (_mediaView && !_mediaView->isHidden()) {
|
||||
_mediaView->activateWindow();
|
||||
|
|
|
@ -99,6 +99,7 @@ public:
|
|||
bool closeActiveWindow();
|
||||
bool minimizeActiveWindow();
|
||||
QWidget *getFileDialogParent();
|
||||
void notifyFileDialogShown(bool shown);
|
||||
|
||||
// Media view interface.
|
||||
void checkMediaViewActivation();
|
||||
|
|
|
@ -360,11 +360,13 @@ bool GetDefault(
|
|||
Platform::FileDialog::InitLastPath();
|
||||
}
|
||||
|
||||
remoteContent = QByteArray();
|
||||
remoteContent = QByteArray();
|
||||
if (startFile.isEmpty() || startFile.at(0) != '/') {
|
||||
startFile = cDialogLastPath() + '/' + startFile;
|
||||
}
|
||||
QString file;
|
||||
|
||||
Core::App().notifyFileDialogShown(true);
|
||||
if (type == Type::ReadFiles) {
|
||||
files = QFileDialog::getOpenFileNames(Core::App().getFileDialogParent(), caption, startFile, filter);
|
||||
QString path = files.isEmpty() ? QString() : QFileInfo(files.back()).absoluteDir().absolutePath();
|
||||
|
@ -373,17 +375,19 @@ bool GetDefault(
|
|||
Local::writeUserSettings();
|
||||
}
|
||||
return !files.isEmpty();
|
||||
} else if (type == Type::ReadFolder) {
|
||||
} else if (type == Type::ReadFolder) {
|
||||
file = QFileDialog::getExistingDirectory(Core::App().getFileDialogParent(), caption, startFile);
|
||||
} else if (type == Type::WriteFile) {
|
||||
} else if (type == Type::WriteFile) {
|
||||
file = QFileDialog::getSaveFileName(Core::App().getFileDialogParent(), caption, startFile, filter);
|
||||
} else {
|
||||
} else {
|
||||
file = QFileDialog::getOpenFileName(Core::App().getFileDialogParent(), caption, startFile, filter);
|
||||
}
|
||||
if (file.isEmpty()) {
|
||||
files = QStringList();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Core::App().notifyFileDialogShown(false);
|
||||
|
||||
if (file.isEmpty()) {
|
||||
files = QStringList();
|
||||
return false;
|
||||
}
|
||||
if (type != Type::ReadFolder) {
|
||||
// Save last used directory for all queries except directory choosing.
|
||||
auto path = QFileInfo(file).absoluteDir().absolutePath();
|
||||
|
|
|
@ -1095,6 +1095,17 @@ void OverlayWidget::onToMessage() {
|
|||
}
|
||||
}
|
||||
|
||||
void OverlayWidget::notifyFileDialogShown(bool shown) {
|
||||
if (shown && isHidden()) {
|
||||
return;
|
||||
}
|
||||
if (shown) {
|
||||
Ui::Platform::BringToBack(this);
|
||||
} else {
|
||||
Ui::Platform::ShowOverAll(this);
|
||||
}
|
||||
}
|
||||
|
||||
void OverlayWidget::onSaveAs() {
|
||||
QString file;
|
||||
if (_doc) {
|
||||
|
@ -1116,9 +1127,7 @@ void OverlayWidget::onSaveAs() {
|
|||
filter = mimeType.filterString() + qsl(";;") + FileDialog::AllFilesFilter();
|
||||
}
|
||||
|
||||
Ui::Platform::BringToBack(this);
|
||||
file = FileNameForSave(tr::lng_save_file(tr::now), filter, qsl("doc"), name, true, alreadyDir);
|
||||
Ui::Platform::ShowOverAll(this);
|
||||
if (!file.isEmpty() && file != location.name()) {
|
||||
if (_doc->data().isEmpty()) {
|
||||
QFile(file).remove();
|
||||
|
@ -1142,7 +1151,6 @@ void OverlayWidget::onSaveAs() {
|
|||
} else {
|
||||
if (!_photo || !_photo->loaded()) return;
|
||||
|
||||
Ui::Platform::BringToBack(this);
|
||||
auto filter = qsl("JPEG Image (*.jpg);;") + FileDialog::AllFilesFilter();
|
||||
FileDialog::GetWritePath(
|
||||
this,
|
||||
|
@ -1158,9 +1166,6 @@ void OverlayWidget::onSaveAs() {
|
|||
if (!result.isEmpty() && _photo == photo && photo->loaded()) {
|
||||
photo->large()->original().save(result, "JPG");
|
||||
}
|
||||
Ui::Platform::ShowOverAll(this);
|
||||
}), crl::guard(this, [=] {
|
||||
Ui::Platform::ShowOverAll(this);
|
||||
}));
|
||||
}
|
||||
activateWindow();
|
||||
|
|
|
@ -92,6 +92,8 @@ public:
|
|||
|
||||
PeerData *ui_getPeerForMouseAction();
|
||||
|
||||
void notifyFileDialogShown(bool shown);
|
||||
|
||||
void clearData();
|
||||
|
||||
~OverlayWidget();
|
||||
|
|
Loading…
Add table
Reference in a new issue