mirror of
https://github.com/feather-wallet/feather.git
synced 2025-01-24 03:25:51 +00:00
Disable various tabs when websocket is disabled
This commit is contained in:
parent
15bed134af
commit
b8db796479
10 changed files with 52 additions and 9 deletions
|
@ -68,6 +68,9 @@ MainWindow::MainWindow(WindowManager *windowManager, Wallet *wallet, QWidget *pa
|
||||||
#endif
|
#endif
|
||||||
websocketNotifier()->emitCache(); // Get cached data
|
websocketNotifier()->emitCache(); // Get cached data
|
||||||
|
|
||||||
|
connect(m_windowManager, &WindowManager::websocketStatusChanged, this, &MainWindow::onWebsocketStatusChanged);
|
||||||
|
this->onWebsocketStatusChanged(!config()->get(Config::disableWebsocket).toBool());
|
||||||
|
|
||||||
connect(m_windowManager, &WindowManager::torSettingsChanged, m_ctx.get(), &AppContext::onTorSettingsChanged);
|
connect(m_windowManager, &WindowManager::torSettingsChanged, m_ctx.get(), &AppContext::onTorSettingsChanged);
|
||||||
connect(torManager(), &TorManager::connectionStateChanged, this, &MainWindow::onTorConnectionStateChanged);
|
connect(torManager(), &TorManager::connectionStateChanged, this, &MainWindow::onTorConnectionStateChanged);
|
||||||
this->onTorConnectionStateChanged(torManager()->torConnected);
|
this->onTorConnectionStateChanged(torManager()->torConnected);
|
||||||
|
@ -540,6 +543,20 @@ void MainWindow::tryStoreWallet() {
|
||||||
m_ctx->wallet->store();
|
m_ctx->wallet->store();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::onWebsocketStatusChanged(bool enabled) {
|
||||||
|
ui->actionShow_Home->setVisible(enabled);
|
||||||
|
ui->actionShow_calc->setVisible(enabled);
|
||||||
|
ui->actionShow_Exchange->setVisible(enabled);
|
||||||
|
|
||||||
|
ui->tabWidget->setTabVisible(Tabs::HOME, enabled && config()->get(Config::showTabHome).toBool());
|
||||||
|
ui->tabWidget->setTabVisible(Tabs::CALC, enabled && config()->get(Config::showTabCalc).toBool());
|
||||||
|
ui->tabWidget->setTabVisible(Tabs::EXCHANGES, enabled && config()->get(Config::showTabExchange).toBool());
|
||||||
|
|
||||||
|
#ifdef HAS_XMRIG
|
||||||
|
m_xmrig->setDownloadsTabEnabled(enabled);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::onSynchronized() {
|
void MainWindow::onSynchronized() {
|
||||||
this->updateNetStats();
|
this->updateNetStats();
|
||||||
this->setStatusText("Synchronized");
|
this->setStatusText("Synchronized");
|
||||||
|
@ -828,6 +845,7 @@ void MainWindow::menuSettingsClicked() {
|
||||||
connect(&settings, &Settings::preferredFiatCurrencyChanged, m_balanceTickerWidget, &BalanceTickerWidget::updateDisplay);
|
connect(&settings, &Settings::preferredFiatCurrencyChanged, m_balanceTickerWidget, &BalanceTickerWidget::updateDisplay);
|
||||||
connect(&settings, &Settings::preferredFiatCurrencyChanged, m_sendWidget, QOverload<>::of(&SendWidget::onPreferredFiatCurrencyChanged));
|
connect(&settings, &Settings::preferredFiatCurrencyChanged, m_sendWidget, QOverload<>::of(&SendWidget::onPreferredFiatCurrencyChanged));
|
||||||
connect(&settings, &Settings::skinChanged, this, &MainWindow::skinChanged);
|
connect(&settings, &Settings::skinChanged, this, &MainWindow::skinChanged);
|
||||||
|
connect(&settings, &Settings::websocketStatusChanged, m_windowManager, &WindowManager::onWebsocketStatusChanged);
|
||||||
settings.exec();
|
settings.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -182,6 +182,7 @@ private slots:
|
||||||
void onUpdatesAvailable(const QJsonObject &updates);
|
void onUpdatesAvailable(const QJsonObject &updates);
|
||||||
void toggleSearchbar(bool enabled);
|
void toggleSearchbar(bool enabled);
|
||||||
void tryStoreWallet();
|
void tryStoreWallet();
|
||||||
|
void onWebsocketStatusChanged(bool enabled);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend WindowManager;
|
friend WindowManager;
|
||||||
|
|
|
@ -94,14 +94,6 @@ void Settings::setupGeneralTab() {
|
||||||
// [Balance display]
|
// [Balance display]
|
||||||
ui->comboBox_balanceDisplay->setCurrentIndex(config()->get(Config::balanceDisplay).toInt());
|
ui->comboBox_balanceDisplay->setCurrentIndex(config()->get(Config::balanceDisplay).toInt());
|
||||||
connect(ui->comboBox_balanceDisplay, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &Settings::comboBox_balanceDisplayChanged);
|
connect(ui->comboBox_balanceDisplay, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &Settings::comboBox_balanceDisplayChanged);
|
||||||
|
|
||||||
// [Offline mode]
|
|
||||||
ui->checkBox_offlineMode->setChecked(config()->get(Config::offlineMode).toBool());
|
|
||||||
connect(ui->checkBox_offlineMode, &QCheckBox::toggled, [this](bool checked){
|
|
||||||
config()->set(Config::offlineMode, checked);
|
|
||||||
m_ctx->wallet->setOffline(checked);
|
|
||||||
this->enableWebsocket(checked);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::setupPrivacyTab() {
|
void Settings::setupPrivacyTab() {
|
||||||
|
@ -129,7 +121,7 @@ void Settings::setupPrivacyTab() {
|
||||||
ui->checkBox_disableWebsocket->setChecked(config()->get(Config::disableWebsocket).toBool());
|
ui->checkBox_disableWebsocket->setChecked(config()->get(Config::disableWebsocket).toBool());
|
||||||
connect(ui->checkBox_disableWebsocket, &QCheckBox::toggled, [this](bool checked){
|
connect(ui->checkBox_disableWebsocket, &QCheckBox::toggled, [this](bool checked){
|
||||||
config()->set(Config::disableWebsocket, checked);
|
config()->set(Config::disableWebsocket, checked);
|
||||||
this->enableWebsocket(checked);
|
this->enableWebsocket(!checked);
|
||||||
});
|
});
|
||||||
|
|
||||||
// [Do not write log files to disk]
|
// [Do not write log files to disk]
|
||||||
|
@ -148,6 +140,14 @@ void Settings::setupPrivacyTab() {
|
||||||
connect(ui->spinBox_inactivityLockTimeout, QOverload<int>::of(&QSpinBox::valueChanged), [](int value){
|
connect(ui->spinBox_inactivityLockTimeout, QOverload<int>::of(&QSpinBox::valueChanged), [](int value){
|
||||||
config()->set(Config::inactivityLockTimeout, value);
|
config()->set(Config::inactivityLockTimeout, value);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// [Offline mode]
|
||||||
|
ui->checkBox_offlineMode->setChecked(config()->get(Config::offlineMode).toBool());
|
||||||
|
connect(ui->checkBox_offlineMode, &QCheckBox::toggled, [this](bool checked){
|
||||||
|
config()->set(Config::offlineMode, checked);
|
||||||
|
m_ctx->wallet->setOffline(checked);
|
||||||
|
this->enableWebsocket(!checked);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::setupNodeTab() {
|
void Settings::setupNodeTab() {
|
||||||
|
@ -261,6 +261,8 @@ void Settings::enableWebsocket(bool enabled) {
|
||||||
} else {
|
} else {
|
||||||
websocketNotifier()->websocketClient.stop();
|
websocketNotifier()->websocketClient.stop();
|
||||||
}
|
}
|
||||||
|
ui->nodeWidget->onWebsocketStatusChanged();
|
||||||
|
emit websocketStatusChanged(enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
Settings::~Settings() = default;
|
Settings::~Settings() = default;
|
|
@ -28,6 +28,7 @@ signals:
|
||||||
void skinChanged(QString skinName);
|
void skinChanged(QString skinName);
|
||||||
void blockExplorerChanged(QString blockExplorer);
|
void blockExplorerChanged(QString blockExplorer);
|
||||||
void amountPrecisionChanged(int precision);
|
void amountPrecisionChanged(int precision);
|
||||||
|
void websocketStatusChanged(bool enabled);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void checkboxExternalLinkWarn();
|
void checkboxExternalLinkWarn();
|
||||||
|
|
|
@ -522,6 +522,10 @@ void WindowManager::onTorSettingsChanged() {
|
||||||
emit torSettingsChanged();
|
emit torSettingsChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WindowManager::onWebsocketStatusChanged(bool enabled) {
|
||||||
|
emit websocketStatusChanged(enabled);
|
||||||
|
}
|
||||||
|
|
||||||
void WindowManager::initWS() {
|
void WindowManager::initWS() {
|
||||||
if (config()->get(Config::offlineMode).toBool()) {
|
if (config()->get(Config::offlineMode).toBool()) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -32,9 +32,11 @@ public:
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void torSettingsChanged();
|
void torSettingsChanged();
|
||||||
|
void websocketStatusChanged(bool enabled);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void onTorSettingsChanged();
|
void onTorSettingsChanged();
|
||||||
|
void onWebsocketStatusChanged(bool enabled);
|
||||||
void tryOpenWallet(const QString &path, const QString &password);
|
void tryOpenWallet(const QString &path, const QString &password);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
|
@ -47,6 +47,8 @@ NodeWidget::NodeWidget(QWidget *parent)
|
||||||
|
|
||||||
connect(ui->customView, &QTreeView::doubleClicked, this, &NodeWidget::onContextConnect);
|
connect(ui->customView, &QTreeView::doubleClicked, this, &NodeWidget::onContextConnect);
|
||||||
connect(ui->wsView, &QTreeView::doubleClicked, this, &NodeWidget::onContextConnect);
|
connect(ui->wsView, &QTreeView::doubleClicked, this, &NodeWidget::onContextConnect);
|
||||||
|
|
||||||
|
this->onWebsocketStatusChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void NodeWidget::onShowWSContextMenu(const QPoint &pos) {
|
void NodeWidget::onShowWSContextMenu(const QPoint &pos) {
|
||||||
|
@ -65,6 +67,13 @@ void NodeWidget::onShowCustomContextMenu(const QPoint &pos) {
|
||||||
this->showContextMenu(pos, node);
|
this->showContextMenu(pos, node);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NodeWidget::onWebsocketStatusChanged() {
|
||||||
|
bool disabled = config()->get(Config::disableWebsocket).toBool() || config()->get(Config::offlineMode).toBool();
|
||||||
|
QString labelText = disabled ? "From cached list" : "From websocket (recommended)";
|
||||||
|
ui->radioButton_websocket->setText(labelText);
|
||||||
|
ui->wsView->setColumnHidden(1, disabled);
|
||||||
|
}
|
||||||
|
|
||||||
void NodeWidget::showContextMenu(const QPoint &pos, const FeatherNode &node) {
|
void NodeWidget::showContextMenu(const QPoint &pos, const FeatherNode &node) {
|
||||||
QMenu menu(this);
|
QMenu menu(this);
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,7 @@ public slots:
|
||||||
void onCustomAddClicked();
|
void onCustomAddClicked();
|
||||||
void onShowWSContextMenu(const QPoint &pos);
|
void onShowWSContextMenu(const QPoint &pos);
|
||||||
void onShowCustomContextMenu(const QPoint &pos);
|
void onShowCustomContextMenu(const QPoint &pos);
|
||||||
|
void onWebsocketStatusChanged();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onContextConnect();
|
void onContextConnect();
|
||||||
|
|
|
@ -134,6 +134,10 @@ bool XMRigWidget::isMining() {
|
||||||
return m_isMining;
|
return m_isMining;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void XMRigWidget::setDownloadsTabEnabled(bool enabled) {
|
||||||
|
ui->tabWidget->setTabVisible(2, enabled);
|
||||||
|
}
|
||||||
|
|
||||||
void XMRigWidget::onWalletClosed() {
|
void XMRigWidget::onWalletClosed() {
|
||||||
this->onStopClicked();
|
this->onStopClicked();
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@ public:
|
||||||
QStandardItemModel *model();
|
QStandardItemModel *model();
|
||||||
|
|
||||||
bool isMining();
|
bool isMining();
|
||||||
|
void setDownloadsTabEnabled(bool enabled);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void onWalletClosed();
|
void onWalletClosed();
|
||||||
|
|
Loading…
Reference in a new issue