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 <QDBusConnection> |
14 | #include <QDBusInterface> |
15 | #include <QDialogButtonBox> |
16 | #include <QProcess> |
17 | #include <QStandardPaths> |
18 | |
19 | class KBuildSycocaProgressDialogPrivate |
20 | { |
21 | public: |
22 | explicit KBuildSycocaProgressDialogPrivate(KBuildSycocaProgressDialog *parent) |
23 | : m_parent(parent) |
24 | { |
25 | } |
26 | |
27 | KBuildSycocaProgressDialog *const m_parent; |
28 | }; |
29 | |
30 | void KBuildSycocaProgressDialog::rebuildKSycoca(QWidget *parent) |
31 | { |
32 | KBuildSycocaProgressDialog dlg(parent, i18n("Updating System Configuration" ), i18n("Updating system configuration…" )); |
33 | |
34 | const QString exec = QStandardPaths::findExecutable(QStringLiteral(KBUILDSYCOCA_EXENAME)); |
35 | if (exec.isEmpty()) { |
36 | qCWarning(KIO_WIDGETS) << "Could not find kbuildsycoca executable:" << KBUILDSYCOCA_EXENAME; |
37 | return; |
38 | } |
39 | QProcess *proc = new QProcess(&dlg); |
40 | proc->start(program: exec, arguments: QStringList()); |
41 | QObject::connect(sender: proc, signal: &QProcess::finished, context: &dlg, slot: &QWidget::close); |
42 | |
43 | dlg.exec(); |
44 | } |
45 | |
46 | KBuildSycocaProgressDialog::KBuildSycocaProgressDialog(QWidget *_parent, const QString &title, const QString &text) |
47 | : QProgressDialog(_parent) |
48 | , d(new KBuildSycocaProgressDialogPrivate(this)) |
49 | { |
50 | setWindowTitle(title); |
51 | setModal(true); |
52 | setLabelText(text); |
53 | setRange(minimum: 0, maximum: 0); |
54 | setAutoClose(false); |
55 | QDialogButtonBox *dialogButtonBox = new QDialogButtonBox(QDialogButtonBox::Cancel, this); |
56 | setCancelButton(dialogButtonBox->button(which: QDialogButtonBox::Cancel)); |
57 | } |
58 | |
59 | KBuildSycocaProgressDialog::~KBuildSycocaProgressDialog() = default; |
60 | |
61 | #include "moc_kbuildsycocaprogressdialog.cpp" |
62 | |