Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 57 additions & 1 deletion src/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "dialog/ViewOnlyDialog.h"
#include "dialog/WalletInfoDialog.h"
#include "dialog/WalletCacheDebugDialog.h"
#include "dialog/SyncDatesDialog.h"
#include "libwalletqt/AddressBook.h"
#include "libwalletqt/rows/CoinsInfo.h"
#include "libwalletqt/rows/Output.h"
Expand Down Expand Up @@ -96,6 +97,7 @@ MainWindow::MainWindow(WindowManager *windowManager, Wallet *wallet, QWidget *pa
connect(m_windowManager, &WindowManager::offlineMode, this, &MainWindow::onOfflineMode);
connect(m_windowManager, &WindowManager::manualFeeSelectionEnabled, this, &MainWindow::onManualFeeSelectionEnabled);
connect(m_windowManager, &WindowManager::subtractFeeFromAmountEnabled, this, &MainWindow::onSubtractFeeFromAmountEnabled);
connect(m_windowManager, &WindowManager::dataSavingModeEnabled, this, &MainWindow::onDataSavingModeEnabled);

connect(torManager(), &TorManager::connectionStateChanged, this, &MainWindow::onTorConnectionStateChanged);
this->onTorConnectionStateChanged(torManager()->torConnected);
Expand All @@ -115,6 +117,12 @@ MainWindow::MainWindow(WindowManager *windowManager, Wallet *wallet, QWidget *pa

conf()->set(Config::firstRun, false);

// Check Data Saving Mode before starting wallet sync
if (conf()->get(Config::dataSavingMode).toBool()) {
m_wallet->pauseRefresh();
qInfo() << "Data Saving Mode enabled - auto-sync disabled on wallet open";
}

this->onWalletOpened();

connect(&appData()->prices, &Prices::fiatPricesUpdated, this, &MainWindow::updateBalance);
Expand Down Expand Up @@ -316,6 +324,8 @@ void MainWindow::initMenu() {
connect(ui->actionRefresh_tabs, &QAction::triggered, [this]{m_wallet->refreshModels();});
connect(ui->actionRescan_spent, &QAction::triggered, this, &MainWindow::rescanSpent);
connect(ui->actionWallet_cache_debug, &QAction::triggered, this, &MainWindow::showWalletCacheDebugDialog);
connect(ui->actionSync_dates, &QAction::triggered, this, &MainWindow::onSyncDates);
connect(ui->actionFull_sync, &QAction::triggered, this, &MainWindow::onFullSync);
connect(ui->actionTxPoolViewer, &QAction::triggered, this, &MainWindow::showTxPoolViewerDialog);

// [Wallet] -> [History]
Expand Down Expand Up @@ -485,7 +495,6 @@ void MainWindow::initWalletContext() {

// Wallet
connect(m_wallet, &Wallet::connectionStatusChanged, [this](int status){
// Order is important, first inform UI about a potential disconnect, then reconnect
this->onConnectionStatusChanged(status);
m_nodes->autoConnect();
});
Expand Down Expand Up @@ -1431,6 +1440,53 @@ void MainWindow::importTransaction() {
dialog.exec();
}

void MainWindow::onDataSavingModeEnabled(bool enabled) {
qInfo() << "Data Saving Mode" << (enabled ? "enabled" : "disabled");

if (enabled) {
m_wallet->pauseRefresh();
this->setStatusText("Data Saving Mode enabled - Auto-sync paused", false, 5000);
QMessageBox::information(this, "Data Saving Mode Enabled",
"Auto-sync has been disabled to save data.\n\n"
"Use Wallet > Advanced > Sync Options to:\n"
"• Sync Dates - Sync a specific date range\n"
"• Full Sync - Sync normally\n\n"
"Note: Restart the wallet for immediate sync, otherwise wait for the next sync cycle.");
} else {
m_wallet->startRefresh();
this->setStatusText("Data Saving Mode disabled - Resuming sync", false, 3000);
}
}

void MainWindow::onFullSync() {
qInfo() << "User initiated full sync";
if (conf()->get(Config::dataSavingMode).toBool()) {
conf()->set(Config::dataSavingMode, false);
qInfo() << "Data Saving Mode disabled for full sync";
}
m_wallet->startRefresh();
this->setStatusText("Full sync started - syncing from last sync date", false, 3000);
}

void MainWindow::onSyncDates() {
SyncDatesDialog dialog(this);
if (dialog.exec() == QDialog::Accepted) {
QDateTime startDate = dialog.getStartDate();
QDateTime endDate = dialog.getEndDate();

if (conf()->get(Config::dataSavingMode).toBool()) {
conf()->set(Config::dataSavingMode, false);
qInfo() << "Data Saving Mode disabled for date range sync";
}

qInfo() << "User initiated date range sync from" << startDate << "to" << endDate;
m_wallet->syncDateRange(startDate, endDate);

QString msg = QString("Syncing from %1 to %2").arg(startDate.toString("yyyy-MM-dd"), endDate.toString("yyyy-MM-dd"));
this->setStatusText(msg, false, 5000);
}
}

void MainWindow::onDeviceError(const QString &error, quint64 errorCode) {
qCritical() << "Device error: " << error;

Expand Down
4 changes: 4 additions & 0 deletions src/MainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,10 @@ private slots:
void onManualFeeSelectionEnabled(bool enabled);
void onSubtractFeeFromAmountEnabled(bool enabled);
void onMultiBroadcast(const QMap<QString, QString> &txHexMap);

void onDataSavingModeEnabled(bool enabled);
void onFullSync();
void onSyncDates();

private:
friend WindowManager;
Expand Down
25 changes: 25 additions & 0 deletions src/MainWindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -542,11 +542,20 @@
<property name="title">
<string>Advanced</string>
</property>
<widget class="QMenu" name="menuSync">
<property name="title">
<string>Sync Options</string>
</property>
<addaction name="actionSync_dates"/>
<addaction name="actionFull_sync"/>
</widget>
<addaction name="actionStore_wallet"/>
<addaction name="actionUpdate_balance"/>
<addaction name="actionRefresh_tabs"/>
<addaction name="actionRescan_spent"/>
<addaction name="actionWallet_cache_debug"/>
<addaction name="separator"/>
<addaction name="menuSync"/>
</widget>
<addaction name="actionInformation"/>
<addaction name="menuAdvanced"/>
Expand Down Expand Up @@ -862,6 +871,22 @@
<string>Wallet cache debug</string>
</property>
</action>
<action name="actionSync_dates">
<property name="text">
<string>Sync Dates...</string>
</property>
<property name="toolTip">
<string>Sync a specific date range (Data Saving Mode)</string>
</property>
</action>
<action name="actionFull_sync">
<property name="text">
<string>Full Sync</string>
</property>
<property name="toolTip">
<string>Perform a full wallet synchronization</string>
</property>
</action>
<action name="actionPay_to_many">
<property name="text">
<string>Pay to many</string>
Expand Down
18 changes: 18 additions & 0 deletions src/SettingsDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,24 @@ void Settings::setupTransactionsTab() {
conf()->set(Config::subtractFeeFromAmount, toggled);
emit subtractFeeFromAmountEnabled(toggled);
});

// [Data Saving Mode]
ui->checkBox_dataSavingMode->setChecked(conf()->get(Config::dataSavingMode).toBool());
connect(ui->checkBox_dataSavingMode, &QCheckBox::toggled, [this](bool toggled){
conf()->set(Config::dataSavingMode, toggled);
emit dataSavingModeEnabled(toggled);
});
connect(ui->btn_dataSavingInfo, &QPushButton::clicked, [this]{
Utils::showInfo(this, "Data Saving Mode",
"Data Saving Mode allows you to save mobile data and time when you haven't received Monero since last opening your wallet.\n\n"
"When enabled:\n"
"• Wallet will NOT auto-sync on open\n"
"• You can use 'Skip Sync' to jump to current block height\n"
"• You can use 'Sync Dates' to sync a specific date range\n"
"• You can use 'Full Sync' to sync normally\n"
"• You can import specific transactions if needed\n\n"
"This can save 500+ MB of data and 30+ minutes of syncing time.");
});
}

void Settings::setupPluginsTab() {
Expand Down
1 change: 1 addition & 0 deletions src/SettingsDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ Q_OBJECT
void pluginConfigured(const QString &id);
void manualFeeSelectionEnabled(bool enabled);
void subtractFeeFromAmountEnabled(bool enabled);
void dataSavingModeEnabled(bool enabled);

public slots:
// void checkboxExternalLinkWarn();
Expand Down
37 changes: 37 additions & 0 deletions src/SettingsDialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -1017,6 +1017,43 @@
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_dataSaving">
<item>
<widget class="QCheckBox" name="checkBox_dataSavingMode">
<property name="text">
<string>Data Saving Mode (Skip auto-sync)</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btn_dataSavingInfo">
<property name="text">
<string>?</string>
</property>
<property name="maximumSize">
<size>
<width>30</width>
<height>16777215</height>
</size>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_dataSaving">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
Expand Down
1 change: 1 addition & 0 deletions src/WindowManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ void WindowManager::showSettings(Nodes *nodes, QWidget *parent, bool showProxyTa
connect(&settings, &Settings::offlineMode, this, &WindowManager::offlineMode);
connect(&settings, &Settings::manualFeeSelectionEnabled, this, &WindowManager::manualFeeSelectionEnabled);
connect(&settings, &Settings::subtractFeeFromAmountEnabled, this, &WindowManager::subtractFeeFromAmountEnabled);
connect(&settings, &Settings::dataSavingModeEnabled, this, &WindowManager::dataSavingModeEnabled);
connect(&settings, &Settings::hideUpdateNotifications, [this](bool hidden){
for (const auto &window : m_windows) {
window->onHideUpdateNotifications(hidden);
Expand Down
1 change: 1 addition & 0 deletions src/WindowManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ Q_OBJECT
void pluginConfigured(const QString &id);
void manualFeeSelectionEnabled(bool enabled);
void subtractFeeFromAmountEnabled(bool enabled);
void dataSavingModeEnabled(bool enabled);

public slots:
void onProxySettingsChanged();
Expand Down
53 changes: 53 additions & 0 deletions src/dialog/SyncDatesDialog.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// SPDX-License-Identifier: BSD-3-Clause
// SPDX-FileCopyrightText: The Monero Project

#include "SyncDatesDialog.h"
#include "ui_SyncDatesDialog.h"

#include <QMessageBox>

SyncDatesDialog::SyncDatesDialog(QWidget *parent)
: QDialog(parent)
, ui(new Ui::SyncDatesDialog)
{
ui->setupUi(this);

// Set default dates
QDateTime now = QDateTime::currentDateTime();
ui->dateEdit_start->setDateTime(now.addMonths(-1)); // Default to 1 month ago
ui->dateEdit_end->setDateTime(now);

// Set reasonable date ranges
QDateTime genesisTime = QDateTime::fromSecsSinceEpoch(1397818193, Qt::UTC); // Monero genesis
ui->dateEdit_start->setMinimumDateTime(genesisTime);
ui->dateEdit_start->setMaximumDateTime(now);
ui->dateEdit_end->setMinimumDateTime(genesisTime);
ui->dateEdit_end->setMaximumDateTime(now);

connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &SyncDatesDialog::onAccepted);
connect(ui->buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);

this->adjustSize();
}

QDateTime SyncDatesDialog::getStartDate() const {
return m_startDate;
}

QDateTime SyncDatesDialog::getEndDate() const {
return m_endDate;
}

void SyncDatesDialog::onAccepted() {
m_startDate = ui->dateEdit_start->dateTime();
m_endDate = ui->dateEdit_end->dateTime();

if (m_startDate >= m_endDate) {
QMessageBox::warning(this, "Invalid Date Range", "Start date must be before end date.");
return;
}

this->accept();
}

SyncDatesDialog::~SyncDatesDialog() = default;
34 changes: 34 additions & 0 deletions src/dialog/SyncDatesDialog.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// SPDX-License-Identifier: BSD-3-Clause
// SPDX-FileCopyrightText: The Monero Project

#ifndef FEATHER_SYNCDATESDIALOG_H
#define FEATHER_SYNCDATESDIALOG_H

#include <QDialog>
#include <QDateTime>

namespace Ui {
class SyncDatesDialog;
}

class SyncDatesDialog : public QDialog
{
Q_OBJECT

public:
explicit SyncDatesDialog(QWidget *parent = nullptr);
~SyncDatesDialog() override;

QDateTime getStartDate() const;
QDateTime getEndDate() const;

private slots:
void onAccepted();

private:
QScopedPointer<Ui::SyncDatesDialog> ui;
QDateTime m_startDate;
QDateTime m_endDate;
};

#endif // FEATHER_SYNCDATESDIALOG_H
Loading