1
mirror of https://invent.kde.org/network/falkon.git synced 2024-11-11 09:32:12 +01:00

[RSS] Show for akregator/liferea in PATH instead of just in /usr/bin

This commit is contained in:
nowrep 2013-02-13 21:48:06 +01:00
parent 1059936d57
commit bf75704cac
3 changed files with 32 additions and 7 deletions

View File

@ -24,13 +24,14 @@
#include "rssmanager.h"
#include "settings.h"
#include "webview.h"
#include "qztools.h"
#include <QMessageBox>
#include <QClipboard>
#include <QProcess>
#include <QFile>
bool startExternalProcess(const QString &program, const QStringList &arguments)
static bool startExternalProcess(const QString &program, const QStringList &arguments)
{
if (!QProcess::startDetached(program, arguments)) {
QString info = "<ul><li><b>" + RSSNotification::tr("Executable: ") + "</b>" + program + "</li><li><b>" + RSSNotification::tr("Arguments: ") + "</b>" + arguments.join(" ") + "</li></ul>";
@ -62,14 +63,16 @@ RSSNotification::RSSNotification(const QString &title, const QUrl &url, WebView*
<< RssApp("Yahoo!", "http://add.my.yahoo.com/rss?url=", QIcon(":/icons/sites/yahoo.png"));
#ifdef QZ_WS_X11
// TODO: Not really clever solution.
// It should look in PATH
if (QFile("/usr/bin/akregator").exists()) {
m_rssApps << RssApp("Akregator", "/usr/bin/akregator -a ", QIcon(":/icons/sites/akregator.png"), DesktopApplication);
const QString &akregatorBin = QzTools::resolveFromPath("akregator");
const QString &lifereaBin = QzTools::resolveFromPath("liferea");
const QString &lifereaAddFeedBin = QzTools::resolveFromPath("liferea-add-feed");
if (!akregatorBin.isEmpty()) {
m_rssApps << RssApp("Akregator", akregatorBin + " -a ", QIcon(":/icons/sites/akregator.png"), DesktopApplication);
}
if (QFile("/usr/bin/liferea").exists() && QFile("/usr/bin/liferea-add-feed").exists()) {
m_rssApps << RssApp("Liferea", "/usr/bin/liferea-add-feed ", QIcon(":/icons/sites/liferea.png"), DesktopApplication);
if (!lifereaBin.isEmpty() && !lifereaAddFeedBin.isEmpty()) {
m_rssApps << RssApp("Liferea", lifereaAddFeedBin + " ", QIcon(":/icons/sites/liferea.png"), DesktopApplication);
}
#endif

View File

@ -362,6 +362,26 @@ QIcon QzTools::iconFromFileName(const QString &fileName)
return icon;
}
QString QT_QUPZILLA_EXPORT QzTools::resolveFromPath(const QString &name)
{
const QString &path = qgetenv("PATH").trimmed();
if (path.isEmpty()) {
return QString();
}
QStringList dirs = path.split(QLatin1Char(':'), QString::SkipEmptyParts);
foreach(const QString & dir, dirs) {
QDir d(dir);
if (d.exists(name)) {
return d.absoluteFilePath(name);
}
}
return QString();
}
// Qt5 migration help functions
bool QzTools::isCertificateValid(const QSslCertificate &cert)
{

View File

@ -56,6 +56,8 @@ QString QT_QUPZILLA_EXPORT fileSizeToString(qint64 size);
QPixmap QT_QUPZILLA_EXPORT createPixmapForSite(const QIcon &icon, const QString &title, const QString &url);
QString QT_QUPZILLA_EXPORT applyDirectionToPage(QString &pageContents);
QString QT_QUPZILLA_EXPORT resolveFromPath(const QString &name);
QIcon QT_QUPZILLA_EXPORT iconFromFileName(const QString &fileName);
QString QT_QUPZILLA_EXPORT buildSystem();