Marble

TileCreatorDialog.cpp
1// SPDX-License-Identifier: LGPL-2.1-or-later
2//
3// SPDX-FileCopyrightText: 2006-2007 Torsten Rahn <tackat@kde.org>
4// SPDX-FileCopyrightText: 2007 Inge Wallin <ingwa@kde.org>
5//
6
7// Own
8#include "TileCreatorDialog.h"
9
10// Qt
11#include <QPushButton>
12#include <QTimer>
13
14// Marble
15#include "MarbleDebug.h"
16#include "TileCreator.h"
17
18#include "ui_TileCreatorDialog.h"
19
20namespace Marble
21{
22
23class TileCreatorDialogPrivate
24{
25public:
26 Ui::TileCreatorDialog uiWidget;
27
28 TileCreator *m_creator = nullptr;
29};
30
31TileCreatorDialog::TileCreatorDialog(TileCreator *creator, QWidget *parent)
32 : QDialog(parent)
33 , d(new TileCreatorDialogPrivate)
34{
35 d->m_creator = creator;
36
37 d->uiWidget.setupUi(this);
38
39 connect(d->m_creator, &TileCreator::progress, this, &TileCreatorDialog::setProgress, Qt::QueuedConnection);
40 connect(d->uiWidget.buttonBox, &QDialogButtonBox::rejected, this, &TileCreatorDialog::cancelTileCreation);
41
42 // Start the creation process
43 d->m_creator->start();
44}
45
46void TileCreatorDialog::cancelTileCreation()
47{
48 d->uiWidget.buttonBox->button(QDialogButtonBox::Cancel)->setEnabled(false);
49
50 /** @todo: Cancelling mostly crashes Marble. Fix that and uncomment below */
51 // d->m_creator->cancelTileCreation();
52}
53
54TileCreatorDialog::~TileCreatorDialog()
55{
56 disconnect(d->m_creator, SIGNAL(progress(int)), this, SLOT(setProgress(int)));
57
58 if (d->m_creator->isRunning())
59 d->m_creator->cancelTileCreation();
60 d->m_creator->wait();
61 d->m_creator->deleteLater();
62 delete d;
63}
64
65void TileCreatorDialog::setProgress(int progress)
66{
67 d->uiWidget.progressBar->setValue(progress);
68
69 if (progress == 100) {
70 QTimer::singleShot(0, this, SLOT(accept()));
71 }
72}
73
74void TileCreatorDialog::setSummary(const QString &name, const QString &description)
75{
76 const QString summary = QLatin1StringView("<b>") + QCoreApplication::translate("DGML", name.toUtf8().constData()) + QLatin1StringView("</b><br>")
77 + QCoreApplication::translate("DGML", description.toUtf8().constData());
78 d->uiWidget.descriptionLabel->setText(summary);
79}
80
81}
82
83#include "moc_TileCreatorDialog.cpp"
QString name(StandardAction id)
Binds a QML item to a specific geodetic location in screen coordinates.
const char * constData() const const
QString translate(const char *context, const char *sourceText, const char *disambiguation, int n)
QByteArray toUtf8() const const
QueuedConnection
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
void setupUi(QWidget *widget)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 20 2024 11:52:13 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.