2020-10-07 10:36:04 +00:00
|
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
// Copyright (c) 2020, The Monero Project.
|
|
|
|
|
|
|
|
#ifndef MAINWINDOW_H
|
|
|
|
#define MAINWINDOW_H
|
|
|
|
|
2020-10-22 03:50:59 +00:00
|
|
|
#ifdef Q_OS_MAC
|
|
|
|
#include "src/kdmactouchbar.h"
|
|
|
|
#endif
|
|
|
|
|
2020-10-07 10:36:04 +00:00
|
|
|
#include <QMainWindow>
|
|
|
|
#include <QSystemTrayIcon>
|
|
|
|
#include <QScreen>
|
|
|
|
#include <QtWidgets/QMenu>
|
|
|
|
#include <model/SubaddressModel.h>
|
|
|
|
#include <model/SubaddressProxyModel.h>
|
|
|
|
#include <model/TransactionHistoryModel.h>
|
|
|
|
#include <model/CoinsModel.h>
|
|
|
|
#include <model/CoinsProxyModel.h>
|
|
|
|
|
|
|
|
#include "components.h"
|
|
|
|
#include "calcwindow.h"
|
|
|
|
#include "widgets/ccswidget.h"
|
|
|
|
#include "widgets/redditwidget.h"
|
|
|
|
#include "widgets/tickerwidget.h"
|
2020-10-16 19:01:18 +00:00
|
|
|
#include "widgets/xmrigwidget.h"
|
2020-10-07 10:36:04 +00:00
|
|
|
#include "utils/networking.h"
|
|
|
|
#include "appcontext.h"
|
|
|
|
#include "utils/config.h"
|
|
|
|
#include "wizard/walletwizard.h"
|
|
|
|
#include "settings.h"
|
|
|
|
#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"
|
|
|
|
#include "dialog/restoredialog.h"
|
|
|
|
|
|
|
|
namespace Ui {
|
|
|
|
class MainWindow;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct ToggleTab {
|
|
|
|
ToggleTab(QWidget *tab, const QString &name, const QString &description, QAction *menuAction, Config::ConfigKey configKey) :
|
|
|
|
tab(tab), key(name), name(description), menuAction(menuAction), configKey(configKey){}
|
|
|
|
QWidget *tab;
|
|
|
|
QString key;
|
|
|
|
QString name;
|
|
|
|
QAction *menuAction;
|
|
|
|
Config::ConfigKey configKey;
|
|
|
|
};
|
|
|
|
|
|
|
|
class MainWindow : public QMainWindow
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit MainWindow(AppContext *ctx, QWidget *parent = nullptr);
|
|
|
|
static MainWindow *getInstance();
|
|
|
|
static AppContext *getContext();
|
|
|
|
~MainWindow() override;
|
|
|
|
|
|
|
|
qreal screenDpiRef;
|
|
|
|
QRect screenGeo;
|
|
|
|
QRect screenRect;
|
|
|
|
qreal screenDpi;
|
|
|
|
qreal screenDpiPhysical;
|
|
|
|
qreal screenRatio;
|
|
|
|
|
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
|
|
|
|
};
|
|
|
|
|
2020-10-07 10:36:04 +00:00
|
|
|
public slots:
|
|
|
|
void initWidgets();
|
|
|
|
void initMenu();
|
|
|
|
void showWizard(WalletWizard::Page startPage);
|
|
|
|
void menuNewRestoreClicked();
|
|
|
|
void menuQuitClicked();
|
|
|
|
void menuSettingsClicked();
|
|
|
|
void menuAboutClicked();
|
|
|
|
void menuSignVerifyClicked();
|
|
|
|
void menuVerifyTxProof();
|
|
|
|
void showWalletInfoDialog();
|
|
|
|
void showSeedDialog();
|
|
|
|
void showConnectionStatusDialog();
|
|
|
|
void showPasswordDialog();
|
|
|
|
void showKeysDialog();
|
2020-10-12 22:01:06 +00:00
|
|
|
void showViewOnlyDialog();
|
2020-10-07 10:36:04 +00:00
|
|
|
void donateButtonClicked();
|
|
|
|
void showCalcWindow();
|
|
|
|
void showSendTab();
|
|
|
|
void showHistoryTab();
|
|
|
|
void showSendScreen(const CCSEntry &entry);
|
|
|
|
void skinChanged(const QString &skinName);
|
|
|
|
void menuTorClicked();
|
|
|
|
void onBlockchainSync(int height, int target);
|
|
|
|
void onRefreshSync(int height, int target);
|
|
|
|
void onWalletOpenedError(const QString &err);
|
|
|
|
void onWalletCreatedError(const QString &err);
|
|
|
|
void onWalletCreated(Wallet *wallet);
|
|
|
|
void menuWalletCloseClicked();
|
|
|
|
void menuWalletOpenClicked();
|
2020-10-21 06:45:25 +00:00
|
|
|
void onWalletOpenPasswordRequired(bool invalidPassword, const QString &path);
|
2020-10-07 10:36:04 +00:00
|
|
|
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();
|
2020-10-07 10:36:04 +00:00
|
|
|
|
2020-10-16 03:05:05 +00:00
|
|
|
// offline tx signing
|
2020-10-14 18:18:25 +00:00
|
|
|
void exportKeyImages();
|
|
|
|
void importKeyImages();
|
|
|
|
void exportOutputs();
|
|
|
|
void importOutputs();
|
2020-10-16 03:05:05 +00:00
|
|
|
void loadUnsignedTx();
|
|
|
|
void loadUnsignedTxFromClipboard();
|
|
|
|
void loadSignedTx();
|
|
|
|
void loadSignedTxFromText();
|
2020-10-14 18:18:25 +00:00
|
|
|
|
2020-10-07 10:36:04 +00:00
|
|
|
// libwalletqt
|
2020-12-25 14:20:39 +00:00
|
|
|
void onBalanceUpdated(quint64 balance, quint64 spendable);
|
2020-10-07 10:36:04 +00:00
|
|
|
void onSynchronized();
|
|
|
|
void onWalletOpened();
|
|
|
|
void onWalletClosed();
|
|
|
|
void onWalletClosed(WalletWizard::Page page);
|
|
|
|
void onConnectionStatusChanged(int status);
|
|
|
|
void onCreateTransactionError(const QString &message);
|
|
|
|
void onCreateTransactionSuccess(PendingTransaction *tx, const QString &address, const quint32 &mixin);
|
|
|
|
void onTransactionCommitted(bool status, PendingTransaction *tx, const QStringList& txid);
|
|
|
|
|
|
|
|
signals:
|
|
|
|
void walletClosed();
|
|
|
|
void closed();
|
|
|
|
|
|
|
|
private:
|
|
|
|
AppContext *m_ctx;
|
|
|
|
|
|
|
|
static MainWindow * pMainWindow;
|
|
|
|
void closeEvent(QCloseEvent *event) override;
|
2020-10-16 03:15:46 +00:00
|
|
|
void cleanupBeforeClose();
|
2020-10-07 10:36:04 +00:00
|
|
|
void create_status_bar();
|
|
|
|
void initMain();
|
|
|
|
void loadSkins();
|
|
|
|
QString loadStylesheet(const QString &resource);
|
|
|
|
void saveGeo();
|
|
|
|
void restoreGeo();
|
|
|
|
void showDebugInfo();
|
|
|
|
void showNodeExhaustedMessage();
|
|
|
|
void showWSNodeExhaustedMessage();
|
2020-10-16 03:05:05 +00:00
|
|
|
void createUnsignedTxDialog(UnsignedTransaction *tx);
|
2020-10-22 03:50:59 +00:00
|
|
|
void touchbarShowWizard();
|
|
|
|
void touchbarShowWallet();
|
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-24 14:46:56 +00:00
|
|
|
void setStatusText(const QString &text);
|
2020-12-25 14:20:39 +00:00
|
|
|
void showBalanceDialog();
|
2020-12-24 14:46:56 +00:00
|
|
|
QString statusDots();
|
2020-10-07 10:36:04 +00:00
|
|
|
|
|
|
|
WalletWizard *createWizard(WalletWizard::Page startPage);
|
|
|
|
|
|
|
|
Ui::MainWindow *ui;
|
|
|
|
Settings *m_windowSettings = nullptr;
|
|
|
|
CalcWindow *m_windowCalc = nullptr;
|
|
|
|
RestoreDialog *m_restoreDialog = nullptr;
|
|
|
|
AboutDialog *m_aboutDialog = nullptr;
|
2020-10-16 19:01:18 +00:00
|
|
|
XMRigWidget *m_xmrig = nullptr;
|
2020-10-07 10:36:04 +00:00
|
|
|
|
|
|
|
QSystemTrayIcon *m_trayIcon;
|
|
|
|
QMenu m_trayMenu;
|
|
|
|
QAction *m_trayActionCalc;
|
|
|
|
QAction *m_trayActionExit;
|
|
|
|
QAction *m_trayActionSend;
|
|
|
|
QAction *m_trayActionHistory;
|
|
|
|
|
|
|
|
QList<TickerWidget*> m_tickerWidgets;
|
|
|
|
TickerWidget *m_balanceWidget;
|
|
|
|
|
|
|
|
// lower status bar
|
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;
|
2020-10-07 10:36:04 +00:00
|
|
|
StatusBarButton *m_statusBtnConnectionStatusIndicator;
|
|
|
|
StatusBarButton *m_statusBtnPassword;
|
|
|
|
StatusBarButton *m_statusBtnPreferences;
|
|
|
|
StatusBarButton *m_statusBtnSeed;
|
|
|
|
StatusBarButton *m_statusBtnTor;
|
|
|
|
|
|
|
|
SubaddressProxyModel *subaddressProxyModel;
|
|
|
|
TransactionHistoryModel *txHistModel;
|
|
|
|
CoinsModel *coinsModel;
|
2020-10-22 03:50:59 +00:00
|
|
|
#ifdef Q_OS_MAC
|
|
|
|
QAction *m_touchbarActionWelcome;
|
|
|
|
KDMacTouchBar *m_touchbar;
|
|
|
|
QList<QAction *> m_touchbarWalletItems;
|
|
|
|
QList<QAction *> m_touchbarWizardItems;
|
|
|
|
#endif
|
2020-10-07 10:36:04 +00:00
|
|
|
QSignalMapper *m_tabShowHideSignalMapper;
|
|
|
|
QMap<QString, ToggleTab*> m_tabShowHideMapper;
|
|
|
|
WalletWizard *m_wizard = nullptr;
|
|
|
|
|
|
|
|
QMap<QString, QString> m_skins;
|
|
|
|
|
2020-11-23 16:57:38 +00:00
|
|
|
QTimer m_updateBytes;
|
|
|
|
|
2020-12-24 14:46:56 +00:00
|
|
|
QString m_statusText;
|
|
|
|
int m_statusDots;
|
|
|
|
bool m_constructingTransaction = false;
|
|
|
|
QTimer m_txTimer;
|
|
|
|
|
2020-10-07 10:36:04 +00:00
|
|
|
private slots:
|
|
|
|
void menuToggleTabVisible(const QString &key);
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // MAINWINDOW_H
|