Skip to content
This repository has been archived by the owner on Apr 29, 2020. It is now read-only.

Commit

Permalink
fix: unable to drag file.
Browse files Browse the repository at this point in the history
Change-Id: I050a7feb4155feb150521fc4cbc9c3ca5c98bb18
  • Loading branch information
reionwong committed Aug 6, 2018
1 parent 9d40216 commit 46d5f83
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 22 deletions.
24 changes: 3 additions & 21 deletions deepin-font-installer/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <QDir>
#include <QFile>
#include <QDebug>
#include <QFileInfo>
#include <QFontInfo>
#include <QMimeType>
#include <QApplication>
Expand Down Expand Up @@ -61,34 +62,15 @@ QString Utils::getConfigPath()

bool Utils::isFontMimeType(const QString &filePath)
{
const QMimeType mimeType = QMimeDatabase().mimeTypeForUrl(QUrl(filePath));
const QString mimeName = mimeType.name();
const QString mimeName = QMimeDatabase().mimeTypeForFile(filePath).name();;

if (mimeName == "application/x-font-ttf" ||
mimeName == "application/x-font-otf" ||
mimeName == "application/x-font-type1" ||
mimeName.startsWith("font/")) {
if (mimeName.startsWith("font/")) {
return true;
}

return false;
}

bool Utils::isFont(const QString &filePath)
{
QFileInfo file(filePath);

if (file.exists()) {
QStringList fontMimes;
fontMimes << "application/x-font-ttf"
<< "application/x-font-otf"
<< "application/x-font-type1";
return fontMimes.contains(QMimeDatabase().mimeTypeForFile(file).name());
} else {
return false;
}
}

QString Utils::suffixList()
{
return QString("Font Files (*.ttf *.ttc *.otf)");
Expand Down
1 change: 0 additions & 1 deletion deepin-font-installer/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ class Utils : public QObject
static QString getQssContent(const QString &filePath);
static QString getConfigPath();
static bool isFontMimeType(const QString &filePath);
static bool isFont(const QString &filePath);
static QString suffixList();
};

Expand Down

0 comments on commit 46d5f83

Please sign in to comment.