mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-01-11 15:29:51 -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 <QMimeData>
|
||||||
#include <QPalette>
|
#include <QPalette>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
|
#include <QPainter>
|
||||||
|
|
||||||
#include "core/DatabaseIcons.h"
|
#include "core/DatabaseIcons.h"
|
||||||
#include "core/Entry.h"
|
#include "core/Entry.h"
|
||||||
#include "core/Global.h"
|
#include "core/Global.h"
|
||||||
#include "core/Group.h"
|
#include "core/Group.h"
|
||||||
#include "core/Metadata.h"
|
#include "core/Metadata.h"
|
||||||
|
#include "core/FilePath.h"
|
||||||
|
|
||||||
// String being displayed when hiding content
|
// String being displayed when hiding content
|
||||||
const QString EntryModel::HiddenContentDisplay(QString("\u25cf").repeated(6));
|
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
|
// Format used to display dates
|
||||||
const Qt::DateFormat EntryModel::DateFormat = Qt::DefaultLocaleShortDate;
|
const Qt::DateFormat EntryModel::DateFormat = Qt::DefaultLocaleShortDate;
|
||||||
|
|
||||||
// Paperclip symbol
|
|
||||||
const QString EntryModel::PaperClipDisplay("\U0001f4ce");
|
|
||||||
|
|
||||||
EntryModel::EntryModel(QObject* parent)
|
EntryModel::EntryModel(QObject* parent)
|
||||||
: QAbstractTableModel(parent)
|
: QAbstractTableModel(parent)
|
||||||
, m_group(nullptr)
|
, m_group(nullptr)
|
||||||
, m_hideUsernames(false)
|
, m_hideUsernames(false)
|
||||||
, m_hidePasswords(true)
|
, 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
|
Entry* EntryModel::entryFromIndex(const QModelIndex& index) const
|
||||||
@ -205,9 +209,6 @@ QVariant EntryModel::data(const QModelIndex& index, int role) const
|
|||||||
case Accessed:
|
case Accessed:
|
||||||
result = entry->timeInfo().lastAccessTime().toLocalTime().toString(EntryModel::DateFormat);
|
result = entry->timeInfo().lastAccessTime().toLocalTime().toString(EntryModel::DateFormat);
|
||||||
return result;
|
return result;
|
||||||
case Paperclip:
|
|
||||||
result = entry->attachments()->keys().isEmpty() ? QString() : EntryModel::PaperClipDisplay;
|
|
||||||
return result;
|
|
||||||
case Attachments:
|
case Attachments:
|
||||||
// Display comma-separated list of attachments
|
// Display comma-separated list of attachments
|
||||||
QList<QString> attachments = entry->attachments()->keys();
|
QList<QString> attachments = entry->attachments()->keys();
|
||||||
@ -238,7 +239,7 @@ QVariant EntryModel::data(const QModelIndex& index, int role) const
|
|||||||
case Paperclip:
|
case Paperclip:
|
||||||
// Display entries with attachments above those without when
|
// Display entries with attachments above those without when
|
||||||
// sorting ascendingly (and vice versa when sorting descendingly)
|
// sorting ascendingly (and vice versa when sorting descendingly)
|
||||||
return entry->attachments()->keys().isEmpty() ? 1 : 0;
|
return entry->attachments()->isEmpty() ? 1 : 0;
|
||||||
default:
|
default:
|
||||||
// For all other columns, simply use data provided by Qt::Display-
|
// For all other columns, simply use data provided by Qt::Display-
|
||||||
// Role for sorting
|
// Role for sorting
|
||||||
@ -257,6 +258,10 @@ QVariant EntryModel::data(const QModelIndex& index, int role) const
|
|||||||
} else {
|
} else {
|
||||||
return entry->iconScaledPixmap();
|
return entry->iconScaledPixmap();
|
||||||
}
|
}
|
||||||
|
case Paperclip:
|
||||||
|
if (!entry->attachments()->isEmpty()) {
|
||||||
|
return m_paperClipPixmapCentered;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (role == Qt::FontRole) {
|
} else if (role == Qt::FontRole) {
|
||||||
QFont font;
|
QFont font;
|
||||||
@ -279,12 +284,6 @@ QVariant EntryModel::data(const QModelIndex& index, int role) const
|
|||||||
if (index.column() == Paperclip) {
|
if (index.column() == Paperclip) {
|
||||||
return Qt::AlignCenter;
|
return Qt::AlignCenter;
|
||||||
}
|
}
|
||||||
} else if (role == Qt::SizeHintRole) {
|
|
||||||
if (index.column() == Paperclip) {
|
|
||||||
QFont font;
|
|
||||||
QFontMetrics fm(font);
|
|
||||||
return fm.width(PaperClipDisplay) / 2;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return QVariant();
|
return QVariant();
|
||||||
@ -316,15 +315,12 @@ QVariant EntryModel::headerData(int section, Qt::Orientation orientation, int ro
|
|||||||
return tr("Modified");
|
return tr("Modified");
|
||||||
case Accessed:
|
case Accessed:
|
||||||
return tr("Accessed");
|
return tr("Accessed");
|
||||||
case Paperclip:
|
|
||||||
return EntryModel::PaperClipDisplay;
|
|
||||||
case Attachments:
|
case Attachments:
|
||||||
return tr("Attachments");
|
return tr("Attachments");
|
||||||
}
|
}
|
||||||
} else if (role == Qt::TextAlignmentRole) {
|
} else if (role == Qt::DecorationRole) {
|
||||||
switch (section) {
|
if (section == Paperclip) {
|
||||||
case Paperclip:
|
return m_paperClipPixmap;
|
||||||
return Qt::AlignCenter;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
#define KEEPASSX_ENTRYMODEL_H
|
#define KEEPASSX_ENTRYMODEL_H
|
||||||
|
|
||||||
#include <QAbstractTableModel>
|
#include <QAbstractTableModel>
|
||||||
|
#include <QPixmap>
|
||||||
|
|
||||||
class Entry;
|
class Entry;
|
||||||
class Group;
|
class Group;
|
||||||
@ -95,9 +96,11 @@ private:
|
|||||||
bool m_hideUsernames;
|
bool m_hideUsernames;
|
||||||
bool m_hidePasswords;
|
bool m_hidePasswords;
|
||||||
|
|
||||||
|
QPixmap m_paperClipPixmap;
|
||||||
|
QPixmap m_paperClipPixmapCentered;
|
||||||
|
|
||||||
static const QString HiddenContentDisplay;
|
static const QString HiddenContentDisplay;
|
||||||
static const Qt::DateFormat DateFormat;
|
static const Qt::DateFormat DateFormat;
|
||||||
static const QString PaperClipDisplay;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // KEEPASSX_ENTRYMODEL_H
|
#endif // KEEPASSX_ENTRYMODEL_H
|
||||||
|
@ -72,6 +72,10 @@ EntryView::EntryView(QWidget* parent)
|
|||||||
m_columnActions->setExclusive(false);
|
m_columnActions->setExclusive(false);
|
||||||
for (int columnIndex = 1; columnIndex < header()->count(); ++columnIndex) {
|
for (int columnIndex = 1; columnIndex < header()->count(); ++columnIndex) {
|
||||||
QString caption = m_model->headerData(columnIndex, Qt::Horizontal, Qt::DisplayRole).toString();
|
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);
|
QAction* action = m_headerMenu->addAction(caption);
|
||||||
action->setCheckable(true);
|
action->setCheckable(true);
|
||||||
action->setData(columnIndex);
|
action->setData(columnIndex);
|
||||||
|
Loading…
Reference in New Issue
Block a user