diff options
-rw-r--r-- | CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/data/rekonq.desktop | 2 | ||||
-rw-r--r-- | src/mainview.cpp | 2 | ||||
-rw-r--r-- | src/newtabpage.cpp | 34 | ||||
-rw-r--r-- | src/rekonq.kcfg | 4 | ||||
-rw-r--r-- | src/tabbar.cpp | 5 | ||||
-rw-r--r-- | src/urlbar/completionwidget.cpp | 42 | ||||
-rw-r--r-- | src/urlbar/completionwidget.h | 10 | ||||
-rw-r--r-- | src/urlbar/listitem.cpp | 32 | ||||
-rw-r--r-- | src/urlbar/listitem.h | 5 | ||||
-rw-r--r-- | src/urlbar/urlbar.cpp | 41 | ||||
-rw-r--r-- | src/urlbar/urlbar.h | 11 | ||||
-rw-r--r-- | src/websnap.cpp | 8 | ||||
-rw-r--r-- | src/websnap.h | 1 | ||||
-rw-r--r-- | src/webtab.cpp | 16 |
15 files changed, 109 insertions, 106 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 0716ca2d..a4bd59e1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,7 +7,7 @@ PROJECT( rekonq ) # Informations to update before to release this package. # rekonq info -SET(REKONQ_VERSION "0.4.60" ) +SET(REKONQ_VERSION "0.4.61" ) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/version.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/version.h ) diff --git a/src/data/rekonq.desktop b/src/data/rekonq.desktop index df564c47..b0f8f2e3 100644 --- a/src/data/rekonq.desktop +++ b/src/data/rekonq.desktop @@ -5,6 +5,7 @@ Name[da]=rekonq Name[de]=rekonq Name[en_GB]=rekonq Name[es]=rekonq +Name[fr]=rekonq Name[ga]=rekonq Name[lt]=rekonq Name[nds]=Rekonq @@ -20,6 +21,7 @@ GenericName[da]=KDE-browser baseret på Webkit GenericName[de]=WebKit-basierter Webbrowser für KDE GenericName[en_GB]=Webkit KDE Browser GenericName[es]=Navegador Webkit para KDE +GenericName[fr]=Navigateur Webkit pour KDE GenericName[ga]=Brabhsálaí Webkit KDE GenericName[lt]=Webkit KDE naršyklė GenericName[nds]=Webkit-KDE-Kieker diff --git a/src/mainview.cpp b/src/mainview.cpp index a5eaa748..cb2e3b11 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -467,7 +467,7 @@ void MainView::closeTab(int index) case 0: // new tab page case 1: // blank page w->load( KUrl("about:home") ); - urlBarWidget()->setFocus(); + urlBar()->setFocus(); break; case 2: // homepage w->load( KUrl(ReKonfig::homePage()) ); diff --git a/src/newtabpage.cpp b/src/newtabpage.cpp index 043648e7..d7671937 100644 --- a/src/newtabpage.cpp +++ b/src/newtabpage.cpp @@ -283,20 +283,9 @@ void NewTabPage::setupPreview(QWebElement e, int index) void NewTabPage::snapFinished(int index, const KUrl &url, const QString &title) { - // do not try to modify the page if it isn't the newTabPage - if(m_root.document().findAll("#rekonq-newtabpage").count() == 0) - return; - - QWebElement prev = m_root.findFirst("#preview" + QVariant(index).toString()); - QWebElement newPrev = validPreview(index, url, title); - - if(m_root.findAll(".closedTabs").count() != 0) - hideControls(newPrev); - - prev.replace(newPrev); - - // update title - if(m_root.findAll(".favorites").count() != 0) + // Update title if necessary + QStringList urls = ReKonfig::previewUrls(); + if(KUrl(urls.at(index)) == url) { QStringList names = ReKonfig::previewNames(); names.replace(index, title); @@ -304,6 +293,23 @@ void NewTabPage::snapFinished(int index, const KUrl &url, const QString &title) ReKonfig::self()->writeConfig(); } + + // Update page, but only if open + if(m_root.document().findAll("#rekonq-newtabpage").count() == 0) + return; + if(m_root.findAll(".favorites").count() == 0 && m_root.findAll(".closedTabs").count() == 0) + return; + + QWebElement prev = m_root.findFirst("#preview" + QVariant(index).toString()); + if(KUrl(prev.findFirst("a").attribute("href")) == url) + { + QWebElement newPrev = validPreview(index, url, title); + + if(m_root.findAll(".closedTabs").count() != 0) + hideControls(newPrev); + + prev.replace(newPrev); + } } diff --git a/src/rekonq.kcfg b/src/rekonq.kcfg index ea09acbc..c999d063 100644 --- a/src/rekonq.kcfg +++ b/src/rekonq.kcfg @@ -34,10 +34,10 @@ <!-- New Tab Page Settings --> <group name="NewTabPage"> <entry name="previewNames" type="StringList"> - <default>KDE Homepage,UserBase,,,,,,</default> + <default>KDE Homepage,UserBase,rekonq site</default> </entry> <entry name="previewUrls" type="StringList"> - <default>http://www.kde.org,http://userbase.kde.org,,,,,,</default> + <default>http://www.kde.org,http://userbase.kde.org,http://rekonq.sourceforge.net</default> </entry> </group> diff --git a/src/tabbar.cpp b/src/tabbar.cpp index 518b1a96..f8da57b1 100644 --- a/src/tabbar.cpp +++ b/src/tabbar.cpp @@ -164,13 +164,16 @@ void TabBar::showTabPreview(int tab) delete m_previewPopup.data(); m_previewPopup.clear(); + if (indexedTab->progress() != 0) + return; + m_previewPopup = new KPassivePopup(this); m_previewPopup.data()->setFrameShape(QFrame::StyledPanel); m_previewPopup.data()->setFrameShadow(QFrame::Plain); m_previewPopup.data()->setFixedSize(w, h); QLabel *l = new QLabel(); - l->setPixmap( WebSnap::renderPreview( *indexedTab->page(), w, h, false) ); + l->setPixmap( WebSnap::renderPreview( *indexedTab->page(), w, h, true) ); m_previewPopup.data()->setView(l); m_previewPopup.data()->layout()->setAlignment(Qt::AlignTop); diff --git a/src/urlbar/completionwidget.cpp b/src/urlbar/completionwidget.cpp index 83e99f9d..be86238d 100644 --- a/src/urlbar/completionwidget.cpp +++ b/src/urlbar/completionwidget.cpp @@ -30,6 +30,7 @@ // Local Includes #include "application.h" +#include "urlresolver.h" // KDE Includes #include <KGlobalSettings> @@ -173,6 +174,8 @@ bool CompletionWidget::eventFilter( QObject *o, QEvent *e ) //actions on the CompletionWidget if (wid && wid->isAncestorOf(_parent) && isVisible()) { + ListItem *child; + if ( type == QEvent::KeyPress ) { QKeyEvent *ev = static_cast<QKeyEvent *>( e ); @@ -196,7 +199,7 @@ bool CompletionWidget::eventFilter( QObject *o, QEvent *e ) ev->accept(); return true; } - else if (ev->modifiers() & Qt::ControlModifier) + if (ev->modifiers() & Qt::ControlModifier) { emit nextItemSubChoice(); ev->accept(); @@ -206,18 +209,19 @@ bool CompletionWidget::eventFilter( QObject *o, QEvent *e ) case Qt::Key_Enter: case Qt::Key_Return: - - // need this to let ListItem magic work.. - ListItem *child = findChild<ListItem *>( QString::number(_currentIndex) ); + child = findChild<ListItem *>( QString::number(_currentIndex) ); emit chosenUrl( child->url(), Rekonq::CurrentTab); ev->accept(); hide(); return true; - break; + + case Qt::Key_Escape: + hide(); + return true; } } } - + return QFrame::eventFilter(o,e); } @@ -246,3 +250,29 @@ void CompletionWidget::itemChosen(ListItem *item, Qt::MouseButton button) emit chosenUrl( item->url(), Rekonq::CurrentTab); hide(); } + + + + +void CompletionWidget::suggestUrls(const QString &text) +{ + QWidget *w = qobject_cast<QWidget *>(parent()); + if(!w->hasFocus()) + return; + + if(text.isEmpty()) + { + hide(); + return; + } + + UrlResolver res(text); + UrlSearchList list = res.orderedSearchItems(); + + if(list.count() > 0) + { + clear(); + insertSearchList(list, text); + popup(); + } +} diff --git a/src/urlbar/completionwidget.h b/src/urlbar/completionwidget.h index 125e186a..896518fc 100644 --- a/src/urlbar/completionwidget.h +++ b/src/urlbar/completionwidget.h @@ -30,7 +30,6 @@ // Local Includes #include "application.h" -#include "urlresolver.h" #include "listitem.h" // KDE Includes @@ -47,21 +46,22 @@ class CompletionWidget : public QFrame public: CompletionWidget(QWidget *parent); - void insertSearchList(const UrlSearchList &list, const QString& text); - void popup(); - void clear(); - virtual bool eventFilter(QObject *obj, QEvent *ev); void setVisible(bool visible); private slots: void itemChosen(ListItem *item, Qt::MouseButton = Qt::LeftButton); + void suggestUrls(const QString &text); signals: void chosenUrl(const KUrl &, Rekonq::OpenType); void nextItemSubChoice(); private: + void insertSearchList(const UrlSearchList &list, const QString& text); + void popup(); + void clear(); + void sizeAndPosition(); void up(); void down(); diff --git a/src/urlbar/listitem.cpp b/src/urlbar/listitem.cpp index 7d1d39b2..229b43e9 100644 --- a/src/urlbar/listitem.cpp +++ b/src/urlbar/listitem.cpp @@ -31,6 +31,7 @@ // Local Includes #include "urlresolver.h" #include "application.h" +#include "websnap.h" // KDE Includes #include <KIcon> @@ -199,7 +200,9 @@ ItemText::ItemText(const QString &text, const QString &textToPointOut, QWidget * : QLabel(parent) { QString t = text; - t = t.replace(QRegExp("(" + textToPointOut + ")", Qt::CaseInsensitive), "<b>\\1</b>"); + if (!textToPointOut.isEmpty()) + t = t.replace(QRegExp("(" + textToPointOut + ")", Qt::CaseInsensitive), "<b>\\1</b>"); + setText(t); setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum); } @@ -236,7 +239,8 @@ ItemPreview::ItemPreview(const QString &url, int width, int height, QWidget *par setFixedSize(width, height); setFrameStyle(QFrame::StyledPanel | QFrame::Raised); - QString path = KStandardDirs::locateLocal("cache", QString("thumbs/") + guessNameFromUrl( QUrl(url) ) + ".png", true); + KUrl u = WebSnap::fileForUrl( QUrl(url) ); + QString path = u.pathOrUrl(); if(QFile::exists(path)) { QPixmap preview; @@ -246,26 +250,6 @@ ItemPreview::ItemPreview(const QString &url, int width, int height, QWidget *par } -//TODO: REMOVE DUPLICATE CODE WITH PREVIEWIMAGE -QString ItemPreview::guessNameFromUrl(QUrl url) -{ - QString name = url.toString( QUrl::RemoveScheme | QUrl::RemoveUserInfo | QUrl::StripTrailingSlash ); - - // TODO learn Regular Expressions :) - // and implement something better here.. - name.remove('/'); - name.remove('&'); - name.remove('.'); - name.remove('-'); - name.remove('_'); - name.remove('?'); - name.remove('='); - name.remove('+'); - - return name; -} - - // --------------------------------------------------------------- @@ -279,7 +263,7 @@ SearchListItem::SearchListItem(const UrlSearchItem &item, const QString &text, Q if (m_currentEngine == "") m_currentEngine = EngineBar::defaultEngine(); m_iconLabel = new ItemIcon("edit-find", this); //TODO: get the default engine icon - m_titleLabel = new ItemText(searchItemTitle(m_currentEngine, text), text); + m_titleLabel = new ItemText(searchItemTitle(m_currentEngine, text)); m_engineBar = new EngineBar(text, m_currentEngine, this); // without this it will not work :) @@ -297,7 +281,7 @@ SearchListItem::SearchListItem(const UrlSearchItem &item, const QString &text, Q QString SearchListItem::searchItemTitle(QString engine, QString text) { - return QString("Search "+ engine +" for <u>"+text+"</u>"); + return QString("Search "+ engine +" for <b>"+text+"</b>"); } diff --git a/src/urlbar/listitem.h b/src/urlbar/listitem.h index e355160a..8a6f520f 100644 --- a/src/urlbar/listitem.h +++ b/src/urlbar/listitem.h @@ -114,7 +114,7 @@ class ItemText : public QLabel Q_OBJECT public: - ItemText(const QString &text, const QString &textToPointOut, QWidget *parent = 0); + ItemText(const QString &text, const QString &textToPointOut = QString(), QWidget *parent = 0); }; @@ -193,9 +193,6 @@ class ItemPreview : public QLabel public: ItemPreview(const QString &url, int width, int height, QWidget *parent = 0); - -private: - static QString guessNameFromUrl(QUrl url); }; diff --git a/src/urlbar/urlbar.cpp b/src/urlbar/urlbar.cpp index 4e7310bf..8c6c0749 100644 --- a/src/urlbar/urlbar.cpp +++ b/src/urlbar/urlbar.cpp @@ -38,8 +38,9 @@ #include "application.h" #include "lineedit.h" #include "mainwindow.h" +#include "webtab.h" #include "webview.h" -#include "urlresolver.h" +#include "completionwidget.h" // KDE Includes #include <KDebug> @@ -71,7 +72,7 @@ UrlBar::UrlBar(QWidget *parent) // suggestions installEventFilter(_box); - connect(_box, SIGNAL(chosenUrl(const KUrl &, Rekonq::OpenType)), SLOT(activated(const KUrl &, Rekonq::OpenType))); + connect(_box, SIGNAL(chosenUrl(const KUrl &, Rekonq::OpenType)), this, SLOT(activated(const KUrl &, Rekonq::OpenType))); // load typed urls connect(this, SIGNAL(returnPressed(const QString &)), this, SLOT(loadTyped(const QString &))); @@ -94,6 +95,7 @@ void UrlBar::setQUrl(const QUrl& url) } else { + clearFocus(); LineEdit::setUrl(url); setCursorPosition(0); iconButton()->setIcon( Application::icon(url) ); @@ -103,7 +105,7 @@ void UrlBar::setQUrl(const QUrl& url) void UrlBar::activated(const KUrl& url, Rekonq::OpenType type) { - disconnect(this, SIGNAL(textChanged(const QString &)), this, SLOT(suggestUrls(const QString &))); + disconnect(this, SIGNAL(textChanged(const QString &)), _box, SLOT(suggestUrls(const QString &))); clearFocus(); setUrl(url); @@ -152,12 +154,6 @@ void UrlBar::paintEvent(QPaintEvent *event) void UrlBar::keyPressEvent(QKeyEvent *event) { - if(event->key() == Qt::Key_Escape) - { - _box->hide(); - return; - } - // this handles the Modifiers + Return key combinations QString currentText = text().trimmed(); if ((event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return) @@ -191,35 +187,10 @@ void UrlBar::keyPressEvent(QKeyEvent *event) } -void UrlBar::suggestUrls(const QString &text) -{ - if (!hasFocus()) - { - return; - } - - if(text.isEmpty()) - { - _box->hide(); - return; - } - - UrlResolver res(text); - UrlSearchList list = res.orderedSearchItems(); - - if(list.count() > 0) - { - _box->clear(); - _box->insertSearchList(list, text); - _box->popup(); - } -} - - void UrlBar::focusInEvent(QFocusEvent *event) { // activate suggestions on edit text - connect(this, SIGNAL(textChanged(const QString &)), this, SLOT(suggestUrls(const QString &))); + connect(this, SIGNAL(textChanged(const QString &)), _box, SLOT(suggestUrls(const QString &))); LineEdit::focusInEvent(event); } diff --git a/src/urlbar/urlbar.h b/src/urlbar/urlbar.h index 804188f7..3ecd914e 100644 --- a/src/urlbar/urlbar.h +++ b/src/urlbar/urlbar.h @@ -33,20 +33,16 @@ // Local Includes #include "lineedit.h" -#include "completionwidget.h" -#include "webtab.h" +#include "application.h" // KDE Includes #include <KUrl> -#include <KComboBox> - -// Qt Includes -#include <QUrl> -#include <QPointer> // Forward Declarations class QLinearGradient; class QWidget; +class CompletionWidget; +class WebTab; class UrlBar : public LineEdit @@ -61,7 +57,6 @@ public: private slots: void activated(const KUrl& url, Rekonq::OpenType = Rekonq::CurrentTab); - void suggestUrls(const QString &editedText); void setQUrl(const QUrl &url); void loadFinished(); diff --git a/src/websnap.cpp b/src/websnap.cpp index 906bbc1e..612fdf4e 100644 --- a/src/websnap.cpp +++ b/src/websnap.cpp @@ -146,20 +146,22 @@ QString WebSnap::guessNameFromUrl(QUrl url) void WebSnap::saveResult(bool ok) { + QPixmap image = QPixmap(); + // crude error-checking if (!ok) { kDebug() << "Error loading site.."; m_snapTitle = "Error..."; - m_image = QPixmap(); + } else { - m_image = renderPreview(m_page, WIDTH, HEIGHT); + image = renderPreview(m_page, WIDTH, HEIGHT); m_snapTitle = m_page.mainFrame()->title(); } QFile::remove(fileForUrl(m_url).toLocalFile()); - m_image.save(fileForUrl(m_url).toLocalFile()); + image.save(fileForUrl(m_url).toLocalFile()); NewTabPage p( m_frame ); p.snapFinished(m_previewIndex, m_url, m_snapTitle); diff --git a/src/websnap.h b/src/websnap.h index e7c9e593..9773b4cc 100644 --- a/src/websnap.h +++ b/src/websnap.h @@ -78,7 +78,6 @@ private slots: private: QWebPage m_page; - QPixmap m_image; QUrl m_url; QString m_snapTitle; diff --git a/src/webtab.cpp b/src/webtab.cpp index fd44cc10..6bafd04a 100644 --- a/src/webtab.cpp +++ b/src/webtab.cpp @@ -184,7 +184,21 @@ bool WebTab::hasRSSInfo() foreach(QWebElement el, col) { if( el.attribute("type") == QL1S("application/rss+xml") || el.attribute("type") == QL1S("application/rss+xml") ) - _rssList << KUrl( el.attribute("href") ); + { + if( el.attribute("href").startsWith( QL1S("http") ) ) + { + _rssList << KUrl( el.attribute("href") ); + } + else + { + KUrl u = url(); + // NOTE + // cd() is probably better than setPath() here, + // for all those url sites just having a path + if(u.cd( el.attribute("href") )) + _rssList << u; + } + } } return !_rssList.isEmpty(); |