mirror of
https://github.com/feather-wallet/feather.git
synced 2024-12-22 19:49:28 +00:00
ccs: add MAGIC monero fund
This commit is contained in:
parent
6225e0e389
commit
a09b15f79e
9 changed files with 49 additions and 40 deletions
|
@ -1111,7 +1111,7 @@ void MainWindow::payToMany() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::showSendScreen(const CCSEntry &entry) { // TODO: rename this function
|
void MainWindow::showSendScreen(const CCSEntry &entry) { // TODO: rename this function
|
||||||
m_sendWidget->fill(entry.address, QString("CCS: %1").arg(entry.title));
|
m_sendWidget->fill(entry.address, QString("Donation to %1: %2").arg(entry.organizer, entry.title));
|
||||||
ui->tabWidget->setCurrentIndex(Tabs::SEND);
|
ui->tabWidget->setCurrentIndex(Tabs::SEND);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -122,7 +122,7 @@
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="tab">
|
<widget class="QWidget" name="tab">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
<string>CCS</string>
|
<string>Crowdfunding</string>
|
||||||
</attribute>
|
</attribute>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_6">
|
<layout class="QVBoxLayout" name="verticalLayout_6">
|
||||||
<property name="leftMargin">
|
<property name="leftMargin">
|
||||||
|
@ -479,7 +479,7 @@
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>977</width>
|
<width>977</width>
|
||||||
<height>27</height>
|
<height>24</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QMenu" name="menuFile">
|
<widget class="QMenu" name="menuFile">
|
||||||
|
|
|
@ -9,12 +9,14 @@
|
||||||
struct CCSEntry {
|
struct CCSEntry {
|
||||||
CCSEntry()= default;;
|
CCSEntry()= default;;
|
||||||
|
|
||||||
QString title = "";
|
QString title;
|
||||||
QString date = "";
|
QString date;
|
||||||
QString address = "";
|
QString address;
|
||||||
QString author = "";
|
QString author;
|
||||||
QString state = "";
|
QString state;
|
||||||
QString url = "";
|
QString url;
|
||||||
|
QString organizer;
|
||||||
|
QString currency;
|
||||||
double target_amount = 0;
|
double target_amount = 0;
|
||||||
double raised_amount = 0;
|
double raised_amount = 0;
|
||||||
double percentage_funded = 0;
|
double percentage_funded = 0;
|
||||||
|
|
|
@ -54,10 +54,12 @@ QVariant CCSModel::data(const QModelIndex &index, int role) const
|
||||||
switch(index.column()) {
|
switch(index.column()) {
|
||||||
case Title:
|
case Title:
|
||||||
return entry->title;
|
return entry->title;
|
||||||
|
case Organizer:
|
||||||
|
return entry->organizer;
|
||||||
case Author:
|
case Author:
|
||||||
return entry->author;
|
return QString("%1 ").arg(entry->author);
|
||||||
case Progress:
|
case Progress:
|
||||||
return QString("%1/%2 XMR").arg(entry->raised_amount).arg(entry->target_amount);
|
return QString("%1/%2 %3").arg(QString::number(entry->raised_amount), QString::number(entry->target_amount), entry->currency);
|
||||||
default:
|
default:
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
@ -74,7 +76,9 @@ QVariant CCSModel::headerData(int section, Qt::Orientation orientation, int role
|
||||||
{
|
{
|
||||||
switch(section) {
|
switch(section) {
|
||||||
case Title:
|
case Title:
|
||||||
return QString("Community Crowdfunding Proposal");
|
return QString("Proposal");
|
||||||
|
case Organizer:
|
||||||
|
return QString("Organizer");
|
||||||
case Author:
|
case Author:
|
||||||
return QString("Author");
|
return QString("Author");
|
||||||
case Progress:
|
case Progress:
|
||||||
|
|
|
@ -17,6 +17,7 @@ public:
|
||||||
enum ModelColumn
|
enum ModelColumn
|
||||||
{
|
{
|
||||||
Title = 0,
|
Title = 0,
|
||||||
|
Organizer,
|
||||||
Author,
|
Author,
|
||||||
Progress,
|
Progress,
|
||||||
COUNT
|
COUNT
|
||||||
|
|
|
@ -18,16 +18,17 @@ CCSWidget::CCSWidget(QWidget *parent)
|
||||||
, m_contextMenu(new QMenu(this))
|
, m_contextMenu(new QMenu(this))
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
ui->tableView->setModel(m_model);
|
ui->treeView->setModel(m_model);
|
||||||
this->setupTable();
|
|
||||||
|
|
||||||
m_contextMenu->addAction("View proposal", this, &CCSWidget::linkClicked);
|
m_contextMenu->addAction("View proposal", this, &CCSWidget::linkClicked);
|
||||||
m_contextMenu->addAction("Donate", this, &CCSWidget::donateClicked);
|
m_contextMenu->addAction("Donate", this, &CCSWidget::donateClicked);
|
||||||
connect(ui->tableView, &QHeaderView::customContextMenuRequested, this, &CCSWidget::showContextMenu);
|
|
||||||
|
|
||||||
connect(ui->tableView, &QTableView::doubleClicked, this, &CCSWidget::linkClicked);
|
connect(ui->treeView, &QHeaderView::customContextMenuRequested, this, &CCSWidget::showContextMenu);
|
||||||
|
connect(ui->treeView, &QTreeView::doubleClicked, this, &CCSWidget::linkClicked);
|
||||||
|
|
||||||
ui->tableView->verticalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
|
ui->treeView->setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||||
|
ui->treeView->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
|
||||||
|
ui->treeView->header()->setSectionResizeMode(CCSModel::Title, QHeaderView::Stretch);
|
||||||
}
|
}
|
||||||
|
|
||||||
CCSModel* CCSWidget::model() {
|
CCSModel* CCSWidget::model() {
|
||||||
|
@ -35,7 +36,7 @@ CCSModel* CCSWidget::model() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCSWidget::linkClicked() {
|
void CCSWidget::linkClicked() {
|
||||||
QModelIndex index = ui->tableView->currentIndex();
|
QModelIndex index = ui->treeView->currentIndex();
|
||||||
auto entry = m_model->entry(index.row());
|
auto entry = m_model->entry(index.row());
|
||||||
|
|
||||||
if (entry) {
|
if (entry) {
|
||||||
|
@ -44,28 +45,20 @@ void CCSWidget::linkClicked() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCSWidget::donateClicked() {
|
void CCSWidget::donateClicked() {
|
||||||
QModelIndex index = ui->tableView->currentIndex();
|
QModelIndex index = ui->treeView->currentIndex();
|
||||||
auto entry = m_model->entry(index.row());
|
auto entry = m_model->entry(index.row());
|
||||||
|
|
||||||
if (entry)
|
if (entry)
|
||||||
emit selected(*entry);
|
emit selected(*entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCSWidget::setupTable() {
|
|
||||||
ui->tableView->verticalHeader()->setVisible(false);
|
|
||||||
ui->tableView->setSelectionBehavior(QAbstractItemView::SelectRows);
|
|
||||||
|
|
||||||
ui->tableView->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch);
|
|
||||||
ui->tableView->setColumnWidth(2, 160);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CCSWidget::showContextMenu(const QPoint &pos) {
|
void CCSWidget::showContextMenu(const QPoint &pos) {
|
||||||
QModelIndex index = ui->tableView->indexAt(pos);
|
QModelIndex index = ui->treeView->indexAt(pos);
|
||||||
if (!index.isValid()) {
|
if (!index.isValid()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_contextMenu->exec(ui->tableView->viewport()->mapToGlobal(pos));
|
m_contextMenu->exec(ui->treeView->viewport()->mapToGlobal(pos));
|
||||||
}
|
}
|
||||||
|
|
||||||
CCSWidget::~CCSWidget() = default;
|
CCSWidget::~CCSWidget() = default;
|
|
@ -36,7 +36,6 @@ private slots:
|
||||||
void linkClicked();
|
void linkClicked();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setupTable();
|
|
||||||
void showContextMenu(const QPoint &pos);
|
void showContextMenu(const QPoint &pos);
|
||||||
|
|
||||||
QScopedPointer<Ui::CSSWidget> ui;
|
QScopedPointer<Ui::CSSWidget> ui;
|
||||||
|
|
|
@ -30,20 +30,17 @@
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QTableView" name="tableView">
|
<widget class="QTreeView" name="treeView">
|
||||||
<property name="contextMenuPolicy">
|
<property name="contextMenuPolicy">
|
||||||
<enum>Qt::CustomContextMenu</enum>
|
<enum>Qt::CustomContextMenu</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="editTriggers">
|
<property name="alternatingRowColors">
|
||||||
<set>QAbstractItemView::NoEditTriggers</set>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="selectionMode">
|
<property name="rootIsDecorated">
|
||||||
<enum>QAbstractItemView::SingleSelection</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sortingEnabled">
|
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
<attribute name="horizontalHeaderStretchLastSection">
|
<attribute name="headerStretchLastSection">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</attribute>
|
</attribute>
|
||||||
</widget>
|
</widget>
|
||||||
|
|
|
@ -156,7 +156,7 @@ void WebsocketNotifier::onWSReddit(const QJsonArray& reddit_data) {
|
||||||
void WebsocketNotifier::onWSCCS(const QJsonArray &ccs_data) {
|
void WebsocketNotifier::onWSCCS(const QJsonArray &ccs_data) {
|
||||||
QList<QSharedPointer<CCSEntry>> l;
|
QList<QSharedPointer<CCSEntry>> l;
|
||||||
|
|
||||||
for (auto &&entry: ccs_data) {
|
for (const auto& entry: ccs_data) {
|
||||||
auto obj = entry.toObject();
|
auto obj = entry.toObject();
|
||||||
auto c = QSharedPointer<CCSEntry>(new CCSEntry());
|
auto c = QSharedPointer<CCSEntry>(new CCSEntry());
|
||||||
|
|
||||||
|
@ -168,11 +168,24 @@ void WebsocketNotifier::onWSCCS(const QJsonArray &ccs_data) {
|
||||||
c->author = obj.value("author").toString();
|
c->author = obj.value("author").toString();
|
||||||
c->date = obj.value("date").toString();
|
c->date = obj.value("date").toString();
|
||||||
c->title = obj.value("title").toString();
|
c->title = obj.value("title").toString();
|
||||||
c->url = obj.value("url").toString();
|
|
||||||
c->target_amount = obj.value("target_amount").toDouble();
|
c->target_amount = obj.value("target_amount").toDouble();
|
||||||
c->raised_amount = obj.value("raised_amount").toDouble();
|
c->raised_amount = obj.value("raised_amount").toDouble();
|
||||||
c->percentage_funded = obj.value("percentage_funded").toDouble();
|
c->percentage_funded = obj.value("percentage_funded").toDouble();
|
||||||
c->contributions = obj.value("contributions").toInt();
|
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://monerofund.org/%1").arg(urlpath);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
l.append(c);
|
l.append(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue