mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-04-07 01:53:14 +00:00
Use separate click handler for OpenWith.
This commit is contained in:
parent
f9f84fd407
commit
5ec37e9112
@ -702,7 +702,7 @@ void BackgroundPreviewBox::checkLoadedDocument() {
|
|||||||
const auto document = _paper.document();
|
const auto document = _paper.document();
|
||||||
if (!_full.isNull()
|
if (!_full.isNull()
|
||||||
|| !document
|
|| !document
|
||||||
|| !document->loaded(DocumentData::FilePathResolveChecked)
|
|| !document->loaded(DocumentData::FilePathResolve::Checked)
|
||||||
|| _generating) {
|
|| _generating) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -35,6 +35,8 @@ namespace {
|
|||||||
|
|
||||||
constexpr auto kMemoryForCache = 32 * 1024 * 1024;
|
constexpr auto kMemoryForCache = 32 * 1024 * 1024;
|
||||||
|
|
||||||
|
using FilePathResolve = DocumentData::FilePathResolve;
|
||||||
|
|
||||||
Core::MediaActiveCache<DocumentData> &ActiveCache() {
|
Core::MediaActiveCache<DocumentData> &ActiveCache() {
|
||||||
static auto Instance = Core::MediaActiveCache<DocumentData>(
|
static auto Instance = Core::MediaActiveCache<DocumentData>(
|
||||||
kMemoryForCache,
|
kMemoryForCache,
|
||||||
@ -294,6 +296,19 @@ void DocumentOpenClickHandler::Open(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const auto openFile = [&] {
|
||||||
|
const auto &location = data->location(true);
|
||||||
|
if (data->size < App::kImageSizeLimit && location.accessEnable()) {
|
||||||
|
const auto guard = gsl::finally([&] {
|
||||||
|
location.accessDisable();
|
||||||
|
});
|
||||||
|
if (QImageReader(location.name()).canRead()) {
|
||||||
|
Core::App().showDocument(data, context);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
LaunchWithWarning(location.name(), context);
|
||||||
|
};
|
||||||
const auto &location = data->location(true);
|
const auto &location = data->location(true);
|
||||||
if (data->isTheme() && !location.isEmpty() && location.accessEnable()) {
|
if (data->isTheme() && !location.isEmpty() && location.accessEnable()) {
|
||||||
Core::App().showDocument(data, context);
|
Core::App().showDocument(data, context);
|
||||||
@ -309,17 +324,11 @@ void DocumentOpenClickHandler::Open(
|
|||||||
} else {
|
} else {
|
||||||
Core::App().showDocument(data, context);
|
Core::App().showDocument(data, context);
|
||||||
}
|
}
|
||||||
} else if (!location.isEmpty()) {
|
} else if (!location.isEmpty()
|
||||||
if (data->size < App::kImageSizeLimit && location.accessEnable()) {
|
|| (data->loaded()
|
||||||
const auto guard = gsl::finally([&] {
|
&& !data->filepath(
|
||||||
location.accessDisable();
|
FilePathResolve::SaveFromDataSilent).isEmpty())) {
|
||||||
});
|
openFile();
|
||||||
if (QImageReader(location.name()).canRead()) {
|
|
||||||
Core::App().showDocument(data, context);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
LaunchWithWarning(location.name(), context);
|
|
||||||
} else if (data->status == FileReady
|
} else if (data->status == FileReady
|
||||||
|| data->status == FileDownloadFailed) {
|
|| data->status == FileDownloadFailed) {
|
||||||
DocumentSaveClickHandler::Save(origin, data);
|
DocumentSaveClickHandler::Save(origin, data);
|
||||||
@ -338,19 +347,13 @@ void DocumentSaveClickHandler::Save(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mode == Mode::ToCacheOrFile
|
|
||||||
&& data->loaded(DocumentData::FilePathResolveSaveFromDataSilent)) {
|
|
||||||
File::OpenWith(data->filepath(), QCursor::pos());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
auto savename = QString();
|
auto savename = QString();
|
||||||
if (mode != Mode::ToCacheOrFile || !data->saveToCache()) {
|
if (mode != Mode::ToCacheOrFile || !data->saveToCache()) {
|
||||||
const auto filepath = data->filepath(
|
const auto filepath = data->filepath(FilePathResolve::Checked);
|
||||||
DocumentData::FilePathResolveChecked);
|
|
||||||
if (mode != Mode::ToNewFile
|
if (mode != Mode::ToNewFile
|
||||||
&& (!filepath.isEmpty()
|
&& (!filepath.isEmpty()
|
||||||
|| !data->filepath(
|
|| !data->filepath(
|
||||||
DocumentData::FilePathResolveSaveFromData).isEmpty())) {
|
FilePathResolve::SaveFromData).isEmpty())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const auto fileinfo = QFileInfo(filepath);
|
const auto fileinfo = QFileInfo(filepath);
|
||||||
@ -389,6 +392,31 @@ void DocumentCancelClickHandler::onClickImpl() const {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DocumentOpenWithClickHandler::Open(
|
||||||
|
Data::FileOrigin origin,
|
||||||
|
not_null<DocumentData*> data) {
|
||||||
|
if (!data->date) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data->loaded()) {
|
||||||
|
const auto path = data->filepath(
|
||||||
|
FilePathResolve::SaveFromDataSilent);
|
||||||
|
if (!path.isEmpty()) {
|
||||||
|
File::OpenWith(path, QCursor::pos());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
DocumentSaveClickHandler::Save(
|
||||||
|
origin,
|
||||||
|
data,
|
||||||
|
DocumentSaveClickHandler::Mode::ToFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DocumentOpenWithClickHandler::onClickImpl() const {
|
||||||
|
Open(context(), document());
|
||||||
|
}
|
||||||
|
|
||||||
Data::FileOrigin StickerData::setOrigin() const {
|
Data::FileOrigin StickerData::setOrigin() const {
|
||||||
return set.match([&](const MTPDinputStickerSetID &data) {
|
return set.match([&](const MTPDinputStickerSetID &data) {
|
||||||
return Data::FileOrigin(
|
return Data::FileOrigin(
|
||||||
@ -689,7 +717,7 @@ void DocumentData::automaticLoadSettingsChanged() {
|
|||||||
_loader = nullptr;
|
_loader = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DocumentData::loaded(FilePathResolveType type) const {
|
bool DocumentData::loaded(FilePathResolve resolve) const {
|
||||||
if (loading() && _loader->finished()) {
|
if (loading() && _loader->finished()) {
|
||||||
if (_loader->cancelled()) {
|
if (_loader->cancelled()) {
|
||||||
destroyLoader(CancelledMtpFileLoader);
|
destroyLoader(CancelledMtpFileLoader);
|
||||||
@ -721,7 +749,7 @@ bool DocumentData::loaded(FilePathResolveType type) const {
|
|||||||
}
|
}
|
||||||
_owner->notifyDocumentLayoutChanged(this);
|
_owner->notifyDocumentLayoutChanged(this);
|
||||||
}
|
}
|
||||||
return !data().isEmpty() || !filepath(type).isEmpty();
|
return !data().isEmpty() || !filepath(resolve).isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DocumentData::destroyLoader(mtpFileLoader *newValue) const {
|
void DocumentData::destroyLoader(mtpFileLoader *newValue) const {
|
||||||
@ -782,7 +810,7 @@ void DocumentData::save(
|
|||||||
const QString &toFile,
|
const QString &toFile,
|
||||||
LoadFromCloudSetting fromCloud,
|
LoadFromCloudSetting fromCloud,
|
||||||
bool autoLoading) {
|
bool autoLoading) {
|
||||||
if (loaded(FilePathResolveChecked)) {
|
if (loaded(FilePathResolve::Checked)) {
|
||||||
auto &l = location(true);
|
auto &l = location(true);
|
||||||
if (!toFile.isEmpty()) {
|
if (!toFile.isEmpty()) {
|
||||||
if (!_data.isEmpty()) {
|
if (!_data.isEmpty()) {
|
||||||
@ -946,14 +974,16 @@ void DocumentData::setLocation(const FileLocation &loc) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString DocumentData::filepath(FilePathResolveType type) const {
|
QString DocumentData::filepath(FilePathResolve resolve) const {
|
||||||
bool check = (type != FilePathResolveCached);
|
bool check = (resolve != FilePathResolve::Cached);
|
||||||
QString result = (check && _location.name().isEmpty()) ? QString() : location(check).name();
|
QString result = (check && _location.name().isEmpty()) ? QString() : location(check).name();
|
||||||
bool saveFromData = result.isEmpty() && !data().isEmpty();
|
bool saveFromData = result.isEmpty() && !data().isEmpty();
|
||||||
if (saveFromData) {
|
if (saveFromData) {
|
||||||
if (type != FilePathResolveSaveFromData && type != FilePathResolveSaveFromDataSilent) {
|
if (resolve != FilePathResolve::SaveFromData
|
||||||
|
&& resolve != FilePathResolve::SaveFromDataSilent) {
|
||||||
saveFromData = false;
|
saveFromData = false;
|
||||||
} else if (type == FilePathResolveSaveFromDataSilent && Global::AskDownloadPath()) {
|
} else if (resolve == FilePathResolve::SaveFromDataSilent
|
||||||
|
&& Global::AskDownloadPath()) {
|
||||||
saveFromData = false;
|
saveFromData = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1284,7 +1314,7 @@ bool DocumentData::isVideoMessage() const {
|
|||||||
bool DocumentData::isAnimation() const {
|
bool DocumentData::isAnimation() const {
|
||||||
return (type == AnimatedDocument)
|
return (type == AnimatedDocument)
|
||||||
|| isVideoMessage()
|
|| isVideoMessage()
|
||||||
|| hasMimeType(qstr("image/gif"));
|
|| (hasMimeType(qstr("image/gif")) && !_inappPlaybackFailed);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DocumentData::isGifv() const {
|
bool DocumentData::isGifv() const {
|
||||||
@ -1553,7 +1583,7 @@ base::binary_guard ReadImageAsync(
|
|||||||
//
|
//
|
||||||
// document->setInappPlaybackFailed();
|
// document->setInappPlaybackFailed();
|
||||||
// const auto filepath = document->filepath(
|
// const auto filepath = document->filepath(
|
||||||
// DocumentData::FilePathResolveSaveFromData);
|
// DocumentData::FilePathResolve::SaveFromData);
|
||||||
// if (filepath.isEmpty()) {
|
// if (filepath.isEmpty()) {
|
||||||
// const auto save = [=] {
|
// const auto save = [=] {
|
||||||
// Ui::hideLayer();
|
// Ui::hideLayer();
|
||||||
|
@ -99,14 +99,14 @@ public:
|
|||||||
const HistoryItem *item);
|
const HistoryItem *item);
|
||||||
void automaticLoadSettingsChanged();
|
void automaticLoadSettingsChanged();
|
||||||
|
|
||||||
enum FilePathResolveType {
|
enum class FilePathResolve {
|
||||||
FilePathResolveCached,
|
Cached,
|
||||||
FilePathResolveChecked,
|
Checked,
|
||||||
FilePathResolveSaveFromData,
|
SaveFromData,
|
||||||
FilePathResolveSaveFromDataSilent,
|
SaveFromDataSilent,
|
||||||
};
|
};
|
||||||
[[nodiscard]] bool loaded(
|
[[nodiscard]] bool loaded(
|
||||||
FilePathResolveType type = FilePathResolveCached) const;
|
FilePathResolve resolve = FilePathResolve::Cached) const;
|
||||||
[[nodiscard]] bool loading() const;
|
[[nodiscard]] bool loading() const;
|
||||||
[[nodiscard]] QString loadingFilePath() const;
|
[[nodiscard]] QString loadingFilePath() const;
|
||||||
[[nodiscard]] bool displayLoading() const;
|
[[nodiscard]] bool displayLoading() const;
|
||||||
@ -129,7 +129,7 @@ public:
|
|||||||
void setLocation(const FileLocation &loc);
|
void setLocation(const FileLocation &loc);
|
||||||
|
|
||||||
[[nodiscard]] QString filepath(
|
[[nodiscard]] QString filepath(
|
||||||
FilePathResolveType type = FilePathResolveCached) const;
|
FilePathResolve resolve = FilePathResolve::Cached) const;
|
||||||
|
|
||||||
[[nodiscard]] bool saveToCache() const;
|
[[nodiscard]] bool saveToCache() const;
|
||||||
|
|
||||||
@ -344,6 +344,18 @@ protected:
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class DocumentOpenWithClickHandler : public DocumentClickHandler {
|
||||||
|
public:
|
||||||
|
using DocumentClickHandler::DocumentClickHandler;
|
||||||
|
static void Open(
|
||||||
|
Data::FileOrigin origin,
|
||||||
|
not_null<DocumentData*> document);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void onClickImpl() const override;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
class VoiceSeekClickHandler : public DocumentOpenClickHandler {
|
class VoiceSeekClickHandler : public DocumentOpenClickHandler {
|
||||||
public:
|
public:
|
||||||
using DocumentOpenClickHandler::DocumentOpenClickHandler;
|
using DocumentOpenClickHandler::DocumentOpenClickHandler;
|
||||||
|
@ -1011,7 +1011,7 @@ void InnerWidget::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!document->filepath(DocumentData::FilePathResolveChecked).isEmpty()) {
|
if (!document->filepath(DocumentData::FilePathResolve::Checked).isEmpty()) {
|
||||||
_menu->addAction(lang((cPlatform() == dbipMac || cPlatform() == dbipMacOld) ? lng_context_show_in_finder : lng_context_show_in_folder), [=] {
|
_menu->addAction(lang((cPlatform() == dbipMac || cPlatform() == dbipMacOld) ? lng_context_show_in_finder : lng_context_show_in_folder), [=] {
|
||||||
showContextInFolder(document);
|
showContextInFolder(document);
|
||||||
});
|
});
|
||||||
@ -1118,7 +1118,7 @@ void InnerWidget::cancelContextDownload(not_null<DocumentData*> document) {
|
|||||||
|
|
||||||
void InnerWidget::showContextInFolder(not_null<DocumentData*> document) {
|
void InnerWidget::showContextInFolder(not_null<DocumentData*> document) {
|
||||||
const auto filepath = document->filepath(
|
const auto filepath = document->filepath(
|
||||||
DocumentData::FilePathResolveChecked);
|
DocumentData::FilePathResolve::Checked);
|
||||||
if (!filepath.isEmpty()) {
|
if (!filepath.isEmpty()) {
|
||||||
File::ShowInFolder(filepath);
|
File::ShowInFolder(filepath);
|
||||||
}
|
}
|
||||||
@ -1625,7 +1625,7 @@ void InnerWidget::performDrag() {
|
|||||||
// auto mimeData = std::make_unique<QMimeData>();
|
// auto mimeData = std::make_unique<QMimeData>();
|
||||||
// mimeData->setData(forwardMimeType, "1");
|
// mimeData->setData(forwardMimeType, "1");
|
||||||
// if (auto document = (pressedMedia ? pressedMedia->getDocument() : nullptr)) {
|
// if (auto document = (pressedMedia ? pressedMedia->getDocument() : nullptr)) {
|
||||||
// auto filepath = document->filepath(DocumentData::FilePathResolveChecked);
|
// auto filepath = document->filepath(DocumentData::FilePathResolve::Checked);
|
||||||
// if (!filepath.isEmpty()) {
|
// if (!filepath.isEmpty()) {
|
||||||
// QList<QUrl> urls;
|
// QList<QUrl> urls;
|
||||||
// urls.push_back(QUrl::fromLocalFile(filepath));
|
// urls.push_back(QUrl::fromLocalFile(filepath));
|
||||||
|
@ -1192,7 +1192,7 @@ std::unique_ptr<QMimeData> HistoryInner::prepareDrag() {
|
|||||||
if (const auto media = view->media()) {
|
if (const auto media = view->media()) {
|
||||||
if (const auto document = media->getDocument()) {
|
if (const auto document = media->getDocument()) {
|
||||||
const auto filepath = document->filepath(
|
const auto filepath = document->filepath(
|
||||||
DocumentData::FilePathResolveChecked);
|
DocumentData::FilePathResolve::Checked);
|
||||||
if (!filepath.isEmpty()) {
|
if (!filepath.isEmpty()) {
|
||||||
QList<QUrl> urls;
|
QList<QUrl> urls;
|
||||||
urls.push_back(QUrl::fromLocalFile(filepath));
|
urls.push_back(QUrl::fromLocalFile(filepath));
|
||||||
@ -1538,7 +1538,7 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
|
|||||||
saveContextGif(itemId);
|
saveContextGif(itemId);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (!document->filepath(DocumentData::FilePathResolveChecked).isEmpty()) {
|
if (!document->filepath(DocumentData::FilePathResolve::Checked).isEmpty()) {
|
||||||
_menu->addAction(lang((cPlatform() == dbipMac || cPlatform() == dbipMacOld) ? lng_context_show_in_finder : lng_context_show_in_folder), [=] {
|
_menu->addAction(lang((cPlatform() == dbipMac || cPlatform() == dbipMacOld) ? lng_context_show_in_finder : lng_context_show_in_folder), [=] {
|
||||||
showContextInFolder(document);
|
showContextInFolder(document);
|
||||||
});
|
});
|
||||||
@ -1814,7 +1814,7 @@ void HistoryInner::cancelContextDownload(not_null<DocumentData*> document) {
|
|||||||
|
|
||||||
void HistoryInner::showContextInFolder(not_null<DocumentData*> document) {
|
void HistoryInner::showContextInFolder(not_null<DocumentData*> document) {
|
||||||
const auto filepath = document->filepath(
|
const auto filepath = document->filepath(
|
||||||
DocumentData::FilePathResolveChecked);
|
DocumentData::FilePathResolve::Checked);
|
||||||
if (!filepath.isEmpty()) {
|
if (!filepath.isEmpty()) {
|
||||||
File::ShowInFolder(filepath);
|
File::ShowInFolder(filepath);
|
||||||
}
|
}
|
||||||
|
@ -340,7 +340,9 @@ struct HistoryMessageLogEntryOriginal
|
|||||||
|
|
||||||
class FileClickHandler;
|
class FileClickHandler;
|
||||||
struct HistoryDocumentThumbed : public RuntimeComponent<HistoryDocumentThumbed, HistoryDocument> {
|
struct HistoryDocumentThumbed : public RuntimeComponent<HistoryDocumentThumbed, HistoryDocument> {
|
||||||
std::shared_ptr<FileClickHandler> _linksavel, _linkcancell;
|
std::shared_ptr<FileClickHandler> _linksavel;
|
||||||
|
std::shared_ptr<FileClickHandler> _linkopenwithl;
|
||||||
|
std::shared_ptr<FileClickHandler> _linkcancell;
|
||||||
int _thumbw = 0;
|
int _thumbw = 0;
|
||||||
|
|
||||||
mutable int _linkw = 0;
|
mutable int _linkw = 0;
|
||||||
|
@ -86,6 +86,9 @@ void HistoryDocument::createComponents(bool caption) {
|
|||||||
thumbed->_linksavel = std::make_shared<DocumentSaveClickHandler>(
|
thumbed->_linksavel = std::make_shared<DocumentSaveClickHandler>(
|
||||||
_data,
|
_data,
|
||||||
_parent->data()->fullId());
|
_parent->data()->fullId());
|
||||||
|
thumbed->_linkopenwithl = std::make_shared<DocumentOpenWithClickHandler>(
|
||||||
|
_data,
|
||||||
|
_parent->data()->fullId());
|
||||||
thumbed->_linkcancell = std::make_shared<DocumentCancelClickHandler>(
|
thumbed->_linkcancell = std::make_shared<DocumentCancelClickHandler>(
|
||||||
_data,
|
_data,
|
||||||
_parent->data()->fullId());
|
_parent->data()->fullId());
|
||||||
@ -282,6 +285,8 @@ void HistoryDocument::draw(Painter &p, const QRect &r, TextSelection selection,
|
|||||||
if (_data->status != FileUploadFailed) {
|
if (_data->status != FileUploadFailed) {
|
||||||
const auto &lnk = (_data->loading() || _data->uploading())
|
const auto &lnk = (_data->loading() || _data->uploading())
|
||||||
? thumbed->_linkcancell
|
? thumbed->_linkcancell
|
||||||
|
: _data->loaded()
|
||||||
|
? thumbed->_linkopenwithl
|
||||||
: thumbed->_linksavel;
|
: thumbed->_linksavel;
|
||||||
bool over = ClickHandler::showAsActive(lnk);
|
bool over = ClickHandler::showAsActive(lnk);
|
||||||
p.setFont(over ? st::semiboldFont->underline() : st::semiboldFont);
|
p.setFont(over ? st::semiboldFont->underline() : st::semiboldFont);
|
||||||
@ -474,6 +479,8 @@ TextState HistoryDocument::textState(QPoint point, StateRequest request) const {
|
|||||||
if (rtlrect(nameleft, linktop, thumbed->_linkw, st::semiboldFont->height, width()).contains(point)) {
|
if (rtlrect(nameleft, linktop, thumbed->_linkw, st::semiboldFont->height, width()).contains(point)) {
|
||||||
result.link = (_data->loading() || _data->uploading())
|
result.link = (_data->loading() || _data->uploading())
|
||||||
? thumbed->_linkcancell
|
? thumbed->_linkcancell
|
||||||
|
: _data->loaded()
|
||||||
|
? thumbed->_linkopenwithl
|
||||||
: thumbed->_linksavel;
|
: thumbed->_linksavel;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -874,7 +874,7 @@ void HistoryGif::playAnimation(bool autoplay) {
|
|||||||
using Mode = Media::Clip::Reader::Mode;
|
using Mode = Media::Clip::Reader::Mode;
|
||||||
if (_gif) {
|
if (_gif) {
|
||||||
stopAnimation();
|
stopAnimation();
|
||||||
} else if (_data->loaded(DocumentData::FilePathResolveChecked)) {
|
} else if (_data->loaded(DocumentData::FilePathResolve::Checked)) {
|
||||||
if (!cAutoPlayGif()) {
|
if (!cAutoPlayGif()) {
|
||||||
history()->owner().stopAutoplayAnimations();
|
history()->owner().stopAutoplayAnimations();
|
||||||
}
|
}
|
||||||
|
@ -112,7 +112,7 @@ void OpenGif(FullMsgId itemId) {
|
|||||||
|
|
||||||
void ShowInFolder(not_null<DocumentData*> document) {
|
void ShowInFolder(not_null<DocumentData*> document) {
|
||||||
const auto filepath = document->filepath(
|
const auto filepath = document->filepath(
|
||||||
DocumentData::FilePathResolveChecked);
|
DocumentData::FilePathResolve::Checked);
|
||||||
if (!filepath.isEmpty()) {
|
if (!filepath.isEmpty()) {
|
||||||
File::ShowInFolder(filepath);
|
File::ShowInFolder(filepath);
|
||||||
}
|
}
|
||||||
@ -175,7 +175,7 @@ void AddDocumentActions(
|
|||||||
[=] { ToggleFavedSticker(document, contextId); });
|
[=] { ToggleFavedSticker(document, contextId); });
|
||||||
}
|
}
|
||||||
if (!document->filepath(
|
if (!document->filepath(
|
||||||
DocumentData::FilePathResolveChecked).isEmpty()) {
|
DocumentData::FilePathResolve::Checked).isEmpty()) {
|
||||||
menu->addAction(
|
menu->addAction(
|
||||||
lang((cPlatform() == dbipMac || cPlatform() == dbipMacOld)
|
lang((cPlatform() == dbipMac || cPlatform() == dbipMacOld)
|
||||||
? lng_context_show_in_finder
|
? lng_context_show_in_finder
|
||||||
|
@ -2311,7 +2311,7 @@ std::unique_ptr<QMimeData> ListWidget::prepareDrag() {
|
|||||||
if (const auto media = pressedView->media()) {
|
if (const auto media = pressedView->media()) {
|
||||||
if (const auto document = media->getDocument()) {
|
if (const auto document = media->getDocument()) {
|
||||||
const auto filepath = document->filepath(
|
const auto filepath = document->filepath(
|
||||||
DocumentData::FilePathResolveChecked);
|
DocumentData::FilePathResolve::Checked);
|
||||||
if (!filepath.isEmpty()) {
|
if (!filepath.isEmpty()) {
|
||||||
QList<QUrl> urls;
|
QList<QUrl> urls;
|
||||||
urls.push_back(QUrl::fromLocalFile(filepath));
|
urls.push_back(QUrl::fromLocalFile(filepath));
|
||||||
|
@ -1256,7 +1256,7 @@ void ListWidget::showContextMenu(
|
|||||||
document->cancel();
|
document->cancel();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
auto filepath = document->filepath(DocumentData::FilePathResolveChecked);
|
auto filepath = document->filepath(DocumentData::FilePathResolve::Checked);
|
||||||
if (!filepath.isEmpty()) {
|
if (!filepath.isEmpty()) {
|
||||||
auto handler = App::LambdaDelayed(
|
auto handler = App::LambdaDelayed(
|
||||||
st::defaultDropdownMenu.menu.ripple.hideDuration,
|
st::defaultDropdownMenu.menu.ripple.hideDuration,
|
||||||
@ -1957,7 +1957,7 @@ void ListWidget::performDrag() {
|
|||||||
// auto mimeData = std::make_unique<QMimeData>();
|
// auto mimeData = std::make_unique<QMimeData>();
|
||||||
// mimeData->setData(forwardMimeType, "1");
|
// mimeData->setData(forwardMimeType, "1");
|
||||||
// if (auto document = (pressedMedia ? pressedMedia->getDocument() : nullptr)) {
|
// if (auto document = (pressedMedia ? pressedMedia->getDocument() : nullptr)) {
|
||||||
// auto filepath = document->filepath(DocumentData::FilePathResolveChecked);
|
// auto filepath = document->filepath(DocumentData::FilePathResolve::Checked);
|
||||||
// if (!filepath.isEmpty()) {
|
// if (!filepath.isEmpty()) {
|
||||||
// QList<QUrl> urls;
|
// QList<QUrl> urls;
|
||||||
// urls.push_back(QUrl::fromLocalFile(filepath));
|
// urls.push_back(QUrl::fromLocalFile(filepath));
|
||||||
|
@ -466,7 +466,7 @@ void OverlayWidget::updateControls() {
|
|||||||
_docCancel->moveToLeft(_docRect.x() + 2 * st::mediaviewFilePadding + st::mediaviewFileIconSize, _docRect.y() + st::mediaviewFilePadding + st::mediaviewFileLinksTop);
|
_docCancel->moveToLeft(_docRect.x() + 2 * st::mediaviewFilePadding + st::mediaviewFileIconSize, _docRect.y() + st::mediaviewFilePadding + st::mediaviewFileLinksTop);
|
||||||
_docCancel->show();
|
_docCancel->show();
|
||||||
} else {
|
} else {
|
||||||
if (_doc->loaded(DocumentData::FilePathResolveChecked)) {
|
if (_doc->loaded(DocumentData::FilePathResolve::Checked)) {
|
||||||
_docDownload->hide();
|
_docDownload->hide();
|
||||||
_docSaveAs->moveToLeft(_docRect.x() + 2 * st::mediaviewFilePadding + st::mediaviewFileIconSize, _docRect.y() + st::mediaviewFilePadding + st::mediaviewFileLinksTop);
|
_docSaveAs->moveToLeft(_docRect.x() + 2 * st::mediaviewFilePadding + st::mediaviewFileIconSize, _docRect.y() + st::mediaviewFilePadding + st::mediaviewFileLinksTop);
|
||||||
_docSaveAs->show();
|
_docSaveAs->show();
|
||||||
@ -490,7 +490,7 @@ void OverlayWidget::updateControls() {
|
|||||||
updateThemePreviewGeometry();
|
updateThemePreviewGeometry();
|
||||||
|
|
||||||
_saveVisible = (_photo && _photo->loaded())
|
_saveVisible = (_photo && _photo->loaded())
|
||||||
|| (_doc && (_doc->loaded(DocumentData::FilePathResolveChecked)
|
|| (_doc && (_doc->loaded(DocumentData::FilePathResolve::Checked)
|
||||||
|| !documentContentShown()));
|
|| !documentContentShown()));
|
||||||
_saveNav = myrtlrect(width() - st::mediaviewIconSize.width() * 2, height() - st::mediaviewIconSize.height(), st::mediaviewIconSize.width(), st::mediaviewIconSize.height());
|
_saveNav = myrtlrect(width() - st::mediaviewIconSize.width() * 2, height() - st::mediaviewIconSize.height(), st::mediaviewIconSize.width(), st::mediaviewIconSize.height());
|
||||||
_saveNavIcon = centerrect(_saveNav, st::mediaviewSave);
|
_saveNavIcon = centerrect(_saveNav, st::mediaviewSave);
|
||||||
@ -593,7 +593,7 @@ void OverlayWidget::updateActions() {
|
|||||||
if (IsServerMsgId(_msgid.msg)) {
|
if (IsServerMsgId(_msgid.msg)) {
|
||||||
_actions.push_back({ lang(lng_context_to_msg), SLOT(onToMessage()) });
|
_actions.push_back({ lang(lng_context_to_msg), SLOT(onToMessage()) });
|
||||||
}
|
}
|
||||||
if (_doc && !_doc->filepath(DocumentData::FilePathResolveChecked).isEmpty()) {
|
if (_doc && !_doc->filepath(DocumentData::FilePathResolve::Checked).isEmpty()) {
|
||||||
_actions.push_back({ lang((cPlatform() == dbipMac || cPlatform() == dbipMacOld) ? lng_context_show_in_finder : lng_context_show_in_folder), SLOT(onShowInFolder()) });
|
_actions.push_back({ lang((cPlatform() == dbipMac || cPlatform() == dbipMacOld) ? lng_context_show_in_finder : lng_context_show_in_folder), SLOT(onShowInFolder()) });
|
||||||
}
|
}
|
||||||
if ((_doc && documentContentShown()) || (_photo && _photo->loaded())) {
|
if ((_doc && documentContentShown()) || (_photo && _photo->loaded())) {
|
||||||
@ -1194,7 +1194,7 @@ void OverlayWidget::onSaveCancel() {
|
|||||||
void OverlayWidget::onShowInFolder() {
|
void OverlayWidget::onShowInFolder() {
|
||||||
if (!_doc) return;
|
if (!_doc) return;
|
||||||
|
|
||||||
auto filepath = _doc->filepath(DocumentData::FilePathResolveChecked);
|
auto filepath = _doc->filepath(DocumentData::FilePathResolve::Checked);
|
||||||
if (!filepath.isEmpty()) {
|
if (!filepath.isEmpty()) {
|
||||||
File::ShowInFolder(filepath);
|
File::ShowInFolder(filepath);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user