summaryrefslogtreecommitdiffstats
path: root/src/widgets/widgets/qprogressbar.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets/widgets/qprogressbar.cpp')
-rw-r--r--src/widgets/widgets/qprogressbar.cpp65
1 files changed, 15 insertions, 50 deletions
diff --git a/src/widgets/widgets/qprogressbar.cpp b/src/widgets/widgets/qprogressbar.cpp
index e2d4875f54..79cdecd22a 100644
--- a/src/widgets/widgets/qprogressbar.cpp
+++ b/src/widgets/widgets/qprogressbar.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtWidgets module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qprogressbar.h"
@@ -45,13 +9,15 @@
#include <qstylepainter.h>
#include <qstyleoption.h>
#include <private/qwidget_p.h>
-#ifndef QT_NO_ACCESSIBILITY
+#if QT_CONFIG(accessibility)
#include <qaccessible.h>
#endif
#include <limits.h>
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
class QProgressBarPrivate : public QWidgetPrivate
{
Q_DECLARE_PUBLIC(QProgressBar)
@@ -89,7 +55,7 @@ QProgressBarPrivate::QProgressBarPrivate()
void QProgressBarPrivate::initDefaultFormat()
{
if (defaultFormat)
- format = QLatin1String("%p") + locale.percent();
+ format = "%p"_L1 + locale.percent();
}
void QProgressBarPrivate::init()
@@ -152,10 +118,9 @@ bool QProgressBarPrivate::repaintRequired() const
const auto totalSteps = qint64(maximum) - minimum;
if (textVisible) {
- if ((format.contains(QLatin1String("%v"))))
+ if (format.contains("%v"_L1))
return true;
- if ((format.contains(QLatin1String("%p"))
- && valueDifference >= qAbs(totalSteps / 100)))
+ if (format.contains("%p"_L1) && valueDifference >= qAbs(totalSteps / 100))
return true;
}
@@ -201,7 +166,7 @@ bool QProgressBarPrivate::repaintRequired() const
example, when using QNetworkAccessManager to download items when
they are unable to determine the size of the item being downloaded.
- \sa QProgressDialog, {fowler}{GUI Design Handbook: Progress Indicator}
+ \sa QProgressDialog
*/
/*!
@@ -318,7 +283,7 @@ void QProgressBar::setValue(int value)
return;
d->value = value;
emit valueChanged(value);
-#ifndef QT_NO_ACCESSIBILITY
+#if QT_CONFIG(accessibility)
if (isVisible()) {
QAccessibleValueChangeEvent event(this, value);
QAccessible::updateAccessibility(&event);
@@ -422,7 +387,7 @@ QSize QProgressBar::sizeHint() const
QStyleOptionProgressBar opt;
initStyleOption(&opt);
int cw = style()->pixelMetric(QStyle::PM_ProgressBarChunkWidth, &opt, this);
- QSize size = QSize(qMax(9, cw) * 7 + fm.horizontalAdvance(QLatin1Char('0')) * 4, fm.height() + 8);
+ QSize size = QSize(qMax(9, cw) * 7 + fm.horizontalAdvance(u'0') * 4, fm.height() + 8);
if (!(opt.state & QStyle::State_Horizontal))
size = size.transposed();
return style()->sizeFromContents(QStyle::CT_ProgressBar, &opt, size, this);
@@ -468,19 +433,19 @@ QString QProgressBar::text() const
QString result = d->format;
QLocale locale = d->locale; // Omit group separators for compatibility with previous versions that were non-localized.
locale.setNumberOptions(locale.numberOptions() | QLocale::OmitGroupSeparator);
- result.replace(QLatin1String("%m"), locale.toString(totalSteps));
- result.replace(QLatin1String("%v"), locale.toString(d->value));
+ result.replace("%m"_L1, locale.toString(totalSteps));
+ result.replace("%v"_L1, locale.toString(d->value));
// If max and min are equal and we get this far, it means that the
// progress bar has one step and that we are on that step. Return
// 100% here in order to avoid division by zero further down.
if (totalSteps == 0) {
- result.replace(QLatin1String("%p"), locale.toString(100));
+ result.replace("%p"_L1, locale.toString(100));
return result;
}
const auto progress = static_cast<int>((qint64(d->value) - d->minimum) * 100.0 / totalSteps);
- result.replace(QLatin1String("%p"), locale.toString(progress));
+ result.replace("%p"_L1, locale.toString(progress));
return result;
}