mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-08-02 11:36:18 -04:00

* Renamed NewEntryAttachmentsDialog to EditEntryAttachmentsDialog for clarity. * Introduced EditEntryAttachmentsDialog class to manage editing of existing attachments. * Added functionality to preview attachments while editing them. * Enhanced EntryAttachmentsModel with rowByKey method for better key management. * Add image attachment support with zoom functionality. * Add html and markdown detection. * Improve button layout on the attachment section when editing an entry
40 lines
1.3 KiB
C++
40 lines
1.3 KiB
C++
#include "TestTextAttachmentsPreviewWidget.h"
|
|
|
|
#include <attachments/TextAttachmentsPreviewWidget.h>
|
|
|
|
#include <QComboBox>
|
|
#include <QTest>
|
|
|
|
void TestTextAttachmentsPreviewWidget::initTestCase()
|
|
{
|
|
m_widget.reset(new TextAttachmentsPreviewWidget());
|
|
}
|
|
|
|
void TestTextAttachmentsPreviewWidget::testDetectMimeByFile()
|
|
{
|
|
const auto combobox = m_widget->findChild<QComboBox*>("typeComboBox");
|
|
QVERIFY(combobox);
|
|
|
|
const attachments::Attachment Text{.name = "test.txt", .data = {}};
|
|
m_widget->openAttachment(Text, attachments::OpenMode::ReadOnly);
|
|
|
|
QCoreApplication::processEvents();
|
|
|
|
QCOMPARE(combobox->currentData().toInt(), TextAttachmentsPreviewWidget::PlainText);
|
|
|
|
const attachments::Attachment Html{.name = "test.html", .data = {}};
|
|
m_widget->openAttachment(Html, attachments::OpenMode::ReadOnly);
|
|
|
|
QCoreApplication::processEvents();
|
|
|
|
QCOMPARE(combobox->currentData().toInt(), TextAttachmentsPreviewWidget::Html);
|
|
|
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
|
|
const attachments::Attachment Markdown{.name = "test.md", .data = {}};
|
|
m_widget->openAttachment(Markdown, attachments::OpenMode::ReadOnly);
|
|
|
|
QCoreApplication::processEvents();
|
|
|
|
QCOMPARE(combobox->currentData().toInt(), TextAttachmentsPreviewWidget::Markdown);
|
|
#endif
|
|
}
|