Merge pull request #2854

a99eef6 always use native directory separators in paths (xiphon)
This commit is contained in:
luigi1111
2020-04-28 15:16:57 -05:00
10 changed files with 35 additions and 42 deletions

View File

@@ -227,7 +227,7 @@ QString Wallet::address(quint32 accountIndex, quint32 addressIndex) const
QString Wallet::path() const
{
return QString::fromStdString(m_walletImpl->path());
return QDir::toNativeSeparators(QString::fromStdString(m_walletImpl->path()));
}
bool Wallet::store(const QString &path)

View File

@@ -210,6 +210,7 @@ int main(int argc, char *argv[])
qCritical() << "Error: accounts root directory could not be set";
return 1;
}
moneroAccountsDir = QDir::toNativeSeparators(moneroAccountsDir);
#if defined(Q_OS_LINUX)
if (isDesktop) app.setWindowIcon(QIcon(":/images/appicon.ico"));
@@ -241,7 +242,7 @@ Verify update binary using 'shasum'-compatible (SHA256 algo) output signed by tw
Monero::Utils::onStartup();
// Log settings
const QString logPath = getLogPath(parser.value(logPathOption));
const QString logPath = QDir::toNativeSeparators(getLogPath(parser.value(logPathOption)));
Monero::Wallet::init(argv[0], "monero-wallet-gui", logPath.toStdString().c_str(), true);
qInstallMessageHandler(messageHandler);

View File

@@ -43,11 +43,20 @@
#include "KeysFiles.h"
WalletKeysFiles::WalletKeysFiles(const qint64 &modified, const QString &path, const quint8 &networkType, const QString &address)
: m_modified(modified), m_path(path), m_networkType(networkType), m_address(address)
WalletKeysFiles::WalletKeysFiles(const QFileInfo &info, quint8 networkType, QString address)
: m_fileName(info.fileName())
, m_modified(info.lastModified().toSecsSinceEpoch())
, m_path(QDir::toNativeSeparators(info.absoluteFilePath()))
, m_networkType(networkType)
, m_address(std::move(address))
{
}
QString WalletKeysFiles::fileName() const
{
return m_fileName;
}
qint64 WalletKeysFiles::modified() const
{
return m_modified;
@@ -127,11 +136,7 @@ void WalletKeysFilesModel::findWallets(const QString &moneroAccountsDir)
file.close();
}
const QFileInfo info(wallet);
const QDateTime modifiedAt = info.lastModified();
this->addWalletKeysFile(WalletKeysFiles(modifiedAt.toSecsSinceEpoch(),
info.absoluteFilePath(), networkType, address));
this->addWalletKeysFile(WalletKeysFiles(wallet, networkType, std::move(address)));
}
}
@@ -152,6 +157,8 @@ QVariant WalletKeysFilesModel::data(const QModelIndex & index, int role) const {
return QVariant();
const WalletKeysFiles &walletKeyFile = m_walletKeyFiles[index.row()];
if (role == FileNameRole)
return walletKeyFile.fileName();
if (role == ModifiedRole)
return walletKeyFile.modified();
else if (role == PathRole)
@@ -165,6 +172,7 @@ QVariant WalletKeysFilesModel::data(const QModelIndex & index, int role) const {
QHash<int, QByteArray> WalletKeysFilesModel::roleNames() const {
QHash<int, QByteArray> roles;
roles[FileNameRole] = "fileName";
roles[ModifiedRole] = "modified";
roles[PathRole] = "path";
roles[NetworkTypeRole] = "networktype";

View File

@@ -37,14 +37,16 @@
class WalletKeysFiles
{
public:
WalletKeysFiles(const qint64 &modified, const QString &path, const quint8 &networkType, const QString &address);
WalletKeysFiles(const QFileInfo &info, quint8 networkType, QString address);
QString fileName() const;
qint64 modified() const;
QString path() const;
quint8 networkType() const;
QString address() const;
private:
QString m_fileName;
qint64 m_modified;
QString m_path;
quint8 m_networkType;
@@ -56,7 +58,8 @@ class WalletKeysFilesModel : public QAbstractListModel
Q_OBJECT
public:
enum KeysFilesRoles {
ModifiedRole = Qt::UserRole + 1,
FileNameRole = Qt::UserRole + 1,
ModifiedRole,
PathRole,
NetworkTypeRole,
AddressRole