This commit is contained in:
Martin Rotter 2015-12-18 14:09:14 +01:00
parent 62a0d29903
commit 261e76c539
5 changed files with 48 additions and 7 deletions

View File

@ -5,6 +5,7 @@ Added:
▪ Background color of notifications is now changeable. (issue #134) ▪ Background color of notifications is now changeable. (issue #134)
▪ Auto-update setting of individual Tiny Tiny RSS feeds can now be changed. ▪ Auto-update setting of individual Tiny Tiny RSS feeds can now be changed.
▪ RSS Guard is now useable as external RSS reader by common web browsers like Firefox etc. (issue #135)
3.0.0 3.0.0
————— —————

View File

@ -66,8 +66,10 @@ int main(int argc, char *argv[]) {
Application application(APP_LOW_NAME, argc, argv); Application application(APP_LOW_NAME, argc, argv);
qDebug("Instantiated Application class."); qDebug("Instantiated Application class.");
// TODO: dat '\n' do konstant
// Check if another instance is running. // Check if another instance is running.
if (application.sendMessage(APP_IS_RUNNING)) { if (application.sendMessage((QStringList() << APP_IS_RUNNING << application.arguments().mid(1)).join('\n'))) {
qWarning("Another instance of the application is already running. Notifying it."); qWarning("Another instance of the application is already running. Notifying it.");
return EXIT_FAILURE; return EXIT_FAILURE;
} }

View File

@ -29,6 +29,7 @@
#include "adblock/adblockmanager.h" #include "adblock/adblockmanager.h"
#include "services/abstract/serviceroot.h" #include "services/abstract/serviceroot.h"
#include "services/standard/standardserviceroot.h"
#include "services/standard/standardserviceentrypoint.h" #include "services/standard/standardserviceentrypoint.h"
#include "services/tt-rss/ttrssserviceentrypoint.h" #include "services/tt-rss/ttrssserviceentrypoint.h"
@ -158,12 +159,30 @@ void Application::restoreDatabaseSettings(bool restore_database, bool restore_se
void Application::processExecutionMessage(const QString &message) { void Application::processExecutionMessage(const QString &message) {
qDebug("Received '%s' execution message from another application instance.", qPrintable(message)); qDebug("Received '%s' execution message from another application instance.", qPrintable(message));
if (message == APP_IS_RUNNING) { // TODO: dat '\n' do konstant a taky "feed:"
showGuiMessage(APP_NAME, tr("Application is already running."), QSystemTrayIcon::Information);
mainForm()->display(); foreach (QString msg, message.split('\n')) {
} if (msg == APP_IS_RUNNING) {
else if (message == APP_QUIT_INSTANCE) { showGuiMessage(APP_NAME, tr("Application is already running."), QSystemTrayIcon::Information);
quit(); mainForm()->display();
}
else if (msg == APP_QUIT_INSTANCE) {
quit();
}
else if (msg.startsWith(QL1S("feed:"))) {
// Application was running, and someone wants to add new feed.
StandardServiceRoot *root = qApp->mainForm()->tabWidget()->feedMessageViewer()->feedsView()->sourceModel()->standardServiceRoot();
if (root != NULL) {
root->checkArgumentForFeedAdding(msg);
}
else {
showGuiMessage(tr("Cannot add feed"),
tr("Feed cannot be added because standard RSS/ATOM account is not enabled."),
QSystemTrayIcon::Warning, qApp->mainForm(),
true);
}
}
} }
} }

View File

@ -41,6 +41,7 @@
#include <QAction> #include <QAction>
#include <QPointer> #include <QPointer>
#include <QSqlTableModel> #include <QSqlTableModel>
#include <QClipboard>
StandardServiceRoot::StandardServiceRoot(RootItem *parent) StandardServiceRoot::StandardServiceRoot(RootItem *parent)
@ -95,6 +96,8 @@ void StandardServiceRoot::start() {
} }
} }
} }
checkArgumentsForFeedAdding();
} }
void StandardServiceRoot::stop() { void StandardServiceRoot::stop() {
@ -296,6 +299,19 @@ void StandardServiceRoot::loadFromDatabase(){
m_recycleBin->updateCounts(true); m_recycleBin->updateCounts(true);
} }
void StandardServiceRoot::checkArgumentsForFeedAdding() {
foreach (QString arg, qApp->arguments().mid(1)) {
checkArgumentForFeedAdding(arg);
}
}
void StandardServiceRoot::checkArgumentForFeedAdding(const QString &argument) {
if (argument.startsWith(QL1S("feed:"))) {
qApp->clipboard()->setText(argument);
addNewFeed();
}
}
QList<StandardCategory*> StandardServiceRoot::allCategories() { QList<StandardCategory*> StandardServiceRoot::allCategories() {
QList<Category*> cats = getSubTreeCategories(); QList<Category*> cats = getSubTreeCategories();
QList<StandardCategory*> std_cats; QList<StandardCategory*> std_cats;

View File

@ -95,6 +95,7 @@ class StandardServiceRoot : public ServiceRoot {
bool cleanFeeds(QList<Feed*> items, bool clean_read_only); bool cleanFeeds(QList<Feed*> items, bool clean_read_only);
void loadFromDatabase(); void loadFromDatabase();
void checkArgumentForFeedAdding(const QString &argument);
public slots: public slots:
void addNewCategory(); void addNewCategory();
@ -103,6 +104,8 @@ class StandardServiceRoot : public ServiceRoot {
void exportFeeds(); void exportFeeds();
private: private:
void checkArgumentsForFeedAdding();
// Returns converted ids of given feeds // Returns converted ids of given feeds
// which are suitable as IN clause for SQL queries. // which are suitable as IN clause for SQL queries.
QStringList textualFeedIds(const QList<Feed *> &feeds); QStringList textualFeedIds(const QList<Feed *> &feeds);