mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
refactor: onTextEditChanged method refactoring
Made as single commit because this change requires an explanation. As i understand, `getTypingNotification` always return the same value because `setTypingNotification` is not connected for any signal and the only time it's called - from `PrivacyForm`'s method which is never called and also is not connected to signals. I guess that removing `getTypingNotification` from `onTextEditChanged` will not affect anything
This commit is contained in:
parent
731f588f05
commit
83b3449d0a
|
@ -62,16 +62,24 @@ static const QString MIC_BTN_STYLESHEET = QStringLiteral(":/ui/micButton/micButt
|
||||||
static const QString VIDEO_BTN_STYLESHEET = QStringLiteral(":/ui/videoButton/videoButton.css");
|
static const QString VIDEO_BTN_STYLESHEET = QStringLiteral(":/ui/videoButton/videoButton.css");
|
||||||
static const QString VOL_BTN_STYLESHEET = QStringLiteral(":/ui/volButton/volButton.css");
|
static const QString VOL_BTN_STYLESHEET = QStringLiteral(":/ui/volButton/volButton.css");
|
||||||
|
|
||||||
// Associated with "Status" enum, don't change items's order
|
|
||||||
static const QVector<QString> STATUS_TO_STRING {
|
|
||||||
ChatForm::tr("online", "contact status"),
|
|
||||||
ChatForm::tr("away", "contact status"),
|
|
||||||
ChatForm::tr("busy", "contact status"),
|
|
||||||
ChatForm::tr("offline", "contact status")
|
|
||||||
};
|
|
||||||
|
|
||||||
const QString ChatForm::ACTION_PREFIX = QStringLiteral("/me ");
|
const QString ChatForm::ACTION_PREFIX = QStringLiteral("/me ");
|
||||||
|
|
||||||
|
QString statusToString(const Status status)
|
||||||
|
{
|
||||||
|
QString result;
|
||||||
|
switch (status) {
|
||||||
|
case Status::Online: result = ChatForm::tr("online", "contact status");
|
||||||
|
break;
|
||||||
|
case Status::Away: result = ChatForm::tr("away", "contact status");
|
||||||
|
break;
|
||||||
|
case Status::Busy: result = ChatForm::tr("busy", "contact status");
|
||||||
|
break;
|
||||||
|
case Status::Offline: result = ChatForm::tr("offline", "contact status");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
QString secondsToDHMS(quint32 duration)
|
QString secondsToDHMS(quint32 duration)
|
||||||
{
|
{
|
||||||
QString res;
|
QString res;
|
||||||
|
@ -208,25 +216,22 @@ void ChatForm::onSendTriggered()
|
||||||
|
|
||||||
void ChatForm::onTextEditChanged()
|
void ChatForm::onTextEditChanged()
|
||||||
{
|
{
|
||||||
Core* core = Core::getInstance();
|
|
||||||
if (!Settings::getInstance().getTypingNotification()) {
|
if (!Settings::getInstance().getTypingNotification()) {
|
||||||
if (isTyping) {
|
if (isTyping) {
|
||||||
core->sendTyping(f->getFriendId(), false);
|
isTyping = false;
|
||||||
|
Core::getInstance()->sendTyping(f->getFriendId(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
isTyping = false;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
bool isTypingNow = !msgEdit->toPlainText().isEmpty();
|
||||||
if (msgEdit->toPlainText().length() > 0) {
|
if (isTyping != isTypingNow) {
|
||||||
typingTimer.start(TYPING_NOTIFICATION_DURATION);
|
Core::getInstance()->sendTyping(f->getFriendId(), isTypingNow);
|
||||||
if (!isTyping) {
|
if (isTypingNow) {
|
||||||
isTyping = true;
|
typingTimer.start(TYPING_NOTIFICATION_DURATION);
|
||||||
core->sendTyping(f->getFriendId(), isTyping);
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
isTyping = false;
|
isTyping = isTypingNow;
|
||||||
core->sendTyping(f->getFriendId(), isTyping);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -350,7 +355,7 @@ void ChatForm::onAvInvite(uint32_t friendId, bool video)
|
||||||
onAvStart(friendId, video);
|
onAvStart(friendId, video);
|
||||||
} else {
|
} else {
|
||||||
callConfirm->show();
|
callConfirm->show();
|
||||||
auto* confirmData = callConfirm.data();
|
CallConfirmWidget* confirmData = callConfirm.data();
|
||||||
connect(confirmData, &CallConfirmWidget::accepted, this, &ChatForm::onAnswerCallTriggered);
|
connect(confirmData, &CallConfirmWidget::accepted, this, &ChatForm::onAnswerCallTriggered);
|
||||||
connect(confirmData, &CallConfirmWidget::rejected, this, &ChatForm::onRejectCallTriggered);
|
connect(confirmData, &CallConfirmWidget::rejected, this, &ChatForm::onRejectCallTriggered);
|
||||||
auto msg = ChatMessage::createChatInfoMessage(tr("%1 calling").arg(displayedName),
|
auto msg = ChatMessage::createChatInfoMessage(tr("%1 calling").arg(displayedName),
|
||||||
|
@ -536,7 +541,7 @@ void ChatForm::onFriendStatusChanged(uint32_t friendId, Status status)
|
||||||
updateCallButtons();
|
updateCallButtons();
|
||||||
|
|
||||||
if (Settings::getInstance().getStatusChangeNotificationEnabled()) {
|
if (Settings::getInstance().getStatusChangeNotificationEnabled()) {
|
||||||
QString fStatus = STATUS_TO_STRING[static_cast<int>(status)];
|
QString fStatus = statusToString(status);
|
||||||
addSystemInfoMessage(tr("%1 is now %2", "e.g. \"Dubslow is now online\"")
|
addSystemInfoMessage(tr("%1 is now %2", "e.g. \"Dubslow is now online\"")
|
||||||
.arg(f->getDisplayedName())
|
.arg(f->getDisplayedName())
|
||||||
.arg(fStatus),
|
.arg(fStatus),
|
||||||
|
@ -883,7 +888,7 @@ void ChatForm::updateMuteVolButton()
|
||||||
|
|
||||||
void ChatForm::startCounter()
|
void ChatForm::startCounter()
|
||||||
{
|
{
|
||||||
if (callDurationTimer != nullptr) {
|
if (callDurationTimer) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
callDurationTimer = new QTimer();
|
callDurationTimer = new QTimer();
|
||||||
|
@ -895,7 +900,7 @@ void ChatForm::startCounter()
|
||||||
|
|
||||||
void ChatForm::stopCounter()
|
void ChatForm::stopCounter()
|
||||||
{
|
{
|
||||||
if (callDurationTimer == nullptr) {
|
if (!callDurationTimer) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QString dhms = secondsToDHMS(timeElapsed.elapsed() / 1000);
|
QString dhms = secondsToDHMS(timeElapsed.elapsed() / 1000);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user