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

Merge pull request #314 from dubslow/master

api update
This commit is contained in:
Tux3 / Mlkj / !Lev.uXFMLA 2014-09-25 20:08:43 +02:00
commit b305566267
2 changed files with 10 additions and 8 deletions

View File

@ -218,7 +218,7 @@ void Core::start()
buffer.open(QIODevice::WriteOnly); buffer.open(QIODevice::WriteOnly);
pic.save(&buffer, "PNG"); pic.save(&buffer, "PNG");
buffer.close(); buffer.close();
if (tox_set_avatar(tox, TOX_AVATARFORMAT_PNG, (uint8_t*)data.constData(), data.size()) != 0) if (tox_set_avatar(tox, TOX_AVATAR_FORMAT_PNG, (uint8_t*)data.constData(), data.size()) != 0)
qWarning() << "Core:start: Error setting avatar, size:"<<data.size(); qWarning() << "Core:start: Error setting avatar, size:"<<data.size();
emit selfAvatarChanged(pic); emit selfAvatarChanged(pic);
} }

View File

@ -278,19 +278,21 @@ Camera* Widget::getCamera()
void Widget::onAvatarClicked() void Widget::onAvatarClicked()
{ {
QString filename = QFileDialog::getOpenFileName(this, "Choose a profile picture"); QString filename = QFileDialog::getOpenFileName(this, tr("Choose a profile picture"), QDir::homePath(), "*.png");
if (filename == "")
return;
QFile file(filename); QFile file(filename);
file.open(QIODevice::ReadOnly); file.open(QIODevice::ReadOnly);
if (!file.isOpen()) if (!file.isOpen())
{ {
QMessageBox::critical(this, "Error", "Unable to open this file"); QMessageBox::critical(this, tr("Error"), tr("Unable to open this file"));
return; return;
} }
QPixmap pic; QPixmap pic;
if (!pic.loadFromData(file.readAll())) if (!pic.loadFromData(file.readAll()))
{ {
QMessageBox::critical(this, "Error", "Unable to read this image"); QMessageBox::critical(this, tr("Error"), tr("Unable to read this image"));
return; return;
} }
@ -300,7 +302,7 @@ void Widget::onAvatarClicked()
pic.save(&buffer, "PNG"); pic.save(&buffer, "PNG");
buffer.close(); buffer.close();
if (bytes.size() >= TOX_MAX_AVATAR_DATA_LENGTH) if (bytes.size() >= TOX_AVATAR_MAX_DATA_LENGTH)
{ {
pic = pic.scaled(64,64, Qt::KeepAspectRatio, Qt::SmoothTransformation); pic = pic.scaled(64,64, Qt::KeepAspectRatio, Qt::SmoothTransformation);
bytes.clear(); bytes.clear();
@ -309,13 +311,13 @@ void Widget::onAvatarClicked()
buffer.close(); buffer.close();
} }
if (bytes.size() >= TOX_MAX_AVATAR_DATA_LENGTH) if (bytes.size() >= TOX_AVATAR_MAX_DATA_LENGTH)
{ {
QMessageBox::critical(this, "Error", "This image is too big"); QMessageBox::critical(this, tr("Error"), tr("This image is too big"));
return; return;
} }
core->setAvatar(TOX_AVATARFORMAT_PNG, bytes); core->setAvatar(TOX_AVATAR_FORMAT_PNG, bytes);
} }
void Widget::onSelfAvatarLoaded(const QPixmap& pic) void Widget::onSelfAvatarLoaded(const QPixmap& pic)