diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/application.cpp | 15 | ||||
-rw-r--r-- | src/homepage.cpp | 52 | ||||
-rw-r--r-- | src/homepage.h | 2 | ||||
-rw-r--r-- | src/mainview.cpp | 15 | ||||
-rw-r--r-- | src/mainview.h | 6 | ||||
-rw-r--r-- | src/previewimage.cpp | 70 | ||||
-rw-r--r-- | src/webview.cpp | 8 |
7 files changed, 99 insertions, 69 deletions
diff --git a/src/application.cpp b/src/application.cpp index 69acf2f2..41fcd515 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -249,8 +249,8 @@ KIcon Application::icon(const KUrl &url) if(url.isEmpty() && Application::instance()->mainWindow()->currentTab()->url().scheme() == "rekonq") return KIcon("arrow-right"); - if(url == KUrl("rekonq:allTabs")) - return KIcon("tab-duplicate"); + if(url == KUrl("rekonq:closedTabs")) + return KIcon("tab-close"); if(url == KUrl("rekonq:history")) return KIcon("view-history"); if(url == KUrl("rekonq:bookmarks")) @@ -339,12 +339,18 @@ void Application::loadUrl(const KUrl& url, const Rekonq::OpenType& type) return; } + // WARNING this is just a temporary hack waiting for the new "awesome bar" (rekonq 0.4 target) + // and it may not work in all cases. + // Known issues are (add that here to test the awesome bar code): + // - web shortcuts with space separator + // - relative urls + // - ... KUrl loadingUrl(url); if (loadingUrl.isRelative()) { QString fn = loadingUrl.url(KUrl::RemoveTrailingSlash); - if(loadingUrl.path().contains('.')) + if(loadingUrl.path().contains('.') && !loadingUrl.path().contains(' ')) { loadingUrl.setUrl("//" + fn); loadingUrl.setScheme("http"); @@ -365,6 +371,7 @@ void Application::loadUrl(const KUrl& url, const Rekonq::OpenType& type) { loadingUrl = data.uri().url(); } + // ------------------- END WARNING -------------------------------------- WebView *webView = 0; MainWindow *w = 0; @@ -442,7 +449,7 @@ MainWindowList Application::mainWindowList() bool Application::homePage(const KUrl &url) { - if ( url == KUrl("rekonq:allTabs") + if ( url == KUrl("rekonq:closedTabs") || url == KUrl("rekonq:history") || url == KUrl("rekonq:bookmarks") || url == KUrl("rekonq:favorites") diff --git a/src/homepage.cpp b/src/homepage.cpp index 4735315a..fabb2a91 100644 --- a/src/homepage.cpp +++ b/src/homepage.cpp @@ -75,10 +75,10 @@ QString HomePage::rekonqHomePage(const KUrl &url) QString speed; QString title; - if(url == KUrl("rekonq:allTabs")) + if(url == KUrl("rekonq:closedTabs")) { - speed = fillAllTabs(); - title = i18n("All Tabs"); + speed = fillClosedTabs(); + title = i18n("Closed Tabs"); } if(url == KUrl("rekonq:history")) { @@ -170,11 +170,11 @@ QString HomePage::homePageMenu(KUrl currentUrl) menu += "</a></div>"; menu += "<div class=\"link"; - if(currentUrl == "rekonq:allTabs") + if(currentUrl == "rekonq:closedTabs") menu += " current"; - menu += "\"><a href=\"rekonq:allTabs\">"; - menu += "<img src=\"file:///" + loader->iconPath("tab-duplicate", KIconLoader::Desktop) + "\" />"; - menu += i18n("All Tabs"); + menu += "\"><a href=\"rekonq:closedTabs\">"; + menu += "<img src=\"file:///" + loader->iconPath("tab-close", KIconLoader::Desktop) + "\" />"; + menu += i18n("Closed Tabs"); menu += "</a></div>"; menu += "<div class=\"link"; @@ -276,29 +276,27 @@ QString HomePage::createBookItem(const KBookmark &bookmark) } -QString HomePage::fillAllTabs() +QString HomePage::fillClosedTabs() { - QString tabs; + KUrl::List links = Application::instance()->mainWindow()->mainView()->recentlyClosedTabs(); + QString closed; - MainView *mv = Application::instance()->mainWindow()->mainView(); - for (int i = 0 ; i < mv->count() -1 ; i++) + Q_FOREACH( const KUrl &url, links) { - QString urlString = mv->webView(i)->url().toEncoded(QUrl::StripTrailingSlash); - QString title = mv->webView(i)->title(); - - if(title.length() > 20) + QString text = url.prettyUrl(); + if(text.length() > 20) { - title.truncate(17); - title += "..."; + text.truncate(17); + text += "..."; } - 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 tabs; + + closed += "<div class=\"thumbnail\">"; + closed += "<object type=\"application/image-preview\" data=\""; + closed += url.prettyUrl() + "\" width=\"200\">"; + closed += "</object>"; + closed += "<br />"; + closed += "<a href=\"" + url.prettyUrl() + "\">" + text + "</a></div>"; + } + + return closed; } diff --git a/src/homepage.h b/src/homepage.h index 06db0822..7963119c 100644 --- a/src/homepage.h +++ b/src/homepage.h @@ -55,7 +55,7 @@ private: QString lastVisitedSites(); QString fillHistory(); QString fillBookmarks(); - QString fillAllTabs(); + QString fillClosedTabs(); QString createBookItem(const KBookmark &bookmark); diff --git a/src/mainview.cpp b/src/mainview.cpp index 8c6ba19b..dbd59e91 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -181,6 +181,8 @@ void MainView::clear() // What exactly do we need to clear here? m_urlBar->clearHistory(); m_urlBar->clear(); + + m_recentlyClosedTabs.clear(); } @@ -414,6 +416,13 @@ void MainView::slotCloseTab(int index) return; } hasFocus = tab->hasFocus(); + + //store close tab except homepage + if (!tab->url().prettyUrl().startsWith("rekonq:") && !tab->url().isEmpty()) + { + m_recentlyClosedTabs.removeAll(tab->url()); + m_recentlyClosedTabs.prepend(tab->url()); + } } QWidget *webView = widget(index); @@ -573,6 +582,12 @@ 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 4ba65e28..8c993a63 100644 --- a/src/mainview.h +++ b/src/mainview.h @@ -89,6 +89,8 @@ public: */ WebView *newWebView(bool focused = true, bool nearParent = false); + KUrl::List recentlyClosedTabs(); + signals: // tab widget signals void tabsChanged(); @@ -154,8 +156,10 @@ private: TabBar *m_tabBar; QString m_loadingGitPath; - + int m_currentTabIndex; + + KUrl::List m_recentlyClosedTabs; }; #endif // MAINVIEW_H diff --git a/src/previewimage.cpp b/src/previewimage.cpp index 03741770..ae23cde0 100644 --- a/src/previewimage.cpp +++ b/src/previewimage.cpp @@ -58,8 +58,9 @@ PreviewImage::PreviewImage(const QUrl &url, int index, bool isFavorite) , m_isFavorite(isFavorite) , m_index(index) , m_button(0) -{ +{ loadUrlPreview(url); + setAlignment(Qt::AlignCenter); } @@ -73,15 +74,15 @@ PreviewImage::~PreviewImage() void PreviewImage::loadUrlPreview(const QUrl& url) { m_url = url; - + if(url.isEmpty()) { showEmptyPreview(); return; } - + m_savePath = KStandardDirs::locateLocal("cache", QString("thumbs/") + guessNameFromUrl(m_url) + ".png", true); - + if(QFile::exists(m_savePath)) { m_pixmap.load(m_savePath); @@ -92,9 +93,9 @@ void PreviewImage::loadUrlPreview(const QUrl& url) loadingSnapshot = true; ws = new WebSnap( url ); connect(ws, SIGNAL(finished()), this, SLOT(snapFinished())); - + QString path = KStandardDirs::locate("appdata", "pics/busywidget.gif"); - + // load an animation waiting for site preview QMovie *movie = new QMovie(path, QByteArray(), this); movie->setSpeed(50); @@ -110,26 +111,26 @@ void PreviewImage::snapFinished() QMovie *m = movie(); delete m; setMovie(0); - + m_pixmap = ws->previewImage(); setPixmap(m_pixmap); m_pixmap.save(m_savePath); - + if(m_index > -1) { // Update title QStringList names = ReKonfig::previewNames(); // update url (for added thumbs) QStringList urls = ReKonfig::previewUrls(); - + // stripTrailingSlash to be sure to get the same string for same adress urls.replace(m_index, ws->snapUrl().toString(QUrl::StripTrailingSlash)); names.replace(m_index, ws->snapTitle()); - + ReKonfig::setPreviewNames(names); ReKonfig::setPreviewUrls(urls); - + ReKonfig::self()->writeConfig(); } } @@ -139,9 +140,9 @@ void PreviewImage::showEmptyPreview() { if(!m_isFavorite) return; - + clear(); - + QHBoxLayout *layout = new QHBoxLayout(this); m_button = new QToolButton(this); m_button->setDefaultAction(historyMenu()); @@ -172,21 +173,24 @@ void PreviewImage::mousePressEvent(QMouseEvent *event) { if(event->button() == Qt::LeftButton) { - if(m_isFavorite) - { + // if(m_isFavorite) + // { Application::instance()->loadUrl(m_url); - } + + //TODO: what is that ? : + /* } 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); @@ -198,31 +202,31 @@ void PreviewImage::mouseReleaseEvent(QMouseEvent *event) kDebug() << "NO000... don't leave your finger from the button!!"; Q_UNUSED(event) } - + void PreviewImage::contextMenuEvent(QContextMenuEvent* event) { if(!m_isFavorite) return; - + if(loadingSnapshot) return; - + KMenu menu(this); KAction *a; - + if(!m_url.isEmpty()) { a = new KAction(KIcon("edit-delete"), i18n("Remove Thumbnail"), this); connect(a, SIGNAL(triggered(bool)), this, SLOT(removeMe())); menu.addAction(a); - + a = new KAction(KIcon("view-refresh"), i18n("Refresh Thumbnail"), &menu); connect(a, SIGNAL(triggered(bool)), this, SLOT(refreshPreview())); menu.addAction(a); } menu.addAction(historyMenu()); - + menu.exec(mapToGlobal(event->pos())); } @@ -231,7 +235,7 @@ KActionMenu* PreviewImage::historyMenu() { KActionMenu *histMenu = new KActionMenu(KIcon("insert-image"), i18n("Set page to preview"), this); QList<HistoryItem> history = Application::historyManager()->history(); - + if(history.isEmpty()) { KAction *a = new KAction(i18n("History is empty"), this); @@ -239,7 +243,7 @@ KActionMenu* PreviewImage::historyMenu() histMenu->addAction(a); return histMenu; } - + int maxItems = 15; for (int i = 0; i < maxItems && i < history.size() ; ++i) { @@ -249,7 +253,7 @@ KActionMenu* PreviewImage::historyMenu() connect(a, SIGNAL(triggered(bool)), this, SLOT(setUrlFromAction())); histMenu->addAction(a); } - + return histMenu; } @@ -258,20 +262,20 @@ void PreviewImage::removeMe() { QStringList names = ReKonfig::previewNames(); QStringList urls = ReKonfig::previewUrls(); - + int index = urls.indexOf(QRegExp(m_url.toString(QUrl::StripTrailingSlash), Qt::CaseSensitive, QRegExp::FixedString)); urls.replace(index, QString("")); names.replace(index, QString("")); - + ReKonfig::setPreviewNames(names); ReKonfig::setPreviewUrls(urls); - + // sync file data ReKonfig::self()->writeConfig(); showEmptyPreview(); - + m_url = ""; } @@ -280,13 +284,13 @@ void PreviewImage::setUrlFromAction() { KAction *a = qobject_cast<KAction*>(sender()); KUrl url = KUrl(a->data().toString()); - + if(m_button) { layout()->deleteLater(); m_button->menu()->deleteLater(); m_button->deleteLater(); - } + } loadUrlPreview(url); } @@ -313,6 +317,6 @@ QString PreviewImage::guessNameFromUrl(QUrl url) name.remove('?'); name.remove('='); name.remove('+'); - + return name; } diff --git a/src/webview.cpp b/src/webview.cpp index 2250380a..1815e871 100644 --- a/src/webview.cpp +++ b/src/webview.cpp @@ -64,6 +64,7 @@ WebView::WebView(QWidget* parent) connect(page(), SIGNAL(statusBarMessage(const QString&)), this, SLOT(setStatusBarText(const QString&))); connect(this, SIGNAL(loadProgress(int)), this, SLOT(slotUpdateProgress(int))); connect(this, SIGNAL(loadFinished(bool)), this, SLOT(slotLoadFinished(bool))); + connect(this, SIGNAL(selectionChanged()), this, SLOT(selectionChanged())); } @@ -202,12 +203,12 @@ void WebView::contextMenuEvent(QContextMenuEvent *event) } } } - + if (!searchMenu->menu()->isEmpty()) { menu.addAction(searchMenu); } - + menu.addSeparator(); // TODO Add translate, show translation } @@ -401,7 +402,7 @@ void WebView::viewImage(Qt::MouseButtons buttons, Qt::KeyboardModifiers modifier { KAction *a = qobject_cast<KAction*>(sender()); KUrl url(a->data().toUrl()); - + if (modifiers & Qt::ControlModifier || buttons == Qt::MidButton) { Application::instance()->loadUrl(url, Rekonq::SettingOpenTab); @@ -439,3 +440,4 @@ void WebView::keyPressEvent(QKeyEvent *event) } QWebView::keyPressEvent(event); } + |