From b86685795a003e22f3e5a5c6e01f928acb729090 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Fri, 16 Oct 2009 02:24:14 +0200 Subject: removed bugged closed tabs and implemented a simple tab switch --- src/application.cpp | 2 +- src/homepage.cpp | 49 ++++++++++++++++++++++++++----------------------- src/homepage.h | 2 +- src/mainview.cpp | 10 +--------- src/mainview.h | 4 ---- src/previewimage.cpp | 29 ++++++++++++++++++++--------- 6 files changed, 49 insertions(+), 47 deletions(-) (limited to 'src') 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"; menu += "
"; - menu += "iconPath("edit-redo", KIconLoader::Desktop) + "\" />"; - menu += "Closed Tabs
"; + menu += "\">"; + menu += "iconPath("tab-duplicate", KIconLoader::Desktop) + "\" />"; + menu += "All Tabs"; menu += "
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 += "
"; - closed += ""; - closed += ""; - closed += "
"; - closed += "" + text + "
"; + tabs += "
"; + tabs += ""; + tabs += ""; + tabs += ""; + tabs += "
"; + tabs += "" + title + "
"; } - 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 @@ -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); } -- cgit v1.2.1