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:
Kuznetsov Oleg 2025-01-12 07:08:19 +03:00 committed by GitHub
parent 40ee047ef0
commit dce34de875
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
16 changed files with 717 additions and 47 deletions

View file

@ -272,3 +272,70 @@ void TestTools::testArrayContainsValues()
const auto result3 = Tools::getMissingValuesFromList<int>(numberValues, QList<int>({6, 7, 8}));
QCOMPARE(result3.length(), 3);
}
void TestTools::testMimeTypes()
{
const QStringList TextMimeTypes = {
"text/plain", // Plain text
"text/html", // HTML documents
"text/css", // CSS stylesheets
"text/javascript", // JavaScript files
"text/markdown", // Markdown documents
"text/xml", // XML documents
"text/rtf", // Rich Text Format
"text/vcard", // vCard files
"text/tab-separated-values", // Tab-separated values
"application/json", // JSON data
"application/xml", // XML data
"application/soap+xml", // SOAP messages
"application/x-yaml", // YAML data
"application/protobuf", // Protocol Buffers
};
const QStringList ImageMimeTypes = {
"image/jpeg", // JPEG images
"image/png", // PNG images
"image/gif", // GIF images
"image/bmp", // BMP images
"image/webp", // WEBP images
"image/svg+xml" // SVG images
};
const QStringList UnknownMimeTypes = {
"audio/mpeg", // MPEG audio files
"video/mp4", // MP4 video files
"application/pdf", // PDF documents
"application/zip", // ZIP archives
"application/x-tar", // TAR archives
"application/x-rar-compressed", // RAR archives
"application/x-7z-compressed", // 7z archives
"application/x-shockwave-flash", // Adobe Flash files
"application/vnd.ms-excel", // Microsoft Excel files
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", // Microsoft Excel (OpenXML) files
"application/vnd.ms-powerpoint", // Microsoft PowerPoint files
"application/vnd.openxmlformats-officedocument.presentationml.presentation", // Microsoft PowerPoint (OpenXML)
// files
"application/msword", // Microsoft Word files
"application/vnd.openxmlformats-officedocument.wordprocessingml.document", // Microsoft Word (OpenXML) files
"application/vnd.oasis.opendocument.text", // OpenDocument Text
"application/vnd.oasis.opendocument.spreadsheet", // OpenDocument Spreadsheet
"application/vnd.oasis.opendocument.presentation", // OpenDocument Presentation
"application/x-httpd-php", // PHP files
"application/x-perl", // Perl scripts
"application/x-python", // Python scripts
"application/x-ruby", // Ruby scripts
"application/x-shellscript", // Shell scripts
};
for (const auto& mime : TextMimeTypes) {
QCOMPARE(Tools::toMimeType(mime), Tools::MimeType::PlainText);
}
for (const auto& mime : ImageMimeTypes) {
QCOMPARE(Tools::toMimeType(mime), Tools::MimeType::Image);
}
for (const auto& mime : UnknownMimeTypes) {
QCOMPARE(Tools::toMimeType(mime), Tools::MimeType::Unknown);
}
}

View file

@ -37,6 +37,7 @@ private slots:
void testConvertToRegex();
void testConvertToRegex_data();
void testArrayContainsValues();
void testMimeTypes();
};
#endif // KEEPASSX_TESTTOOLS_H