plugins: remove reddit

This commit is contained in:
tobtoht 2024-05-07 21:45:57 +02:00
parent 8d814a16b3
commit c2701c00dd
No known key found for this signature in database
GPG key ID: E45B10DD027D2472
16 changed files with 3 additions and 552 deletions

View file

@ -31,7 +31,6 @@ option(WITH_PLUGIN_HOME "Include Home tab plugin" ON)
option(WITH_PLUGIN_TICKERS "Include Tickers Home plugin" ON) option(WITH_PLUGIN_TICKERS "Include Tickers Home plugin" ON)
option(WITH_PLUGIN_CROWDFUNDING "Include Crowdfunding Home plugin" ON) option(WITH_PLUGIN_CROWDFUNDING "Include Crowdfunding Home plugin" ON)
option(WITH_PLUGIN_BOUNTIES "Include Bounties Home plugin" ON) option(WITH_PLUGIN_BOUNTIES "Include Bounties Home plugin" ON)
option(WITH_PLUGIN_REDDIT "Include Reddit Home plugin" ON)
option(WITH_PLUGIN_REVUO "Include Revuo Home plugin" ON) option(WITH_PLUGIN_REVUO "Include Revuo Home plugin" ON)
option(WITH_PLUGIN_CALC "Include Calc tab plugin" ON) option(WITH_PLUGIN_CALC "Include Calc tab plugin" ON)
option(WITH_PLUGIN_XMRIG "Include XMRig plugin" ON) option(WITH_PLUGIN_XMRIG "Include XMRig plugin" ON)

View file

@ -352,13 +352,6 @@ void Settings::setupPluginsTab() {
void Settings::setupMiscTab() { void Settings::setupMiscTab() {
// [Block explorer] // [Block explorer]
ui->blockExplorerConfigureWidget->setup("Block explorers", Config::blockExplorers, Config::blockExplorer, {"%txid%"}); ui->blockExplorerConfigureWidget->setup("Block explorers", Config::blockExplorers, Config::blockExplorer, {"%txid%"});
// [Reddit frontend]
ui->comboBox_redditFrontend->setCurrentIndex(ui->comboBox_redditFrontend->findText(conf()->get(Config::redditFrontend).toString()));
connect(ui->comboBox_redditFrontend, QOverload<int>::of(&QComboBox::currentIndexChanged), [this]{
QString redditFrontend = ui->comboBox_redditFrontend->currentText();
conf()->set(Config::redditFrontend, redditFrontend);
});
} }
void Settings::onProxySettingsChanged() { void Settings::onProxySettingsChanged() {

View file

@ -1067,48 +1067,6 @@
<item> <item>
<widget class="UrlListConfigureWidget" name="blockExplorerConfigureWidget" native="true"/> <widget class="UrlListConfigureWidget" name="blockExplorerConfigureWidget" native="true"/>
</item> </item>
<item>
<widget class="QLabel" name="label_18">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Reddit frontend:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox_redditFrontend">
<item>
<property name="text">
<string>old.reddit.com</string>
</property>
</item>
<item>
<property name="text">
<string>old.reddittorjg6rue252oqsxryoxengawnmo46qy4kyii5wtqnwfj4ooad.onion</string>
</property>
</item>
<item>
<property name="text">
<string>reddit.com</string>
</property>
</item>
<item>
<property name="text">
<string>reddittorjg6rue252oqsxryoxengawnmo46qy4kyii5wtqnwfj4ooad.onion</string>
</property>
</item>
<item>
<property name="text">
<string>teddit.net</string>
</property>
</item>
</widget>
</item>
<item> <item>
<spacer name="verticalSpacer_7"> <spacer name="verticalSpacer_7">
<property name="orientation"> <property name="orientation">

View file

@ -100,7 +100,7 @@
<item row="4" column="0"> <item row="4" column="0">
<widget class="QLabel" name="label_5"> <widget class="QLabel" name="label_5">
<property name="text"> <property name="text">
<string>Reddit:</string> <string>Lemmy:</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -158,7 +158,7 @@
<item row="4" column="1"> <item row="4" column="1">
<widget class="QLabel" name="label_12"> <widget class="QLabel" name="label_12">
<property name="text"> <property name="text">
<string>/r/FeatherWallet</string> <string>monero.town/c/featherwallet</string>
</property> </property>
<property name="textInteractionFlags"> <property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set> <set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>

View file

@ -1,108 +0,0 @@
// SPDX-License-Identifier: BSD-3-Clause
// SPDX-FileCopyrightText: 2020-2024 The Monero Project
#include "RedditModel.h"
RedditModel::RedditModel(QObject *parent)
: QAbstractTableModel(parent)
{
}
void RedditModel::clear() {
beginResetModel();
m_posts.clear();
endResetModel();
}
void RedditModel::updatePosts(const QList<QSharedPointer<RedditPost>>& posts) {
beginResetModel();
m_posts.clear();
for (const auto& post : posts) {
m_posts.push_back(post);
}
endResetModel();
}
int RedditModel::rowCount(const QModelIndex &parent) const{
if (parent.isValid()) {
return 0;
}
return m_posts.count();
}
int RedditModel::columnCount(const QModelIndex &parent) const
{
if (parent.isValid()) {
return 0;
}
return ModelColumn::COUNT;
}
QVariant RedditModel::data(const QModelIndex &index, int role) const
{
if (!index.isValid() || index.row() < 0 || index.row() >= m_posts.count())
return QVariant();
QSharedPointer<RedditPost> post = m_posts.at(index.row());
if(role == Qt::DisplayRole || role == Qt::UserRole) {
switch(index.column()) {
case Title:
return post->title;
case Author:
return post->author;
case Comments: {
if (role == Qt::UserRole) {
return post->comments;
}
return QString::number(post->comments);
}
default:
return QVariant();
}
}
else if (role == Qt::TextAlignmentRole) {
switch(index.column()) {
case Comments:
return Qt::AlignRight;
default:
return QVariant();
}
}
return QVariant();
}
QVariant RedditModel::headerData(int section, Qt::Orientation orientation, int role) const
{
if (role != Qt::DisplayRole) {
return QVariant();
}
if (orientation == Qt::Horizontal)
{
switch(section) {
case Title:
return QString("Reddit Post");
case Author:
return QString("Author");
case Comments:
return QString(" Comments ");
default:
return QVariant();
}
}
return QVariant();
}
QSharedPointer<RedditPost> RedditModel::post(int row) {
if (row < 0 || row >= m_posts.size()) {
qCritical("%s: no reddit post for index %d", __FUNCTION__, row);
return QSharedPointer<RedditPost>();
}
return m_posts.at(row);
}

View file

@ -1,41 +0,0 @@
// SPDX-License-Identifier: BSD-3-Clause
// SPDX-FileCopyrightText: 2020-2024 The Monero Project
#ifndef FEATHER_REDDITMODEL_H
#define FEATHER_REDDITMODEL_H
#include <QAbstractTableModel>
#include <QSharedPointer>
#include "RedditPost.h"
class RedditModel : public QAbstractTableModel
{
Q_OBJECT
public:
enum ModelColumn
{
Title = 0,
Author,
Comments,
COUNT
};
explicit RedditModel(QObject *parent);
int rowCount(const QModelIndex &parent) const override;
int columnCount(const QModelIndex &parent) const override;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
void clear();
void updatePosts(const QList<QSharedPointer<RedditPost>>& posts);
QSharedPointer<RedditPost> post(int row);
private:
QList<QSharedPointer<RedditPost>> m_posts;
};
#endif //FEATHER_REDDITMODEL_H

View file

@ -1,59 +0,0 @@
// SPDX-License-Identifier: BSD-3-Clause
// SPDX-FileCopyrightText: 2020-2024 The Monero Project
#include "RedditPlugin.h"
#include "plugins/PluginRegistry.h"
#include "RedditWidget.h"
RedditPlugin::RedditPlugin()
{
}
void RedditPlugin::initialize(Wallet *wallet, QObject *parent) {
this->setParent(parent);
m_redditWidget = new RedditWidget(nullptr);
connect(m_redditWidget, &RedditWidget::setStatusText, this, &Plugin::setStatusText);
}
QString RedditPlugin::id() {
return "reddit";
}
int RedditPlugin::idx() const {
return 30;
}
QString RedditPlugin::parent() {
return "home";
}
QString RedditPlugin::displayName() {
return "Reddit";
}
QString RedditPlugin::description() {
return {};
}
QString RedditPlugin::icon() {
return {};
}
QStringList RedditPlugin::socketData() {
return {"reddit"};
}
Plugin::PluginType RedditPlugin::type() {
return Plugin::PluginType::TAB;
}
QWidget* RedditPlugin::tab() {
return m_redditWidget;
}
const bool RedditPlugin::registered = [] {
PluginRegistry::registerPlugin(RedditPlugin::create());
PluginRegistry::getInstance().registerPluginCreator(&RedditPlugin::create);
return true;
}();

View file

@ -1,39 +0,0 @@
// SPDX-License-Identifier: BSD-3-Clause
// SPDX-FileCopyrightText: 2020-2024 The Monero Project
#ifndef REDDITPLUGIN_H
#define REDDITPLUGIN_H
#include "plugins/Plugin.h"
#include "RedditWidget.h"
#include "plugins/PluginRegistry.h"
class RedditPlugin : public Plugin {
Q_OBJECT
public:
explicit RedditPlugin();
QString id() override;
int idx() const override;
QString parent() override;
QString displayName() override;
QString description() override;
QString icon() override;
QStringList socketData() override;
PluginType type() override;
QWidget* tab() override;
void initialize(Wallet *wallet, QObject *parent) override;
static RedditPlugin* create() { return new RedditPlugin(); }
private:
RedditWidget* m_redditWidget = nullptr;
static const bool registered;
};
#endif //REDDITPLUGIN_H

View file

@ -1,19 +0,0 @@
// SPDX-License-Identifier: BSD-3-Clause
// SPDX-FileCopyrightText: 2020-2024 The Monero Project
#ifndef FEATHER_REDDITPOST_H
#define FEATHER_REDDITPOST_H
#include <QString>
struct RedditPost {
RedditPost(const QString &title, const QString &author, const QString &permalink, int comments)
: title(title), author(author), permalink(permalink), comments(comments){};
QString title;
QString author;
QString permalink;
int comments;
};
#endif //FEATHER_REDDITPOST_H

View file

@ -1,10 +0,0 @@
// SPDX-License-Identifier: BSD-3-Clause
// SPDX-FileCopyrightText: 2020-2024 The Monero Project
#include "RedditProxyModel.h"
RedditProxyModel::RedditProxyModel(QObject *parent)
: QSortFilterProxyModel(parent)
{
setSortRole(Qt::UserRole);
}

View file

@ -1,17 +0,0 @@
// SPDX-License-Identifier: BSD-3-Clause
// SPDX-FileCopyrightText: 2020-2024 The Monero Project
#ifndef REDDITPROXYMODEL_H
#define REDDITPROXYMODEL_H
#include <QSortFilterProxyModel>
class RedditProxyModel : public QSortFilterProxyModel
{
Q_OBJECT
public:
explicit RedditProxyModel(QObject* parent = nullptr);
};
#endif //REDDITPROXYMODEL_H

View file

@ -1,99 +0,0 @@
// SPDX-License-Identifier: BSD-3-Clause
// SPDX-FileCopyrightText: 2020-2024 The Monero Project
#include "RedditWidget.h"
#include "ui_RedditWidget.h"
#include <QTableWidget>
#include "RedditModel.h"
#include "utils/Utils.h"
#include "utils/config.h"
#include "utils/WebsocketNotifier.h"
RedditWidget::RedditWidget(QWidget *parent)
: QWidget(parent)
, ui(new Ui::RedditWidget)
, m_model(new RedditModel(this))
, m_contextMenu(new QMenu(this))
{
ui->setupUi(this);
m_proxyModel = new RedditProxyModel(this);
m_proxyModel->setSourceModel(m_model);
ui->tableView->setModel(m_proxyModel);
ui->tableView->setSortingEnabled(true);
ui->tableView->sortByColumn(2, Qt::DescendingOrder);
this->setupTable();
m_contextMenu->addAction("View thread", this, &RedditWidget::linkClicked);
m_contextMenu->addAction("Copy link", this, &RedditWidget::copyUrl);
connect(ui->tableView, &QHeaderView::customContextMenuRequested, this, &RedditWidget::showContextMenu);
connect(ui->tableView, &QTableView::doubleClicked, this, &RedditWidget::linkClicked);
ui->tableView->verticalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
connect(websocketNotifier(), &WebsocketNotifier::dataReceived, this, [this](const QString& type, const QJsonValue& json) {
if (type == "reddit") {
QJsonArray reddit_data = json.toArray();
QList<QSharedPointer<RedditPost>> l;
for (auto &&entry: reddit_data) {
auto obj = entry.toObject();
auto redditPost = new RedditPost(
obj.value("title").toString(),
obj.value("author").toString(),
obj.value("permalink").toString(),
obj.value("comments").toInt());
QSharedPointer<RedditPost> r = QSharedPointer<RedditPost>(redditPost);
l.append(r);
}
m_model->updatePosts(l);
}
});
}
void RedditWidget::linkClicked() {
QModelIndex index = m_proxyModel->mapToSource(ui->tableView->currentIndex());
auto post = m_model->post(index.row());
if (post)
Utils::externalLinkWarning(this, this->getLink(post->permalink));
}
void RedditWidget::copyUrl() {
QModelIndex index = m_proxyModel->mapToSource(ui->tableView->currentIndex());
auto post = m_model->post(index.row());
if (post) {
Utils::copyToClipboard(this->getLink(post->permalink));
emit setStatusText("Link copied to clipboard", true, 1000);
}
}
void RedditWidget::setupTable() {
ui->tableView->verticalHeader()->setVisible(false);
ui->tableView->setSelectionBehavior(QAbstractItemView::SelectRows);
ui->tableView->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
ui->tableView->horizontalHeader()->setSectionResizeMode( 0, QHeaderView::Stretch);
}
void RedditWidget::showContextMenu(const QPoint &pos) {
QModelIndex index = ui->tableView->indexAt(pos);
if (!index.isValid()) {
return;
}
m_contextMenu->exec(ui->tableView->viewport()->mapToGlobal(pos));
}
QString RedditWidget::getLink(const QString &permaLink) {
QString redditFrontend = conf()->get(Config::redditFrontend).toString();
return QString("https://%1%2").arg(redditFrontend, permaLink);
}
RedditWidget::~RedditWidget() = default;

View file

@ -1,44 +0,0 @@
// SPDX-License-Identifier: BSD-3-Clause
// SPDX-FileCopyrightText: 2020-2024 The Monero Project
#ifndef FEATHER_REDDITWIDGET_H
#define FEATHER_REDDITWIDGET_H
#include <QItemSelection>
#include <QMenu>
#include <QWidget>
#include "RedditModel.h"
#include "RedditProxyModel.h"
namespace Ui {
class RedditWidget;
}
class RedditWidget : public QWidget
{
Q_OBJECT
public:
explicit RedditWidget(QWidget *parent = nullptr);
~RedditWidget();
public slots:
void linkClicked();
signals:
void setStatusText(const QString &msg, bool override, int timeout);
private:
void setupTable();
void showContextMenu(const QPoint &pos);
void copyUrl();
QString getLink(const QString &permaLink);
QScopedPointer<Ui::RedditWidget> ui;
RedditModel* const m_model;
RedditProxyModel* m_proxyModel;
QMenu *m_contextMenu;
};
#endif // FEATHER_REDDITWIDGET_H

View file

@ -1,61 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>RedditWidget</class>
<widget class="QWidget" name="RedditWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>492</width>
<height>409</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>4</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QTableView" name="tableView">
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::SingleSelection</enum>
</property>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum>
</property>
<property name="sortingEnabled">
<bool>false</bool>
</property>
<attribute name="horizontalHeaderStretchLastSection">
<bool>false</bool>
</attribute>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
<slots>
<slot>linkClicked()</slot>
</slots>
</ui>

View file

@ -104,7 +104,6 @@ static const QHash<Config::ConfigKey, ConfigDirective> configStrings = {
"http://blkchairbknpn73cfjhevhla7rkp4ed5gg2knctvv7it4lioy22defid.onion/monero/transaction/%txid%", "http://blkchairbknpn73cfjhevhla7rkp4ed5gg2knctvv7it4lioy22defid.onion/monero/transaction/%txid%",
"http://127.0.0.1:31312/tx?id=%txid%"}}}, "http://127.0.0.1:31312/tx?id=%txid%"}}},
{Config::blockExplorer,{QS("blockExplorer"), "https://xmrchain.net/tx/%txid%"}}, {Config::blockExplorer,{QS("blockExplorer"), "https://xmrchain.net/tx/%txid%"}},
{Config::redditFrontend, {QS("redditFrontend"), "old.reddit.com"}},
{Config::bountiesFrontend, {QS("bountiesFrontend"), "https://bounties.monero.social"}}, {Config::bountiesFrontend, {QS("bountiesFrontend"), "https://bounties.monero.social"}},
{Config::lastPath, {QS("lastPath"), QDir::homePath()}}, {Config::lastPath, {QS("lastPath"), QDir::homePath()}},
@ -130,7 +129,7 @@ static const QHash<Config::ConfigKey, ConfigDirective> configStrings = {
{Config::useLocalTor, {QS("useLocalTor"), false}}, {Config::useLocalTor, {QS("useLocalTor"), false}},
{Config::initSyncThreshold, {QS("initSyncThreshold"), 360}}, {Config::initSyncThreshold, {QS("initSyncThreshold"), 360}},
{Config::enabledPlugins, {QS("enabledPlugins"), QStringList{"tickers", "crowdfunding", "bounties", "reddit", "revuo", "calc", "xmrig"}}}, {Config::enabledPlugins, {QS("enabledPlugins"), QStringList{"tickers", "crowdfunding", "bounties", "revuo", "calc", "xmrig"}}},
{Config::restartRequired, {QS("restartRequired"), false}}, {Config::restartRequired, {QS("restartRequired"), false}},
{Config::tickers, {QS("tickers"), QStringList{"XMR", "BTC", "XMR/BTC"}}}, {Config::tickers, {QS("tickers"), QStringList{"XMR", "BTC", "XMR/BTC"}}},

View file

@ -127,7 +127,6 @@ public:
// Misc // Misc
blockExplorers, blockExplorers,
blockExplorer, blockExplorer,
redditFrontend,
bountiesFrontend, // unused bountiesFrontend, // unused
lastPath, lastPath,