2020-10-07 10:36:04 +00:00
|
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
2022-02-10 10:26:41 +00:00
|
|
|
// SPDX-FileCopyrightText: 2020-2022 The Monero Project
|
2020-10-07 10:36:04 +00:00
|
|
|
|
2021-06-27 12:51:15 +00:00
|
|
|
#ifndef FEATHER_MAINWINDOW_H
|
|
|
|
#define FEATHER_MAINWINDOW_H
|
2020-10-07 10:36:04 +00:00
|
|
|
|
|
|
|
#include <QMainWindow>
|
|
|
|
#include <QSystemTrayIcon>
|
2021-05-02 18:22:38 +00:00
|
|
|
#include <QMenu>
|
2020-10-07 10:36:04 +00:00
|
|
|
|
2021-05-02 18:22:38 +00:00
|
|
|
#include "appcontext.h"
|
2020-10-07 10:36:04 +00:00
|
|
|
#include "components.h"
|
2021-06-28 17:48:23 +00:00
|
|
|
#include "CalcWindow.h"
|
|
|
|
#include "SettingsDialog.h"
|
2021-05-02 18:22:38 +00:00
|
|
|
|
2021-06-27 11:46:32 +00:00
|
|
|
#include "dialog/AboutDialog.h"
|
|
|
|
#include "dialog/SignVerifyDialog.h"
|
|
|
|
#include "dialog/VerifyProofDialog.h"
|
|
|
|
#include "dialog/SeedDialog.h"
|
|
|
|
#include "dialog/PasswordChangeDialog.h"
|
|
|
|
#include "dialog/KeysDialog.h"
|
|
|
|
#include "dialog/AboutDialog.h"
|
2021-05-25 00:26:28 +00:00
|
|
|
#include "dialog/RestoreHeightDialog.h"
|
2021-06-27 11:46:32 +00:00
|
|
|
#include "dialog/SplashDialog.h"
|
2021-03-24 01:37:54 +00:00
|
|
|
#include "libwalletqt/Wallet.h"
|
2021-05-02 18:22:38 +00:00
|
|
|
#include "model/SubaddressModel.h"
|
|
|
|
#include "model/SubaddressProxyModel.h"
|
|
|
|
#include "model/TransactionHistoryModel.h"
|
|
|
|
#include "model/CoinsModel.h"
|
|
|
|
#include "model/CoinsProxyModel.h"
|
|
|
|
#include "utils/networking.h"
|
|
|
|
#include "utils/config.h"
|
2022-03-04 16:20:17 +00:00
|
|
|
#include "utils/EventFilter.h"
|
2021-06-27 15:00:09 +00:00
|
|
|
#include "widgets/CCSWidget.h"
|
|
|
|
#include "widgets/RedditWidget.h"
|
2021-05-24 23:10:45 +00:00
|
|
|
#include "widgets/TickerWidget.h"
|
2021-05-02 18:22:38 +00:00
|
|
|
#include "wizard/WalletWizard.h"
|
|
|
|
|
2021-06-28 17:48:23 +00:00
|
|
|
#include "ContactsWidget.h"
|
|
|
|
#include "HistoryWidget.h"
|
|
|
|
#include "SendWidget.h"
|
|
|
|
#include "ReceiveWidget.h"
|
|
|
|
#include "CoinsWidget.h"
|
2021-05-10 15:05:10 +00:00
|
|
|
|
2021-05-18 15:59:18 +00:00
|
|
|
#include "WindowManager.h"
|
|
|
|
|
2021-05-02 18:22:38 +00:00
|
|
|
#ifdef HAS_LOCALMONERO
|
|
|
|
#include "widgets/LocalMoneroWidget.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAS_XMRIG
|
2021-06-27 15:00:09 +00:00
|
|
|
#include "widgets/XMRigWidget.h"
|
2021-05-02 18:22:38 +00:00
|
|
|
#endif
|
|
|
|
|
2020-10-07 10:36:04 +00:00
|
|
|
namespace Ui {
|
|
|
|
class MainWindow;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct ToggleTab {
|
2020-12-28 04:39:20 +00:00
|
|
|
ToggleTab(QWidget *tab, QString name, QString description, QAction *menuAction, Config::ConfigKey configKey) :
|
|
|
|
tab(tab), key(std::move(name)), name(std::move(description)), menuAction(menuAction), configKey(configKey){}
|
2020-10-07 10:36:04 +00:00
|
|
|
QWidget *tab;
|
|
|
|
QString key;
|
|
|
|
QString name;
|
|
|
|
QAction *menuAction;
|
|
|
|
Config::ConfigKey configKey;
|
|
|
|
};
|
|
|
|
|
2021-05-18 15:59:18 +00:00
|
|
|
class WindowManager;
|
2020-10-07 10:36:04 +00:00
|
|
|
class MainWindow : public QMainWindow
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2021-05-18 15:59:18 +00:00
|
|
|
explicit MainWindow(WindowManager *windowManager, Wallet *wallet, QWidget *parent = nullptr);
|
2020-10-07 10:36:04 +00:00
|
|
|
~MainWindow() override;
|
|
|
|
|
2021-05-18 15:59:18 +00:00
|
|
|
QString walletName();
|
|
|
|
QString walletCachePath();
|
|
|
|
QString walletKeysPath();
|
|
|
|
|
2020-10-21 11:24:16 +00:00
|
|
|
enum Tabs {
|
|
|
|
HOME = 0,
|
|
|
|
HISTORY,
|
|
|
|
SEND,
|
|
|
|
RECEIVE,
|
|
|
|
COINS,
|
|
|
|
CALC,
|
2020-12-12 01:49:33 +00:00
|
|
|
EXCHANGES,
|
2020-10-21 11:24:16 +00:00
|
|
|
XMRIG
|
|
|
|
};
|
|
|
|
|
2020-12-11 13:32:14 +00:00
|
|
|
enum TabsHome {
|
|
|
|
CCS,
|
|
|
|
REDDIT
|
|
|
|
};
|
|
|
|
|
2021-05-18 15:59:18 +00:00
|
|
|
void showOrHide();
|
|
|
|
void bringToFront();
|
|
|
|
|
|
|
|
signals:
|
|
|
|
void closed();
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
// TODO: use a consistent naming convention for slots
|
|
|
|
// Menu
|
|
|
|
void menuOpenClicked();
|
2020-10-07 10:36:04 +00:00
|
|
|
void menuNewRestoreClicked();
|
|
|
|
void menuQuitClicked();
|
|
|
|
void menuSettingsClicked();
|
|
|
|
void menuAboutClicked();
|
|
|
|
void menuSignVerifyClicked();
|
|
|
|
void menuVerifyTxProof();
|
2021-05-18 15:59:18 +00:00
|
|
|
void menuWalletCloseClicked();
|
|
|
|
void menuTorClicked();
|
|
|
|
void menuToggleTabVisible(const QString &key);
|
2021-07-08 12:03:54 +00:00
|
|
|
void menuClearHistoryClicked();
|
2021-05-18 15:59:18 +00:00
|
|
|
void onExportHistoryCSV(bool checked);
|
|
|
|
void onExportContactsCSV(bool checked);
|
|
|
|
void onCreateDesktopEntry(bool checked);
|
2021-10-21 21:13:25 +00:00
|
|
|
void onShowDocumentaton();
|
2021-05-18 15:59:18 +00:00
|
|
|
void onReportBug(bool checked);
|
2022-03-11 13:56:07 +00:00
|
|
|
void onShowSettingsPage(int page);
|
2021-05-18 15:59:18 +00:00
|
|
|
|
|
|
|
// offline tx signing
|
|
|
|
void exportKeyImages();
|
|
|
|
void importKeyImages();
|
|
|
|
void exportOutputs();
|
|
|
|
void importOutputs();
|
|
|
|
void loadUnsignedTx();
|
|
|
|
void loadUnsignedTxFromClipboard();
|
|
|
|
void loadSignedTx();
|
|
|
|
void loadSignedTxFromText();
|
|
|
|
|
|
|
|
void onTorConnectionStateChanged(bool connected);
|
|
|
|
void onCheckUpdatesComplete(const QString &version, const QString &binaryFilename, const QString &hash, const QString &signer);
|
|
|
|
void onShowUpdateCheck(const QString &version, const QString &binaryFilename, const QString &hash, const QString &signer);
|
|
|
|
void onSignedHashesReceived(QNetworkReply *reply, const QString &platformTag, const QString &version);
|
|
|
|
void onInitiateTransaction();
|
|
|
|
void onEndTransaction();
|
|
|
|
void onCustomRestoreHeightSet(int height);
|
2022-03-12 12:53:46 +00:00
|
|
|
void onKeysCorrupted();
|
2022-03-20 22:30:48 +00:00
|
|
|
void onSelectedInputsChanged(const QStringList &selectedInputs);
|
2021-05-18 15:59:18 +00:00
|
|
|
|
|
|
|
// libwalletqt
|
|
|
|
void onBalanceUpdated(quint64 balance, quint64 spendable);
|
|
|
|
void onSynchronized();
|
|
|
|
void onWalletOpened();
|
|
|
|
void onConnectionStatusChanged(int status);
|
|
|
|
void onCreateTransactionError(const QString &message);
|
|
|
|
void onCreateTransactionSuccess(PendingTransaction *tx, const QVector<QString> &address);
|
|
|
|
void onTransactionCommitted(bool status, PendingTransaction *tx, const QStringList& txid);
|
|
|
|
|
|
|
|
// Dialogs
|
2020-10-07 10:36:04 +00:00
|
|
|
void showWalletInfoDialog();
|
|
|
|
void showSeedDialog();
|
|
|
|
void showPasswordDialog();
|
|
|
|
void showKeysDialog();
|
2020-10-12 22:01:06 +00:00
|
|
|
void showViewOnlyDialog();
|
2021-05-18 15:59:18 +00:00
|
|
|
void showWalletCacheDebugDialog();
|
2021-05-22 13:42:26 +00:00
|
|
|
void showAccountSwitcherDialog();
|
2021-07-06 14:10:24 +00:00
|
|
|
void showAddressChecker();
|
2021-05-18 15:59:18 +00:00
|
|
|
|
2020-10-07 10:36:04 +00:00
|
|
|
void donateButtonClicked();
|
|
|
|
void showCalcWindow();
|
2021-01-26 23:55:27 +00:00
|
|
|
void payToMany();
|
2020-10-07 10:36:04 +00:00
|
|
|
void showSendTab();
|
|
|
|
void showHistoryTab();
|
|
|
|
void showSendScreen(const CCSEntry &entry);
|
|
|
|
void skinChanged(const QString &skinName);
|
|
|
|
void onBlockchainSync(int height, int target);
|
|
|
|
void onRefreshSync(int height, int target);
|
|
|
|
void onViewOnBlockExplorer(const QString &txid);
|
2020-12-14 22:07:23 +00:00
|
|
|
void onResendTransaction(const QString &txid);
|
2020-10-21 06:25:02 +00:00
|
|
|
void importContacts();
|
2020-10-07 10:36:04 +00:00
|
|
|
void showRestoreHeightDialog();
|
2020-11-10 11:38:37 +00:00
|
|
|
void importTransaction();
|
2021-05-02 18:22:38 +00:00
|
|
|
void onDeviceError(const QString &error);
|
2021-07-01 21:00:47 +00:00
|
|
|
void onDeviceButtonRequest(quint64 code);
|
|
|
|
void onDeviceButtonPressed();
|
2021-07-08 00:34:27 +00:00
|
|
|
void onWalletPassphraseNeeded(bool on_device);
|
2021-05-02 18:22:38 +00:00
|
|
|
void menuHwDeviceClicked();
|
|
|
|
void onUpdatesAvailable(const QJsonObject &updates);
|
2021-05-23 14:58:18 +00:00
|
|
|
void toggleSearchbar(bool enabled);
|
2021-08-14 14:53:22 +00:00
|
|
|
void tryStoreWallet();
|
2022-03-15 12:36:20 +00:00
|
|
|
void onWebsocketStatusChanged(bool enabled);
|
2020-10-07 10:36:04 +00:00
|
|
|
|
|
|
|
private:
|
2021-07-03 01:29:13 +00:00
|
|
|
friend WindowManager;
|
|
|
|
|
2021-05-02 18:22:38 +00:00
|
|
|
void initStatusBar();
|
|
|
|
void initWidgets();
|
|
|
|
void initMenu();
|
|
|
|
void initHome();
|
|
|
|
void initWalletContext();
|
|
|
|
|
2020-10-07 10:36:04 +00:00
|
|
|
void closeEvent(QCloseEvent *event) override;
|
2021-05-18 15:59:18 +00:00
|
|
|
|
2020-10-07 10:36:04 +00:00
|
|
|
void saveGeo();
|
|
|
|
void restoreGeo();
|
|
|
|
void showDebugInfo();
|
|
|
|
void showNodeExhaustedMessage();
|
|
|
|
void showWSNodeExhaustedMessage();
|
2020-10-16 03:05:05 +00:00
|
|
|
void createUnsignedTxDialog(UnsignedTransaction *tx);
|
2020-11-14 09:57:06 +00:00
|
|
|
void updatePasswordIcon();
|
2020-11-23 16:57:38 +00:00
|
|
|
void updateNetStats();
|
2020-12-14 19:44:37 +00:00
|
|
|
void rescanSpent();
|
2020-12-31 00:00:37 +00:00
|
|
|
void setStatusText(const QString &text, bool override = false, int timeout = 1000);
|
2020-12-25 14:20:39 +00:00
|
|
|
void showBalanceDialog();
|
2020-12-24 14:46:56 +00:00
|
|
|
QString statusDots();
|
2021-05-02 18:22:38 +00:00
|
|
|
QString getPlatformTag();
|
|
|
|
void displayWalletErrorMsg(const QString &err);
|
|
|
|
QString getHardwareDevice();
|
2021-05-23 13:58:28 +00:00
|
|
|
void updateTitle();
|
2021-05-18 15:59:18 +00:00
|
|
|
void donationNag();
|
2021-07-08 12:03:54 +00:00
|
|
|
void addToRecentlyOpened(const QString &filename);
|
|
|
|
void updateRecentlyOpenedMenu();
|
2021-06-25 14:14:49 +00:00
|
|
|
void updateWidgetIcons();
|
2021-06-04 18:48:44 +00:00
|
|
|
bool verifyPassword();
|
2021-10-28 17:50:18 +00:00
|
|
|
void patchStylesheetMac();
|
2022-03-04 16:20:17 +00:00
|
|
|
void userActivity();
|
|
|
|
void checkUserActivity();
|
2020-10-07 10:36:04 +00:00
|
|
|
|
2021-07-01 21:00:47 +00:00
|
|
|
QIcon hardwareDevicePairedIcon();
|
|
|
|
QIcon hardwareDeviceUnpairedIcon();
|
|
|
|
|
2021-06-27 12:13:05 +00:00
|
|
|
QScopedPointer<Ui::MainWindow> ui;
|
2021-05-18 15:59:18 +00:00
|
|
|
WindowManager *m_windowManager;
|
|
|
|
QSharedPointer<AppContext> m_ctx;
|
2021-05-10 13:20:33 +00:00
|
|
|
|
2020-10-07 10:36:04 +00:00
|
|
|
CalcWindow *m_windowCalc = nullptr;
|
2021-05-02 18:22:38 +00:00
|
|
|
SplashDialog *m_splashDialog = nullptr;
|
|
|
|
|
2021-06-14 18:01:40 +00:00
|
|
|
#ifdef HAS_XMRIG
|
2021-05-18 15:59:18 +00:00
|
|
|
XMRigWidget *m_xmrig = nullptr;
|
2021-06-14 18:01:40 +00:00
|
|
|
#endif
|
2021-05-18 15:59:18 +00:00
|
|
|
ContactsWidget *m_contactsWidget = nullptr;
|
|
|
|
HistoryWidget *m_historyWidget = nullptr;
|
2021-05-10 15:05:10 +00:00
|
|
|
SendWidget *m_sendWidget = nullptr;
|
2021-05-18 15:59:18 +00:00
|
|
|
ReceiveWidget *m_receiveWidget = nullptr;
|
2021-05-10 15:05:10 +00:00
|
|
|
CoinsWidget *m_coinsWidget = nullptr;
|
2021-05-02 18:22:38 +00:00
|
|
|
#ifdef HAS_LOCALMONERO
|
|
|
|
LocalMoneroWidget *m_localMoneroWidget = nullptr;
|
|
|
|
#endif
|
2020-10-07 10:36:04 +00:00
|
|
|
|
2021-05-24 23:10:45 +00:00
|
|
|
QList<PriceTickerWidget*> m_priceTickerWidgets;
|
|
|
|
BalanceTickerWidget *m_balanceTickerWidget;
|
2020-10-07 10:36:04 +00:00
|
|
|
|
2021-07-08 12:03:54 +00:00
|
|
|
QPointer<QAction> m_clearRecentlyOpenAction;
|
|
|
|
|
2020-10-07 10:36:04 +00:00
|
|
|
// lower status bar
|
2021-05-02 18:22:38 +00:00
|
|
|
QPushButton *m_statusUpdateAvailable;
|
2020-12-25 14:20:39 +00:00
|
|
|
ClickableLabel *m_statusLabelBalance;
|
2020-10-07 10:36:04 +00:00
|
|
|
QLabel *m_statusLabelStatus;
|
2020-11-23 16:57:38 +00:00
|
|
|
QLabel *m_statusLabelNetStats;
|
2021-05-22 13:42:26 +00:00
|
|
|
StatusBarButton *m_statusAccountSwitcher;
|
2020-10-07 10:36:04 +00:00
|
|
|
StatusBarButton *m_statusBtnConnectionStatusIndicator;
|
|
|
|
StatusBarButton *m_statusBtnPassword;
|
|
|
|
StatusBarButton *m_statusBtnPreferences;
|
|
|
|
StatusBarButton *m_statusBtnSeed;
|
|
|
|
StatusBarButton *m_statusBtnTor;
|
2021-05-02 18:22:38 +00:00
|
|
|
StatusBarButton *m_statusBtnHwDevice;
|
2020-10-07 10:36:04 +00:00
|
|
|
|
|
|
|
QSignalMapper *m_tabShowHideSignalMapper;
|
|
|
|
QMap<QString, ToggleTab*> m_tabShowHideMapper;
|
|
|
|
|
2020-11-23 16:57:38 +00:00
|
|
|
QTimer m_updateBytes;
|
2022-03-04 16:20:17 +00:00
|
|
|
QTimer m_checkUserActivity;
|
2020-11-23 16:57:38 +00:00
|
|
|
|
2020-12-24 14:46:56 +00:00
|
|
|
QString m_statusText;
|
|
|
|
int m_statusDots;
|
|
|
|
bool m_constructingTransaction = false;
|
2020-12-31 00:00:37 +00:00
|
|
|
bool m_statusOverrideActive = false;
|
2021-05-02 18:22:38 +00:00
|
|
|
bool m_showDeviceError = false;
|
2020-12-24 14:46:56 +00:00
|
|
|
QTimer m_txTimer;
|
|
|
|
|
2021-05-18 15:59:18 +00:00
|
|
|
bool cleanedUp = false;
|
2022-03-12 12:53:46 +00:00
|
|
|
bool m_criticalWarningShown = false;
|
2022-03-04 16:20:17 +00:00
|
|
|
|
|
|
|
EventFilter *m_eventFilter = nullptr;
|
|
|
|
qint64 m_userLastActive = QDateTime::currentSecsSinceEpoch();
|
2020-10-07 10:36:04 +00:00
|
|
|
};
|
|
|
|
|
2021-06-27 12:51:15 +00:00
|
|
|
#endif // FEATHER_MAINWINDOW_H
|