File indexing completed on 2025-02-16 04:32:00
0001 /* 0002 SPDX-FileCopyrightText: 2016 Jean-Baptiste Mardelle <jb@kdenlive.org> 0003 This file is part of Kdenlive. See www.kdenlive.org. 0004 0005 SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0006 */ 0007 0008 #pragma once 0009 0010 #include <QElapsedTimer> 0011 #include <QStyleOptionToolButton> 0012 #include <QToolButton> 0013 0014 class QAction; 0015 0016 /** @class ProgressButton 0017 @brief A Toolbar button with a small progress bar. 0018 */ 0019 class ProgressButton : public QToolButton 0020 { 0021 Q_PROPERTY(int progress READ progress WRITE setProgress NOTIFY progressChanged) 0022 Q_OBJECT 0023 public: 0024 explicit ProgressButton(const QString &text, double max = 100, QWidget *parent = nullptr); 0025 ~ProgressButton() override; 0026 int progress() const; 0027 void setProgress(int); 0028 void defineDefaultAction(QAction *action, QAction *actionInProgress); 0029 0030 protected: 0031 void paintEvent(QPaintEvent *event) override; 0032 0033 private: 0034 QAction *m_defaultAction; 0035 int m_max; 0036 int m_progress; 0037 QElapsedTimer m_timer; 0038 QString m_remainingTime; 0039 int m_iconSize; 0040 QFont m_progressFont; 0041 QStyleOptionToolButton m_buttonStyle; 0042 /** @brief While rendering, replace real action by a fake on so that rendering is not triggered when clicking again. */ 0043 QAction *m_dummyAction; 0044 0045 Q_SIGNALS: 0046 void progressChanged(); 0047 };