Optimize open default apps
This commit is contained in:
parent
e6eedc365e
commit
ff1c006041
1 changed files with 19 additions and 11 deletions
|
@ -252,14 +252,22 @@ QString MimeAppManager::getDefaultAppByMimeType(const QMimeType &mimeType)
|
||||||
|
|
||||||
settings.beginGroup("Default Applications");
|
settings.beginGroup("Default Applications");
|
||||||
// TODO: User applications directory?
|
// TODO: User applications directory?
|
||||||
if (settings.contains(mimeType.name()))
|
if (settings.contains(mimeType.name())) {
|
||||||
return QString("/usr/share/applications/%1").arg(settings.value(mimeType.name()).toString());
|
const QString desktopFile = QString("/usr/share/applications/%1").arg(settings.value(mimeType.name()).toString());
|
||||||
|
if (QFile::exists(desktopFile)) {
|
||||||
|
return desktopFile;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
|
|
||||||
settings.beginGroup("Added Associations");
|
settings.beginGroup("Added Associations");
|
||||||
if (settings.contains(mimeType.name()))
|
if (settings.contains(mimeType.name())) {
|
||||||
return QString("/usr/share/applications/%1").arg(settings.value(mimeType.name()).toString());
|
QString desktopFile = QString("/usr/share/applications/%1").arg(settings.value(mimeType.name()).toString());
|
||||||
|
if (QFile::exists(desktopFile)) {
|
||||||
|
return desktopFile;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
@ -314,15 +322,15 @@ bool MimeAppManager::setDefaultAppForFile(const QString &filePath, const QString
|
||||||
value = info.fileName();
|
value = info.fileName();
|
||||||
}
|
}
|
||||||
|
|
||||||
// QSettings settings(mimeappsFile, QSettings::IniFormat);
|
QSettings settings(mimeappsFile, QSettings::IniFormat);
|
||||||
// settings.setIniCodec("UTF-8");
|
settings.setIniCodec("UTF-8");
|
||||||
|
|
||||||
// if (!settings.isWritable())
|
if (!settings.isWritable())
|
||||||
// return false;
|
return false;
|
||||||
|
|
||||||
// settings.beginGroup("Default Applications"); // Added Associations
|
settings.beginGroup("Default Applications"); // Added Associations
|
||||||
// settings.setValue(mimeType.name(), value);
|
settings.setValue(mimeType.name(), value);
|
||||||
// settings.sync();
|
settings.sync();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue