From 5b36d44ed228ecfda5e5bf49973faf1181af5163 Mon Sep 17 00:00:00 2001 From: tobtoht Date: Mon, 11 Aug 2025 14:26:22 +0200 Subject: [PATCH] plugins: remove Crowdfunding and Bounties --- CMakeLists.txt | 2 - src/plugins/bounties/BountiesModel.cpp | 122 ------------------ src/plugins/bounties/BountiesModel.h | 43 ------ src/plugins/bounties/BountiesPlugin.cpp | 59 --------- src/plugins/bounties/BountiesPlugin.h | 36 ------ src/plugins/bounties/BountiesProxyModel.cpp | 10 -- src/plugins/bounties/BountiesProxyModel.h | 17 --- src/plugins/bounties/BountiesWidget.cpp | 100 -------------- src/plugins/bounties/BountiesWidget.h | 45 ------- src/plugins/bounties/BountiesWidget.ui | 46 ------- src/plugins/bounties/Bounty.h | 23 ---- src/plugins/crowdfunding/CCSEntry.h | 26 ---- src/plugins/crowdfunding/CCSModel.cpp | 100 -------------- src/plugins/crowdfunding/CCSModel.h | 43 ------ .../crowdfunding/CCSProgressDelegate.cpp | 39 ------ .../crowdfunding/CCSProgressDelegate.h | 24 ---- src/plugins/crowdfunding/CCSWidget.cpp | 103 --------------- src/plugins/crowdfunding/CCSWidget.h | 45 ------- src/plugins/crowdfunding/CCSWidget.ui | 56 -------- .../crowdfunding/CrowdfundingPlugin.cpp | 59 --------- src/plugins/crowdfunding/CrowdfundingPlugin.h | 35 ----- 21 files changed, 1033 deletions(-) delete mode 100644 src/plugins/bounties/BountiesModel.cpp delete mode 100644 src/plugins/bounties/BountiesModel.h delete mode 100644 src/plugins/bounties/BountiesPlugin.cpp delete mode 100644 src/plugins/bounties/BountiesPlugin.h delete mode 100644 src/plugins/bounties/BountiesProxyModel.cpp delete mode 100644 src/plugins/bounties/BountiesProxyModel.h delete mode 100644 src/plugins/bounties/BountiesWidget.cpp delete mode 100644 src/plugins/bounties/BountiesWidget.h delete mode 100644 src/plugins/bounties/BountiesWidget.ui delete mode 100644 src/plugins/bounties/Bounty.h delete mode 100644 src/plugins/crowdfunding/CCSEntry.h delete mode 100644 src/plugins/crowdfunding/CCSModel.cpp delete mode 100644 src/plugins/crowdfunding/CCSModel.h delete mode 100644 src/plugins/crowdfunding/CCSProgressDelegate.cpp delete mode 100644 src/plugins/crowdfunding/CCSProgressDelegate.h delete mode 100644 src/plugins/crowdfunding/CCSWidget.cpp delete mode 100644 src/plugins/crowdfunding/CCSWidget.h delete mode 100644 src/plugins/crowdfunding/CCSWidget.ui delete mode 100644 src/plugins/crowdfunding/CrowdfundingPlugin.cpp delete mode 100644 src/plugins/crowdfunding/CrowdfundingPlugin.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 31a7872f..0f7f5bdb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,8 +33,6 @@ option(TOR_INSTALLED "Is Tor installed on the filesystem?" OFF) # Plugins option(WITH_PLUGIN_HOME "Include Home tab plugin" ON) option(WITH_PLUGIN_TICKERS "Include Tickers Home plugin" ON) -option(WITH_PLUGIN_CROWDFUNDING "Include Crowdfunding Home plugin" ON) -option(WITH_PLUGIN_BOUNTIES "Include Bounties Home plugin" ON) option(WITH_PLUGIN_REVUO "Include Revuo Home plugin" ON) option(WITH_PLUGIN_CALC "Include Calc tab plugin" ON) diff --git a/src/plugins/bounties/BountiesModel.cpp b/src/plugins/bounties/BountiesModel.cpp deleted file mode 100644 index e06c976d..00000000 --- a/src/plugins/bounties/BountiesModel.cpp +++ /dev/null @@ -1,122 +0,0 @@ -// SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: The Monero Project - -#include "BountiesModel.h" - -BountiesModel::BountiesModel(QObject *parent) - : QAbstractTableModel(parent) -{ - -} - -void BountiesModel::clear() { - beginResetModel(); - - m_bounties.clear(); - - endResetModel(); -} - -void BountiesModel::updateBounties(const QList> &posts) { - beginResetModel(); - - m_bounties.clear(); - for (const auto& post : posts) { - m_bounties.push_back(post); - } - - endResetModel(); -} - -int BountiesModel::rowCount(const QModelIndex &parent) const{ - if (parent.isValid()) { - return 0; - } - return m_bounties.count(); -} - -int BountiesModel::columnCount(const QModelIndex &parent) const -{ - if (parent.isValid()) { - return 0; - } - return ModelColumn::COUNT; -} - -QVariant BountiesModel::data(const QModelIndex &index, int role) const -{ - if (!index.isValid() || index.row() < 0 || index.row() >= m_bounties.count()) - return {}; - - QSharedPointer post = m_bounties.at(index.row()); - - if(role == Qt::DisplayRole || role == Qt::UserRole) { - switch(index.column()) { - case Votes: { - if (role == Qt::UserRole) { - return post->votes; - } - return QString::number(post->votes); - } - case Title: - return post->title; - case Status: - return post->status; - case Bounty: { - if (role == Qt::UserRole) { - return post->bountyAmount; - } - - if (post->bountyAmount > 0) { - return QString("%1 XMR").arg(QString::number(post->bountyAmount, 'f', 5)); - } - return "None"; - } - default: - return {}; - } - } - else if (role == Qt::TextAlignmentRole) { - switch(index.column()) { - case Votes: - case Status: - case Bounty: - return Qt::AlignRight; - default: - return {}; - } - } - return {}; -} - -QVariant BountiesModel::headerData(int section, Qt::Orientation orientation, int role) const -{ - if (role != Qt::DisplayRole) { - return QVariant(); - } - if (orientation == Qt::Horizontal) - { - switch(section) { - case Votes: - return QString("Score "); - case Title: - return QString("Title"); - case Status: - return QString(" Status "); - case Bounty: - return QString(" Bounty "); - default: - return QVariant(); - } - } - return QVariant(); -} - -QSharedPointer BountiesModel::post(int row) { - if (row < 0 || row >= m_bounties.size()) { - qCritical("%s: no reddit post for index %d", __FUNCTION__, row); - return QSharedPointer(); - } - - return m_bounties.at(row); -} \ No newline at end of file diff --git a/src/plugins/bounties/BountiesModel.h b/src/plugins/bounties/BountiesModel.h deleted file mode 100644 index 5084c606..00000000 --- a/src/plugins/bounties/BountiesModel.h +++ /dev/null @@ -1,43 +0,0 @@ -// SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: The Monero Project - -#ifndef FEATHER_BOUNTIESMODEL_H -#define FEATHER_BOUNTIESMODEL_H - -#include -#include - -#include "Bounty.h" - -class BountiesModel : public QAbstractTableModel -{ - Q_OBJECT - -public: - enum ModelColumn - { - Title = 0, - Votes, - Status, - Bounty, - COUNT - }; - - explicit BountiesModel(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 updateBounties(const QList>& posts); - - QSharedPointer post(int row); - -private: - QList> m_bounties; -}; - - -#endif //FEATHER_BOUNTIESMODEL_H diff --git a/src/plugins/bounties/BountiesPlugin.cpp b/src/plugins/bounties/BountiesPlugin.cpp deleted file mode 100644 index a1caff4c..00000000 --- a/src/plugins/bounties/BountiesPlugin.cpp +++ /dev/null @@ -1,59 +0,0 @@ -// SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: The Monero Project - -#include "BountiesPlugin.h" - -#include "plugins/PluginRegistry.h" -#include "BountiesWidget.h" - -BountiesPlugin::BountiesPlugin() -{ -} - -void BountiesPlugin::initialize(Wallet *wallet, QObject *parent) { - this->setParent(parent); - m_tab = new BountiesWidget(nullptr); - connect(m_tab, &BountiesWidget::donate, this, &Plugin::fillSendTab); -} - -QString BountiesPlugin::id() { - return "bounties"; -} - -int BountiesPlugin::idx() const { - return 20; -} - -QString BountiesPlugin::parent() { - return "home"; -} - -QString BountiesPlugin::displayName() { - return "Bounties"; -} - -QString BountiesPlugin::description() { - return ""; -} - -QString BountiesPlugin::icon() { - return {}; -} - -QStringList BountiesPlugin::socketData() { - return {"bounties"}; -} - -Plugin::PluginType BountiesPlugin::type() { - return Plugin::PluginType::TAB; -} - -QWidget* BountiesPlugin::tab() { - return m_tab; -} - -const bool BountiesPlugin::registered = [] { - PluginRegistry::registerPlugin(BountiesPlugin::create()); - PluginRegistry::getInstance().registerPluginCreator(&BountiesPlugin::create); - return true; -}(); diff --git a/src/plugins/bounties/BountiesPlugin.h b/src/plugins/bounties/BountiesPlugin.h deleted file mode 100644 index 71246e96..00000000 --- a/src/plugins/bounties/BountiesPlugin.h +++ /dev/null @@ -1,36 +0,0 @@ -// SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: The Monero Project - -#ifndef BOUNTIESPLUGIN_H -#define BOUNTIESPLUGIN_H - -#include "plugins/Plugin.h" -#include "BountiesWidget.h" - -class BountiesPlugin : public Plugin { - Q_OBJECT - -public: - explicit BountiesPlugin(); - - 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 BountiesPlugin* create() { return new BountiesPlugin(); } - -private: - BountiesWidget* m_tab = nullptr; - static const bool registered; -}; - - -#endif //BOUNTIESPLUGIN_H diff --git a/src/plugins/bounties/BountiesProxyModel.cpp b/src/plugins/bounties/BountiesProxyModel.cpp deleted file mode 100644 index 7b940ca3..00000000 --- a/src/plugins/bounties/BountiesProxyModel.cpp +++ /dev/null @@ -1,10 +0,0 @@ -// SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: The Monero Project - -#include "BountiesProxyModel.h" - -BountiesProxyModel::BountiesProxyModel(QObject *parent) - : QSortFilterProxyModel(parent) -{ - setSortRole(Qt::UserRole); -} diff --git a/src/plugins/bounties/BountiesProxyModel.h b/src/plugins/bounties/BountiesProxyModel.h deleted file mode 100644 index 40d5b44c..00000000 --- a/src/plugins/bounties/BountiesProxyModel.h +++ /dev/null @@ -1,17 +0,0 @@ -// SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: The Monero Project - -#ifndef BOUNTIESPROXYMODEL_H -#define BOUNTIESPROXYMODEL_H - -#include - -class BountiesProxyModel : public QSortFilterProxyModel -{ - Q_OBJECT - -public: - explicit BountiesProxyModel(QObject* parent = nullptr); -}; - -#endif //BOUNTIESPROXYMODEL_H diff --git a/src/plugins/bounties/BountiesWidget.cpp b/src/plugins/bounties/BountiesWidget.cpp deleted file mode 100644 index 5040c9e7..00000000 --- a/src/plugins/bounties/BountiesWidget.cpp +++ /dev/null @@ -1,100 +0,0 @@ -// SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: The Monero Project - -#include "BountiesWidget.h" -#include "ui_BountiesWidget.h" - -#include -#include - -#include "BountiesModel.h" -#include "utils/Utils.h" -#include "utils/config.h" -#include "utils/WebsocketNotifier.h" - -BountiesWidget::BountiesWidget(QWidget *parent) - : QWidget(parent) - , ui(new Ui::BountiesWidget) - , m_model(new BountiesModel(this)) - , m_contextMenu(new QMenu(this)) -{ - ui->setupUi(this); - - m_proxyModel = new BountiesProxyModel(this); - m_proxyModel->setSourceModel(m_model); - - ui->tableView->setModel(m_proxyModel); - ui->tableView->setSortingEnabled(true); - ui->tableView->sortByColumn(3, Qt::DescendingOrder); - this->setupTable(); - - m_contextMenu->addAction("View Bounty", this, &BountiesWidget::linkClicked); - m_contextMenu->addAction("Donate", this, &BountiesWidget::donateClicked); - connect(ui->tableView, &QHeaderView::customContextMenuRequested, this, &BountiesWidget::showContextMenu); - - connect(ui->tableView, &QTableView::doubleClicked, this, &BountiesWidget::linkClicked); - - connect(websocketNotifier(), &WebsocketNotifier::dataReceived, this, [this](const QString &type, const QJsonValue &json) { - if (type == "bounties") { - QJsonArray bounties_data = json.toArray(); - QList> l; - - for (const auto& entry : bounties_data) { - QJsonObject obj = entry.toObject(); - auto bounty = new BountyEntry(obj.value("votes").toInt(), - obj.value("title").toString(), - obj.value("amount").toDouble(), - obj.value("link").toString(), - obj.value("address").toString(), - obj.value("status").toString()); - QSharedPointer b = QSharedPointer(bounty); - l.append(b); - } - - m_model->updateBounties(l); - } - }); - - ui->tableView->verticalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); -} - -void BountiesWidget::linkClicked() { - QModelIndex index = m_proxyModel->mapToSource(ui->tableView->currentIndex()); - auto post = m_model->post(index.row()); - - if (post) - Utils::externalLinkWarning(this, this->getLink(post->link)); -} - -void BountiesWidget::donateClicked() { - QModelIndex index = m_proxyModel->mapToSource(ui->tableView->currentIndex()); - auto bounty = m_model->post(index.row()); - - if (bounty) { - emit donate(bounty->donationAddress, QString("Bounty: %1").arg(bounty->title)); - } -} - -void BountiesWidget::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 BountiesWidget::showContextMenu(const QPoint &pos) { - QModelIndex index = ui->tableView->indexAt(pos); - if (!index.isValid()) { - return; - } - - m_contextMenu->exec(ui->tableView->viewport()->mapToGlobal(pos)); -} - -QString BountiesWidget::getLink(const QString &permaLink) { - QString frontend = conf()->get(Config::bountiesFrontend).toString(); - return QString("%1/%2").arg(frontend, permaLink); -} - -BountiesWidget::~BountiesWidget() = default; \ No newline at end of file diff --git a/src/plugins/bounties/BountiesWidget.h b/src/plugins/bounties/BountiesWidget.h deleted file mode 100644 index 44b5ecb5..00000000 --- a/src/plugins/bounties/BountiesWidget.h +++ /dev/null @@ -1,45 +0,0 @@ -// SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: The Monero Project - -#ifndef FEATHER_BOUNTIESWIDGET_H -#define FEATHER_BOUNTIESWIDGET_H - -#include -#include -#include - -#include "BountiesModel.h" -#include "BountiesProxyModel.h" - -namespace Ui { - class BountiesWidget; -} - -class BountiesWidget : public QWidget -{ - Q_OBJECT - -public: - explicit BountiesWidget(QWidget *parent = nullptr); - ~BountiesWidget() override; - -public slots: - void linkClicked(); - -signals: - void setStatusText(const QString &msg, bool override, int timeout); - void donate(const QString &address, const QString &description); - -private: - void setupTable(); - void showContextMenu(const QPoint &pos); - void donateClicked(); - QString getLink(const QString &permaLink); - - QScopedPointer ui; - BountiesModel *m_model; - BountiesProxyModel *m_proxyModel; - QMenu *m_contextMenu; -}; - -#endif //FEATHER_BOUNTIESWIDGET_H diff --git a/src/plugins/bounties/BountiesWidget.ui b/src/plugins/bounties/BountiesWidget.ui deleted file mode 100644 index c57cafd8..00000000 --- a/src/plugins/bounties/BountiesWidget.ui +++ /dev/null @@ -1,46 +0,0 @@ - - - BountiesWidget - - - - 0 - 0 - 566 - 372 - - - - Form - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - Qt::CustomContextMenu - - - QAbstractItemView::SingleSelection - - - false - - - - - - - - diff --git a/src/plugins/bounties/Bounty.h b/src/plugins/bounties/Bounty.h deleted file mode 100644 index ac2bb97f..00000000 --- a/src/plugins/bounties/Bounty.h +++ /dev/null @@ -1,23 +0,0 @@ -// SPDX-License-Identifier: BSD-3-Clause -// Copyright (c) The Monero Project. - -#ifndef FEATHER_BOUNTY_H -#define FEATHER_BOUNTY_H - -#include -#include - -struct BountyEntry { - BountyEntry(int votes, QString title, double bountyAmount, QString link, QString donationAddress, QString status) - : votes(votes), title(std::move(title)), bountyAmount(bountyAmount), link(std::move(link)), - donationAddress(std::move(donationAddress)), status(std::move(status)){}; - - int votes; - QString title; - double bountyAmount; - QString link; - QString donationAddress; - QString status; -}; - -#endif //FEATHER_BOUNTY_H diff --git a/src/plugins/crowdfunding/CCSEntry.h b/src/plugins/crowdfunding/CCSEntry.h deleted file mode 100644 index 49c8f63b..00000000 --- a/src/plugins/crowdfunding/CCSEntry.h +++ /dev/null @@ -1,26 +0,0 @@ -// SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: The Monero Project - -#ifndef FEATHER_CCSENTRY_H -#define FEATHER_CCSENTRY_H - -#include - -struct CCSEntry { - CCSEntry()= default;; - - QString title; - QString date; - QString address; - QString author; - QString state; - QString url; - QString organizer; - QString currency; - double target_amount = 0; - double raised_amount = 0; - double percentage_funded = 0; - int contributions = 0; -}; - -#endif //FEATHER_CCSENTRY_H diff --git a/src/plugins/crowdfunding/CCSModel.cpp b/src/plugins/crowdfunding/CCSModel.cpp deleted file mode 100644 index baaaf2ea..00000000 --- a/src/plugins/crowdfunding/CCSModel.cpp +++ /dev/null @@ -1,100 +0,0 @@ -// SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: The Monero Project - -#include "CCSModel.h" - -CCSModel::CCSModel(QObject *parent) - : QAbstractTableModel(parent) -{ - -} - -void CCSModel::clear() { - beginResetModel(); - - m_entries.clear(); - - endResetModel(); -} - -void CCSModel::updateEntries(const QList>& entries) { - beginResetModel(); - - m_entries.clear(); - for (const auto& entry : entries) { - m_entries.push_back(entry); - } - - endResetModel(); -} - -int CCSModel::rowCount(const QModelIndex &parent) const{ - if (parent.isValid()) { - return 0; - } - return m_entries.count(); -} - -int CCSModel::columnCount(const QModelIndex &parent) const -{ - if (parent.isValid()) { - return 0; - } - return ModelColumn::COUNT; -} - -QVariant CCSModel::data(const QModelIndex &index, int role) const -{ - if (!index.isValid() || index.row() < 0 || index.row() >= m_entries.count()) - return QVariant(); - - QSharedPointer entry = m_entries.at(index.row()); - - if(role == Qt::DisplayRole) { - switch(index.column()) { - case Title: - return entry->title; - case Organizer: - return entry->organizer; - case Author: - return QString("%1 ").arg(entry->author); - case Progress: - return QString("%1/%2 %3").arg(QString::number(entry->raised_amount), QString::number(entry->target_amount), entry->currency); - default: - return QVariant(); - } - } - return QVariant(); -} - -QVariant CCSModel::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("Proposal"); - case Organizer: - return QString("Organizer "); - case Author: - return QString("Author"); - case Progress: - return QString("Progress"); - default: - return QVariant(); - } - } - return QVariant(); -} - -QSharedPointer CCSModel::entry(int row) { - if (row < 0 || row >= m_entries.size()) { - qCritical("%s: no reddit post for index %d", __FUNCTION__, row); - return QSharedPointer(); - } - - return m_entries.at(row); -} \ No newline at end of file diff --git a/src/plugins/crowdfunding/CCSModel.h b/src/plugins/crowdfunding/CCSModel.h deleted file mode 100644 index e310878f..00000000 --- a/src/plugins/crowdfunding/CCSModel.h +++ /dev/null @@ -1,43 +0,0 @@ -// SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: The Monero Project - -#ifndef FEATHER_CCSMODEL_H -#define FEATHER_CCSMODEL_H - -#include -#include - -#include "CCSEntry.h" - -class CCSModel : public QAbstractTableModel -{ -Q_OBJECT - -public: - enum ModelColumn - { - Title = 0, - Organizer, - Author, - Progress, - COUNT - }; - - explicit CCSModel(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 updateEntries(const QList>& entries); - - QSharedPointer entry(int row); - -private: - QList> m_entries; -}; - - -#endif //FEATHER_CCSMODEL_H diff --git a/src/plugins/crowdfunding/CCSProgressDelegate.cpp b/src/plugins/crowdfunding/CCSProgressDelegate.cpp deleted file mode 100644 index c915d24d..00000000 --- a/src/plugins/crowdfunding/CCSProgressDelegate.cpp +++ /dev/null @@ -1,39 +0,0 @@ -// SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: The Monero Project - -#include "CCSProgressDelegate.h" - -#include - -CCSProgressDelegate::CCSProgressDelegate(CCSModel *model, QWidget *parent) - : QStyledItemDelegate(parent) - , m_model(model) -{ -} - -void CCSProgressDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, - const QModelIndex &index) const { - - if (index.column() != CCSModel::Progress) { - QStyledItemDelegate::paint(painter, option, index); - return; - } - - QStyleOptionProgressBar progressBarOption; - progressBarOption.state = QStyle::State_Enabled; - progressBarOption.direction = QApplication::layoutDirection(); - progressBarOption.rect = option.rect; - progressBarOption.fontMetrics = QApplication::fontMetrics(); - progressBarOption.minimum = 0; - progressBarOption.maximum = 100; - progressBarOption.textAlignment = Qt::AlignCenter; - progressBarOption.textVisible = true; - - QSharedPointer entry = m_model->entry(index.row()); - auto target = QString("%1/%2 XMR").arg(entry->raised_amount).arg(entry->target_amount); - auto progress = (int)entry->percentage_funded; - progressBarOption.progress = progress < 0 ? 0 : progress; - progressBarOption.text = target; - - QApplication::style()->drawControl(QStyle::CE_ProgressBar, &progressBarOption, painter); // Draw the progress bar onto the view. -} \ No newline at end of file diff --git a/src/plugins/crowdfunding/CCSProgressDelegate.h b/src/plugins/crowdfunding/CCSProgressDelegate.h deleted file mode 100644 index 4c0f5cb9..00000000 --- a/src/plugins/crowdfunding/CCSProgressDelegate.h +++ /dev/null @@ -1,24 +0,0 @@ -// SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: The Monero Project - -#ifndef FEATHER_CSSPROGRESSDELEGATE_H -#define FEATHER_CSSPROGRESSDELEGATE_H - -#include - -#include "CCSModel.h" - -class CCSProgressDelegate : public QStyledItemDelegate -{ - Q_OBJECT - -public: - explicit CCSProgressDelegate(CCSModel *model, QWidget *parent = nullptr); - void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override; - -private: - CCSModel *m_model; -}; - - -#endif //FEATHER_CSSPROGRESSDELEGATE_H diff --git a/src/plugins/crowdfunding/CCSWidget.cpp b/src/plugins/crowdfunding/CCSWidget.cpp deleted file mode 100644 index 92d8e944..00000000 --- a/src/plugins/crowdfunding/CCSWidget.cpp +++ /dev/null @@ -1,103 +0,0 @@ -// SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: The Monero Project - -#include "CCSWidget.h" -#include "ui_CCSWidget.h" - -#include -#include - -#include "CCSProgressDelegate.h" -#include "utils/Utils.h" -#include "utils/WebsocketNotifier.h" - -CCSWidget::CCSWidget(QWidget *parent) - : QWidget(parent) - , ui(new Ui::CSSWidget) - , m_model(new CCSModel(this)) - , m_contextMenu(new QMenu(this)) -{ - ui->setupUi(this); - ui->treeView->setModel(m_model); - - m_contextMenu->addAction("View proposal", this, &CCSWidget::linkClicked); - m_contextMenu->addAction("Donate", this, &CCSWidget::donateClicked); - - connect(ui->treeView, &QHeaderView::customContextMenuRequested, this, &CCSWidget::showContextMenu); - connect(ui->treeView, &QTreeView::doubleClicked, this, &CCSWidget::linkClicked); - - ui->treeView->setSelectionBehavior(QAbstractItemView::SelectRows); - ui->treeView->header()->setSectionResizeMode(QHeaderView::ResizeToContents); - ui->treeView->header()->setSectionResizeMode(CCSModel::Title, QHeaderView::Stretch); - - connect(websocketNotifier(), &WebsocketNotifier::dataReceived, this, [this](const QString& type, const QJsonValue& json) { - if (type == "ccs") { - QJsonArray ccs_data = json.toArray(); - QList> l; - - for (const auto& entry: ccs_data) { - auto obj = entry.toObject(); - auto c = QSharedPointer(new CCSEntry()); - - if (obj.value("state").toString() != "FUNDING-REQUIRED") - continue; - - c->state = obj.value("state").toString(); - c->address = obj.value("address").toString(); - c->author = obj.value("author").toString(); - c->date = obj.value("date").toString(); - c->title = obj.value("title").toString(); - c->target_amount = obj.value("target_amount").toDouble(); - c->raised_amount = obj.value("raised_amount").toDouble(); - c->percentage_funded = obj.value("percentage_funded").toDouble(); - c->contributions = obj.value("contributions").toInt(); - c->organizer = obj.value("organizer").toString(); - c->currency = obj.value("currency").toString(); - - QString urlpath = obj.value("urlpath").toString(); - if (c->organizer == "CCS") { - c->url = QString("https://ccs.getmonero.org/%1").arg(urlpath); - } - else if (c->organizer == "MAGIC") { - c->url = QString("https://donate.magicgrants.org/%1").arg(urlpath); - } - else { - continue; - } - - l.append(c); - } - - m_model->updateEntries(l); - } - }); -} - -void CCSWidget::linkClicked() { - QModelIndex index = ui->treeView->currentIndex(); - auto entry = m_model->entry(index.row()); - - if (entry) { - Utils::externalLinkWarning(this, entry->url); - } -} - -void CCSWidget::donateClicked() { - QModelIndex index = ui->treeView->currentIndex(); - auto entry = m_model->entry(index.row()); - - if (entry) { - emit fillSendTab(entry->address, QString("Donation to %1: %2").arg(entry->organizer, entry->title)); - } -} - -void CCSWidget::showContextMenu(const QPoint &pos) { - QModelIndex index = ui->treeView->indexAt(pos); - if (!index.isValid()) { - return; - } - - m_contextMenu->exec(ui->treeView->viewport()->mapToGlobal(pos)); -} - -CCSWidget::~CCSWidget() = default; \ No newline at end of file diff --git a/src/plugins/crowdfunding/CCSWidget.h b/src/plugins/crowdfunding/CCSWidget.h deleted file mode 100644 index 5a763da8..00000000 --- a/src/plugins/crowdfunding/CCSWidget.h +++ /dev/null @@ -1,45 +0,0 @@ -// SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: The Monero Project - -#ifndef FEATHER_CSSWIDGET_H -#define FEATHER_CSSWIDGET_H - -#include -#include -#include -#include -#include - -#include "CCSModel.h" -#include "CCSEntry.h" - -namespace Ui { - class CSSWidget; -} - -class CCSWidget : public QWidget -{ -Q_OBJECT - -public: - explicit CCSWidget(QWidget *parent = nullptr); - ~CCSWidget(); - -signals: - void fillSendTab(const QString &address, const QString &description); - -public slots: - void donateClicked(); - -private slots: - void linkClicked(); - -private: - void showContextMenu(const QPoint &pos); - - QScopedPointer ui; - CCSModel *m_model; - QMenu *m_contextMenu; -}; - -#endif // FEATHER_CSSWIDGET_H diff --git a/src/plugins/crowdfunding/CCSWidget.ui b/src/plugins/crowdfunding/CCSWidget.ui deleted file mode 100644 index 51163e36..00000000 --- a/src/plugins/crowdfunding/CCSWidget.ui +++ /dev/null @@ -1,56 +0,0 @@ - - - CSSWidget - - - - 0 - 0 - 893 - 396 - - - - Form - - - - 4 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - Qt::CustomContextMenu - - - true - - - false - - - false - - - - - - - - - donateClicked() - linkClicked() - - diff --git a/src/plugins/crowdfunding/CrowdfundingPlugin.cpp b/src/plugins/crowdfunding/CrowdfundingPlugin.cpp deleted file mode 100644 index 8cebc63d..00000000 --- a/src/plugins/crowdfunding/CrowdfundingPlugin.cpp +++ /dev/null @@ -1,59 +0,0 @@ -// SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: The Monero Project - -#include "CrowdfundingPlugin.h" - -#include "plugins/PluginRegistry.h" -#include "CCSWidget.h" - -CrowdfundingPlugin::CrowdfundingPlugin() -{ -} - -void CrowdfundingPlugin::initialize(Wallet *wallet, QObject *parent) { - this->setParent(parent); - m_tab = new CCSWidget(nullptr); - connect(m_tab, &CCSWidget::fillSendTab, this, &Plugin::fillSendTab); -} - -QString CrowdfundingPlugin::id() { - return "crowdfunding"; -} - -int CrowdfundingPlugin::idx() const { - return 10; -} - -QString CrowdfundingPlugin::parent() { - return "home"; -} - -QString CrowdfundingPlugin::displayName() { - return "Crowdfunding"; -} - -QString CrowdfundingPlugin::description() { - return {}; -} - -QString CrowdfundingPlugin::icon() { - return {}; -} - -QStringList CrowdfundingPlugin::socketData() { - return {"ccs"}; -} - -Plugin::PluginType CrowdfundingPlugin::type() { - return Plugin::PluginType::TAB; -} - -QWidget* CrowdfundingPlugin::tab() { - return m_tab; -} - -const bool CrowdfundingPlugin::registered = [] { - PluginRegistry::registerPlugin(CrowdfundingPlugin::create()); - PluginRegistry::getInstance().registerPluginCreator(&CrowdfundingPlugin::create); - return true; -}(); diff --git a/src/plugins/crowdfunding/CrowdfundingPlugin.h b/src/plugins/crowdfunding/CrowdfundingPlugin.h deleted file mode 100644 index 9bd4736c..00000000 --- a/src/plugins/crowdfunding/CrowdfundingPlugin.h +++ /dev/null @@ -1,35 +0,0 @@ -// SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: The Monero Project - -#ifndef CROWDFUNDINGPLUGIN_H -#define CROWDFUNDINGPLUGIN_H - -#include "plugins/Plugin.h" -#include "CCSWidget.h" - -class CrowdfundingPlugin : public Plugin { - Q_OBJECT - -public: - explicit CrowdfundingPlugin(); - - 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 CrowdfundingPlugin* create() { return new CrowdfundingPlugin(); } - -private: - CCSWidget* m_tab = nullptr; - static const bool registered; -}; - -#endif //CROWDFUNDINGPLUGIN_H -- 2.52.0