rename of chatmemoedit
This commit is contained in:
@@ -7,43 +7,43 @@
|
||||
Chat::Chat() {}
|
||||
|
||||
ChatMemoEdit::ChatMemoEdit(QWidget* parent) : QTextEdit(parent) {
|
||||
QObject::connect(this, &QTextEdit::textChanged, this, &ChatMemoEdit::updateDisplay);
|
||||
QObject::connect(this, &QTextEdit::textChanged, this, &ChatMemoEdit::updateDisplayChat);
|
||||
}
|
||||
|
||||
void ChatMemoEdit::updateDisplay() {
|
||||
void ChatMemoEdit::updateDisplayChat() {
|
||||
QString txt = this->toPlainText();
|
||||
if (lenDisplayLabel)
|
||||
lenDisplayLabel->setText(QString::number(txt.toUtf8().size()) + "/" + QString::number(maxlen));
|
||||
if (lenDisplayLabelchat)
|
||||
lenDisplayLabelchat->setText(QString::number(txt.toUtf8().size()) + "/" + QString::number(maxlenchat));
|
||||
|
||||
if (txt.toUtf8().size() <= maxlen) {
|
||||
if (txt.toUtf8().size() <= maxlenchat) {
|
||||
// Everything is fine
|
||||
if (sendChatButton)
|
||||
sendChatButton->setEnabled(true);
|
||||
|
||||
if (lenDisplayLabel)
|
||||
lenDisplayLabel->setStyleSheet("");
|
||||
if (lenDisplayLabelchat)
|
||||
lenDisplayLabelchat->setStyleSheet("");
|
||||
}
|
||||
else {
|
||||
// Overweight
|
||||
if (sendChatButton)
|
||||
sendChatButton->setEnabled(false);
|
||||
|
||||
if (lenDisplayLabel)
|
||||
lenDisplayLabel->setStyleSheet("color: red;");
|
||||
if (lenDisplayLabelchat)
|
||||
lenDisplayLabelchat->setStyleSheet("color: red;");
|
||||
}
|
||||
}
|
||||
|
||||
void ChatMemoEdit::setMaxLen(int len) {
|
||||
this->maxlen = len;
|
||||
updateDisplay();
|
||||
void ChatMemoEdit::setMaxLenChat(int len) {
|
||||
this->maxlenchat = len;
|
||||
updateDisplayChat();
|
||||
}
|
||||
|
||||
void ChatMemoEdit::SetSendChatButton(QPushButton* button) {
|
||||
this->sendChatButton = button;
|
||||
}
|
||||
|
||||
void ChatMemoEdit::setLenDisplayLabel(QLabel* label) {
|
||||
this->lenDisplayLabel = label;
|
||||
void ChatMemoEdit::setLenDisplayLabelChat(QLabel* label) {
|
||||
this->lenDisplayLabelchat = label;
|
||||
}
|
||||
|
||||
void Chat::renderChatBox(Ui::MainWindow *ui, QListView *view, QLabel *label)
|
||||
@@ -93,5 +93,7 @@ void Chat::renderChatBox(Ui::MainWindow *ui, QListView *view, QLabel *label)
|
||||
ui->listChat->setModel(chat);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
#include "ui_mainwindow.h"
|
||||
#include "ui_requestContactDialog.h"
|
||||
#include "addressbook.h"
|
||||
#include "ui_memodialog.h"
|
||||
#include "ui_contactrequest.h"
|
||||
#include <QtWidgets>
|
||||
#include <QUuid>
|
||||
|
||||
@@ -1365,7 +1365,7 @@ void MainWindow::setupchatTab() {
|
||||
});
|
||||
|
||||
|
||||
ui->memoTxtChat->setLenDisplayLabel(ui->memoSizeChat);
|
||||
ui->memoTxtChat->setLenDisplayLabelChat(ui->memoSizeChat);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -60,8 +60,8 @@ public:
|
||||
void stopWebsocket();
|
||||
void saveContact();
|
||||
void saveandsendContact();
|
||||
void setMaxLen(int len);
|
||||
void updateDisplay();
|
||||
// void setmaxlenChat(int len);
|
||||
// void updateDisplay();
|
||||
|
||||
|
||||
void balancesReady();
|
||||
@@ -199,14 +199,14 @@ class ChatMemoEdit : public QTextEdit
|
||||
public:
|
||||
ChatMemoEdit(QWidget* parent);
|
||||
|
||||
void setMaxLen(int len);
|
||||
void setLenDisplayLabel(QLabel* label);
|
||||
void setMaxLenChat(int len);
|
||||
void setLenDisplayLabelChat(QLabel* label);
|
||||
void SetSendChatButton(QPushButton* button);
|
||||
void updateDisplay();
|
||||
void updateDisplayChat();
|
||||
|
||||
private:
|
||||
int maxlen = 512;
|
||||
QLabel* lenDisplayLabel = nullptr;
|
||||
int maxlenchat = 512;
|
||||
QLabel* lenDisplayLabelchat = nullptr;
|
||||
QPushButton* sendChatButton = nullptr;
|
||||
};
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@
|
||||
<customwidget>
|
||||
<class>MemoEdit</class>
|
||||
<extends>QPlainTextEdit</extends>
|
||||
<header>memoedit.h</header>
|
||||
<header location="global">memoedit.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
|
||||
Reference in New Issue
Block a user