File indexing completed on 2024-04-21 03:49:59

0001 // SPDX-License-Identifier: LGPL-2.1-or-later
0002 //
0003 // SPDX-FileCopyrightText: 2008 David Roberts <dvdr18@gmail.com>
0004 // SPDX-FileCopyrightText: 2008 Inge Wallin <inge@lysator.liu.se>
0005 // SPDX-FileCopyrightText: 2010 Harshit Jain <hjain.itbhu@gmail.com>
0006 // SPDX-FileCopyrightText: 2012 Mohammed Nafees <nafees.technocool@gmail.com>
0007 //
0008 
0009 // Own
0010 #include "SunControlWidget.h"
0011 #include "ui_SunControlWidget.h"
0012 
0013 // Qt
0014 #include <QPushButton>
0015 #include <QShowEvent>
0016 
0017 // Marble
0018 #include "MarbleDebug.h"
0019 #include "MarbleWidget.h"
0020 
0021 using namespace Marble;
0022 /* TRANSLATOR Marble::SunControlWidget */
0023 
0024 SunControlWidget::SunControlWidget( MarbleWidget* marbleWidget, QWidget* parent )
0025     : QDialog( parent ),
0026       m_uiWidget( new Ui::SunControlWidget ),
0027       m_marbleWidget( marbleWidget ),
0028       m_shadow( "shadow" )
0029 {
0030     m_uiWidget->setupUi( this );
0031 
0032     m_uiWidget->lockWarningLabel->hide();
0033     
0034     connect( m_uiWidget->buttonBox->button(QDialogButtonBox::Apply), SIGNAL(clicked()), this, SLOT(apply()) );
0035     connect( m_uiWidget->buttonBox, SIGNAL(rejected()), this, SLOT(reject()) );
0036     connect( m_uiWidget->buttonBox->button(QDialogButtonBox::Ok), SIGNAL(clicked()), this, SLOT(apply()) );
0037     connect( m_uiWidget->buttonBox->button(QDialogButtonBox::Ok), SIGNAL(clicked()), this, SLOT(accept()) );
0038     
0039     setModal( false );
0040 
0041 }
0042 
0043 SunControlWidget::~SunControlWidget()
0044 {
0045     delete m_uiWidget;
0046 }
0047 
0048 void SunControlWidget::apply()
0049 {
0050     if( m_uiWidget->sunShading->isChecked() )
0051     {
0052         if( m_uiWidget->showShadow->isChecked() )
0053         {
0054             emit showSun( true );
0055             m_marbleWidget->setShowCityLights( false );
0056             m_shadow = "shadow";
0057         }
0058         else if( m_uiWidget->showNightMap->isChecked() )
0059         {
0060             emit showSun( true );
0061             m_marbleWidget->setShowCityLights( true );
0062             m_shadow = "nightmap";
0063         }
0064     }
0065     else
0066     {
0067         emit showSun( false );
0068         m_marbleWidget->setShowCityLights( false );
0069     }
0070 
0071     if( m_uiWidget->lockToSubSolarPointCheckBox->isChecked() )
0072     {
0073         m_marbleWidget->setLockToSubSolarPoint( true );
0074         emit isLockedToSubSolarPoint( true );
0075     }
0076     else
0077     {
0078         m_marbleWidget->setLockToSubSolarPoint( false );
0079         emit isLockedToSubSolarPoint( false );
0080     }
0081 
0082     if( m_uiWidget->subSolarIconCheckBox->isChecked() )
0083     {
0084         m_marbleWidget->setSubSolarPointIconVisible( true );
0085         emit isSubSolarPointIconVisible( true );
0086     }
0087     else
0088     {
0089         m_marbleWidget->setSubSolarPointIconVisible( false );
0090         emit isSubSolarPointIconVisible( false );
0091     }
0092 }
0093 
0094 void SunControlWidget::setSunShading( bool active )
0095 {
0096     m_uiWidget->sunShading->setChecked( active );
0097 }
0098 
0099 void SunControlWidget::showEvent( QShowEvent* event )
0100 {
0101     if( !event->spontaneous() ) 
0102     {
0103         // Loading all options
0104         if( m_marbleWidget->showSunShading() )
0105         {
0106             m_uiWidget->sunShading->setChecked( true );
0107             m_uiWidget->showShadow->setChecked( m_marbleWidget->showSunShading() );
0108             m_uiWidget->showNightMap->setChecked( m_marbleWidget->showCityLights() );
0109         }
0110         else
0111         {   
0112             m_uiWidget->showShadow->setChecked( false );
0113             if (m_shadow == QLatin1String("shadow"))
0114             {
0115                 m_uiWidget->showShadow->setChecked( true );
0116             }
0117             else
0118             {
0119                 m_uiWidget->showNightMap->setChecked( true );
0120             }
0121         }
0122         m_uiWidget->subSolarIconCheckBox->setChecked( m_marbleWidget->isSubSolarPointIconVisible() );
0123         m_uiWidget->lockToSubSolarPointCheckBox->setChecked( m_marbleWidget->isLockedToSubSolarPoint() );
0124     }
0125 }
0126 
0127 #include "moc_SunControlWidget.cpp"