feather/src/MainWindow.h

285 lines
8.2 KiB
C
Raw Normal View History

// SPDX-License-Identifier: BSD-3-Clause
2022-02-10 10:26:41 +00:00
// SPDX-FileCopyrightText: 2020-2022 The Monero Project
2021-06-27 12:51:15 +00:00
#ifndef FEATHER_MAINWINDOW_H
#define FEATHER_MAINWINDOW_H
#include <QMainWindow>
#include <QSystemTrayIcon>
2021-05-02 18:22:38 +00:00
#include <QMenu>
2021-05-02 18:22:38 +00:00
#include "appcontext.h"
#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
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){}
QWidget *tab;
QString key;
QString name;
QAction *menuAction;
Config::ConfigKey configKey;
};
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();
enum Tabs {
HOME = 0,
HISTORY,
SEND,
RECEIVE,
COINS,
CALC,
2020-12-12 01:49:33 +00:00
EXCHANGES,
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();
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);
void menuClearHistoryClicked();
2021-05-18 15:59:18 +00:00
void onExportHistoryCSV(bool checked);
void onExportContactsCSV(bool checked);
void onCreateDesktopEntry(bool checked);
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
void showWalletInfoDialog();
void showSeedDialog();
void showPasswordDialog();
void showKeysDialog();
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
void donateButtonClicked();
void showCalcWindow();
2021-01-26 23:55:27 +00:00
void payToMany();
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();
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);
void tryStoreWallet();
void onWebsocketStatusChanged(bool enabled);
private:
friend WindowManager;
2021-05-02 18:22:38 +00:00
void initStatusBar();
void initWidgets();
void initMenu();
void initHome();
void initWalletContext();
void closeEvent(QCloseEvent *event) override;
2021-05-18 15:59:18 +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();
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();
void addToRecentlyOpened(const QString &filename);
void updateRecentlyOpenedMenu();
2021-06-25 14:14:49 +00:00
void updateWidgetIcons();
bool verifyPassword();
void patchStylesheetMac();
2022-03-04 16:20:17 +00:00
void userActivity();
void checkUserActivity();
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
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
2021-05-24 23:10:45 +00:00
QList<PriceTickerWidget*> m_priceTickerWidgets;
BalanceTickerWidget *m_balanceTickerWidget;
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;
StatusBarButton *m_statusBtnTor;
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;
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();
};
2021-06-27 12:51:15 +00:00
#endif // FEATHER_MAINWINDOW_H