mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-08-05 04:54:20 -04:00
Refactor attachment handling system with enhanced UI (#12085)
* 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
This commit is contained in:
parent
c4b4be48a5
commit
f2a4cc7e66
54 changed files with 3254 additions and 388 deletions
76
tests/gui/attachments/TestImageAttachmentsView.cpp
Normal file
76
tests/gui/attachments/TestImageAttachmentsView.cpp
Normal file
|
@ -0,0 +1,76 @@
|
|||
#include "TestImageAttachmentsView.h"
|
||||
|
||||
#include <attachments/ImageAttachmentsView.h>
|
||||
|
||||
#include <QBuffer>
|
||||
#include <QPixmap>
|
||||
#include <QSignalSpy>
|
||||
#include <QTest>
|
||||
#include <QWheelEvent>
|
||||
|
||||
void TestImageAttachmentsView::initTestCase()
|
||||
{
|
||||
m_view.reset(new ImageAttachmentsView());
|
||||
|
||||
// Generate the black rectange.
|
||||
QImage image(1000, 1000, QImage::Format_RGB32);
|
||||
image.fill(Qt::black);
|
||||
|
||||
auto scene = new QGraphicsScene();
|
||||
scene->addPixmap(QPixmap::fromImage(image));
|
||||
|
||||
m_view->setScene(scene);
|
||||
m_view->show();
|
||||
|
||||
QCoreApplication::processEvents();
|
||||
}
|
||||
|
||||
void TestImageAttachmentsView::testEmitWheelEvent()
|
||||
{
|
||||
QSignalSpy ctrlWheelEvent{m_view.data(), &ImageAttachmentsView::ctrlWheelEvent};
|
||||
|
||||
QPoint center = m_view->rect().center();
|
||||
|
||||
m_view->setFocus();
|
||||
|
||||
QWheelEvent event(center, // local pos
|
||||
m_view->mapToGlobal(center), // global pos
|
||||
QPoint(0, 0),
|
||||
QPoint(0, 120),
|
||||
Qt::NoButton,
|
||||
Qt::ControlModifier,
|
||||
Qt::ScrollBegin,
|
||||
false);
|
||||
|
||||
QCoreApplication::sendEvent(m_view->viewport(), &event);
|
||||
|
||||
QCOMPARE(ctrlWheelEvent.count(), 1);
|
||||
}
|
||||
|
||||
void TestImageAttachmentsView::testEnableFit()
|
||||
{
|
||||
m_view->enableAutoFitInView();
|
||||
QVERIFY(m_view->isAutoFitInViewActivated());
|
||||
|
||||
const auto oldTransform = m_view->transform();
|
||||
|
||||
m_view->resize(m_view->size() + QSize(100, 100));
|
||||
|
||||
QCoreApplication::processEvents();
|
||||
|
||||
QVERIFY(m_view->transform() != oldTransform);
|
||||
}
|
||||
|
||||
void TestImageAttachmentsView::testDisableFit()
|
||||
{
|
||||
m_view->disableAutoFitInView();
|
||||
QVERIFY(!m_view->isAutoFitInViewActivated());
|
||||
|
||||
const auto expectedTransform = m_view->transform();
|
||||
|
||||
m_view->resize(m_view->size() + QSize(100, 100));
|
||||
|
||||
QCoreApplication::processEvents();
|
||||
|
||||
QCOMPARE(m_view->transform(), expectedTransform);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue