2014-05-30 12:53:19 +04:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2018-01-03 13:23:14 +03:00
|
|
|
the official desktop application for the Telegram messaging service.
|
2014-05-30 12:53:19 +04:00
|
|
|
|
2018-01-03 13:23:14 +03:00
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
2014-05-30 12:53:19 +04:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2017-04-06 17:38:10 +03:00
|
|
|
#include "base/observer.h"
|
2016-05-25 20:59:21 +03:00
|
|
|
|
2017-02-28 17:05:30 +03:00
|
|
|
// legacy
|
2017-12-21 20:15:37 +04: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 22:52:35 +03:00
|
|
|
TimeId fileTime = TimeId(0));
|
2017-12-21 20:15:37 +04:00
|
|
|
QString filedialogNextFilename(
|
|
|
|
const QString &name,
|
|
|
|
const QString &cur,
|
|
|
|
const QString &path = QString());
|
2016-05-25 20:59:21 +03:00
|
|
|
|
2017-02-28 17:05:30 +03:00
|
|
|
namespace File {
|
|
|
|
|
|
|
|
// Those functions are async wrappers to Platform::File::Unsafe* calls.
|
|
|
|
void OpenEmailLink(const QString &email);
|
|
|
|
void OpenWith(const QString &filepath, QPoint menuPosition);
|
|
|
|
void Launch(const QString &filepath);
|
|
|
|
void ShowInFolder(const QString &filepath);
|
|
|
|
|
2019-09-03 11:43:29 +03:00
|
|
|
[[nodiscard]] QString DefaultDownloadPath();
|
|
|
|
|
|
|
|
[[nodiscard]] QString NameFromUserString(QString name);
|
2018-11-22 17:15:52 +04:00
|
|
|
|
2017-02-28 17:05:30 +03:00
|
|
|
namespace internal {
|
|
|
|
|
|
|
|
inline QString UrlToLocalDefault(const QUrl &url) {
|
|
|
|
return url.toLocalFile();
|
|
|
|
}
|
|
|
|
|
|
|
|
void UnsafeOpenEmailLinkDefault(const QString &email);
|
|
|
|
void UnsafeLaunchDefault(const QString &filepath);
|
|
|
|
|
|
|
|
} // namespace internal
|
|
|
|
} // namespace File
|
|
|
|
|
2016-05-25 20:59:21 +03:00
|
|
|
namespace FileDialog {
|
2017-02-28 18:43:03 +03:00
|
|
|
|
|
|
|
struct OpenResult {
|
|
|
|
QStringList paths;
|
|
|
|
QByteArray remoteContent;
|
|
|
|
};
|
2017-12-21 20:15:37 +04:00
|
|
|
void GetOpenPath(
|
2018-04-17 19:19:34 +04:00
|
|
|
QPointer<QWidget> parent,
|
2017-12-21 20:15:37 +04:00
|
|
|
const QString &caption,
|
|
|
|
const QString &filter,
|
2018-06-04 18:35:11 +03:00
|
|
|
Fn<void(OpenResult &&result)> callback,
|
|
|
|
Fn<void()> failed = Fn<void()>());
|
2017-12-21 20:15:37 +04:00
|
|
|
void GetOpenPaths(
|
2018-04-17 19:19:34 +04:00
|
|
|
QPointer<QWidget> parent,
|
2017-12-21 20:15:37 +04:00
|
|
|
const QString &caption,
|
|
|
|
const QString &filter,
|
2018-06-04 18:35:11 +03:00
|
|
|
Fn<void(OpenResult &&result)> callback,
|
|
|
|
Fn<void()> failed = Fn<void()>());
|
2017-12-21 20:15:37 +04:00
|
|
|
void GetWritePath(
|
2018-04-17 19:19:34 +04:00
|
|
|
QPointer<QWidget> parent,
|
2017-12-21 20:15:37 +04:00
|
|
|
const QString &caption,
|
|
|
|
const QString &filter,
|
|
|
|
const QString &initialPath,
|
2018-06-04 18:35:11 +03:00
|
|
|
Fn<void(QString &&result)> callback,
|
|
|
|
Fn<void()> failed = Fn<void()>());
|
2017-12-21 20:15:37 +04:00
|
|
|
void GetFolder(
|
2018-04-17 19:19:34 +04:00
|
|
|
QPointer<QWidget> parent,
|
2017-12-21 20:15:37 +04:00
|
|
|
const QString &caption,
|
|
|
|
const QString &initialPath,
|
2018-06-04 18:35:11 +03:00
|
|
|
Fn<void(QString &&result)> callback,
|
|
|
|
Fn<void()> failed = Fn<void()>());
|
2017-02-28 18:43:03 +03:00
|
|
|
|
|
|
|
QString AllFilesFilter();
|
|
|
|
|
2016-07-06 21:30:14 +03:00
|
|
|
namespace internal {
|
|
|
|
|
|
|
|
enum class Type {
|
|
|
|
ReadFile,
|
|
|
|
ReadFiles,
|
|
|
|
ReadFolder,
|
|
|
|
WriteFile,
|
|
|
|
};
|
|
|
|
|
2017-02-28 17:05:30 +03:00
|
|
|
void InitLastPathDefault();
|
|
|
|
|
2017-12-21 20:15:37 +04:00
|
|
|
bool GetDefault(
|
2018-04-17 19:19:34 +04:00
|
|
|
QPointer<QWidget> parent,
|
2017-12-21 20:15:37 +04:00
|
|
|
QStringList &files,
|
|
|
|
QByteArray &remoteContent,
|
|
|
|
const QString &caption,
|
|
|
|
const QString &filter,
|
|
|
|
::FileDialog::internal::Type type,
|
|
|
|
QString startFile);
|
2017-02-28 17:05:30 +03:00
|
|
|
|
2016-07-06 21:30:14 +03:00
|
|
|
} // namespace internal
|
2016-05-25 20:59:21 +03:00
|
|
|
} // namespace FileDialog
|