From 4ff1ef46d5a03e1fe19619ce41070c70a517d41d Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Tue, 19 Nov 2013 16:39:13 +0100 Subject: improvement on urlbar suggestions STEP 1: clean up! - remember deleting ASAP the UrlSuggester - remove preview label icon to let loading being faster - remove unused opensearch inventories - let ESC key on suggestions behave like major browser (restoring original string) --- src/data/CMakeLists.txt | 21 ------- src/data/beolingus.xml | 8 --- src/data/bing.xml | 8 --- src/data/db_opensearch.json | 67 ---------------------- src/data/de2en.xml | 8 --- src/data/dictfr.xml | 8 --- src/data/facebook.xml | 8 --- src/data/google.xml | 9 --- src/data/kde_techbase.xml | 8 --- src/data/kde_userbase.xml | 8 --- src/data/voila.xml | 8 --- src/data/wikia.xml | 8 --- src/data/wikipedia.xml | 8 --- src/data/wiktionary.xml | 8 --- src/data/wr_english.xml | 6 -- src/data/yahoo.xml | 8 --- src/data/youtube.xml | 7 --- src/urlbar/completionwidget.cpp | 6 ++ src/urlbar/listitem.cpp | 122 +--------------------------------------- src/urlbar/listitem.h | 56 ++---------------- src/urlbar/urlsuggester.h | 19 +------ 21 files changed, 14 insertions(+), 395 deletions(-) delete mode 100644 src/data/beolingus.xml delete mode 100644 src/data/bing.xml delete mode 100644 src/data/db_opensearch.json delete mode 100644 src/data/de2en.xml delete mode 100644 src/data/dictfr.xml delete mode 100644 src/data/facebook.xml delete mode 100644 src/data/google.xml delete mode 100644 src/data/kde_techbase.xml delete mode 100644 src/data/kde_userbase.xml delete mode 100644 src/data/voila.xml delete mode 100644 src/data/wikia.xml delete mode 100644 src/data/wikipedia.xml delete mode 100644 src/data/wiktionary.xml delete mode 100644 src/data/wr_english.xml delete mode 100644 src/data/yahoo.xml delete mode 100644 src/data/youtube.xml diff --git a/src/data/CMakeLists.txt b/src/data/CMakeLists.txt index 1b6f2ca8..cda545f0 100644 --- a/src/data/CMakeLists.txt +++ b/src/data/CMakeLists.txt @@ -43,24 +43,3 @@ INSTALL( DESTINATION ${DATA_INSTALL_DIR}/rekonq ) -# opensearch engines -INSTALL( - FILES - beolingus.xml - bing.xml - yahoo.xml - de2en.xml - dictfr.xml - facebook.xml - google.xml - kde_techbase.xml - kde_userbase.xml - youtube.xml - voila.xml - wikia.xml - wikipedia.xml - wiktionary.xml - wr_english.xml - db_opensearch.json - DESTINATION ${DATA_INSTALL_DIR}/rekonq/opensearch -) diff --git a/src/data/beolingus.xml b/src/data/beolingus.xml deleted file mode 100644 index 60901163..00000000 --- a/src/data/beolingus.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - De-En Beolingus - Beolingus: German-English Dictionary - - - http://dict.tu-chemnitz.de/pics/beo-de.png - diff --git a/src/data/bing.xml b/src/data/bing.xml deleted file mode 100644 index 5c18a651..00000000 --- a/src/data/bing.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - Bing - Use the Bing Decision Engine to search the Web. - - - http://www.bing.com/s/wlflag.ico - diff --git a/src/data/db_opensearch.json b/src/data/db_opensearch.json deleted file mode 100644 index 16fc3f89..00000000 --- a/src/data/db_opensearch.json +++ /dev/null @@ -1,67 +0,0 @@ -[["http://www.7digital.com/osd.xml","7digital"], -["http://dict.tu-chemnitz.de/de-en/opensearch.xml","beolingus"], -["http://www.blip.tv/opensearch.xml","blip"], -["http://b.static.ak.fbcdn.net/rsrc.php/zJ/r/H2SSvhJMJA-.xml","facebook"], -["http://www.flickr.com/opensearch.xml","flickr"], -["https://github.com/opensearch.xml","github"], -["https://bugs.kde.org/search_plugin.cgi","bugft"], -["http://st.pimg.net/tucs/opensearch.xml","cpan"], - -["http://citeseerx.ist.psu.edu/search_plugins/citeseerx_general.xml","citeseerx"], -["http://citeseerx.ist.psu.edu/search_plugins/citeseerx_authorl.xml","citeseerx"], -["http://citeseerx.ist.psu.edu/search_plugins/citeseerx_title.xml","citeseerx"], - -["http://identi.ca/opensearch/people","identica_people"], -["http://identi.ca/opensearch/notice","identica_notices"], - -["http://www.cnrtl.fr/portail/opensearch.xml","dictfr"], - -["http://www.youtube.com/opensearch?locale=en_GB","youtube"], -["http://static1.urbandictionary.com/osd.xml?1292027099","urbandictionary"], - -["http://www.wordreference.com/tools/OpenSearch/enes.xml","en2es"], -["http://www.wordreference.com/tools/OpenSearch/esen.xml","es2en"], -["http://www.wordreference.com/tools/OpenSearch/enfr.xml","en2fr"], -["http://www.wordreference.com/tools/OpenSearch/fren.xml","fr2en"], -["http://www.wordreference.com/tools/OpenSearch/enit.xml","en2it"], -["http://www.wordreference.com/tools/OpenSearch/iten.xml","it2en"], -["http://www.wordreference.com/tools/OpenSearch/definition.xml","wordref"], -["http://dict.tu-chemnitz.de/de-en/opensearch.xml","de2en"], -["http://www.dict.cc/opensearch.xml","en2de"], -["http://dict.leo.org/plugins/Shared/Searches/leo_frde_de.xml","fr2de"], -["http://dict.leo.org/plugins/Shared/Searches/leo_ende_de.xml","leo"], - -["http://opensearch.search.ke.voila.fr/voila.xml","voila"], -["http://www.wikia.com/opensearch_desc.php","wikia"], - -["http://techbase.kde.org/opensearch_desc.php","kde_techbase"], -["http://userbase.kde.org/opensearch_desc.php","kde_userbase"], - -["http://duckduckgo.com/opensearch.xml","duckduckgo"], - -["http://ecosia.org/_files/searchplugin.xml","ecosia"], - -["http://fr.wikipedia.org/w/opensearch_desc.php","wikipedia"], -["http://en.wikipedia.org/w/opensearch_desc.php","wikipedia"], -["http://it.wikipedia.org/w/opensearch_desc.php","wikipedia"], -["http://de.wikipedia.org/w/opensearch_desc.php","wikipedia"], -["http://es.wikipedia.org/w/opensearch_desc.php","wikipedia"], -["http://nl.wikipedia.org/w/opensearch_desc.php","wikipedia"], -["http://pl.wikipedia.org/w/opensearch_desc.php","wikipedia"], -["http://ja.wikipedia.org/w/opensearch_desc.php","wikipedia"], -["http://ru.wikipedia.org/w/opensearch_desc.php","wikipedia"], -["http://pt.wikipedia.org/w/opensearch_desc.php","wikipedia"], - -["http://fr.wiktionary.org/w/opensearch_desc.php","wiktionary"], -["http://en.wiktionary.org/w/opensearch_desc.php","wiktionary"], -["http://it.wiktionary.org/w/opensearch_desc.php","wiktionary"], -["http://de.wiktionary.org/w/opensearch_desc.php","wiktionary"], -["http://es.wiktionary.org/w/opensearch_desc.php","wiktionary"], -["http://nl.wiktionary.org/w/opensearch_desc.php","wiktionary"], -["http://pl.wiktionary.org/w/opensearch_desc.php","wiktionary"], -["http://ja.wiktionary.org/w/opensearch_desc.php","wiktionary"], -["http://ru.wiktionary.org/w/opensearch_desc.php","wiktionary"], -["http://pt.wiktionary.org/w/opensearch_desc.php","wiktionary"], - -["http://search.yippy.com/search?v:project=opensearch-desc&v:frame=form&","yippy"], -["http://www.wolframalpha.com/searchDescription.xml","wolfram_alpha"]] \ No newline at end of file diff --git a/src/data/de2en.xml b/src/data/de2en.xml deleted file mode 100644 index 60901163..00000000 --- a/src/data/de2en.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - De-En Beolingus - Beolingus: German-English Dictionary - - - http://dict.tu-chemnitz.de/pics/beo-de.png - diff --git a/src/data/dictfr.xml b/src/data/dictfr.xml deleted file mode 100644 index 64e90ea3..00000000 --- a/src/data/dictfr.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - Portail Lexical - CNRTL - Cherche dans le TLF sur le portail lexical du CNRTL - - - http://www.cnrtl.fr/favicon.ico - diff --git a/src/data/facebook.xml b/src/data/facebook.xml deleted file mode 100644 index 612e7cd0..00000000 --- a/src/data/facebook.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - Facebook - Search Facebook - - - http://www.facebook.com/favicon.ico - diff --git a/src/data/google.xml b/src/data/google.xml deleted file mode 100644 index 622a0737..00000000 --- a/src/data/google.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - Google - Google Web Search - - - http://www.google.com/favicon.ico - - diff --git a/src/data/kde_techbase.xml b/src/data/kde_techbase.xml deleted file mode 100644 index 25fc6e4c..00000000 --- a/src/data/kde_techbase.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - KDE TechBase (en) - KDE TechBase (en) - - - http://techbase.kde.org/favicon.ico - diff --git a/src/data/kde_userbase.xml b/src/data/kde_userbase.xml deleted file mode 100644 index 64877019..00000000 --- a/src/data/kde_userbase.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - KDE UserBase (en) - KDE UserBase (en) - - - http://userbase.kde.org/favicon.png - diff --git a/src/data/voila.xml b/src/data/voila.xml deleted file mode 100644 index 55780275..00000000 --- a/src/data/voila.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - Voila - Moteur de recherche Voila - - - http://www.voila.fr/favicon.ico - diff --git a/src/data/wikia.xml b/src/data/wikia.xml deleted file mode 100644 index 0a1eac69..00000000 --- a/src/data/wikia.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - Wikia (en) - Wikia (en) - - - http://images.wikia.com/wikiaglobal/images/6/64/Favicon.ico - diff --git a/src/data/wikipedia.xml b/src/data/wikipedia.xml deleted file mode 100644 index 9f9bdda4..00000000 --- a/src/data/wikipedia.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - Wikipedia - Wikipedia - - - http://en.wikipedia.org/favicon.ico - diff --git a/src/data/wiktionary.xml b/src/data/wiktionary.xml deleted file mode 100644 index 033f5b9e..00000000 --- a/src/data/wiktionary.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - Wiktionary - Wiktionary - - - http://en.wiktionary.org/favicon.ico - diff --git a/src/data/wr_english.xml b/src/data/wr_english.xml deleted file mode 100644 index 30c9339b..00000000 --- a/src/data/wr_english.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - WR English - WordReference monolingual English dictionary search - - diff --git a/src/data/yahoo.xml b/src/data/yahoo.xml deleted file mode 100644 index d769ef25..00000000 --- a/src/data/yahoo.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - Yahoo! - Yahoo! Web Search - - - http://www.yahoo.com/favicon.ico - diff --git a/src/data/youtube.xml b/src/data/youtube.xml deleted file mode 100644 index 1fa8338a..00000000 --- a/src/data/youtube.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - Recherche de vidéos YouTube - Recherche de vidéos sur YouTube - - http://www.youtube.com/favicon.ico - diff --git a/src/urlbar/completionwidget.cpp b/src/urlbar/completionwidget.cpp index f745afae..b7a7bfdb 100644 --- a/src/urlbar/completionwidget.cpp +++ b/src/urlbar/completionwidget.cpp @@ -334,6 +334,10 @@ bool CompletionWidget::eventFilter(QObject *obj, QEvent *ev) } case Qt::Key_Escape: hide(); + + w = qobject_cast(parent()); + w->setText(_typedString); + return true; } } @@ -400,6 +404,8 @@ void CompletionWidget::suggestUrls(const QString &text) // NOTE: It's important to call this AFTER orderedSearchItems() to let everything work res->computeSuggestions(); + + delete res; } diff --git a/src/urlbar/listitem.cpp b/src/urlbar/listitem.cpp index 02605167..b8b980c6 100644 --- a/src/urlbar/listitem.cpp +++ b/src/urlbar/listitem.cpp @@ -344,14 +344,6 @@ PreviewListItem::PreviewListItem(const UrlSuggestionItem &item, const QString &t vLayout->addWidget(new TextLabel("" + item.url + "", text, this)); hLayout->addLayout(vLayout); - // preview label icon - QLabel *previewLabelIcon = new QLabel(this); - previewLabelIcon->setFixedSize(45, 33); - new PreviewLabel(item.url, 38, 29, previewLabelIcon); - IconLabel* icon = new IconLabel(item.url, previewLabelIcon); - icon->move(27, 16); - hLayout->addWidget(previewLabelIcon); - setLayout(hLayout); } @@ -359,67 +351,6 @@ PreviewListItem::PreviewListItem(const UrlSuggestionItem &item, const QString &t // --------------------------------------------------------------- -PreviewLabel::PreviewLabel(const QString &url, int width, int height, QWidget *parent) - : QLabel(parent) -{ - setFixedSize(width, height); - setFrameStyle(QFrame::StyledPanel | QFrame::Raised); - - KUrl u = KUrl(url); - if (WebSnap::existsImage(KUrl(u))) - { - QPixmap preview; - preview.load(WebSnap::imagePathFromUrl(u)); - setPixmap(preview.scaled(width, height, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); - } -} - - -// --------------------------------------------------------------- - - -ImageLabel::ImageLabel(const QString &url, int width, int height, QWidget *parent) - : QLabel(parent), - m_url(url) -{ - setFixedSize(width, height); - if (WebSnap::existsImage(KUrl(url))) - { - QPixmap pix; - pix.load(WebSnap::imagePathFromUrl(url)); - setPixmap(pix); - } - else - { - KIO::TransferJob *job = KIO::get(KUrl(url), KIO::NoReload, KIO::HideProgressInfo); - connect(job, SIGNAL(data(KIO::Job*,QByteArray)), - this, SLOT(slotData(KJob*,QByteArray))); - connect(job, SIGNAL(result(KJob*)), - this, SLOT(slotResult(KJob*))); - } -} - - -void ImageLabel::slotData(KJob *job, const QByteArray &data) -{ - Q_UNUSED(job); - m_data.append(data); -} - - -void ImageLabel::slotResult(KJob *) -{ - QPixmap pix; - if (!pix.loadFromData(m_data)) - kDebug() << "error while loading image: "; - setPixmap(pix); - pix.save(WebSnap::imagePathFromUrl(m_url), "PNG"); -} - - -// --------------------------------------------------------------- - - SearchListItem::SearchListItem(const UrlSuggestionItem &item, const QString &text, QWidget *parent) : ListItem(item, parent) , m_text(text) @@ -590,52 +521,6 @@ QString SuggestionListItem::text() // --------------------------------------------------------------- -VisualSuggestionListItem::VisualSuggestionListItem(const UrlSuggestionItem &item, const QString &text, QWidget *parent) - : ListItem(item, parent) - , m_text(item.title) -{ - - QHBoxLayout *hLayout = new QHBoxLayout; - hLayout->setSpacing(4); - QLabel *previewLabelIcon = new QLabel(this); - - if (!item.image.isEmpty()) - { - previewLabelIcon->setFixedSize(item.image_width + 10, item.image_height + 10); - new ImageLabel(item.image, item.image_width, item.image_height, previewLabelIcon); - IconLabel* icon = new IconLabel(item.url, previewLabelIcon); - icon->move(item.image_width - 10, item.image_height - 10); - } - else - { - previewLabelIcon->setFixedSize(18, 18); - new IconLabel(item.url, previewLabelIcon); - } - - hLayout->addWidget(previewLabelIcon); - QVBoxLayout *vLayout = new QVBoxLayout; - vLayout->setMargin(0); - vLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::MinimumExpanding)); - vLayout->addWidget(new TextLabel(item.title, text, this)); - DescriptionLabel *d = new DescriptionLabel("", this); - vLayout->addWidget(d); - vLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::MinimumExpanding)); - hLayout->addLayout(vLayout); - hLayout->addWidget(new TypeIconLabel(item.type, this)); - setLayout(hLayout); - d->setText("" + item.description + ""); -} - - -QString VisualSuggestionListItem::text() -{ - return m_text; -} - - -// --------------------------------------------------------------- - - BrowseListItem::BrowseListItem(const UrlSuggestionItem &item, const QString &text, QWidget *parent) : ListItem(item, parent) { @@ -676,12 +561,7 @@ ListItem *ListItemFactory::create(const UrlSuggestionItem &item, const QString & if (item.type & UrlSuggestionItem::Suggestion) { - if (item.description.isEmpty()) - { - return new SuggestionListItem(item, text, parent); - } - - return new VisualSuggestionListItem(item, text, parent); + return new SuggestionListItem(item, text, parent); } return new PreviewListItem(item, text, parent); diff --git a/src/urlbar/listitem.h b/src/urlbar/listitem.h index 54bff109..f34da334 100644 --- a/src/urlbar/listitem.h +++ b/src/urlbar/listitem.h @@ -97,7 +97,7 @@ class REKONQ_TESTS_EXPORT TypeIconLabel : public QLabel public: explicit TypeIconLabel(int type, QWidget *parent = 0); - + private: QLabel *getIcon(QString icon); }; @@ -126,10 +126,11 @@ class REKONQ_TESTS_EXPORT TextLabel : public QLabel public: explicit TextLabel(const QString &text, const QString &textToPointOut = QString(), QWidget *parent = 0); explicit TextLabel(QWidget *parent = 0); - + void setEngineText(const QString &engine, const QString &text); }; + // ------------------------------------------------------------------------- @@ -151,6 +152,7 @@ class REKONQ_TESTS_EXPORT EngineBar : public KToolBar public: explicit EngineBar(KService::Ptr selectedEngine, QWidget *parent = 0); + void selectNextEngine(); Q_SIGNALS: @@ -175,6 +177,7 @@ class REKONQ_TESTS_EXPORT SearchListItem : public ListItem public: explicit SearchListItem(const UrlSuggestionItem &item, const QString &text, QWidget *parent = 0); + QString text(); public Q_SLOTS: @@ -201,22 +204,7 @@ class REKONQ_TESTS_EXPORT SuggestionListItem : public ListItem public: SuggestionListItem(const UrlSuggestionItem &item, const QString &text, QWidget *parent = 0); - QString text(); - -private: - QString m_text; -}; - - -// ------------------------------------------------------------------------- - - -class REKONQ_TESTS_EXPORT VisualSuggestionListItem : public ListItem -{ - Q_OBJECT - -public: - VisualSuggestionListItem(const UrlSuggestionItem &item, const QString &text, QWidget *parent = 0); + QString text(); private: @@ -239,38 +227,6 @@ public: // ------------------------------------------------------------------------- -class REKONQ_TESTS_EXPORT PreviewLabel : public QLabel -{ - Q_OBJECT - -public: - PreviewLabel(const QString &url, int width, int height, QWidget *parent = 0); -}; - - -// ------------------------------------------------------------------------- - - -class REKONQ_TESTS_EXPORT ImageLabel : public QLabel -{ - Q_OBJECT - -public: - ImageLabel(const QString &url, int width, int height, QWidget *parent); - -private: - QString m_url; - QByteArray m_data; - -private Q_SLOTS: - void slotData(KJob* job, const QByteArray& data); - void slotResult(KJob* job); -}; - - -// ------------------------------------------------------------------------- - - class REKONQ_TESTS_EXPORT BrowseListItem : public ListItem { Q_OBJECT diff --git a/src/urlbar/urlsuggester.h b/src/urlbar/urlsuggester.h index a5914504..14df59fc 100644 --- a/src/urlbar/urlsuggester.h +++ b/src/urlbar/urlsuggester.h @@ -58,9 +58,6 @@ public: QString url; QString title; QString description; - QString image; - int image_width; - int image_height; QString bookmarkPath; UrlSuggestionItem(const UrlSuggestionItem &item) @@ -68,9 +65,6 @@ public: , url(item.url) , title(item.title) , description(item.description) - , image(item.image) - , image_width(item.image_width) - , image_height(item.image_height) {}; UrlSuggestionItem() @@ -78,26 +72,17 @@ public: , url(QString()) , title(QString()) , description(QString()) - , image(QString()) - , image_width(0) - , image_height(0) {}; UrlSuggestionItem(const int &_type, const QString &_url, const QString &_title = QString(), - const QString &_description = QString(), - const QString &_image = QString(), - const int &_image_width = 0, - const int &_image_height = 0 + const QString &_description = QString() ) : type(_type) , url(_url) , title(_title) , description(_description) - , image(_image) - , image_width(_image_width) - , image_height(_image_height) {}; inline bool operator==(const UrlSuggestionItem &i) const @@ -113,8 +98,6 @@ typedef QList UrlSuggestionList; // ---------------------------------------------------------------------- - - class UrlSuggester : public QObject { Q_OBJECT -- cgit v1.2.1