summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/rekonq.kcfg2
-rw-r--r--src/urlbar/favoritewidget.cpp121
-rw-r--r--src/urlbar/favoritewidget.h58
-rw-r--r--src/urlbar/urlbar.cpp102
-rw-r--r--src/urlbar/urlbar.h17
6 files changed, 282 insertions, 19 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index fd946168..09c75312 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -77,6 +77,7 @@ SET( rekonq_KDEINIT_SRCS
urlbar/sslwidget.cpp
urlbar/bookmarkwidget.cpp
urlbar/webshortcutwidget.cpp
+ urlbar/favoritewidget.cpp
#----------------------------------------
analyzer/analyzerpanel.cpp
analyzer/networkanalyzer.cpp
diff --git a/src/rekonq.kcfg b/src/rekonq.kcfg
index 13074f9d..762fe946 100644
--- a/src/rekonq.kcfg
+++ b/src/rekonq.kcfg
@@ -42,7 +42,7 @@
<default>KDE Homepage,UserBase,rekonq site</default>
</entry>
<entry name="previewUrls" type="StringList">
- <default>http://www.kde.org,http://userbase.kde.org,http://rekonq.kde.org</default>
+ <default>http://www.kde.org/,http://userbase.kde.org/,http://rekonq.kde.org/</default>
</entry>
</group>
diff --git a/src/urlbar/favoritewidget.cpp b/src/urlbar/favoritewidget.cpp
new file mode 100644
index 00000000..d58ba3f6
--- /dev/null
+++ b/src/urlbar/favoritewidget.cpp
@@ -0,0 +1,121 @@
+/* ============================================================
+*
+* This file is a part of the rekonq project
+*
+* Copyright (C) 2011 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 "favoritewidget.h"
+#include "favoritewidget.moc"
+
+// Auto Includes
+#include "rekonq.h"
+
+// Local includes
+#include "application.h"
+#include "bookmarkprovider.h"
+#include "bookmarkowner.h"
+
+// KDE Includes
+#include <KLocalizedString>
+#include <KIcon>
+#include <KLineEdit>
+
+// Qt Includes
+#include <QtGui/QDialogButtonBox>
+#include <QtGui/QFormLayout>
+#include <QtGui/QLabel>
+#include <QtGui/QPushButton>
+
+
+FavoriteWidget::FavoriteWidget(WebTab *tab, QWidget *parent)
+ : QMenu(parent)
+ , m_tab(tab)
+{
+ setAttribute(Qt::WA_DeleteOnClose);
+ setFixedWidth(350);
+
+ QVBoxLayout *layout = new QVBoxLayout(this);
+
+ // Title
+ QLabel *favoriteInfo = new QLabel(this);
+ favoriteInfo->setText(i18n("<h4>Remove this favorite?</h4>"));
+ layout->addWidget(favoriteInfo, 0, Qt::AlignCenter);
+
+ QHBoxLayout *hLay = new QHBoxLayout(this);
+
+ // Favorite icon
+ QLabel *bookmarkIcon = new QLabel(this);
+ bookmarkIcon->setPixmap(KIcon("emblem-favorite").pixmap(32, 32));
+ hLay->addWidget(bookmarkIcon);
+
+ QVBoxLayout *vLay = new QVBoxLayout(this);
+
+ // Favorite name
+ QLabel *nameLabel = new QLabel(this);
+ nameLabel->setText(i18n("Name: %1", m_tab->view()->title()));
+ vLay->addWidget(nameLabel);
+
+ // Favorite url
+ QLabel *urlLabel = new QLabel(this);
+ urlLabel->setText(i18n("URL: %1", m_tab->url().url()));
+ vLay->addWidget(urlLabel);
+
+ hLay->addLayout(vLay);
+ layout->addLayout(hLay);
+
+ // 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);
+
+ setLayout(layout);
+}
+
+
+void FavoriteWidget::showAt(const QPoint &pos)
+{
+ adjustSize();
+
+ QPoint p(pos.x() - width(), pos.y() + 10);
+ move(p);
+ show();
+}
+
+
+void FavoriteWidget::accept()
+{
+ QStringList urls = ReKonfig::previewUrls();
+ if(urls.removeOne(m_tab->url().url()))
+ {
+ ReKonfig::setPreviewUrls(urls);
+ QStringList titles = ReKonfig::previewNames();
+ titles.removeOne(m_tab->view()->title());
+ ReKonfig::setPreviewNames(titles);
+
+ emit updateIcon();
+ }
+
+ close();
+}
diff --git a/src/urlbar/favoritewidget.h b/src/urlbar/favoritewidget.h
new file mode 100644
index 00000000..c75d2a7e
--- /dev/null
+++ b/src/urlbar/favoritewidget.h
@@ -0,0 +1,58 @@
+/* ============================================================
+*
+* This file is a part of the rekonq project
+*
+* Copyright (C) 2011 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 FAVORITE_WIDGET_H
+#define FAVORITE_WIDGET_H
+
+
+// Qt Includes
+#include <QtGui/QMenu>
+#include <QtGui/QCheckBox>
+
+// Local Includes
+#include "webtab.h"
+
+
+class FavoriteWidget : public QMenu
+{
+ Q_OBJECT
+
+public:
+ explicit FavoriteWidget(WebTab *tab, QWidget *parent = 0);
+
+ void showAt(const QPoint &pos);
+
+Q_SIGNALS:
+ void updateIcon();
+
+private Q_SLOTS:
+ void accept();
+
+private:
+ WebTab *m_tab;
+};
+
+#endif // FAVORITE_WIDGET_H
diff --git a/src/urlbar/urlbar.cpp b/src/urlbar/urlbar.cpp
index 37c085e6..8dd4f092 100644
--- a/src/urlbar/urlbar.cpp
+++ b/src/urlbar/urlbar.cpp
@@ -45,11 +45,13 @@
#include "bookmarkowner.h"
#include "bookmarkwidget.h"
#include "iconmanager.h"
+#include "favoritewidget.h"
// KDE Includes
#include <KCompletionBox>
#include <KStandardDirs>
#include <KColorScheme>
+#include <KMenu>
// Qt Includes
#include <QtGui/QPainter>
@@ -114,7 +116,8 @@ UrlBar::UrlBar(QWidget *parent)
connect(_tab->view(), SIGNAL(iconChanged()), this, SLOT(refreshFavicon()));
// search icon
- connect(rApp->opensearchManager(), SIGNAL(openSearchEngineAdded(const QString &, const QString &, const QString &)), this, SLOT(updateRightIcons()));
+ connect(rApp->opensearchManager(), SIGNAL(openSearchEngineAdded(const QString &, const QString &, const QString &)),
+ this, SLOT(updateRightIcons()));
_suggestionTimer->setSingleShot(true);
connect(_suggestionTimer, SIGNAL(timeout()), this, SLOT(suggest()));
@@ -335,9 +338,19 @@ void UrlBar::loadFinished()
return;
}
+ kDebug() << ReKonfig::previewUrls();
+ kDebug() << _tab->url().url();
+
+ // show Favorite Icon
+ if(ReKonfig::previewUrls().contains(_tab->url().url()))
+ {
+ IconButton *bt = addRightIcon(UrlBar::Favorite);
+ connect(bt, SIGNAL(clicked(QPoint)), this, SLOT(showFavoriteDialog(QPoint)));
+ }
+
// show bookmark info
IconButton *bt = addRightIcon(UrlBar::BK);
- connect(bt, SIGNAL(clicked(const QPoint &)), this, SLOT(showBookmarkInfo(const QPoint &)));
+ connect(bt, SIGNAL(clicked(QPoint)), this, SLOT(showBookmarkInfo(QPoint)));
// show KGet downloads??
if(!KStandardDirs::findExe("kget").isNull() && ReKonfig::kgetList())
@@ -376,24 +389,23 @@ void UrlBar::loadFinished()
}
-void UrlBar::showBookmarkInfo(const QPoint &pos)
+void UrlBar::showBookmarkDialog()
+{
+ showBookmarkInfo(QCursor::pos());
+}
+
+
+void UrlBar::showBookmarkInfo(QPoint pos)
{
if(_tab->url().scheme() == QL1S("about"))
return;
KBookmark bookmark = rApp->bookmarkProvider()->bookmarkForUrl(_tab->url());
- IconButton *bt = qobject_cast<IconButton *>(this->sender());
- if(!bt)
- return;
-
if(bookmark.isNull())
{
bookmark = rApp->bookmarkProvider()->bookmarkOwner()->bookmarkCurrentPage();
-
- // set bk icon
- bt->setIcon(KIcon("bookmarks"));
- bt->setToolTip(i18n("Edit this bookmark"));
+ updateRightIcons();
}
else
{
@@ -443,8 +455,10 @@ void UrlBar::activateSuggestions(bool b)
}
-void UrlBar::mouseDoubleClickEvent(QMouseEvent *)
+void UrlBar::mouseDoubleClickEvent(QMouseEvent *event)
{
+ Q_UNUSED(event);
+
selectAll();
}
@@ -480,6 +494,8 @@ IconButton *UrlBar::addRightIcon(UrlBar::icon ic)
rightIcon->setIcon(KIcon("bookmarks"));
rightIcon->setToolTip(i18n("Edit this bookmark"));
}
+ rightIcon->setContextMenuPolicy(Qt::CustomContextMenu);
+ connect(rightIcon, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(bookmarkContextMenu(QPoint)));
break;
case UrlBar::SearchEngine:
{
@@ -492,6 +508,10 @@ IconButton *UrlBar::addRightIcon(UrlBar::icon ic)
rightIcon->setToolTip(i18n("Add search engine"));
break;
}
+ case UrlBar::Favorite:
+ rightIcon->setIcon(KIcon("emblem-favorite"));
+ rightIcon->setToolTip(i18n("Remove from favorite"));
+ break;
default:
kDebug() << "ERROR.. default non extant case!!";
break;
@@ -569,3 +589,61 @@ void UrlBar::refreshFavicon()
}
_icon->setIcon(rApp->iconManager()->iconForUrl(u));
}
+
+
+void UrlBar::showFavoriteDialog(QPoint pos)
+{
+ if(_tab->url().scheme() == QL1S("about"))
+ return;
+
+ IconButton *bt = qobject_cast<IconButton *>(this->sender());
+ if(!bt)
+ return;
+
+ FavoriteWidget *widget = new FavoriteWidget(_tab, window());
+ connect(widget, SIGNAL(updateIcon()), this, SLOT(updateRightIcons()));
+ widget->showAt(pos);
+}
+
+
+void UrlBar::bookmarkContextMenu(QPoint pos)
+{
+ Q_UNUSED(pos);
+
+ KMenu menu(this);
+ QAction *qa;
+
+ if(!rApp->bookmarkProvider()->bookmarkForUrl(_tab->url()).isNull())
+ {
+ qa = new KAction(KIcon("bookmarks"), i18n("Edit Bookmark"), this);
+ connect(qa, SIGNAL(triggered(bool)), this, SLOT(showBookmarkDialog()));
+ menu.addAction(qa);
+ }
+
+ if(!ReKonfig::previewUrls().contains(_tab->url().url()))
+ {
+ qa = new KAction(KIcon("emblem-favorite"), i18n("Add to favorite"), this);
+ connect(qa, SIGNAL(triggered(bool)), this, SLOT(addFavorite()));
+ menu.addAction(qa);
+ }
+
+ menu.exec(QCursor::pos());
+}
+
+
+
+void UrlBar::addFavorite()
+{
+ if(ReKonfig::previewUrls().contains(_tab->url().url()))
+ return;
+
+ QStringList urls = ReKonfig::previewUrls();
+ urls << _tab->url().url();
+ ReKonfig::setPreviewUrls(urls);
+
+ QStringList titles = ReKonfig::previewNames();
+ titles << _tab->view()->title();
+ ReKonfig::setPreviewNames(titles);
+
+ updateRightIcons();
+}
diff --git a/src/urlbar/urlbar.h b/src/urlbar/urlbar.h
index 9ed89dae..58e9b5fb 100644
--- a/src/urlbar/urlbar.h
+++ b/src/urlbar/urlbar.h
@@ -55,12 +55,11 @@ class IconButton : public QToolButton
public:
IconButton(QWidget *parent = 0);
-signals:
+Q_SIGNALS:
void clicked(QPoint);
protected:
void mouseReleaseEvent(QMouseEvent *event);
-
};
@@ -83,7 +82,8 @@ public:
RSS = 0x00000010,
SSL = 0x00000100,
BK = 0x00001000,
- SearchEngine = 0x00010000
+ SearchEngine = 0x00010000,
+ Favorite = 0x00100000
};
explicit UrlBar(QWidget *parent = 0);
@@ -91,10 +91,10 @@ public:
void activateSuggestions(bool);
-public slots:
+public Q_SLOTS:
void setQUrl(const QUrl &url);
-private slots:
+private Q_SLOTS:
void activated(const KUrl& url, Rekonq::OpenType = Rekonq::CurrentTab);
void loadFinished();
@@ -106,7 +106,12 @@ private slots:
void detectTypedString(const QString &);
void suggest();
- void showBookmarkInfo(const QPoint &pos);
+ void showBookmarkInfo(QPoint);
+ void showBookmarkDialog();
+
+ void showFavoriteDialog(QPoint);
+ void bookmarkContextMenu(QPoint);
+ void addFavorite();
void refreshFavicon();