Add Headermemo, work in Progress

This commit is contained in:
DenioD
2020-04-28 20:32:31 +02:00
parent e681d3000d
commit 555ac40ec2
5 changed files with 91 additions and 71 deletions

View File

@@ -983,6 +983,54 @@ void MainWindow::setupTransactionsTab() {
});
}
void MainWindow::setupchatTab() {
// Send button
QObject::connect(ui->sendChatButton, &QPushButton::clicked, this, &MainWindow::sendChatButton);
}
ChatMemoEdit::ChatMemoEdit(QWidget* parent) : QPlainTextEdit(parent) {
QObject::connect(this, &QPlainTextEdit::textChanged, this, &ChatMemoEdit::updateDisplay);
}
void ChatMemoEdit::updateDisplay() {
QString txt = this->toPlainText();
if (lenDisplayLabel)
lenDisplayLabel->setText(QString::number(txt.toUtf8().size()) + "/" + QString::number(maxlen));
if (txt.toUtf8().size() <= maxlen) {
// Everything is fine
if (sendChatButton)
sendChatButton->setEnabled(true);
if (lenDisplayLabel)
lenDisplayLabel->setStyleSheet("");
}
else {
// Overweight
if (sendChatButton)
sendChatButton->setEnabled(false);
if (lenDisplayLabel)
lenDisplayLabel->setStyleSheet("color: red;");
}
}
void ChatMemoEdit::setMaxLen(int len) {
this->maxlen = len;
updateDisplay();
}
void ChatMemoEdit::setLenDisplayLabel(QLabel* label_40) {
this->lenDisplayLabel = label_40;
}
void ChatMemoEdit::setSendChatButton(QPushButton* button) {
this->sendChatButton = button;
}
void MainWindow::updateChat()
{
qDebug() << "Called MainWindow::updateChat()";