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 +++++++++---------- src/download.h | 4 ---- src/networkaccessmanager.cpp | 2 +- src/rekonq.kcfg | 2 +- src/settings.cpp | 11 +++++++++-- src/settings_proxy.ui | 41 ++++++++++++++++++++++++----------------- src/webview.cpp | 10 ++++++++++ 7 files changed, 54 insertions(+), 35 deletions(-) (limited to 'src') 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; } } diff --git a/src/download.h b/src/download.h index 7986341d..65f36d3b 100644 --- a/src/download.h +++ b/src/download.h @@ -37,10 +37,6 @@ class Download : public QObject Download(const KUrl &srcUrl, const KUrl &destUrl); ~Download(); - Q_SIGNALS: - void finishedSuccessfully(KUrl dest, QByteArray data); - void finishedWithError(); - private slots: void slotResult(KJob * job); void slotData(KIO::Job *job, const QByteArray& data); diff --git a/src/networkaccessmanager.cpp b/src/networkaccessmanager.cpp index 1d601440..82947c3b 100644 --- a/src/networkaccessmanager.cpp +++ b/src/networkaccessmanager.cpp @@ -64,7 +64,7 @@ NetworkAccessManager::NetworkAccessManager(QObject *parent) void NetworkAccessManager::loadSettings() { QNetworkProxy proxy; - if ( ReKonfig::enableProxy() ) + if ( ReKonfig::isProxyEnabled() ) { if ( ReKonfig::proxyType() == 0 ) { diff --git a/src/rekonq.kcfg b/src/rekonq.kcfg index c20134be..a1b6ca4c 100644 --- a/src/rekonq.kcfg +++ b/src/rekonq.kcfg @@ -50,7 +50,7 @@ - + false diff --git a/src/settings.cpp b/src/settings.cpp index 462874f9..2181d0fd 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -131,10 +131,17 @@ void SettingsDialog::readConfig() connect(d->generalUi.downloadDirUrlRequester, SIGNAL(textChanged(QString)),this, SLOT(saveSettings())); // ======= Fonts - d->fontsUi.standardFontChooser->setFont(ReKonfig::standardFont(), false); + QFont stdFont = ReKonfig::standardFont(); + d->fontsUi.standardFontChooser->setFont(stdFont, false); connect(d->fontsUi.standardFontChooser, SIGNAL(fontSelected(QFont)),this, SLOT(saveSettings())); - d->fontsUi.fixedFontChooser->setFont(ReKonfig::fixedFont(), true); + QFont fxFont = ReKonfig::fixedFont(); + d->fontsUi.fixedFontChooser->setFont(fxFont, true); connect(d->fontsUi.fixedFontChooser, SIGNAL(fontSelected(QFont)),this, SLOT(saveSettings())); + + // ======= Proxy + bool proxyEnabled = ReKonfig::isProxyEnabled(); + d->proxyUi.groupBox->setEnabled(proxyEnabled); + connect(d->proxyUi.kcfg_isProxyEnabled, SIGNAL(clicked(bool)), d->proxyUi.groupBox, SLOT(setEnabled(bool))); } diff --git a/src/settings_proxy.ui b/src/settings_proxy.ui index a7dd6073..bcee0a7e 100644 --- a/src/settings_proxy.ui +++ b/src/settings_proxy.ui @@ -5,21 +5,28 @@ 0 0 - 472 - 221 + 440 + 223 Proxy - + - + + + enable proxy + + + + + - Enable proxy + Proxy Settings - + Type: @@ -29,7 +36,7 @@ - + @@ -43,7 +50,7 @@ - + Host: @@ -53,10 +60,10 @@ - + - + Port: @@ -66,7 +73,7 @@ - + 10000 @@ -76,7 +83,7 @@ - + Qt::Horizontal @@ -89,7 +96,7 @@ - + User Name: @@ -99,10 +106,10 @@ - + - + Password: @@ -112,10 +119,10 @@ - + - + Qt::Vertical diff --git a/src/webview.cpp b/src/webview.cpp index a4ca8211..95fcdf83 100644 --- a/src/webview.cpp +++ b/src/webview.cpp @@ -126,6 +126,11 @@ void WebPage::handleUnsupportedContent(QNetworkReply *reply) { KUrl srcUrl = reply->url(); QString path = ReKonfig::downloadDir() + QString("/") + srcUrl.fileName(); + QFile file(path); + if (file.exists()) + { + path = KFileDialog::getOpenFileName(); + } KUrl destUrl = KUrl(path); BrowserApplication::instance()->downloadUrl( srcUrl, destUrl ); return; @@ -312,6 +317,11 @@ void WebView::downloadRequested(const QNetworkRequest &request) { KUrl srcUrl = request.url(); QString path = ReKonfig::downloadDir() + QString("/") + srcUrl.fileName(); + QFile file(path); + if (file.exists()) + { + path = KFileDialog::getOpenFileName(); + } KUrl destUrl = KUrl(path); BrowserApplication::instance()->downloadUrl( srcUrl, destUrl ); } -- cgit v1.2.1