File indexing completed on 2024-12-22 05:01:00
0001 /* 0002 * 0003 * SPDX-FileCopyrightText: 2006 Till Adam <adam@kde.org> 0004 * SPDX-FileCopyrightText: 2012-2024 Laurent Montel <montel@kde.org> 0005 * 0006 * SPDX-License-Identifier: GPL-2.0-only 0007 */ 0008 0009 #include "collectionquotawidget.h" 0010 0011 #include <KIO/Global> 0012 #include <KLocalizedString> 0013 #include <QGridLayout> 0014 #include <QLabel> 0015 #include <QProgressBar> 0016 0017 CollectionQuotaWidget::CollectionQuotaWidget(QWidget *parent) 0018 : QWidget(parent) 0019 , mProgressBar(new QProgressBar(this)) 0020 , mUsage(new QLabel(this)) 0021 { 0022 auto layout = new QGridLayout(this); 0023 0024 auto lab = new QLabel(i18n("Usage:"), this); 0025 layout->addWidget(lab, 0, 0); 0026 0027 mUsage->setTextFormat(Qt::PlainText); 0028 layout->addWidget(mUsage, 0, 1); 0029 0030 auto Status = new QLabel(i18n("Status:"), this); 0031 layout->addWidget(Status, 1, 0); 0032 // xgettext: no-c-format 0033 mProgressBar->setFormat(i18n("%p% full")); 0034 layout->addWidget(mProgressBar, 1, 1); 0035 layout->setRowStretch(2, 1); 0036 } 0037 0038 void CollectionQuotaWidget::setQuotaInfo(qint64 current, qint64 maxValue) 0039 { 0040 const int perc = qBound(0, qRound(100.0 * current / qMax(1LL, maxValue)), 100); 0041 mProgressBar->setValue(perc); 0042 mUsage->setText(i18n("%1 of %2 used", KIO::convertSize(qMax(0LL, current)), KIO::convertSize(qMax(0LL, maxValue)))); 0043 } 0044 0045 #include "moc_collectionquotawidget.cpp"