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