summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPierre Rossi <pierre.rossi@nokia.com>2010-09-03 15:36:00 +0200
committerPierre Rossi <pierre.rossi@nokia.com>2010-09-03 17:28:38 +0200
commit0033619d3c4dae176e679bc3320afe03e9d4e0d1 (patch)
treef3e9da3732c643d83617216d1ea09ee745052fbe /src
parentInclude all .moc files removed in the previous commit (diff)
downloadrekonq-0033619d3c4dae176e679bc3320afe03e9d4e0d1.tar.xz
Fixes the multiple preview/walet bars in a single tab.
This also adds a colorful blink effect when an already visible bar is requested again.
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/notificationbar.cpp86
-rw-r--r--src/notificationbar.h49
-rw-r--r--src/previewselectorbar.cpp2
-rw-r--r--src/previewselectorbar.h6
-rw-r--r--src/walletbar.cpp2
-rw-r--r--src/walletbar.h5
-rw-r--r--src/webtab.cpp44
8 files changed, 164 insertions, 31 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index ef623499..5f99a608 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -16,6 +16,7 @@ SET( rekonq_KDEINIT_SRCS
mainwindow.cpp
networkaccessmanager.cpp
newtabpage.cpp
+ notificationbar.cpp
paneltreeview.cpp
previewselectorbar.cpp
protocolhandler.cpp
diff --git a/src/notificationbar.cpp b/src/notificationbar.cpp
new file mode 100644
index 00000000..4325d73b
--- /dev/null
+++ b/src/notificationbar.cpp
@@ -0,0 +1,86 @@
+/* ============================================================
+*
+* This file is a part of the rekonq project
+*
+* Copyright (C) 2010 by Pierre Rossi <pierre dot rossi 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/>.
+*
+* ============================================================ */
+#include <QApplication>
+#include <QColor>
+#include <QGraphicsEffect>
+#include <QPainter>
+#include <QPropertyAnimation>
+
+#include "notificationbar.h"
+
+
+class BlinkEffect : public QGraphicsEffect
+{
+ Q_OBJECT
+ Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity)
+
+public:
+ BlinkEffect(QObject *parent = 0)
+ : QGraphicsEffect(parent)
+ , m_opacity(0)
+ , m_backgroundColor(QApplication::palette().highlight().color().lighter())
+ {}
+
+ qreal opacity() const { return m_opacity; }
+ void setOpacity(qreal opacity)
+ {
+ m_opacity = opacity;
+ update();
+ }
+
+protected:
+ void draw(QPainter *painter)
+ {
+ painter->drawPixmap(QPoint(0,0), sourcePixmap());
+ painter->setOpacity(m_opacity);
+ painter->fillRect(boundingRect(), m_backgroundColor);
+ }
+
+private:
+ double m_opacity;
+ QColor m_backgroundColor;
+
+};
+
+
+NotificationBar::NotificationBar(QWidget *parent)
+ : QWidget(parent)
+ , m_blinkEffect(new BlinkEffect(this))
+ , m_opacityAnimation(new QPropertyAnimation(m_blinkEffect, "opacity"))
+{
+ m_blinkEffect->setOpacity(0);
+ setGraphicsEffect(m_blinkEffect);
+}
+
+void NotificationBar::notifyUser(int animationDuration)
+{
+ m_opacityAnimation->setDuration(animationDuration);
+ m_opacityAnimation->setStartValue(0.9);
+ m_opacityAnimation->setEndValue(0.0);
+ m_opacityAnimation->start();
+
+}
+
+#include "notificationbar.moc"
diff --git a/src/notificationbar.h b/src/notificationbar.h
new file mode 100644
index 00000000..15b0255c
--- /dev/null
+++ b/src/notificationbar.h
@@ -0,0 +1,49 @@
+/* ============================================================
+*
+* This file is a part of the rekonq project
+*
+* Copyright (C) 2010 by Pierre Rossi <pierre dot rossi 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 NOTIFICATIONBAR_H
+#define NOTIFICATIONBAR_H
+
+// Qt Includes
+#include <QWidget>
+
+// Forward Declarations
+class QPropertyAnimation;
+class BlinkEffect;
+
+class NotificationBar : public QWidget
+{
+public:
+ explicit NotificationBar(QWidget *parent = 0);
+
+ void notifyUser(int animationDuration = 500);
+
+private:
+ BlinkEffect *m_blinkEffect;
+ QPropertyAnimation *m_opacityAnimation;
+
+};
+
+#endif // NOTIFICATIONBAR_H
diff --git a/src/previewselectorbar.cpp b/src/previewselectorbar.cpp
index 2dcdbeff..209a0a92 100644
--- a/src/previewselectorbar.cpp
+++ b/src/previewselectorbar.cpp
@@ -51,7 +51,7 @@
PreviewSelectorBar::PreviewSelectorBar(int index, QWidget* parent)
- : QWidget(parent)
+ : NotificationBar(parent)
, m_button(0)
, m_label(0)
, m_previewIndex(index)
diff --git a/src/previewselectorbar.h b/src/previewselectorbar.h
index ff2c7e2a..214514db 100644
--- a/src/previewselectorbar.h
+++ b/src/previewselectorbar.h
@@ -30,16 +30,14 @@
// Rekonq Includes
#include "rekonq_defines.h"
-
-// Qt Includes
-#include <QtGui/QWidget>
+#include "notificationbar.h"
// Forward Declarations
class QLabel;
class QPushButton;
-class REKONQ_TESTS_EXPORT PreviewSelectorBar : public QWidget
+class REKONQ_TESTS_EXPORT PreviewSelectorBar : public NotificationBar
{
Q_OBJECT
diff --git a/src/walletbar.cpp b/src/walletbar.cpp
index f02c74b8..c2397da9 100644
--- a/src/walletbar.cpp
+++ b/src/walletbar.cpp
@@ -43,7 +43,7 @@
WalletBar::WalletBar(QWidget *parent)
- : QWidget(parent)
+ : NotificationBar(parent)
, m_label(new QLabel(this))
{
m_label->setWordWrap(true);
diff --git a/src/walletbar.h b/src/walletbar.h
index a33dc4d3..afd657f4 100644
--- a/src/walletbar.h
+++ b/src/walletbar.h
@@ -30,15 +30,14 @@
// Rekonq Includes
#include "rekonq_defines.h"
+#include "notificationbar.h"
// Qt Includes
#include <QtCore/QUrl>
-#include <QtGui/QWidget>
class QLabel;
-
-class REKONQ_TESTS_EXPORT WalletBar : public QWidget
+class REKONQ_TESTS_EXPORT WalletBar : public NotificationBar
{
Q_OBJECT
diff --git a/src/webtab.cpp b/src/webtab.cpp
index a9a43bd9..02c94d32 100644
--- a/src/webtab.cpp
+++ b/src/webtab.cpp
@@ -129,35 +129,35 @@ void WebTab::createWalletBar(const QString &key, const QUrl &url)
if (blackList.contains(urlString))
return;
- if(!_walletBar.isNull())
- {
- _walletBar.clear();
+ if(_walletBar.isNull()) {
+ _walletBar = new WalletBar(this);
+ KWebWallet *wallet = page()->wallet();
+ _walletBar.data()->onSaveFormData(key, url);
+ qobject_cast<QVBoxLayout *>(layout())->insertWidget(0, _walletBar.data() );
+
+ connect(_walletBar.data(), SIGNAL(saveFormDataAccepted(const QString &)),
+ wallet, SLOT(acceptSaveFormDataRequest(const QString &)));
+ connect(_walletBar.data(), SIGNAL(saveFormDataRejected(const QString &)),
+ wallet, SLOT(rejectSaveFormDataRequest(const QString &)));
+ } else {
+ _walletBar.data()->notifyUser();
}
- KWebWallet *wallet = page()->wallet();
- _walletBar = new WalletBar(this);
- _walletBar.data()->onSaveFormData(key, url);
- qobject_cast<QVBoxLayout *>(layout())->insertWidget(0, _walletBar.data() );
-
- connect(_walletBar.data(), SIGNAL(saveFormDataAccepted(const QString &)),
- wallet, SLOT(acceptSaveFormDataRequest(const QString &)));
- connect(_walletBar.data(), SIGNAL(saveFormDataRejected(const QString &)),
- wallet, SLOT(rejectSaveFormDataRequest(const QString &)));
}
void WebTab::createPreviewSelectorBar(int index)
{
- if(!_previewSelectorBar.isNull())
- {
- _previewSelectorBar.clear();
+ if(_previewSelectorBar.isNull()) {
+ _previewSelectorBar = new PreviewSelectorBar(index, this);
+ qobject_cast<QVBoxLayout *>(layout())->insertWidget(0, _previewSelectorBar.data());
+
+ connect(page(), SIGNAL(loadStarted()), _previewSelectorBar.data(), SLOT(loadProgress()));
+ connect(page(), SIGNAL(loadProgress(int)), _previewSelectorBar.data(), SLOT(loadProgress()));
+ connect(page(), SIGNAL(loadFinished(bool)), _previewSelectorBar.data(), SLOT(loadFinished()));
+ connect(page()->mainFrame(), SIGNAL(urlChanged(QUrl)), _previewSelectorBar.data(), SLOT(verifyUrl()));
+ } else {
+ _previewSelectorBar.data()->notifyUser();
}
- _previewSelectorBar = new PreviewSelectorBar(index, this);
- qobject_cast<QVBoxLayout *>(layout())->insertWidget(0, _previewSelectorBar.data());
-
- connect(page(), SIGNAL(loadStarted()), _previewSelectorBar.data(), SLOT(loadProgress()));
- connect(page(), SIGNAL(loadProgress(int)), _previewSelectorBar.data(), SLOT(loadProgress()));
- connect(page(), SIGNAL(loadFinished(bool)), _previewSelectorBar.data(), SLOT(loadFinished()));
- connect(page()->mainFrame(), SIGNAL(urlChanged(QUrl)), _previewSelectorBar.data(), SLOT(verifyUrl()));
}