mirror of
https://invent.kde.org/network/falkon.git
synced 2024-11-11 01:22:10 +01:00
Fixed unneeded cpu usage by making ProgressBar class
This commit is contained in:
parent
cfb889df8a
commit
c2f1d3dbe7
|
@ -114,7 +114,8 @@ SOURCES += main.cpp\
|
||||||
bookmarks/bookmarkicon.cpp \
|
bookmarks/bookmarkicon.cpp \
|
||||||
sidebar/historysidebar.cpp \
|
sidebar/historysidebar.cpp \
|
||||||
desktopnotifications/desktopnotification.cpp \
|
desktopnotifications/desktopnotification.cpp \
|
||||||
desktopnotifications/desktopnotificationsfactory.cpp
|
desktopnotifications/desktopnotificationsfactory.cpp \
|
||||||
|
tools/progressbar.cpp
|
||||||
|
|
||||||
HEADERS += 3rdparty/squeezelabel.h \
|
HEADERS += 3rdparty/squeezelabel.h \
|
||||||
3rdparty/qtwin.h \
|
3rdparty/qtwin.h \
|
||||||
|
@ -187,7 +188,8 @@ HEADERS += 3rdparty/squeezelabel.h \
|
||||||
bookmarks/bookmarkicon.h \
|
bookmarks/bookmarkicon.h \
|
||||||
sidebar/historysidebar.h \
|
sidebar/historysidebar.h \
|
||||||
desktopnotifications/desktopnotification.h \
|
desktopnotifications/desktopnotification.h \
|
||||||
desktopnotifications/desktopnotificationsfactory.h
|
desktopnotifications/desktopnotificationsfactory.h \
|
||||||
|
tools/progressbar.h
|
||||||
|
|
||||||
FORMS += \
|
FORMS += \
|
||||||
preferences/autofillmanager.ui \
|
preferences/autofillmanager.ui \
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#include "locationbar.h"
|
#include "locationbar.h"
|
||||||
#include "clickablelabel.h"
|
#include "clickablelabel.h"
|
||||||
#include "adblockicon.h"
|
#include "adblockicon.h"
|
||||||
|
#include "progressbar.h"
|
||||||
|
|
||||||
void QupZilla::postLaunch()
|
void QupZilla::postLaunch()
|
||||||
{
|
{
|
||||||
|
@ -142,8 +143,7 @@ void QupZilla::setupUi()
|
||||||
m_navigation->addWidget(new QLabel()); //Elegant spacer -,-
|
m_navigation->addWidget(new QLabel()); //Elegant spacer -,-
|
||||||
m_navigation->setContextMenuPolicy(Qt::CustomContextMenu);
|
m_navigation->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
|
|
||||||
m_progressBar = new QProgressBar(this);
|
m_progressBar = new ProgressBar(statusBar());
|
||||||
m_progressBar->setMaximumSize(QSize(150, 16));
|
|
||||||
m_privateBrowsing = new QLabel(this);
|
m_privateBrowsing = new QLabel(this);
|
||||||
m_privateBrowsing->setPixmap(QPixmap(":/icons/locationbar/privatebrowsing.png"));
|
m_privateBrowsing->setPixmap(QPixmap(":/icons/locationbar/privatebrowsing.png"));
|
||||||
m_privateBrowsing->setVisible(false);
|
m_privateBrowsing->setVisible(false);
|
||||||
|
|
|
@ -48,6 +48,7 @@
|
||||||
#include "clickablelabel.h"
|
#include "clickablelabel.h"
|
||||||
#include "docktitlebarwidget.h"
|
#include "docktitlebarwidget.h"
|
||||||
#include "sidebar.h"
|
#include "sidebar.h"
|
||||||
|
#include "progressbar.h"
|
||||||
|
|
||||||
const QString QupZilla::VERSION = "1.0.0-b1";
|
const QString QupZilla::VERSION = "1.0.0-b1";
|
||||||
//const QString QupZilla::BUILDTIME = QLocale(QLocale::English).toDateTime(__DATE__" "__TIME__, "MMM d yyyy hh:mm:ss").toString("MM/dd/yyyy hh:ss");
|
//const QString QupZilla::BUILDTIME = QLocale(QLocale::English).toDateTime(__DATE__" "__TIME__, "MMM d yyyy hh:mm:ss").toString("MM/dd/yyyy hh:ss");
|
||||||
|
@ -58,7 +59,7 @@ const QString QupZilla::WWWADDRESS = "http://qupzilla.ic.cz";
|
||||||
const QString QupZilla::WEBKITVERSION = qWebKitVersion();
|
const QString QupZilla::WEBKITVERSION = qWebKitVersion();
|
||||||
|
|
||||||
QupZilla::QupZilla(bool tryRestore, QUrl startUrl) :
|
QupZilla::QupZilla(bool tryRestore, QUrl startUrl) :
|
||||||
QMainWindow()
|
QMainWindow(0)
|
||||||
,m_tryRestore(tryRestore)
|
,m_tryRestore(tryRestore)
|
||||||
,m_startingUrl(startUrl)
|
,m_startingUrl(startUrl)
|
||||||
,m_actionPrivateBrowsing(0)
|
,m_actionPrivateBrowsing(0)
|
||||||
|
@ -93,7 +94,7 @@ void QupZilla::loadSettings()
|
||||||
m_newtab = settings.value("newTabUrl","").toUrl();
|
m_newtab = settings.value("newTabUrl","").toUrl();
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
|
|
||||||
QWebSettings* websettings=mApp->webSettings();
|
QWebSettings* websettings = mApp->webSettings();
|
||||||
websettings->setAttribute(QWebSettings::JavascriptCanAccessClipboard, true);
|
websettings->setAttribute(QWebSettings::JavascriptCanAccessClipboard, true);
|
||||||
|
|
||||||
//Browser Window settings
|
//Browser Window settings
|
||||||
|
@ -179,13 +180,13 @@ void QupZilla::refreshHistory(int index)
|
||||||
|
|
||||||
if (history->canGoBack()) {
|
if (history->canGoBack()) {
|
||||||
m_buttonBack->setEnabled(true);
|
m_buttonBack->setEnabled(true);
|
||||||
}else{
|
} else {
|
||||||
m_buttonBack->setEnabled(false);
|
m_buttonBack->setEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (history->canGoForward()) {
|
if (history->canGoForward()) {
|
||||||
m_buttonNext->setEnabled(true);
|
m_buttonNext->setEnabled(true);
|
||||||
}else{
|
} else {
|
||||||
m_buttonNext->setEnabled(false);
|
m_buttonNext->setEnabled(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,6 +72,7 @@ class MainApplication;
|
||||||
class WebTab;
|
class WebTab;
|
||||||
class AdBlockIcon;
|
class AdBlockIcon;
|
||||||
class SideBar;
|
class SideBar;
|
||||||
|
class ProgressBar;
|
||||||
class QupZilla : public QMainWindow
|
class QupZilla : public QMainWindow
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -103,7 +104,7 @@ public:
|
||||||
|
|
||||||
inline QAction* buttonStop(){ return m_buttonStop; }
|
inline QAction* buttonStop(){ return m_buttonStop; }
|
||||||
inline QAction* buttonReload(){ return m_buttonReload; }
|
inline QAction* buttonReload(){ return m_buttonReload; }
|
||||||
inline QProgressBar* progressBar(){ return m_progressBar; }
|
inline ProgressBar* progressBar(){ return m_progressBar; }
|
||||||
inline QToolBar* navigationToolbar(){ return m_navigation; }
|
inline QToolBar* navigationToolbar(){ return m_navigation; }
|
||||||
inline QString activeProfil(){ return m_activeProfil; }
|
inline QString activeProfil(){ return m_activeProfil; }
|
||||||
inline QString activeLanguage(){ return m_activeLanguage; }
|
inline QString activeLanguage(){ return m_activeLanguage; }
|
||||||
|
@ -111,6 +112,7 @@ public:
|
||||||
inline QLabel* ipLabel(){ return m_ipLabel; }
|
inline QLabel* ipLabel(){ return m_ipLabel; }
|
||||||
inline QColor menuTextColor() { return m_menuTextColor; }
|
inline QColor menuTextColor() { return m_menuTextColor; }
|
||||||
inline QAction* acShowBookmarksToolbar() { return m_actionShowBookmarksToolbar; }
|
inline QAction* acShowBookmarksToolbar() { return m_actionShowBookmarksToolbar; }
|
||||||
|
inline QMenu* menuHelp() { return m_menuHelp; }
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void loadHistory();
|
void loadHistory();
|
||||||
|
@ -242,7 +244,7 @@ private:
|
||||||
QAction* m_buttonStop;
|
QAction* m_buttonStop;
|
||||||
QAction* m_buttonReload;
|
QAction* m_buttonReload;
|
||||||
QAction* m_actionExitFullscreen;
|
QAction* m_actionExitFullscreen;
|
||||||
QProgressBar* m_progressBar;
|
ProgressBar* m_progressBar;
|
||||||
QLabel* m_ipLabel;
|
QLabel* m_ipLabel;
|
||||||
QToolBar* m_navigation;
|
QToolBar* m_navigation;
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,7 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
int result = app.exec();
|
int result = app.exec();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#include "rsswidget.h"
|
#include "rsswidget.h"
|
||||||
#include "webpage.h"
|
#include "webpage.h"
|
||||||
#include "bookmarkicon.h"
|
#include "bookmarkicon.h"
|
||||||
|
#include "progressbar.h"
|
||||||
|
|
||||||
LocationBar::LocationBar(QupZilla* mainClass, QWidget* parent)
|
LocationBar::LocationBar(QupZilla* mainClass, QWidget* parent)
|
||||||
: LineEdit(parent)
|
: LineEdit(parent)
|
||||||
|
|
|
@ -44,7 +44,6 @@ 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"))
|
||||||
|
|
|
@ -27,7 +27,6 @@ Updater::Updater(QupZilla* mainClass, QObject* parent) :
|
||||||
#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()
|
||||||
|
@ -49,13 +48,21 @@ void Updater::downCompleted(QNetworkReply* reply)
|
||||||
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) {
|
||||||
mApp->desktopNotifications()->notify(QPixmap(":icons/qupzillaupdate.png"), tr("Update is available"), tr("Newer version of QupZilla is ready to download."));
|
mApp->desktopNotifications()->notify(QPixmap(":icons/qupzillaupdate.png"), tr("Update available"), tr("New version of QupZilla is ready to download."));
|
||||||
|
QAction* action = new QAction(QIcon(":icons/qupzillaupdate.png"), "Update", this);
|
||||||
|
connect(action, SIGNAL(triggered()), this, SLOT(downloadNewVersion()));
|
||||||
|
p_QupZilla->menuBar()->addAction(action);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
reply->manager()->deleteLater();
|
reply->manager()->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Updater::downloadNewVersion()
|
||||||
|
{
|
||||||
|
p_QupZilla->tabWidget()->addView(QUrl(QupZilla::WWWADDRESS + "/download.php"), tr("Update"), TabWidget::NewSelectedTab);
|
||||||
|
}
|
||||||
|
|
||||||
Updater::~Updater()
|
Updater::~Updater()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,15 +33,15 @@ public:
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
public slots:
|
private slots:
|
||||||
void downCompleted(QNetworkReply* reply);
|
void downCompleted(QNetworkReply* reply);
|
||||||
void start();
|
void start();
|
||||||
|
void downloadNewVersion();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void startDownloadingUpdateInfo(const QUrl &url);
|
void startDownloadingUpdateInfo(const QUrl &url);
|
||||||
|
|
||||||
QupZilla* p_QupZilla;
|
QupZilla* p_QupZilla;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // UPDATER_H
|
#endif // UPDATER_H
|
||||||
|
|
39
src/tools/progressbar.cpp
Normal file
39
src/tools/progressbar.cpp
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
#include "progressbar.h"
|
||||||
|
|
||||||
|
ProgressBar::ProgressBar(QWidget* parent)
|
||||||
|
: QWidget(parent)
|
||||||
|
, m_value(0)
|
||||||
|
, m_lastPaintedValue(-1)
|
||||||
|
{
|
||||||
|
setMinimumSize(QSize(130,16));
|
||||||
|
setMaximumSize(QSize(150,16));
|
||||||
|
}
|
||||||
|
|
||||||
|
void ProgressBar::setValue(int value)
|
||||||
|
{
|
||||||
|
m_value = value;
|
||||||
|
if (m_lastPaintedValue != m_value)
|
||||||
|
repaint();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ProgressBar::initStyleOption(QStyleOptionProgressBar *option)
|
||||||
|
{
|
||||||
|
if (!option)
|
||||||
|
return;
|
||||||
|
|
||||||
|
option->initFrom(this);
|
||||||
|
option->minimum = 0;
|
||||||
|
option->maximum = 100;
|
||||||
|
option->progress = m_value;
|
||||||
|
option->textAlignment = Qt::AlignLeft;
|
||||||
|
option->textVisible = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ProgressBar::paintEvent(QPaintEvent*)
|
||||||
|
{
|
||||||
|
QStylePainter paint(this);
|
||||||
|
QStyleOptionProgressBarV2 opt;
|
||||||
|
initStyleOption(&opt);
|
||||||
|
paint.drawControl(QStyle::CE_ProgressBar, opt);
|
||||||
|
m_lastPaintedValue = m_value;
|
||||||
|
}
|
29
src/tools/progressbar.h
Normal file
29
src/tools/progressbar.h
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
#ifndef PROGRESSBAR_H
|
||||||
|
#define PROGRESSBAR_H
|
||||||
|
|
||||||
|
#include <QStylePainter>
|
||||||
|
#include <QStyleOptionProgressBarV2>
|
||||||
|
#include <QStyleOptionProgressBar>
|
||||||
|
|
||||||
|
class ProgressBar : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit ProgressBar(QWidget* parent = 0);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void setValue(int value);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void paintEvent(QPaintEvent* e);
|
||||||
|
void initStyleOption(QStyleOptionProgressBar* option);
|
||||||
|
|
||||||
|
private:
|
||||||
|
int m_value;
|
||||||
|
int m_lastPaintedValue;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // PROGRESSBAR_H
|
Loading…
Reference in New Issue
Block a user