wowlet/src/mainwindow.h

231 lines
6.4 KiB
C
Raw Normal View History

// SPDX-License-Identifier: BSD-3-Clause
// Copyright (c) 2020, The Monero Project.
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#ifdef Q_OS_MAC
#include "src/kdmactouchbar.h"
#endif
#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"
#include "widgets/xmrigwidget.h"
#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;
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
};
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();
void showViewOnlyDialog();
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);
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();
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
// libwalletqt
2020-12-25 14:20:39 +00:00
void onBalanceUpdated(quint64 balance, quint64 spendable);
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;
void cleanupBeforeClose();
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);
void touchbarShowWizard();
void touchbarShowWallet();
2020-11-14 09:57:06 +00:00
void updatePasswordIcon();
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();
WalletWizard *createWizard(WalletWizard::Page startPage);
Ui::MainWindow *ui;
Settings *m_windowSettings = nullptr;
CalcWindow *m_windowCalc = nullptr;
RestoreDialog *m_restoreDialog = nullptr;
AboutDialog *m_aboutDialog = nullptr;
XMRigWidget *m_xmrig = nullptr;
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;
QLabel *m_statusLabelStatus;
QLabel *m_statusLabelNetStats;
StatusBarButton *m_statusBtnConnectionStatusIndicator;
StatusBarButton *m_statusBtnPassword;
StatusBarButton *m_statusBtnPreferences;
StatusBarButton *m_statusBtnSeed;
StatusBarButton *m_statusBtnTor;
SubaddressProxyModel *subaddressProxyModel;
TransactionHistoryModel *txHistModel;
CoinsModel *coinsModel;
#ifdef Q_OS_MAC
QAction *m_touchbarActionWelcome;
KDMacTouchBar *m_touchbar;
QList<QAction *> m_touchbarWalletItems;
QList<QAction *> m_touchbarWizardItems;
#endif
QSignalMapper *m_tabShowHideSignalMapper;
QMap<QString, ToggleTab*> m_tabShowHideMapper;
WalletWizard *m_wizard = nullptr;
QMap<QString, QString> m_skins;
QTimer m_updateBytes;
2020-12-24 14:46:56 +00:00
QString m_statusText;
int m_statusDots;
bool m_constructingTransaction = false;
QTimer m_txTimer;
private slots:
void menuToggleTabVisible(const QString &key);
};
#endif // MAINWINDOW_H