mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
update delete avatar action
This commit is contained in:
parent
0a11ccbeab
commit
afb3bf35ee
|
@ -529,6 +529,15 @@ QList<HistoryKeeper::HistMessage> HistoryKeeper::exportMessagesDeleteFile()
|
||||||
|
|
||||||
return msgs;
|
return msgs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void HistoryKeeper::removeAvatar(const QString& ownerId)
|
||||||
|
{
|
||||||
|
QSqlQuery query;
|
||||||
|
query.prepare("UPDATE aliases SET avatar=NULL, av_hash=NULL WHERE user_id = (:id)");
|
||||||
|
query.bindValue(":id", ownerId.left(64));
|
||||||
|
query.exec();
|
||||||
|
}
|
||||||
|
|
||||||
void HistoryKeeper::saveAvatar(QPixmap& pic, const QString& ownerId)
|
void HistoryKeeper::saveAvatar(QPixmap& pic, const QString& ownerId)
|
||||||
{
|
{
|
||||||
QByteArray bArray;
|
QByteArray bArray;
|
||||||
|
|
|
@ -78,6 +78,8 @@ public:
|
||||||
void saveAvatarHash(const QByteArray& hash, const QString& ownerId);
|
void saveAvatarHash(const QByteArray& hash, const QString& ownerId);
|
||||||
QByteArray getAvatarHash(const QString& ownerId);
|
QByteArray getAvatarHash(const QString& ownerId);
|
||||||
|
|
||||||
|
void removeAvatar(const QString& ownerId);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
HistoryKeeper(GenericDdInterface *db_);
|
HistoryKeeper(GenericDdInterface *db_);
|
||||||
HistoryKeeper(HistoryKeeper &hk) = delete;
|
HistoryKeeper(HistoryKeeper &hk) = delete;
|
||||||
|
|
|
@ -184,18 +184,13 @@ void ProfileForm::showProfilePictureContextMenu(const QPoint &point)
|
||||||
QPoint pos = profilePicture->mapToGlobal(point);
|
QPoint pos = profilePicture->mapToGlobal(point);
|
||||||
|
|
||||||
QMenu contextMenu;
|
QMenu contextMenu;
|
||||||
QAction *removeAction = contextMenu.addAction(tr("Remove"));
|
QAction *removeAction = contextMenu.addAction(style()->standardIcon(QStyle::SP_DialogCancelButton), tr("Remove"));
|
||||||
QAction *selectedItem = contextMenu.exec(pos);
|
QAction *selectedItem = contextMenu.exec(pos);
|
||||||
|
|
||||||
if (selectedItem == removeAction)
|
if (selectedItem == removeAction)
|
||||||
{
|
{
|
||||||
QString selfPubKey = Core::getInstance()->getSelfId().publicKey;
|
QString selfPubKey = Core::getInstance()->getSelfId().publicKey;
|
||||||
if (!QFile::remove(Settings::getInstance().getSettingsDirPath()+"avatars/"+selfPubKey.left(64)+".png"))
|
HistoryKeeper::getInstance()->removeAvatar(selfPubKey);
|
||||||
{
|
|
||||||
GUI::showError(tr("Error"), tr("Could not remove avatar."));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Core::getInstance()->setAvatar({});
|
Core::getInstance()->setAvatar({});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user