RSS: Added support for adding feeds into external applications
- including some web applications (Google Reader, My AOL, Yahoo! ...) - Liferea and Akregator are support from desktop readers * akregator needs testing (i don't use kde) closes #364
113
src/lib/3rdparty/processinfo.cpp
vendored
Normal file
@ -0,0 +1,113 @@
|
|||||||
|
/* ============================================================
|
||||||
|
* QupZilla - WebKit based browser
|
||||||
|
* Copyright (C) 2010-2012 David Rosca <nowrep@gmail.com>
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
* ============================================================ */
|
||||||
|
#include "processinfo.h"
|
||||||
|
|
||||||
|
#ifdef Q_WS_X11
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <dirent.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <cstdio>
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <cstring>
|
||||||
|
#include <cstdarg>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
ProcessInfo::ProcessInfo(const QString &name)
|
||||||
|
: m_name(name)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ProcessInfo::isRunning() const
|
||||||
|
{
|
||||||
|
#ifdef Q_WS_X11
|
||||||
|
pid_t pid = GetPIDbyName(qPrintable(m_name));
|
||||||
|
// -1 = process not found
|
||||||
|
// -2 = /proc fs access error
|
||||||
|
return (pid != -1 && pid != -2);
|
||||||
|
#else
|
||||||
|
return false;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef Q_WS_X11
|
||||||
|
bool ProcessInfo::IsNumeric(const char* ccharptr_CharacterList) const
|
||||||
|
{
|
||||||
|
for (; *ccharptr_CharacterList; ccharptr_CharacterList++) {
|
||||||
|
if (*ccharptr_CharacterList < '0' || *ccharptr_CharacterList > '9') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
pid_t ProcessInfo::GetPIDbyName(const char* cchrptr_ProcessName) const
|
||||||
|
{
|
||||||
|
char chrarry_CommandLinePath[100] ;
|
||||||
|
char chrarry_NameOfProcess[300] ;
|
||||||
|
char* chrptr_StringToCompare = NULL ;
|
||||||
|
pid_t pid_ProcessIdentifier = (pid_t) - 1 ;
|
||||||
|
struct dirent* de_DirEntity = NULL ;
|
||||||
|
DIR* dir_proc = NULL ;
|
||||||
|
|
||||||
|
dir_proc = opendir("/proc/") ;
|
||||||
|
if (dir_proc == NULL) {
|
||||||
|
perror("Couldn't open the /proc/ directory") ;
|
||||||
|
return (pid_t) - 2 ;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Loop while not NULL
|
||||||
|
while ((de_DirEntity = readdir(dir_proc))) {
|
||||||
|
if (de_DirEntity->d_type == DT_DIR) {
|
||||||
|
if (IsNumeric(de_DirEntity->d_name)) {
|
||||||
|
strcpy(chrarry_CommandLinePath, "/proc/") ;
|
||||||
|
strcat(chrarry_CommandLinePath, de_DirEntity->d_name) ;
|
||||||
|
strcat(chrarry_CommandLinePath, "/cmdline") ;
|
||||||
|
FILE* fd_CmdLineFile = fopen(chrarry_CommandLinePath, "rt") ; // open the file for reading text
|
||||||
|
if (fd_CmdLineFile) {
|
||||||
|
fscanf(fd_CmdLineFile, "%20s", chrarry_NameOfProcess) ; // read from /proc/<NR>/cmdline
|
||||||
|
fclose(fd_CmdLineFile); // close the file prior to exiting the routine
|
||||||
|
|
||||||
|
if (strrchr(chrarry_NameOfProcess, '/')) {
|
||||||
|
chrptr_StringToCompare = strrchr(chrarry_NameOfProcess, '/') + 1 ;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
chrptr_StringToCompare = chrarry_NameOfProcess ;
|
||||||
|
}
|
||||||
|
|
||||||
|
//printf("Process name: %s\n", chrarry_NameOfProcess);
|
||||||
|
//printf("Pure Process name: %s\n", chrptr_StringToCompare );
|
||||||
|
|
||||||
|
if (!strcmp(chrptr_StringToCompare, cchrptr_ProcessName)) {
|
||||||
|
pid_ProcessIdentifier = (pid_t) atoi(de_DirEntity->d_name) ;
|
||||||
|
closedir(dir_proc) ;
|
||||||
|
return pid_ProcessIdentifier ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
closedir(dir_proc) ;
|
||||||
|
return pid_ProcessIdentifier ;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
47
src/lib/3rdparty/processinfo.h
vendored
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
/* ============================================================
|
||||||
|
* QupZilla - WebKit based browser
|
||||||
|
* Copyright (C) 2010-2012 David Rosca <nowrep@gmail.com>
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
* ============================================================ */
|
||||||
|
#ifndef PROCESSINFO_H
|
||||||
|
#define PROCESSINFO_H
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
|
#include "qz_namespace.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Code used from http://ubuntuforums.org/showpost.php?p=6593782&postcount=5
|
||||||
|
* written by user WitchCraft
|
||||||
|
*/
|
||||||
|
|
||||||
|
class QT_QUPZILLA_EXPORT ProcessInfo
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit ProcessInfo(const QString &name);
|
||||||
|
|
||||||
|
bool isRunning() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
#ifdef Q_WS_X11
|
||||||
|
bool IsNumeric(const char* ccharptr_CharacterList) const;
|
||||||
|
|
||||||
|
pid_t GetPIDbyName(const char* cchrptr_ProcessName) const;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
QString m_name;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // PROCESSINFO_H
|
@ -55,7 +55,7 @@ QNetworkReply* AdBlockSchemeHandler::createRequest(QNetworkAccessManager::Operat
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString message = AdBlockManager::tr("Do you want to add <b>%1</b> subscription?").arg(subscriptionTitle);
|
const QString &message = AdBlockManager::tr("Do you want to add <b>%1</b> subscription?").arg(subscriptionTitle);
|
||||||
|
|
||||||
QMessageBox::StandardButton result = QMessageBox::question(0, AdBlockManager::tr("AdBlock Subscription"), message, QMessageBox::Yes | QMessageBox::No);
|
QMessageBox::StandardButton result = QMessageBox::question(0, AdBlockManager::tr("AdBlock Subscription"), message, QMessageBox::Yes | QMessageBox::No);
|
||||||
if (result == QMessageBox::Yes) {
|
if (result == QMessageBox::Yes) {
|
||||||
|
@ -17,13 +17,11 @@
|
|||||||
<file>qupzilla.png</file>
|
<file>qupzilla.png</file>
|
||||||
<file>icons/locationbar/privatebrowsing.png</file>
|
<file>icons/locationbar/privatebrowsing.png</file>
|
||||||
<file>icons/locationbar/unknownpage.png</file>
|
<file>icons/locationbar/unknownpage.png</file>
|
||||||
<file>icons/menu/google.png</file>
|
|
||||||
<file>icons/menu/history.png</file>
|
<file>icons/menu/history.png</file>
|
||||||
<file>icons/menu/history_entry.png</file>
|
<file>icons/menu/history_entry.png</file>
|
||||||
<file>icons/menu/popup.png</file>
|
<file>icons/menu/popup.png</file>
|
||||||
<file>icons/menu/qt.png</file>
|
<file>icons/menu/qt.png</file>
|
||||||
<file>icons/menu/rss.png</file>
|
<file>icons/menu/rss.png</file>
|
||||||
<file>icons/menu/youtube.png</file>
|
|
||||||
<file>icons/other/about.png</file>
|
<file>icons/other/about.png</file>
|
||||||
<file>icons/other/feed.png</file>
|
<file>icons/other/feed.png</file>
|
||||||
<file>icons/other/progress.gif</file>
|
<file>icons/other/progress.gif</file>
|
||||||
@ -45,7 +43,6 @@
|
|||||||
<file>icons/other/adblock-disabled.png</file>
|
<file>icons/other/adblock-disabled.png</file>
|
||||||
<file>icons/menu/search-icon.png</file>
|
<file>icons/menu/search-icon.png</file>
|
||||||
<file>icons/menu/gear.png</file>
|
<file>icons/menu/gear.png</file>
|
||||||
<file>icons/menu/wikipedia.png</file>
|
|
||||||
<file>icons/browsers/firefox.png</file>
|
<file>icons/browsers/firefox.png</file>
|
||||||
<file>icons/browsers/chrome.png</file>
|
<file>icons/browsers/chrome.png</file>
|
||||||
<file>icons/browsers/opera.png</file>
|
<file>icons/browsers/opera.png</file>
|
||||||
@ -58,9 +55,18 @@
|
|||||||
<file>icons/preferences/mail-inbox.png</file>
|
<file>icons/preferences/mail-inbox.png</file>
|
||||||
<file>icons/preferences/preferences-system-firewall.png</file>
|
<file>icons/preferences/preferences-system-firewall.png</file>
|
||||||
<file>icons/browsers/html.png</file>
|
<file>icons/browsers/html.png</file>
|
||||||
<file>icons/menu/translate.png</file>
|
|
||||||
<file>icons/menu/duck.png</file>
|
|
||||||
<file>icons/exeicons/qupzilla-window.png</file>
|
<file>icons/exeicons/qupzilla-window.png</file>
|
||||||
<file>icons/preferences/text-x-sql.png</file>
|
<file>icons/preferences/text-x-sql.png</file>
|
||||||
|
<file>icons/sites/akregator.png</file>
|
||||||
|
<file>icons/sites/aol.png</file>
|
||||||
|
<file>icons/sites/bloglines.png</file>
|
||||||
|
<file>icons/sites/duck.png</file>
|
||||||
|
<file>icons/sites/google.png</file>
|
||||||
|
<file>icons/sites/liferea.png</file>
|
||||||
|
<file>icons/sites/netvibes.png</file>
|
||||||
|
<file>icons/sites/translate.png</file>
|
||||||
|
<file>icons/sites/wikipedia.png</file>
|
||||||
|
<file>icons/sites/yahoo.png</file>
|
||||||
|
<file>icons/sites/youtube.png</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
BIN
src/lib/data/icons/sites/akregator.png
Normal file
After Width: | Height: | Size: 687 B |
BIN
src/lib/data/icons/sites/aol.png
Normal file
After Width: | Height: | Size: 358 B |
BIN
src/lib/data/icons/sites/bloglines.png
Normal file
After Width: | Height: | Size: 404 B |
Before Width: | Height: | Size: 577 B After Width: | Height: | Size: 577 B |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
BIN
src/lib/data/icons/sites/liferea.png
Normal file
After Width: | Height: | Size: 734 B |
BIN
src/lib/data/icons/sites/netvibes.png
Normal file
After Width: | Height: | Size: 317 B |
Before Width: | Height: | Size: 597 B After Width: | Height: | Size: 597 B |
Before Width: | Height: | Size: 387 B After Width: | Height: | Size: 387 B |
BIN
src/lib/data/icons/sites/yahoo.png
Normal file
After Width: | Height: | Size: 419 B |
Before Width: | Height: | Size: 436 B After Width: | Height: | Size: 436 B |
@ -180,7 +180,8 @@ SOURCES += \
|
|||||||
adblock/adblocktreewidget.cpp \
|
adblock/adblocktreewidget.cpp \
|
||||||
adblock/adblockaddsubscriptiondialog.cpp \
|
adblock/adblockaddsubscriptiondialog.cpp \
|
||||||
adblock/adblockschemehandler.cpp \
|
adblock/adblockschemehandler.cpp \
|
||||||
tools/emptynetworkreply.cpp
|
tools/emptynetworkreply.cpp \
|
||||||
|
3rdparty/processinfo.cpp
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
webview/tabpreview.h \
|
webview/tabpreview.h \
|
||||||
@ -333,7 +334,8 @@ HEADERS += \
|
|||||||
adblock/adblocktreewidget.h \
|
adblock/adblocktreewidget.h \
|
||||||
adblock/adblockaddsubscriptiondialog.h \
|
adblock/adblockaddsubscriptiondialog.h \
|
||||||
adblock/adblockschemehandler.h \
|
adblock/adblockschemehandler.h \
|
||||||
tools/emptynetworkreply.h
|
tools/emptynetworkreply.h \
|
||||||
|
3rdparty/processinfo.h
|
||||||
|
|
||||||
FORMS += \
|
FORMS += \
|
||||||
preferences/autofillmanager.ui \
|
preferences/autofillmanager.ui \
|
||||||
|
@ -119,28 +119,28 @@ void SearchEnginesManager::restoreDefaults()
|
|||||||
{
|
{
|
||||||
Engine google;
|
Engine google;
|
||||||
google.name = "Google";
|
google.name = "Google";
|
||||||
google.icon = QIcon(":icons/menu/google.png");
|
google.icon = QIcon(":icons/sites/google.png");
|
||||||
google.url = "http://www.google.com/search?client=qupzilla&q=%s";
|
google.url = "http://www.google.com/search?client=qupzilla&q=%s";
|
||||||
google.shortcut = "g";
|
google.shortcut = "g";
|
||||||
google.suggestionsUrl = "http://suggestqueries.google.com/complete/search?output=firefox&q=%s";
|
google.suggestionsUrl = "http://suggestqueries.google.com/complete/search?output=firefox&q=%s";
|
||||||
|
|
||||||
Engine wiki;
|
Engine wiki;
|
||||||
wiki.name = "Wikipedia (en)";
|
wiki.name = "Wikipedia (en)";
|
||||||
wiki.icon = QIcon(":/icons/menu/wikipedia.png");
|
wiki.icon = QIcon(":/icons/sites/wikipedia.png");
|
||||||
wiki.url = "http://en.wikipedia.org/wiki/Special:Search?search=%s&fulltext=Search";
|
wiki.url = "http://en.wikipedia.org/wiki/Special:Search?search=%s&fulltext=Search";
|
||||||
wiki.shortcut = "w";
|
wiki.shortcut = "w";
|
||||||
wiki.suggestionsUrl = "http://en.wikipedia.org/w/api.php?action=opensearch&search=%s&namespace=0";
|
wiki.suggestionsUrl = "http://en.wikipedia.org/w/api.php?action=opensearch&search=%s&namespace=0";
|
||||||
|
|
||||||
Engine yt;
|
Engine yt;
|
||||||
yt.name = "YouTube";
|
yt.name = "YouTube";
|
||||||
yt.icon = QIcon(":/icons/menu/youtube.png");
|
yt.icon = QIcon(":/icons/sites/youtube.png");
|
||||||
yt.url = "http://www.youtube.com/results?search_query=%s&search=Search";
|
yt.url = "http://www.youtube.com/results?search_query=%s&search=Search";
|
||||||
yt.shortcut = "yt";
|
yt.shortcut = "yt";
|
||||||
yt.suggestionsUrl = "http://suggestqueries.google.com/complete/search?ds=yt&output=firefox&q=%s";
|
yt.suggestionsUrl = "http://suggestqueries.google.com/complete/search?ds=yt&output=firefox&q=%s";
|
||||||
|
|
||||||
Engine duck;
|
Engine duck;
|
||||||
duck.name = "DuckDuckGo";
|
duck.name = "DuckDuckGo";
|
||||||
duck.icon = QIcon(":/icons/menu/duck.png");
|
duck.icon = QIcon(":/icons/sites/duck.png");
|
||||||
duck.url = "https://duckduckgo.com/?q=%s&t=qupzilla";
|
duck.url = "https://duckduckgo.com/?q=%s&t=qupzilla";
|
||||||
duck.shortcut = "d";
|
duck.shortcut = "d";
|
||||||
|
|
||||||
|
@ -18,24 +18,146 @@
|
|||||||
#include "rssnotification.h"
|
#include "rssnotification.h"
|
||||||
#include "ui_rssnotification.h"
|
#include "ui_rssnotification.h"
|
||||||
#include "mainapplication.h"
|
#include "mainapplication.h"
|
||||||
#include "qupzilla.h"
|
#include "browsinglibrary.h"
|
||||||
#include "iconprovider.h"
|
#include "iconprovider.h"
|
||||||
|
#include "processinfo.h"
|
||||||
|
#include "rssmanager.h"
|
||||||
|
#include "settings.h"
|
||||||
|
#include "webview.h"
|
||||||
|
|
||||||
RSSNotification::RSSNotification(QString host, QWidget* parent)
|
#include <QMessageBox>
|
||||||
|
#include <QClipboard>
|
||||||
|
#include <QProcess>
|
||||||
|
#include <QFile>
|
||||||
|
|
||||||
|
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)
|
||||||
: AnimatedWidget(AnimatedWidget::Down, 300, parent)
|
: AnimatedWidget(AnimatedWidget::Down, 300, parent)
|
||||||
, ui(new Ui::RSSNotification)
|
, ui(new Ui::RSSNotification)
|
||||||
|
, m_title(title)
|
||||||
|
, m_url(url)
|
||||||
|
, m_view(parent)
|
||||||
{
|
{
|
||||||
setAttribute(Qt::WA_DeleteOnClose);
|
setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
|
||||||
ui->setupUi(widget());
|
ui->setupUi(widget());
|
||||||
ui->closeButton->setIcon(qIconProvider->standardIcon(QStyle::SP_DialogCloseButton));
|
ui->closeButton->setIcon(qIconProvider->standardIcon(QStyle::SP_DialogCloseButton));
|
||||||
ui->label->setText(QupZilla::tr("You have successfully added RSS feed \"%1\".").arg(host));
|
ui->label->setText(tr("RSS feed <b>\"%1\"</b>").arg(title));
|
||||||
|
|
||||||
connect(ui->pushButton, SIGNAL(clicked()), mApp->getWindow(), SLOT(showRSSManager()));
|
m_rssApps << RssApp("Bloglines", "http://www.bloglines.com/sub?url=", QIcon(":/icons/sites/bloglines.png"))
|
||||||
connect(ui->pushButton, SIGNAL(clicked()), this, SLOT(hide()));
|
<< RssApp("Google Reader", "http://www.google.com/ig/add?feedurl=", QIcon(":/icons/sites/google.png"))
|
||||||
|
<< RssApp("My AOL", "http://feeds.my.aol.com/add.jsp?url=", QIcon(":/icons/sites/aol.png"))
|
||||||
|
<< RssApp("Netvibes", "http://www.netvibes.com/subscribe.php?url=", QIcon(":/icons/sites/netvibes.png"))
|
||||||
|
<< RssApp("Yahoo!", "http://add.my.yahoo.com/rss?url=", QIcon(":/icons/sites/yahoo.png"));
|
||||||
|
|
||||||
|
#ifdef Q_WS_X11
|
||||||
|
if (QFile("/usr/bin/akregator").exists()) {
|
||||||
|
m_rssApps << RssApp("Akregator", "/usr/bin/akregator -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);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
foreach(const RssApp & app, m_rssApps) {
|
||||||
|
ui->comboBox->addItem(app.icon, app.title, QVariant(app.type));
|
||||||
|
}
|
||||||
|
|
||||||
|
ui->comboBox->addItem(QIcon(":/icons/qupzilla.png"), tr("Internal Reader"), QVariant(Internal));
|
||||||
|
ui->comboBox->addItem(tr("Other..."), QVariant(Other));
|
||||||
|
|
||||||
|
Settings settings;
|
||||||
|
settings.beginGroup("RSS");
|
||||||
|
ui->comboBox->setCurrentIndex(settings.value("LastAddOptionIndex", ui->comboBox->count() - 2).toInt());
|
||||||
|
settings.endGroup();
|
||||||
|
|
||||||
|
connect(ui->add, SIGNAL(clicked()), this, SLOT(addRss()));
|
||||||
connect(ui->closeButton, SIGNAL(clicked()), this, SLOT(hide()));
|
connect(ui->closeButton, SIGNAL(clicked()), this, SLOT(hide()));
|
||||||
|
|
||||||
startAnimation();
|
startAnimation();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RSSNotification::hide()
|
||||||
|
{
|
||||||
|
m_view->setFocus();
|
||||||
|
AnimatedWidget::hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
void RSSNotification::addRss()
|
||||||
|
{
|
||||||
|
bool success = false;
|
||||||
|
int index = ui->comboBox->currentIndex();
|
||||||
|
|
||||||
|
switch (ui->comboBox->itemData(index).toInt()) {
|
||||||
|
case WebApplication: {
|
||||||
|
const RssApp &app = m_rssApps.at(index);
|
||||||
|
const QUrl &url = QUrl::fromEncoded(QString(app.address + QUrl::toPercentEncoding(m_url.toString())).toAscii());
|
||||||
|
|
||||||
|
m_view->openUrlInNewTab(url, Qz::NT_SelectedTab);
|
||||||
|
success = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case DesktopApplication: {
|
||||||
|
const RssApp &app = m_rssApps.at(index);
|
||||||
|
if (app.title == "Akregator") {
|
||||||
|
success = startExternalProcess("/usr/bin/akregator", QStringList() << "-a" << m_url.toEncoded());
|
||||||
|
}
|
||||||
|
else if (app.title == "Liferea") {
|
||||||
|
if (!ProcessInfo("liferea").isRunning()) {
|
||||||
|
QMessageBox::warning(this, tr("Liferea not running"), tr("Liferea must be running in order to add new feed."));
|
||||||
|
success = false;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
success = startExternalProcess("/usr/bin/liferea-add-feed", QStringList(m_url.toEncoded()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case Other: {
|
||||||
|
QApplication::clipboard()->setText(m_url.toEncoded());
|
||||||
|
const QString &message = tr("To add this RSS feed into other application, please use this information:<br/><br/>"
|
||||||
|
"<b>Title: </b>%1<br/><b>Url: </b>%2<br/><br/>"
|
||||||
|
"Url address of this feed has been copied into your clipboard.").arg(m_title, m_url.toString());
|
||||||
|
QMessageBox::information(0, tr("Add feed into other application"), message);
|
||||||
|
success = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case Internal:
|
||||||
|
success = mApp->rssManager()->addRssFeed(m_url, m_title, m_view->icon());
|
||||||
|
if (success) {
|
||||||
|
mApp->browsingLibrary()->showRSS(mApp->mainWindows().at(0));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (success) {
|
||||||
|
Settings settings;
|
||||||
|
settings.beginGroup("RSS");
|
||||||
|
settings.setValue("LastAddOptionIndex", index);
|
||||||
|
settings.endGroup();
|
||||||
|
|
||||||
|
hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
RSSNotification::~RSSNotification()
|
RSSNotification::~RSSNotification()
|
||||||
{
|
{
|
||||||
delete ui;
|
delete ui;
|
||||||
|
@ -18,23 +18,55 @@
|
|||||||
#ifndef RSSNOTIFICATION_H
|
#ifndef RSSNOTIFICATION_H
|
||||||
#define RSSNOTIFICATION_H
|
#define RSSNOTIFICATION_H
|
||||||
|
|
||||||
|
#include <QUrl>
|
||||||
|
#include <QIcon>
|
||||||
|
|
||||||
#include "qz_namespace.h"
|
#include "qz_namespace.h"
|
||||||
#include "animatedwidget.h"
|
#include "animatedwidget.h"
|
||||||
|
|
||||||
|
class WebView;
|
||||||
|
|
||||||
namespace Ui
|
namespace Ui
|
||||||
{
|
{
|
||||||
class RSSNotification;
|
class RSSNotification;
|
||||||
}
|
}
|
||||||
|
|
||||||
class AnimatedWidget;
|
|
||||||
class QT_QUPZILLA_EXPORT RSSNotification : public AnimatedWidget
|
class QT_QUPZILLA_EXPORT RSSNotification : public AnimatedWidget
|
||||||
{
|
{
|
||||||
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit RSSNotification(QString host, QWidget* parent = 0);
|
explicit RSSNotification(const QString &title, const QUrl &url, WebView* parent = 0);
|
||||||
~RSSNotification();
|
~RSSNotification();
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void hide();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void addRss();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
enum AppType { WebApplication, DesktopApplication, Internal, Other };
|
||||||
|
struct RssApp {
|
||||||
|
QString title;
|
||||||
|
QString address;
|
||||||
|
QIcon icon;
|
||||||
|
AppType type;
|
||||||
|
|
||||||
|
RssApp(const QString &t, const QString &a, const QIcon &i, AppType ty = WebApplication) {
|
||||||
|
title = t;
|
||||||
|
address = a;
|
||||||
|
icon = i;
|
||||||
|
type = ty;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
Ui::RSSNotification* ui;
|
Ui::RSSNotification* ui;
|
||||||
|
|
||||||
|
QString m_title;
|
||||||
|
QUrl m_url;
|
||||||
|
WebView* m_view;
|
||||||
|
|
||||||
|
QList<RssApp> m_rssApps;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // RSSNOTIFICATION_H
|
#endif // RSSNOTIFICATION_H
|
||||||
|
@ -38,6 +38,13 @@
|
|||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label">
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_2">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
@ -45,14 +52,36 @@
|
|||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string/>
|
<string>Add this feed into</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="pushButton">
|
<widget class="QComboBox" name="comboBox"/>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>QSizePolicy::Fixed</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>10</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="add">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Open RSS Manager</string>
|
<string>Add</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -112,11 +112,9 @@ void RSSWidget::addRss()
|
|||||||
title = button->toolTip();
|
title = button->toolTip();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mApp->rssManager()->addRssFeed(url, title, m_view->icon())) {
|
RSSNotification* notif = new RSSNotification(title, url, m_view);
|
||||||
RSSNotification* notif = new RSSNotification(title, m_view);
|
m_view->addNotification(notif);
|
||||||
m_view->addNotification(notif);
|
close();
|
||||||
close();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -837,7 +837,7 @@ void WebView::createSelectedTextContextMenu(QMenu* menu, const QWebHitTestResult
|
|||||||
|
|
||||||
QString langCode = mApp->currentLanguage().left(2);
|
QString langCode = mApp->currentLanguage().left(2);
|
||||||
QUrl googleTranslateUrl = QUrl(QString("http://translate.google.com/#auto|%1|%2").arg(langCode, selectedText));
|
QUrl googleTranslateUrl = QUrl(QString("http://translate.google.com/#auto|%1|%2").arg(langCode, selectedText));
|
||||||
Action* gtwact = new Action(QIcon(":icons/menu/translate.png"), tr("Google Translate"));
|
Action* gtwact = new Action(QIcon(":icons/sites/translate.png"), tr("Google Translate"));
|
||||||
gtwact->setData(googleTranslateUrl);
|
gtwact->setData(googleTranslateUrl);
|
||||||
connect(gtwact, SIGNAL(triggered()), this, SLOT(openUrlInSelectedTab()));
|
connect(gtwact, SIGNAL(triggered()), this, SLOT(openUrlInSelectedTab()));
|
||||||
connect(gtwact, SIGNAL(middleClicked()), this, SLOT(openUrlInBackgroundTab()));
|
connect(gtwact, SIGNAL(middleClicked()), this, SLOT(openUrlInBackgroundTab()));
|
||||||
|