Marble

SunControlWidget.cpp
1// SPDX-License-Identifier: LGPL-2.1-or-later
2//
3// SPDX-FileCopyrightText: 2008 David Roberts <dvdr18@gmail.com>
4// SPDX-FileCopyrightText: 2008 Inge Wallin <inge@lysator.liu.se>
5// SPDX-FileCopyrightText: 2010 Harshit Jain <hjain.itbhu@gmail.com>
6// SPDX-FileCopyrightText: 2012 Mohammed Nafees <nafees.technocool@gmail.com>
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
21using namespace Marble;
22/* TRANSLATOR Marble::SunControlWidget */
23
24SunControlWidget::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
43SunControlWidget::~SunControlWidget()
44{
45 delete m_uiWidget;
46}
47
48void 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
94void SunControlWidget::setSunShading( bool active )
95{
96 m_uiWidget->sunShading->setChecked( active );
97}
98
99void 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"
This file contains the headers for MarbleWidget.
A widget class that displays a view of the earth.
void setShowCityLights(bool visible)
Set whether city lights instead of night shadow are visible.
void setSubSolarPointIconVisible(bool visible)
Set whether the sun icon is shown in the sub solar point.
void setLockToSubSolarPoint(bool visible)
Set the globe locked to the sub solar point.
KGuiItem apply()
Binds a QML item to a specific geodetic location in screen coordinates.
T qobject_cast(QObject *object)
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
virtual bool event(QEvent *event) override
void setupUi(QWidget *widget)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:18:17 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.