1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-24 04:36:34 +01:00

[RSSWidget] Fixed displaying a lot of RSS feeds.

Closes #906
This commit is contained in:
nowrep 2013-09-22 15:48:17 +02:00
parent 68eff6bc3a
commit 611e8bbfdf
2 changed files with 20 additions and 9 deletions

View File

@ -22,6 +22,7 @@ Version 1.5.0
* X11: Set correct WM_CLASS property to windows * X11: Set correct WM_CLASS property to windows
* fixed: size of preferences dialog on low-res screens * fixed: size of preferences dialog on low-res screens
* fixed: loading plugins with relative paths in portable build * fixed: loading plugins with relative paths in portable build
* fixed: displaying a lot of RSS feeds in RSS widget in locationbar
Version 1.4.4 Version 1.4.4
* released 1 September 2013 * released 1 September 2013

View File

@ -37,6 +37,11 @@ RSSWidget::RSSWidget(WebView* view, QWidget* parent)
QWebFrame* frame = m_view->page()->mainFrame(); QWebFrame* frame = m_view->page()->mainFrame();
QWebElementCollection links = frame->findAllElements("link[type=\"application/rss+xml\"]"); QWebElementCollection links = frame->findAllElements("link[type=\"application/rss+xml\"]");
// Make sure RSS feeds fit into a window, in case there is a lot of feeds from one page
// See #906
int cols = links.count() / 10 == 0 ? 1 : links.count() / 10;
int row = 0;
for (int i = 0; i < links.count(); i++) { for (int i = 0; i < links.count(); i++) {
QWebElement element = links.at(i); QWebElement element = links.at(i);
QString title = element.attribute("title"); QString title = element.attribute("title");
@ -51,14 +56,22 @@ RSSWidget::RSSWidget(WebView* view, QWidget* parent)
QPushButton* button = new QPushButton(this); QPushButton* button = new QPushButton(this);
button->setText(tr("Add")); button->setText(tr("Add"));
button->setToolTip(title); button->setToolTip(url.toString());
button->setProperty("rss-url", url); button->setProperty("rss-url", url);
button->setProperty("rss-title", title);
QLabel* label = new QLabel(this); QLabel* label = new QLabel(this);
label->setText(title); label->setText(fontMetrics().elidedText(title, Qt::ElideRight, 300));
label->setToolTip(title);
ui->gridLayout->addWidget(label, i, 0); int pos = i % cols > 0 ? (i % cols) * 2 : 0;
ui->gridLayout->addWidget(button, i, 1);
ui->gridLayout->addWidget(label, row, pos);
ui->gridLayout->addWidget(button, row, pos + 1);
connect(button, SIGNAL(clicked()), this, SLOT(addRss())); connect(button, SIGNAL(clicked()), this, SLOT(addRss()));
if (i % cols == cols - 1) {
row++;
}
} }
} }
@ -78,13 +91,10 @@ void RSSWidget::addRss()
return; return;
} }
QString title; QString title = button->property("rss-title").toString();
if (button->toolTip().isEmpty()) { if (title.isEmpty()) {
title = m_view->url().host(); title = m_view->url().host();
} }
else {
title = button->toolTip();
}
RSSNotification* notif = new RSSNotification(title, url, m_view); RSSNotification* notif = new RSSNotification(title, url, m_view);
m_view->addNotification(notif); m_view->addNotification(notif);