diff options
author | Andrea Diamantini <adjam7@gmail.com> | 2012-08-05 15:36:18 +0200 |
---|---|---|
committer | Andrea Diamantini <adjam7@gmail.com> | 2012-12-10 02:48:04 +0100 |
commit | 94c00524d2e57bb0d83314340484a6177ace4733 (patch) | |
tree | d51e75571eca034c0ee17009d831c16e41f68da7 /src | |
parent | Ensure Rekonq (tools) menu does not crash by using a Q(Weak)Pointer (diff) | |
download | rekonq-94c00524d2e57bb0d83314340484a6177ace4733.tar.xz |
Clean up WebWindow ctor
Diffstat (limited to 'src')
-rw-r--r-- | src/tabwindow/tabwindow.cpp | 6 | ||||
-rw-r--r-- | src/webwindow/webwindow.cpp | 56 | ||||
-rw-r--r-- | src/webwindow/webwindow.h | 9 |
3 files changed, 28 insertions, 43 deletions
diff --git a/src/tabwindow/tabwindow.cpp b/src/tabwindow/tabwindow.cpp index 3e479bdf..765d0774 100644 --- a/src/tabwindow/tabwindow.cpp +++ b/src/tabwindow/tabwindow.cpp @@ -147,11 +147,7 @@ WebWindow *TabWindow::webWindow(int index) const WebWindow *TabWindow::prepareNewTab(WebPage *page) { - WebWindow *tab; - if (page) - tab = new WebWindow(page, this); - else - tab = new WebWindow(this); + WebWindow *tab = new WebWindow(this, page); connect(tab, SIGNAL(titleChanged(QString)), this, SLOT(tabTitleChanged(QString))); diff --git a/src/webwindow/webwindow.cpp b/src/webwindow/webwindow.cpp index 60e7970b..aec2ebe2 100644 --- a/src/webwindow/webwindow.cpp +++ b/src/webwindow/webwindow.cpp @@ -52,9 +52,8 @@ #include <QVBoxLayout> -WebWindow::WebWindow(QWidget *parent) +WebWindow::WebWindow(QWidget *parent, WebPage *pg) : QWidget(parent) - , _progress(0) , _tab(new WebTab(this)) , _bar(new UrlBar(_tab)) , _mainToolBar(new KToolBar(this, false, false)) @@ -65,32 +64,12 @@ WebWindow::WebWindow(QWidget *parent) , m_hidePopupTimer(new QTimer(this)) , _ac(new KActionCollection(this)) { - init(); -} - - -WebWindow::WebWindow(WebPage *page, QWidget *parent) - : QWidget(parent) - , _tab(new WebTab(this)) - , _bar(new UrlBar(_tab)) - , _mainToolBar(new KToolBar(this, false, false)) - , _bookmarksBar(0) - , m_loadStopReloadAction(0) - , m_rekonqMenu(0) - , m_popup(new QLabel(this)) - , m_hidePopupTimer(new QTimer(this)) - , _ac(new KActionCollection(this)) -{ - _tab->view()->setPage(page); - page->setParent(_tab->view()); + if (pg) + { + _tab->view()->setPage(pg); + pg->setParent(_tab->view()); + } - init(); -} - -// --------------------------------------------------------------------------------------------------- - -void WebWindow::init() -{ // then, setup our actions setupActions(); @@ -143,12 +122,13 @@ void WebWindow::init() connect(_tab->page(), SIGNAL(linkHovered(QString,QString,QString)), this, SLOT(notifyMessage(QString))); } + void WebWindow::setupActions() { KAction *a; // ========================= History related actions ============================== - a = _ac->addAction(KStandardAction::Back); + a = actionCollection()->addAction(KStandardAction::Back); connect(a, SIGNAL(triggered(Qt::MouseButtons, Qt::KeyboardModifiers)), this, SLOT(openPrevious(Qt::MouseButtons, Qt::KeyboardModifiers))); @@ -157,7 +137,7 @@ void WebWindow::setupActions() connect(m_historyBackMenu, SIGNAL(aboutToShow()), this, SLOT(aboutToShowBackMenu())); connect(m_historyBackMenu, SIGNAL(triggered(QAction*)), this, SLOT(openActionUrl(QAction*))); - a = _ac->addAction(KStandardAction::Forward); + a = actionCollection()->addAction(KStandardAction::Forward); connect(a, SIGNAL(triggered(Qt::MouseButtons, Qt::KeyboardModifiers)), this, SLOT(openNext(Qt::MouseButtons, Qt::KeyboardModifiers))); @@ -169,11 +149,11 @@ void WebWindow::setupActions() // urlbar a = new KAction(i18n("Location Bar"), this); a->setDefaultWidget(_bar); - _ac->addAction(QL1S("url_bar"), a); + actionCollection()->addAction(QL1S("url_bar"), a); // load stop reload Action m_loadStopReloadAction = new KAction(this); - _ac->addAction(QL1S("load_stop_reload") , m_loadStopReloadAction); + actionCollection()->addAction(QL1S("load_stop_reload") , m_loadStopReloadAction); m_loadStopReloadAction->setShortcutConfigurable(false); m_loadStopReloadAction->setIcon(KIcon("go-jump-locationbar")); @@ -194,11 +174,23 @@ void WebWindow::setupTools() toolsAction->setMenu(m_rekonqMenu); // dummy menu to have the dropdown arrow // adding rekonq_tools to rekonq actionCollection - _ac->addAction(QL1S("rekonq_tools"), toolsAction); + actionCollection()->addAction(QL1S("rekonq_tools"), toolsAction); } // --------------------------------------------------------------------------------------------------- +KActionCollection *WebWindow::actionCollection() const +{ + return _ac; +} + + +QAction *WebWindow::actionByName(const QString &name) +{ + return actionCollection()->action(name); +} + + void WebWindow::load(const QUrl &url) { _tab->view()->load(url); diff --git a/src/webwindow/webwindow.h b/src/webwindow/webwindow.h index 695c7393..a300f6f4 100644 --- a/src/webwindow/webwindow.h +++ b/src/webwindow/webwindow.h @@ -61,8 +61,7 @@ class WebWindow : public QWidget Q_OBJECT public: - WebWindow(QWidget *parent = 0); - WebWindow(WebPage *page, QWidget *parent = 0); + WebWindow(QWidget *parent = 0, WebPage *pg = 0); void load(const QUrl &); @@ -79,10 +78,8 @@ public: bool isLoading(); - inline QAction *actionByName(const QString &name) - { - return _ac->action(name); - } + virtual KActionCollection *actionCollection () const; + QAction *actionByName(const QString &name); private: void init(); |