Libkleo

progressdialog.cpp
1/*
2 progressdialog.cpp
3
4 This file is part of libkleopatra, the KDE keymanagement library
5 SPDX-FileCopyrightText: 2004 Klarälvdalens Datakonsult AB
6
7 SPDX-License-Identifier: GPL-2.0-or-later
8*/
9
10#include <config-libkleo.h>
11
12#include "progressdialog.h"
13
14#ifndef QT_NO_PROGRESSDIALOG
15
16#include "progressbar.h"
17
18#include <kleo_ui_debug.h>
19
20#include <KLocalizedString>
21
22#include <QTimer>
23
24Kleo::ProgressDialog::ProgressDialog(QGpgME::Job *job, const QString &baseText, QWidget *creator, Qt::WindowFlags f)
25 : QProgressDialog(creator, f)
26 , mBaseText(baseText)
27{
28 Q_ASSERT(job);
29 setBar(new ProgressBar(this /*, "replacement progressbar in Kleo::ProgressDialog"*/));
30
31 setMinimumDuration(2000 /*ms*/);
32 setAutoReset(false);
33 setAutoClose(false);
34 setLabelText(baseText);
35 setModal(false);
36 setRange(0, 0); // activate busy indicator
37
38 if (!connect(job, &QGpgME::Job::jobProgress, this, &ProgressDialog::slotProgress)) {
39 qCWarning(KLEO_UI_LOG) << "new-style connect failed; connecting to QGpgME::Job::jobProgress the old way";
40 connect(job, SIGNAL(jobProgress(int, int)), this, SLOT(slotProgress(int, int)));
41 }
42 if (!connect(job, &QGpgME::Job::done, this, &ProgressDialog::slotDone)) {
43 qCWarning(KLEO_UI_LOG) << "new-style connect failed; connecting to QGpgME::Job::done the old way";
44 connect(job, SIGNAL(done()), this, SLOT(slotDone()));
45 }
46 connect(this, &QProgressDialog::canceled, job, &QGpgME::Job::slotCancel);
47
48 QTimer::singleShot(minimumDuration(), this, &ProgressDialog::forceShow);
49}
50
51Kleo::ProgressDialog::~ProgressDialog()
52{
53}
54
56{
57 if (0 < ms && ms < minimumDuration()) {
59 }
61}
62
63void Kleo::ProgressDialog::slotProgress(int current, int total)
64{
65 qCDebug(KLEO_UI_LOG) << "Kleo::ProgressDialog::slotProgress(" << current << "," << total << ")";
66 setRange(current, total);
67}
68
69void Kleo::ProgressDialog::slotDone()
70{
71 qCDebug(KLEO_UI_LOG) << "Kleo::ProgressDialog::slotDone()";
72 hide();
73 deleteLater();
74}
75
76#endif // QT_NO_PROGRESSDIALOG
77
78#include "moc_progressdialog.cpp"
void setMinimumDuration(int ms)
void setMinimumDuration(int ms)
typedef WindowFlags
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:14:12 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.