Marble

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

KDE's Doxygen guidelines are available online.