mirror of
https://invent.kde.org/network/falkon.git
synced 2024-09-22 02:02:10 +02:00
Fixed parsing arguments when starting external applications.
When starting external RSS readers and external download managers.
This commit is contained in:
parent
5641d380d8
commit
68e0831bdb
|
@ -35,7 +35,6 @@
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
#include <QProcess>
|
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
#include "Shlwapi.h"
|
#include "Shlwapi.h"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* ============================================================
|
/* ============================================================
|
||||||
* QupZilla - WebKit based browser
|
* QupZilla - WebKit based browser
|
||||||
* Copyright (C) 2010-2012 David Rosca <nowrep@gmail.com>
|
* Copyright (C) 2010-2013 David Rosca <nowrep@gmail.com>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -30,10 +30,9 @@
|
||||||
#include "downloadfilehelper.h"
|
#include "downloadfilehelper.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
|
|
||||||
|
#include <QMessageBox>
|
||||||
#include <QCloseEvent>
|
#include <QCloseEvent>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QProcess>
|
|
||||||
#include <QMessageBox>
|
|
||||||
|
|
||||||
DownloadManager::DownloadManager(QWidget* parent)
|
DownloadManager::DownloadManager(QWidget* parent)
|
||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
|
@ -102,16 +101,7 @@ void DownloadManager::keyPressEvent(QKeyEvent* e)
|
||||||
|
|
||||||
void DownloadManager::startExternalManager(const QUrl &url)
|
void DownloadManager::startExternalManager(const QUrl &url)
|
||||||
{
|
{
|
||||||
QStringList arguments = m_externalArguments.split(QLatin1Char(' '), QString::SkipEmptyParts);
|
QzTools::startExternalProcess(m_externalExecutable, m_externalArguments);
|
||||||
arguments << url.toString();
|
|
||||||
|
|
||||||
bool success = QProcess::startDetached(m_externalExecutable, arguments);
|
|
||||||
|
|
||||||
if (!success) {
|
|
||||||
QString info = "<ul><li><b>" + tr("Executable: ") + "</b>" + m_externalExecutable + "</li><li><b>" + tr("Arguments: ") + "</b>" + arguments.join(" ") + "</li></ul>";
|
|
||||||
QMessageBox::critical(this, tr("Cannot start external download manager"), tr("Cannot start external download manager! %1").arg(info));
|
|
||||||
}
|
|
||||||
|
|
||||||
m_lastDownloadOption = ExternalManager;
|
m_lastDownloadOption = ExternalManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,21 +28,8 @@
|
||||||
|
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QClipboard>
|
#include <QClipboard>
|
||||||
#include <QProcess>
|
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
|
|
||||||
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>";
|
|
||||||
QMessageBox::critical(0, RSSNotification::tr("Cannot start external program"), RSSNotification::tr("Cannot start external program! %1").arg(info));
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
RSSNotification::RSSNotification(const QString &title, const QUrl &url, WebView* parent)
|
RSSNotification::RSSNotification(const QString &title, const QUrl &url, WebView* parent)
|
||||||
: AnimatedWidget(AnimatedWidget::Down, 300, parent)
|
: AnimatedWidget(AnimatedWidget::Down, 300, parent)
|
||||||
, ui(new Ui::RSSNotification)
|
, ui(new Ui::RSSNotification)
|
||||||
|
@ -56,11 +43,37 @@ RSSNotification::RSSNotification(const QString &title, const QUrl &url, WebView*
|
||||||
ui->closeButton->setIcon(qIconProvider->standardIcon(QStyle::SP_DialogCloseButton));
|
ui->closeButton->setIcon(qIconProvider->standardIcon(QStyle::SP_DialogCloseButton));
|
||||||
ui->label->setText(tr("RSS feed <b>\"%1\"</b>").arg(title));
|
ui->label->setText(tr("RSS feed <b>\"%1\"</b>").arg(title));
|
||||||
|
|
||||||
m_rssApps << RssApp("Bloglines", "http://www.bloglines.com/sub?url=", QIcon(":/icons/sites/bloglines.png"))
|
RssApp bloglines;
|
||||||
<< RssApp("Google Reader", "http://www.google.com/ig/add?feedurl=", QIcon(":/icons/sites/google.png"))
|
bloglines.type = WebApplication;
|
||||||
<< RssApp("My AOL", "http://feeds.my.aol.com/add.jsp?url=", QIcon(":/icons/sites/aol.png"))
|
bloglines.title = "Bloglines";
|
||||||
<< RssApp("Netvibes", "http://www.netvibes.com/subscribe.php?url=", QIcon(":/icons/sites/netvibes.png"))
|
bloglines.icon = QIcon(":/icons/sites/bloglines.png");
|
||||||
<< RssApp("Yahoo!", "http://add.my.yahoo.com/rss?url=", QIcon(":/icons/sites/yahoo.png"));
|
bloglines.address = "http://www.bloglines.com/sub?url=";
|
||||||
|
|
||||||
|
RssApp greader;
|
||||||
|
greader.type = WebApplication;
|
||||||
|
greader.title = "Google Reader";
|
||||||
|
greader.icon = QIcon(":/icons/sites/google.png");
|
||||||
|
greader.address = "http://www.google.com/ig/add?feedurl=";
|
||||||
|
|
||||||
|
RssApp myaol;
|
||||||
|
myaol.type = WebApplication;
|
||||||
|
myaol.title = "My AOL";
|
||||||
|
myaol.icon = QIcon(":/icons/sites/aol.png");
|
||||||
|
myaol.address = "http://feeds.my.aol.com/add.jsp?url=";
|
||||||
|
|
||||||
|
RssApp netvibes;
|
||||||
|
netvibes.type = WebApplication;
|
||||||
|
netvibes.title = "Netvibes";
|
||||||
|
netvibes.icon = QIcon(":/icons/sites/netvibes.png");
|
||||||
|
netvibes.address = "http://www.netvibes.com/subscribe.php?url=";
|
||||||
|
|
||||||
|
RssApp yahoo;
|
||||||
|
yahoo.type = WebApplication;
|
||||||
|
yahoo.title = "Yahoo!";
|
||||||
|
yahoo.icon = QIcon(":/icons/sites/yahoo.png");
|
||||||
|
yahoo.address = "http://add.my.yahoo.com/rss?url=";
|
||||||
|
|
||||||
|
m_rssApps << bloglines << greader << myaol << netvibes << yahoo;
|
||||||
|
|
||||||
#ifdef QZ_WS_X11
|
#ifdef QZ_WS_X11
|
||||||
const QString &akregatorBin = QzTools::resolveFromPath("akregator");
|
const QString &akregatorBin = QzTools::resolveFromPath("akregator");
|
||||||
|
@ -68,11 +81,24 @@ RSSNotification::RSSNotification(const QString &title, const QUrl &url, WebView*
|
||||||
const QString &lifereaAddFeedBin = QzTools::resolveFromPath("liferea-add-feed");
|
const QString &lifereaAddFeedBin = QzTools::resolveFromPath("liferea-add-feed");
|
||||||
|
|
||||||
if (!akregatorBin.isEmpty()) {
|
if (!akregatorBin.isEmpty()) {
|
||||||
m_rssApps << RssApp("Akregator", akregatorBin + " -a ", QIcon(":/icons/sites/akregator.png"), DesktopApplication);
|
RssApp akregator;
|
||||||
|
akregator.type = DesktopApplication;
|
||||||
|
akregator.title = "Akregator";
|
||||||
|
akregator.icon = QIcon(":/icons/sites/akregator.png");
|
||||||
|
akregator.executable = akregatorBin;
|
||||||
|
akregator.arguments = "-a";
|
||||||
|
|
||||||
|
m_rssApps << akregator;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!lifereaBin.isEmpty() && !lifereaAddFeedBin.isEmpty()) {
|
if (!lifereaBin.isEmpty() && !lifereaAddFeedBin.isEmpty()) {
|
||||||
m_rssApps << RssApp("Liferea", lifereaAddFeedBin + " ", QIcon(":/icons/sites/liferea.png"), DesktopApplication);
|
RssApp liferea;
|
||||||
|
liferea.type = DesktopApplication;
|
||||||
|
liferea.title = "Liferea";
|
||||||
|
liferea.icon = QIcon(":/icons/sites/liferea.png");
|
||||||
|
liferea.executable = lifereaAddFeedBin;
|
||||||
|
|
||||||
|
m_rssApps << liferea;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -117,18 +143,15 @@ void RSSNotification::addRss()
|
||||||
|
|
||||||
case DesktopApplication: {
|
case DesktopApplication: {
|
||||||
const RssApp app = m_rssApps.at(index);
|
const RssApp app = m_rssApps.at(index);
|
||||||
if (app.title == QLatin1String("Akregator")) {
|
if (app.title == QLatin1String("Liferea")) {
|
||||||
success = startExternalProcess("/usr/bin/akregator", QStringList() << "-a" << m_url.toEncoded());
|
|
||||||
}
|
|
||||||
else if (app.title == QLatin1String("Liferea")) {
|
|
||||||
if (!ProcessInfo("liferea").isRunning()) {
|
if (!ProcessInfo("liferea").isRunning()) {
|
||||||
QMessageBox::warning(this, tr("Liferea not running"), tr("Liferea must be running in order to add new feed."));
|
QMessageBox::warning(this, tr("Liferea not running"), tr("Liferea must be running in order to add new feed."));
|
||||||
success = false;
|
success = false;
|
||||||
}
|
break;
|
||||||
else {
|
|
||||||
success = startExternalProcess("/usr/bin/liferea-add-feed", QStringList(m_url.toEncoded()));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
const QString &arguments = QString("%1 %2").arg(app.arguments, QString::fromUtf8(m_url.toEncoded()));
|
||||||
|
success = QzTools::startExternalProcess(app.executable, arguments);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* ============================================================
|
/* ============================================================
|
||||||
* QupZilla - WebKit based browser
|
* QupZilla - WebKit based browser
|
||||||
* Copyright (C) 2010-2012 David Rosca <nowrep@gmail.com>
|
* Copyright (C) 2010-2013 David Rosca <nowrep@gmail.com>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -47,17 +47,12 @@ private slots:
|
||||||
private:
|
private:
|
||||||
enum AppType { WebApplication, DesktopApplication, Internal, Other };
|
enum AppType { WebApplication, DesktopApplication, Internal, Other };
|
||||||
struct RssApp {
|
struct RssApp {
|
||||||
QString title;
|
|
||||||
QString address;
|
|
||||||
QIcon icon;
|
|
||||||
AppType type;
|
AppType type;
|
||||||
|
QString title;
|
||||||
RssApp(const QString &t, const QString &a, const QIcon &i, AppType ty = WebApplication) {
|
QIcon icon;
|
||||||
title = t;
|
QString address;
|
||||||
address = a;
|
QString executable;
|
||||||
icon = i;
|
QString arguments;
|
||||||
type = ty;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Ui::RSSNotification* ui;
|
Ui::RSSNotification* ui;
|
||||||
|
|
|
@ -36,6 +36,8 @@
|
||||||
#include <QTemporaryFile>
|
#include <QTemporaryFile>
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
#include <QSysInfo>
|
#include <QSysInfo>
|
||||||
|
#include <QProcess>
|
||||||
|
#include <QMessageBox>
|
||||||
|
|
||||||
#if QT_VERSION >= 0x050000
|
#if QT_VERSION >= 0x050000
|
||||||
#include <QUrlQuery>
|
#include <QUrlQuery>
|
||||||
|
@ -548,6 +550,24 @@ QStringList QzTools::splitCommandArguments(const QString &command)
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool QzTools::startExternalProcess(const QString &executable, const QString &args)
|
||||||
|
{
|
||||||
|
const QStringList &arguments = splitCommandArguments(args);
|
||||||
|
|
||||||
|
bool success = QProcess::startDetached(executable, arguments);
|
||||||
|
|
||||||
|
if (!success) {
|
||||||
|
QString info = "<ul><li><b>%1</b>%2</li><li><b>%3</b>%4</li></ul>";
|
||||||
|
info = info.arg(QObject::tr("Executable: "), executable,
|
||||||
|
QObject::tr("Arguments: "), arguments.join(QLatin1String(" ")));
|
||||||
|
|
||||||
|
QMessageBox::critical(0, QObject::tr("Cannot start external program"),
|
||||||
|
QObject::tr("Cannot start external program! %1").arg(info));
|
||||||
|
}
|
||||||
|
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
|
||||||
// Qt5 migration help functions
|
// Qt5 migration help functions
|
||||||
bool QzTools::isCertificateValid(const QSslCertificate &cert)
|
bool QzTools::isCertificateValid(const QSslCertificate &cert)
|
||||||
{
|
{
|
||||||
|
|
|
@ -58,6 +58,7 @@ QString QT_QUPZILLA_EXPORT applyDirectionToPage(QString &pageContents);
|
||||||
|
|
||||||
QString QT_QUPZILLA_EXPORT resolveFromPath(const QString &name);
|
QString QT_QUPZILLA_EXPORT resolveFromPath(const QString &name);
|
||||||
QStringList QT_QUPZILLA_EXPORT splitCommandArguments(const QString &command);
|
QStringList QT_QUPZILLA_EXPORT splitCommandArguments(const QString &command);
|
||||||
|
bool QT_QUPZILLA_EXPORT startExternalProcess(const QString &executable, const QString &args);
|
||||||
|
|
||||||
QIcon QT_QUPZILLA_EXPORT iconFromFileName(const QString &fileName);
|
QIcon QT_QUPZILLA_EXPORT iconFromFileName(const QString &fileName);
|
||||||
bool QT_QUPZILLA_EXPORT isUtf8(const char* string);
|
bool QT_QUPZILLA_EXPORT isUtf8(const char* string);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user