1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-21 03:06:34 +01:00

Possibility to close download manager window on finished download

Alos little performance improvent when click2flash is enabled.
Pages will now be adjusted only once per load to correctly show
click2flash, not with every object loaded.
This commit is contained in:
nowrep 2011-10-30 16:32:36 +01:00
parent 975e023d54
commit 4e8cb1bdf5
7 changed files with 48 additions and 18 deletions

View File

@ -28,10 +28,10 @@
#include "webpage.h" #include "webpage.h"
#include "downloadfilehelper.h" #include "downloadfilehelper.h"
DownloadManager::DownloadManager(QWidget* parent) : DownloadManager::DownloadManager(QWidget* parent)
QWidget(parent) : QWidget(parent)
,ui(new Ui::DownloadManager) , ui(new Ui::DownloadManager)
,m_isClosing(false) , m_isClosing(false)
{ {
setWindowFlags(windowFlags() ^ Qt::WindowMaximizeButtonHint); setWindowFlags(windowFlags() ^ Qt::WindowMaximizeButtonHint);
ui->setupUi(this); ui->setupUi(this);
@ -60,6 +60,7 @@ void DownloadManager::loadSettings()
settings.beginGroup("DownloadManager"); settings.beginGroup("DownloadManager");
m_downloadPath = settings.value("defaultDownloadPath", "").toString(); m_downloadPath = settings.value("defaultDownloadPath", "").toString();
m_lastDownloadPath = settings.value("lastDownloadPath", QDir::homePath() + "/").toString(); m_lastDownloadPath = settings.value("lastDownloadPath", QDir::homePath() + "/").toString();
m_closeOnFinish = settings.value("CloseManagerOnFinish", false).toBool();
m_useNativeDialog = settings.value("useNativeDialog", m_useNativeDialog = settings.value("useNativeDialog",
#ifdef Q_WS_WIN #ifdef Q_WS_WIN
false false
@ -200,8 +201,10 @@ void DownloadManager::downloadFinished(bool success)
if (downloadingAllFilesFinished) { if (downloadingAllFilesFinished) {
if (success && qApp->activeWindow() != this) { if (success && qApp->activeWindow() != this) {
mApp->desktopNotifications()->notify(QPixmap(":icons/notifications/download.png"), tr("Download Finished"), tr("All files have been successfuly downloaded.")); mApp->desktopNotifications()->notify(QPixmap(":icons/notifications/download.png"), tr("Download Finished"), tr("All files have been successfuly downloaded."));
raise(); if (!m_closeOnFinish) {
activateWindow(); raise();
activateWindow();
}
} }
ui->speedLabel->clear(); ui->speedLabel->clear();
setWindowTitle(tr("Download Manager")); setWindowTitle(tr("Download Manager"));
@ -211,6 +214,8 @@ void DownloadManager::downloadFinished(bool success)
win7.setProgressState(win7.NoProgress); win7.setProgressState(win7.NoProgress);
} }
#endif #endif
if (m_closeOnFinish)
close();
} }
} }

View File

@ -91,6 +91,7 @@ private:
QString m_downloadPath; QString m_downloadPath;
bool m_useNativeDialog; bool m_useNativeDialog;
bool m_isClosing; bool m_isClosing;
bool m_closeOnFinish;
}; };
#endif // DOWNLOADMANAGER_H #endif // DOWNLOADMANAGER_H

View File

@ -101,9 +101,13 @@ void ClickToFlash::ensurePluginVisible()
// I don't know any other method how to show our plugin // I don't know any other method how to show our plugin
// and adjust it on the proper position in page // and adjust it on the proper position in page
m_page->mainFrame()->setZoomFactor(m_page->mainFrame()->zoomFactor() + 1); // Scheduling adjustingPage rather than actually changing zoomFactor
m_page->mainFrame()->setZoomFactor(m_page->mainFrame()->zoomFactor() - 1); // right now, as it is CPU intensive when there is lot of click2flash
// objects on page
m_page->scheduleAdjustPage();
} }
void ClickToFlash::customContextMenuRequested(const QPoint &pos) void ClickToFlash::customContextMenuRequested(const QPoint &pos)
{ {
QMenu menu; QMenu menu;

View File

@ -213,6 +213,7 @@ Preferences::Preferences(QupZilla* mainClass, QWidget* parent) :
//DOWNLOADS //DOWNLOADS
settings.beginGroup("DownloadManager"); settings.beginGroup("DownloadManager");
ui->downLoc->setText( settings.value("defaultDownloadPath","").toString() ); ui->downLoc->setText( settings.value("defaultDownloadPath","").toString() );
ui->closeDownManOnFinish->setChecked( settings.value("CloseManagerOnFinish", false).toBool() );
ui->downlaodNativeSystemDialog->setChecked( settings.value("useNativeDialog", ui->downlaodNativeSystemDialog->setChecked( settings.value("useNativeDialog",
#ifdef Q_WS_WIN #ifdef Q_WS_WIN
false false
@ -584,6 +585,7 @@ void Preferences::saveSettings()
settings.setValue("defaultDownloadPath",""); settings.setValue("defaultDownloadPath","");
else else
settings.setValue("defaultDownloadPath", ui->downLoc->text()); settings.setValue("defaultDownloadPath", ui->downLoc->text());
settings.setValue("CloseManagerOnFinish", ui->closeDownManOnFinish->isChecked());
settings.setValue("useNativeDialog", ui->downlaodNativeSystemDialog->isChecked()); settings.setValue("useNativeDialog", ui->downlaodNativeSystemDialog->isChecked());
settings.endGroup(); settings.endGroup();

View File

@ -1464,7 +1464,7 @@
</item> </item>
</layout> </layout>
</item> </item>
<item row="8" column="2"> <item row="9" column="2">
<spacer name="verticalSpacer_10"> <spacer name="verticalSpacer_10">
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
@ -1513,7 +1513,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="7" column="1" colspan="3"> <item row="8" column="1" colspan="3">
<widget class="QCheckBox" name="downlaodNativeSystemDialog"> <widget class="QCheckBox" name="downlaodNativeSystemDialog">
<property name="text"> <property name="text">
<string>Use native system file dialog <string>Use native system file dialog
@ -1521,6 +1521,13 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="7" column="1" colspan="3">
<widget class="QCheckBox" name="closeDownManOnFinish">
<property name="text">
<string>Close download manager when downloading finishes</string>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="stackedWidgetPage5"> <widget class="QWidget" name="stackedWidgetPage5">

View File

@ -36,13 +36,13 @@ WebPage::WebPage(WebView* parent, QupZilla* mainClass)
, m_view(parent) , m_view(parent)
, m_blockAlerts(false) , m_blockAlerts(false)
, m_secureStatus(false) , m_secureStatus(false)
// ,m_isOpeningNextWindowAsNewTab(false) // , m_isOpeningNextWindowAsNewTab(false)
{ {
setForwardUnsupportedContent(true); setForwardUnsupportedContent(true);
setPluginFactory(new WebPluginFactory(this)); setPluginFactory(new WebPluginFactory(this));
history()->setMaximumItemCount(20); history()->setMaximumItemCount(20);
connect(this, SIGNAL(unsupportedContent(QNetworkReply*)), SLOT(handleUnsupportedContent(QNetworkReply*))); connect(this, SIGNAL(unsupportedContent(QNetworkReply*)), SLOT(handleUnsupportedContent(QNetworkReply*)));
connect(this, SIGNAL(loadStarted()), this, SLOT(loadingStarted())); // connect(this, SIGNAL(loadStarted()), this, SLOT(loadingStarted()));
connect(this, SIGNAL(loadProgress(int)), this, SLOT(progress(int))); connect(this, SIGNAL(loadProgress(int)), this, SLOT(progress(int)));
connect(this, SIGNAL(loadFinished(bool)), this, SLOT(finished())); connect(this, SIGNAL(loadFinished(bool)), this, SLOT(finished()));
connect(m_view, SIGNAL(urlChanged(QUrl)), this, SLOT(urlChanged(QUrl))); connect(m_view, SIGNAL(urlChanged(QUrl)), this, SLOT(urlChanged(QUrl)));
@ -52,6 +52,7 @@ void WebPage::urlChanged(const QUrl &url)
{ {
Q_UNUSED(url) Q_UNUSED(url)
m_adBlockedEntries.clear(); m_adBlockedEntries.clear();
m_blockAlerts = false;
} }
void WebPage::progress(int prog) void WebPage::progress(int prog)
@ -68,15 +69,22 @@ void WebPage::progress(int prog)
void WebPage::finished() void WebPage::finished()
{ {
progress(100); progress(100);
if (m_adjustingScheduled) {
m_adjustingScheduled = false;
mainFrame()->setZoomFactor(mainFrame()->zoomFactor() + 1);
mainFrame()->setZoomFactor(mainFrame()->zoomFactor() - 1);
}
QTimer::singleShot(100, this, SLOT(cleanBlockedObjects())); QTimer::singleShot(100, this, SLOT(cleanBlockedObjects()));
} }
void WebPage::loadingStarted() //void WebPage::loadingStarted()
{ //{
// m_adBlockedEntries.clear(); // m_adBlockedEntries.clear();
m_blockAlerts = false; // m_blockAlerts = false;
//m_SslCert.clear(); // m_SslCert.clear();
} //}
void WebPage::handleUnsupportedContent(QNetworkReply* reply) void WebPage::handleUnsupportedContent(QNetworkReply* reply)
{ {

View File

@ -66,13 +66,15 @@ public:
QupZilla* qupzilla() { return p_QupZilla; } QupZilla* qupzilla() { return p_QupZilla; }
void scheduleAdjustPage() { m_adjustingScheduled = true; }
signals: signals:
void privacyChanged(bool status); void privacyChanged(bool status);
protected slots: protected slots:
QWebPage* createWindow(QWebPage::WebWindowType type); QWebPage* createWindow(QWebPage::WebWindowType type);
void handleUnsupportedContent(QNetworkReply* url); void handleUnsupportedContent(QNetworkReply* url);
void loadingStarted(); // void loadingStarted();
void progress(int prog); void progress(int prog);
void finished(); void finished();
@ -98,6 +100,7 @@ private:
bool m_blockAlerts; bool m_blockAlerts;
bool m_secureStatus; bool m_secureStatus;
bool m_adjustingScheduled;
// bool m_isOpeningNextWindowAsNewTab; // bool m_isOpeningNextWindowAsNewTab;
}; };