summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2010-03-30 11:26:07 +0200
committerAndrea Diamantini <adjam7@gmail.com>2010-03-30 11:26:07 +0200
commit80b37fa28d6c4e148ac0c69e91e07c1679866c54 (patch)
tree53f3ba9d14e2da053fd01c2dfa4dd7fc54aa5c31 /src
parentfixing crash on manual rules saving (diff)
downloadrekonq-80b37fa28d6c4e148ac0c69e91e07c1679866c54.tar.xz
Cleaning urlbar API and improving animation
WARNING: This is the best animation I could provide with the KComboBox class. In the KLineEdit derived it works perfectly. In the Combos there are some shadows on top :( Squashed commit of the following: commit 01e72a1996161028f8dbdc4e355daf00f954eace commit 8bc032d98a4987d3b01566ac520f5e8a1a095dd0 commit bc5cfd9f7d1b34f5af06dd7af6de8d3b2edb277b commit 73b4deac84d91fece407b9c700dcc61e36a34327 commit c55b753913b2619607c6aa11cabbf77ca3c84e3e commit b901fbe71b7539f65260c4fa9bbfb22f4ea997b9 commit 1de363d9614c1309ac1ac4a8eea7e70be7f2f3ed commit 76d6373f8b6c41f5c27b8404db2074f9bfc309c9 commit d741aa7109db016abc292d49fb45d15bb09e6c01
Diffstat (limited to 'src')
-rw-r--r--src/mainview.cpp28
-rw-r--r--src/mainview.h2
-rw-r--r--src/mainwindow.cpp8
-rw-r--r--src/urlbar/lineedit.cpp2
-rw-r--r--src/urlbar/urlbar.cpp109
-rw-r--r--src/urlbar/urlbar.h17
6 files changed, 64 insertions, 102 deletions
diff --git a/src/mainview.cpp b/src/mainview.cpp
index 6643becb..a00325fb 100644
--- a/src/mainview.cpp
+++ b/src/mainview.cpp
@@ -275,41 +275,31 @@ void MainView::currentChanged(int index)
m_currentTabIndex = index;
if (oldTab)
- {
- // disconnecting webview from urlbar
- disconnect(oldTab->view(), SIGNAL(loadProgress(int)), urlBar(), SLOT(updateProgress(int)));
- disconnect(oldTab->view(), SIGNAL(loadFinished(bool)), urlBar(), SLOT(loadFinished(bool)));
- disconnect(oldTab->view(), SIGNAL(urlChanged(const QUrl &)), urlBar(), SLOT(setUrl(const QUrl &)));
-
+ {
// disconnecting webpage from mainview
disconnect(oldTab->page(), SIGNAL(statusBarMessage(const QString&)),
this, SIGNAL(showStatusBarMessage(const QString&)));
disconnect(oldTab->page(), SIGNAL(linkHovered(const QString&, const QString&, const QString&)),
this, SIGNAL(linkHovered(const QString&)));
}
-
- // connecting webview with urlbar
- connect(tab->view(), SIGNAL(loadProgress(int)), urlBar(), SLOT(updateProgress(int)));
- connect(tab->view(), SIGNAL(loadFinished(bool)), urlBar(), SLOT(loadFinished(bool)));
- connect(tab->view(), SIGNAL(urlChanged(const QUrl &)), urlBar(), SLOT(setUrl(const QUrl &)));
connect(tab->page(), SIGNAL(statusBarMessage(const QString&)),
this, SIGNAL(showStatusBarMessage(const QString&)));
connect(tab->page(), SIGNAL(linkHovered(const QString&, const QString&, const QString&)),
this, SIGNAL(linkHovered(const QString&)));
- emit setCurrentTitle(tab->view()->title());
- urlBar()->setUrl(tab->view()->url());
- urlBar()->setProgress(tab->progress());
-
+ emit currentTitle(tab->view()->title());
+ urlBar()->setCurrentTab(tab);
+
// clean up "status bar"
emit showStatusBarMessage( QString() );
// notify UI to eventually switch stop/reload button
- if(urlBar()->isLoading())
- emit browserTabLoading(true);
- else
+ int progr = tab->progress();
+ if(progr == 0)
emit browserTabLoading(false);
+ else
+ emit browserTabLoading(true);
// update zoom slider
if(!Application::instance()->mainWindowList().isEmpty())
@@ -613,7 +603,7 @@ void MainView::webViewTitleChanged(const QString &title)
}
if (currentIndex() == index)
{
- emit setCurrentTitle(tabTitle);
+ emit currentTitle(tabTitle);
}
Application::historyManager()->updateHistoryEntry(view->url(), tabTitle);
}
diff --git a/src/mainview.h b/src/mainview.h
index 061ad1aa..fc10c2d9 100644
--- a/src/mainview.h
+++ b/src/mainview.h
@@ -105,7 +105,7 @@ signals:
void lastTabClosed();
// current tab signals
- void setCurrentTitle(const QString &url);
+ void currentTitle(const QString &url);
void showStatusBarMessage(const QString &message, Rekonq::Notify status = Rekonq::Info);
void linkHovered(const QString &link);
void browserTabLoading(bool);
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 6efd58ed..6701ea2e 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -215,7 +215,7 @@ void MainWindow::postLaunch()
connect(m_view, SIGNAL(linkHovered(const QString&)), this, SLOT(notifyMessage(const QString&)));
// --------- connect signals and slots
- connect(m_view, SIGNAL(setCurrentTitle(const QString &)), this, SLOT(updateWindowTitle(const QString &)));
+ connect(m_view, SIGNAL(currentTitle(const QString &)), this, SLOT(updateWindowTitle(const QString &)));
connect(m_view, SIGNAL(printRequested(QWebFrame *)), this, SLOT(printRequested(QWebFrame *)));
// (shift +) ctrl + tab switching
@@ -751,7 +751,7 @@ void MainWindow::privateBrowsing(bool enable)
if (button == KMessageBox::Continue)
{
settings->setAttribute(QWebSettings::PrivateBrowsingEnabled, true);
- m_view->urlBar()->setBackgroundColor(Qt::lightGray); // palette().color(QPalette::Active, QPalette::Background));
+ m_view->urlBar()->setPrivateMode(true);
}
else
{
@@ -761,8 +761,8 @@ void MainWindow::privateBrowsing(bool enable)
else
{
settings->setAttribute(QWebSettings::PrivateBrowsingEnabled, false);
- m_view->urlBar()->setBackgroundColor(palette().color(QPalette::Active, QPalette::Base));
-
+ m_view->urlBar()->setPrivateMode(false);
+
m_lastSearch.clear();
m_view->clear();
m_view->reloadAllTabs();
diff --git a/src/urlbar/lineedit.cpp b/src/urlbar/lineedit.cpp
index f3c93e8e..ac92b858 100644
--- a/src/urlbar/lineedit.cpp
+++ b/src/urlbar/lineedit.cpp
@@ -42,7 +42,7 @@ LineEdit::LineEdit(QWidget* parent)
setMinimumWidth(200);
setFocusPolicy(Qt::WheelFocus);
setHandleSignals(true);
- setClearButtonShown(true);
+ setClearButtonShown(false);
}
diff --git a/src/urlbar/urlbar.cpp b/src/urlbar/urlbar.cpp
index 57108d29..a04d6534 100644
--- a/src/urlbar/urlbar.cpp
+++ b/src/urlbar/urlbar.cpp
@@ -50,14 +50,13 @@
#include <QTimer>
#include <QVBoxLayout>
-QColor UrlBar::s_defaultBaseColor;
-
UrlBar::UrlBar(QWidget *parent)
: KComboBox(true, parent)
, m_lineEdit(new LineEdit)
- , m_progress(0)
, m_box(new CompletionWidget(this))
+ , _tab(0)
+ , _privateMode(false)
{
//cosmetic
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
@@ -72,11 +71,6 @@ UrlBar::UrlBar(QWidget *parent)
p.setColor(QPalette::Base, Qt::transparent);
m_lineEdit->setPalette(p);
- if (!s_defaultBaseColor.isValid())
- {
- s_defaultBaseColor = palette().color(QPalette::Base);
- }
-
setLineEdit(m_lineEdit);
// clear the URL bar
@@ -123,13 +117,6 @@ void UrlBar::setUrl(const QUrl& url)
}
-void UrlBar::setProgress(int progress)
-{
- m_progress = progress;
- update();
-}
-
-
void UrlBar::updateUrl()
{
// Don't change my typed url...
@@ -184,26 +171,21 @@ void UrlBar::activated(const QString& urlString, Rekonq::OpenType type)
}
-void UrlBar::loadFinished(bool)
-{
- // reset progress bar after small delay
- m_progress = 0;
- QTimer::singleShot(200, this, SLOT(update()));
-}
-
-
-void UrlBar::updateProgress(int progress)
-{
- m_progress = progress;
- update();
-}
-
-
void UrlBar::paintEvent(QPaintEvent *event)
{
+ QColor backgroundColor;
+ if( _privateMode )
+ {
+ backgroundColor = QColor(192, 192, 192); // gray
+ }
+ else
+ {
+ backgroundColor = Application::palette().color(QPalette::Base);
+ }
+
// set background color of UrlBar
QPalette p = palette();
- p.setColor(QPalette::Base, s_defaultBaseColor);
+ p.setColor(QPalette::Base, backgroundColor);
setPalette(p);
KComboBox::paintEvent(event);
@@ -221,11 +203,20 @@ void UrlBar::paintEvent(QPaintEvent *event)
{
loadingColor = QColor(116, 192, 250);
}
- painter.setBrush(generateGradient(loadingColor, height()));
+ int progr = _tab->progress();
+
+ backgroundColor.setAlpha(0);
+ backgroundColor.setAlpha(200);
+ QLinearGradient gradient(0, 0, width(), height() );
+ gradient.setColorAt(0, loadingColor);
+ gradient.setColorAt(((double)progr)/100, backgroundColor);
+
+ painter.setBrush( gradient );
painter.setPen(Qt::transparent);
+
QRect backgroundRect = m_lineEdit->frameGeometry();
- int mid = backgroundRect.width() * m_progress / 100;
+ int mid = backgroundRect.width() * progr / 100;
QRect progressRect(backgroundRect.x(), backgroundRect.y(), mid, backgroundRect.height());
painter.drawRect(progressRect);
painter.end();
@@ -239,41 +230,8 @@ QSize UrlBar::sizeHint() const
}
-QLinearGradient UrlBar::generateGradient(const QColor &color, int height)
-{
- QColor base = s_defaultBaseColor;
- base.setAlpha(0);
- QColor barColor = color;
- barColor.setAlpha(200);
- QLinearGradient gradient(0, 0, 0, height);
- gradient.setColorAt(0, base);
- gradient.setColorAt(0.25, barColor.lighter(120));
- gradient.setColorAt(0.5, barColor);
- gradient.setColorAt(0.75, barColor.lighter(120));
- gradient.setColorAt(1, base);
- return gradient;
-}
-
-
-void UrlBar::setBackgroundColor(QColor c)
-{
- s_defaultBaseColor = c;
- update();
-}
-
-
-bool UrlBar::isLoading()
-{
- if(m_progress == 0)
- {
- return false;
- }
- return true;
-}
-
void UrlBar::keyPressEvent(QKeyEvent *event)
{
-
// this handles the Modifiers + Return key combinations
QString currentText = m_lineEdit->text().trimmed();
if ((event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return)
@@ -338,3 +296,22 @@ void UrlBar::focusInEvent(QFocusEvent *event)
KComboBox::focusInEvent(event);
}
+
+
+void UrlBar::setCurrentTab(WebTab *tab)
+{
+ if(_tab)
+ disconnect(_tab->view(), SIGNAL(urlChanged(const QUrl &)), this, SLOT(setUrl(const QUrl &)));
+ _tab = tab;
+ connect(_tab->view(), SIGNAL(urlChanged(const QUrl &)), this, SLOT(setUrl(const QUrl &)));
+
+ // update it now (the first time)
+ setUrl( _tab->url() );
+ update();
+}
+
+
+void UrlBar::setPrivateMode(bool on)
+{
+ _privateMode = on;
+}
diff --git a/src/urlbar/urlbar.h b/src/urlbar/urlbar.h
index 552d1ee0..991b9038 100644
--- a/src/urlbar/urlbar.h
+++ b/src/urlbar/urlbar.h
@@ -34,6 +34,7 @@
// Local Includes
#include "lineedit.h"
#include "completionwidget.h"
+#include "webtab.h"
// KDE Includes
#include <KUrl>
@@ -59,18 +60,16 @@ public:
void selectAll() const;
KUrl url() const;
QSize sizeHint() const;
- void setBackgroundColor(QColor);
- bool isLoading();
- void setProgress(int progress);
+ void setCurrentTab(WebTab *);
+ void setPrivateMode(bool on);
+
public slots:
void setUrl(const QUrl &url);
- void updateProgress(int progress);
void updateUrl();
private slots:
void activated(const QString& url, Rekonq::OpenType = Rekonq::CurrentTab);
- void loadFinished(bool);
void suggestUrls(const QString &editedText);
protected:
@@ -79,17 +78,13 @@ protected:
virtual void focusInEvent(QFocusEvent *event);
private:
- static QLinearGradient generateGradient(const QColor &color, int height);
-
- static QColor s_defaultBaseColor;
-
LineEdit *m_lineEdit;
KUrl m_currentUrl;
- int m_progress;
CompletionWidget *m_box;
- KUrl m_suggestedUrl;
+ WebTab *_tab;
+ bool _privateMode;
};
#endif