mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-10-01 01:26:01 -04:00
Add a dataPath() generater function instead of using static DataPath methods.
This commit is contained in:
parent
5db102d668
commit
bda22394f5
@ -22,23 +22,13 @@
|
||||
|
||||
#include "config-keepassx.h"
|
||||
|
||||
DataPath* DataPath::m_instance(0);
|
||||
|
||||
QString DataPath::getPath(const QString& name)
|
||||
{
|
||||
if (!m_instance) {
|
||||
m_instance = new DataPath();
|
||||
}
|
||||
|
||||
return m_instance->m_basePath + name;
|
||||
return m_basePath + name;
|
||||
}
|
||||
|
||||
QIcon DataPath::applicationIcon()
|
||||
{
|
||||
if (!m_instance) {
|
||||
m_instance = new DataPath();
|
||||
}
|
||||
|
||||
QIcon icon = QIcon::fromTheme("keepassx");
|
||||
|
||||
#if defined(QT_DEBUG) || defined(Q_WS_MAC) || defined(Q_WS_WIN)
|
||||
@ -46,9 +36,9 @@ QIcon DataPath::applicationIcon()
|
||||
QStringList pngSizes;
|
||||
pngSizes << "16" << "24" << "32" << "48" << "64" << "128";
|
||||
Q_FOREACH (const QString& size, pngSizes) {
|
||||
icon.addFile(QString("%1/icons/application/%2x%2/apps/keepassx.png").arg(m_instance->m_basePath, size));
|
||||
icon.addFile(QString("%1/icons/application/%2x%2/apps/keepassx.png").arg(m_basePath, size));
|
||||
}
|
||||
icon.addFile(QString("%1/icons/application/scalable/apps/keepassx.svgz").arg(m_instance->m_basePath));
|
||||
icon.addFile(QString("%1/icons/application/scalable/apps/keepassx.svgz").arg(m_basePath));
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -94,3 +84,14 @@ bool DataPath::testSetDir(const QString& dir)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
DataPath* dataPath()
|
||||
{
|
||||
static DataPath* instance = 0;
|
||||
|
||||
if (!instance) {
|
||||
instance = new DataPath();
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
@ -24,15 +24,18 @@
|
||||
class DataPath
|
||||
{
|
||||
public:
|
||||
static QString getPath(const QString& name);
|
||||
static QIcon applicationIcon();
|
||||
QString getPath(const QString& name);
|
||||
QIcon applicationIcon();
|
||||
|
||||
private:
|
||||
DataPath();
|
||||
bool testSetDir(const QString& dir);
|
||||
|
||||
static DataPath* m_instance;
|
||||
QString m_basePath;
|
||||
|
||||
friend DataPath* dataPath();
|
||||
};
|
||||
|
||||
DataPath* dataPath();
|
||||
|
||||
#endif // KEEPASSX_DATAPATH_H
|
||||
|
@ -31,7 +31,7 @@ QImage DatabaseIcons::icon(int index)
|
||||
}
|
||||
else {
|
||||
QString iconPath = QString("icons/database/").append(m_indexToName.at(index));
|
||||
QImage icon(DataPath::getPath(iconPath));
|
||||
QImage icon(dataPath()->getPath(iconPath));
|
||||
|
||||
m_iconCache[index] = icon;
|
||||
return icon;
|
||||
|
@ -28,7 +28,7 @@ MainWindow::MainWindow()
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
setWindowIcon(DataPath::applicationIcon());
|
||||
setWindowIcon(dataPath()->applicationIcon());
|
||||
|
||||
connect(m_ui->tabWidget, SIGNAL(currentChanged(int)), SLOT(currentTabChanged(int)));
|
||||
connect(m_ui->tabWidget, SIGNAL(entrySelectionChanged(bool)), m_ui->actionEntryEdit, SLOT(setEnabled(bool)));
|
||||
|
Loading…
Reference in New Issue
Block a user