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 "MarbleWidget.h"
19
20using namespace Marble;
21/* TRANSLATOR Marble::SunControlWidget */
22
23SunControlWidget::SunControlWidget(MarbleWidget *marbleWidget, QWidget *parent)
24 : QDialog(parent)
25 , m_uiWidget(new Ui::SunControlWidget)
26 , m_marbleWidget(marbleWidget)
27 , m_shadow(QStringLiteral("shadow"))
28{
29 m_uiWidget->setupUi(this);
30
31 m_uiWidget->lockWarningLabel->hide();
32
33 connect(m_uiWidget->buttonBox->button(QDialogButtonBox::Apply), &QAbstractButton::clicked, this, &SunControlWidget::apply);
34 connect(m_uiWidget->buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
35 connect(m_uiWidget->buttonBox->button(QDialogButtonBox::Ok), &QAbstractButton::clicked, this, &SunControlWidget::apply);
36 connect(m_uiWidget->buttonBox->button(QDialogButtonBox::Ok), &QAbstractButton::clicked, this, &QDialog::accept);
37
38 setModal(false);
39}
40
41SunControlWidget::~SunControlWidget()
42{
43 delete m_uiWidget;
44}
45
46void SunControlWidget::apply()
47{
48 if (m_uiWidget->sunShading->isChecked()) {
49 if (m_uiWidget->showShadow->isChecked()) {
50 Q_EMIT showSun(true);
51 m_marbleWidget->setShowCityLights(false);
52 m_shadow = QStringLiteral("shadow");
53 } else if (m_uiWidget->showNightMap->isChecked()) {
54 Q_EMIT showSun(true);
55 m_marbleWidget->setShowCityLights(true);
56 m_shadow = QStringLiteral("nightmap");
57 }
58 } else {
59 Q_EMIT showSun(false);
60 m_marbleWidget->setShowCityLights(false);
61 }
62
63 if (m_uiWidget->lockToSubSolarPointCheckBox->isChecked()) {
64 m_marbleWidget->setLockToSubSolarPoint(true);
65 Q_EMIT isLockedToSubSolarPoint(true);
66 } else {
67 m_marbleWidget->setLockToSubSolarPoint(false);
68 Q_EMIT isLockedToSubSolarPoint(false);
69 }
70
71 if (m_uiWidget->subSolarIconCheckBox->isChecked()) {
72 m_marbleWidget->setSubSolarPointIconVisible(true);
73 Q_EMIT isSubSolarPointIconVisible(true);
74 } else {
75 m_marbleWidget->setSubSolarPointIconVisible(false);
76 Q_EMIT isSubSolarPointIconVisible(false);
77 }
78}
79
80void SunControlWidget::setSunShading(bool active)
81{
82 m_uiWidget->sunShading->setChecked(active);
83}
84
85void SunControlWidget::showEvent(QShowEvent *event)
86{
87 if (!event->spontaneous()) {
88 // Loading all options
89 if (m_marbleWidget->showSunShading()) {
90 m_uiWidget->sunShading->setChecked(true);
91 m_uiWidget->showShadow->setChecked(m_marbleWidget->showSunShading());
92 m_uiWidget->showNightMap->setChecked(m_marbleWidget->showCityLights());
93 } else {
94 m_uiWidget->showShadow->setChecked(false);
95 if (m_shadow == QLatin1StringView("shadow")) {
96 m_uiWidget->showShadow->setChecked(true);
97 } else {
98 m_uiWidget->showNightMap->setChecked(true);
99 }
100 }
101 m_uiWidget->subSolarIconCheckBox->setChecked(m_marbleWidget->isSubSolarPointIconVisible());
102 m_uiWidget->lockToSubSolarPointCheckBox->setChecked(m_marbleWidget->isLockedToSubSolarPoint());
103 }
104}
105
106#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.
Binds a QML item to a specific geodetic location in screen coordinates.
void clicked(bool checked)
virtual void accept()
virtual void reject()
Q_EMITQ_EMIT
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 Mon Nov 4 2024 16:37:04 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.