diff options
author | Andrea Diamantini <adjam7@gmail.com> | 2012-08-02 14:45:16 +0200 |
---|---|---|
committer | Andrea Diamantini <adjam7@gmail.com> | 2012-12-10 02:48:04 +0100 |
commit | d7bbc59e802d23abbaa59df8b4b1b4b313c3bb07 (patch) | |
tree | a24f104943ccf343e35b13a237a7d197850345e5 | |
parent | Fix urlbar widget show (diff) | |
download | rekonq-d7bbc59e802d23abbaa59df8b4b1b4b313c3bb07.tar.xz |
Removed (FOR NOW) open search feature
This needs a new implementation and a better integration in rekonq code
WARNING: Restart reverting this...
-rw-r--r-- | src/CMakeLists.txt | 5 | ||||
-rw-r--r-- | src/urlbar/urlbar.cpp | 46 | ||||
-rw-r--r-- | src/urlbar/urlbar.h | 1 | ||||
-rw-r--r-- | src/urlbar/webshortcutwidget.cpp | 163 | ||||
-rw-r--r-- | src/urlbar/webshortcutwidget.h | 76 | ||||
-rw-r--r-- | src/webtab/webtab.cpp | 7 | ||||
-rw-r--r-- | src/webtab/webtab.h | 1 |
7 files changed, 2 insertions, 297 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0a2fa6ef..e4d48dd4 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -70,11 +70,10 @@ set(rekonq_KDEINIT_SRCS urlbar/urlbar.cpp urlbar/completionwidget.cpp urlbar/listitem.cpp - urlbar/rsswidget.cpp - urlbar/sslwidget.cpp urlbar/bookmarkwidget.cpp - urlbar/webshortcutwidget.cpp urlbar/favoritewidget.cpp + urlbar/rsswidget.cpp + urlbar/sslwidget.cpp urlbar/urlsuggester.cpp #---------------------------------------- useragent/useragentinfo.cpp diff --git a/src/urlbar/urlbar.cpp b/src/urlbar/urlbar.cpp index 7224a1b7..c77edeb5 100644 --- a/src/urlbar/urlbar.cpp +++ b/src/urlbar/urlbar.cpp @@ -46,7 +46,6 @@ #include "bookmarkwidget.h" #include "favoritewidget.h" #include "rsswidget.h" -#include "webshortcutwidget.h" #include "urlsuggester.h" @@ -111,23 +110,6 @@ QString guessUrlWithCustomFirstLevel(const QString &str1, const QString &str2) } -KUrl extractOpensearchUrl(const KUrl &tabUrl, QWebElement e) -{ - QString href = e.attribute(QL1S("href")); - KUrl url = KUrl(href); - if (!href.contains(":")) - { - QString host = tabUrl.scheme() + "://" + tabUrl.host(); - if (tabUrl.port() != -1) - { - host += QL1C(':') + QString::number(tabUrl.port()); - } - url = KUrl(tabUrl, href); - } - return url; -} - - // ----------------------------------------------------------------------------------------------------------- @@ -423,13 +405,6 @@ void UrlBar::loadFinished() connect(bt, SIGNAL(clicked(QPoint)), _tab->page(), SLOT(showSSLInfo(QPoint))); } - // show add search engine - if (_tab->hasNewSearchEngine()) - { - IconButton *bt = addRightIcon(UrlBar::SearchEngine); - connect(bt, SIGNAL(clicked(QPoint)), this, SLOT(showSearchEngine(QPoint))); - } - // FIXME Reimplement if (_tab->hasAdBlockedElements()) // { // IconButton *bt = addRightIcon(UrlBar::AdBlock); @@ -829,24 +804,3 @@ void UrlBar::showRSSInfo(const QPoint &pos) RSSWidget *widget = new RSSWidget(map, window()); widget->showAt(pos); } - - -void UrlBar::showSearchEngine(const QPoint &pos) -{ - QWebElement e = _tab->page()->mainFrame()->findFirstElement( - QL1S("head >link[rel=\"search\"][ type=\"application/opensearchdescription+xml\"]")); - QString title = e.attribute(QL1S("title")); - if (!title.isEmpty()) - { - WebShortcutWidget *widget = new WebShortcutWidget(window()); - widget->setWindowFlags(Qt::Popup); - -// FIXME connect(widget, SIGNAL(webShortcutSet(KUrl, QString, QString)), -// rApp->opensearchManager(), SLOT(addOpenSearchEngine(KUrl, QString, QString))); -// connect(rApp->opensearchManager(), SIGNAL(openSearchEngineAdded(QString)), -// this, SLOT(openSearchEngineAdded())); - - KUrl u = extractOpensearchUrl(_tab->url(), e); - widget->show(u, title, pos); - } -} diff --git a/src/urlbar/urlbar.h b/src/urlbar/urlbar.h index ffa0c1bc..3f283e39 100644 --- a/src/urlbar/urlbar.h +++ b/src/urlbar/urlbar.h @@ -127,7 +127,6 @@ private Q_SLOTS: void loadDigitedUrl(); void showRSSInfo(const QPoint &); - void showSearchEngine(const QPoint &); protected: void paintEvent(QPaintEvent *event); diff --git a/src/urlbar/webshortcutwidget.cpp b/src/urlbar/webshortcutwidget.cpp deleted file mode 100644 index c6dc3b79..00000000 --- a/src/urlbar/webshortcutwidget.cpp +++ /dev/null @@ -1,163 +0,0 @@ -/* ============================================================ -* -* This file is a part of the rekonq project -* -* Copyright (C) 2009 by Fredy Yanardi <fyanardi@gmail.com> -* Copyright (C) 2010-2011 by Lionel Chauvin <megabigbug@yahoo.fr> -* Copyright (C) 2012 by Andrea Diamantini <adjam7 at gmail dot com> -* -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License as -* published by the Free Software Foundation; either version 2 of -* the License or (at your option) version 3 or any later version -* accepted by the membership of KDE e.V. (or its successor approved -* by the membership of KDE e.V.), which shall act as a proxy -* defined in Section 14 of version 3 of the license. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see <http://www.gnu.org/licenses/>. -* -* ============================================================ */ - - -// Self Includes -#include "webshortcutwidget.h" -#include "webshortcutwidget.moc" - -// KDE Includes -#include <KGlobalSettings> -#include <KIcon> -#include <KLocale> -#include <KServiceTypeTrader> - -// Qt Includes -#include <QSet> -#include <QLabel> -#include <QLineEdit> -#include <QDialogButtonBox> -#include <QFormLayout> - - -WebShortcutWidget::WebShortcutWidget(QWidget *parent) - : QMenu(parent) - , m_wsLineEdit(new QLineEdit(this)) - , m_nameLineEdit(new QLineEdit(this)) - , m_noteLabel(new QLabel(this)) -{ - setAttribute(Qt::WA_DeleteOnClose); - setFixedWidth(350); - - QFormLayout *layout = new QFormLayout(this); - QVBoxLayout *vLay = new QVBoxLayout; - - // Web Search Icon - QLabel *webSearchIcon = new QLabel(this); - webSearchIcon->setPixmap(KIcon("edit-web-search").pixmap(32, 32)); - - // Title - QLabel *titleLabel = new QLabel(this); - titleLabel->setText("<h4>" + i18n("Add Search Engine") + "</h4>"); - vLay->addWidget(titleLabel); - - // Name - vLay->addWidget(m_nameLineEdit); - - layout->addRow(webSearchIcon, vLay); - - // Shortcuts - QLabel *shortcutsLabel = new QLabel(i18n("Shortcuts:"), this); - layout->addRow(shortcutsLabel, m_wsLineEdit); - connect(m_wsLineEdit, SIGNAL(textChanged(QString)), SLOT(shortcutsChanged(QString))); - - // Note - m_noteLabel->setWordWrap(true); - layout->addRow(m_noteLabel); - m_noteLabel->hide(); - - // Ok & Cancel buttons - QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, this); - connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept())); - connect(buttonBox, SIGNAL(rejected()), this, SLOT(close())); - layout->addWidget(buttonBox); - - m_providers = KServiceTypeTrader::self()->query("SearchProvider"); - - m_wsLineEdit->setFocus(); -} - - -void WebShortcutWidget::showAt(const QPoint &pos) -{ - adjustSize(); - - QPoint p(pos.x() - width(), pos.y() + 10); - move(p); - exec(); -} - - -void WebShortcutWidget::show(const KUrl &url, const QString &openSearchName, const QPoint &pos) -{ - m_wsLineEdit->clear(); - m_nameLineEdit->setText(openSearchName); - m_url = url; - showAt(pos); -} - - -void WebShortcutWidget::accept() -{ - emit webShortcutSet(m_url, m_nameLineEdit->text(), m_wsLineEdit->text()); - - // close widget (and destroy it) - close(); -} - - -void WebShortcutWidget::shortcutsChanged(const QString& newShorthands) -{ - int savedCursorPosition = m_wsLineEdit->cursorPosition(); - QString normalizedShorthands = QString(newShorthands).replace(QL1C(' '), QL1C(',')); - m_wsLineEdit->setText(normalizedShorthands); - m_wsLineEdit->setCursorPosition(savedCursorPosition); - - QSet<QString> shorthands = normalizedShorthands.split(QL1C(',')).toSet(); - QString contenderName = ""; - QString contenderWS = ""; - - Q_FOREACH(const QString & shorthand, shorthands) - { - Q_FOREACH(KService::Ptr provider, m_providers) - { - if (provider->property("Keys").toStringList().contains(shorthand)) - { - contenderName = provider->property("Name").toString(); - contenderWS = shorthand; - break; - } - } - } - - if (!contenderName.isEmpty()) - { - m_noteLabel->setText(i18n("The shortcut \"%1\" is already assigned to \"%2\".", contenderWS, contenderName)); - m_noteLabel->setVisible(true); - resize(minimumSize().width(), minimumSizeHint().height() + 15); - } - else - { - m_noteLabel->clear(); - bool noteIsVisible = m_noteLabel->isVisible(); - m_noteLabel->setVisible(false); - if (noteIsVisible) - { - resize(minimumSize()); - } - } -} diff --git a/src/urlbar/webshortcutwidget.h b/src/urlbar/webshortcutwidget.h deleted file mode 100644 index d1291714..00000000 --- a/src/urlbar/webshortcutwidget.h +++ /dev/null @@ -1,76 +0,0 @@ -/* ============================================================ -* -* This file is a part of the rekonq project -* -* Copyright (C) 2009 by Fredy Yanardi <fyanardi@gmail.com> -* Copyright (C) 2010-2011 by Lionel Chauvin <megabigbug@yahoo.fr> -* Copyright (C) 2012 by Andrea Diamantini <adjam7 at gmail dot com> -* -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License as -* published by the Free Software Foundation; either version 2 of -* the License or (at your option) version 3 or any later version -* accepted by the membership of KDE e.V. (or its successor approved -* by the membership of KDE e.V.), which shall act as a proxy -* defined in Section 14 of version 3 of the license. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see <http://www.gnu.org/licenses/>. -* -* ============================================================ */ - - -#ifndef WEBSHORTCUTWIDGET_H -#define WEBSHORTCUTWIDGET_H - - -// Rekonq Includes -#include "rekonq_defines.h" - -// KDE Includes -#include <KUrl> -#include <KService> - -// Qt Includes -#include <QMenu> - -// Forward Declarations -class QLabel; -class QLineEdit; -class QPushButton; - - -class REKONQ_TESTS_EXPORT WebShortcutWidget : public QMenu -{ - Q_OBJECT -public: - WebShortcutWidget(QWidget *parent = 0); - - void show(const KUrl &url, const QString &openSearchName, const QPoint &pos); - -private Q_SLOTS: - void accept(); - void shortcutsChanged(const QString& newShorthands); - -Q_SIGNALS: - void webShortcutSet(const KUrl &url, const QString &openSearchName, const QString &webShortcut); - -private: - QLineEdit *m_wsLineEdit; - QLineEdit *m_nameLineEdit; - QLabel *m_noteLabel; - - KService::List m_providers; - KUrl m_url; - - void showAt(const QPoint &pos); -}; - -#endif // WEBSHORTCUTWIDGET_H - diff --git a/src/webtab/webtab.cpp b/src/webtab/webtab.cpp index 27e711fd..e53d7b48 100644 --- a/src/webtab/webtab.cpp +++ b/src/webtab/webtab.cpp @@ -179,13 +179,6 @@ bool WebTab::hasRSSInfo() } -bool WebTab::hasNewSearchEngine() -{ - QWebElement e = page()->mainFrame()->findFirstElement(QL1S("head >link[rel=\"search\"][ type=\"application/opensearchdescription+xml\"]")); - return !e.isNull(); // FIXME && !rApp->opensearchManager()->engineExists(extractOpensearchUrl(e)); -} - - void WebTab::createWalletBar(const QString &key, const QUrl &url) { // check if the url is in the wallet blacklist diff --git a/src/webtab/webtab.h b/src/webtab/webtab.h index 5984ea53..8b60f0ff 100644 --- a/src/webtab/webtab.h +++ b/src/webtab/webtab.h @@ -71,7 +71,6 @@ public: KUrl url(); bool hasRSSInfo(); - bool hasNewSearchEngine(); void createPreviewSelectorBar(int index); void hideSelectorBar(); |