File indexing completed on 2024-04-28 05:46:35
0001 /* 0002 SPDX-FileCopyrightText: 2010 Volker Lanz <vl@fidra.de> 0003 SPDX-FileCopyrightText: 2014-2018 Andrius Štikonas <andrius@stikonas.eu> 0004 0005 SPDX-License-Identifier: GPL-3.0-or-later 0006 */ 0007 0008 #include "gui/scanprogressdialog.h" 0009 #include <KLocalizedString> 0010 #include <QCloseEvent> 0011 #include <QProgressBar> 0012 0013 ScanProgressDialog::ScanProgressDialog(QWidget* parent) : 0014 QProgressDialog(parent) 0015 { 0016 setWindowTitle(xi18nc("@title:window", "Scanning Devices…")); 0017 setMinimumWidth(280); 0018 setMinimumDuration(150); 0019 setValue(0); 0020 setAttribute(Qt::WA_ShowModal, true); 0021 0022 QProgressBar* progressBar = findProgressBar(); 0023 if (progressBar) { 0024 progressBar->setFormat(i18nc("%p is the percent value, % is the percent sign", "%p%")); 0025 } 0026 } 0027 0028 void ScanProgressDialog::closeEvent(QCloseEvent* e) 0029 { 0030 e->ignore(); 0031 } 0032 0033 void ScanProgressDialog::setDeviceName(const QString& device) 0034 { 0035 if (device.isEmpty()) { 0036 setLabelText(xi18nc("@label", "Scanning…")); 0037 } else { 0038 setLabelText(xi18nc("@label", "Scanning device: <filename>%1</filename>", device)); 0039 } 0040 } 0041 0042 void ScanProgressDialog::showEvent(QShowEvent* e) 0043 { 0044 setCancelButton(nullptr); 0045 QProgressDialog::showEvent(e); 0046 } 0047 0048 QProgressBar* ScanProgressDialog::findProgressBar() 0049 { 0050 auto children = findChildren<QProgressBar*>(); 0051 return children.isEmpty() ? nullptr : children.first(); 0052 }