Limit memo size
This commit is contained in:
97
src/memodialog.ui
Normal file
97
src/memodialog.ui
Normal file
@@ -0,0 +1,97 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>MemoDialog</class>
|
||||||
|
<widget class="QDialog" name="MemoDialog">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>618</width>
|
||||||
|
<height>115</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Dialog</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
|
<item row="1" column="0" colspan="2">
|
||||||
|
<widget class="QLineEdit" name="memoTxt"/>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="text">
|
||||||
|
<string>Memo</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QLabel" name="memoSize">
|
||||||
|
<property name="text">
|
||||||
|
<string>6 / 512</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="0" colspan="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="0" colspan="2">
|
||||||
|
<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>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonBox</sender>
|
||||||
|
<signal>accepted()</signal>
|
||||||
|
<receiver>MemoDialog</receiver>
|
||||||
|
<slot>accept()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>248</x>
|
||||||
|
<y>254</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>157</x>
|
||||||
|
<y>274</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonBox</sender>
|
||||||
|
<signal>rejected()</signal>
|
||||||
|
<receiver>MemoDialog</receiver>
|
||||||
|
<slot>reject()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>316</x>
|
||||||
|
<y>260</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>286</x>
|
||||||
|
<y>274</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
</connections>
|
||||||
|
</ui>
|
||||||
@@ -615,8 +615,7 @@ void RPC::refreshTransactions() {
|
|||||||
QString::fromStdString(it["txid"]),
|
QString::fromStdString(it["txid"]),
|
||||||
it["amount"].get<json::number_float_t>() + fee,
|
it["amount"].get<json::number_float_t>() + fee,
|
||||||
it["confirmations"].get<json::number_unsigned_t>(),
|
it["confirmations"].get<json::number_unsigned_t>(),
|
||||||
"", ""
|
"", "" };
|
||||||
};
|
|
||||||
|
|
||||||
txdata.push_back(tx);
|
txdata.push_back(tx);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "ui_mainwindow.h"
|
#include "ui_mainwindow.h"
|
||||||
#include "ui_confirm.h"
|
#include "ui_confirm.h"
|
||||||
|
#include "ui_memodialog.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
#include "rpc.h"
|
#include "rpc.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
@@ -238,13 +239,30 @@ void MainWindow::memoButtonClicked(int number) {
|
|||||||
QString currentMemo = memoTxt->text();
|
QString currentMemo = memoTxt->text();
|
||||||
|
|
||||||
// Ref to see if the button was clicked
|
// Ref to see if the button was clicked
|
||||||
bool ok;
|
// bool ok;
|
||||||
QString newMemo = QInputDialog::getText(this, "Memo",
|
// QString newMemo = QInputDialog::getText(this, "Memo",
|
||||||
"Please type a memo to include with the amount. The memo will be visible to the recepient",
|
// "Please type a memo to include with the amount. The memo will be visible to the recepient",
|
||||||
QLineEdit::Normal, currentMemo, &ok);
|
// QLineEdit::Normal, currentMemo, &ok);
|
||||||
if (ok) {
|
Ui_MemoDialog memoDialog;
|
||||||
memoTxt->setText(newMemo);
|
QDialog dialog(this);
|
||||||
|
memoDialog.setupUi(&dialog);
|
||||||
|
|
||||||
|
QObject::connect(memoDialog.memoTxt, &QLineEdit::textChanged, [=] (QString txt) {
|
||||||
|
memoDialog.memoSize->setText(QString::number(txt.toUtf8().size()) + "/512");
|
||||||
|
|
||||||
|
memoDialog.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(txt.toUtf8().size() <= 512);
|
||||||
|
if (txt.toUtf8().size() > 512) {
|
||||||
|
memoDialog.memoSize->setStyleSheet("color: red;");
|
||||||
|
} else {
|
||||||
|
memoDialog.memoSize->setStyleSheet("");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
memoDialog.memoTxt->setText(currentMemo);
|
||||||
|
|
||||||
|
if (dialog.exec() == QDialog::Accepted) {
|
||||||
|
memoTxt->setText(memoDialog.memoTxt->text());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::removeExtraAddresses() {
|
void MainWindow::removeExtraAddresses() {
|
||||||
|
|||||||
90
src/ui_memodialog.h
Normal file
90
src/ui_memodialog.h
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
/********************************************************************************
|
||||||
|
** Form generated from reading UI file 'memodialog.ui'
|
||||||
|
**
|
||||||
|
** Created by: Qt User Interface Compiler version 5.11.2
|
||||||
|
**
|
||||||
|
** WARNING! All changes made in this file will be lost when recompiling UI file!
|
||||||
|
********************************************************************************/
|
||||||
|
|
||||||
|
#ifndef UI_MEMODIALOG_H
|
||||||
|
#define UI_MEMODIALOG_H
|
||||||
|
|
||||||
|
#include <QtCore/QVariant>
|
||||||
|
#include <QtWidgets/QApplication>
|
||||||
|
#include <QtWidgets/QDialog>
|
||||||
|
#include <QtWidgets/QDialogButtonBox>
|
||||||
|
#include <QtWidgets/QGridLayout>
|
||||||
|
#include <QtWidgets/QLabel>
|
||||||
|
#include <QtWidgets/QLineEdit>
|
||||||
|
#include <QtWidgets/QSpacerItem>
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
class Ui_MemoDialog
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
QGridLayout *gridLayout;
|
||||||
|
QLineEdit *memoTxt;
|
||||||
|
QLabel *label;
|
||||||
|
QLabel *memoSize;
|
||||||
|
QDialogButtonBox *buttonBox;
|
||||||
|
QSpacerItem *verticalSpacer;
|
||||||
|
|
||||||
|
void setupUi(QDialog *MemoDialog)
|
||||||
|
{
|
||||||
|
if (MemoDialog->objectName().isEmpty())
|
||||||
|
MemoDialog->setObjectName(QStringLiteral("MemoDialog"));
|
||||||
|
MemoDialog->resize(618, 115);
|
||||||
|
gridLayout = new QGridLayout(MemoDialog);
|
||||||
|
gridLayout->setObjectName(QStringLiteral("gridLayout"));
|
||||||
|
memoTxt = new QLineEdit(MemoDialog);
|
||||||
|
memoTxt->setObjectName(QStringLiteral("memoTxt"));
|
||||||
|
|
||||||
|
gridLayout->addWidget(memoTxt, 1, 0, 1, 2);
|
||||||
|
|
||||||
|
label = new QLabel(MemoDialog);
|
||||||
|
label->setObjectName(QStringLiteral("label"));
|
||||||
|
|
||||||
|
gridLayout->addWidget(label, 0, 0, 1, 1);
|
||||||
|
|
||||||
|
memoSize = new QLabel(MemoDialog);
|
||||||
|
memoSize->setObjectName(QStringLiteral("memoSize"));
|
||||||
|
memoSize->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
|
||||||
|
|
||||||
|
gridLayout->addWidget(memoSize, 0, 1, 1, 1);
|
||||||
|
|
||||||
|
buttonBox = new QDialogButtonBox(MemoDialog);
|
||||||
|
buttonBox->setObjectName(QStringLiteral("buttonBox"));
|
||||||
|
buttonBox->setOrientation(Qt::Horizontal);
|
||||||
|
buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok);
|
||||||
|
|
||||||
|
gridLayout->addWidget(buttonBox, 3, 0, 1, 2);
|
||||||
|
|
||||||
|
verticalSpacer = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding);
|
||||||
|
|
||||||
|
gridLayout->addItem(verticalSpacer, 2, 0, 1, 2);
|
||||||
|
|
||||||
|
|
||||||
|
retranslateUi(MemoDialog);
|
||||||
|
QObject::connect(buttonBox, SIGNAL(accepted()), MemoDialog, SLOT(accept()));
|
||||||
|
QObject::connect(buttonBox, SIGNAL(rejected()), MemoDialog, SLOT(reject()));
|
||||||
|
|
||||||
|
QMetaObject::connectSlotsByName(MemoDialog);
|
||||||
|
} // setupUi
|
||||||
|
|
||||||
|
void retranslateUi(QDialog *MemoDialog)
|
||||||
|
{
|
||||||
|
MemoDialog->setWindowTitle(QApplication::translate("MemoDialog", "Dialog", nullptr));
|
||||||
|
label->setText(QApplication::translate("MemoDialog", "Memo", nullptr));
|
||||||
|
memoSize->setText(QApplication::translate("MemoDialog", "6 / 512", nullptr));
|
||||||
|
} // retranslateUi
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
class MemoDialog: public Ui_MemoDialog {};
|
||||||
|
} // namespace Ui
|
||||||
|
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
#endif // UI_MEMODIALOG_H
|
||||||
@@ -71,7 +71,8 @@ FORMS += \
|
|||||||
src/mainwindow.ui \
|
src/mainwindow.ui \
|
||||||
src/settings.ui \
|
src/settings.ui \
|
||||||
src/about.ui \
|
src/about.ui \
|
||||||
src/confirm.ui
|
src/confirm.ui \
|
||||||
|
src/memodialog.ui
|
||||||
|
|
||||||
# Default rules for deployment.
|
# Default rules for deployment.
|
||||||
qnx: target.path = /tmp/$${TARGET}/bin
|
qnx: target.path = /tmp/$${TARGET}/bin
|
||||||
|
|||||||
Reference in New Issue
Block a user