|
|
@ -158,7 +158,7 @@ void engineSelectDlg::on_actionUninstall_triggered() { |
|
|
|
}else { |
|
|
|
}else { |
|
|
|
// Proceed with uninstall
|
|
|
|
// Proceed with uninstall
|
|
|
|
// remove it from hard drive
|
|
|
|
// remove it from hard drive
|
|
|
|
QDir enginesFolder(fsutils::searchEngineLocation()+QDir::separator()+"engines"); |
|
|
|
QDir enginesFolder(fsutils::searchEngineLocation() + "/engines"); |
|
|
|
QStringList filters; |
|
|
|
QStringList filters; |
|
|
|
filters << id+".*"; |
|
|
|
filters << id+".*"; |
|
|
|
QStringList files = enginesFolder.entryList(filters, QDir::Files, QDir::Unsorted); |
|
|
|
QStringList files = enginesFolder.entryList(filters, QDir::Files, QDir::Unsorted); |
|
|
@ -224,7 +224,7 @@ QTreeWidgetItem* engineSelectDlg::findItemWithID(QString id) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool engineSelectDlg::isUpdateNeeded(QString plugin_name, qreal new_version) const { |
|
|
|
bool engineSelectDlg::isUpdateNeeded(QString plugin_name, qreal new_version) const { |
|
|
|
qreal old_version = SearchEngine::getPluginVersion(fsutils::searchEngineLocation()+QDir::separator()+"engines"+QDir::separator()+plugin_name+".py"); |
|
|
|
qreal old_version = SearchEngine::getPluginVersion(fsutils::searchEngineLocation() + "/engines/" + plugin_name + ".py"); |
|
|
|
qDebug("IsUpdate needed? tobeinstalled: %.2f, alreadyinstalled: %.2f", new_version, old_version); |
|
|
|
qDebug("IsUpdate needed? tobeinstalled: %.2f, alreadyinstalled: %.2f", new_version, old_version); |
|
|
|
return (new_version > old_version); |
|
|
|
return (new_version > old_version); |
|
|
|
} |
|
|
|
} |
|
|
@ -239,7 +239,7 @@ void engineSelectDlg::installPlugin(QString path, QString plugin_name) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
// Process with install
|
|
|
|
// Process with install
|
|
|
|
QString dest_path = fsutils::searchEngineLocation()+QDir::separator()+"engines"+QDir::separator()+plugin_name+".py"; |
|
|
|
QString dest_path = fsutils::searchEngineLocation() + "/engines/" + plugin_name + ".py"; |
|
|
|
bool update = false; |
|
|
|
bool update = false; |
|
|
|
if (QFile::exists(dest_path)) { |
|
|
|
if (QFile::exists(dest_path)) { |
|
|
|
// Backup in case install fails
|
|
|
|
// Backup in case install fails
|
|
|
@ -304,12 +304,12 @@ void engineSelectDlg::addNewEngine(QString engine_name) { |
|
|
|
setRowColor(pluginsTree->indexOfTopLevelItem(item), "red"); |
|
|
|
setRowColor(pluginsTree->indexOfTopLevelItem(item), "red"); |
|
|
|
} |
|
|
|
} |
|
|
|
// Handle icon
|
|
|
|
// Handle icon
|
|
|
|
QString iconPath = fsutils::searchEngineLocation()+QDir::separator()+"engines"+QDir::separator()+engine->getName()+".png"; |
|
|
|
QString iconPath = fsutils::searchEngineLocation() + "/engines/" + engine->getName() + ".png"; |
|
|
|
if (QFile::exists(iconPath)) { |
|
|
|
if (QFile::exists(iconPath)) { |
|
|
|
// Good, we already have the icon
|
|
|
|
// Good, we already have the icon
|
|
|
|
item->setData(ENGINE_NAME, Qt::DecorationRole, QVariant(QIcon(iconPath))); |
|
|
|
item->setData(ENGINE_NAME, Qt::DecorationRole, QVariant(QIcon(iconPath))); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
iconPath = fsutils::searchEngineLocation()+QDir::separator()+"engines"+QDir::separator()+engine->getName()+".ico"; |
|
|
|
iconPath = fsutils::searchEngineLocation() + "/engines/" + engine->getName() + ".ico"; |
|
|
|
if (QFile::exists(iconPath)) { // ICO support
|
|
|
|
if (QFile::exists(iconPath)) { // ICO support
|
|
|
|
item->setData(ENGINE_NAME, Qt::DecorationRole, QVariant(QIcon(iconPath))); |
|
|
|
item->setData(ENGINE_NAME, Qt::DecorationRole, QVariant(QIcon(iconPath))); |
|
|
|
} else { |
|
|
|
} else { |
|
|
@ -355,7 +355,7 @@ void engineSelectDlg::askForLocalPlugin() { |
|
|
|
QString path; |
|
|
|
QString path; |
|
|
|
foreach (path, pathsList) { |
|
|
|
foreach (path, pathsList) { |
|
|
|
if (path.endsWith(".py", Qt::CaseInsensitive)) { |
|
|
|
if (path.endsWith(".py", Qt::CaseInsensitive)) { |
|
|
|
QString plugin_name = path.split(QDir::separator()).last(); |
|
|
|
QString plugin_name = path.split("/").last(); |
|
|
|
plugin_name.replace(".py", "", Qt::CaseInsensitive); |
|
|
|
plugin_name.replace(".py", "", Qt::CaseInsensitive); |
|
|
|
installPlugin(path, plugin_name); |
|
|
|
installPlugin(path, plugin_name); |
|
|
|
} |
|
|
|
} |
|
|
@ -409,6 +409,7 @@ bool engineSelectDlg::parseVersionsFile(QString versions_file) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void engineSelectDlg::processDownloadedFile(QString url, QString filePath) { |
|
|
|
void engineSelectDlg::processDownloadedFile(QString url, QString filePath) { |
|
|
|
|
|
|
|
filePath = fsutils::fromNativePath(filePath); |
|
|
|
setCursor(QCursor(Qt::ArrowCursor)); |
|
|
|
setCursor(QCursor(Qt::ArrowCursor)); |
|
|
|
qDebug("engineSelectDlg received %s", qPrintable(url)); |
|
|
|
qDebug("engineSelectDlg received %s", qPrintable(url)); |
|
|
|
if (url.endsWith("favicon.ico", Qt::CaseInsensitive)) { |
|
|
|
if (url.endsWith("favicon.ico", Qt::CaseInsensitive)) { |
|
|
@ -423,9 +424,9 @@ void engineSelectDlg::processDownloadedFile(QString url, QString filePath) { |
|
|
|
QFile icon(filePath); |
|
|
|
QFile icon(filePath); |
|
|
|
icon.open(QIODevice::ReadOnly); |
|
|
|
icon.open(QIODevice::ReadOnly); |
|
|
|
if (ICOHandler::canRead(&icon)) |
|
|
|
if (ICOHandler::canRead(&icon)) |
|
|
|
iconPath = fsutils::searchEngineLocation()+QDir::separator()+"engines"+QDir::separator()+id+".ico"; |
|
|
|
iconPath = fsutils::searchEngineLocation() + "/engines/" + id + ".ico"; |
|
|
|
else |
|
|
|
else |
|
|
|
iconPath = fsutils::searchEngineLocation()+QDir::separator()+"engines"+QDir::separator()+id+".png"; |
|
|
|
iconPath = fsutils::searchEngineLocation() + "/engines/" + id + ".png"; |
|
|
|
QFile::copy(filePath, iconPath); |
|
|
|
QFile::copy(filePath, iconPath); |
|
|
|
item->setData(ENGINE_NAME, Qt::DecorationRole, QVariant(QIcon(iconPath))); |
|
|
|
item->setData(ENGINE_NAME, Qt::DecorationRole, QVariant(QIcon(iconPath))); |
|
|
|
} |
|
|
|
} |
|
|
|