diff --git a/src/lib/tools/progressbar.cpp b/src/lib/tools/progressbar.cpp index b92622ef5..60e9eaaa0 100644 --- a/src/lib/tools/progressbar.cpp +++ b/src/lib/tools/progressbar.cpp @@ -1,6 +1,7 @@ /* ============================================================ * Falkon - Qt web browser * Copyright (C) 2010-2016 David Rosca +* Copyright (C) 2024 Juraj Oravec * * 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 . * ============================================================ */ + #include "progressbar.h" -#include -#include 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); } diff --git a/src/lib/tools/progressbar.h b/src/lib/tools/progressbar.h index 02c9ccf3f..ebfdd283a 100644 --- a/src/lib/tools/progressbar.h +++ b/src/lib/tools/progressbar.h @@ -1,6 +1,7 @@ /* ============================================================ * Falkon - Qt web browser * Copyright (C) 2010-2014 David Rosca +* Copyright (C) 2024 Juraj Oravec * * 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 +#include #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