mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
make import run once
and rename function
This commit is contained in:
parent
20d0eb06f6
commit
e5a5074f91
|
@ -329,7 +329,7 @@ void Core::start()
|
||||||
toxav_register_audio_callback(toxav, playCallAudio, this);
|
toxav_register_audio_callback(toxav, playCallAudio, this);
|
||||||
toxav_register_video_callback(toxav, playCallVideo, this);
|
toxav_register_video_callback(toxav, playCallVideo, this);
|
||||||
|
|
||||||
HistoryKeeper::getInstance()->importAvatar(getSelfId().toString().left(64));
|
HistoryKeeper::getInstance()->importAvatarToDatabase(getSelfId().toString().left(64));
|
||||||
QPixmap pic = Settings::getInstance().getSavedAvatar(getSelfId().toString());
|
QPixmap pic = Settings::getInstance().getSavedAvatar(getSelfId().toString());
|
||||||
if (!pic.isNull() && !pic.size().isEmpty())
|
if (!pic.isNull() && !pic.size().isEmpty())
|
||||||
{
|
{
|
||||||
|
|
|
@ -40,7 +40,7 @@ Friend::Friend(uint32_t FriendId, const ToxId &UserId)
|
||||||
|
|
||||||
widget = new FriendWidget(friendId, getDisplayedName());
|
widget = new FriendWidget(friendId, getDisplayedName());
|
||||||
chatForm = new ChatForm(this);
|
chatForm = new ChatForm(this);
|
||||||
HistoryKeeper::getInstance()->importAvatar(UserId.publicKey);
|
HistoryKeeper::getInstance()->importAvatarToDatabase(UserId.publicKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
Friend::~Friend()
|
Friend::~Friend()
|
||||||
|
|
|
@ -152,6 +152,7 @@ HistoryKeeper::HistoryKeeper(GenericDdInterface *db_) :
|
||||||
if (!ans.value(1).toString().contains("avatar"))
|
if (!ans.value(1).toString().contains("avatar"))
|
||||||
{
|
{
|
||||||
//add collum in table
|
//add collum in table
|
||||||
|
needImport = true;
|
||||||
db->exec("ALTER TABLE aliases ADD COLUMN avatar BLOB");
|
db->exec("ALTER TABLE aliases ADD COLUMN avatar BLOB");
|
||||||
qDebug() << "Struct DB updated: Added column avatar in table aliases.";
|
qDebug() << "Struct DB updated: Added column avatar in table aliases.";
|
||||||
}
|
}
|
||||||
|
@ -167,18 +168,21 @@ HistoryKeeper::HistoryKeeper(GenericDdInterface *db_) :
|
||||||
messageID = sqlAnswer.value(0).toLongLong();
|
messageID = sqlAnswer.value(0).toLongLong();
|
||||||
}
|
}
|
||||||
|
|
||||||
void HistoryKeeper::importAvatar(const QString& ownerId)
|
void HistoryKeeper::importAvatarToDatabase(const QString& ownerId)
|
||||||
{
|
{
|
||||||
QString puth (Settings::getInstance().getSettingsDirPath() +
|
if (needImport)
|
||||||
QString("avatars") + QDir::separator() +
|
|
||||||
ownerId +".png");
|
|
||||||
qDebug() << QString("Try import avatar for: %1.").arg(ownerId);
|
|
||||||
getAliasID(ownerId);
|
|
||||||
if (QFile::exists(puth) && !hasAvatar(ownerId))
|
|
||||||
{
|
{
|
||||||
QPixmap pic(puth);
|
QString puth (Settings::getInstance().getSettingsDirPath() +
|
||||||
saveAvatar(pic,ownerId);
|
QString("avatars") + QDir::separator() +
|
||||||
qDebug() << QString("Import avatar for: %1.").arg(ownerId);
|
ownerId +".png");
|
||||||
|
qDebug() << QString("Try import avatar for: %1.").arg(ownerId);
|
||||||
|
getAliasID(ownerId);
|
||||||
|
if (QFile::exists(puth) && !hasAvatar(ownerId))
|
||||||
|
{
|
||||||
|
QPixmap pic(puth);
|
||||||
|
saveAvatar(pic,ownerId);
|
||||||
|
qDebug() << QString("Import avatar for: %1.").arg(ownerId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -83,7 +83,7 @@ public:
|
||||||
void removeAvatar(const QString& ownerId);
|
void removeAvatar(const QString& ownerId);
|
||||||
bool hasAvatar(const QString& ownerId);
|
bool hasAvatar(const QString& ownerId);
|
||||||
|
|
||||||
void importAvatar(const QString& ownerId); // may be deleted after all move to new db structure
|
void importAvatarToDatabase(const QString& ownerId); // may be deleted after all move to new db structure
|
||||||
|
|
||||||
private:
|
private:
|
||||||
HistoryKeeper(GenericDdInterface *db_);
|
HistoryKeeper(GenericDdInterface *db_);
|
||||||
|
@ -99,7 +99,7 @@ private:
|
||||||
QList<QString> generateAddChatEntryCmd(const QString& chat, const QString& message, const QString& sender, const QDateTime &dt, bool isSent, QString dispName);
|
QList<QString> generateAddChatEntryCmd(const QString& chat, const QString& message, const QString& sender, const QDateTime &dt, bool isSent, QString dispName);
|
||||||
|
|
||||||
ChatType convertToChatType(int);
|
ChatType convertToChatType(int);
|
||||||
|
bool needImport = false; // must be deleted with "importAvatarToDatabase"
|
||||||
GenericDdInterface *db;
|
GenericDdInterface *db;
|
||||||
QMap<QString, int> aliases;
|
QMap<QString, int> aliases;
|
||||||
QMap<QString, QPair<int, ChatType>> chats;
|
QMap<QString, QPair<int, ChatType>> chats;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user