1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 18:56: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 "downloadfilehelper.h"
DownloadManager::DownloadManager(QWidget* parent) :
QWidget(parent)
,ui(new Ui::DownloadManager)
,m_isClosing(false)
DownloadManager::DownloadManager(QWidget* parent)
: QWidget(parent)
, ui(new Ui::DownloadManager)
, m_isClosing(false)
{
setWindowFlags(windowFlags() ^ Qt::WindowMaximizeButtonHint);
ui->setupUi(this);
@ -60,6 +60,7 @@ void DownloadManager::loadSettings()
settings.beginGroup("DownloadManager");
m_downloadPath = settings.value("defaultDownloadPath", "").toString();
m_lastDownloadPath = settings.value("lastDownloadPath", QDir::homePath() + "/").toString();
m_closeOnFinish = settings.value("CloseManagerOnFinish", false).toBool();
m_useNativeDialog = settings.value("useNativeDialog",
#ifdef Q_WS_WIN
false
@ -200,9 +201,11 @@ void DownloadManager::downloadFinished(bool success)
if (downloadingAllFilesFinished) {
if (success && qApp->activeWindow() != this) {
mApp->desktopNotifications()->notify(QPixmap(":icons/notifications/download.png"), tr("Download Finished"), tr("All files have been successfuly downloaded."));
if (!m_closeOnFinish) {
raise();
activateWindow();
}
}
ui->speedLabel->clear();
setWindowTitle(tr("Download Manager"));
#ifdef W7API
@ -211,6 +214,8 @@ void DownloadManager::downloadFinished(bool success)
win7.setProgressState(win7.NoProgress);
}
#endif
if (m_closeOnFinish)
close();
}
}

View File

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

View File

@ -101,9 +101,13 @@ void ClickToFlash::ensurePluginVisible()
// I don't know any other method how to show our plugin
// and adjust it on the proper position in page
m_page->mainFrame()->setZoomFactor(m_page->mainFrame()->zoomFactor() + 1);
m_page->mainFrame()->setZoomFactor(m_page->mainFrame()->zoomFactor() - 1);
// Scheduling adjustingPage rather than actually changing zoomFactor
// 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)
{
QMenu menu;

View File

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

View File

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

View File

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

View File

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