summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2012-12-05 18:09:44 +0100
committerAndrea Diamantini <adjam7@gmail.com>2012-12-10 02:48:06 +0100
commite81948d7b150c47e6776d87f8095de52a340b02d (patch)
treec9248bcc01f768909987610b31e097eaa6db8e22
parentDon't leak actions (diff)
downloadrekonq-e81948d7b150c47e6776d87f8095de52a340b02d.tar.xz
Fix open external link on web app
-rw-r--r--src/application.cpp33
-rw-r--r--src/application.h4
-rw-r--r--src/tabwindow/tabwindow.cpp59
-rw-r--r--src/tabwindow/tabwindow.h5
4 files changed, 83 insertions, 18 deletions
diff --git a/src/application.cpp b/src/application.cpp
index 409e2a1d..0f15c3e8 100644
--- a/src/application.cpp
+++ b/src/application.cpp
@@ -36,10 +36,14 @@
// Local Includes
#include "searchengine.h"
+
#include "tabbar.h"
#include "tabwindow.h"
+
#include "webwindow.h"
#include "webtab.h"
+#include "webpage.h"
+
#include "urlresolver.h"
// Local Manager(s) Includes
@@ -134,6 +138,7 @@ int Application::newInstance()
kDebug() << "URL: " << u;
WebTab *tab = newWebApp();
+ connect(tab->page(), SIGNAL(pageCreated(WebPage *)), this, SLOT(pageCreated(WebPage *)));
tab->view()->load(u);
if (isFirstLoad)
@@ -830,3 +835,31 @@ void Application::newPrivateBrowsingWindow()
// NOTE: what about an "about:incognito" page?
loadUrl(KUrl("about:home"), Rekonq::NewPrivateWindow);
}
+
+
+void Application::pageCreated(WebPage *pg)
+{
+ if (m_tabWindows.isEmpty())
+ {
+ // NOTE: This is "adjusted" from newTabWindow() code...
+ TabWindow *w = new TabWindow(pg);
+
+ // set object name
+ int n = m_tabWindows.count() + 1;
+ w->setObjectName(QL1S("win") + QString::number(n));
+
+ // This is used to track which window was activated most recently
+ w->installEventFilter(this);
+
+ m_tabWindows.prepend(w);
+ w->show();
+
+ return;
+ }
+
+ TabWindow *tw = tabWindow();
+ tw->newTab(pg);
+
+ tw->activateWindow();
+ tw->raise();
+}
diff --git a/src/application.h b/src/application.h
index 5e1be2e4..d5165a55 100644
--- a/src/application.h
+++ b/src/application.h
@@ -43,7 +43,7 @@ class TabWindow;
class WebWindow;
class WebTab;
-
+class WebPage;
typedef QList< QWeakPointer<TabWindow> > TabWindowList;
typedef QList<WebTab *> WebAppList;
@@ -112,6 +112,8 @@ private Q_SLOTS:
void createWebAppShortcut();
void newPrivateBrowsingWindow();
+
+ void pageCreated(WebPage *);
private:
TabWindowList m_tabWindows;
diff --git a/src/tabwindow/tabwindow.cpp b/src/tabwindow/tabwindow.cpp
index beb087c5..c42d2048 100644
--- a/src/tabwindow/tabwindow.cpp
+++ b/src/tabwindow/tabwindow.cpp
@@ -76,6 +76,36 @@ TabWindow::TabWindow(bool withTab, bool PrivateBrowsingMode, QWidget *parent)
, _isPrivateBrowsing(PrivateBrowsingMode)
, _ac(new KActionCollection(this))
{
+ init();
+
+ // NOTE: we usually create TabWindow with AT LEAST one tab, but
+ // in one important case...
+ if (withTab)
+ {
+ WebWindow *tab = prepareNewTab();
+ addTab(tab, i18n("new tab"));
+ setCurrentWidget(tab);
+ }
+}
+
+
+TabWindow::TabWindow(WebPage *pg, QWidget *parent)
+ : RekonqWindow(parent)
+ , _addTabButton(new QToolButton(this))
+ , _openedTabsCounter(0)
+ , _isPrivateBrowsing(false)
+ , _ac(new KActionCollection(this))
+{
+ init();
+
+ WebWindow *tab = prepareNewTab(pg);
+ addTab(tab, i18n("new tab"));
+ setCurrentWidget(tab);
+}
+
+
+void TabWindow::init()
+{
setContentsMargins(0, 0, 0, 0);
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
@@ -86,7 +116,7 @@ TabWindow::TabWindow(bool withTab, bool PrivateBrowsingMode, QWidget *parent)
// setting tabbar
TabBar *tabBar = new TabBar(this);
setTabBar(tabBar);
-
+
// sets document mode; this removes the frame around the tabs
setDocumentMode(true);
@@ -101,12 +131,12 @@ TabWindow::TabWindow(bool withTab, bool PrivateBrowsingMode, QWidget *parent)
connect(tabBar, SIGNAL(closeOtherTabs(int)), this, SLOT(closeOtherTabs(int)));
connect(tabBar, SIGNAL(reloadTab(int)), this, SLOT(reloadTab(int)));
connect(tabBar, SIGNAL(detachTab(int)), this, SLOT(detachTab(int)));
-
+
connect(tabBar, SIGNAL(tabLayoutChanged()), this, SLOT(updateNewTabButtonPosition()));
// ============================== Tab Window Actions ====================================
_ac->addAssociatedWidget(this);
-
+
KAction* a;
a = new KAction(KIcon("tab-new"), i18n("New &Tab"), this);
@@ -128,7 +158,7 @@ TabWindow::TabWindow(bool withTab, bool PrivateBrowsingMode, QWidget *parent)
KShortcut fullScreenShortcut = KStandardShortcut::fullScreen();
fullScreenShortcut.setAlternate(Qt::Key_F11);
a->setShortcut(fullScreenShortcut);
-
+
a = new KAction(KIcon("bookmarks"), i18n("Bookmark all tabs"), this);
actionCollection()->addAction(QL1S("bookmark_all_tabs"), a);
connect(a, SIGNAL(triggered(bool)), this, SLOT(bookmarkAllTabs()));
@@ -140,18 +170,11 @@ TabWindow::TabWindow(bool withTab, bool PrivateBrowsingMode, QWidget *parent)
_addTabButton->raise();
_addTabButton->setToolButtonStyle(Qt::ToolButtonIconOnly);
- connect(this, SIGNAL(currentChanged(int)), this, SLOT(currentChanged(int)));
+ connect(this, SIGNAL(currentChanged(int)), this, SLOT(currentChanged(int)));
+}
- // NOTE: we usually create TabWindow with AT LEAST one tab, but
- // in one important case...
- if (withTab)
- {
- WebWindow *tab = prepareNewTab();
- addTab(tab, i18n("new tab"));
- setCurrentWidget(tab);
- }
-}
+// ----------------------------------------------------------------------------------------------------
KActionCollection *TabWindow::actionCollection() const
@@ -251,12 +274,16 @@ void TabWindow::loadUrl(const KUrl &url, Rekonq::OpenType type, TabHistory *hist
}
-void TabWindow::newTab()
+void TabWindow::newTab(WebPage *page)
{
- WebWindow *tab = prepareNewTab();
+ WebWindow *tab = prepareNewTab(page);
addTab(tab, i18n("new tab"));
setCurrentWidget(tab);
+ // no need to load an url if we already have a page...
+ if (page)
+ return;
+
switch (ReKonfig::newTabsBehaviour())
{
case 0: // new tab page
diff --git a/src/tabwindow/tabwindow.h b/src/tabwindow/tabwindow.h
index dd938af3..fc2cc4de 100644
--- a/src/tabwindow/tabwindow.h
+++ b/src/tabwindow/tabwindow.h
@@ -61,6 +61,7 @@ class TabWindow : public RekonqWindow
public:
TabWindow(bool withTab = true, bool PrivateBrowsingMode = false, QWidget *parent = 0);
+ TabWindow(WebPage *pg, QWidget *parent = 0);
WebWindow* currentWebWindow() const;
WebWindow* webWindow(int index) const;
@@ -74,7 +75,7 @@ public:
public Q_SLOTS:
void loadUrl(const KUrl &, Rekonq::OpenType type = Rekonq::CurrentTab, TabHistory *history = 0);
- void newTab();
+ void newTab(WebPage *page = 0);
private:
/**
@@ -82,6 +83,8 @@ private:
*/
WebWindow *prepareNewTab(WebPage *page = 0);
+ void init();
+
private Q_SLOTS:
/**
* Updates new tab button position