feather/src/MainWindow.h

267 lines
7.5 KiB
C
Raw Normal View History

// SPDX-License-Identifier: BSD-3-Clause
2023-01-02 19:30:11 +00:00
// SPDX-FileCopyrightText: 2020-2023 The Monero Project
2021-06-27 12:51:15 +00:00
#ifndef FEATHER_MAINWINDOW_H
#define FEATHER_MAINWINDOW_H
#include <QMainWindow>
#include <QSystemTrayIcon>
#include "components.h"
2023-02-11 17:24:18 +00:00
#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/AccountSwitcherDialog.h"
2021-06-27 11:46:32 +00:00
#include "dialog/SignVerifyDialog.h"
#include "dialog/VerifyProofDialog.h"
#include "dialog/SeedDialog.h"
#include "dialog/PasswordChangeDialog.h"
#include "dialog/KeysDialog.h"
#include "dialog/AboutDialog.h"
#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"
2021-05-02 18:22:38 +00:00
#include "utils/config.h"
#include "utils/daemonrpc.h"
2022-03-04 16:20:17 +00:00
#include "utils/EventFilter.h"
2021-05-24 23:10:45 +00:00
#include "widgets/TickerWidget.h"
2023-01-19 14:12:16 +00:00
#include "widgets/WalletUnlockWidget.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"
2023-11-30 14:01:39 +00:00
#include "plugins/Plugin.h"
2021-05-18 15:59:18 +00:00
#ifdef CHECK_UPDATES
#include "utils/updater/Updater.h"
#endif
namespace Ui {
class MainWindow;
}
struct ToggleTab {
2023-11-30 14:01:39 +00:00
ToggleTab(QWidget *tab, QString name, QString description, QAction *menuAction) :
tab(tab), key(std::move(name)), name(std::move(description)), menuAction(menuAction) {}
QWidget *tab;
QString key;
QString name;
QAction *menuAction;
};
2021-05-18 15:59:18 +00:00
class WindowManager;
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
2021-05-18 15:59:18 +00:00
explicit MainWindow(WindowManager *windowManager, Wallet *wallet, QWidget *parent = nullptr);
~MainWindow() override;
2021-05-18 15:59:18 +00:00
QString walletName();
QString walletCachePath();
QString walletKeysPath();
2023-12-02 18:28:31 +00:00
enum Stack {
WALLET = 0,
LOCKED,
OFFLINE
};
2021-05-18 15:59:18 +00:00
void showOrHide();
void bringToFront();
2023-02-11 17:11:21 +00:00
public slots:
void onPreferredFiatCurrencyChanged();
void onHideUpdateNotifications(bool hidden);
2021-05-18 15:59:18 +00:00
signals:
2023-11-30 14:01:39 +00:00
void updateIcons();
2021-05-18 15:59:18 +00:00
void closed();
2023-11-30 14:01:39 +00:00
void uiSetup();
void aboutToQuit();
2021-05-18 15:59:18 +00:00
2023-02-11 17:11:21 +00:00
protected:
void changeEvent(QEvent* event) override;
2021-05-18 15:59:18 +00:00
private slots:
// TODO: use a consistent naming convention for slots
// Menu
void menuOpenClicked();
void menuNewRestoreClicked();
void menuQuitClicked();
2023-02-11 17:11:21 +00:00
void menuSettingsClicked(bool showProxytab = false);
void menuAboutClicked();
void menuSignVerifyClicked();
void menuVerifyTxProof();
2021-05-18 15:59:18 +00:00
void menuWalletCloseClicked();
2023-02-11 17:11:21 +00:00
void menuProxySettingsClicked();
2021-05-18 15:59:18 +00:00
void menuToggleTabVisible(const QString &key);
void menuClearHistoryClicked();
2023-03-29 09:00:41 +00:00
void onExportHistoryCSV();
void onExportContactsCSV();
void onCreateDesktopEntry();
2023-01-09 02:17:25 +00:00
void onShowDocumentation();
2023-03-29 09:00:41 +00:00
void onReportBug();
2022-03-11 13:56:07 +00:00
void onShowSettingsPage(int page);
2021-05-18 15:59:18 +00:00
// offline tx signing
void loadSignedTx();
void loadSignedTxFromText();
void onTorConnectionStateChanged(bool connected);
2023-02-01 14:40:12 +00:00
void showUpdateDialog();
2021-05-18 15:59:18 +00:00
void onInitiateTransaction();
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);
2023-12-30 13:17:11 +00:00
void onSyncStatus(quint64 height, quint64 target, bool daemonSync);
2021-05-18 15:59:18 +00:00
void onWalletOpened();
void onConnectionStatusChanged(int status);
void onTransactionCreated(PendingTransaction *tx, const QVector<QString> &address);
2021-05-18 15:59:18 +00:00
void onTransactionCommitted(bool status, PendingTransaction *tx, const QStringList& txid);
// Dialogs
void showWalletInfoDialog();
void showSeedDialog();
void showPasswordDialog();
void showKeysDialog();
void showViewOnlyDialog();
2023-12-02 18:28:31 +00:00
void showKeyImageSyncWizard();
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();
2023-12-02 18:28:31 +00:00
void showURDialog();
void donateButtonClicked();
2021-01-26 23:55:27 +00:00
void payToMany();
void showHistoryTab();
void skinChanged(const QString &skinName);
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-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();
2021-05-23 14:58:18 +00:00
void toggleSearchbar(bool enabled);
void tryStoreWallet();
void onWebsocketStatusChanged(bool enabled);
2023-02-01 14:40:12 +00:00
void showUpdateNotification();
2023-02-11 17:11:21 +00:00
void onProxySettingsChanged();
void onOfflineMode(bool offline);
2023-03-02 12:41:33 +00:00
void onMultiBroadcast(const QMap<QString, QString> &txHexMap);
private:
friend WindowManager;
2021-05-02 18:22:38 +00:00
void initStatusBar();
2023-11-30 14:01:39 +00:00
void initPlugins();
2021-05-02 18:22:38 +00:00
void initWidgets();
void initMenu();
2023-12-02 18:28:31 +00:00
void initOffline();
2021-05-02 18:22:38 +00:00
void initWalletContext();
void closeEvent(QCloseEvent *event) override;
2021-05-18 15:59:18 +00:00
void saveGeo();
void restoreGeo();
void showDebugInfo();
2020-11-14 09:57:06 +00:00
void updatePasswordIcon();
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 getHardwareDevice();
2021-05-23 13:58:28 +00:00
void updateTitle();
2021-05-18 15:59:18 +00:00
void donationNag();
void addToRecentlyOpened(QString filename);
void updateRecentlyOpenedMenu();
2021-06-25 14:14:49 +00:00
void updateWidgetIcons();
2023-01-09 02:17:25 +00:00
bool verifyPassword(bool sensitive = true);
2022-06-23 17:48:30 +00:00
void fillSendTab(const QString &address, const QString &description);
2022-03-04 16:20:17 +00:00
void userActivity();
void checkUserActivity();
2023-01-19 14:12:16 +00:00
void lockWallet();
void unlockWallet(const QString &password);
void closeQDialogChildren(QObject *object);
2023-11-30 14:01:39 +00:00
int findTab(const QString &title);
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;
Wallet *m_wallet = nullptr;
Nodes *m_nodes;
DaemonRpc *m_rpc;
2021-05-10 13:20:33 +00:00
2021-05-02 18:22:38 +00:00
SplashDialog *m_splashDialog = nullptr;
AccountSwitcherDialog *m_accountSwitcherDialog = nullptr;
2021-05-02 18:22:38 +00:00
2023-01-19 14:12:16 +00:00
WalletUnlockWidget *m_walletUnlockWidget = nullptr;
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;
QPointer<QAction> m_clearRecentlyOpenAction;
// 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;
QLabel *m_statusLabelStatus;
QLabel *m_statusLabelNetStats;
2021-05-22 13:42:26 +00:00
StatusBarButton *m_statusAccountSwitcher;
StatusBarButton *m_statusBtnConnectionStatusIndicator;
StatusBarButton *m_statusBtnPassword;
StatusBarButton *m_statusBtnPreferences;
StatusBarButton *m_statusBtnSeed;
2023-02-11 17:11:21 +00:00
StatusBarButton *m_statusBtnProxySettings;
2021-05-02 18:22:38 +00:00
StatusBarButton *m_statusBtnHwDevice;
QSignalMapper *m_tabShowHideSignalMapper;
QMap<QString, ToggleTab*> m_tabShowHideMapper;
QTimer m_updateBytes;
2022-03-04 16:20:17 +00:00
QTimer m_checkUserActivity;
2023-11-30 14:01:39 +00:00
QList<Plugin*> m_plugins;
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;
2023-01-19 14:12:16 +00:00
bool m_locked = 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();
2023-02-01 14:40:12 +00:00
#ifdef CHECK_UPDATES
2023-02-01 14:40:12 +00:00
QSharedPointer<Updater> m_updater = nullptr;
#endif
};
2021-06-27 12:51:15 +00:00
#endif // FEATHER_MAINWINDOW_H