mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 10:46:35 +01:00
Remove own implementation and use QProgressBar
Signed-off-by: Juraj Oravec <jurajoravec@mailo.com>
This commit is contained in:
parent
ed19c54ad7
commit
4483f2659e
@ -1,6 +1,7 @@
|
|||||||
/* ============================================================
|
/* ============================================================
|
||||||
* Falkon - Qt web browser
|
* Falkon - Qt web browser
|
||||||
* Copyright (C) 2010-2016 David Rosca <nowrep@gmail.com>
|
* 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
|
* 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
|
* 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
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
* ============================================================ */
|
* ============================================================ */
|
||||||
|
|
||||||
#include "progressbar.h"
|
#include "progressbar.h"
|
||||||
|
|
||||||
#include <QStylePainter>
|
|
||||||
#include <QStyleOptionProgressBar>
|
|
||||||
|
|
||||||
ProgressBar::ProgressBar(QWidget* parent)
|
ProgressBar::ProgressBar(QWidget* parent)
|
||||||
: QWidget(parent)
|
: QProgressBar(parent)
|
||||||
, m_value(0)
|
|
||||||
, m_lastPaintedValue(-1)
|
|
||||||
{
|
{
|
||||||
setMinimumSize(130, 16);
|
setMinimumSize(130, 16);
|
||||||
setMaximumSize(150, 16);
|
setMaximumSize(150, 16);
|
||||||
}
|
|
||||||
|
setMinimum(0);
|
||||||
void ProgressBar::setValue(int value)
|
setMaximum(100);
|
||||||
{
|
setTextVisible(false);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
/* ============================================================
|
/* ============================================================
|
||||||
* Falkon - Qt web browser
|
* Falkon - Qt web browser
|
||||||
* Copyright (C) 2010-2014 David Rosca <nowrep@gmail.com>
|
* 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
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -18,28 +19,15 @@
|
|||||||
#ifndef PROGRESSBAR_H
|
#ifndef PROGRESSBAR_H
|
||||||
#define PROGRESSBAR_H
|
#define PROGRESSBAR_H
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QProgressBar>
|
||||||
|
|
||||||
#include "qzcommon.h"
|
#include "qzcommon.h"
|
||||||
|
|
||||||
class QStyleOptionProgressBar;
|
class FALKON_EXPORT ProgressBar : public QProgressBar
|
||||||
|
|
||||||
class FALKON_EXPORT ProgressBar : public QWidget
|
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit ProgressBar(QWidget* parent = nullptr);
|
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
|
#endif // PROGRESSBAR_H
|
||||||
|
Loading…
Reference in New Issue
Block a user