mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-09-01 15:05:56 +00:00
Pass correct parent to choose folder file dialog.
I hope it fixes #25689, although it didn't work for me, not crash.
This commit is contained in:
@@ -21,11 +21,13 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||||||
#include "history/view/history_view_list_widget.h" // HistoryView::SelectedItem.
|
#include "history/view/history_view_list_widget.h" // HistoryView::SelectedItem.
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
|
#include "mainwindow.h"
|
||||||
#include "storage/storage_account.h"
|
#include "storage/storage_account.h"
|
||||||
#include "ui/text/text_utilities.h"
|
#include "ui/text/text_utilities.h"
|
||||||
#include "ui/toast/toast.h"
|
#include "ui/toast/toast.h"
|
||||||
#include "ui/widgets/popup_menu.h"
|
#include "ui/widgets/popup_menu.h"
|
||||||
#include "window/window_session_controller.h"
|
#include "window/window_session_controller.h"
|
||||||
|
#include "window/window_controller.h"
|
||||||
#include "styles/style_menu_icons.h"
|
#include "styles/style_menu_icons.h"
|
||||||
#include "styles/style_widgets.h"
|
#include "styles/style_widgets.h"
|
||||||
|
|
||||||
@@ -76,7 +78,12 @@ void AddAction(
|
|||||||
: &st::menuIconDownload;
|
: &st::menuIconDownload;
|
||||||
const auto showToast = documents.empty();
|
const auto showToast = documents.empty();
|
||||||
|
|
||||||
|
const auto weak = base::make_weak(controller);
|
||||||
const auto saveImages = [=](const QString &folderPath) {
|
const auto saveImages = [=](const QString &folderPath) {
|
||||||
|
const auto controller = weak.get();
|
||||||
|
if (!controller) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const auto session = &controller->session();
|
const auto session = &controller->session();
|
||||||
const auto downloadPath = folderPath.isEmpty()
|
const auto downloadPath = folderPath.isEmpty()
|
||||||
? Core::App().settings().downloadPath()
|
? Core::App().settings().downloadPath()
|
||||||
@@ -141,6 +148,10 @@ void AddAction(
|
|||||||
saveDocuments(folderPath);
|
saveDocuments(folderPath);
|
||||||
callback();
|
callback();
|
||||||
};
|
};
|
||||||
|
const auto controller = weak.get();
|
||||||
|
if (!controller) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (Core::App().settings().askDownloadPath()) {
|
if (Core::App().settings().askDownloadPath()) {
|
||||||
const auto initialPath = [] {
|
const auto initialPath = [] {
|
||||||
const auto path = Core::App().settings().downloadPath();
|
const auto path = Core::App().settings().downloadPath();
|
||||||
@@ -159,7 +170,7 @@ void AddAction(
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
FileDialog::GetFolder(
|
FileDialog::GetFolder(
|
||||||
nullptr,
|
controller->window().widget().get(),
|
||||||
tr::lng_download_path_choose(tr::now),
|
tr::lng_download_path_choose(tr::now),
|
||||||
initialPath,
|
initialPath,
|
||||||
handleFolder);
|
handleFolder);
|
||||||
|
Reference in New Issue
Block a user