mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-12-23 22:39:43 -05:00
Convert from unicode to image based paperclip
This commit is contained in:
parent
8c4df37062
commit
fd71b4a22e
BIN
share/icons/application/16x16/actions/paperclip.png
Normal file
BIN
share/icons/application/16x16/actions/paperclip.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 352 B |
BIN
share/icons/application/22x22/actions/paperclip.png
Normal file
BIN
share/icons/application/22x22/actions/paperclip.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 421 B |
BIN
share/icons/application/32x32/actions/paperclip.png
Normal file
BIN
share/icons/application/32x32/actions/paperclip.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 559 B |
BIN
share/icons/svg/paperclip.svgz
Normal file
BIN
share/icons/svg/paperclip.svgz
Normal file
Binary file not shown.
@ -22,12 +22,14 @@
|
||||
#include <QMimeData>
|
||||
#include <QPalette>
|
||||
#include <QDateTime>
|
||||
#include <QPainter>
|
||||
|
||||
#include "core/DatabaseIcons.h"
|
||||
#include "core/Entry.h"
|
||||
#include "core/Global.h"
|
||||
#include "core/Group.h"
|
||||
#include "core/Metadata.h"
|
||||
#include "core/FilePath.h"
|
||||
|
||||
// String being displayed when hiding content
|
||||
const QString EntryModel::HiddenContentDisplay(QString("\u25cf").repeated(6));
|
||||
@ -35,15 +37,17 @@ const QString EntryModel::HiddenContentDisplay(QString("\u25cf").repeated(6));
|
||||
// Format used to display dates
|
||||
const Qt::DateFormat EntryModel::DateFormat = Qt::DefaultLocaleShortDate;
|
||||
|
||||
// Paperclip symbol
|
||||
const QString EntryModel::PaperClipDisplay("\U0001f4ce");
|
||||
|
||||
EntryModel::EntryModel(QObject* parent)
|
||||
: QAbstractTableModel(parent)
|
||||
, m_group(nullptr)
|
||||
, m_hideUsernames(false)
|
||||
, m_hidePasswords(true)
|
||||
, m_paperClipPixmap(FilePath::instance()->icon("actions", "paperclip").pixmap(16))
|
||||
, m_paperClipPixmapCentered(24, 16)
|
||||
{
|
||||
m_paperClipPixmapCentered.fill(Qt::transparent);
|
||||
QPainter painter(&m_paperClipPixmapCentered);
|
||||
painter.drawPixmap(8, 0, m_paperClipPixmap);
|
||||
}
|
||||
|
||||
Entry* EntryModel::entryFromIndex(const QModelIndex& index) const
|
||||
@ -205,9 +209,6 @@ QVariant EntryModel::data(const QModelIndex& index, int role) const
|
||||
case Accessed:
|
||||
result = entry->timeInfo().lastAccessTime().toLocalTime().toString(EntryModel::DateFormat);
|
||||
return result;
|
||||
case Paperclip:
|
||||
result = entry->attachments()->keys().isEmpty() ? QString() : EntryModel::PaperClipDisplay;
|
||||
return result;
|
||||
case Attachments:
|
||||
// Display comma-separated list of attachments
|
||||
QList<QString> attachments = entry->attachments()->keys();
|
||||
@ -238,7 +239,7 @@ QVariant EntryModel::data(const QModelIndex& index, int role) const
|
||||
case Paperclip:
|
||||
// Display entries with attachments above those without when
|
||||
// sorting ascendingly (and vice versa when sorting descendingly)
|
||||
return entry->attachments()->keys().isEmpty() ? 1 : 0;
|
||||
return entry->attachments()->isEmpty() ? 1 : 0;
|
||||
default:
|
||||
// For all other columns, simply use data provided by Qt::Display-
|
||||
// Role for sorting
|
||||
@ -257,6 +258,10 @@ QVariant EntryModel::data(const QModelIndex& index, int role) const
|
||||
} else {
|
||||
return entry->iconScaledPixmap();
|
||||
}
|
||||
case Paperclip:
|
||||
if (!entry->attachments()->isEmpty()) {
|
||||
return m_paperClipPixmapCentered;
|
||||
}
|
||||
}
|
||||
} else if (role == Qt::FontRole) {
|
||||
QFont font;
|
||||
@ -279,12 +284,6 @@ QVariant EntryModel::data(const QModelIndex& index, int role) const
|
||||
if (index.column() == Paperclip) {
|
||||
return Qt::AlignCenter;
|
||||
}
|
||||
} else if (role == Qt::SizeHintRole) {
|
||||
if (index.column() == Paperclip) {
|
||||
QFont font;
|
||||
QFontMetrics fm(font);
|
||||
return fm.width(PaperClipDisplay) / 2;
|
||||
}
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
@ -316,15 +315,12 @@ QVariant EntryModel::headerData(int section, Qt::Orientation orientation, int ro
|
||||
return tr("Modified");
|
||||
case Accessed:
|
||||
return tr("Accessed");
|
||||
case Paperclip:
|
||||
return EntryModel::PaperClipDisplay;
|
||||
case Attachments:
|
||||
return tr("Attachments");
|
||||
}
|
||||
} else if (role == Qt::TextAlignmentRole) {
|
||||
switch (section) {
|
||||
case Paperclip:
|
||||
return Qt::AlignCenter;
|
||||
} else if (role == Qt::DecorationRole) {
|
||||
if (section == Paperclip) {
|
||||
return m_paperClipPixmap;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,6 +19,7 @@
|
||||
#define KEEPASSX_ENTRYMODEL_H
|
||||
|
||||
#include <QAbstractTableModel>
|
||||
#include <QPixmap>
|
||||
|
||||
class Entry;
|
||||
class Group;
|
||||
@ -95,9 +96,11 @@ private:
|
||||
bool m_hideUsernames;
|
||||
bool m_hidePasswords;
|
||||
|
||||
QPixmap m_paperClipPixmap;
|
||||
QPixmap m_paperClipPixmapCentered;
|
||||
|
||||
static const QString HiddenContentDisplay;
|
||||
static const Qt::DateFormat DateFormat;
|
||||
static const QString PaperClipDisplay;
|
||||
};
|
||||
|
||||
#endif // KEEPASSX_ENTRYMODEL_H
|
||||
|
@ -72,6 +72,10 @@ EntryView::EntryView(QWidget* parent)
|
||||
m_columnActions->setExclusive(false);
|
||||
for (int columnIndex = 1; columnIndex < header()->count(); ++columnIndex) {
|
||||
QString caption = m_model->headerData(columnIndex, Qt::Horizontal, Qt::DisplayRole).toString();
|
||||
if (columnIndex == EntryModel::Paperclip) {
|
||||
caption = tr("Attachments (icon)");
|
||||
}
|
||||
|
||||
QAction* action = m_headerMenu->addAction(caption);
|
||||
action->setCheckable(true);
|
||||
action->setData(columnIndex);
|
||||
|
Loading…
Reference in New Issue
Block a user