| 1 | /* |
| 2 | This file is part of the KDE project |
| 3 | SPDX-FileCopyrightText: 2003 Waldo Bastian <bastian@kde.org> |
| 4 | |
| 5 | SPDX-License-Identifier: LGPL-2.0-only |
| 6 | */ |
| 7 | #include "kbuildsycocaprogressdialog.h" |
| 8 | #include "kio_widgets_debug.h" |
| 9 | |
| 10 | #include <KLocalizedString> |
| 11 | #include <KSycoca> |
| 12 | |
| 13 | #include <QDialogButtonBox> |
| 14 | #include <QProcess> |
| 15 | #include <QStandardPaths> |
| 16 | |
| 17 | class KBuildSycocaProgressDialogPrivate |
| 18 | { |
| 19 | public: |
| 20 | explicit KBuildSycocaProgressDialogPrivate(KBuildSycocaProgressDialog *parent) |
| 21 | : m_parent(parent) |
| 22 | { |
| 23 | } |
| 24 | |
| 25 | KBuildSycocaProgressDialog *const m_parent; |
| 26 | }; |
| 27 | |
| 28 | void KBuildSycocaProgressDialog::rebuildKSycoca(QWidget *parent) |
| 29 | { |
| 30 | KBuildSycocaProgressDialog dlg(parent, i18n("Updating System Configuration" ), i18n("Updating system configuration…" )); |
| 31 | |
| 32 | const QString exec = QStandardPaths::findExecutable(QStringLiteral(KBUILDSYCOCA_EXENAME)); |
| 33 | if (exec.isEmpty()) { |
| 34 | qCWarning(KIO_WIDGETS) << "Could not find kbuildsycoca executable:" << KBUILDSYCOCA_EXENAME; |
| 35 | return; |
| 36 | } |
| 37 | QProcess *proc = new QProcess(&dlg); |
| 38 | proc->start(program: exec, arguments: QStringList()); |
| 39 | QObject::connect(sender: proc, signal: &QProcess::finished, context: &dlg, slot: &QWidget::close); |
| 40 | |
| 41 | dlg.exec(); |
| 42 | } |
| 43 | |
| 44 | KBuildSycocaProgressDialog::KBuildSycocaProgressDialog(QWidget *_parent, const QString &title, const QString &text) |
| 45 | : QProgressDialog(_parent) |
| 46 | , d(new KBuildSycocaProgressDialogPrivate(this)) |
| 47 | { |
| 48 | setWindowTitle(title); |
| 49 | setModal(true); |
| 50 | setLabelText(text); |
| 51 | setRange(minimum: 0, maximum: 0); |
| 52 | setAutoClose(false); |
| 53 | QDialogButtonBox *dialogButtonBox = new QDialogButtonBox(QDialogButtonBox::Cancel, this); |
| 54 | setCancelButton(dialogButtonBox->button(which: QDialogButtonBox::Cancel)); |
| 55 | } |
| 56 | |
| 57 | KBuildSycocaProgressDialog::~KBuildSycocaProgressDialog() = default; |
| 58 | |
| 59 | #include "moc_kbuildsycocaprogressdialog.cpp" |
| 60 | |