diff --git a/src/SettingsDialog.cpp b/src/SettingsDialog.cpp index 65bed8b5..bc227e00 100644 --- a/src/SettingsDialog.cpp +++ b/src/SettingsDialog.cpp @@ -16,6 +16,7 @@ #include "utils/WebsocketNotifier.h" #include "widgets/NetworkProxyWidget.h" #include "utils/ColorScheme.h" +#include "utils/DaemonManager.h" Settings::Settings(Nodes *nodes, QWidget *parent) : QDialog(parent) @@ -169,6 +170,15 @@ void Settings::setupNetworkTab() { ui->nodeWidget->setupUI(m_nodes); connect(ui->nodeWidget, &NodeWidget::nodeSourceChanged, m_nodes, &Nodes::onNodeSourceChanged); connect(ui->nodeWidget, &NodeWidget::connectToNode, m_nodes, QOverload::of(&Nodes::connectToNode)); + // wowlet: built-in node on/off — start/stop the embedded wownerod, then reconnect (autoConnect + // honours Config::runLocalNode: local 127.0.0.1 when on, the selected remote when off). + connect(ui->nodeWidget, &NodeWidget::localNodeToggled, this, [this](bool enabled){ + if (enabled) + daemonManager()->start(); + else + daemonManager()->stop(); + m_nodes->autoConnect(true); + }); } else { m_nodes = new Nodes(this, nullptr); ui->nodeWidget->setupUI(m_nodes); diff --git a/src/widgets/NodeWidget.cpp b/src/widgets/NodeWidget.cpp index 8a776516..de9a4ce7 100644 --- a/src/widgets/NodeWidget.cpp +++ b/src/widgets/NodeWidget.cpp @@ -5,10 +5,13 @@ #include "ui_NodeWidget.h" #include +#include #include #include +#include #include #include +#include #include "model/NodeModel.h" #include "utils/Icons.h" @@ -52,6 +55,36 @@ NodeWidget::NodeWidget(QWidget *parent) ui->frame_addCustomNodes->setVisible(index); this->onWebsocketStatusChanged(); + + // wowlet: built-in node toggle + the "why run your own node" messaging. Running your own node is + // a privacy win (no remote operator sees your wallet) AND it strengthens the Wownero network by + // adding a peer — a deliberate differentiator we surface clearly here. + m_localNodeCheck = new QCheckBox(tr("Run your own Wownero node (much recommended)"), this); + m_localNodeCheck->setChecked(conf()->get(Config::runLocalNode).toBool()); + auto *localNodeInfo = new QLabel( + tr("wowlet bundles its own node so you can be your own boss — and every node keeps the Wownero " + "network strong + decentralized. 🐕 Uncheck to use a remote node instead."), this); + localNodeInfo->setWordWrap(true); + localNodeInfo->setStyleSheet("color: gray;"); + + if (auto *vlayout = qobject_cast(this->layout())) { + vlayout->insertWidget(0, localNodeInfo); + vlayout->insertWidget(0, m_localNodeCheck); + } + + auto applyLocalNodeState = [this](bool on) { + // When the built-in node is on, the remote list is overridden — grey it out so it's obvious. + ui->stackedWidget->setEnabled(!on); + ui->checkBox_websocketList->setEnabled(!on); + ui->frame_addCustomNodes->setEnabled(!on); + }; + applyLocalNodeState(m_localNodeCheck->isChecked()); + + connect(m_localNodeCheck, &QCheckBox::toggled, this, [this, applyLocalNodeState](bool checked){ + conf()->set(Config::runLocalNode, checked); + applyLocalNodeState(checked); + emit localNodeToggled(checked); + }); } void NodeWidget::onShowWSContextMenu(const QPoint &pos) { diff --git a/src/widgets/NodeWidget.h b/src/widgets/NodeWidget.h index af76739e..e260839d 100644 --- a/src/widgets/NodeWidget.h +++ b/src/widgets/NodeWidget.h @@ -16,6 +16,7 @@ namespace Ui { } class NodeModel; +class QCheckBox; class NodeWidget : public QWidget { Q_OBJECT @@ -44,12 +45,14 @@ private slots: signals: void connectToNode(FeatherNode node); void nodeSourceChanged(NodeSource nodeSource); + void localNodeToggled(bool enabled); private: void showContextMenu(const QPoint &pos, const FeatherNode &node); FeatherNode selectedNode(); QScopedPointer ui; + QCheckBox *m_localNodeCheck = nullptr; Nodes *m_nodes; NodeModel *m_customModel; NodeModel *m_wsModel;