summaryrefslogtreecommitdiff
path: root/src/tabwindow
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2012-07-28 11:11:56 +0200
committerAndrea Diamantini <adjam7@gmail.com>2012-12-10 02:48:04 +0100
commit9a111024c84f7f7cc10cbbd5fc43ee82e48ae79e (patch)
tree688b549594169bfca6b248415286adede8e4f4c5 /src/tabwindow
parentUpdate SearchEngine class to fix it with KDE 4.9 changes (diff)
downloadrekonq-9a111024c84f7f7cc10cbbd5fc43ee82e48ae79e.tar.xz
Class Application Import, first (important) part
Diffstat (limited to 'src/tabwindow')
-rw-r--r--src/tabwindow/tabwindow.cpp43
-rw-r--r--src/tabwindow/tabwindow.h31
2 files changed, 63 insertions, 11 deletions
diff --git a/src/tabwindow/tabwindow.cpp b/src/tabwindow/tabwindow.cpp
index 9e2a17ce..a849426e 100644
--- a/src/tabwindow/tabwindow.cpp
+++ b/src/tabwindow/tabwindow.cpp
@@ -85,6 +85,11 @@ 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);
+
// FIXME: Manage sizes...
kDebug() << "SIZE: " << size();
kDebug() << "SIZE HINT: " << sizeHint();
@@ -147,15 +152,35 @@ WebWindow *TabWindow::prepareNewTab(WebPage *page)
}
-void TabWindow::loadUrlInNewTab(const QUrl &url, TabHistory *history)
+void TabWindow::loadUrl(const KUrl &url, Rekonq::OpenType type, TabHistory *history)
{
- WebWindow *tab = prepareNewTab();
+ WebWindow *tab = 0;
+ switch (type)
+ {
+ case Rekonq::NewTab:
+ case Rekonq::NewBackGroundTab:
+ tab = prepareNewTab();
+ addTab(tab, i18n("new tab"));
+ break;
+
+ case Rekonq::NewFocusedTab:
+ tab = prepareNewTab();
+ addTab(tab, i18n("new tab"));
+ setCurrentWidget(tab);
+ break;
+
+ case Rekonq::NewWindow:
+ // TODO
+// emit loadUrlInNewWindow(url);
+ return;
- // Now, the dirty jobs...
- addTab(tab, i18n("new tab"));
- tab->load(url);
+ case Rekonq::CurrentTab:
+ default:
+ tab = currentWebWindow();
+ break;
+ };
- setCurrentWidget(tab);
+ tab->load(url);
if (history)
{
@@ -169,7 +194,7 @@ void TabWindow::loadUrlInNewTab(const QUrl &url, TabHistory *history)
void TabWindow::newCleanTab()
{
QUrl u = QUrl::fromUserInput("/DATI/WEBPAGES/HomePage/index.htm");
- loadUrlInNewTab(u);
+ loadUrl(u, Rekonq::NewTab);
}
@@ -338,7 +363,7 @@ void TabWindow::cloneTab(int index)
QWebHistory* history = webWindow(index)->page()->history();
TabHistory tHistory(history);
- loadUrlInNewTab(u, &tHistory);
+ loadUrl(u, Rekonq::NewTab, &tHistory);
}
@@ -440,7 +465,7 @@ void TabWindow::restoreClosedTab(int i)
QUrl u = QUrl(history.url);
- loadUrlInNewTab(u, &history);
+ loadUrl(u, Rekonq::NewTab, &history);
// just to get sure...
m_recentlyClosedTabs.removeAll(history);
diff --git a/src/tabwindow/tabwindow.h b/src/tabwindow/tabwindow.h
index f8cb759f..24f1b42e 100644
--- a/src/tabwindow/tabwindow.h
+++ b/src/tabwindow/tabwindow.h
@@ -25,8 +25,9 @@
#include <KTabWidget>
+class KUrl;
+
class QLabel;
-class QUrl;
class QToolButton;
class QWebHistory;
@@ -37,6 +38,32 @@ class WebPage;
class WebWindow;
+// --------------------------------------------------------------------------------------
+
+
+namespace Rekonq
+{
+
+/**
+* @short Open link options
+* Different modes of opening new tab
+*/
+enum OpenType
+{
+ CurrentTab, ///< open url in current tab
+ NewTab, ///< open url according to users settings
+ NewFocusedTab, ///< open url in new tab and focus it
+ NewBackGroundTab, ///< open url in new background tab
+ NewWindow ///< open url in new window
+};
+
+
+}
+
+
+// --------------------------------------------------------------------------------------
+
+
class TabWindow : public KTabWidget
{
Q_OBJECT
@@ -52,7 +79,7 @@ public:
TabBar* tabBar() const;
public Q_SLOTS:
- void loadUrlInNewTab(const QUrl &, TabHistory *history = 0);
+ void loadUrl(const KUrl &, Rekonq::OpenType type = Rekonq::CurrentTab, TabHistory *history = 0);
void newCleanTab();
private: