2018-09-09 10:04:19 -04:00
|
|
|
#include "messagereplydialog.h"
|
2024-11-12 07:50:08 -08:00
|
|
|
#include <QSet>
|
|
|
|
|
#include "EventFilter.hpp"
|
2018-09-09 10:04:19 -04:00
|
|
|
#include "varicode.h"
|
2024-11-12 07:50:08 -08:00
|
|
|
#include "ui_messagereplydialog.h"
|
2018-09-09 10:04:19 -04:00
|
|
|
|
2018-09-10 10:18:13 -04:00
|
|
|
|
2018-09-09 10:04:19 -04:00
|
|
|
MessageReplyDialog::MessageReplyDialog(QWidget *parent) :
|
|
|
|
|
QDialog(parent),
|
|
|
|
|
ui(new Ui::MessageReplyDialog)
|
|
|
|
|
{
|
|
|
|
|
ui->setupUi(this);
|
2024-11-12 08:58:57 -08:00
|
|
|
ui->textEdit->installEventFilter(new EventFilter::EnterKeyPress([this](QKeyEvent * const event)
|
2024-11-12 07:50:08 -08:00
|
|
|
{
|
2024-11-12 08:58:57 -08:00
|
|
|
if (event->modifiers() & Qt::ShiftModifier) return false;
|
2024-11-12 07:50:08 -08:00
|
|
|
this->accept();
|
2024-11-12 08:58:57 -08:00
|
|
|
return true;
|
|
|
|
|
}, this));
|
2018-09-09 10:04:19 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MessageReplyDialog::~MessageReplyDialog()
|
|
|
|
|
{
|
|
|
|
|
delete ui;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MessageReplyDialog::setLabel(QString value){
|
|
|
|
|
ui->label->setText(value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MessageReplyDialog::setTextValue(QString text){
|
|
|
|
|
ui->textEdit->setPlainText(text);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString MessageReplyDialog::textValue() const {
|
|
|
|
|
return ui->textEdit->toPlainText();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MessageReplyDialog::on_textEdit_textChanged(){
|
|
|
|
|
auto text = ui->textEdit->toPlainText();
|
|
|
|
|
|
|
|
|
|
QString x;
|
|
|
|
|
QString::const_iterator i;
|
|
|
|
|
for(i = text.constBegin(); i != text.constEnd(); i++){
|
2018-10-03 12:36:45 -04:00
|
|
|
auto ch = (*i).toUpper().toLatin1();
|
|
|
|
|
if(ch == 10 || (32 <= ch && ch <= 126)){
|
|
|
|
|
// newline or printable 7-bit ascii
|
2018-09-09 10:04:19 -04:00
|
|
|
x += ch;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(x != text){
|
|
|
|
|
int pos = ui->textEdit->textCursor().position();
|
|
|
|
|
int maxpos = x.size();
|
|
|
|
|
ui->textEdit->setPlainText(x);
|
|
|
|
|
QTextCursor c = ui->textEdit->textCursor();
|
|
|
|
|
c.setPosition(pos < maxpos ? pos : maxpos, QTextCursor::MoveAnchor);
|
|
|
|
|
|
|
|
|
|
ui->textEdit->setTextCursor(c);
|
|
|
|
|
}
|
|
|
|
|
}
|