diff options
author | Andrea Diamantini <adjam7@gmail.com> | 2009-10-16 02:24:14 +0200 |
---|---|---|
committer | Andrea Diamantini <adjam7@gmail.com> | 2009-10-16 02:24:14 +0200 |
commit | b86685795a003e22f3e5a5c6e01f928acb729090 (patch) | |
tree | 35c1c32cfbdd1b5eb32bf8c3d01b2c369fdbaf71 | |
parent | some fixes on preview home page mechanism (diff) | |
download | rekonq-b86685795a003e22f3e5a5c6e01f928acb729090.tar.xz |
removed bugged closed tabs and implemented a simple tab switch
-rw-r--r-- | src/application.cpp | 2 | ||||
-rw-r--r-- | src/homepage.cpp | 49 | ||||
-rw-r--r-- | src/homepage.h | 2 | ||||
-rw-r--r-- | src/mainview.cpp | 10 | ||||
-rw-r--r-- | src/mainview.h | 4 | ||||
-rw-r--r-- | src/previewimage.cpp | 29 |
6 files changed, 49 insertions, 47 deletions
diff --git a/src/application.cpp b/src/application.cpp index 6719d456..a492f61f 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -433,7 +433,7 @@ MainWindowList Application::mainWindowList() bool Application::homePage(const KUrl &url) { - if ( url == KUrl("rekonq:closedTabs") + if ( url == KUrl("rekonq:allTabs") || url == KUrl("rekonq:history") || url == KUrl("rekonq:bookmarks") || url == KUrl("rekonq:favorites") diff --git a/src/homepage.cpp b/src/homepage.cpp index 7cad8911..78133885 100644 --- a/src/homepage.cpp +++ b/src/homepage.cpp @@ -74,9 +74,9 @@ QString HomePage::rekonqHomePage(const KUrl &url) QString menu = homePageMenu(url); QString speed; - if(url == KUrl("rekonq:closedTabs")) + if(url == KUrl("rekonq:allTabs")) { - speed = fillRecentlyClosedTabs(); + speed = fillAllTabs(); } if(url == KUrl("rekonq:history")) { @@ -163,11 +163,11 @@ QString HomePage::homePageMenu(KUrl currentUrl) menu += "Favorites</a></div>"; menu += "<div class=\"link"; - if(currentUrl == "rekonq:closedTabs") + if(currentUrl == "rekonq:allTabs") menu += " current"; - menu += "\"><a href=\"rekonq:closedTabs\">"; - menu += "<img src=\"file:///" + loader->iconPath("edit-redo", KIconLoader::Desktop) + "\" />"; - menu += "Closed Tabs</a></div>"; + menu += "\"><a href=\"rekonq:allTabs\">"; + menu += "<img src=\"file:///" + loader->iconPath("tab-duplicate", KIconLoader::Desktop) + "\" />"; + menu += "All Tabs</a></div>"; menu += "<div class=\"link"; if(currentUrl == "rekonq:bookmarks") @@ -267,26 +267,29 @@ QString HomePage::createBookItem(const KBookmark &bookmark) } -QString HomePage::fillRecentlyClosedTabs() +QString HomePage::fillAllTabs() { - KUrl::List links = Application::instance()->mainWindow()->mainView()->recentlyClosedTabs(); - QString closed; - - Q_FOREACH( const KUrl &url, links) - { - QString text = url.prettyUrl(); - if(text.length() > 20) + QString tabs; + + MainView *mv = Application::instance()->mainWindow()->mainView(); + for (int i = 0 ; i < mv->count() -1 ; i++) + { + QString urlString = mv->webView(i)->url().toEncoded(QUrl::StripTrailingSlash); + QString title = mv->webView(i)->title(); + + if(title.length() > 20) { - text.truncate(17); - text += "..."; + title.truncate(17); + title += "..."; } - closed += "<div class=\"thumbnail\">"; - closed += "<object type=\"application/image-preview\" data=\""; - closed += url.path() + "\" width=\"200\">"; - closed += "</object>"; - closed += "<br />"; - closed += "<a href=\"" + url.path() + "\">" + text + "</a></div>"; + tabs += "<div class=\"thumbnail\">"; + tabs += "<object type=\"application/image-preview\" data=\""; + tabs += urlString + "\" width=\"200\">"; + tabs += "<param name=\"index\" value=\"" + QString::number(i) + "\" />"; + tabs += "</object>"; + tabs += "<br />"; + tabs += "<a href=\"" + urlString + "\">" + title + "</a></div>"; } - return closed; + return tabs; } diff --git a/src/homepage.h b/src/homepage.h index 7d62f50a..06db0822 100644 --- a/src/homepage.h +++ b/src/homepage.h @@ -55,7 +55,7 @@ private: QString lastVisitedSites(); QString fillHistory(); QString fillBookmarks(); - QString fillRecentlyClosedTabs(); + QString fillAllTabs(); QString createBookItem(const KBookmark &bookmark); diff --git a/src/mainview.cpp b/src/mainview.cpp index a0b0c6e7..8c6ba19b 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -181,8 +181,6 @@ void MainView::clear() // What exactly do we need to clear here? m_urlBar->clearHistory(); m_urlBar->clear(); - - m_recentlyClosedTabs.clear(); } @@ -200,6 +198,7 @@ void MainView::slotReloadTab(int index) } +// this slot is called on tab switching void MainView::slotCurrentChanged(int index) { // retrieve the webview related to the index @@ -415,7 +414,6 @@ void MainView::slotCloseTab(int index) return; } hasFocus = tab->hasFocus(); - m_recentlyClosedTabs.prepend(tab->url()); } QWidget *webView = widget(index); @@ -575,12 +573,6 @@ QLabel *MainView::animatedLoading(int index, bool addMovie) } -KUrl::List MainView::recentlyClosedTabs() -{ - return m_recentlyClosedTabs; -} - - void MainView::resizeEvent(QResizeEvent *event) { updateTabBar(); diff --git a/src/mainview.h b/src/mainview.h index db4c455d..4ba65e28 100644 --- a/src/mainview.h +++ b/src/mainview.h @@ -89,8 +89,6 @@ public: */ WebView *newWebView(bool focused = true, bool nearParent = false); - KUrl::List recentlyClosedTabs(); - signals: // tab widget signals void tabsChanged(); @@ -158,8 +156,6 @@ private: QString m_loadingGitPath; int m_currentTabIndex; - - KUrl::List m_recentlyClosedTabs; }; #endif // MAINVIEW_H diff --git a/src/previewimage.cpp b/src/previewimage.cpp index fd007432..5430c80b 100644 --- a/src/previewimage.cpp +++ b/src/previewimage.cpp @@ -32,6 +32,8 @@ #include "application.h" #include "history.h" #include "rekonq.h" +#include "mainwindow.h" +#include "mainview.h" // KDE Includes #include <KUrl> @@ -168,17 +170,26 @@ void PreviewImage::mouseMoveEvent(QMouseEvent *event) void PreviewImage::mousePressEvent(QMouseEvent *event) { - switch(event->button()) + if(event->button() == Qt::LeftButton) { - case Qt::LeftButton: - Application::instance()->loadUrl(m_url); - break; - case Qt::RightButton: - // TODO - break; - default: - QLabel::mousePressEvent(event); + if(m_isFavorite) + { + Application::instance()->loadUrl(m_url); + } + else + { + MainView *mv = Application::instance()->mainWindow()->mainView(); + int actualIndex = mv->currentIndex(); + + kDebug() << "Actual index: " << actualIndex; + kDebug() << "m_index: " << m_index; + + mv->slotCloseTab(actualIndex); + mv->setCurrentIndex(m_index); + } + return; }; + QLabel::mousePressEvent(event); } |