File indexing completed on 2024-05-05 03:50:38
0001 // SPDX-License-Identifier: LGPL-2.1-or-later 0002 // 0003 // SPDX-FileCopyrightText: 2013 Adrian Draghici <draghici.adrian.b@gmail.com> 0004 // 0005 0006 // Self 0007 #include "EditGroundOverlayDialog.h" 0008 #include "ui_EditGroundOverlayDialog.h" 0009 0010 // Qt 0011 #include <QFileDialog> 0012 #include <QMessageBox> 0013 #include <QPushButton> 0014 0015 //Marble 0016 #include "FormattedTextWidget.h" 0017 #include "GeoDataGroundOverlay.h" 0018 #include "TextureLayer.h" 0019 0020 namespace Marble 0021 { 0022 0023 class Q_DECL_HIDDEN EditGroundOverlayDialog::Private : public Ui::UiEditGroundOverlayDialog 0024 { 0025 0026 public: 0027 GeoDataGroundOverlay *m_overlay; 0028 TextureLayer *m_textureLayer; 0029 0030 Private( GeoDataGroundOverlay *overlay, TextureLayer *textureLayer ); 0031 ~Private(); 0032 0033 void updateCoordinates(); 0034 }; 0035 0036 EditGroundOverlayDialog::Private::Private( GeoDataGroundOverlay *overlay, TextureLayer *textureLayer ) : 0037 Ui::UiEditGroundOverlayDialog(), 0038 m_overlay( overlay ), 0039 m_textureLayer( textureLayer ) 0040 { 0041 // nothing to do 0042 } 0043 0044 EditGroundOverlayDialog::Private::~Private() 0045 { 0046 // nothing to do 0047 } 0048 0049 EditGroundOverlayDialog::EditGroundOverlayDialog( GeoDataGroundOverlay *overlay, 0050 TextureLayer *textureLayer, 0051 QWidget *parent ) : 0052 QDialog( parent ), 0053 d( new Private( overlay, textureLayer ) ) 0054 { 0055 d->setupUi( this ); 0056 0057 d->m_header->setName( overlay->name() ); 0058 d->m_header->setIconLink( overlay->absoluteIconFile() ); 0059 d->m_header->setPositionVisible(false); 0060 d->m_formattedTextWidget->setText( overlay->description() ); 0061 0062 d->m_north->setRange( -90, 90 ); 0063 d->m_south->setRange( -90, 90 ); 0064 d->m_west->setRange( -180, 180 ); 0065 d->m_east->setRange( -180, 180 ); 0066 d->m_rotation->setRange( -360, 360 ); 0067 0068 GeoDataLatLonBox latLonBox = overlay->latLonBox(); 0069 d->m_north->setValue( latLonBox.north( GeoDataCoordinates::Degree ) ); 0070 d->m_south->setValue( latLonBox.south( GeoDataCoordinates::Degree ) ); 0071 d->m_west->setValue( latLonBox.west( GeoDataCoordinates::Degree ) ); 0072 d->m_east->setValue( latLonBox.east( GeoDataCoordinates::Degree ) ); 0073 d->m_rotation->setValue( latLonBox.rotation( GeoDataCoordinates::Degree ) ); 0074 0075 connect( d->buttonBox->button( QDialogButtonBox::Ok ), SIGNAL(pressed()), this, SLOT(checkFields()) ); 0076 } 0077 0078 EditGroundOverlayDialog::~EditGroundOverlayDialog() 0079 { 0080 delete d; 0081 } 0082 0083 void EditGroundOverlayDialog::updateGroundOverlay() 0084 { 0085 d->m_overlay->setName( d->m_header->name() ); 0086 d->m_overlay->setIconFile( d->m_header->iconLink() ); 0087 d->m_overlay->setDescription( d->m_formattedTextWidget->text() ); 0088 0089 d->m_overlay->latLonBox().setBoundaries( d->m_north->value(), 0090 d->m_south->value(), 0091 d->m_east->value(), 0092 d->m_west->value(), 0093 GeoDataCoordinates::Degree ); 0094 0095 d->m_overlay->latLonBox().setRotation( d->m_rotation->value(), GeoDataCoordinates::Degree ); 0096 } 0097 0098 void EditGroundOverlayDialog::setGroundOverlayUpdated() 0099 { 0100 emit groundOverlayUpdated( d->m_overlay ); 0101 } 0102 0103 void EditGroundOverlayDialog::checkFields() 0104 { 0105 if ( d->m_header->name().isEmpty() ) { 0106 QMessageBox::warning( this, 0107 tr( "No name specified" ), 0108 tr( "Please specify a name for this ground overlay." ) ); 0109 } else if ( d->m_header->iconLink().isEmpty() ) { 0110 QMessageBox::warning( this, 0111 tr( "No image specified" ), 0112 tr( "Please specify an image file." ) ); 0113 } else if( !QFileInfo( d->m_header->iconLink() ).exists() ) { 0114 QMessageBox::warning( this, 0115 tr( "Invalid image path" ), 0116 tr( "Please specify a valid path for the image file." ) ); 0117 } else { 0118 this->updateGroundOverlay(); 0119 this->setGroundOverlayUpdated(); 0120 d->m_textureLayer->reset(); 0121 accept(); 0122 } 0123 } 0124 0125 } 0126 0127 #include "moc_EditGroundOverlayDialog.cpp"