diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp
index 35b6b00..13b7241 100644
--- a/src/MainWindow.cpp
+++ b/src/MainWindow.cpp
@@ -63,6 +63,7 @@ MainWindow::MainWindow(WindowManager *windowManager, Wallet *wallet, QWidget *pa
// Websocket notifier
connect(websocketNotifier(), &WebsocketNotifier::CCSReceived, ui->ccsWidget->model(), &CCSModel::updateEntries);
connect(websocketNotifier(), &WebsocketNotifier::RedditReceived, ui->redditWidget->model(), &RedditModel::updatePosts);
+ connect(websocketNotifier(), &WebsocketNotifier::RevuoReceived, ui->revuoWidget, &RevuoWidget::updateItems);
connect(websocketNotifier(), &WebsocketNotifier::UpdatesReceived, this, &MainWindow::onUpdatesAvailable);
#ifdef HAS_XMRIG
connect(websocketNotifier(), &WebsocketNotifier::XMRigDownloadsReceived, m_xmrig, &XMRigWidget::onDownloads);
@@ -373,6 +374,10 @@ void MainWindow::initHome() {
connect(ui->ccsWidget, &CCSWidget::selected, this, &MainWindow::showSendScreen);
connect(ui->redditWidget, &RedditWidget::setStatusText, this, &MainWindow::setStatusText);
+ connect(ui->revuoWidget, &RevuoWidget::donate, [this](const QString &address, const QString &description){
+ m_sendWidget->fill(address, description);
+ ui->tabWidget->setCurrentIndex(Tabs::SEND);
+ });
}
void MainWindow::initWalletContext() {
@@ -887,6 +892,7 @@ void MainWindow::updateWidgetIcons() {
m_localMoneroWidget->skinChanged();
#endif
ui->conversionWidget->skinChanged();
+ ui->revuoWidget->skinChanged();
m_statusBtnHwDevice->setIcon(this->hardwareDevicePairedIcon());
}
diff --git a/src/MainWindow.ui b/src/MainWindow.ui
index 9d1602e..cbd3ecb 100644
--- a/src/MainWindow.ui
+++ b/src/MainWindow.ui
@@ -145,6 +145,28 @@
+
+
+ Revuo
+
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+ -
+
+
+
+
@@ -872,6 +894,12 @@
1
+
+ RevuoWidget
+ QWidget
+
+ 1
+
diff --git a/src/utils/WebsocketNotifier.cpp b/src/utils/WebsocketNotifier.cpp
index ad436df..6ffca2d 100644
--- a/src/utils/WebsocketNotifier.cpp
+++ b/src/utils/WebsocketNotifier.cpp
@@ -60,6 +60,11 @@ void WebsocketNotifier::onWSMessage(const QJsonObject &msg) {
emit TxFiatHistoryReceived(txFiatHistory_data);
}
+ else if(cmd == "revuo") {
+ auto revuo_data = msg.value("data").toArray();
+ this->onWSRevuo(revuo_data);
+ }
+
#if defined(CHECK_UPDATES)
else if (cmd == "updates") {
this->onWSUpdates(msg.value("data").toObject());
@@ -176,6 +181,29 @@ void WebsocketNotifier::onWSCCS(const QJsonArray &ccs_data) {
emit CCSReceived(l);
}
+void WebsocketNotifier::onWSRevuo(const QJsonArray &revuo_data) {
+ QList> l;
+
+ for (auto &&entry: revuo_data) {
+ auto obj = entry.toObject();
+
+ QStringList newsbytes;
+ for (const auto &n : obj.value("newsbytes").toArray()) {
+ newsbytes.append(n.toString());
+ }
+
+ auto revuoItem = new RevuoItem(
+ obj.value("title").toString(),
+ obj.value("url").toString(),
+ newsbytes);
+
+ QSharedPointer r = QSharedPointer(revuoItem);
+ l.append(r);
+ }
+
+ emit RevuoReceived(l);
+}
+
void WebsocketNotifier::onWSUpdates(const QJsonObject &updates) {
emit UpdatesReceived(updates);
}
diff --git a/src/utils/WebsocketNotifier.h b/src/utils/WebsocketNotifier.h
index 388a9d4..a0fff99 100644
--- a/src/utils/WebsocketNotifier.h
+++ b/src/utils/WebsocketNotifier.h
@@ -13,6 +13,7 @@
#include "prices.h"
#include "widgets/RedditPost.h"
#include "widgets/CCSEntry.h"
+#include "widgets/RevuoItem.h"
#include "TxFiatHistory.h"
class WebsocketNotifier : public QObject {
@@ -36,6 +37,7 @@ signals:
void FiatRatesReceived(const QJsonObject &fiat_rates);
void RedditReceived(QList> L);
void CCSReceived(QList> L);
+ void RevuoReceived(QList> L);
void TxFiatHistoryReceived(const QJsonObject &data);
void UpdatesReceived(const QJsonObject &updates);
void XMRigDownloadsReceived(const QJsonObject &downloads);
@@ -49,6 +51,7 @@ private slots:
void onWSNodes(const QJsonArray &nodes);
void onWSReddit(const QJsonArray &reddit_data);
void onWSCCS(const QJsonArray &ccs_data);
+ void onWSRevuo(const QJsonArray &revuo_data);
void onWSUpdates(const QJsonObject &updates);
void onWSXMRigDownloads(const QJsonObject &downloads);
diff --git a/src/widgets/RevuoItem.h b/src/widgets/RevuoItem.h
new file mode 100644
index 0000000..c6410fe
--- /dev/null
+++ b/src/widgets/RevuoItem.h
@@ -0,0 +1,19 @@
+// SPDX-License-Identifier: BSD-3-Clause
+// SPDX-FileCopyrightText: 2020-2022 The Monero Project
+
+#ifndef FEATHER_REVUOITEM_H
+#define FEATHER_REVUOITEM_H
+
+#include
+#include
+
+struct RevuoItem {
+ RevuoItem(const QString &title, const QString &url, const QStringList &newsbytes)
+ : title(title), url(url), newsbytes(newsbytes){};
+
+ QString title;
+ QString url;
+ QStringList newsbytes;
+};
+
+#endif //FEATHER_REVUOITEM_H
diff --git a/src/widgets/RevuoWidget.cpp b/src/widgets/RevuoWidget.cpp
new file mode 100644
index 0000000..c6d6621
--- /dev/null
+++ b/src/widgets/RevuoWidget.cpp
@@ -0,0 +1,92 @@
+// SPDX-License-Identifier: BSD-3-Clause
+// SPDX-FileCopyrightText: 2020-2022 The Monero Project
+
+#include "RevuoWidget.h"
+#include "ui_RevuoWidget.h"
+
+#include "utils/ColorScheme.h"
+#include "Utils.h"
+
+RevuoWidget::RevuoWidget(QWidget *parent)
+ : QWidget(parent)
+ , ui(new Ui::RevuoWidget)
+ , m_contextMenu(new QMenu(this))
+{
+ ui->setupUi(this);
+
+ ui->textBrowser->setOpenLinks(false);
+ ui->textBrowser->document()->setDefaultStyleSheet("a {color: white; }");
+ connect(ui->textBrowser, &QTextBrowser::anchorClicked, this, &RevuoWidget::onLinkActivated);
+
+ ui->textBrowser->setText("No item selected
");
+
+ m_contextMenu->addAction("Open link", this, &RevuoWidget::onOpenLink);
+ m_contextMenu->addAction("Donate to author", this, &RevuoWidget::onDonate);
+
+ connect(ui->listWidget, &QListWidget::currentTextChanged, this, &RevuoWidget::onSelectItem);
+ connect(ui->listWidget, &QListWidget::customContextMenuRequested, this, &RevuoWidget::showContextMenu);
+}
+
+void RevuoWidget::updateItems(const QList> &items) {
+ QStringList titles;
+ for (const auto &item : items) {
+ titles << item->title;
+
+ QString text = "Recent News
\n";
+ for (const auto &newsbyte : item->newsbytes) {
+ text += " • " + newsbyte + "
\n";
+ }
+ text += "
\nEnjoy Revuo? Consider a donation to the author.";
+
+ m_items[item->title] = text;
+ m_links[item->title] = item->url;
+ }
+
+ ui->listWidget->clear();
+ ui->listWidget->addItems(titles);
+ ui->listWidget->setCurrentRow(0);
+}
+
+void RevuoWidget::onSelectItem(const QString &item) {
+ auto *currentItem = ui->listWidget->currentItem();
+ if (currentItem == nullptr) {
+ return;
+ }
+ QString title = currentItem->text();
+ ui->textBrowser->setText(m_items[title]);
+}
+
+void RevuoWidget::onLinkActivated(const QUrl &link) {
+ if (link.host() == "donate-revuo") {
+ this->onDonate();
+ return;
+ }
+
+ Utils::externalLinkWarning(this, link.toString());
+}
+
+void RevuoWidget::showContextMenu(const QPoint &pos) {
+ m_contextMenu->exec(ui->listWidget->viewport()->mapToGlobal(pos));
+}
+
+void RevuoWidget::onOpenLink() {
+ QString currentItem = ui->listWidget->currentItem()->text();
+ Utils::externalLinkWarning(this, m_links[currentItem]);
+}
+
+void RevuoWidget::onDonate() {
+ emit donate("89Esx7ZAoVcD9wiDw57gxgS7m52sFEEbQiFC4qq18YZy3CdcsXvJ67FYdcDFbmYEGK7xerxgmDptd1C2xLstCbgF3RUhSMT", "Donation to Revuo Monero");
+}
+
+void RevuoWidget::skinChanged() {
+ QString color = "black";
+ if (ColorScheme::hasDarkBackground(this)) {
+ color = "white";
+ }
+ auto stylesheet = QString("a {color: %1; }").arg(color);
+
+ ui->textBrowser->document()->setDefaultStyleSheet(stylesheet);
+ this->onSelectItem("");
+}
+
+RevuoWidget::~RevuoWidget() = default;
\ No newline at end of file
diff --git a/src/widgets/RevuoWidget.h b/src/widgets/RevuoWidget.h
new file mode 100644
index 0000000..546148f
--- /dev/null
+++ b/src/widgets/RevuoWidget.h
@@ -0,0 +1,47 @@
+// SPDX-License-Identifier: BSD-3-Clause
+// SPDX-FileCopyrightText: 2020-2022 The Monero Project
+
+#ifndef FEATHER_REVUOWIDGET_H
+#define FEATHER_REVUOWIDGET_H
+
+#include
+#include
+
+#include "RevuoItem.h"
+
+namespace Ui {
+ class RevuoWidget;
+}
+
+class RevuoWidget : public QWidget
+{
+ Q_OBJECT
+
+public:
+ explicit RevuoWidget(QWidget *parent = nullptr);
+ ~RevuoWidget();
+
+signals:
+ void donate(const QString &address, const QString &description);
+
+public slots:
+ void updateItems(const QList>& items);
+ void skinChanged();
+
+private slots:
+ void onLinkActivated(const QUrl &link);
+ void onSelectItem(const QString &item);
+ void onOpenLink();
+ void onDonate();
+ void showContextMenu(const QPoint &pos);
+
+private:
+ QScopedPointer ui;
+
+ QMenu *m_contextMenu;
+ QHash m_items;
+ QHash m_links;
+};
+
+
+#endif //FEATHER_REVUOWIDGET_H
diff --git a/src/widgets/RevuoWidget.ui b/src/widgets/RevuoWidget.ui
new file mode 100644
index 0000000..6d4d51e
--- /dev/null
+++ b/src/widgets/RevuoWidget.ui
@@ -0,0 +1,47 @@
+
+
+ RevuoWidget
+
+
+
+ 0
+ 0
+ 945
+ 508
+
+
+
+ Form
+
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+ -
+
+
+ Qt::CustomContextMenu
+
+
+
+ -
+
+
+
+
+
+
+
+
+
+
+