feather/src/mainwindow.h

258 lines
7.4 KiB
C
Raw Normal View History

// SPDX-License-Identifier: BSD-3-Clause
2020-12-26 19:56:06 +00:00
// Copyright (c) 2020-2021, The Monero Project.
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QSystemTrayIcon>
2021-05-02 18:22:38 +00:00
#include <QMenu>
2020-12-28 04:39:20 +00:00
#include <utility>
2021-05-02 18:22:38 +00:00
#include "appcontext.h"
#include "components.h"
#include "calcwindow.h"
#include "settings.h"
2021-05-02 18:22:38 +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-05-02 18:22:38 +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"
#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-05-18 15:59:18 +00:00
#include "contactswidget.h"
#include "historywidget.h"
2021-05-10 15:05:10 +00:00
#include "sendwidget.h"
2021-05-18 15:59:18 +00:00
#include "receivewidget.h"
2021-05-10 15:05:10 +00:00
#include "coinswidget.h"
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
#include "widgets/xmrigwidget.h"
#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 onExportHistoryCSV(bool checked);
void onExportContactsCSV(bool checked);
void onCreateDesktopEntry(bool checked);
void onReportBug(bool checked);
// 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 onShowDonationNag();
void onInitiateTransaction();
void onEndTransaction();
void onCustomRestoreHeightSet(int height);
// 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 showConnectionStatusDialog();
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-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);
void menuHwDeviceClicked();
void onUpdatesAvailable(const QJsonObject &updates);
2021-05-23 14:58:18 +00:00
void toggleSearchbar(bool enabled);
2021-05-24 14:50:09 +00:00
void onSetStatusText(const QString &text);
private:
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 updateRecentlyOpened(const QString &filename);
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
Settings *m_windowSettings = nullptr;
CalcWindow *m_windowCalc = nullptr;
2021-05-02 18:22:38 +00:00
SplashDialog *m_splashDialog = nullptr;
2021-05-18 15:59:18 +00:00
XMRigWidget *m_xmrig = nullptr;
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;
// 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;
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;
};
#endif // MAINWINDOW_H