Kstars

opsterrain.cpp
1/*
2 SPDX-FileCopyrightText: 2021 Hy Murveit <hy@murveit.com>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#include "opsterrain.h"
8
9#include "ksfilereader.h"
10#include "kstars.h"
11#include "kstarsdata.h"
12#include "Options.h"
13#include "skymap.h"
14#include "skycomponents/skymapcomposite.h"
15#include "auxiliary/kspaths.h"
16
17#include <KConfigDialog>
18
19#include <QPushButton>
20#include <QFileDialog>
21
22OpsTerrain::OpsTerrain() : QFrame(KStars::Instance())
23{
24 setupUi(this);
25
26 m_ConfigDialog = KConfigDialog::exists("settings");
27
28 connect(m_ConfigDialog->button(QDialogButtonBox::Apply), SIGNAL(clicked()), SLOT(slotApply()));
29 connect(m_ConfigDialog->button(QDialogButtonBox::Ok), SIGNAL(clicked()), SLOT(slotApply()));
30
31 selectTerrainFileB->setIcon(QIcon::fromTheme("document-open"));
32 selectTerrainFileB->setAttribute(Qt::WA_LayoutUsesWidgetRect);
33 connect(selectTerrainFileB, SIGNAL(clicked()), this, SLOT(saveTerrainFilename()));
34}
35
36void OpsTerrain::syncOptions()
37{
38 kcfg_ShowTerrain->setChecked(Options::showTerrain());
39 kcfg_TerrainPanning->setChecked(Options::terrainPanning());
40 kcfg_TerrainSkipSpeedup->setChecked(Options::terrainSkipSpeedup());
41 kcfg_TerrainSmoothPixels->setChecked(Options::terrainSmoothPixels());
42 kcfg_TerrainTransparencySpeedup->setChecked(Options::terrainTransparencySpeedup());
43}
44
45
46void OpsTerrain::saveTerrainFilename()
47{
48 QDir dir = QDir(KSPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + "/terrain");
49 dir.mkpath(".");
50
51 QUrl dirPath = QUrl::fromLocalFile(dir.path());
52 QUrl fileUrl =
53 QFileDialog::getOpenFileUrl(KStars::Instance(), i18nc("@title:window", "Terrain Image Filename"), dirPath,
54 i18n("PNG Files (*.png)"));
55
56 if (!fileUrl.isEmpty())
57 kcfg_TerrainSource->setText(fileUrl.toLocalFile());
58}
59
60void OpsTerrain::slotApply()
61{
62 KStarsData *data = KStarsData::Instance();
63 SkyMap *map = SkyMap::Instance();
64
65 data->setFullTimeUpdate();
67 map->forceUpdate();
68}
static KConfigDialog * exists(const QString &name)
KStarsData is the backbone of KStars.
Definition kstarsdata.h:74
void setFullTimeUpdate()
The Sky is updated more frequently than the moon, which is updated more frequently than the planets.
This is the main window for KStars.
Definition kstars.h:89
static KStars * Instance()
Definition kstars.h:121
void updateTime(const bool automaticDSTchange=true)
Update time-dependent data and (possibly) repaint the sky map.
Definition kstars.cpp:592
This is the canvas on which the sky is painted.
Definition skymap.h:54
QString i18nc(const char *context, const char *text, const TYPE &arg...)
QString i18n(const char *text, const TYPE &arg...)
KIOCORE_EXPORT QString dir(const QString &fileClass)
QUrl getOpenFileUrl(QWidget *parent, const QString &caption, const QUrl &dir, const QString &filter, QString *selectedFilter, Options options, const QStringList &supportedSchemes)
QIcon fromTheme(const QString &name)
WA_LayoutUsesWidgetRect
QFuture< void > map(Iterator begin, Iterator end, MapFunctor &&function)
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
QUrl fromLocalFile(const QString &localFile)
bool isEmpty() const const
QString toLocalFile() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:04:47 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.