1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

Added typing notification support and enabled by default

This commit is contained in:
novist 2015-01-04 13:20:36 +02:00
parent d042c2f346
commit 2a8cbd189d
6 changed files with 48 additions and 4 deletions

View File

@ -189,7 +189,7 @@ void Settings::load()
s.endGroup();
s.beginGroup("Privacy");
typingNotification = s.value("typingNotification", false).toBool();
typingNotification = s.value("typingNotification", true).toBool();
enableLogging = s.value("enableLogging", false).toBool();
encryptLogs = s.value("encryptLogs", false).toBool();
encryptTox = s.value("encryptTox", false).toBool();

View File

@ -54,6 +54,15 @@ ChatForm::ChatForm(Friend* chatFriend)
statusMessageLabel->setFont(Style::getFont(Style::Medium));
statusMessageLabel->setMinimumHeight(Style::getFont(Style::Medium).pixelSize());
isTypingLabel = new QLabel();
QFont font = isTypingLabel->font();
font.setItalic(true);
font.setPixelSize(8);
isTypingLabel->setFont(font);
QVBoxLayout* mainLayout = dynamic_cast<QVBoxLayout*>(layout());
mainLayout->insertWidget(1, isTypingLabel);
netcam = new NetCamView();
timer = nullptr;
@ -71,6 +80,7 @@ ChatForm::ChatForm(Friend* chatFriend)
connect(callButton, &QPushButton::clicked, this, &ChatForm::onCallTriggered);
connect(videoButton, &QPushButton::clicked, this, &ChatForm::onVideoCallTriggered);
connect(msgEdit, &ChatTextEdit::enterPressed, this, &ChatForm::onSendTriggered);
connect(msgEdit, &ChatTextEdit::textChanged, this, &ChatForm::onTextEditChanged);
connect(micButton, SIGNAL(clicked()), this, SLOT(onMicMuteToggle()));
connect(volButton, SIGNAL(clicked()), this, SLOT(onVolMuteToggle()));
connect(chatWidget, &ChatAreaWidget::onFileTranfertInterract, this, &ChatForm::onFileTansBtnClicked);
@ -132,6 +142,21 @@ void ChatForm::onSendTriggered()
msgEdit->clear();
}
void ChatForm::onTextEditChanged()
{
bool isNowTyping;
if (!Settings::getInstance().isTypingNotificationEnabled())
isNowTyping = false;
else
isNowTyping = msgEdit->toPlainText().length() > 0;
if (isTyping != isNowTyping)
{
isTyping = isNowTyping;
Core::getInstance()->sendTyping(f->getFriendID(), isTyping);
}
}
void ChatForm::onAttachClicked()
{
QStringList paths = QFileDialog::getOpenFileNames(0,tr("Send a file"));
@ -870,6 +895,14 @@ void ChatForm::dischargeReceipt(int receipt)
}
}
void ChatForm::setFriendTyping(bool isTyping)
{
if (isTyping)
isTypingLabel->setText(f->getDisplayedName() + " " + tr("is typing..."));
else
isTypingLabel->clear();
}
void ChatForm::clearReciepts()
{
receipts.clear();

View File

@ -39,6 +39,7 @@ public:
void loadHistory(QDateTime since, bool processUndelivered = false);
void dischargeReceipt(int receipt);
void setFriendTyping(bool isTyping);
signals:
void sendFile(int32_t friendId, QString, QString, long long);
@ -75,6 +76,7 @@ public slots:
private slots:
void onSendTriggered();
void onTextEditChanged();
void onAttachClicked();
void onCallTriggered();
void onVideoCallTriggered();
@ -100,6 +102,7 @@ private:
QLabel *callDuration;
QTimer *timer;
QElapsedTimer timeElapsed;
QLabel *isTypingLabel;
QHash<uint, FileTransferInstance*> ftransWidgets;
void startCounter();
@ -107,6 +110,7 @@ private:
QString secondsToDHMS(quint32 duration);
QHash<int, int> receipts;
QMap<int, MessageActionPtr> undeliveredMsgs;
bool isTyping;
};
#endif // CHATFORM_H

View File

@ -43,9 +43,6 @@
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QCheckBox" name="cbTypingNotification">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Typing Notification</string>
</property>

View File

@ -242,6 +242,7 @@ void Widget::init()
connect(core, &Core::avInvite, this, &Widget::playRingtone);
connect(core, &Core::blockingClearContacts, this, &Widget::clearContactsList, Qt::BlockingQueuedConnection);
connect(core, &Core::blockingGetPassword, this, &Widget::getPassword, Qt::BlockingQueuedConnection);
connect(core, &Core::friendTypingChanged, this, &Widget::onFriendTypingChanged);
connect(core, SIGNAL(messageSentResult(int,QString,int)), this, SLOT(onMessageSendResult(int,QString,int)));
connect(core, SIGNAL(groupSentResult(int,QString,int)), this, SLOT(onGroupSendResult(int,QString,int)));
@ -1178,6 +1179,14 @@ void Widget::getPassword(QString info, int passtype, uint8_t* salt)
}
}
void Widget::onFriendTypingChanged(int friendId, bool isTyping)
{
Friend* f = FriendList::findFriend(friendId);
if (!f)
return;
f->getChatForm()->setFriendTyping(isTyping);
}
void Widget::onSetShowSystemTray(bool newValue){
icon->setVisible(newValue);
}

View File

@ -132,6 +132,7 @@ private slots:
void onIconClick(QSystemTrayIcon::ActivationReason);
void onUserAwayCheck();
void getPassword(QString info, int passtype, uint8_t* salt);
void onFriendTypingChanged(int friendId, bool isTyping);
void onSetShowSystemTray(bool newValue);
void onSplitterMoved(int pos, int index);