Aditya Kulkarni
5 years ago
10 changed files with 282 additions and 28 deletions
@ -0,0 +1,44 @@ |
|||
#include "memoedit.h" |
|||
|
|||
MemoEdit::MemoEdit(QWidget* parent) : QPlainTextEdit(parent) { |
|||
QObject::connect(this, &QPlainTextEdit::textChanged, [=]() { |
|||
QString txt = this->toPlainText(); |
|||
if (lenDisplayLabel) |
|||
lenDisplayLabel->setText(QString::number(txt.toUtf8().size()) + "/" + QString::number(maxlen)); |
|||
|
|||
if (txt.toUtf8().size() <= maxlen) { |
|||
// Everything is fine
|
|||
acceptButton->setEnabled(true); |
|||
lenDisplayLabel->setStyleSheet(""); |
|||
} |
|||
else { |
|||
// Overweight
|
|||
acceptButton->setEnabled(false); |
|||
lenDisplayLabel->setStyleSheet("color: red;"); |
|||
} |
|||
|
|||
}); |
|||
} |
|||
|
|||
void MemoEdit::setMaxLen(int len) { |
|||
this->maxlen = len; |
|||
} |
|||
|
|||
void MemoEdit::setLenDisplayLabel(QLabel* label) { |
|||
this->lenDisplayLabel = label; |
|||
} |
|||
|
|||
void MemoEdit::setAcceptButton(QPushButton* button) { |
|||
this->acceptButton = button; |
|||
} |
|||
|
|||
void MemoEdit::includeReplyTo(QString addr) { |
|||
if (addr.isEmpty()) |
|||
return; |
|||
|
|||
auto curText = this->toPlainText(); |
|||
if (curText.endsWith(addr)) |
|||
return; |
|||
|
|||
this->setPlainText(curText + "\n" + tr("Reply to") + ":\n" + addr); |
|||
} |
@ -0,0 +1,22 @@ |
|||
#ifndef MEMOEDIT_H |
|||
#define MEMOEDIT_H |
|||
|
|||
#include "precompiled.h" |
|||
|
|||
class MemoEdit : public QPlainTextEdit |
|||
{ |
|||
public: |
|||
MemoEdit(QWidget* parent); |
|||
|
|||
void setMaxLen(int len); |
|||
void setLenDisplayLabel(QLabel* label); |
|||
void setAcceptButton(QPushButton* button); |
|||
void includeReplyTo(QString replyToAddress); |
|||
|
|||
private: |
|||
int maxlen = 512; |
|||
QLabel* lenDisplayLabel = nullptr; |
|||
QPushButton* acceptButton = nullptr; |
|||
}; |
|||
|
|||
#endif // MEMOEDIT_H
|
@ -0,0 +1,14 @@ |
|||
#include "requestdialog.h" |
|||
#include "ui_requestdialog.h" |
|||
|
|||
RequestDialog::RequestDialog(QWidget *parent) : |
|||
QDialog(parent), |
|||
ui(new Ui::RequestDialog) |
|||
{ |
|||
ui->setupUi(this); |
|||
} |
|||
|
|||
RequestDialog::~RequestDialog() |
|||
{ |
|||
delete ui; |
|||
} |
@ -0,0 +1,22 @@ |
|||
#ifndef REQUESTDIALOG_H |
|||
#define REQUESTDIALOG_H |
|||
|
|||
#include <QDialog> |
|||
|
|||
namespace Ui { |
|||
class RequestDialog; |
|||
} |
|||
|
|||
class RequestDialog : public QDialog |
|||
{ |
|||
Q_OBJECT |
|||
|
|||
public: |
|||
explicit RequestDialog(QWidget *parent = nullptr); |
|||
~RequestDialog(); |
|||
|
|||
private: |
|||
Ui::RequestDialog *ui; |
|||
}; |
|||
|
|||
#endif // REQUESTDIALOG_H
|
@ -0,0 +1,124 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<ui version="4.0"> |
|||
<class>RequestDialog</class> |
|||
<widget class="QDialog" name="RequestDialog"> |
|||
<property name="geometry"> |
|||
<rect> |
|||
<x>0</x> |
|||
<y>0</y> |
|||
<width>544</width> |
|||
<height>450</height> |
|||
</rect> |
|||
</property> |
|||
<property name="windowTitle"> |
|||
<string>Dialog</string> |
|||
</property> |
|||
<layout class="QGridLayout" name="gridLayout"> |
|||
<item row="1" column="1" colspan="3"> |
|||
<widget class="QLineEdit" name="txtAmount"> |
|||
<property name="alignment"> |
|||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> |
|||
</property> |
|||
<property name="placeholderText"> |
|||
<string>amount in ZEC</string> |
|||
</property> |
|||
</widget> |
|||
</item> |
|||
<item row="2" column="1" colspan="3"> |
|||
<widget class="QLabel" name="txtAmountUSD"> |
|||
<property name="text"> |
|||
<string>Amount USD</string> |
|||
</property> |
|||
<property name="alignment"> |
|||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> |
|||
</property> |
|||
</widget> |
|||
</item> |
|||
<item row="1" column="0"> |
|||
<widget class="QLabel" name="label_2"> |
|||
<property name="text"> |
|||
<string>Amount</string> |
|||
</property> |
|||
</widget> |
|||
</item> |
|||
<item row="3" column="1" colspan="3"> |
|||
<widget class="QTextEdit" name="txtMemo"/> |
|||
</item> |
|||
<item row="0" column="1" colspan="3"> |
|||
<widget class="QLineEdit" name="txtFrom"> |
|||
<property name="sizePolicy"> |
|||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed"> |
|||
<horstretch>0</horstretch> |
|||
<verstretch>0</verstretch> |
|||
</sizepolicy> |
|||
</property> |
|||
<property name="alignment"> |
|||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> |
|||
</property> |
|||
<property name="placeholderText"> |
|||
<string>z address</string> |
|||
</property> |
|||
</widget> |
|||
</item> |
|||
<item row="3" column="0"> |
|||
<widget class="QLabel" name="label_3"> |
|||
<property name="text"> |
|||
<string>Memo</string> |
|||
</property> |
|||
</widget> |
|||
</item> |
|||
<item row="0" column="0"> |
|||
<widget class="QLabel" name="label"> |
|||
<property name="text"> |
|||
<string>Request From</string> |
|||
</property> |
|||
</widget> |
|||
</item> |
|||
<item row="4" column="2" 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> |
|||
</layout> |
|||
</widget> |
|||
<resources/> |
|||
<connections> |
|||
<connection> |
|||
<sender>buttonBox</sender> |
|||
<signal>accepted()</signal> |
|||
<receiver>RequestDialog</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>RequestDialog</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> |
Loading…
Reference in new issue