| 1 | // For license of this file, see <project-root-folder>/LICENSE.md.cxx . . $ `<file>/src/librssguard/gui/reusable/progressbarwithtext.cpp`/ |
| 2 | |
| 3 | #include "gui/reusable/progressbarwithtext.h"cxx . . $ `<file>/src/librssguard/gui/reusable/progressbarwithtext.h`/ |
| 4 | |
| 5 | #include "definitions/definitions.h"cxx . . $ `<file>/src/librssguard/definitions/definitions.h`/ |
| 6 | |
| 7 | #include <QLocale> |
| 8 | |
| 9 | ProgressBarWithTextcxx . . $ ProgressBarWithText#::ProgressBarWithTextcxx . . $ ProgressBarWithText#ProgressBarWithText(108f35f7aa7f3cf9).(QWidgetcxx . . $ QWidget#* parent) : QProgressBarcxx . . $ QProgressBar#(parent) {} |
| 10 | |
| 11 | QStringcxx . . $ QString# ProgressBarWithTextcxx . . $ ProgressBarWithText#::textcxx . . $ ProgressBarWithText#text(6ef7b6c27b00b43d).() const { |
| 12 | qint64cxx . . $ qint64# total_steps = qint64cxx . . $ qint64#(maximumcxx . . $ QProgressBar#maximum(455f465bc33b4cdf).()) - minimumcxx . . $ QProgressBar#minimum(455f465bc33b4cdf).(); |
| 13 | QStringcxx . . $ QString# result = formatcxx . . $ QProgressBar#format(6ef7b6c27b00b43d).(); |
| 14 | QLocalecxx . . $ QLocale# localecxx . . $ QLocale#QLocale(49f6e7a06ebc5aa8).; |
| 15 | |
| 16 | locale.setNumberOptionscxx . . $ QLocale#setNumberOptions(cdbc00fe8d4f9ca4).(locale.numberOptionscxx . . $ QLocale#numberOptions(6d95a6375c8d6e4d).() |cxx . . $ QFlags#`operator|`(2cc1994e0be6f18e). QLocalecxx . . $ QLocale#::OmitGroupSeparatorcxx . . $ QLocale#OmitGroupSeparator.); |
| 17 | result.replacecxx . . $ QString#replace(8efa7599e214252).(QL1Scxx . . $ `src/librssguard/definitions/definitions.h:449:9`!("%m"), locale.toStringcxx . . $ QLocale#toString(61209c1a5e78d47d).(total_steps)); |
| 18 | result.replacecxx . . $ QString#replace(8efa7599e214252).(QL1Scxx . . $ `src/librssguard/definitions/definitions.h:449:9`!("%v"), locale.toStringcxx . . $ QLocale#toString(3f3c3d0e9c0eb37f).(valuecxx . . $ QProgressBar#value(455f465bc33b4cdf).())); |
| 19 | |
| 20 | // If max and min are equal and we get this far, it means that the |
| 21 | // progress bar has one step and that we are on that step. Return |
| 22 | // 100% here in order to avoid division by zero further down. |
| 23 | if (total_steps == 0) { |
| 24 | result.replacecxx . . $ QString#replace(8efa7599e214252).(QL1Scxx . . $ `src/librssguard/definitions/definitions.h:449:9`!("%p"), locale.toStringcxx . . $ QLocale#toString(3f3c3d0e9c0eb37f).(100)); |
| 25 | return resultcxx . . $ QString#QString(28715ad661ad3cec).; |
| 26 | } |
| 27 | |
| 28 | const auto progress = static_cast<int>((qint64cxx . . $ qint64#(valuecxx . . $ QProgressBar#value(455f465bc33b4cdf).()) - minimumcxx . . $ QProgressBar#minimum(455f465bc33b4cdf).()) * 100.0 / total_steps); |
| 29 | |
| 30 | result.replacecxx . . $ QString#replace(8efa7599e214252).(QL1Scxx . . $ `src/librssguard/definitions/definitions.h:449:9`!("%p"), locale.toStringcxx . . $ QLocale#toString(3f3c3d0e9c0eb37f).(progress)); |
| 31 | |
| 32 | // Now, shorten the text to fit the widget. |
| 33 | bool elide = false; |
| 34 | |
| 35 | while (fontMetricscxx . . $ QWidget#fontMetrics(ee264e9e8967f9a7).().boundingRectcxx . . $ QFontMetrics#boundingRect(d8b0a2d97d69e4b8).(result + QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!("...")).widthcxx . . $ QRect#width(ea6fe5115c70a13f).() > widthcxx . . $ QWidget#width(455f465bc33b4cdf).() - 30) { |
| 36 | result.chopcxx . . $ QString#chop(35cb52607f6af42f).(1); |
| 37 | elide = true; |
| 38 | } |
| 39 | |
| 40 | return elide ? result + QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!("...") : resultcxx . . $ QString#QString(132dd6869045752b).; |
| 41 | } |