mirror of
https://github.com/feather-wallet/feather.git
synced 2024-12-22 11:39:25 +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
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -122,7 +122,7 @@
|
|||
</property>
|
||||
<widget class="QWidget" name="tab">
|
||||
<attribute name="title">
|
||||
<string>CCS</string>
|
||||
<string>Crowdfunding</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_6">
|
||||
<property name="leftMargin">
|
||||
|
@ -479,7 +479,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>977</width>
|
||||
<height>27</height>
|
||||
<height>24</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menuFile">
|
||||
|
|
|
@ -9,12 +9,14 @@
|
|||
struct CCSEntry {
|
||||
CCSEntry()= default;;
|
||||
|
||||
QString title = "";
|
||||
QString date = "";
|
||||
QString address = "";
|
||||
QString author = "";
|
||||
QString state = "";
|
||||
QString url = "";
|
||||
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;
|
||||
|
|
|
@ -54,10 +54,12 @@ QVariant CCSModel::data(const QModelIndex &index, int role) const
|
|||
switch(index.column()) {
|
||||
case Title:
|
||||
return entry->title;
|
||||
case Organizer:
|
||||
return entry->organizer;
|
||||
case Author:
|
||||
return entry->author;
|
||||
return QString("%1 ").arg(entry->author);
|
||||
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:
|
||||
return QVariant();
|
||||
}
|
||||
|
@ -74,7 +76,9 @@ QVariant CCSModel::headerData(int section, Qt::Orientation orientation, int role
|
|||
{
|
||||
switch(section) {
|
||||
case Title:
|
||||
return QString("Community Crowdfunding Proposal");
|
||||
return QString("Proposal");
|
||||
case Organizer:
|
||||
return QString("Organizer");
|
||||
case Author:
|
||||
return QString("Author");
|
||||
case Progress:
|
||||
|
|
|
@ -17,6 +17,7 @@ public:
|
|||
enum ModelColumn
|
||||
{
|
||||
Title = 0,
|
||||
Organizer,
|
||||
Author,
|
||||
Progress,
|
||||
COUNT
|
||||
|
|
|
@ -18,16 +18,17 @@ CCSWidget::CCSWidget(QWidget *parent)
|
|||
, m_contextMenu(new QMenu(this))
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->tableView->setModel(m_model);
|
||||
this->setupTable();
|
||||
ui->treeView->setModel(m_model);
|
||||
|
||||
m_contextMenu->addAction("View proposal", this, &CCSWidget::linkClicked);
|
||||
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() {
|
||||
|
@ -35,7 +36,7 @@ CCSModel* CCSWidget::model() {
|
|||
}
|
||||
|
||||
void CCSWidget::linkClicked() {
|
||||
QModelIndex index = ui->tableView->currentIndex();
|
||||
QModelIndex index = ui->treeView->currentIndex();
|
||||
auto entry = m_model->entry(index.row());
|
||||
|
||||
if (entry) {
|
||||
|
@ -44,28 +45,20 @@ void CCSWidget::linkClicked() {
|
|||
}
|
||||
|
||||
void CCSWidget::donateClicked() {
|
||||
QModelIndex index = ui->tableView->currentIndex();
|
||||
QModelIndex index = ui->treeView->currentIndex();
|
||||
auto entry = m_model->entry(index.row());
|
||||
|
||||
if (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) {
|
||||
QModelIndex index = ui->tableView->indexAt(pos);
|
||||
QModelIndex index = ui->treeView->indexAt(pos);
|
||||
if (!index.isValid()) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_contextMenu->exec(ui->tableView->viewport()->mapToGlobal(pos));
|
||||
m_contextMenu->exec(ui->treeView->viewport()->mapToGlobal(pos));
|
||||
}
|
||||
|
||||
CCSWidget::~CCSWidget() = default;
|
|
@ -36,7 +36,6 @@ private slots:
|
|||
void linkClicked();
|
||||
|
||||
private:
|
||||
void setupTable();
|
||||
void showContextMenu(const QPoint &pos);
|
||||
|
||||
QScopedPointer<Ui::CSSWidget> ui;
|
||||
|
|
|
@ -30,20 +30,17 @@
|
|||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QTableView" name="tableView">
|
||||
<widget class="QTreeView" name="treeView">
|
||||
<property name="contextMenuPolicy">
|
||||
<enum>Qt::CustomContextMenu</enum>
|
||||
</property>
|
||||
<property name="editTriggers">
|
||||
<set>QAbstractItemView::NoEditTriggers</set>
|
||||
<property name="alternatingRowColors">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="selectionMode">
|
||||
<enum>QAbstractItemView::SingleSelection</enum>
|
||||
</property>
|
||||
<property name="sortingEnabled">
|
||||
<property name="rootIsDecorated">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<attribute name="horizontalHeaderStretchLastSection">
|
||||
<attribute name="headerStretchLastSection">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
</widget>
|
||||
|
|
|
@ -156,7 +156,7 @@ void WebsocketNotifier::onWSReddit(const QJsonArray& reddit_data) {
|
|||
void WebsocketNotifier::onWSCCS(const QJsonArray &ccs_data) {
|
||||
QList<QSharedPointer<CCSEntry>> l;
|
||||
|
||||
for (auto &&entry: ccs_data) {
|
||||
for (const auto& entry: ccs_data) {
|
||||
auto obj = entry.toObject();
|
||||
auto c = QSharedPointer<CCSEntry>(new CCSEntry());
|
||||
|
||||
|
@ -168,11 +168,24 @@ void WebsocketNotifier::onWSCCS(const QJsonArray &ccs_data) {
|
|||
c->author = obj.value("author").toString();
|
||||
c->date = obj.value("date").toString();
|
||||
c->title = obj.value("title").toString();
|
||||
c->url = obj.value("url").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://monerofund.org/%1").arg(urlpath);
|
||||
}
|
||||
else {
|
||||
continue;
|
||||
}
|
||||
|
||||
l.append(c);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue