2014-05-30 08:53:19 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2018-01-03 10:23:14 +00:00
|
|
|
the official desktop application for the Telegram messaging service.
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2018-01-03 10:23:14 +00:00
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
2014-05-30 08:53:19 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2020-06-08 15:17:33 +00:00
|
|
|
namespace Main {
|
|
|
|
class Session;
|
|
|
|
} // namespace Main
|
|
|
|
|
2017-02-28 14:05:30 +00:00
|
|
|
// legacy
|
2017-12-21 16:15:37 +00:00
|
|
|
bool filedialogGetSaveFile(
|
|
|
|
QString &file,
|
|
|
|
const QString &caption,
|
|
|
|
const QString &filter,
|
|
|
|
const QString &initialPath);
|
|
|
|
|
|
|
|
QString filedialogDefaultName(
|
|
|
|
const QString &prefix,
|
|
|
|
const QString &extension,
|
|
|
|
const QString &path = QString(),
|
|
|
|
bool skipExistance = false,
|
2018-02-03 19:52:35 +00:00
|
|
|
TimeId fileTime = TimeId(0));
|
2017-12-21 16:15:37 +00:00
|
|
|
QString filedialogNextFilename(
|
|
|
|
const QString &name,
|
|
|
|
const QString &cur,
|
|
|
|
const QString &path = QString());
|
2016-05-25 17:59:21 +00:00
|
|
|
|
2017-02-28 14:05:30 +00:00
|
|
|
namespace File {
|
|
|
|
|
|
|
|
// Those functions are async wrappers to Platform::File::Unsafe* calls.
|
2020-04-28 08:26:12 +00:00
|
|
|
void OpenUrl(const QString &url);
|
2017-02-28 14:05:30 +00:00
|
|
|
void OpenEmailLink(const QString &email);
|
2023-01-20 05:16:51 +00:00
|
|
|
void OpenWith(const QString &filepath);
|
2017-02-28 14:05:30 +00:00
|
|
|
void Launch(const QString &filepath);
|
|
|
|
void ShowInFolder(const QString &filepath);
|
|
|
|
|
2020-06-08 15:17:33 +00:00
|
|
|
[[nodiscard]] QString DefaultDownloadPathFolder(
|
|
|
|
not_null<Main::Session*> session);
|
|
|
|
[[nodiscard]] QString DefaultDownloadPath(not_null<Main::Session*> session);
|
2019-09-03 08:43:29 +00:00
|
|
|
|
2017-02-28 14:05:30 +00:00
|
|
|
namespace internal {
|
|
|
|
|
|
|
|
inline QString UrlToLocalDefault(const QUrl &url) {
|
|
|
|
return url.toLocalFile();
|
|
|
|
}
|
|
|
|
|
2020-04-28 08:26:12 +00:00
|
|
|
void UnsafeOpenUrlDefault(const QString &url);
|
2017-02-28 14:05:30 +00:00
|
|
|
void UnsafeOpenEmailLinkDefault(const QString &email);
|
|
|
|
void UnsafeLaunchDefault(const QString &filepath);
|
|
|
|
|
|
|
|
} // namespace internal
|
|
|
|
} // namespace File
|
|
|
|
|
2016-05-25 17:59:21 +00:00
|
|
|
namespace FileDialog {
|
2017-02-28 15:43:03 +00:00
|
|
|
|
|
|
|
struct OpenResult {
|
|
|
|
QStringList paths;
|
|
|
|
QByteArray remoteContent;
|
|
|
|
};
|
2017-12-21 16:15:37 +00:00
|
|
|
void GetOpenPath(
|
2018-04-17 15:19:34 +00:00
|
|
|
QPointer<QWidget> parent,
|
2017-12-21 16:15:37 +00:00
|
|
|
const QString &caption,
|
|
|
|
const QString &filter,
|
2018-06-04 15:35:11 +00:00
|
|
|
Fn<void(OpenResult &&result)> callback,
|
|
|
|
Fn<void()> failed = Fn<void()>());
|
2017-12-21 16:15:37 +00:00
|
|
|
void GetOpenPaths(
|
2018-04-17 15:19:34 +00:00
|
|
|
QPointer<QWidget> parent,
|
2017-12-21 16:15:37 +00:00
|
|
|
const QString &caption,
|
|
|
|
const QString &filter,
|
2018-06-04 15:35:11 +00:00
|
|
|
Fn<void(OpenResult &&result)> callback,
|
|
|
|
Fn<void()> failed = Fn<void()>());
|
2017-12-21 16:15:37 +00:00
|
|
|
void GetWritePath(
|
2018-04-17 15:19:34 +00:00
|
|
|
QPointer<QWidget> parent,
|
2017-12-21 16:15:37 +00:00
|
|
|
const QString &caption,
|
|
|
|
const QString &filter,
|
|
|
|
const QString &initialPath,
|
2018-06-04 15:35:11 +00:00
|
|
|
Fn<void(QString &&result)> callback,
|
|
|
|
Fn<void()> failed = Fn<void()>());
|
2017-12-21 16:15:37 +00:00
|
|
|
void GetFolder(
|
2018-04-17 15:19:34 +00:00
|
|
|
QPointer<QWidget> parent,
|
2017-12-21 16:15:37 +00:00
|
|
|
const QString &caption,
|
|
|
|
const QString &initialPath,
|
2018-06-04 15:35:11 +00:00
|
|
|
Fn<void(QString &&result)> callback,
|
|
|
|
Fn<void()> failed = Fn<void()>());
|
2017-02-28 15:43:03 +00:00
|
|
|
|
2020-10-13 10:00:35 +00:00
|
|
|
[[nodiscard]] QString AllFilesFilter();
|
|
|
|
[[nodiscard]] QString ImagesFilter();
|
|
|
|
[[nodiscard]] QString AllOrImagesFilter();
|
|
|
|
[[nodiscard]] QString ImagesOrAllFilter();
|
2020-10-20 08:19:48 +00:00
|
|
|
[[nodiscard]] QString PhotoVideoFilesFilter();
|
2022-11-30 00:05:55 +00:00
|
|
|
[[nodiscard]] const QString &Tmp();
|
2017-02-28 15:43:03 +00:00
|
|
|
|
2016-07-06 18:30:14 +00:00
|
|
|
namespace internal {
|
|
|
|
|
|
|
|
enum class Type {
|
|
|
|
ReadFile,
|
|
|
|
ReadFiles,
|
|
|
|
ReadFolder,
|
|
|
|
WriteFile,
|
|
|
|
};
|
|
|
|
|
2017-02-28 14:05:30 +00:00
|
|
|
void InitLastPathDefault();
|
|
|
|
|
2017-12-21 16:15:37 +00:00
|
|
|
bool GetDefault(
|
2018-04-17 15:19:34 +00:00
|
|
|
QPointer<QWidget> parent,
|
2017-12-21 16:15:37 +00:00
|
|
|
QStringList &files,
|
|
|
|
QByteArray &remoteContent,
|
|
|
|
const QString &caption,
|
|
|
|
const QString &filter,
|
|
|
|
::FileDialog::internal::Type type,
|
|
|
|
QString startFile);
|
2017-02-28 14:05:30 +00:00
|
|
|
|
2016-07-06 18:30:14 +00:00
|
|
|
} // namespace internal
|
2016-05-25 17:59:21 +00:00
|
|
|
} // namespace FileDialog
|