mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 18:56:34 +01:00
Some edits in desktopnotificationsfactory + use it when newer version is
available and after all downloads are completed
This commit is contained in:
parent
cd4763d2d9
commit
cfb889df8a
@ -34,6 +34,7 @@
|
|||||||
#include "downloadmanager.h"
|
#include "downloadmanager.h"
|
||||||
#include "autofillmodel.h"
|
#include "autofillmodel.h"
|
||||||
#include "adblockmanager.h"
|
#include "adblockmanager.h"
|
||||||
|
#include "desktopnotificationsfactory.h"
|
||||||
|
|
||||||
MainApplication::MainApplication(int &argc, char **argv)
|
MainApplication::MainApplication(int &argc, char **argv)
|
||||||
: QtSingleApplication("QupZillaWebBrowser", argc, argv)
|
: QtSingleApplication("QupZillaWebBrowser", argc, argv)
|
||||||
@ -50,6 +51,7 @@ MainApplication::MainApplication(int &argc, char **argv)
|
|||||||
,m_downloadManager(0)
|
,m_downloadManager(0)
|
||||||
,m_autofill(0)
|
,m_autofill(0)
|
||||||
,m_networkCache(new QNetworkDiskCache)
|
,m_networkCache(new QNetworkDiskCache)
|
||||||
|
,m_desktopNotifications(0)
|
||||||
,m_isClosing(false)
|
,m_isClosing(false)
|
||||||
,m_isChanged(false)
|
,m_isChanged(false)
|
||||||
,m_isExited(false)
|
,m_isExited(false)
|
||||||
@ -420,6 +422,13 @@ AutoFillModel* MainApplication::autoFill()
|
|||||||
return m_autofill;
|
return m_autofill;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DesktopNotificationsFactory* MainApplication::desktopNotifications()
|
||||||
|
{
|
||||||
|
if (!m_desktopNotifications)
|
||||||
|
m_desktopNotifications = new DesktopNotificationsFactory(this);
|
||||||
|
return m_desktopNotifications;
|
||||||
|
}
|
||||||
|
|
||||||
void MainApplication::aboutToCloseWindow(QupZilla* window)
|
void MainApplication::aboutToCloseWindow(QupZilla* window)
|
||||||
{
|
{
|
||||||
if (!window)
|
if (!window)
|
||||||
|
@ -41,6 +41,7 @@ class PluginProxy;
|
|||||||
class BookmarksModel;
|
class BookmarksModel;
|
||||||
class DownloadManager;
|
class DownloadManager;
|
||||||
class AutoFillModel;
|
class AutoFillModel;
|
||||||
|
class DesktopNotificationsFactory;
|
||||||
|
|
||||||
class MainApplication : public QtSingleApplication
|
class MainApplication : public QtSingleApplication
|
||||||
{
|
{
|
||||||
@ -82,6 +83,7 @@ public:
|
|||||||
DownloadManager* downManager();
|
DownloadManager* downManager();
|
||||||
AutoFillModel* autoFill();
|
AutoFillModel* autoFill();
|
||||||
QNetworkDiskCache* networkCache() { return m_networkCache; }
|
QNetworkDiskCache* networkCache() { return m_networkCache; }
|
||||||
|
DesktopNotificationsFactory* desktopNotifications();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
bool saveStateSlot();
|
bool saveStateSlot();
|
||||||
@ -115,6 +117,7 @@ private:
|
|||||||
DownloadManager* m_downloadManager;
|
DownloadManager* m_downloadManager;
|
||||||
AutoFillModel* m_autofill;
|
AutoFillModel* m_autofill;
|
||||||
QNetworkDiskCache* m_networkCache;
|
QNetworkDiskCache* m_networkCache;
|
||||||
|
DesktopNotificationsFactory* m_desktopNotifications;
|
||||||
|
|
||||||
QList<QPointer<QupZilla> > m_mainWindows;
|
QList<QPointer<QupZilla> > m_mainWindows;
|
||||||
|
|
||||||
|
@ -70,5 +70,7 @@
|
|||||||
<file>icons/preferences/stock_keyring.png</file>
|
<file>icons/preferences/stock_keyring.png</file>
|
||||||
<file>icons/other/list-add.png</file>
|
<file>icons/other/list-add.png</file>
|
||||||
<file>icons/other/adblock.png</file>
|
<file>icons/other/adblock.png</file>
|
||||||
|
<file>icons/preferences/stock_dialog-question.png</file>
|
||||||
|
<file>icons/notifications/download.png</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
BIN
src/data/icons/notifications/download.png
Normal file
BIN
src/data/icons/notifications/download.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.0 KiB |
BIN
src/data/icons/preferences/stock_dialog-question.png
Normal file
BIN
src/data/icons/preferences/stock_dialog-question.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.8 KiB |
@ -27,7 +27,7 @@ DesktopNotification::DesktopNotification(bool settingPosition)
|
|||||||
void DesktopNotification::show()
|
void DesktopNotification::show()
|
||||||
{
|
{
|
||||||
ui->icon->setPixmap(m_icon);
|
ui->icon->setPixmap(m_icon);
|
||||||
ui->heading->setText(QString("<b>%1</b>").arg(m_heading));
|
ui->heading->setText(m_heading);
|
||||||
ui->text->setText(m_text);
|
ui->text->setText(m_text);
|
||||||
|
|
||||||
if (!m_settingPosition) {
|
if (!m_settingPosition) {
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>356</width>
|
<width>356</width>
|
||||||
<height>91</height>
|
<height>74</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@ -35,26 +35,13 @@ background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1,stop:0 #e4ecf1, stop:1
|
|||||||
<property name="frameShadow">
|
<property name="frameShadow">
|
||||||
<enum>QFrame::Raised</enum>
|
<enum>QFrame::Raised</enum>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
<item row="0" column="1">
|
<item>
|
||||||
<widget class="QLabel" name="heading">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="0" rowspan="2">
|
|
||||||
<widget class="QLabel" name="icon">
|
<widget class="QLabel" name="icon">
|
||||||
<property name="maximumSize">
|
<property name="maximumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>64</width>
|
<width>48</width>
|
||||||
<height>64</height>
|
<height>48</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@ -62,15 +49,67 @@ background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1,stop:0 #e4ecf1, stop:1
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1">
|
<item>
|
||||||
<widget class="QLabel" name="text">
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
<property name="text">
|
<property name="spacing">
|
||||||
<string/>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="alignment">
|
<item>
|
||||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
<spacer name="verticalSpacer">
|
||||||
</property>
|
<property name="orientation">
|
||||||
</widget>
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>40</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="heading">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="styleSheet">
|
||||||
|
<string notr="true">QLabel {
|
||||||
|
font: bold;
|
||||||
|
font-size: 13pt;
|
||||||
|
}</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="text">
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="verticalSpacer_2">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>40</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
@ -15,7 +15,8 @@ void DesktopNotificationsFactory::loadSettings()
|
|||||||
settings.beginGroup("Notifications");
|
settings.beginGroup("Notifications");
|
||||||
m_enabled = settings.value("Enabled", true).toBool();
|
m_enabled = settings.value("Enabled", true).toBool();
|
||||||
m_timeout = settings.value("Timeout", 6000).toInt();
|
m_timeout = settings.value("Timeout", 6000).toInt();
|
||||||
#ifdef Q_WS_X11
|
//#ifdef Q_WS_X11
|
||||||
|
#if 0
|
||||||
m_notifType = settings.value("UseNativeDesktop", true).toBool() ? DesktopNative : PopupWidget;
|
m_notifType = settings.value("UseNativeDesktop", true).toBool() ? DesktopNative : PopupWidget;
|
||||||
#else
|
#else
|
||||||
m_notifType = PopupWidget;
|
m_notifType = PopupWidget;
|
||||||
@ -26,6 +27,9 @@ void DesktopNotificationsFactory::loadSettings()
|
|||||||
|
|
||||||
void DesktopNotificationsFactory::notify(const QPixmap &icon, const QString &heading, const QString &text)
|
void DesktopNotificationsFactory::notify(const QPixmap &icon, const QString &heading, const QString &text)
|
||||||
{
|
{
|
||||||
|
if (!m_enabled)
|
||||||
|
return;
|
||||||
|
|
||||||
switch (m_notifType) {
|
switch (m_notifType) {
|
||||||
case PopupWidget:
|
case PopupWidget:
|
||||||
if (!m_desktopNotif)
|
if (!m_desktopNotif)
|
||||||
@ -34,15 +38,20 @@ void DesktopNotificationsFactory::notify(const QPixmap &icon, const QString &hea
|
|||||||
m_desktopNotif->setHeading(heading);
|
m_desktopNotif->setHeading(heading);
|
||||||
m_desktopNotif->setText(text);
|
m_desktopNotif->setText(text);
|
||||||
m_desktopNotif->setTimeout(m_timeout);
|
m_desktopNotif->setTimeout(m_timeout);
|
||||||
|
m_desktopNotif->move(m_position);
|
||||||
m_desktopNotif->show();
|
m_desktopNotif->show();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DesktopNative:
|
case DesktopNative:
|
||||||
|
QFile tmp(QDir::tempPath() + "/qupzilla_notif.png");
|
||||||
|
tmp.open(QFile::WriteOnly);
|
||||||
|
icon.save(tmp.fileName());
|
||||||
|
|
||||||
QDBusInterface dbus("org.freedesktop.Notifications", "/org/freedesktop/Notifications", "org.freedesktop.Notifications", QDBusConnection::sessionBus());
|
QDBusInterface dbus("org.freedesktop.Notifications", "/org/freedesktop/Notifications", "org.freedesktop.Notifications", QDBusConnection::sessionBus());
|
||||||
QVariantList args;
|
QVariantList args;
|
||||||
args.append("qupzilla");
|
args.append("qupzilla");
|
||||||
args.append(m_uint);
|
args.append(m_uint);
|
||||||
args.append(""); //FIXME:store pixmap in temp folder and provide full path to it
|
args.append(tmp.fileName());
|
||||||
args.append(heading);
|
args.append(heading);
|
||||||
args.append(text);
|
args.append(text);
|
||||||
args.append(QStringList());
|
args.append(QStringList());
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
#include <QPoint>
|
#include <QPoint>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
|
#include <QDir>
|
||||||
|
|
||||||
class DesktopNotification;
|
class DesktopNotification;
|
||||||
class DesktopNotificationsFactory : public QObject
|
class DesktopNotificationsFactory : public QObject
|
||||||
|
@ -128,6 +128,8 @@ void DownloadItem::finished()
|
|||||||
|
|
||||||
if (m_openAfterFinish)
|
if (m_openAfterFinish)
|
||||||
openFile();
|
openFile();
|
||||||
|
|
||||||
|
emit downloadFinished(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DownloadItem::downloadProgress(qint64 received, qint64 total)
|
void DownloadItem::downloadProgress(qint64 received, qint64 total)
|
||||||
@ -258,6 +260,8 @@ void DownloadItem::stop(bool askForDeleteFile)
|
|||||||
#endif
|
#endif
|
||||||
m_downloading = false;
|
m_downloading = false;
|
||||||
|
|
||||||
|
emit downloadFinished(false);
|
||||||
|
|
||||||
if (askForDeleteFile) {
|
if (askForDeleteFile) {
|
||||||
QMessageBox::StandardButton button = QMessageBox::question(m_item->listWidget()->parentWidget(), tr("Delete file"), tr("Do you want to also delete dowloaded file?"), QMessageBox::Yes | QMessageBox::No);
|
QMessageBox::StandardButton button = QMessageBox::question(m_item->listWidget()->parentWidget(), tr("Delete file"), tr("Do you want to also delete dowloaded file?"), QMessageBox::Yes | QMessageBox::No);
|
||||||
if (button != QMessageBox::Yes)
|
if (button != QMessageBox::Yes)
|
||||||
|
@ -56,6 +56,7 @@ public:
|
|||||||
|
|
||||||
signals:
|
signals:
|
||||||
void deleteItem(DownloadItem*);
|
void deleteItem(DownloadItem*);
|
||||||
|
void downloadFinished(bool success);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void finished();
|
void finished();
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#include "ecwin7.h"
|
#include "ecwin7.h"
|
||||||
#include "networkmanager.h"
|
#include "networkmanager.h"
|
||||||
#include "qtwin.h"
|
#include "qtwin.h"
|
||||||
|
#include "desktopnotificationsfactory.h"
|
||||||
|
|
||||||
DownloadManager::DownloadManager(QWidget* parent) :
|
DownloadManager::DownloadManager(QWidget* parent) :
|
||||||
QWidget(parent)
|
QWidget(parent)
|
||||||
@ -77,25 +78,14 @@ void DownloadManager::timerEvent(QTimerEvent* event)
|
|||||||
}
|
}
|
||||||
for (int i = 0; i < ui->list->count(); i++) {
|
for (int i = 0; i < ui->list->count(); i++) {
|
||||||
DownloadItem* downItem = qobject_cast<DownloadItem*>(ui->list->itemWidget(ui->list->item(i)));
|
DownloadItem* downItem = qobject_cast<DownloadItem*>(ui->list->itemWidget(ui->list->item(i)));
|
||||||
if (!downItem || (downItem && downItem->isCancelled()))
|
if (!downItem || (downItem && downItem->isCancelled()) || !downItem->isDownloading())
|
||||||
continue;
|
continue;
|
||||||
if (!downItem->isDownloading()) {
|
progresses.append(downItem->progress());
|
||||||
progresses.append(100);
|
|
||||||
continue;
|
|
||||||
} else
|
|
||||||
progresses.append(downItem->progress());
|
|
||||||
remTimes.append(downItem->remainingTime());
|
remTimes.append(downItem->remainingTime());
|
||||||
speeds.append(downItem->currentSpeed());
|
speeds.append(downItem->currentSpeed());
|
||||||
}
|
}
|
||||||
if (remTimes.isEmpty()) {
|
if (remTimes.isEmpty())
|
||||||
ui->speedLabel->clear();
|
|
||||||
setWindowTitle(tr("Download Manager"));
|
|
||||||
#ifdef W7API
|
|
||||||
win7.setProgressValue(0, 0);
|
|
||||||
win7.setProgressState(win7.Normal);
|
|
||||||
#endif
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
QTime remaining;
|
QTime remaining;
|
||||||
foreach (QTime time, remTimes) {
|
foreach (QTime time, remTimes) {
|
||||||
@ -203,12 +193,35 @@ void DownloadManager::handleUnsupportedContent(QNetworkReply* reply, bool askWha
|
|||||||
QListWidgetItem* item = new QListWidgetItem(ui->list);
|
QListWidgetItem* item = new QListWidgetItem(ui->list);
|
||||||
DownloadItem* downItem = new DownloadItem(item, reply, path, fileName, fileIcon, openFileOptionsChoosed, this);
|
DownloadItem* downItem = new DownloadItem(item, reply, path, fileName, fileIcon, openFileOptionsChoosed, this);
|
||||||
connect(downItem, SIGNAL(deleteItem(DownloadItem*)), this, SLOT(deleteItem(DownloadItem*)));
|
connect(downItem, SIGNAL(deleteItem(DownloadItem*)), this, SLOT(deleteItem(DownloadItem*)));
|
||||||
|
connect(downItem, SIGNAL(downloadFinished(bool)), this, SLOT(downloadFinished(bool)));
|
||||||
ui->list->setItemWidget(item, downItem);
|
ui->list->setItemWidget(item, downItem);
|
||||||
item->setSizeHint(downItem->sizeHint());
|
item->setSizeHint(downItem->sizeHint());
|
||||||
show();
|
show();
|
||||||
activateWindow();
|
activateWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DownloadManager::downloadFinished(bool success)
|
||||||
|
{
|
||||||
|
bool downloadingAllFilesFinished = true;
|
||||||
|
for (int i = 0; i < ui->list->count(); i++) {
|
||||||
|
DownloadItem* downItem = qobject_cast<DownloadItem*>(ui->list->itemWidget(ui->list->item(i)));
|
||||||
|
if (!downItem || (downItem && downItem->isCancelled()) || !downItem->isDownloading())
|
||||||
|
continue;
|
||||||
|
downloadingAllFilesFinished = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (downloadingAllFilesFinished) {
|
||||||
|
if (success)
|
||||||
|
mApp->desktopNotifications()->notify(QPixmap(":icons/notifications/download.png"), tr("Download Finished"), tr("All files has been successfuly downloaded."));
|
||||||
|
ui->speedLabel->clear();
|
||||||
|
setWindowTitle(tr("Download Manager"));
|
||||||
|
#ifdef W7API
|
||||||
|
win7.setProgressValue(0, 0);
|
||||||
|
win7.setProgressState(win7.Normal);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void DownloadManager::deleteItem(DownloadItem* item)
|
void DownloadManager::deleteItem(DownloadItem* item)
|
||||||
{
|
{
|
||||||
if (item && !item->isDownloading())
|
if (item && !item->isDownloading())
|
||||||
|
@ -67,6 +67,7 @@ protected:
|
|||||||
private slots:
|
private slots:
|
||||||
void clearList();
|
void clearList();
|
||||||
void deleteItem(DownloadItem* item);
|
void deleteItem(DownloadItem* item);
|
||||||
|
void downloadFinished(bool success);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
#ifdef W7API
|
#ifdef W7API
|
||||||
|
@ -37,5 +37,6 @@ int main(int argc, char *argv[])
|
|||||||
std::cout << "QupZilla already running - activating existing window" << std::endl;
|
std::cout << "QupZilla already running - activating existing window" << std::endl;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return app.exec();
|
int result = app.exec();
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#include "webview.h"
|
#include "webview.h"
|
||||||
#include "webpage.h"
|
#include "webpage.h"
|
||||||
#include "qtwin.h"
|
#include "qtwin.h"
|
||||||
|
#include "desktopnotificationsfactory.h"
|
||||||
|
|
||||||
AboutDialog::AboutDialog(QWidget* parent) :
|
AboutDialog::AboutDialog(QWidget* parent) :
|
||||||
QDialog(parent),
|
QDialog(parent),
|
||||||
@ -43,6 +44,7 @@ AboutDialog::AboutDialog(QWidget* parent) :
|
|||||||
|
|
||||||
void AboutDialog::buttonClicked()
|
void AboutDialog::buttonClicked()
|
||||||
{
|
{
|
||||||
|
mApp->desktopNotifications()->notify(QPixmap(":qupzilla.png"), "heading","text");
|
||||||
if (ui->authorsButton->text() == tr("Authors and Contributors"))
|
if (ui->authorsButton->text() == tr("Authors and Contributors"))
|
||||||
showAuthors();
|
showAuthors();
|
||||||
else if (ui->authorsButton->text() == tr("< About QupZilla"))
|
else if (ui->authorsButton->text() == tr("< About QupZilla"))
|
||||||
|
@ -18,15 +18,16 @@
|
|||||||
#include "updater.h"
|
#include "updater.h"
|
||||||
#include "qupzilla.h"
|
#include "qupzilla.h"
|
||||||
#include "tabwidget.h"
|
#include "tabwidget.h"
|
||||||
|
#include "desktopnotificationsfactory.h"
|
||||||
|
|
||||||
Updater::Updater(QupZilla* mainClass, QObject* parent) :
|
Updater::Updater(QupZilla* mainClass, QObject* parent) :
|
||||||
QObject(parent)
|
QObject(parent)
|
||||||
,p_QupZilla(mainClass)
|
,p_QupZilla(mainClass)
|
||||||
{
|
{
|
||||||
createTrayIcon();
|
|
||||||
#ifndef DEVELOPING
|
#ifndef DEVELOPING
|
||||||
QTimer::singleShot(60*1000, this, SLOT(start()) ); //Start checking after 1 minute
|
QTimer::singleShot(60*1000, this, SLOT(start()) ); //Start checking after 1 minute
|
||||||
#endif
|
#endif
|
||||||
|
QTimer::singleShot(1000, this, SLOT(start()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Updater::start()
|
void Updater::start()
|
||||||
@ -34,23 +35,8 @@ void Updater::start()
|
|||||||
startDownloadingUpdateInfo(QUrl(QupZilla::WWWADDRESS+"/update.php?v="+QupZilla::VERSION));
|
startDownloadingUpdateInfo(QUrl(QupZilla::WWWADDRESS+"/update.php?v="+QupZilla::VERSION));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Updater::createTrayIcon()
|
|
||||||
{
|
|
||||||
m_trayIcon = new QSystemTrayIcon(this);
|
|
||||||
m_trayIconMenu = new QMenu();
|
|
||||||
m_trayIconMenu->addAction(tr("Go to download page"), p_QupZilla, SLOT(loadActionUrl()))->setData(QUrl(QupZilla::WWWADDRESS+"/download.php"));
|
|
||||||
m_trayIconMenu->addAction(tr("Go to QupZilla website"), p_QupZilla, SLOT(loadActionUrl()))->setData(QUrl(QupZilla::WWWADDRESS));
|
|
||||||
m_trayIconMenu->addSeparator();
|
|
||||||
m_trayIconMenu->addAction(tr("Hide notification"), m_trayIcon, SLOT(hide()));
|
|
||||||
|
|
||||||
|
|
||||||
m_trayIcon->setContextMenu(m_trayIconMenu);
|
|
||||||
m_trayIcon->setIcon(QIcon(":/icons/qupzillaupdate.png"));
|
|
||||||
m_trayIcon->setToolTip(tr("QupZilla is checking for updates"));
|
|
||||||
}
|
|
||||||
void Updater::startDownloadingUpdateInfo(const QUrl &url)
|
void Updater::startDownloadingUpdateInfo(const QUrl &url)
|
||||||
{
|
{
|
||||||
// trayIcon->show(); // Disabled, it was getting focus, so mainwindow lost focus
|
|
||||||
QNetworkAccessManager* manager = new QNetworkAccessManager();
|
QNetworkAccessManager* manager = new QNetworkAccessManager();
|
||||||
QNetworkReply* reply;
|
QNetworkReply* reply;
|
||||||
reply=manager->get(QNetworkRequest(QUrl(url)));
|
reply=manager->get(QNetworkRequest(QUrl(url)));
|
||||||
@ -60,37 +46,16 @@ void Updater::startDownloadingUpdateInfo(const QUrl &url)
|
|||||||
|
|
||||||
void Updater::downCompleted(QNetworkReply* reply)
|
void Updater::downCompleted(QNetworkReply* reply)
|
||||||
{
|
{
|
||||||
m_trayIcon->show();
|
|
||||||
QString html = QString(reply->readAll());
|
QString html = QString(reply->readAll());
|
||||||
if (html.startsWith("Version:")){
|
if (html.startsWith("Version:")){
|
||||||
html.remove("Version:");
|
html.remove("Version:");
|
||||||
if (html != QupZilla::VERSION) {
|
if (html != QupZilla::VERSION)
|
||||||
connect(m_trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(clicked(QSystemTrayIcon::ActivationReason)));
|
mApp->desktopNotifications()->notify(QPixmap(":icons/qupzillaupdate.png"), tr("Update is available"), tr("Newer version of QupZilla is ready to download."));
|
||||||
connect(m_trayIcon, SIGNAL(messageClicked()), this, SLOT(goUpdate()));
|
|
||||||
m_trayIcon->setToolTip(tr("QupZilla found a new version!"));
|
|
||||||
m_trayIcon->showMessage(tr("New version is available"), tr("New version of QupZilla %1 is available!").arg(html));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
m_trayIcon->hide();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
reply->manager()->deleteLater();
|
reply->manager()->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Updater::goUpdate()
|
|
||||||
{
|
|
||||||
p_QupZilla->tabWidget()->addView(QUrl(QupZilla::WWWADDRESS+"/download.php"), tr("QupZilla Update"));
|
|
||||||
}
|
|
||||||
|
|
||||||
void Updater::clicked(QSystemTrayIcon::ActivationReason reason)
|
|
||||||
{
|
|
||||||
if (reason == QSystemTrayIcon::DoubleClick)
|
|
||||||
p_QupZilla->tabWidget()->addView(QUrl(QupZilla::WWWADDRESS+"/download.php"), tr("QupZilla Update"));
|
|
||||||
}
|
|
||||||
|
|
||||||
Updater::~Updater()
|
Updater::~Updater()
|
||||||
{
|
{
|
||||||
m_trayIcon->hide();
|
|
||||||
delete m_trayIconMenu;
|
|
||||||
delete m_trayIcon;
|
|
||||||
}
|
}
|
||||||
|
@ -36,16 +36,10 @@ signals:
|
|||||||
public slots:
|
public slots:
|
||||||
void downCompleted(QNetworkReply* reply);
|
void downCompleted(QNetworkReply* reply);
|
||||||
void start();
|
void start();
|
||||||
void goUpdate();
|
|
||||||
void clicked(QSystemTrayIcon::ActivationReason reason);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void createTrayIcon();
|
|
||||||
void startDownloadingUpdateInfo(const QUrl &url);
|
void startDownloadingUpdateInfo(const QUrl &url);
|
||||||
|
|
||||||
QSystemTrayIcon* m_trayIcon;
|
|
||||||
QMenu* m_trayIconMenu;
|
|
||||||
|
|
||||||
QupZilla* p_QupZilla;
|
QupZilla* p_QupZilla;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -151,11 +151,23 @@
|
|||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Plugins</string>
|
<string>Notifications</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="whatsThis">
|
<property name="whatsThis">
|
||||||
<string notr="true">8</string>
|
<string notr="true">8</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="../data/icons.qrc">
|
||||||
|
<normaloff>:/icons/preferences/stock_dialog-question.png</normaloff>:/icons/preferences/stock_dialog-question.png</iconset>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Plugins</string>
|
||||||
|
</property>
|
||||||
|
<property name="whatsThis">
|
||||||
|
<string notr="true">9</string>
|
||||||
|
</property>
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset resource="../data/icons.qrc">
|
<iconset resource="../data/icons.qrc">
|
||||||
<normaloff>:/icons/preferences/extension.png</normaloff>:/icons/preferences/extension.png</iconset>
|
<normaloff>:/icons/preferences/extension.png</normaloff>:/icons/preferences/extension.png</iconset>
|
||||||
@ -166,7 +178,7 @@
|
|||||||
<string>Other</string>
|
<string>Other</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="whatsThis">
|
<property name="whatsThis">
|
||||||
<string notr="true">9</string>
|
<string notr="true">10</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset resource="../data/icons.qrc">
|
<iconset resource="../data/icons.qrc">
|
||||||
@ -1574,6 +1586,7 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
<widget class="QWidget" name="page_3"/>
|
||||||
<widget class="QWidget" name="page">
|
<widget class="QWidget" name="page">
|
||||||
<layout class="QGridLayout" name="gridLayout_14">
|
<layout class="QGridLayout" name="gridLayout_14">
|
||||||
<item row="0" column="0" colspan="2">
|
<item row="0" column="0" colspan="2">
|
||||||
|
Loading…
Reference in New Issue
Block a user