summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2010-05-14 19:56:26 +0200
committerAndrea Diamantini <adjam7@gmail.com>2010-05-14 19:56:26 +0200
commit0576f6b1542b80963afa20227c7fe53e53f111e8 (patch)
treefa091938cf5f60f7a12a089eac35f4987fd15c1d /src
parentShow faster url to load (diff)
downloadrekonq-0576f6b1542b80963afa20227c7fe53e53f111e8.tar.xz
This commit reintroduces the QStackedWidget class for urlbars and let
us resize them as needed for themes different from oxygen. This anyway seems working better with the upcoming Qt 4.7
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/application.cpp2
-rw-r--r--src/mainview.cpp39
-rw-r--r--src/mainview.h7
-rw-r--r--src/mainwindow.cpp2
-rw-r--r--src/urlbar/stackedurlbar.cpp74
-rw-r--r--src/urlbar/stackedurlbar.h56
-rw-r--r--src/urlbar/urlbar.cpp11
8 files changed, 155 insertions, 37 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 6926630e..b79e64fa 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -49,6 +49,7 @@ SET( rekonq_KDEINIT_SRCS
adblock/adblocknetworkreply.cpp
adblock/adblockrule.cpp
#----------------------------------------
+ urlbar/stackedurlbar.cpp
urlbar/urlbar.cpp
urlbar/completionwidget.cpp
urlbar/urlresolver.cpp
diff --git a/src/application.cpp b/src/application.cpp
index e4279da0..bfa9c03f 100644
--- a/src/application.cpp
+++ b/src/application.cpp
@@ -394,7 +394,7 @@ void Application::loadResolvedUrl(ThreadWeaver::Job *job)
void Application::newWindow()
{
loadUrl(KUrl("about:home"), Rekonq::NewWindow);
- mainWindow()->mainView()->urlBarWidget()->setFocus();
+ mainWindow()->mainView()->urlBar()->setFocus();
}
diff --git a/src/mainview.cpp b/src/mainview.cpp
index dcdaa626..4fbd5959 100644
--- a/src/mainview.cpp
+++ b/src/mainview.cpp
@@ -63,7 +63,7 @@
MainView::MainView(MainWindow *parent)
: KTabWidget(parent)
- , _bars(new QStackedWidget(this))
+ , _widgetBar(new StackedUrlBar(this))
, m_addTabButton(0)
, m_currentTabIndex(0)
, m_parentWindow(parent)
@@ -91,7 +91,7 @@ MainView::MainView(MainWindow *parent)
connect(tabBar, SIGNAL(detachTab(int)), this, SLOT(detachTab(int)));
connect(tabBar, SIGNAL(tabCloseRequested(int)), this, SLOT(closeTab(int)));
- connect(tabBar, SIGNAL(tabMoved(int, int)), this, SLOT(movedTab(int, int)));
+ connect(tabBar, SIGNAL(tabMoved(int, int)), _widgetBar, SLOT(moveBar(int, int)));
// current page index changing
connect(this, SIGNAL(currentChanged(int)), this, SLOT(currentChanged(int)));
@@ -102,7 +102,7 @@ MainView::MainView(MainWindow *parent)
MainView::~MainView()
{
- delete _bars;
+ delete _widgetBar;
delete m_addTabButton;
}
@@ -180,13 +180,13 @@ TabBar *MainView::tabBar() const
UrlBar *MainView::urlBar() const
{
- return qobject_cast<UrlBar *>(_bars->widget(m_currentTabIndex));
+ return _widgetBar->urlBar(m_currentTabIndex);
}
-QWidget *MainView::urlBarWidget() const
+StackedUrlBar *MainView::widgetBar() const
{
- return _bars;
+ return _widgetBar;
}
@@ -293,7 +293,7 @@ void MainView::currentChanged(int index)
this, SIGNAL(linkHovered(const QString&)));
emit currentTitle(tab->view()->title());
- _bars->setCurrentIndex(index);
+ _widgetBar->setCurrentIndex(index);
// clean up "status bar"
emit showStatusBarMessage(QString());
@@ -311,7 +311,7 @@ void MainView::currentChanged(int index)
// set focus to the current webview
if (tab->url().scheme() == QL1S("about"))
- _bars->currentWidget()->setFocus();
+ _widgetBar->currentWidget()->setFocus();
else
tab->view()->setFocus();
}
@@ -349,12 +349,12 @@ WebTab *MainView::newWebTab(bool focused, bool nearParent)
if (nearParent)
{
insertTab(currentIndex() + 1, tab, i18n("(Untitled)"));
- _bars->insertWidget(currentIndex() + 1, bar);
+ _widgetBar->insertWidget(currentIndex() + 1, bar);
}
else
{
addTab(tab, i18n("(Untitled)"));
- _bars->addWidget(bar);
+ _widgetBar->addWidget(bar);
}
updateTabBar();
@@ -387,7 +387,7 @@ void MainView::newTab()
default:
break;
}
- _bars->currentWidget()->setFocus();
+ urlBar()->setFocus();
}
@@ -521,8 +521,8 @@ void MainView::closeTab(int index, bool del)
removeTab(index);
updateTabBar(); // UI operation: do it ASAP!!
- QWidget *urlbar = _bars->widget(index);
- _bars->removeWidget(urlbar);
+ UrlBar *urlbar = _widgetBar->urlBar(index);
+ _widgetBar->removeWidget(urlbar);
if (del)
{
@@ -723,21 +723,12 @@ void MainView::detachTab(int index)
else
{
QString label = tab->view()->title();
- QWidget *bar = _bars->widget(index);
+ UrlBar *bar = _widgetBar->urlBar(index);
closeTab(index, false);
MainWindow *w = Application::instance()->newMainWindow(false);
w->mainView()->addTab(tab, Application::icon(u), label);
- QStackedWidget *stack = qobject_cast<QStackedWidget *>(w->mainView()->urlBarWidget());
- stack->insertWidget(0, bar);
+ _widgetBar->insertWidget(0, bar);
w->mainView()->updateTabBar();
}
}
-
-
-void MainView::movedTab(int from, int to)
-{
- QWidget *bar = _bars->widget(from);
- _bars->removeWidget(bar);
- _bars->insertWidget(to, bar);
-}
diff --git a/src/mainview.h b/src/mainview.h
index 6edccc15..6eacc104 100644
--- a/src/mainview.h
+++ b/src/mainview.h
@@ -40,13 +40,13 @@
#include "application.h"
#include "historymanager.h"
#include "mainwindow.h"
+#include "stackedurlbar.h"
// KDE Includes
#include <KTabWidget>
// Qt Includes
#include <QtGui/QToolButton>
-#include <QStackedWidget>
// Forward Declarations
class QUrl;
@@ -72,7 +72,7 @@ public:
MainView(MainWindow *parent);
~MainView();
- QWidget *urlBarWidget() const;
+ StackedUrlBar *widgetBar() const;
UrlBar *urlBar() const;
WebTab *webTab(int index) const;
@@ -151,7 +151,6 @@ private slots:
void windowCloseRequested();
void postLaunch();
- void movedTab(int, int);
protected:
virtual void resizeEvent(QResizeEvent *event);
@@ -174,7 +173,7 @@ private:
// --------------------------------------------------------------------------
- QStackedWidget *_bars;
+ StackedUrlBar *_widgetBar;
QString m_loadingGitPath;
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 128648bf..083bb810 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -194,7 +194,7 @@ void MainWindow::setupToolbars()
// location bar
KAction *urlBarAction = new KAction(this);
- urlBarAction->setDefaultWidget(m_view->urlBarWidget());
+ urlBarAction->setDefaultWidget(m_view->widgetBar());
m_mainBar->addAction(urlBarAction);
m_mainBar->addAction(actionByName( QL1S("bookmarksActionMenu") ));
diff --git a/src/urlbar/stackedurlbar.cpp b/src/urlbar/stackedurlbar.cpp
new file mode 100644
index 00000000..1882d98c
--- /dev/null
+++ b/src/urlbar/stackedurlbar.cpp
@@ -0,0 +1,74 @@
+/* ============================================================
+*
+* This file is a part of the rekonq project
+*
+* Copyright (C) 2010 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 "stackedurlbar.h"
+#include "stackedurlbar.moc"
+
+// Local Includes
+#include "application.h"
+#include "urlbar.h"
+
+
+StackedUrlBar::StackedUrlBar(QWidget *parent)
+ : QStackedWidget(parent)
+{
+ // cosmetic
+ setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
+ setMinimumWidth(200);
+ setMinimumHeight(26); // FIXME in Qt 4.7 we can probably move using MinimumWidth 20
+}
+
+
+StackedUrlBar::~StackedUrlBar()
+{
+}
+
+
+UrlBar *StackedUrlBar::currentUrlBar()
+{
+ return urlBar(currentIndex());
+}
+
+
+UrlBar *StackedUrlBar::urlBar(int index)
+{
+ UrlBar *urlBar = qobject_cast<UrlBar*>(QStackedWidget::widget(index));
+ if (!urlBar)
+ {
+ kWarning() << "URL bar with index" << index << "not found. Returning NULL. line:" << __LINE__;
+ }
+
+ return urlBar;
+}
+
+
+void StackedUrlBar::moveBar(int from, int to)
+{
+ QWidget *fromBar = widget(from);
+ removeWidget(fromBar);
+ insertWidget(to, fromBar);
+}
diff --git a/src/urlbar/stackedurlbar.h b/src/urlbar/stackedurlbar.h
new file mode 100644
index 00000000..d2c76c8a
--- /dev/null
+++ b/src/urlbar/stackedurlbar.h
@@ -0,0 +1,56 @@
+/* ============================================================
+*
+* This file is a part of the rekonq project
+*
+* Copyright (C) 2010 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 STACKED_URLBAR_H
+#define STACKED_URLBAR_H
+
+
+// Rekonq Includes
+#include "rekonq_defines.h"
+
+// Qt Includes
+#include <QStackedWidget>
+
+// Forward Declarations
+class UrlBar;
+
+
+class REKONQ_TESTS_EXPORT StackedUrlBar : public QStackedWidget
+{
+ Q_OBJECT
+
+public:
+ StackedUrlBar(QWidget *parent = 0);
+ ~StackedUrlBar();
+
+ UrlBar *currentUrlBar();
+ UrlBar *urlBar(int index);
+
+private slots:
+ void moveBar(int, int);
+};
+
+#endif // STACKED_URLBAR_H
diff --git a/src/urlbar/urlbar.cpp b/src/urlbar/urlbar.cpp
index f11cfdeb..fb98076a 100644
--- a/src/urlbar/urlbar.cpp
+++ b/src/urlbar/urlbar.cpp
@@ -61,6 +61,7 @@ IconButton::IconButton(QWidget *parent)
setCursor(Qt::ArrowCursor);
}
+
void IconButton::mouseReleaseEvent(QMouseEvent* event)
{
emit clicked(event->globalPos());
@@ -80,11 +81,6 @@ UrlBar::UrlBar(QWidget *parent)
// initial style
setStyleSheet(QString("UrlBar { padding: 0 0 0 %1px;} ").arg(_icon->sizeHint().width()));
- // cosmetic
- setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
- setMinimumWidth(200);
- setMinimumHeight(26);
-
// doesn't show the clear button
setClearButtonShown(false);
@@ -363,7 +359,8 @@ IconButton *UrlBar::addRightIcon(UrlBar::icon ic)
_rightIconsList << rightIcon;
int iconsCount = _rightIconsList.count();
- rightIcon->move(width() - 23*iconsCount, 6);
+ int iconHeight = (height() - 18) / 2;
+ rightIcon->move(width() - 23*iconsCount, iconHeight);
rightIcon->show();
return rightIcon;
@@ -379,7 +376,7 @@ void UrlBar::clearRightIcons()
void UrlBar::resizeEvent(QResizeEvent *event)
{
- int newHeight = (height() - 19) / 2;
+ int newHeight = (height() - 18) / 2;
_icon->move(4, newHeight);
int iconsCount = _rightIconsList.count();