diff options
author | Andrea Diamantini <adjam7@gmail.com> | 2012-07-31 10:19:50 +0200 |
---|---|---|
committer | Andrea Diamantini <adjam7@gmail.com> | 2012-12-10 02:48:04 +0100 |
commit | 915c3bbdbb8fa23041a57003129b80e5a57f7e12 (patch) | |
tree | 969d4f2d228b121cd632f21bec9ba52fd01d523b /src/tabwindow | |
parent | Fix up copyright headers (diff) | |
download | rekonq-915c3bbdbb8fa23041a57003129b80e5a57f7e12.tar.xz |
detach tab action restored :)
Diffstat (limited to 'src/tabwindow')
-rw-r--r-- | src/tabwindow/tabwindow.cpp | 60 | ||||
-rw-r--r-- | src/tabwindow/tabwindow.h | 3 |
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); |