From 15aea81ea4e80ad2b2006988337dd8659b65d770 Mon Sep 17 00:00:00 2001 From: tobtoht Date: Thu, 26 Jan 2023 16:05:54 +0100 Subject: [PATCH] portable mode: reset wallet dir on start --- src/MainWindow.cpp | 9 +++++++-- src/MainWindow.h | 2 +- src/main.cpp | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index c8cae11..b9e316f 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -1601,9 +1601,14 @@ void MainWindow::donationNag() { config()->set(Config::donateBeg, donationCounter); } -void MainWindow::addToRecentlyOpened(const QString &keysFile) { +void MainWindow::addToRecentlyOpened(QString keysFile) { auto recent = config()->get(Config::recentlyOpenedWallets).toList(); + if (Utils::isPortableMode()) { + QDir appPath{Utils::applicationPath()}; + keysFile = appPath.relativeFilePath(keysFile); + } + if (recent.contains(keysFile)) { recent.removeOne(keysFile); } @@ -1631,7 +1636,7 @@ void MainWindow::updateRecentlyOpenedMenu() { const QStringList recentWallets = config()->get(Config::recentlyOpenedWallets).toStringList(); for (const auto &walletPath : recentWallets) { QFileInfo fileInfo{walletPath}; - ui->menuRecently_open->addAction(fileInfo.fileName(), m_windowManager, std::bind(&WindowManager::tryOpenWallet, m_windowManager, walletPath, "")); + ui->menuRecently_open->addAction(fileInfo.fileName(), m_windowManager, std::bind(&WindowManager::tryOpenWallet, m_windowManager, fileInfo.absoluteFilePath(), "")); } ui->menuRecently_open->addSeparator(); ui->menuRecently_open->addAction(m_clearRecentlyOpenAction); diff --git a/src/MainWindow.h b/src/MainWindow.h index 5525f13..7b1c7dc 100644 --- a/src/MainWindow.h +++ b/src/MainWindow.h @@ -214,7 +214,7 @@ private: QString getHardwareDevice(); void updateTitle(); void donationNag(); - void addToRecentlyOpened(const QString &filename); + void addToRecentlyOpened(QString filename); void updateRecentlyOpenedMenu(); void updateWidgetIcons(); bool verifyPassword(bool sensitive = true); diff --git a/src/main.cpp b/src/main.cpp index ab89fc7..367b3f5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -179,7 +179,7 @@ if (AttachConsole(ATTACH_PARENT_PROCESS)) { // Setup wallet directory QString walletDir = config()->get(Config::walletDirectory).toString(); - if (walletDir.isEmpty()) { + if (walletDir.isEmpty() || Utils::isPortableMode()) { walletDir = Utils::defaultWalletDir(); config()->set(Config::walletDirectory, walletDir); }