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 "widget/gui.h"
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <QImageReader>
|
||||||
|
|
||||||
#ifdef Q_OS_ANDROID
|
#ifdef Q_OS_ANDROID
|
||||||
#include <src/widget/androidgui.h>
|
#include <src/widget/androidgui.h>
|
||||||
@ -154,3 +155,11 @@ Widget* Nexus::getDesktopGUI()
|
|||||||
{
|
{
|
||||||
return getInstance().widget;
|
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 Core* getCore(); ///< Will return 0 if not started
|
||||||
static AndroidGUI* getAndroidGUI(); ///< 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 Widget* getDesktopGUI(); ///< Will return 0 if not started
|
||||||
|
static QString getSupportedImageFilter();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit Nexus(QObject *parent = 0);
|
explicit Nexus(QObject *parent = 0);
|
||||||
|
@ -348,19 +348,10 @@ QString Widget::getUsername()
|
|||||||
|
|
||||||
void Widget::onAvatarClicked()
|
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,
|
QString filename = QFileDialog::getOpenFileName(this,
|
||||||
tr("Choose a profile picture"),
|
tr("Choose a profile picture"),
|
||||||
QDir::homePath(),
|
QDir::homePath(),
|
||||||
filter);
|
Nexus::getSupportedImageFilter());
|
||||||
if (filename.isEmpty())
|
if (filename.isEmpty())
|
||||||
return;
|
return;
|
||||||
QFile file(filename);
|
QFile file(filename);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user