1
mirror of https://github.com/monero-project/monero-gui synced 2024-12-19 04:45:53 +01:00

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
commit 1b7844ec34
No known key found for this signature in database
GPG Key ID: F4ACA0183641E010
10 changed files with 35 additions and 42 deletions

View File

@ -58,11 +58,6 @@ function switchPage(next) {
}
function createWalletPath(isIOS, folder_path,account_name){
// Remove trailing slash - (default on windows and mac)
if (folder_path.substring(folder_path.length -1) === "/"){
folder_path = folder_path.substring(0,folder_path.length -1)
}
// Store releative path on ios.
if(isIOS)
folder_path = "";

View File

@ -215,7 +215,7 @@ ApplicationWindow {
appWindow.viewState = prevState;
}
};
passwordDialog.open(usefulName(walletPath()));
passwordDialog.open(usefulName(persistentSettings.wallet_path));
}
function initialize() {
@ -254,7 +254,7 @@ ApplicationWindow {
simpleModeConnectionTimer.running = true;
// wallet already opened with wizard, we just need to initialize it
var wallet_path = walletPath();
var wallet_path = persistentSettings.wallet_path;
if(isIOS)
wallet_path = moneroAccountsDir + wallet_path;
// console.log("opening wallet at: ", wallet_path, "with password: ", appWindow.walletPassword);
@ -393,11 +393,6 @@ ApplicationWindow {
return !persistentSettings.useRemoteNode || persistentSettings.is_trusted_daemon;
}
function walletPath() {
var wallet_path = persistentSettings.wallet_path
return wallet_path;
}
function usefulName(path) {
// arbitrary "short enough" limit
if (path.length < 32)

View File

@ -131,10 +131,11 @@ Rectangle {
}
MoneroComponents.TextBlock {
id: walletLocation
Layout.fillWidth: true
color: MoneroComponents.Style.dimmedFontColor
font.pixelSize: 14
property string walletPath: (isIOS ? moneroAccountsDir : "") + appWindow.walletPath()
property string walletPath: (isIOS ? moneroAccountsDir : "") + persistentSettings.wallet_path
text: "\
<style type='text/css'>\
a {cursor:pointer;text-decoration: none; color: #FF6C3C}\
@ -389,12 +390,7 @@ Rectangle {
var data = "";
data += "GUI version: " + Version.GUI_VERSION + " (Qt " + qtRuntimeVersion + ")";
data += "\nEmbedded Monero version: " + Version.GUI_MONERO_VERSION;
data += "\nWallet path: ";
var wallet_path = walletPath();
if(isIOS)
wallet_path = moneroAccountsDir + wallet_path;
data += wallet_path;
data += "\nWallet path: " + walletLocation.walletPath;
data += "\nWallet creation height: ";
if(currentWallet)

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

View File

@ -371,7 +371,7 @@ Rectangle {
persistentSettings.locale = wizardController.language_locale
persistentSettings.account_name = wizardController.walletOptionsName
persistentSettings.wallet_path = new_wallet_filename
persistentSettings.wallet_path = wizardController.m_wallet.path;
persistentSettings.restore_height = (isNaN(walletOptionsRestoreHeight))? 0 : walletOptionsRestoreHeight
persistentSettings.allow_background_mining = false

View File

@ -119,7 +119,7 @@ Rectangle {
delegate: Rectangle {
// inherited roles from walletKeysFilesModel:
// index, modified, accessed, path, networktype, address
// index, fileName, modified, accessed, path, networktype, address
id: item
height: flow.itemHeight
width: {
@ -133,11 +133,6 @@ Rectangle {
else if(networktype === 2) return qsTr("Stagenet");
return "";
}
property string fileName: {
var spl = path.split("/");
return spl[spl.length - 1].replace(".keys", "");
}
property string filePath: { return path }
color: "transparent"
Rectangle {
@ -202,9 +197,9 @@ Rectangle {
text: {
// truncate on window width
var maxLength = wizardController.layoutScale <= 1 ? 12 : 16
if(item.fileName.length > maxLength)
return item.fileName.substring(0, maxLength) + "...";
return item.fileName;
if (fileName.length > maxLength)
return fileName.substring(0, maxLength) + "...";
return fileName;
}
Layout.preferredHeight: 26
@ -270,7 +265,7 @@ Rectangle {
onClicked: {
persistentSettings.nettype = parseInt(networktype)
wizardController.openWalletFile(item.filePath);
wizardController.openWalletFile(path);
}
}
}

View File

@ -55,7 +55,7 @@ GridLayout {
function reset() {
walletName.error = !walletName.verify();
walletLocation.error = walletLocation.text === "";
walletLocation.text = moneroAccountsDir + "/";
walletLocation.text = moneroAccountsDir;
walletName.text = defaultAccountName;
}