mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2026-11-27 20:36:49 -08:00
Add New/Preview Entry Attachments dialog and functionality (#11637)
Closes #11506 Closes #3383 * This change adds a new opportunity to add attachments that don’t require a real file in the file system. * Add a new dialog window to add and preview attachments and integrate it into the EntryAttachmentsWidget. * Attachment preview support for images and plain text files. Additional enhancements: * Fix sizing of attachment columns * Add padding to attachment table items * Fix targeting of preview widget styling to not impact unintended children
This commit is contained in:
1 parent
40ee047ef0
commit
dce34de875
16 files changed
+717
-47
No files matched your search
@@ -475,4 +475,32 @@ namespace Tools
|
||||
|
||||
return pattern;
|
||||
}
|
||||
|
||||
MimeType toMimeType(const QString& mimeName)
|
||||
{
|
||||
static QStringList textFormats = {
|
||||
"text/",
|
||||
"application/json",
|
||||
"application/xml",
|
||||
"application/soap+xml",
|
||||
"application/x-yaml",
|
||||
"application/protobuf",
|
||||
};
|
||||
static QStringList imageFormats = {"image/"};
|
||||
|
||||
static auto isCompatible = [](const QString& format, const QStringList& list) {
|
||||
return std::any_of(
|
||||
list.cbegin(), list.cend(), [&format](const auto& item) { return format.startsWith(item); });
|
||||
};
|
||||
|
||||
if (isCompatible(mimeName, imageFormats)) {
|
||||
return MimeType::Image;
|
||||
}
|
||||
|
||||
if (isCompatible(mimeName, textFormats)) {
|
||||
return MimeType::PlainText;
|
||||
}
|
||||
|
||||
return MimeType::Unknown;
|
||||
}
|
||||
} // namespace Tools
|
||||
Reference in new issue
Block a user