1
mirror of https://invent.kde.org/network/falkon.git synced 2024-09-21 09:42:10 +02:00

Remove own implementation and use QProgressBar

Signed-off-by: Juraj Oravec <jurajoravec@mailo.com>
This commit is contained in:
Juraj Oravec 2024-07-22 21:42:55 +02:00
parent ed19c54ad7
commit 4483f2659e
2 changed files with 10 additions and 54 deletions

View File

@ -1,6 +1,7 @@
/* ============================================================
* Falkon - Qt web browser
* Copyright (C) 2010-2016 David Rosca <nowrep@gmail.com>
* Copyright (C) 2024 Juraj Oravec <jurajoravec@mailo.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -15,50 +16,17 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* ============================================================ */
#include "progressbar.h"
#include <QStylePainter>
#include <QStyleOptionProgressBar>
ProgressBar::ProgressBar(QWidget* parent)
: QWidget(parent)
, m_value(0)
, m_lastPaintedValue(-1)
: QProgressBar(parent)
{
setMinimumSize(130, 16);
setMaximumSize(150, 16);
}
void ProgressBar::setValue(int value)
{
m_value = value;
if (m_lastPaintedValue != m_value) {
update();
}
}
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);
QStyleOptionProgressBar opt;
initStyleOption(&opt);
paint.drawControl(QStyle::CE_ProgressBar, opt);
m_lastPaintedValue = m_value;
setMinimum(0);
setMaximum(100);
setTextVisible(false);
}

View File

@ -1,6 +1,7 @@
/* ============================================================
* Falkon - Qt web browser
* Copyright (C) 2010-2014 David Rosca <nowrep@gmail.com>
* Copyright (C) 2024 Juraj Oravec <jurajoravec@mailo.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -18,28 +19,15 @@
#ifndef PROGRESSBAR_H
#define PROGRESSBAR_H
#include <QWidget>
#include <QProgressBar>
#include "qzcommon.h"
class QStyleOptionProgressBar;
class FALKON_EXPORT ProgressBar : public QWidget
class FALKON_EXPORT ProgressBar : public QProgressBar
{
Q_OBJECT
public:
explicit ProgressBar(QWidget* parent = nullptr);
public Q_SLOTS:
void setValue(int value);
protected:
void paintEvent(QPaintEvent* e) override;
void initStyleOption(QStyleOptionProgressBar* option);
private:
int m_value;
int m_lastPaintedValue;
};
#endif // PROGRESSBAR_H