mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2026-01-03 14:12:30 -06:00
Update SearchEngine classes
Guaranteed to work with qt-style separators internally; guaranteed to call native OS environment using native separators
This commit is contained in:
@@ -158,7 +158,7 @@ void engineSelectDlg::on_actionUninstall_triggered() {
|
||||
}else {
|
||||
// Proceed with uninstall
|
||||
// remove it from hard drive
|
||||
QDir enginesFolder(fsutils::searchEngineLocation()+QDir::separator()+"engines");
|
||||
QDir enginesFolder(fsutils::searchEngineLocation() + "/engines");
|
||||
QStringList filters;
|
||||
filters << id+".*";
|
||||
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 {
|
||||
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);
|
||||
return (new_version > old_version);
|
||||
}
|
||||
@@ -239,7 +239,7 @@ void engineSelectDlg::installPlugin(QString path, QString plugin_name) {
|
||||
return;
|
||||
}
|
||||
// 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;
|
||||
if (QFile::exists(dest_path)) {
|
||||
// Backup in case install fails
|
||||
@@ -304,12 +304,12 @@ void engineSelectDlg::addNewEngine(QString engine_name) {
|
||||
setRowColor(pluginsTree->indexOfTopLevelItem(item), "red");
|
||||
}
|
||||
// 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)) {
|
||||
// Good, we already have the icon
|
||||
item->setData(ENGINE_NAME, Qt::DecorationRole, QVariant(QIcon(iconPath)));
|
||||
} 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
|
||||
item->setData(ENGINE_NAME, Qt::DecorationRole, QVariant(QIcon(iconPath)));
|
||||
} else {
|
||||
@@ -355,7 +355,7 @@ void engineSelectDlg::askForLocalPlugin() {
|
||||
QString path;
|
||||
foreach (path, pathsList) {
|
||||
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);
|
||||
installPlugin(path, plugin_name);
|
||||
}
|
||||
@@ -409,6 +409,7 @@ bool engineSelectDlg::parseVersionsFile(QString versions_file) {
|
||||
}
|
||||
|
||||
void engineSelectDlg::processDownloadedFile(QString url, QString filePath) {
|
||||
filePath = fsutils::fromNativePath(filePath);
|
||||
setCursor(QCursor(Qt::ArrowCursor));
|
||||
qDebug("engineSelectDlg received %s", qPrintable(url));
|
||||
if (url.endsWith("favicon.ico", Qt::CaseInsensitive)) {
|
||||
@@ -423,9 +424,9 @@ void engineSelectDlg::processDownloadedFile(QString url, QString filePath) {
|
||||
QFile icon(filePath);
|
||||
icon.open(QIODevice::ReadOnly);
|
||||
if (ICOHandler::canRead(&icon))
|
||||
iconPath = fsutils::searchEngineLocation()+QDir::separator()+"engines"+QDir::separator()+id+".ico";
|
||||
iconPath = fsutils::searchEngineLocation() + "/engines/" + id + ".ico";
|
||||
else
|
||||
iconPath = fsutils::searchEngineLocation()+QDir::separator()+"engines"+QDir::separator()+id+".png";
|
||||
iconPath = fsutils::searchEngineLocation() + "/engines/" + id + ".png";
|
||||
QFile::copy(filePath, iconPath);
|
||||
item->setData(ENGINE_NAME, Qt::DecorationRole, QVariant(QIcon(iconPath)));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user