Marble

SunControlWidget.cpp
1 // SPDX-License-Identifier: LGPL-2.1-or-later
2 //
3 // SPDX-FileCopyrightText: 2008 David Roberts <[email protected]>
4 // SPDX-FileCopyrightText: 2008 Inge Wallin <[email protected]>
5 // SPDX-FileCopyrightText: 2010 Harshit Jain <[email protected]>
6 // SPDX-FileCopyrightText: 2012 Mohammed Nafees <[email protected]>
7 //
8 
9 // Own
10 #include "SunControlWidget.h"
11 #include "ui_SunControlWidget.h"
12 
13 // Qt
14 #include <QPushButton>
15 #include <QShowEvent>
16 
17 // Marble
18 #include "MarbleDebug.h"
19 #include "MarbleWidget.h"
20 
21 using namespace Marble;
22 /* TRANSLATOR Marble::SunControlWidget */
23 
24 SunControlWidget::SunControlWidget( MarbleWidget* marbleWidget, QWidget* parent )
25  : QDialog( parent ),
26  m_uiWidget( new Ui::SunControlWidget ),
27  m_marbleWidget( marbleWidget ),
28  m_shadow( "shadow" )
29 {
30  m_uiWidget->setupUi( this );
31 
32  m_uiWidget->lockWarningLabel->hide();
33 
34  connect( m_uiWidget->buttonBox->button(QDialogButtonBox::Apply), SIGNAL(clicked()), this, SLOT(apply()) );
35  connect( m_uiWidget->buttonBox, SIGNAL(rejected()), this, SLOT(reject()) );
36  connect( m_uiWidget->buttonBox->button(QDialogButtonBox::Ok), SIGNAL(clicked()), this, SLOT(apply()) );
37  connect( m_uiWidget->buttonBox->button(QDialogButtonBox::Ok), SIGNAL(clicked()), this, SLOT(accept()) );
38 
39  setModal( false );
40 
41 }
42 
43 SunControlWidget::~SunControlWidget()
44 {
45  delete m_uiWidget;
46 }
47 
48 void SunControlWidget::apply()
49 {
50  if( m_uiWidget->sunShading->isChecked() )
51  {
52  if( m_uiWidget->showShadow->isChecked() )
53  {
54  emit showSun( true );
55  m_marbleWidget->setShowCityLights( false );
56  m_shadow = "shadow";
57  }
58  else if( m_uiWidget->showNightMap->isChecked() )
59  {
60  emit showSun( true );
61  m_marbleWidget->setShowCityLights( true );
62  m_shadow = "nightmap";
63  }
64  }
65  else
66  {
67  emit showSun( false );
68  m_marbleWidget->setShowCityLights( false );
69  }
70 
71  if( m_uiWidget->lockToSubSolarPointCheckBox->isChecked() )
72  {
73  m_marbleWidget->setLockToSubSolarPoint( true );
74  emit isLockedToSubSolarPoint( true );
75  }
76  else
77  {
78  m_marbleWidget->setLockToSubSolarPoint( false );
79  emit isLockedToSubSolarPoint( false );
80  }
81 
82  if( m_uiWidget->subSolarIconCheckBox->isChecked() )
83  {
84  m_marbleWidget->setSubSolarPointIconVisible( true );
85  emit isSubSolarPointIconVisible( true );
86  }
87  else
88  {
89  m_marbleWidget->setSubSolarPointIconVisible( false );
90  emit isSubSolarPointIconVisible( false );
91  }
92 }
93 
94 void SunControlWidget::setSunShading( bool active )
95 {
96  m_uiWidget->sunShading->setChecked( active );
97 }
98 
99 void SunControlWidget::showEvent( QShowEvent* event )
100 {
101  if( !event->spontaneous() )
102  {
103  // Loading all options
104  if( m_marbleWidget->showSunShading() )
105  {
106  m_uiWidget->sunShading->setChecked( true );
107  m_uiWidget->showShadow->setChecked( m_marbleWidget->showSunShading() );
108  m_uiWidget->showNightMap->setChecked( m_marbleWidget->showCityLights() );
109  }
110  else
111  {
112  m_uiWidget->showShadow->setChecked( false );
113  if (m_shadow == QLatin1String("shadow"))
114  {
115  m_uiWidget->showShadow->setChecked( true );
116  }
117  else
118  {
119  m_uiWidget->showNightMap->setChecked( true );
120  }
121  }
122  m_uiWidget->subSolarIconCheckBox->setChecked( m_marbleWidget->isSubSolarPointIconVisible() );
123  m_uiWidget->lockToSubSolarPointCheckBox->setChecked( m_marbleWidget->isLockedToSubSolarPoint() );
124  }
125 }
126 
127 #include "moc_SunControlWidget.cpp"
KGuiItem apply()
A widget class that displays a view of the earth.
Definition: MarbleWidget.h:98
Binds a QML item to a specific geodetic location in screen coordinates.
AKONADI_CALENDAR_EXPORT KCalendarCore::Event::Ptr event(const Akonadi::Item &item)
void setupUi(QWidget *widget)
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Thu May 26 2022 04:07:51 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.