mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Update widget.cpp
Added support for dynamically generating supported format list.
This commit is contained in:
parent
eb3d5ea27d
commit
484fb2e89c
|
@ -54,6 +54,10 @@
|
|||
#include <QTimer>
|
||||
#include <QStyleFactory>
|
||||
#include <QTranslator>
|
||||
#include <QString>
|
||||
#include <QByteArray>
|
||||
#include <QImageReader>
|
||||
#include <QList>
|
||||
#include <tox/tox.h>
|
||||
|
||||
#ifdef Q_OS_ANDROID
|
||||
|
@ -344,10 +348,19 @@ QString Widget::getUsername()
|
|||
|
||||
void Widget::onAvatarClicked()
|
||||
{
|
||||
QList<QByteArray> typeList = QImageReader::supportedImageFormats();
|
||||
QString filter("Images (");
|
||||
for(auto i=typeList.begin(); i!=typeList.end(); i++)
|
||||
{
|
||||
filter.append("*.");
|
||||
filter.append(*i);
|
||||
filter.append(" ");
|
||||
}
|
||||
filter[filter.size()-1] = ')';//take the last space and close the () instead
|
||||
QString filename = QFileDialog::getOpenFileName(this,
|
||||
tr("Choose a profile picture"),
|
||||
QDir::homePath(),
|
||||
tr("Images (*.bmp *.jpg *.jpeg *.png *.pmb *.pgm *.ppm *.xbm *.xpm)"));
|
||||
filter);
|
||||
if (filename.isEmpty())
|
||||
return;
|
||||
QFile file(filename);
|
||||
|
|
Loading…
Reference in New Issue
Block a user