From 5f5a1115789cce067f277476a6ab44e0d6c5c933 Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Thu, 2 Jun 2016 11:25:21 -0400 Subject: Get the new RSS reader plugin all setup and fully-functional. --- .../desktop-plugins/rssfeeder/RSSFeedPlugin.cpp | 87 +++++++++++++++++++--- .../desktop-plugins/rssfeeder/RSSFeedPlugin.h | 4 +- .../desktop-plugins/rssfeeder/RSSFeedPlugin.ui | 58 +++++++++------ .../desktop-plugins/rssfeeder/RSSObjects.cpp | 37 +++++++-- .../desktop-plugins/rssfeeder/RSSObjects.h | 1 + 5 files changed, 148 insertions(+), 39 deletions(-) diff --git a/src-qt5/core/lumina-desktop/desktop-plugins/rssfeeder/RSSFeedPlugin.cpp b/src-qt5/core/lumina-desktop/desktop-plugins/rssfeeder/RSSFeedPlugin.cpp index 0bfc090e..4a1149ba 100644 --- a/src-qt5/core/lumina-desktop/desktop-plugins/rssfeeder/RSSFeedPlugin.cpp +++ b/src-qt5/core/lumina-desktop/desktop-plugins/rssfeeder/RSSFeedPlugin.cpp @@ -24,6 +24,9 @@ RSSFeedPlugin::RSSFeedPlugin(QWidget* parent, QString ID) : LDPlugin(parent, ID) //Create the options menu optionsMenu = new QMenu(this); ui->tool_options->setMenu(optionsMenu); + presetMenu = new QMenu(this); + ui->tool_add_preset->setMenu(presetMenu); + //Setup any signal/slot connections connect(ui->push_back1, SIGNAL(clicked()), this, SLOT(backToFeeds()) ); connect(ui->push_back2, SIGNAL(clicked()), this, SLOT(backToFeeds()) ); @@ -34,8 +37,12 @@ RSSFeedPlugin::RSSFeedPlugin(QWidget* parent, QString ID) : LDPlugin(parent, ID) connect(ui->tool_gotosite, SIGNAL(clicked()), this, SLOT(openFeedPage()) ); connect(ui->push_rm_feed, SIGNAL(clicked()), this, SLOT(removeFeed()) ); connect(ui->push_add_url, SIGNAL(clicked()), this, SLOT(addNewFeed()) ); + connect(ui->combo_feed, SIGNAL(currentIndexChanged(int)), this, SLOT(currentFeedChanged()) ); + + connect(presetMenu, SIGNAL(triggered(QAction*)), this, SLOT(loadPreset(QAction*)) ); + updateOptionsMenu(); - QTimer::singleShot(0,this, SLOT(loadIcons()) ); + QTimer::singleShot(0,this, SLOT(ThemeChange()) ); //qDebug() << " - Done with init"; QStringList feeds; if( !LSession::handle()->DesktopPluginSettings()->contains(setprefix+"currentfeeds") ){ @@ -46,6 +53,7 @@ RSSFeedPlugin::RSSFeedPlugin(QWidget* parent, QString ID) : LDPlugin(parent, ID) feeds = LSession::handle()->DesktopPluginSettings()->value(setprefix+"currentfeeds",QStringList()).toStringList(); } RSS->addUrls(feeds); + backToFeeds(); //always load the first page } RSSFeedPlugin::~RSSFeedPlugin(){ @@ -62,15 +70,34 @@ void RSSFeedPlugin::updateOptionsMenu(){ optionsMenu->addAction(LXDG::findIcon("configure",""), tr("Settings"), this, SLOT(openSettings()) ); optionsMenu->addSeparator(); optionsMenu->addAction(LXDG::findIcon("download",""), tr("Update Feeds Now"), this, SLOT(resyncFeeds()) ); + + presetMenu->clear(); + QAction *tmp = presetMenu->addAction( tr("Lumina Desktop RSS") ); + tmp->setWhatsThis("http://lumina-desktop.org/?feed=rss2"); + //Add any other feeds here as needed (TO-DO) + +} + +void RSSFeedPlugin::checkFeedNotify(){ + bool notify = false; + for(int i=0; icombo_feed->count() && !notify; i++){ + if( !ui->combo_feed->itemData(i, Qt::WhatsThisRole).toString().isEmpty()){ notify = true; } + } + QString style; + if(notify){ style = "QComboBox::down-arrow{ background-color: rgba(255,0,0,120); }"; } + ui->combo_feed->setStyleSheet(style); } //Simplification functions for loading feed info onto widgets void RSSFeedPlugin::updateFeed(QString ID){ - //Save the datetime this feed was read - LSession::handle()->DesktopPluginSettings()->setValue(setprefix+"feedReads/"+ID, QDateTime::currentDateTime() ); - //Now clear/update the feed viewer (HTML) ui->text_feed->clear(); + if(ID.isEmpty()){ return; } //nothing to show + + //Save the datetime this feed was read + LSession::handle()->DesktopPluginSettings()->setValue(setprefix+"feedReads/"+ID, QDateTime::currentDateTime() ); + //Get the color to use for hyperlinks (need to specify in html) + QString color = ui->text_feed->palette().text().color().name(); //keep the hyperlinks the same color as the main text (different formatting still applies) QString html; RSSchannel data = RSS->dataForID(ID); ui->label_lastupdate->setText( data.lastsync.toString(Qt::DefaultLocaleShortDate) ); @@ -78,8 +105,17 @@ void RSSFeedPlugin::updateFeed(QString ID){ // html.append("