Send page checkbox

This commit is contained in:
Aditya Kulkarni
2019-01-24 15:09:14 -08:00
parent beb038e82d
commit ace9038070
6 changed files with 326 additions and 186 deletions

View File

@@ -38,6 +38,7 @@ public:
~MainWindow(); ~MainWindow();
void updateLabelsAutoComplete(); void updateLabelsAutoComplete();
RPC* getRPC() { return rpc; }
void setDefaultPayFrom(); void setDefaultPayFrom();
@@ -76,6 +77,8 @@ private:
void addAddressSection(); void addAddressSection();
void maxAmountChecked(int checked); void maxAmountChecked(int checked);
void editSchedule();
void addressChanged(int number, const QString& text); void addressChanged(int number, const QString& text);
void amountChanged (int number, const QString& text); void amountChanged (int number, const QString& text);

View File

@@ -346,8 +346,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>928</width> <width>920</width>
<height>380</height> <height>301</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="sendToLayout"> <layout class="QVBoxLayout" name="sendToLayout">
@@ -530,6 +530,50 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_17">
<item>
<widget class="QCheckBox" name="chkRecurring">
<property name="text">
<string>Recurring payment</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lblRecurDesc">
<property name="text">
<string>Every month, starting 12-May-2012, for 6 payments</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnRecurSchedule">
<property name="text">
<string>Edit Schedule</string>
</property>
<property name="checkable">
<bool>false</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_7">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_6"> <layout class="QHBoxLayout" name="horizontalLayout_6">
<item> <item>
@@ -552,6 +596,20 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QLabel" name="lblMinerFeeUSD">
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_17">
<property name="text">
<string notr="true"/>
</property>
</widget>
</item>
<item> <item>
<spacer name="horizontalSpacer"> <spacer name="horizontalSpacer">
<property name="orientation"> <property name="orientation">
@@ -565,34 +623,6 @@
</property> </property>
</spacer> </spacer>
</item> </item>
<item>
<widget class="QLabel" name="lblMinerFeeUSD">
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_16">
<property name="text">
<string>This transaction does not recur</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>Setup Recurring Payment</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_17">
<property name="text">
<string notr="true"> </string>
</property>
</widget>
</item>
<item> <item>
<widget class="QPushButton" name="sendTransactionButton"> <widget class="QPushButton" name="sendTransactionButton">
<property name="baseSize"> <property name="baseSize">
@@ -1013,7 +1043,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>968</width> <width>968</width>
<height>19</height> <height>22</height>
</rect> </rect>
</property> </property>
<widget class="QMenu" name="menuFile"> <widget class="QMenu" name="menuFile">

View File

@@ -1,131 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0"> <ui version="4.0">
<class>Dialog</class> <class>newRecurringDialog</class>
<widget class="QDialog" name="Dialog"> <widget class="QDialog" name="newRecurringDialog">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>400</width> <width>740</width>
<height>300</height> <height>403</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Dialog</string> <string>Edit Schedule</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<item row="3" column="2"> <item row="5" column="2">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLineEdit" name="lineEdit_4"/>
</item>
<item>
<widget class="QComboBox" name="comboBox_3"/>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="1" column="2">
<widget class="QComboBox" name="comboBox"/>
</item>
<item row="9" column="2">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QLineEdit" name="lineEdit"/>
</item>
<item row="2" column="1">
<widget class="QLabel" name="label_2">
<property name="text">
<string>To</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="label">
<property name="text">
<string>From</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Schedule</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Number of payments</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Amount</string>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Next Payment</string>
</property>
</widget>
</item>
<item row="7" column="2">
<widget class="QLabel" name="label_9">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Payment Description</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLineEdit" name="lineEdit_5"/>
</item>
<item row="4" column="2">
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QHBoxLayout" name="horizontalLayout">
<item> <item>
<widget class="QLabel" name="label_4"> <widget class="QComboBox" name="cmbSchedule"/>
<property name="text">
<string>Every</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_2"/>
</item>
<item>
<widget class="QComboBox" name="comboBox_2"/>
</item> </item>
<item> <item>
<spacer name="horizontalSpacer"> <spacer name="horizontalSpacer">
@@ -142,18 +34,119 @@
</item> </item>
</layout> </layout>
</item> </item>
<item row="5" column="2"> <item row="10" column="2">
<layout class="QHBoxLayout" name="horizontalLayout_2"> <widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Schedule</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Payment Description</string>
</property>
</widget>
</item>
<item row="8" column="2">
<widget class="QLabel" name="lblNextPayment">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
<item row="7" column="1" colspan="2">
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="3" column="2">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item> <item>
<widget class="QLineEdit" name="lineEdit_3"/> <widget class="QLineEdit" name="txtAmt">
</item> <property name="sizePolicy">
<item> <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<widget class="QCheckBox" name="checkBox"> <horstretch>0</horstretch>
<property name="text"> <verstretch>0</verstretch>
<string>Forever</string> </sizepolicy>
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QComboBox" name="cmbCurrency"/>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="0" column="2">
<widget class="QLineEdit" name="txtDesc"/>
</item>
<item row="1" column="1">
<widget class="QLabel" name="label">
<property name="text">
<string>From</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Number of payments</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Amount</string>
</property>
</widget>
</item>
<item row="9" column="1">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="2">
<widget class="AddressCombo" name="cmbFromAddress"/>
</item>
<item row="6" column="2">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLineEdit" name="txtNumPayments"/>
</item>
<item> <item>
<spacer name="horizontalSpacer_2"> <spacer name="horizontalSpacer_2">
<property name="orientation"> <property name="orientation">
@@ -169,21 +162,57 @@
</item> </item>
</layout> </layout>
</item> </item>
<item row="6" column="1" colspan="2"> <item row="8" column="1">
<widget class="Line" name="line"> <widget class="QLabel" name="label_8">
<property name="orientation"> <property name="text">
<enum>Qt::Horizontal</enum> <string>Next Payment</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QLineEdit" name="txtToAddr"/>
</item>
<item row="2" column="1">
<widget class="QLabel" name="label_2">
<property name="text">
<string>To</string>
</property>
</widget>
</item>
<item row="4" column="2">
<widget class="QPlainTextEdit" name="txtMemo"/>
</item>
<item row="4" column="1">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Memo</string>
</property> </property>
</widget> </widget>
</item> </item>
</layout> </layout>
</widget> </widget>
<customwidgets>
<customwidget>
<class>AddressCombo</class>
<extends>QComboBox</extends>
<header>addresscombo.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>txtDesc</tabstop>
<tabstop>cmbFromAddress</tabstop>
<tabstop>txtToAddr</tabstop>
<tabstop>txtAmt</tabstop>
<tabstop>cmbCurrency</tabstop>
<tabstop>cmbSchedule</tabstop>
<tabstop>txtNumPayments</tabstop>
</tabstops>
<resources/> <resources/>
<connections> <connections>
<connection> <connection>
<sender>buttonBox</sender> <sender>buttonBox</sender>
<signal>accepted()</signal> <signal>accepted()</signal>
<receiver>Dialog</receiver> <receiver>newRecurringDialog</receiver>
<slot>accept()</slot> <slot>accept()</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
@@ -199,7 +228,7 @@
<connection> <connection>
<sender>buttonBox</sender> <sender>buttonBox</sender>
<signal>rejected()</signal> <signal>rejected()</signal>
<receiver>Dialog</receiver> <receiver>newRecurringDialog</receiver>
<slot>reject()</slot> <slot>reject()</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">

View File

@@ -1,14 +1,48 @@
#include "recurring.h" #include "recurring.h"
#include "ui_recurringdialog.h"
RecurringDialog::RecurringDialog(QWidget *parent) : #include "mainwindow.h"
QDialog(parent), #include "rpc.h"
ui(new Ui::RecurringDialog) #include "settings.h"
{ #include "ui_newrecurring.h"
ui->setupUi(this);
}
RecurringDialog::~RecurringDialog() void Recurring::showEditDialog(QWidget* parent, MainWindow* main, Tx tx) {
{ Ui_newRecurringDialog ui;
delete ui; QDialog d(parent);
} ui.setupUi(&d);
Settings::saveRestore(&d);
// Add all the from addresses
auto allBalances = main->getRPC()->getAllBalances();
for (QString addr : allBalances->keys()) {
ui.cmbFromAddress->addItem(addr, allBalances->value(addr));
}
if (!tx.fromAddr.isEmpty()) {
ui.cmbFromAddress->setCurrentText(tx.fromAddr);
ui.cmbFromAddress->setEnabled(false);
}
ui.cmbCurrency->addItem(Settings::getTokenName());
ui.cmbCurrency->addItem("USD");
if (tx.toAddrs.length() > 0) {
ui.txtToAddr->setText(tx.toAddrs[0].addr);
ui.txtToAddr->setEnabled(false);
ui.txtAmt->setText(Settings::getDecimalString(tx.toAddrs[0].amount));
ui.txtAmt->setEnabled(false);
ui.txtMemo->setPlainText(tx.toAddrs[0].txtMemo);
ui.txtMemo->setEnabled(false);
}
ui.cmbSchedule->addItem("Every Day", QVariant(Schedule::DAY));
ui.cmbSchedule->addItem("Every Week", QVariant(Schedule::WEEK));
ui.cmbSchedule->addItem("Every Month", QVariant(Schedule::MONTH));
ui.cmbSchedule->addItem("Every Year", QVariant(Schedule::YEAR));
ui.txtNumPayments->setText("10");
ui.txtDesc->setFocus();
d.exec();
}

View File

@@ -1,22 +1,36 @@
#ifndef RECURRING_H #ifndef RECURRING_H
#define RECURRING_H #define RECURRING_H
#include <QDialog> #include "precompiled.h"
namespace Ui { #include "mainwindow.h"
class RecurringDialog;
}
class RecurringDialog : public QDialog enum Schedule {
{ DAY = 1,
Q_OBJECT WEEK,
MONTH,
public: YEAR
explicit RecurringDialog(QWidget *parent = nullptr);
~RecurringDialog();
private:
Ui::RecurringDialog *ui;
}; };
#endif // RECURRING_H struct RecurringPaymentInfo {
QString desc;
QString fromAddr;
QString toAddr;
double amt;
QString currency;
Schedule schedule;
int numPayments;
long startBlock;
int completedPayments;
};
class Recurring
{
public:
Recurring();
static void showEditDialog(QWidget* parent, MainWindow* main, Tx tx);
};
#endif // RECURRING_H

View File

@@ -3,8 +3,10 @@
#include "addressbook.h" #include "addressbook.h"
#include "ui_confirm.h" #include "ui_confirm.h"
#include "ui_memodialog.h" #include "ui_memodialog.h"
#include "ui_newrecurring.h"
#include "settings.h" #include "settings.h"
#include "rpc.h" #include "rpc.h"
#include "recurring.h"
using json = nlohmann::json; using json = nlohmann::json;
@@ -80,6 +82,29 @@ void MainWindow::setupSendTab() {
QFont f = ui->Address1->font(); QFont f = ui->Address1->font();
f.setPointSize(f.pointSize() - 1); f.setPointSize(f.pointSize() - 1);
ui->MemoTxt1->setFont(f); ui->MemoTxt1->setFont(f);
// Recurring button
QObject::connect(ui->chkRecurring, &QCheckBox::stateChanged, [=] (int checked) {
if (checked) {
ui->btnRecurSchedule->setEnabled(true);
} else {
ui->btnRecurSchedule->setEnabled(false);
ui->lblRecurDesc->setText("");
}
});
// Recurring schedule button
QObject::connect(ui->btnRecurSchedule, &QPushButton::clicked, this, &MainWindow::editSchedule);
// Set the default state for the whole page
removeExtraAddresses();
}
void MainWindow::editSchedule() {
// Open the edit schedule dialog
Recurring::showEditDialog(this, this, createTxFromSendPage());
} }
void MainWindow::updateLabelsAutoComplete() { void MainWindow::updateLabelsAutoComplete() {
@@ -354,6 +379,11 @@ void MainWindow::removeExtraAddresses() {
delete addressGroupBox; delete addressGroupBox;
} }
// Reset the recurring button
ui->chkRecurring->setCheckState(Qt::Unchecked);
ui->btnRecurSchedule->setEnabled(false);
ui->lblRecurDesc->setText("");
} }
void MainWindow::maxAmountChecked(int checked) { void MainWindow::maxAmountChecked(int checked) {