diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b73cea6..0235fb3 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -295,7 +295,7 @@ if(STATIC AND NOT Qt6_FOUND) endif() endif() -if(STATIC AND UNIX AND Qt6_FOUND) +if(STATIC AND UNIX AND NOT APPLE AND Qt6_FOUND) target_link_libraries(feather Qt6::QComposePlatformInputContextPlugin) endif() diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index 8dc8119..64c9dfa 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -364,9 +364,6 @@ void MainWindow::initMenu() { #else ui->actionCheckForUpdates->setVisible(false); #endif -#if defined(Q_OS_MACOS) - ui->actionCheckForUpdates->setVisible(false); -#endif connect(ui->actionOfficialWebsite, &QAction::triggered, [this](){Utils::externalLinkWarning(this, "https://featherwallet.org");}); connect(ui->actionDonate_to_Feather, &QAction::triggered, this, &MainWindow::donateButtonClicked); diff --git a/src/dialog/UpdateDialog.cpp b/src/dialog/UpdateDialog.cpp index 076c1a5..e51bbae 100644 --- a/src/dialog/UpdateDialog.cpp +++ b/src/dialog/UpdateDialog.cpp @@ -12,6 +12,7 @@ #include "utils/NetworkManager.h" #include "utils/Updater.h" #include "utils/Utils.h" +#include "utils/SemanticVersion.h" #include "zip.h" @@ -251,17 +252,33 @@ void UpdateDialog::installUpdateMac() { QString appPath = Utils::applicationPath(); QDir appDir(appPath); if (appPath.endsWith("Contents/MacOS")) { - appDir.cd("../../.."); + appDir.cd("../.."); } + + if (appPath.contains("AppTranslocation")) { + this->onInstallError("Error: Application is translocated. Please move it to the Applications folder and try again."); + return; + } + + if (!SemanticVersion::isValid(SemanticVersion::fromString(m_updater->version))) { + this->onInstallError(QString("Error: Invalid version: %1").arg(m_updater->version)); + return; + } + QString appName = QString("feather-%1").arg(m_updater->version); QString zipName = QString("%1.zip").arg(appName); - QString fPath = appDir.filePath(zipName); + QString downloadsPath = QStandardPaths::writableLocation(QStandardPaths::DownloadLocation); + if (downloadsPath.isEmpty()) { + this->onInstallError(QString("Error: Could not determine download location")); + return; + } + + QString fPath = QString("%1/%2").arg(downloadsPath, zipName); QFile file(fPath); qDebug() << "Writing zip file to " << fPath; - if (!file.open(QIODevice::WriteOnly)) - { - this->onInstallError(QString("Error: Could not write to application path: %1").arg(fPath)); + if (!file.open(QIODevice::WriteOnly)) { + this->onInstallError(QString("Error: Could not write to download location: %1").arg(fPath)); return; } @@ -271,14 +288,20 @@ void UpdateDialog::installUpdateMac() { } QProcess unzip; - unzip.start("/usr/bin/unzip", {"-n", fPath, "-d", appDir.path()}); + unzip.start("/usr/bin/unzip", {"-o", fPath, "-d", appDir.absolutePath()}); unzip.waitForFinished(); - m_updatePath = QString("%1.app/Contents/MacOS/feather").arg(appDir.filePath(appName)); + if (unzip.exitStatus() != QProcess::NormalExit) { + this->onInstallError(QString("Error: Unable to extract: %1").arg(fPath)); + return; + } + + m_updatePath = QString("%1/Contents/MacOS/feather").arg(appDir.absolutePath()); + qDebug() << "Update path: " << m_updatePath; file.remove(); - this->setStatus("Installation successful. Do you want to restart Feather now?"); + this->setStatus(QString("Installation successful: Do you want to restart Feather now?").arg(m_updatePath)); ui->btn_restart->show(); }