diff --git a/CMakeLists.txt b/CMakeLists.txt index b1a1e5c..71096d4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,8 +4,8 @@ project(wowlet) message(STATUS "Initiating compile using CMake ${CMAKE_VERSION}") set(THREADS_PREFER_PTHREAD_FLAG ON) -set(VERSION_MAJOR "0") -set(VERSION_MINOR "2") +set(VERSION_MAJOR "2") +set(VERSION_MINOR "0") set(VERSION_REVISION "0") set(VERSION "beta-2") diff --git a/cmake/config-wowlet.h.cmake b/cmake/config-wowlet.h.cmake index 1790145..cd8681e 100644 --- a/cmake/config-wowlet.h.cmake +++ b/cmake/config-wowlet.h.cmake @@ -3,6 +3,7 @@ #define WOWLET_VERSION "@VERSION@" #define WOWLET_BRANCH "@WOWLET_BRANCH@" +#define WOWLET_VERSION_SEMVER "@VERSION_MAJOR@.@VERSION_MINOR@.@VERSION_REVISION@" #define MONERO_VERSION "@MONERO_VERSION@" #define MONERO_BRANCH "@MONERO_BRANCH@" diff --git a/src/appcontext.cpp b/src/appcontext.cpp index 122e5d9..c185181 100644 --- a/src/appcontext.cpp +++ b/src/appcontext.cpp @@ -6,6 +6,7 @@ #include "appcontext.h" #include "globals.h" +#include "config-wowlet.h" // libwalletqt #include "libwalletqt/TransactionHistory.h" @@ -457,6 +458,13 @@ void AppContext::onWSMessage(const QJsonObject &msg) { auto txFiatHistory_data = msg.value("data").toObject(); AppContext::txFiatHistory->onWSData(txFiatHistory_data); } + else if(cmd == "wowlet_releases") { + versionPending = msg.value("data").toObject(); + auto version_str = versionPending.value("version").toString(); + + if(Utils::versionOutdated(WOWLET_VERSION_SEMVER, version_str)) + emit versionOutdated(version_str, versionPending); + } #if defined(HAS_OPENVR) else if(cmd == "requestPIN") { auto pin = msg.value("data").toString(); diff --git a/src/appcontext.h b/src/appcontext.h index 6419c40..b07444a 100644 --- a/src/appcontext.h +++ b/src/appcontext.h @@ -45,6 +45,7 @@ public: bool isMac = false; bool isWindows = false; bool isDebug = false; + static bool isQML; bool androidDebug = false; // Donation config @@ -105,7 +106,7 @@ public: static QMap txDescriptionCache; static QMap txCache; static TxFiatHistory *txFiatHistory; - static bool isQML; + QJsonObject versionPending; // libwalletqt bool refreshed = false; @@ -219,6 +220,7 @@ signals: void initiateTransaction(); void endTransaction(); void setTitle(const QString &title); // set window title + void versionOutdated(QString version_string, QJsonObject data); private: WalletKeysFilesModel *m_walletKeysFilesModel; diff --git a/src/assets.qrc b/src/assets.qrc index 596a774..da545e3 100644 --- a/src/assets.qrc +++ b/src/assets.qrc @@ -186,6 +186,7 @@ assets/images/seal.png assets/images/seed.png assets/images/speaker.png + assets/images/pls_update.jpg assets/images/status_connected_fork.png assets/images/status_connected.png assets/images/status_connected_proxy_fork.png diff --git a/src/assets/images/pls_update.jpg b/src/assets/images/pls_update.jpg new file mode 100644 index 0000000..be276ab Binary files /dev/null and b/src/assets/images/pls_update.jpg differ diff --git a/src/dialog/updatedialog.cpp b/src/dialog/updatedialog.cpp new file mode 100644 index 0000000..a089aa0 --- /dev/null +++ b/src/dialog/updatedialog.cpp @@ -0,0 +1,44 @@ +// SPDX-License-Identifier: BSD-3-Clause +// Copyright (c) 2020-2021, The Monero Project. + +#include +#include "updatedialog.h" +#include "ui_updatedialog.h" + +#include "config-wowlet.h" + +UpdateDialog::UpdateDialog(AppContext *ctx, QWidget *parent) : + QDialog(parent), + ctx(ctx), + ui(new Ui::UpdateDialog) { + ui->setupUi(this); + this->setWindowIcon(QIcon("://assets/images/appicons/64x64.png")); + + auto version_str = ctx->versionPending.value("version").toString(); + + QPixmap p(":assets/images/pls_update.jpg"); + ui->label_image->setPixmap(p.scaled(320, 320, Qt::KeepAspectRatio, Qt::SmoothTransformation)); + + ui->info_label->setText("Current version: " + QString(WOWLET_VERSION_SEMVER) + "\n" + "New version: " + version_str); + + ui->label_download->setText("Download: git.wownero.com"); + ui->label_download->setTextInteractionFlags(Qt::TextBrowserInteraction); + ui->label_download->setOpenExternalLinks(true); + + // checkbox + connect(ui->checkbox_ignore, &QCheckBox::clicked, this, &UpdateDialog::checkboxIgnoreWarning); + + this->adjustSize(); +} + +void UpdateDialog::checkboxIgnoreWarning(bool checked) { + if(checked) + config()->set(Config::ignoreUpdateWarning, WOWLET_VERSION_SEMVER); + else + config()->set(Config::ignoreUpdateWarning, ""); +} + +UpdateDialog::~UpdateDialog() { + delete ui; +} diff --git a/src/dialog/updatedialog.h b/src/dialog/updatedialog.h new file mode 100644 index 0000000..9ec1725 --- /dev/null +++ b/src/dialog/updatedialog.h @@ -0,0 +1,31 @@ +// SPDX-License-Identifier: BSD-3-Clause +// Copyright (c) 2020-2021, The Monero Project. + +#ifndef WOWLET_UPDATEDIALOG_H +#define WOWLET_UPDATEDIALOG_H + +#include +#include "appcontext.h" + +namespace Ui { + class UpdateDialog; +} + +class UpdateDialog : public QDialog +{ +Q_OBJECT + +public: + explicit UpdateDialog(AppContext *ctx, QWidget *parent = nullptr); + ~UpdateDialog() override; + +private slots: + void checkboxIgnoreWarning(bool checked); + +private: + AppContext *ctx = nullptr; + Ui::UpdateDialog *ui; +}; + + +#endif //WOWLET_UPDATEDIALOG_H diff --git a/src/dialog/updatedialog.ui b/src/dialog/updatedialog.ui new file mode 100644 index 0000000..efccab4 --- /dev/null +++ b/src/dialog/updatedialog.ui @@ -0,0 +1,108 @@ + + + UpdateDialog + + + + 0 + 0 + 349 + 189 + + + + Pls update + + + + + + image + + + + + + + info_label + + + + + + + download_label + + + Qt::RichText + + + + + + + Ignore for now + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Ok + + + + + + + + + buttonBox + accepted() + UpdateDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + UpdateDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index b09b812..110b78e 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -19,11 +19,13 @@ #include "dialog/viewonlydialog.h" #include "dialog/broadcasttxdialog.h" #include "dialog/tximportdialog.h" +#include "dialog/updatedialog.h" #include "dialog/passworddialog.h" #include "dialog/balancedialog.h" #include "dialog/WalletCacheDebugDialog.h" #include "ui_mainwindow.h" #include "globals.h" +#include "config-wowlet.h" #include "utils/ColorScheme.h" // libwalletqt @@ -39,6 +41,8 @@ MainWindow::MainWindow(AppContext *ctx, QWidget *parent) : pMainWindow = this; ui->setupUi(this); + ui->label_outdated->setVisible(false); + m_windowSettings = new Settings(this); m_aboutDialog = new AboutDialog(this); m_windowCalc = new CalcWindow(this); @@ -337,6 +341,9 @@ MainWindow::MainWindow(AppContext *ctx, QWidget *parent) : // window title connect(m_ctx, &AppContext::setTitle, this, &QMainWindow::setWindowTitle); + // Version warning + connect(m_ctx, &AppContext::versionOutdated, this, &MainWindow::onVersionWarning); + // init touchbar #ifdef Q_OS_MAC m_touchbar = new KDMacTouchBar(this); @@ -428,6 +435,7 @@ void MainWindow::initMenu() { connect(ui->actionSeed, &QAction::triggered, this, &MainWindow::showSeedDialog); connect(ui->actionPassword, &QAction::triggered, this, &MainWindow::showPasswordDialog); connect(ui->actionKeys, &QAction::triggered, this, &MainWindow::showKeysDialog); + connect(this, &MainWindow::updateDialog, this, &MainWindow::showUpdateDialog); connect(ui->actionViewOnly, &QAction::triggered, this, &MainWindow::showViewOnlyDialog); connect(ui->actionStore_wallet, &QAction::triggered, [this]{ m_ctx->currentWallet->store(); @@ -632,6 +640,8 @@ void MainWindow::onWalletOpened(Wallet *wallet) { this->updatePasswordIcon(); m_updateBytes.start(100); + + if(m_showUpdateWarning == 1) emit updateDialog(); } void MainWindow::onBalanceUpdated(quint64 balance, quint64 spendable) { @@ -886,6 +896,12 @@ void MainWindow::updatePasswordIcon() { m_statusBtnPassword->setIcon(icon); } +void MainWindow::onVersionWarning(QString current_string, QJsonObject version_data) { + if(m_showUpdateWarning != -1) + m_showUpdateWarning = 1; + ui->label_outdated->setVisible(true); +} + void MainWindow::showRestoreHeightDialog() { // settings custom restore height is only available for 25 word seeds auto seed = m_ctx->currentWallet->getCacheAttribute("wowlet.seed"); @@ -911,6 +927,17 @@ void MainWindow::showRestoreHeightDialog() { }); } +void MainWindow::showUpdateDialog() { + if(config()->get(Config::ignoreUpdateWarning).toString() == WOWLET_VERSION_SEMVER) { + m_showUpdateWarning = -1; + return; + } + + auto *dialog = new UpdateDialog(m_ctx, this); + dialog->show(); + m_showUpdateWarning = -1; +} + void MainWindow::showKeysDialog() { auto *dialog = new KeysDialog(m_ctx, this); dialog->exec(); diff --git a/src/mainwindow.h b/src/mainwindow.h index 62e33e0..3e22fac 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -38,6 +38,7 @@ #include "dialog/verifyproofdialog.h" #include "dialog/seeddialog.h" #include "dialog/passwordchangedialog.h" +#include "dialog/updatedialog.h" #include "dialog/keysdialog.h" #include "dialog/aboutdialog.h" #include "dialog/restoredialog.h" @@ -115,6 +116,7 @@ public slots: void showSendScreen(const CCSEntry &entry); void suchDonate(const QString address); void skinChanged(const QString &skinName); + void onVersionWarning(QString current_string, QJsonObject data); void menuTorClicked(); void onBlockchainSync(int height, int target); void onRefreshSync(int height, int target); @@ -158,6 +160,7 @@ public slots: void onUpdateXMRWidget(); signals: + void updateDialog(); void closed(); private: @@ -173,6 +176,7 @@ private: void saveGeo(); void restoreGeo(); void showDebugInfo(); + void showUpdateDialog(); void showNodeExhaustedMessage(); void showWSNodeExhaustedMessage(); void createUnsignedTxDialog(UnsignedTransaction *tx); @@ -236,6 +240,7 @@ private: bool m_constructingTransaction = false; bool m_statusOverrideActive = false; QTimer m_txTimer; + int m_showUpdateWarning = 0; private slots: void menuToggleTabVisible(const QString &key); diff --git a/src/mainwindow.ui b/src/mainwindow.ui index 20d9d21..574c282 100644 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -7,7 +7,7 @@ 0 0 1156 - 502 + 506 @@ -86,6 +86,13 @@ + + + + Warning: outdated wowlet version + + + diff --git a/src/utils/config.cpp b/src/utils/config.cpp index 0aff663..c58cdd7 100644 --- a/src/utils/config.cpp +++ b/src/utils/config.cpp @@ -48,6 +48,7 @@ static const QHash configStrings = { {Config::hideBalance, {QS("hideBalance"), false}}, {Config::hideFiatBalance, {QS("hideFiatBalance"), false}}, {Config::redditFrontend, {QS("redditFrontend"), "old.reddit.com"}}, + {Config::ignoreUpdateWarning, {QS("ignoreUpdateWarning"), ""}}, {Config::showHistorySyncNotice, {QS("showHistorySyncNotice"), true}} }; diff --git a/src/utils/config.h b/src/utils/config.h index d5df478..639baab 100644 --- a/src/utils/config.h +++ b/src/utils/config.h @@ -50,7 +50,8 @@ public: hideBalance, hideFiatBalance, redditFrontend, - showHistorySyncNotice + showHistorySyncNotice, + ignoreUpdateWarning }; ~Config() override; diff --git a/src/utils/utils.cpp b/src/utils/utils.cpp index ca9aee9..80adea7 100644 --- a/src/utils/utils.cpp +++ b/src/utils/utils.cpp @@ -434,6 +434,16 @@ int Utils::maxLength(const QVector &array) { return maxLength; } +bool Utils::versionOutdated(const QString ¤t_version, const QString &newest_version) { + // True when major or minor version changed + auto cver = current_version.split('.'); + auto nver = newest_version.split('.'); + int cverlist[] = {cver.at(0).toInt(), cver.at(1).toInt()}; + int nverlist[] = {nver.at(0).toInt(), nver.at(1).toInt()}; + if(cverlist[0] < nverlist[0] || cverlist[1] < nverlist[1]) return true; + return false; +} + QString Utils::balanceFormat(quint64 balance) { QString str = QString::number(balance / globals::cdiv, 'f', 4); diff --git a/src/utils/utils.h b/src/utils/utils.h index 444e6f8..a156213 100644 --- a/src/utils/utils.h +++ b/src/utils/utils.h @@ -81,6 +81,7 @@ public: static QMap localeCache; static QString balanceFormat(quint64 balance); static QTextCharFormat addressTextFormat(const SubaddressIndex &index); + static bool versionOutdated(const QString ¤t_version, const QString &newest_version); template static QString QtEnumToString (const QEnum value) {