mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-12-28 00:39:43 -05:00
Add generic DataPath::icon() method.
This commit is contained in:
parent
000be1e5be
commit
539ea5bd44
@ -29,18 +29,28 @@ QString DataPath::path(const QString& name)
|
||||
|
||||
QIcon DataPath::applicationIcon()
|
||||
{
|
||||
QIcon icon = QIcon::fromTheme("keepassx");
|
||||
return icon("apps", "keepassx");
|
||||
}
|
||||
|
||||
QIcon DataPath::icon(const QString& category, const QString& name)
|
||||
{
|
||||
QIcon icon = QIcon::fromTheme(name);
|
||||
|
||||
#if defined(QT_DEBUG) || defined(Q_WS_MAC) || defined(Q_WS_WIN)
|
||||
if (icon.isNull()) {
|
||||
QStringList pngSizes;
|
||||
pngSizes << "16" << "24" << "32" << "48" << "64" << "128";
|
||||
QString filename;
|
||||
Q_FOREACH (const QString& size, pngSizes) {
|
||||
icon.addFile(QString("%1/icons/application/%2x%2/apps/keepassx.png").arg(m_basePath, size));
|
||||
filename = QString("%1/icons/application/%2x%2/%3/%4.png").arg(m_basePath, size, category, name);
|
||||
if (QFile::exists(filename)) {
|
||||
icon.addFile(filename);
|
||||
}
|
||||
}
|
||||
filename = QString("%1/icons/application/scalable/%3/%4.svgz").arg(m_basePath, category, name);
|
||||
if (QFile::exists(filename)) {
|
||||
icon.addFile(filename);
|
||||
}
|
||||
icon.addFile(QString("%1/icons/application/scalable/apps/keepassx.svgz").arg(m_basePath));
|
||||
}
|
||||
#endif
|
||||
|
||||
return icon;
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ class DataPath
|
||||
public:
|
||||
QString path(const QString& name);
|
||||
QIcon applicationIcon();
|
||||
QIcon icon(const QString& category, const QString& name);
|
||||
|
||||
private:
|
||||
DataPath();
|
||||
|
Loading…
Reference in New Issue
Block a user