Handle long memos
This commit is contained in:
@@ -132,6 +132,9 @@
|
|||||||
<property name="text">
|
<property name="text">
|
||||||
<string>TextLabel</string>
|
<string>TextLabel</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="wordWrap">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="2">
|
<item row="2" column="2">
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QTabWidget" name="tabWidget">
|
<widget class="QTabWidget" name="tabWidget">
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>0</number>
|
<number>1</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="tab">
|
<widget class="QWidget" name="tab">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
@@ -419,6 +419,9 @@
|
|||||||
<property name="text">
|
<property name="text">
|
||||||
<string/>
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="wordWrap">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
|||||||
@@ -6,17 +6,14 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>618</width>
|
<width>520</width>
|
||||||
<height>115</height>
|
<height>168</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Dialog</string>
|
<string>Dialog</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<item row="1" column="0" colspan="2">
|
|
||||||
<widget class="QLineEdit" name="memoTxt"/>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QLabel" name="label">
|
<widget class="QLabel" name="label">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@@ -27,14 +24,14 @@
|
|||||||
<item row="0" column="1">
|
<item row="0" column="1">
|
||||||
<widget class="QLabel" name="memoSize">
|
<widget class="QLabel" name="memoSize">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>6 / 512</string>
|
<string>0 / 512</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="alignment">
|
<property name="alignment">
|
||||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="0" colspan="2">
|
<item row="2" column="0" colspan="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>
|
||||||
@@ -44,18 +41,8 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0" colspan="2">
|
<item row="1" column="0" colspan="2">
|
||||||
<spacer name="verticalSpacer">
|
<widget class="QPlainTextEdit" name="memoTxt"/>
|
||||||
<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>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
|||||||
@@ -191,6 +191,7 @@ void MainWindow::addAddressSection() {
|
|||||||
QFont font1 = Address1->font();
|
QFont font1 = Address1->font();
|
||||||
font1.setPointSize(font1.pointSize()-1);
|
font1.setPointSize(font1.pointSize()-1);
|
||||||
MemoTxt1->setFont(font1);
|
MemoTxt1->setFont(font1);
|
||||||
|
MemoTxt1->setWordWrap(true);
|
||||||
sendAddressLayout->addWidget(MemoTxt1);
|
sendAddressLayout->addWidget(MemoTxt1);
|
||||||
|
|
||||||
ui->sendToLayout->insertWidget(itemNumber-1, verticalGroupBox);
|
ui->sendToLayout->insertWidget(itemNumber-1, verticalGroupBox);
|
||||||
@@ -234,33 +235,26 @@ void MainWindow::memoButtonClicked(int number) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto memoTxt = ui->sendToWidgets->findChild<QLabel *>(QString("MemoTxt") + QString::number(number));
|
|
||||||
// Get the current memo if it exists
|
// Get the current memo if it exists
|
||||||
|
auto memoTxt = ui->sendToWidgets->findChild<QLabel *>(QString("MemoTxt") + QString::number(number));
|
||||||
QString currentMemo = memoTxt->text();
|
QString currentMemo = memoTxt->text();
|
||||||
|
|
||||||
// Ref to see if the button was clicked
|
|
||||||
// bool ok;
|
|
||||||
// QString newMemo = QInputDialog::getText(this, "Memo",
|
|
||||||
// "Please type a memo to include with the amount. The memo will be visible to the recepient",
|
|
||||||
// QLineEdit::Normal, currentMemo, &ok);
|
|
||||||
Ui_MemoDialog memoDialog;
|
Ui_MemoDialog memoDialog;
|
||||||
QDialog dialog(this);
|
QDialog dialog(this);
|
||||||
memoDialog.setupUi(&dialog);
|
memoDialog.setupUi(&dialog);
|
||||||
|
|
||||||
QObject::connect(memoDialog.memoTxt, &QLineEdit::textChanged, [=] (QString txt) {
|
QObject::connect(memoDialog.memoTxt, &QPlainTextEdit::textChanged, [=] () {
|
||||||
|
QString txt = memoDialog.memoTxt->toPlainText();
|
||||||
memoDialog.memoSize->setText(QString::number(txt.toUtf8().size()) + "/512");
|
memoDialog.memoSize->setText(QString::number(txt.toUtf8().size()) + "/512");
|
||||||
|
|
||||||
memoDialog.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(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);
|
|
||||||
|
memoDialog.memoTxt->setPlainText(currentMemo);
|
||||||
|
memoDialog.memoTxt->setFocus();
|
||||||
|
|
||||||
if (dialog.exec() == QDialog::Accepted) {
|
if (dialog.exec() == QDialog::Accepted) {
|
||||||
memoTxt->setText(memoDialog.memoTxt->text());
|
memoTxt->setText(memoDialog.memoTxt->toPlainText());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -414,6 +408,7 @@ bool MainWindow::confirmTx(Tx tx, ToFields devFee) {
|
|||||||
QFont font1 = Addr->font();
|
QFont font1 = Addr->font();
|
||||||
font1.setPointSize(font1.pointSize() - 1);
|
font1.setPointSize(font1.pointSize() - 1);
|
||||||
Memo->setFont(font1);
|
Memo->setFont(font1);
|
||||||
|
Memo->setWordWrap(true);
|
||||||
|
|
||||||
confirm.gridLayout->addWidget(Memo, (i*2)+1, 0, 1, 3);
|
confirm.gridLayout->addWidget(Memo, (i*2)+1, 0, 1, 3);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -125,6 +125,7 @@ public:
|
|||||||
|
|
||||||
Memo1 = new QLabel(sendToAddrs);
|
Memo1 = new QLabel(sendToAddrs);
|
||||||
Memo1->setObjectName(QStringLiteral("Memo1"));
|
Memo1->setObjectName(QStringLiteral("Memo1"));
|
||||||
|
Memo1->setWordWrap(true);
|
||||||
|
|
||||||
gridLayout->addWidget(Memo1, 1, 0, 1, 3);
|
gridLayout->addWidget(Memo1, 1, 0, 1, 3);
|
||||||
|
|
||||||
|
|||||||
@@ -434,6 +434,7 @@ public:
|
|||||||
QFont font1;
|
QFont font1;
|
||||||
font1.setPointSize(10);
|
font1.setPointSize(10);
|
||||||
MemoTxt1->setFont(font1);
|
MemoTxt1->setFont(font1);
|
||||||
|
MemoTxt1->setWordWrap(true);
|
||||||
|
|
||||||
sendAddressLayout->addWidget(MemoTxt1);
|
sendAddressLayout->addWidget(MemoTxt1);
|
||||||
|
|
||||||
@@ -675,7 +676,7 @@ public:
|
|||||||
|
|
||||||
retranslateUi(MainWindow);
|
retranslateUi(MainWindow);
|
||||||
|
|
||||||
tabWidget->setCurrentIndex(0);
|
tabWidget->setCurrentIndex(1);
|
||||||
|
|
||||||
|
|
||||||
QMetaObject::connectSlotsByName(MainWindow);
|
QMetaObject::connectSlotsByName(MainWindow);
|
||||||
|
|||||||
@@ -15,8 +15,7 @@
|
|||||||
#include <QtWidgets/QDialogButtonBox>
|
#include <QtWidgets/QDialogButtonBox>
|
||||||
#include <QtWidgets/QGridLayout>
|
#include <QtWidgets/QGridLayout>
|
||||||
#include <QtWidgets/QLabel>
|
#include <QtWidgets/QLabel>
|
||||||
#include <QtWidgets/QLineEdit>
|
#include <QtWidgets/QPlainTextEdit>
|
||||||
#include <QtWidgets/QSpacerItem>
|
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
@@ -24,24 +23,18 @@ class Ui_MemoDialog
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QGridLayout *gridLayout;
|
QGridLayout *gridLayout;
|
||||||
QLineEdit *memoTxt;
|
|
||||||
QLabel *label;
|
QLabel *label;
|
||||||
QLabel *memoSize;
|
QLabel *memoSize;
|
||||||
QDialogButtonBox *buttonBox;
|
QDialogButtonBox *buttonBox;
|
||||||
QSpacerItem *verticalSpacer;
|
QPlainTextEdit *memoTxt;
|
||||||
|
|
||||||
void setupUi(QDialog *MemoDialog)
|
void setupUi(QDialog *MemoDialog)
|
||||||
{
|
{
|
||||||
if (MemoDialog->objectName().isEmpty())
|
if (MemoDialog->objectName().isEmpty())
|
||||||
MemoDialog->setObjectName(QStringLiteral("MemoDialog"));
|
MemoDialog->setObjectName(QStringLiteral("MemoDialog"));
|
||||||
MemoDialog->resize(618, 115);
|
MemoDialog->resize(520, 168);
|
||||||
gridLayout = new QGridLayout(MemoDialog);
|
gridLayout = new QGridLayout(MemoDialog);
|
||||||
gridLayout->setObjectName(QStringLiteral("gridLayout"));
|
gridLayout->setObjectName(QStringLiteral("gridLayout"));
|
||||||
memoTxt = new QLineEdit(MemoDialog);
|
|
||||||
memoTxt->setObjectName(QStringLiteral("memoTxt"));
|
|
||||||
|
|
||||||
gridLayout->addWidget(memoTxt, 1, 0, 1, 2);
|
|
||||||
|
|
||||||
label = new QLabel(MemoDialog);
|
label = new QLabel(MemoDialog);
|
||||||
label->setObjectName(QStringLiteral("label"));
|
label->setObjectName(QStringLiteral("label"));
|
||||||
|
|
||||||
@@ -58,11 +51,12 @@ public:
|
|||||||
buttonBox->setOrientation(Qt::Horizontal);
|
buttonBox->setOrientation(Qt::Horizontal);
|
||||||
buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok);
|
buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok);
|
||||||
|
|
||||||
gridLayout->addWidget(buttonBox, 3, 0, 1, 2);
|
gridLayout->addWidget(buttonBox, 2, 0, 1, 2);
|
||||||
|
|
||||||
verticalSpacer = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding);
|
memoTxt = new QPlainTextEdit(MemoDialog);
|
||||||
|
memoTxt->setObjectName(QStringLiteral("memoTxt"));
|
||||||
|
|
||||||
gridLayout->addItem(verticalSpacer, 2, 0, 1, 2);
|
gridLayout->addWidget(memoTxt, 1, 0, 1, 2);
|
||||||
|
|
||||||
|
|
||||||
retranslateUi(MemoDialog);
|
retranslateUi(MemoDialog);
|
||||||
@@ -76,7 +70,7 @@ public:
|
|||||||
{
|
{
|
||||||
MemoDialog->setWindowTitle(QApplication::translate("MemoDialog", "Dialog", nullptr));
|
MemoDialog->setWindowTitle(QApplication::translate("MemoDialog", "Dialog", nullptr));
|
||||||
label->setText(QApplication::translate("MemoDialog", "Memo", nullptr));
|
label->setText(QApplication::translate("MemoDialog", "Memo", nullptr));
|
||||||
memoSize->setText(QApplication::translate("MemoDialog", "6 / 512", nullptr));
|
memoSize->setText(QApplication::translate("MemoDialog", "0 / 512", nullptr));
|
||||||
} // retranslateUi
|
} // retranslateUi
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user