Kstars

opsterrain.cpp
1 /*
2  SPDX-FileCopyrightText: 2021 Hy Murveit <[email protected]>
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 
22 OpsTerrain::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 
36 void 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 
46 void 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 
60 void OpsTerrain::slotApply()
61 {
62  KStarsData *data = KStarsData::Instance();
63  SkyMap *map = SkyMap::Instance();
64 
65  data->setFullTimeUpdate();
67  map->forceUpdate();
68 }
QUrl getOpenFileUrl(QWidget *parent, const QString &caption, const QUrl &dir, const QString &filter, QString *selectedFilter, QFileDialog::Options options, const QStringList &supportedSchemes)
void updateTime(const bool automaticDSTchange=true)
Update time-dependent data and (possibly) repaint the sky map.
Definition: kstars.cpp:567
QIcon fromTheme(const QString &name)
void setFullTimeUpdate()
The Sky is updated more frequently than the moon, which is updated more frequently than the planets.
Definition: kstarsdata.cpp:313
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
static KStars * Instance()
Definition: kstars.h:125
QString i18n(const char *text, const TYPE &arg...)
bool isEmpty() const const
QUrl fromLocalFile(const QString &localFile)
QString toLocalFile() const const
static KConfigDialog * exists(const QString &name)
This is the main window for KStars. In addition to the GUI elements, the class contains the program c...
Definition: kstars.h:92
void setupUi(QWidget *widget)
KIOFILEWIDGETS_EXPORT QString dir(const QString &fileClass)
Canvas widget for displaying the sky bitmap; also handles user interaction events.
Definition: skymap.h:52
QString i18nc(const char *context, const char *text, const TYPE &arg...)
QFuture< void > map(Sequence &sequence, MapFunctor function)
WA_LayoutUsesWidgetRect
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Fri Aug 12 2022 04:00:56 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.