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

fix(ui): don't emit filename change windows for every chat

This commit is contained in:
sudden6 2018-07-11 10:31:22 +02:00
parent aabdb50086
commit 291e86d9f9
No known key found for this signature in database
GPG Key ID: 279509B499E032B9
4 changed files with 10 additions and 6 deletions

View File

@ -169,7 +169,7 @@ signals:
void fileTransferInfo(ToxFile file);
void fileTransferRemotePausedUnpaused(ToxFile file, bool paused);
void fileTransferBrokenUnbroken(ToxFile file, bool broken);
void fileNameChanged();
void fileNameChanged(const ToxPk& friendPk);
void saveRequest();

View File

@ -283,7 +283,7 @@ void CoreFile::removeFile(uint32_t friendId, uint32_t fileId)
QString CoreFile::getCleanFileName(QString filename)
{
QRegularExpression regex("[<>:\"/\\|?*]");
QRegularExpression regex{QStringLiteral(R"([<>:"/\\|?])")};
filename.replace(regex, "_");
return filename;
@ -295,9 +295,9 @@ void CoreFile::onFileReceiveCallback(Tox*, uint32_t friendId, uint32_t fileId, u
{
Core* core = static_cast<Core*>(vCore);
auto filename = ToxString(fname, fnameLen);
const ToxPk friendPk = core->getFriendPublicKey(friendId);
if (kind == TOX_FILE_KIND_AVATAR) {
const ToxPk friendPk = core->getFriendPublicKey(friendId);
if (!filesize) {
qDebug() << QString("Received empty avatar request %1:%2").arg(friendId).arg(fileId);
// Avatars of size 0 means explicitely no avatar
@ -318,7 +318,7 @@ void CoreFile::onFileReceiveCallback(Tox*, uint32_t friendId, uint32_t fileId, u
if (cleanFileName != filename.getQString()) {
qDebug() << QStringLiteral("Cleaned filename");
filename = ToxString(cleanFileName);
emit core->fileNameChanged();
emit core->fileNameChanged(friendPk);
} else {
qDebug() << QStringLiteral("filename already clean");
}

View File

@ -233,8 +233,12 @@ void ChatForm::onSendTriggered()
SendMessageStr(msgEdit->toPlainText());
msgEdit->clear();
}
void ChatForm::onFileNameChanged()
void ChatForm::onFileNameChanged(const ToxPk& friendPk)
{
if(friendPk != f->getPublicKey()) {
return;
}
QMessageBox::warning(this, tr("Filename contained illegal characters"),
tr("Illegal characters have been changed to _ \n"
"so you can save the file on windows."));

View File

@ -74,7 +74,7 @@ public slots:
void onAvEnd(uint32_t friendId, bool error);
void onAvatarChange(uint32_t friendId, const QPixmap& pic);
void onAvatarRemoved(const ToxPk& friendPk);
void onFileNameChanged();
void onFileNameChanged(const ToxPk& friendPk);
protected slots:
void onSearchUp(const QString& phrase) override;