From f56f2761ed68aee64fc334230e4fc34f1a7e2213 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sun, 13 May 2012 12:05:06 +0200 Subject: Improve downloads page - remove from list (+ API for DownloadManager to save changes) - open dir in extern app - css --- src/newtabpage.cpp | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'src/newtabpage.cpp') diff --git a/src/newtabpage.cpp b/src/newtabpage.cpp index abcd41eb..54c0e437 100644 --- a/src/newtabpage.cpp +++ b/src/newtabpage.cpp @@ -53,6 +53,7 @@ #include #include #include +#include #include // Qt Includes @@ -217,6 +218,21 @@ void NewTabPage::generate(const KUrl &url) return; } + if (url.fileName() == QL1S("opendir")) + { + QString value = url.queryItemValue( QL1S("q") ); + KUrl dirUrl = KUrl(value); + (void)new KRun(dirUrl, rApp->mainWindow(), 0, dirUrl.isLocalFile()); + return; + } + + if (url.fileName() == QL1S("removeItem")) + { + int value = url.queryItemValue( QL1S("item") ).toInt(); + rApp->downloadManager()->removeDownloadItem(value); + loadPageForUrl(KUrl("about:downloads")); + return; + } } if (url == KUrl("about:bookmarks/edit")) @@ -562,6 +578,8 @@ void NewTabPage::downloadsPage(const QString & filter) return; } + int i = 0; + Q_FOREACH(DownloadItem * item, list) { KUrl u = KUrl(item->destinationUrl()); @@ -602,7 +620,7 @@ void NewTabPage::downloadsPage(const QString & filter) { div.appendInside(markup(QL1S("a"))); div.lastChild().setAttribute(QL1S("class"), QL1S("greylink")); - div.lastChild().setAttribute(QL1S("href"), QL1S("file://") + dir); + div.lastChild().setAttribute(QL1S("href"), QL1S("about:downloads/opendir?q=") + QL1S("file://") + dir); div.lastChild().setPlainText(i18n("Open directory")); div.appendInside(QL1S(" - ")); @@ -616,6 +634,15 @@ void NewTabPage::downloadsPage(const QString & filter) { div.appendInside(QL1S("") + QL1S("Removed") + QL1S("")); } + + div.appendInside(QL1S(" - ")); + + div.appendInside(markup(QL1S("a"))); + div.lastChild().setAttribute(QL1S("class"), QL1S("greylink")); + div.lastChild().setAttribute(QL1S("href"), QL1S("about:downloads/removeItem?item=") + QString::number(i)); + div.lastChild().setPlainText(i18n("Remove from list")); + + i++; } } -- cgit v1.2.1