mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 10:46:35 +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 \
|
||||
sidebar/historysidebar.cpp \
|
||||
desktopnotifications/desktopnotification.cpp \
|
||||
desktopnotifications/desktopnotificationsfactory.cpp
|
||||
desktopnotifications/desktopnotificationsfactory.cpp \
|
||||
tools/progressbar.cpp
|
||||
|
||||
HEADERS += 3rdparty/squeezelabel.h \
|
||||
3rdparty/qtwin.h \
|
||||
@ -187,7 +188,8 @@ HEADERS += 3rdparty/squeezelabel.h \
|
||||
bookmarks/bookmarkicon.h \
|
||||
sidebar/historysidebar.h \
|
||||
desktopnotifications/desktopnotification.h \
|
||||
desktopnotifications/desktopnotificationsfactory.h
|
||||
desktopnotifications/desktopnotificationsfactory.h \
|
||||
tools/progressbar.h
|
||||
|
||||
FORMS += \
|
||||
preferences/autofillmanager.ui \
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "locationbar.h"
|
||||
#include "clickablelabel.h"
|
||||
#include "adblockicon.h"
|
||||
#include "progressbar.h"
|
||||
|
||||
void QupZilla::postLaunch()
|
||||
{
|
||||
@ -142,8 +143,7 @@ void QupZilla::setupUi()
|
||||
m_navigation->addWidget(new QLabel()); //Elegant spacer -,-
|
||||
m_navigation->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
|
||||
m_progressBar = new QProgressBar(this);
|
||||
m_progressBar->setMaximumSize(QSize(150, 16));
|
||||
m_progressBar = new ProgressBar(statusBar());
|
||||
m_privateBrowsing = new QLabel(this);
|
||||
m_privateBrowsing->setPixmap(QPixmap(":/icons/locationbar/privatebrowsing.png"));
|
||||
m_privateBrowsing->setVisible(false);
|
||||
|
@ -48,6 +48,7 @@
|
||||
#include "clickablelabel.h"
|
||||
#include "docktitlebarwidget.h"
|
||||
#include "sidebar.h"
|
||||
#include "progressbar.h"
|
||||
|
||||
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");
|
||||
@ -58,7 +59,7 @@ const QString QupZilla::WWWADDRESS = "http://qupzilla.ic.cz";
|
||||
const QString QupZilla::WEBKITVERSION = qWebKitVersion();
|
||||
|
||||
QupZilla::QupZilla(bool tryRestore, QUrl startUrl) :
|
||||
QMainWindow()
|
||||
QMainWindow(0)
|
||||
,m_tryRestore(tryRestore)
|
||||
,m_startingUrl(startUrl)
|
||||
,m_actionPrivateBrowsing(0)
|
||||
|
@ -72,6 +72,7 @@ class MainApplication;
|
||||
class WebTab;
|
||||
class AdBlockIcon;
|
||||
class SideBar;
|
||||
class ProgressBar;
|
||||
class QupZilla : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -103,7 +104,7 @@ public:
|
||||
|
||||
inline QAction* buttonStop(){ return m_buttonStop; }
|
||||
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 QString activeProfil(){ return m_activeProfil; }
|
||||
inline QString activeLanguage(){ return m_activeLanguage; }
|
||||
@ -111,6 +112,7 @@ public:
|
||||
inline QLabel* ipLabel(){ return m_ipLabel; }
|
||||
inline QColor menuTextColor() { return m_menuTextColor; }
|
||||
inline QAction* acShowBookmarksToolbar() { return m_actionShowBookmarksToolbar; }
|
||||
inline QMenu* menuHelp() { return m_menuHelp; }
|
||||
|
||||
signals:
|
||||
void loadHistory();
|
||||
@ -242,7 +244,7 @@ private:
|
||||
QAction* m_buttonStop;
|
||||
QAction* m_buttonReload;
|
||||
QAction* m_actionExitFullscreen;
|
||||
QProgressBar* m_progressBar;
|
||||
ProgressBar* m_progressBar;
|
||||
QLabel* m_ipLabel;
|
||||
QToolBar* m_navigation;
|
||||
|
||||
|
@ -37,6 +37,7 @@ int main(int argc, char *argv[])
|
||||
std::cout << "QupZilla already running - activating existing window" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int result = app.exec();
|
||||
return result;
|
||||
}
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "rsswidget.h"
|
||||
#include "webpage.h"
|
||||
#include "bookmarkicon.h"
|
||||
#include "progressbar.h"
|
||||
|
||||
LocationBar::LocationBar(QupZilla* mainClass, QWidget* parent)
|
||||
: LineEdit(parent)
|
||||
|
@ -44,7 +44,6 @@ AboutDialog::AboutDialog(QWidget* parent) :
|
||||
|
||||
void AboutDialog::buttonClicked()
|
||||
{
|
||||
mApp->desktopNotifications()->notify(QPixmap(":qupzilla.png"), "heading","text");
|
||||
if (ui->authorsButton->text() == tr("Authors and Contributors"))
|
||||
showAuthors();
|
||||
else if (ui->authorsButton->text() == tr("< About QupZilla"))
|
||||
|
@ -27,7 +27,6 @@ Updater::Updater(QupZilla* mainClass, QObject* parent) :
|
||||
#ifndef DEVELOPING
|
||||
QTimer::singleShot(60*1000, this, SLOT(start()) ); //Start checking after 1 minute
|
||||
#endif
|
||||
QTimer::singleShot(1000, this, SLOT(start()));
|
||||
}
|
||||
|
||||
void Updater::start()
|
||||
@ -49,13 +48,21 @@ void Updater::downCompleted(QNetworkReply* reply)
|
||||
QString html = QString(reply->readAll());
|
||||
if (html.startsWith("Version:")){
|
||||
html.remove("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."));
|
||||
|
||||
if (html != QupZilla::VERSION) {
|
||||
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();
|
||||
}
|
||||
|
||||
void Updater::downloadNewVersion()
|
||||
{
|
||||
p_QupZilla->tabWidget()->addView(QUrl(QupZilla::WWWADDRESS + "/download.php"), tr("Update"), TabWidget::NewSelectedTab);
|
||||
}
|
||||
|
||||
Updater::~Updater()
|
||||
{
|
||||
}
|
||||
|
@ -33,15 +33,15 @@ public:
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
private slots:
|
||||
void downCompleted(QNetworkReply* reply);
|
||||
void start();
|
||||
void downloadNewVersion();
|
||||
|
||||
private:
|
||||
void startDownloadingUpdateInfo(const QUrl &url);
|
||||
|
||||
QupZilla* p_QupZilla;
|
||||
|
||||
};
|
||||
|
||||
#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