Browse Source

Send page checkbox

recurring
Aditya Kulkarni 5 years ago
parent
commit
ace9038070
  1. 3
      src/mainwindow.h
  2. 72
      src/mainwindow.ui
  3. 199
      src/newrecurring.ui
  4. 60
      src/recurring.cpp
  5. 38
      src/recurring.h
  6. 30
      src/sendtab.cpp

3
src/mainwindow.h

@ -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);

72
src/mainwindow.ui

@ -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">
@ -531,29 +531,36 @@
</widget> </widget>
</item> </item>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_6"> <layout class="QHBoxLayout" name="horizontalLayout_17">
<item> <item>
<widget class="QLabel" name="minerFeeLabel"> <widget class="QCheckBox" name="chkRecurring">
<property name="text"> <property name="text">
<string>Miner Fee</string> <string>Recurring payment</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QLineEdit" name="minerFeeAmt"> <widget class="QLabel" name="lblRecurDesc">
<property name="sizePolicy"> <property name="text">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed"> <string>Every month, starting 12-May-2012, for 6 payments</string>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property> </property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnRecurSchedule">
<property name="text"> <property name="text">
<string>0</string> <string>Edit Schedule</string>
</property>
<property name="checkable">
<bool>false</bool>
</property>
<property name="checked">
<bool>false</bool>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<spacer name="horizontalSpacer"> <spacer name="horizontalSpacer_7">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
@ -565,34 +572,57 @@
</property> </property>
</spacer> </spacer>
</item> </item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item> <item>
<widget class="QLabel" name="lblMinerFeeUSD"> <widget class="QLabel" name="minerFeeLabel">
<property name="text"> <property name="text">
<string/> <string>Miner Fee</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QLabel" name="label_16"> <widget class="QLineEdit" name="minerFeeAmt">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text"> <property name="text">
<string>This transaction does not recur</string> <string>0</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QPushButton" name="pushButton"> <widget class="QLabel" name="lblMinerFeeUSD">
<property name="text"> <property name="text">
<string>Setup Recurring Payment</string> <string/>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QLabel" name="label_17"> <widget class="QLabel" name="label_17">
<property name="text"> <property name="text">
<string notr="true"> </string> <string notr="true"/>
</property> </property>
</widget> </widget>
</item> </item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</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">

199
src/newrecurring.ui

@ -1,29 +1,26 @@
<?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"> <layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLineEdit" name="lineEdit_4"/>
</item>
<item> <item>
<widget class="QComboBox" name="comboBox_3"/> <widget class="QComboBox" name="cmbSchedule"/>
</item> </item>
<item> <item>
<spacer name="horizontalSpacer_3"> <spacer name="horizontalSpacer">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
@ -37,10 +34,7 @@
</item> </item>
</layout> </layout>
</item> </item>
<item row="1" column="2"> <item row="10" column="2">
<widget class="QComboBox" name="comboBox"/>
</item>
<item row="9" column="2">
<widget class="QDialogButtonBox" name="buttonBox"> <widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
@ -50,85 +44,51 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="2"> <item row="5" column="1">
<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"> <widget class="QLabel" name="label_3">
<property name="text"> <property name="text">
<string>Schedule</string> <string>Schedule</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="5" column="1"> <item row="0" column="1">
<widget class="QLabel" name="label_5"> <widget class="QLabel" name="label_7">
<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"> <property name="text">
<string>Next Payment</string> <string>Payment Description</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="7" column="2"> <item row="8" column="2">
<widget class="QLabel" name="label_9"> <widget class="QLabel" name="lblNextPayment">
<property name="text"> <property name="text">
<string>TextLabel</string> <string>TextLabel</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="1"> <item row="7" column="1" colspan="2">
<widget class="QLabel" name="label_7"> <widget class="Line" name="line">
<property name="text"> <property name="orientation">
<string>Payment Description</string> <enum>Qt::Horizontal</enum>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="2"> <item row="3" column="2">
<widget class="QLineEdit" name="lineEdit_5"/> <layout class="QHBoxLayout" name="horizontalLayout_3">
</item>
<item row="4" column="2">
<layout class="QHBoxLayout" name="horizontalLayout">
<item> <item>
<widget class="QLabel" name="label_4"> <widget class="QLineEdit" name="txtAmt">
<property name="text"> <property name="sizePolicy">
<string>Every</string> <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QLineEdit" name="lineEdit_2"/> <widget class="QComboBox" name="cmbCurrency"/>
</item> </item>
<item> <item>
<widget class="QComboBox" name="comboBox_2"/> <spacer name="horizontalSpacer_3">
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
@ -142,17 +102,50 @@
</item> </item>
</layout> </layout>
</item> </item>
<item row="5" column="2"> <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"> <layout class="QHBoxLayout" name="horizontalLayout_2">
<item> <item>
<widget class="QLineEdit" name="lineEdit_3"/> <widget class="QLineEdit" name="txtNumPayments"/>
</item>
<item>
<widget class="QCheckBox" name="checkBox">
<property name="text">
<string>Forever</string>
</property>
</widget>
</item> </item>
<item> <item>
<spacer name="horizontalSpacer_2"> <spacer name="horizontalSpacer_2">
@ -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">

60
src/recurring.cpp

@ -1,14 +1,48 @@
#include "recurring.h" #include "recurring.h"
#include "ui_recurringdialog.h"
#include "mainwindow.h"
RecurringDialog::RecurringDialog(QWidget *parent) : #include "rpc.h"
QDialog(parent), #include "settings.h"
ui(new Ui::RecurringDialog) #include "ui_newrecurring.h"
{
ui->setupUi(this); void Recurring::showEditDialog(QWidget* parent, MainWindow* main, Tx tx) {
} Ui_newRecurringDialog ui;
QDialog d(parent);
RecurringDialog::~RecurringDialog() ui.setupUi(&d);
{ Settings::saveRestore(&d);
delete ui;
} // 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();
}

38
src/recurring.h

@ -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,
YEAR
};
struct RecurringPaymentInfo {
QString desc;
QString fromAddr;
QString toAddr;
double amt;
QString currency;
Schedule schedule;
int numPayments;
long startBlock;
int completedPayments;
};
class Recurring
{
public: public:
explicit RecurringDialog(QWidget *parent = nullptr); Recurring();
~RecurringDialog();
private: static void showEditDialog(QWidget* parent, MainWindow* main, Tx tx);
Ui::RecurringDialog *ui;
}; };
#endif // RECURRING_H #endif // RECURRING_H

30
src/sendtab.cpp

@ -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) {

Loading…
Cancel
Save