MCPcopy Create free account
hub / github.com/TDesktop-x64/tdesktop / Save

Method Save

Telegram/SourceFiles/data/data_file_click_handler.cpp:74–118  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

72}
73
74void DocumentSaveClickHandler::Save(
75 Data::FileOrigin origin,
76 not_null<DocumentData*> data,
77 Mode mode,
78 Fn<void()> started) {
79 if (data->isNull()) {
80 return;
81 }
82
83 auto savename = QString();
84 if (mode == Mode::ToCacheOrFile && data->saveToCache()) {
85 data->save(origin, savename);
86 return;
87 }
88 InvokeQueued(qApp, crl::guard(&data->session(), [=] {
89 // If we call file dialog synchronously, it will stop
90 // background thread timers from working which would
91 // stop audio playback in voice chats / live streams.
92 if (mode != Mode::ToNewFile && data->saveFromData()) {
93 if (started) {
94 started();
95 }
96 return;
97 }
98 const auto filepath = data->filepath(true);
99 const auto fileinfo = QFileInfo(filepath);
100 const auto filedir = filepath.isEmpty()
101 ? QDir()
102 : fileinfo.dir();
103 const auto filename = filepath.isEmpty()
104 ? QString()
105 : fileinfo.fileName();
106 const auto savename = DocumentFileNameForSave(
107 data,
108 (mode == Mode::ToNewFile),
109 filename,
110 filedir);
111 if (!savename.isEmpty()) {
112 data->save(origin, savename);
113 if (started) {
114 started();
115 }
116 }
117 }));
118}
119
120void DocumentSaveClickHandler::SaveAndTrack(
121 FullMsgId itemId,

Callers 5

ManageAppLinkFunction · 0.80
CheckPinnedFunction · 0.80
validateShortcutAtFunction · 0.80
ValidateShortcutFunction · 0.80
wWinMainFunction · 0.80

Calls 12

startedFunction · 0.85
QFileInfoClass · 0.85
DocumentFileNameForSaveFunction · 0.85
saveToCacheMethod · 0.80
saveFromDataMethod · 0.80
filepathMethod · 0.80
fileNameMethod · 0.80
QStringClass · 0.50
isNullMethod · 0.45
saveMethod · 0.45
sessionMethod · 0.45
isEmptyMethod · 0.45

Tested by 1

ManageAppLinkFunction · 0.64