File indexing completed on 2024-04-14 03:48:08
0001 // SPDX-License-Identifier: LGPL-2.1-or-later 0002 // 0003 // SPDX-FileCopyrightText: 2006-2007 Torsten Rahn <tackat@kde.org> 0004 // SPDX-FileCopyrightText: 2007 Inge Wallin <ingwa@kde.org> 0005 // 0006 0007 0008 // Own 0009 #include "TileCreatorDialog.h" 0010 0011 // Qt 0012 #include <QPushButton> 0013 #include <QTimer> 0014 0015 // Marble 0016 #include "MarbleDebug.h" 0017 #include "TileCreator.h" 0018 0019 #include "ui_TileCreatorDialog.h" 0020 0021 namespace Marble 0022 { 0023 0024 class TileCreatorDialogPrivate 0025 { 0026 public: 0027 Ui::TileCreatorDialog uiWidget; 0028 0029 TileCreator *m_creator; 0030 }; 0031 0032 0033 TileCreatorDialog::TileCreatorDialog(TileCreator *creator, QWidget *parent) 0034 : QDialog(parent), 0035 d( new TileCreatorDialogPrivate ) 0036 { 0037 d->m_creator = creator; 0038 0039 d->uiWidget.setupUi(this); 0040 0041 connect( d->m_creator, SIGNAL(progress(int)), 0042 this, SLOT(setProgress(int)), Qt::QueuedConnection ); 0043 connect( d->uiWidget.buttonBox, SIGNAL(rejected()), 0044 this, SLOT(cancelTileCreation()) ); 0045 0046 // Start the creation process 0047 d->m_creator->start(); 0048 } 0049 0050 void TileCreatorDialog::cancelTileCreation() 0051 { 0052 d->uiWidget.buttonBox->button(QDialogButtonBox::Cancel)->setEnabled( false ); 0053 0054 /** @todo: Cancelling mostly crashes Marble. Fix that and uncomment below */ 0055 // d->m_creator->cancelTileCreation(); 0056 } 0057 0058 TileCreatorDialog::~TileCreatorDialog() 0059 { 0060 disconnect( d->m_creator, SIGNAL(progress(int)), 0061 this, SLOT(setProgress(int)) ); 0062 0063 if ( d->m_creator->isRunning() ) 0064 d->m_creator->cancelTileCreation(); 0065 d->m_creator->wait(); 0066 d->m_creator->deleteLater(); 0067 delete d; 0068 } 0069 0070 void TileCreatorDialog::setProgress( int progress ) 0071 { 0072 d->uiWidget.progressBar->setValue( progress ); 0073 0074 if ( progress == 100 ) 0075 { 0076 QTimer::singleShot( 0, this, SLOT(accept()) ); 0077 } 0078 } 0079 0080 void TileCreatorDialog::setSummary( const QString& name, 0081 const QString& description ) 0082 { 0083 const QString summary = QLatin1String("<b>") + QCoreApplication::translate("DGML", name.toUtf8().constData()) + QLatin1String("</b><br>") + QCoreApplication::translate("DGML", description.toUtf8().constData()); 0084 d->uiWidget.descriptionLabel->setText( summary ); 0085 } 0086 0087 } 0088 0089 #include "moc_TileCreatorDialog.cpp"