mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Refactor image filter as discussed
This commit is contained in:
parent
484fb2e89c
commit
07b87616a2
|
@ -5,6 +5,7 @@
|
|||
#include "widget/gui.h"
|
||||
#include <QThread>
|
||||
#include <QDebug>
|
||||
#include <QImageReader>
|
||||
|
||||
#ifdef Q_OS_ANDROID
|
||||
#include <src/widget/androidgui.h>
|
||||
|
@ -154,3 +155,11 @@ Widget* Nexus::getDesktopGUI()
|
|||
{
|
||||
return getInstance().widget;
|
||||
}
|
||||
|
||||
QString Nexus::getSupportedImageFilter()
|
||||
{
|
||||
QString res;
|
||||
for (auto type : QImageReader::supportedImageFormats())
|
||||
res += QString("*.%1 ").arg(QString(type));
|
||||
return tr("Images (%1)", "filetype filter").arg(res.left(res.size()-1));
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ public:
|
|||
static Core* getCore(); ///< Will return 0 if not started
|
||||
static AndroidGUI* getAndroidGUI(); ///< Will return 0 if not started
|
||||
static Widget* getDesktopGUI(); ///< Will return 0 if not started
|
||||
static QString getSupportedImageFilter();
|
||||
|
||||
private:
|
||||
explicit Nexus(QObject *parent = 0);
|
||||
|
|
|
@ -348,19 +348,10 @@ 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(),
|
||||
filter);
|
||||
Nexus::getSupportedImageFilter());
|
||||
if (filename.isEmpty())
|
||||
return;
|
||||
QFile file(filename);
|
||||
|
|
Loading…
Reference in New Issue
Block a user