Browse Source

Merge pull request 'Warn when there is a new version available' (#70) from dsc/wowlet:warn-on-outdated-version into master

Reviewed-on: #70
pull/71/head
wowario 3 months ago
parent
commit
0d502f0e45
  1. 4
      CMakeLists.txt
  2. 1
      cmake/config-wowlet.h.cmake
  3. 8
      src/appcontext.cpp
  4. 4
      src/appcontext.h
  5. 1
      src/assets.qrc
  6. BIN
      src/assets/images/pls_update.jpg
  7. 44
      src/dialog/updatedialog.cpp
  8. 31
      src/dialog/updatedialog.h
  9. 108
      src/dialog/updatedialog.ui
  10. 27
      src/mainwindow.cpp
  11. 5
      src/mainwindow.h
  12. 9
      src/mainwindow.ui
  13. 1
      src/utils/config.cpp
  14. 3
      src/utils/config.h
  15. 10
      src/utils/utils.cpp
  16. 1
      src/utils/utils.h

4
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")

1
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@"

8
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();

4
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<QString, QString> txDescriptionCache;
static QMap<QString, QString> 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;

1
src/assets.qrc

@ -186,6 +186,7 @@
<file>assets/images/seal.png</file>
<file>assets/images/seed.png</file>
<file>assets/images/speaker.png</file>
<file>assets/images/pls_update.jpg</file>
<file>assets/images/status_connected_fork.png</file>
<file>assets/images/status_connected.png</file>
<file>assets/images/status_connected_proxy_fork.png</file>

BIN
src/assets/images/pls_update.jpg

After

Width: 320  |  Height: 320  |  Size: 30 KiB

44
src/dialog/updatedialog.cpp

@ -0,0 +1,44 @@
// SPDX-License-Identifier: BSD-3-Clause
// Copyright (c) 2020-2021, The Monero Project.
#include <QObject>
#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: <a href=\"https://git.wownero.com/wowlet/wowlet/releases\">git.wownero.com</a>");
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;
}

31
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 <QDialog>
#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

108
src/dialog/updatedialog.ui

@ -0,0 +1,108 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>UpdateDialog</class>
<widget class="QDialog" name="UpdateDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>349</width>
<height>189</height>
</rect>
</property>
<property name="windowTitle">
<string>Pls update</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label_image">
<property name="text">
<string>image</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="info_label">
<property name="text">
<string>info_label</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_download">
<property name="text">
<string>download_label</string>
</property>
<property name="textFormat">
<enum>Qt::RichText</enum>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkbox_ignore">
<property name="text">
<string>Ignore for now</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>UpdateDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>UpdateDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

27
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();

5
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);

9
src/mainwindow.ui

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>1156</width>
<height>502</height>
<height>506</height>
</rect>
</property>
<property name="sizePolicy">
@ -86,6 +86,13 @@
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="label_outdated">
<property name="text">
<string>Warning: outdated wowlet version</string>
</property>
</widget>
</item>
<item>
<widget class="Line" name="line">
<property name="orientation">

1
src/utils/config.cpp

@ -48,6 +48,7 @@ static const QHash<Config::ConfigKey, ConfigDirective> 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}}
};

3
src/utils/config.h

@ -50,7 +50,8 @@ public:
hideBalance,
hideFiatBalance,
redditFrontend,
showHistorySyncNotice
showHistorySyncNotice,
ignoreUpdateWarning
};
~Config() override;

10
src/utils/utils.cpp

@ -434,6 +434,16 @@ int Utils::maxLength(const QVector<QString> &array) {
return maxLength;
}
bool Utils::versionOutdated(const QString &current_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);

1
src/utils/utils.h

@ -81,6 +81,7 @@ public:
static QMap<QString, QLocale> localeCache;
static QString balanceFormat(quint64 balance);
static QTextCharFormat addressTextFormat(const SubaddressIndex &index);
static bool versionOutdated(const QString &current_version, const QString &newest_version);
template<typename QEnum>
static QString QtEnumToString (const QEnum value) {

Loading…
Cancel
Save