Beginnings of icon copying

This commit is contained in:
probonopd
2017-02-27 09:20:55 +01:00
parent cdbc4a3a7f
commit b830f1f8cd
+23 -1
View File
@@ -88,7 +88,7 @@ int main(int argc, char **argv)
desktopExecEntry = settings->value("Desktop Entry/Exec", "r").toString().split(' ').first().split('/').last().trimmed();
qDebug() << "desktopExecEntry:" << desktopExecEntry;
desktopFile = firstArgument;
desktopIconEntry = settings->value("Desktop Entry/Icon", "r").toString().split(' ').first().trimmed();
desktopIconEntry = settings->value("Desktop Entry/Icon", "r").toString().split(' ').first().split('.').first().trimmed();
qDebug() << "desktopIconEntry:" << desktopIconEntry;
QString candidateBin = QDir::cleanPath(QFileInfo(firstArgument).absolutePath() + desktopExecEntry); // Not FHS-like
@@ -219,6 +219,28 @@ int main(int argc, char **argv)
}
}
/* To make an AppDir, we need to find the icon and copy it in place */
QStringList candidates;
QString iconToBeUsed = "";
if(desktopIconEntry != ""){
QDirIterator it3(appDirPath, QDirIterator::Subdirectories);
while (it3.hasNext()) {
it3.next();
if((it3.fileName().startsWith(desktopIconEntry)) && ((it3.fileName().endsWith(".png")) || (it3.fileName().endsWith(".svg")) || (it3.fileName().endsWith(".svgz")) || (it3.fileName().endsWith(".xpm")))){
candidates.append(it3.filePath());
}
}
qDebug() << "Found icons from desktop file:" << candidates;
if(candidates.length() == 1){
iconToBeUsed = candidates.at(0); // The only choice
}
/* Copy in place */
if(iconToBeUsed != ""){
/* Check if there is already an icon and only if there is not, copy it to the AppDir */
}
}
for (int i = 2; i < argc; ++i) {
QByteArray argument = QByteArray(argv[i]);
if (argument == QByteArray("-no-plugins")) {