MCPcopy Create free account
hub / github.com/KDE/okular / viewFile

Method viewFile

part/embeddedfilesdialog.cpp:170–191  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

168}
169
170void EmbeddedFilesDialog::viewFile(Okular::EmbeddedFile *ef)
171{
172 // get name and extension
173 QFileInfo fileInfo(ef->name());
174
175 // save in temporary directory with a unique name resembling the attachment name,
176 // using QTemporaryFile's XXXXXX placeholder
177 QTemporaryFile *tmpFile =
178 new QTemporaryFile(QDir::tempPath() + QLatin1Char('/') + fileInfo.baseName() + QStringLiteral(".XXXXXX") + (fileInfo.completeSuffix().isEmpty() ? QLatin1String("") : QString(QLatin1Char('.') + fileInfo.completeSuffix())));
179 GuiUtils::writeEmbeddedFile(ef, this, *tmpFile);
180
181 // set readonly to prevent the viewer application from modifying it
182 tmpFile->setPermissions(QFile::ReadOwner);
183
184 // keep temporary file alive while the dialog is open
185 m_openedFiles.push_back(QSharedPointer<QTemporaryFile>(tmpFile));
186
187 // view the temporary file with the default application
188 auto *job = new KIO::OpenUrlJob(QUrl::fromLocalFile(tmpFile->fileName()));
189 job->setUiDelegate(KIO::createDefaultJobUiDelegate(KJobUiDelegate::AutoHandlingEnabled, this));
190 job->start();
191}
192
193void EmbeddedFilesDialog::saveFile(Okular::EmbeddedFile *ef)
194{

Callers

nothing calls this directly

Calls 6

writeEmbeddedFileFunction · 0.85
isEmptyMethod · 0.80
QStringClass · 0.70
nameMethod · 0.45
fileNameMethod · 0.45
startMethod · 0.45

Tested by

no test coverage detected