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:
parent
aabdb50086
commit
291e86d9f9
|
@ -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();
|
||||
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
|
|
|
@ -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."));
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue
Block a user