From 22bc40e17d463ec817a9c9c1f461b4f7990c5450 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Wed, 21 Jan 2009 02:03:30 +0100 Subject: Reimplemented download system based on KGet one. Thanks Lucas ;) Rekonq now has its one! --- src/download.cpp | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 src/download.cpp (limited to 'src/download.cpp') diff --git a/src/download.cpp b/src/download.cpp new file mode 100644 index 00000000..aedd0a63 --- /dev/null +++ b/src/download.cpp @@ -0,0 +1,82 @@ +/* ============================================================ + * + * This file is a part of the rekonq project + * + * Copyright (C) 2007 Lukas Appelhans + * Copyright (C) 2008 by Andrea Diamantini + * + * + * This program is free software; you can redistribute it + * and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; + * either version 2, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * ============================================================ */ + +// local Includes +#include "download.h" +#include "download.moc" + +// KDE Includes +#include + +// Qt Includes +#include +#include + +Download::Download(const KUrl &srcUrl, const KUrl &destUrl) + : m_srcUrl(srcUrl), + m_destUrl(destUrl) +{ + kDebug(5001) << "DownloadFile: " << m_srcUrl.url() << " to dest: " << m_destUrl.url(); + m_copyJob = KIO::get(m_srcUrl); + connect(m_copyJob, SIGNAL(data(KIO::Job*,const QByteArray &)), SLOT(slotData(KIO::Job*, const QByteArray&))); + connect(m_copyJob, SIGNAL(result(KJob *)), SLOT(slotResult(KJob *))); +} + +Download::~Download() +{ +} + +void Download::slotData(KIO::Job *job, const QByteArray& data) +{ + Q_UNUSED(job); + m_data.append(data); +} + +void Download::slotResult(KJob * job) +{ + kDebug(5001); + switch (job->error()) + { + case 0://The download has finished + { + kDebug(5001) << "Downloading successfully finished" << m_destUrl.url(); + QFile torrentFile(m_destUrl.path()); + if (!torrentFile.open(QIODevice::WriteOnly | QIODevice::Text)) {} + torrentFile.write(m_data); + torrentFile.close(); + emit finishedSuccessfully(m_destUrl, m_data); + m_data = 0; + break; + } + case KIO::ERR_FILE_ALREADY_EXIST: + { + kDebug(5001) << "ERROR - File already exists"; + QFile file(m_destUrl.path()); + emit finishedSuccessfully(m_destUrl, file.readAll()); + m_data = 0; + break; + } + default: + kDebug(5001) << "We are sorry to say you, that there were errors while downloading :("; + m_data = 0; + emit finishedWithError(); + break; + } +} -- cgit v1.2.1 From e095ed8b62c56745367fe79186431fe4f175d777 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Mon, 2 Feb 2009 01:14:46 +0100 Subject: Fixed download problems rewamp proxy ui fixing settings --- src/download.cpp | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'src/download.cpp') diff --git a/src/download.cpp b/src/download.cpp index aedd0a63..d1ed296a 100644 --- a/src/download.cpp +++ b/src/download.cpp @@ -33,7 +33,7 @@ Download::Download(const KUrl &srcUrl, const KUrl &destUrl) : m_srcUrl(srcUrl), m_destUrl(destUrl) { - kDebug(5001) << "DownloadFile: " << m_srcUrl.url() << " to dest: " << m_destUrl.url(); + kWarning() << "DownloadFile: " << m_srcUrl.url() << " to dest: " << m_destUrl.url(); m_copyJob = KIO::get(m_srcUrl); connect(m_copyJob, SIGNAL(data(KIO::Job*,const QByteArray &)), SLOT(slotData(KIO::Job*, const QByteArray&))); connect(m_copyJob, SIGNAL(result(KJob *)), SLOT(slotResult(KJob *))); @@ -56,27 +56,26 @@ void Download::slotResult(KJob * job) { case 0://The download has finished { - kDebug(5001) << "Downloading successfully finished" << m_destUrl.url(); - QFile torrentFile(m_destUrl.path()); - if (!torrentFile.open(QIODevice::WriteOnly | QIODevice::Text)) {} - torrentFile.write(m_data); - torrentFile.close(); - emit finishedSuccessfully(m_destUrl, m_data); + kDebug(5001) << "Downloading successfully finished: " << m_destUrl.url(); + QFile destFile(m_destUrl.path()); + if ( destFile.open(QIODevice::WriteOnly | QIODevice::Text) ) + { + destFile.write(m_data); + destFile.close(); + } m_data = 0; break; } case KIO::ERR_FILE_ALREADY_EXIST: { kDebug(5001) << "ERROR - File already exists"; - QFile file(m_destUrl.path()); - emit finishedSuccessfully(m_destUrl, file.readAll()); + // QFile file(m_destUrl.path()); m_data = 0; break; } default: kDebug(5001) << "We are sorry to say you, that there were errors while downloading :("; m_data = 0; - emit finishedWithError(); break; } } -- cgit v1.2.1 From 3afb0217d09a012c4a65740155b232c67fef4990 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Mon, 2 Feb 2009 01:57:19 +0100 Subject: Fixed download system about downloading files with the same name. --- src/download.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/download.cpp') diff --git a/src/download.cpp b/src/download.cpp index d1ed296a..e4ee556d 100644 --- a/src/download.cpp +++ b/src/download.cpp @@ -58,6 +58,13 @@ void Download::slotResult(KJob * job) { kDebug(5001) << "Downloading successfully finished: " << m_destUrl.url(); QFile destFile(m_destUrl.path()); + int n = 1; + while( destFile.exists() ) + { + QString fn = QFile(m_destUrl.path()).fileName(); + destFile.setFileName( fn + "." + QString::number(n) ); + n++; + } if ( destFile.open(QIODevice::WriteOnly | QIODevice::Text) ) { destFile.write(m_data); @@ -69,7 +76,6 @@ void Download::slotResult(KJob * job) case KIO::ERR_FILE_ALREADY_EXIST: { kDebug(5001) << "ERROR - File already exists"; - // QFile file(m_destUrl.path()); m_data = 0; break; } -- cgit v1.2.1 From 75abb0c0190b991b0766f56e4823666f9c7326c4 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Mon, 2 Feb 2009 09:34:13 +0100 Subject: Code Optimization --- src/download.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src/download.cpp') diff --git a/src/download.cpp b/src/download.cpp index e4ee556d..627b11b2 100644 --- a/src/download.cpp +++ b/src/download.cpp @@ -51,7 +51,6 @@ void Download::slotData(KIO::Job *job, const QByteArray& data) void Download::slotResult(KJob * job) { - kDebug(5001); switch (job->error()) { case 0://The download has finished @@ -59,9 +58,9 @@ void Download::slotResult(KJob * job) kDebug(5001) << "Downloading successfully finished: " << m_destUrl.url(); QFile destFile(m_destUrl.path()); int n = 1; + QString fn = destFile.fileName(); while( destFile.exists() ) { - QString fn = QFile(m_destUrl.path()).fileName(); destFile.setFileName( fn + "." + QString::number(n) ); n++; } @@ -75,12 +74,12 @@ void Download::slotResult(KJob * job) } case KIO::ERR_FILE_ALREADY_EXIST: { - kDebug(5001) << "ERROR - File already exists"; + kWarning() << "ERROR - File already exists"; m_data = 0; break; } default: - kDebug(5001) << "We are sorry to say you, that there were errors while downloading :("; + kWarning() << "We are sorry to say you, that there were errors while downloading :("; m_data = 0; break; } -- cgit v1.2.1 From 39409ac6a2880ad815d6096231d0fcdcfd2547f6 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sun, 22 Mar 2009 10:21:09 +0100 Subject: Fixed Copyright intro --- src/download.cpp | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'src/download.cpp') diff --git a/src/download.cpp b/src/download.cpp index 627b11b2..deba9a53 100644 --- a/src/download.cpp +++ b/src/download.cpp @@ -1,22 +1,22 @@ /* ============================================================ - * - * This file is a part of the rekonq project - * - * Copyright (C) 2007 Lukas Appelhans - * Copyright (C) 2008 by Andrea Diamantini - * - * - * This program is free software; you can redistribute it - * and/or modify it under the terms of the GNU General - * Public License as published by the Free Software Foundation; - * either version 2, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the - * GNU General Public License for more details. - * - * ============================================================ */ +* +* This file is a part of the rekonq project +* +* Copyright (C) 2007 Lukas Appelhans +* Copyright (C) 2008 by Andrea Diamantini +* +* +* This program is free software; you can redistribute it +* and/or modify it under the terms of the GNU General +* Public License as published by the Free Software Foundation; +* either version 2, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* ============================================================ */ // local Includes #include "download.h" -- cgit v1.2.1 From a934072cf9695e46e793898102590322f43c0733 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sat, 28 Mar 2009 15:53:26 +0100 Subject: astyle. First round.. --- src/download.cpp | 56 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 28 insertions(+), 28 deletions(-) (limited to 'src/download.cpp') diff --git a/src/download.cpp b/src/download.cpp index deba9a53..7edc8dc6 100644 --- a/src/download.cpp +++ b/src/download.cpp @@ -30,12 +30,12 @@ #include Download::Download(const KUrl &srcUrl, const KUrl &destUrl) - : m_srcUrl(srcUrl), - m_destUrl(destUrl) + : m_srcUrl(srcUrl), + m_destUrl(destUrl) { kWarning() << "DownloadFile: " << m_srcUrl.url() << " to dest: " << m_destUrl.url(); m_copyJob = KIO::get(m_srcUrl); - connect(m_copyJob, SIGNAL(data(KIO::Job*,const QByteArray &)), SLOT(slotData(KIO::Job*, const QByteArray&))); + connect(m_copyJob, SIGNAL(data(KIO::Job*, const QByteArray &)), SLOT(slotData(KIO::Job*, const QByteArray&))); connect(m_copyJob, SIGNAL(result(KJob *)), SLOT(slotResult(KJob *))); } @@ -53,34 +53,34 @@ void Download::slotResult(KJob * job) { switch (job->error()) { - case 0://The download has finished + case 0://The download has finished + { + kDebug(5001) << "Downloading successfully finished: " << m_destUrl.url(); + QFile destFile(m_destUrl.path()); + int n = 1; + QString fn = destFile.fileName(); + while (destFile.exists()) { - kDebug(5001) << "Downloading successfully finished: " << m_destUrl.url(); - QFile destFile(m_destUrl.path()); - int n = 1; - QString fn = destFile.fileName(); - while( destFile.exists() ) - { - destFile.setFileName( fn + "." + QString::number(n) ); - n++; - } - if ( destFile.open(QIODevice::WriteOnly | QIODevice::Text) ) - { - destFile.write(m_data); - destFile.close(); - } - m_data = 0; - break; + destFile.setFileName(fn + "." + QString::number(n)); + n++; } - case KIO::ERR_FILE_ALREADY_EXIST: + if (destFile.open(QIODevice::WriteOnly | QIODevice::Text)) { - kWarning() << "ERROR - File already exists"; - m_data = 0; - break; + destFile.write(m_data); + destFile.close(); } - default: - kWarning() << "We are sorry to say you, that there were errors while downloading :("; - m_data = 0; - break; + m_data = 0; + break; + } + case KIO::ERR_FILE_ALREADY_EXIST: + { + kWarning() << "ERROR - File already exists"; + m_data = 0; + break; + } + default: + kWarning() << "We are sorry to say you, that there were errors while downloading :("; + m_data = 0; + break; } } -- cgit v1.2.1 From c77e839f7e3cc00858672c3a05a193fe81bceb05 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sat, 18 Apr 2009 01:42:29 +0200 Subject: Fixed Download Manager ctor --- src/download.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/download.cpp') diff --git a/src/download.cpp b/src/download.cpp index 7edc8dc6..9de8dd36 100644 --- a/src/download.cpp +++ b/src/download.cpp @@ -29,9 +29,11 @@ #include #include + Download::Download(const KUrl &srcUrl, const KUrl &destUrl) - : m_srcUrl(srcUrl), - m_destUrl(destUrl) + : QObject() + , m_srcUrl(srcUrl) + , m_destUrl(destUrl) { kWarning() << "DownloadFile: " << m_srcUrl.url() << " to dest: " << m_destUrl.url(); m_copyJob = KIO::get(m_srcUrl); @@ -39,16 +41,19 @@ Download::Download(const KUrl &srcUrl, const KUrl &destUrl) connect(m_copyJob, SIGNAL(result(KJob *)), SLOT(slotResult(KJob *))); } + Download::~Download() { } + void Download::slotData(KIO::Job *job, const QByteArray& data) { Q_UNUSED(job); m_data.append(data); } + void Download::slotResult(KJob * job) { switch (job->error()) -- cgit v1.2.1 From 8eac211c434358cbe536eb6f1448f1d565a5f26f Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Tue, 21 Apr 2009 11:27:17 +0200 Subject: Moving new download system to mainline. I did some changes to fit things as simple as possible. We can obviously improve things in a second moment.. --- src/download.cpp | 184 +++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 158 insertions(+), 26 deletions(-) (limited to 'src/download.cpp') diff --git a/src/download.cpp b/src/download.cpp index 9de8dd36..dba7f98f 100644 --- a/src/download.cpp +++ b/src/download.cpp @@ -18,26 +18,165 @@ * * ============================================================ */ + // local Includes #include "download.h" #include "download.moc" // KDE Includes #include +#include +#include +#include +#include +#include // Qt Includes #include #include +// Local Includes +#include "application.h" +#include "mainwindow.h" + + +DownloadManager::DownloadManager() + : QObject() +{ +} + + +DownloadManager::~DownloadManager() +{ + foreach(Download *download, m_downloads) + { + // cancel all unfinished downloads + download->cancel(); + delete download; + } +} + + +void DownloadManager::newDownload(const KUrl &srcUrl, const KUrl &destUrl) +{ + KUrl destination = destUrl; + Download::DownloadType type; + + KSharedPtr mimeType = KMimeType::findByPath(srcUrl.prettyUrl()); + + QString typeText = KMimeType::extractKnownExtension(srcUrl.fileName()); + typeText += " (" + mimeType->name() + ")"; + + int answer = KMessageBox::questionYesNoCancel( NULL, + i18n("Download '%1'?\n""Type: %2", srcUrl.prettyUrl(), typeText ), + i18n("Download '%1'...", srcUrl.fileName() ), + KStandardGuiItem::save(), + KStandardGuiItem::open(), + KStandardGuiItem::cancel(), + "showOpenSaveDownloadDialog" + ); + + switch(answer) + { + case KMessageBox::Cancel: + return; + break; + + case KMessageBox::Yes: // ----- SAVE + // if destination is empty than ask for download path (if showOpenSaveDownloadDialog setting enabled) + if (destination.isEmpty()) + { + destination = downloadDestination(srcUrl.fileName()); + } + type = Download::Save; + break; + + case KMessageBox::No: // ----- OPEN + // Download file to tmp dir + destination.setDirectory(KStandardDirs::locateLocal("tmp", "", true)); + destination.addPath(srcUrl.fileName()); + type = Download::Open; + break; + + default: + // impossible + break; + }; + + // if user canceled download than abort + if (destination.isEmpty()) + return; + + Download *download = new Download(srcUrl, destination, type); + connect(download, SIGNAL(downloadFinished(int)), this, SLOT(slotDownloadFinished(int))); + m_downloads.append(download); +} + -Download::Download(const KUrl &srcUrl, const KUrl &destUrl) +const QList &DownloadManager::downloads() const +{ + return m_downloads; +}; + + +KUrl DownloadManager::downloadDestination(const QString &filename) +{ + KUrl destination = ReKonfig::downloadDir(); + if (destination.isEmpty()) + destination = KGlobalSettings::downloadPath(); + destination.addPath(filename); + + if (!ReKonfig::downloadToDefaultDir()) + { + destination = KFileDialog::getSaveUrl(destination); + // if user canceled the download return empty url + if (destination.isEmpty()) + return KUrl(); + } + return destination; +} + + +void DownloadManager::slotDownloadFinished(int errorCode) +{ + Q_UNUSED(errorCode) + + // if sender exists and list contains it - (open and) delete it + Download *download = qobject_cast(sender()); + if (download && m_downloads.contains(download)) + { + if (download->type() == Download::Open) + { + KSharedPtr mimeType = KMimeType::findByPath(download->destUrl().prettyUrl()); + KRun::runUrl(download->destUrl(), mimeType->name(), NULL, true); + } + disconnect(download, SIGNAL(downloadFinished(int)), this, SLOT(slotDownloadFinished(int))); + int index = m_downloads.indexOf(download); + delete m_downloads.takeAt(index); + return; + } + kWarning() << "Could not find download or invalid sender. Sender:" << sender(); +} + + +//---- + +#include +#include +#include + + +Download::Download(const KUrl &srcUrl, const KUrl &destUrl, DownloadType type) : QObject() , m_srcUrl(srcUrl) , m_destUrl(destUrl) + , m_type(type) { - kWarning() << "DownloadFile: " << m_srcUrl.url() << " to dest: " << m_destUrl.url(); - m_copyJob = KIO::get(m_srcUrl); - connect(m_copyJob, SIGNAL(data(KIO::Job*, const QByteArray &)), SLOT(slotData(KIO::Job*, const QByteArray&))); + Q_ASSERT(!m_srcUrl.isEmpty()); + Q_ASSERT(!m_destUrl.isEmpty()); + kDebug() << "DownloadFile: " << m_srcUrl.url() << " to dest: " << m_destUrl.url(); + + m_copyJob = KIO::file_copy(m_srcUrl, m_destUrl); connect(m_copyJob, SIGNAL(result(KJob *)), SLOT(slotResult(KJob *))); } @@ -47,45 +186,38 @@ Download::~Download() } -void Download::slotData(KIO::Job *job, const QByteArray& data) +void Download::cancel() { - Q_UNUSED(job); - m_data.append(data); + bool result = m_copyJob->kill(KJob::EmitResult); + Q_ASSERT(result); } -void Download::slotResult(KJob * job) +void Download::slotResult(KJob *job) { switch (job->error()) { - case 0://The download has finished + case 0: //The download has finished { - kDebug(5001) << "Downloading successfully finished: " << m_destUrl.url(); - QFile destFile(m_destUrl.path()); - int n = 1; - QString fn = destFile.fileName(); - while (destFile.exists()) - { - destFile.setFileName(fn + "." + QString::number(n)); - n++; - } - if (destFile.open(QIODevice::WriteOnly | QIODevice::Text)) - { - destFile.write(m_data); - destFile.close(); - } - m_data = 0; + kDebug() << "Downloading successfully finished: " << m_destUrl.url(); break; } case KIO::ERR_FILE_ALREADY_EXIST: { kWarning() << "ERROR - File already exists"; - m_data = 0; + break; + } + case KIO::ERR_USER_CANCELED: + { + kWarning() << "ERROR - User canceled the downlaod"; break; } default: kWarning() << "We are sorry to say you, that there were errors while downloading :("; - m_data = 0; break; } + + // inform the world + emit downloadFinished(job->error()); } + -- cgit v1.2.1 From db75cbfd9bbb52858d6434e96ac914424a66fe09 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Wed, 22 Apr 2009 01:24:48 +0200 Subject: Trivial fixes --- src/download.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src/download.cpp') diff --git a/src/download.cpp b/src/download.cpp index dba7f98f..f950a37f 100644 --- a/src/download.cpp +++ b/src/download.cpp @@ -220,4 +220,3 @@ void Download::slotResult(KJob *job) // inform the world emit downloadFinished(job->error()); } - -- cgit v1.2.1 From 7557af13f9f904cb9a6240d2101fb14e1ffdca99 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Wed, 22 Apr 2009 01:33:28 +0200 Subject: Fixing Copyrights --- src/download.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/download.cpp') diff --git a/src/download.cpp b/src/download.cpp index f950a37f..9cf9812b 100644 --- a/src/download.cpp +++ b/src/download.cpp @@ -3,7 +3,8 @@ * This file is a part of the rekonq project * * Copyright (C) 2007 Lukas Appelhans -* Copyright (C) 2008 by Andrea Diamantini +* Copyright (C) 2008-2009 by Andrea Diamantini +* Copyright (C) 2009 rekonq team. Please, see AUTHORS file for details * * * This program is free software; you can redistribute it -- cgit v1.2.1 From e657ef44ef1eef1f998101ab3dcce1a251d729fc Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sun, 26 Apr 2009 01:45:38 +0200 Subject: Fixed copyright strings, per file, as decided --- src/download.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/download.cpp') diff --git a/src/download.cpp b/src/download.cpp index 9cf9812b..e02b3565 100644 --- a/src/download.cpp +++ b/src/download.cpp @@ -4,7 +4,8 @@ * * Copyright (C) 2007 Lukas Appelhans * Copyright (C) 2008-2009 by Andrea Diamantini -* Copyright (C) 2009 rekonq team. Please, see AUTHORS file for details +* Copyright (C) 2009 by Paweł Prażak +* Copyright (C) 2009 by Domrachev Alexandr * * * This program is free software; you can redistribute it -- cgit v1.2.1 From 82862fbd150afae0101757d1d6081e0e6ddf7baa Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Wed, 29 Apr 2009 11:24:11 +0200 Subject: astyle --- src/download.cpp | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'src/download.cpp') diff --git a/src/download.cpp b/src/download.cpp index e02b3565..9489b270 100644 --- a/src/download.cpp +++ b/src/download.cpp @@ -42,8 +42,8 @@ #include "mainwindow.h" -DownloadManager::DownloadManager() - : QObject() +DownloadManager::DownloadManager() + : QObject() { } @@ -68,17 +68,17 @@ void DownloadManager::newDownload(const KUrl &srcUrl, const KUrl &destUrl) QString typeText = KMimeType::extractKnownExtension(srcUrl.fileName()); typeText += " (" + mimeType->name() + ")"; - - int answer = KMessageBox::questionYesNoCancel( NULL, - i18n("Download '%1'?\n""Type: %2", srcUrl.prettyUrl(), typeText ), - i18n("Download '%1'...", srcUrl.fileName() ), - KStandardGuiItem::save(), - KStandardGuiItem::open(), - KStandardGuiItem::cancel(), - "showOpenSaveDownloadDialog" + + int answer = KMessageBox::questionYesNoCancel(NULL, + i18n("Download '%1'?\n""Type: %2", srcUrl.prettyUrl(), typeText), + i18n("Download '%1'...", srcUrl.fileName()), + KStandardGuiItem::save(), + KStandardGuiItem::open(), + KStandardGuiItem::cancel(), + "showOpenSaveDownloadDialog" ); - switch(answer) + switch (answer) { case KMessageBox::Cancel: return; @@ -108,7 +108,7 @@ void DownloadManager::newDownload(const KUrl &srcUrl, const KUrl &destUrl) // if user canceled download than abort if (destination.isEmpty()) return; - + Download *download = new Download(srcUrl, destination, type); connect(download, SIGNAL(downloadFinished(int)), this, SLOT(slotDownloadFinished(int))); m_downloads.append(download); @@ -127,7 +127,7 @@ KUrl DownloadManager::downloadDestination(const QString &filename) if (destination.isEmpty()) destination = KGlobalSettings::downloadPath(); destination.addPath(filename); - + if (!ReKonfig::downloadToDefaultDir()) { destination = KFileDialog::getSaveUrl(destination); @@ -177,7 +177,7 @@ Download::Download(const KUrl &srcUrl, const KUrl &destUrl, DownloadType type) Q_ASSERT(!m_srcUrl.isEmpty()); Q_ASSERT(!m_destUrl.isEmpty()); kDebug() << "DownloadFile: " << m_srcUrl.url() << " to dest: " << m_destUrl.url(); - + m_copyJob = KIO::file_copy(m_srcUrl, m_destUrl); connect(m_copyJob, SIGNAL(result(KJob *)), SLOT(slotResult(KJob *))); } -- cgit v1.2.1 From 06b2dc0ce6ec6dd4cb090c22e2f9f8521138146b Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Wed, 6 May 2009 03:09:23 +0200 Subject: EBN Krazy fixes. 1st round.. --- src/download.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/download.cpp') diff --git a/src/download.cpp b/src/download.cpp index 9489b270..9a5b7a3d 100644 --- a/src/download.cpp +++ b/src/download.cpp @@ -67,7 +67,7 @@ void DownloadManager::newDownload(const KUrl &srcUrl, const KUrl &destUrl) KSharedPtr mimeType = KMimeType::findByPath(srcUrl.prettyUrl()); QString typeText = KMimeType::extractKnownExtension(srcUrl.fileName()); - typeText += " (" + mimeType->name() + ")"; + typeText += " (" + mimeType->name() + ')'; int answer = KMessageBox::questionYesNoCancel(NULL, i18n("Download '%1'?\n""Type: %2", srcUrl.prettyUrl(), typeText), -- cgit v1.2.1