File indexing completed on 2025-01-05 03:59:37
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 // Own 0008 #include "TileCreatorDialog.h" 0009 #include "ui_TileCreatorDialog.h" 0010 0011 // Qt 0012 #include <QPushButton> 0013 #include <QTimer> 0014 0015 // Marble 0016 #include "TileCreator.h" 0017 0018 #include "digikam_debug.h" 0019 0020 namespace Marble 0021 { 0022 0023 class TileCreatorDialogPrivate 0024 { 0025 public: 0026 Ui::TileCreatorDialog uiWidget; 0027 0028 TileCreator *m_creator; 0029 }; 0030 0031 0032 TileCreatorDialog::TileCreatorDialog(TileCreator *creator, QWidget *parent) 0033 : QDialog(parent), 0034 d( new TileCreatorDialogPrivate ) 0035 { 0036 d->m_creator = creator; 0037 0038 d->uiWidget.setupUi(this); 0039 0040 connect( d->m_creator, SIGNAL(progress(int)), 0041 this, SLOT(setProgress(int)), Qt::QueuedConnection ); 0042 connect( d->uiWidget.buttonBox, SIGNAL(rejected()), 0043 this, SLOT(cancelTileCreation()) ); 0044 0045 // Start the creation process 0046 d->m_creator->start(); 0047 } 0048 0049 void TileCreatorDialog::cancelTileCreation() 0050 { 0051 d->uiWidget.buttonBox->button(QDialogButtonBox::Cancel)->setEnabled( false ); 0052 0053 /** @todo: Cancelling mostly crashes Marble. Fix that and uncomment below */ 0054 // d->m_creator->cancelTileCreation(); 0055 } 0056 0057 TileCreatorDialog::~TileCreatorDialog() 0058 { 0059 disconnect( d->m_creator, SIGNAL(progress(int)), 0060 this, SLOT(setProgress(int)) ); 0061 0062 if ( d->m_creator->isRunning() ) 0063 d->m_creator->cancelTileCreation(); 0064 d->m_creator->wait(); 0065 d->m_creator->deleteLater(); 0066 delete d; 0067 } 0068 0069 void TileCreatorDialog::setProgress( int progress ) 0070 { 0071 d->uiWidget.progressBar->setValue( progress ); 0072 0073 if ( progress == 100 ) 0074 { 0075 QTimer::singleShot( 0, this, SLOT(accept()) ); 0076 } 0077 } 0078 0079 void TileCreatorDialog::setSummary( const QString& name, 0080 const QString& description ) 0081 { 0082 const QString summary = QLatin1String("<b>") + name + QLatin1String("</b><br>") + description; 0083 d->uiWidget.descriptionLabel->setText( summary ); 0084 } 0085 0086 } 0087 0088 #include "moc_TileCreatorDialog.cpp"