summaryrefslogtreecommitdiff
path: root/src/tabwindow
diff options
context:
space:
mode:
Diffstat (limited to 'src/tabwindow')
-rw-r--r--src/tabwindow/tabwindow.cpp60
-rw-r--r--src/tabwindow/tabwindow.h3
2 files changed, 57 insertions, 6 deletions
diff --git a/src/tabwindow/tabwindow.cpp b/src/tabwindow/tabwindow.cpp
index 83f8151f..cce684cf 100644
--- a/src/tabwindow/tabwindow.cpp
+++ b/src/tabwindow/tabwindow.cpp
@@ -53,7 +53,7 @@
#include <QWebSettings>
-TabWindow::TabWindow(QWidget *parent)
+TabWindow::TabWindow(bool withTab, QWidget *parent)
: KTabWidget(parent)
, _addTabButton(new QToolButton(this))
, _openedTabsCounter(0)
@@ -95,10 +95,13 @@ TabWindow::TabWindow(QWidget *parent)
connect(this, SIGNAL(currentChanged(int)), this, SLOT(currentChanged(int)));
// NOTE: NEVER create a tabwindow without AT LEAST one tab...
- WebWindow *tab = prepareNewTab();
- addTab(tab, i18n("new tab"));
- setCurrentWidget(tab);
-
+ if (withTab)
+ {
+ WebWindow *tab = prepareNewTab();
+ addTab(tab, i18n("new tab"));
+ setCurrentWidget(tab);
+ }
+
// FIXME: Manage sizes...
kDebug() << "SIZE: " << size();
kDebug() << "SIZE HINT: " << sizeHint();
@@ -439,6 +442,53 @@ void TabWindow::closeOtherTabs(int index)
}
+void TabWindow::detachTab(int index, TabWindow *toWindow)
+{
+ if (index < 0)
+ index = currentIndex();
+ if (index < 0 || index >= count())
+ return;
+
+ WebWindow *tab = webWindow(index);
+ KUrl u = tab->url();
+ if (u.scheme() == QL1S("about"))
+ {
+ closeTab(index);
+ loadUrl(u, Rekonq::NewWindow);
+ return;
+ }
+ // else
+
+ closeTab(index, false);
+
+ TabWindow *w = 0;
+ w = (toWindow == 0)
+ ? new TabWindow(false)
+ : toWindow;
+
+ w->addTab(tab, tab->title());
+ w->setCurrentWidget(tab);
+
+ w->show();
+
+ // disconnect signals from old tabwindow
+ // WARNING: Code copied from prepareNewTab method.
+ // Any new changes there should be applied here...
+ disconnect(tab, SIGNAL(titleChanged(QString)), this, SLOT(tabTitleChanged(QString)));
+ disconnect(tab, SIGNAL(loadStarted()), this, SLOT(tabLoadStarted()));
+ disconnect(tab, SIGNAL(loadFinished(bool)), this, SLOT(tabLoadFinished(bool)));
+ disconnect(tab, SIGNAL(pageCreated(WebPage *)), this, SLOT(pageCreated(WebPage *)));
+
+ // reconnect signals to new tabwindow
+ // WARNING: Code copied from prepareNewTab method.
+ // Any new changes there should be applied here...
+ connect(tab, SIGNAL(titleChanged(QString)), w, SLOT(tabTitleChanged(QString)));
+ connect(tab, SIGNAL(loadStarted()), w, SLOT(tabLoadStarted()));
+ connect(tab, SIGNAL(loadFinished(bool)), w, SLOT(tabLoadFinished(bool)));
+ connect(tab, SIGNAL(pageCreated(WebPage *)), w, SLOT(pageCreated(WebPage *)));
+}
+
+
void TabWindow::reloadTab(int index)
{
// When index is -1 index chooses the current tab
diff --git a/src/tabwindow/tabwindow.h b/src/tabwindow/tabwindow.h
index 1ec13e88..42755ca6 100644
--- a/src/tabwindow/tabwindow.h
+++ b/src/tabwindow/tabwindow.h
@@ -79,7 +79,7 @@ class TabWindow : public KTabWidget
Q_OBJECT
public:
- TabWindow(QWidget *parent = 0);
+ TabWindow(bool withTab = true, QWidget *parent = 0);
virtual QSize sizeHint() const;
@@ -117,6 +117,7 @@ private Q_SLOTS:
void cloneTab(int index = -1);
void closeTab(int index = -1, bool del = true);
void closeOtherTabs(int index = -1);
+ void detachTab(int index = -1, TabWindow *toWindow = 0);
void reloadTab(int index = -1);
void reloadAllTabs();
void restoreClosedTab(int i);