Kstars

opsadvanced.cpp
1 /*
2  SPDX-FileCopyrightText: 2004 Jason Harris <[email protected]>
3 
4  SPDX-License-Identifier: GPL-2.0-or-later
5 */
6 
7 #include "opsadvanced.h"
8 
9 #include "kspaths.h"
10 #include "kstars.h"
11 #include "ksutils.h"
12 #include "Options.h"
13 #include "skymap.h"
14 #include "ksmessagebox.h"
15 #include "widgets/timespinbox.h"
16 
17 #include <KConfigDialog>
18 
19 #include <QCheckBox>
20 #include <QDesktopServices>
21 #include <QLabel>
22 #include <QRadioButton>
23 
24 OpsAdvanced::OpsAdvanced() : QFrame(KStars::Instance())
25 {
26  setupUi(this);
27 
28  //Initialize the timestep value
29  SlewTimeScale->tsbox()->changeScale(Options::slewTimeScale());
30 
31  connect(SlewTimeScale, SIGNAL(scaleChanged(float)), this, SLOT(slotChangeTimeScale(float)));
32 
33  connect(kcfg_HideOnSlew, SIGNAL(clicked()), this, SLOT(slotToggleHideOptions()));
34 
35  connect(kcfg_VerboseLogging, SIGNAL(toggled(bool)), this, SLOT(slotToggleVerbosityOptions()));
36 
37  connect(kcfg_LogToFile, SIGNAL(toggled(bool)), this, SLOT(slotToggleOutputOptions()));
38 
39  connect(showLogsB, SIGNAL(clicked()), this, SLOT(slotShowLogFiles()));
40 
41  connect(kcfg_ObsListDemoteHole, &QCheckBox::toggled,
42  [this](bool state)
43  {
44  kcfg_ObsListHoleSize->setEnabled(state);
45  });
46 
47  connect(zoomScrollSlider, &QSlider::valueChanged, [&](int value)
48  {
49  kcfg_ZoomScrollFactor->setValue(value / 100.0);
50  });
51 
52  connect(purgeAllConfigB, &QPushButton::clicked, this, &OpsAdvanced::slotPurge);
53 
54  connect(kcfg_DefaultCursor, static_cast<void (QComboBox::*)(int)>(&QComboBox::activated), [](int index)
55  {
56  Options::setDefaultCursor(index);
57  SkyMap::Instance()->setMouseCursorShape(static_cast<SkyMap::Cursor>(index));
58  });
59 
60  //Get a pointer to the KConfigDialog
61  KConfigDialog *m_ConfigDialog = KConfigDialog::exists("settings");
62  connect(m_ConfigDialog->button(QDialogButtonBox::Apply), SIGNAL(clicked()), SLOT(slotApply()));
63  connect(m_ConfigDialog->button(QDialogButtonBox::Ok), SIGNAL(clicked()), SLOT(slotApply()));
64 }
65 
66 void OpsAdvanced::slotChangeTimeScale(float newScale)
67 {
68  Options::setSlewTimeScale(newScale);
69 }
70 
71 void OpsAdvanced::slotToggleHideOptions()
72 {
73  const auto isOn = kcfg_HideOnSlew->isChecked();
74  textLabelHideTimeStep->setEnabled(isOn);
75  SlewTimeScale->setEnabled(isOn);
76  kcfg_MagLimitHideStar->setEnabled(isOn);
77  kcfg_HideCBounds->setEnabled(isOn);
78  kcfg_HideCLines->setEnabled(isOn);
79  kcfg_HideCNames->setEnabled(isOn);
80  kcfg_HideGrids->setEnabled(isOn);
81  kcfg_HideLabels->setEnabled(isOn);
82  kcfg_HidePlanets->setEnabled(isOn);
83  kcfg_HideStars->setEnabled(isOn);
84 }
85 
86 void OpsAdvanced::slotToggleVerbosityOptions()
87 {
88  if (kcfg_DisableLogging->isChecked())
90 }
91 
92 void OpsAdvanced::slotToggleOutputOptions()
93 {
94  if (kcfg_LogToDefault->isChecked())
95  {
96  if (kcfg_DisableLogging->isChecked() == false)
98  }
99  else
101 }
102 
103 void OpsAdvanced::slotShowLogFiles()
104 {
105  QUrl path = QUrl::fromLocalFile(QDir(KSPaths::writableLocation(QStandardPaths::AppLocalDataLocation)).filePath("logs"));
106 
108 }
109 
110 void OpsAdvanced::slotApply()
111 {
113 }
114 
115 void OpsAdvanced::slotPurge()
116 {
117  connect(KSMessageBox::Instance(), &KSMessageBox::accepted, this, [this]()
118  {
119  KSMessageBox::Instance()->disconnect(this);
120  QString dbFile = QDir(KSPaths::writableLocation(QStandardPaths::AppLocalDataLocation)).filePath("userdb.sqlite");
121  QFile::remove(dbFile);
123  QFile::remove(configFile);
125  QFile::remove(configFile);
126 
127  KSMessageBox::Instance()->info(i18n("Purge complete. Please restart KStars."));
128  });
129 
130  connect(KSMessageBox::Instance(), &KSMessageBox::rejected, this, [this]()
131  {
132  KSMessageBox::Instance()->disconnect(this);
133  });
134 
135  KSMessageBox::Instance()->warningContinueCancel(
136  i18n("Warning! All KStars configuration is going to be purged. This cannot be reversed."),
137  i18n("Clear Configuration"), 30, false);
138 
139 }
bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *method)
bool remove()
void clicked(bool checked)
QString writableLocation(QStandardPaths::StandardLocation type)
bool openUrl(const QUrl &url)
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
void setMouseCursorShape(Cursor type)
Sets the shape of the default mouse cursor.
Definition: skymap.cpp:1300
void toggled(bool checked)
static void UseFile()
Store all logs into the specified file.
Definition: ksutils.cpp:927
void rejected()
QString i18n(const char *text, const TYPE &arg...)
static void SyncFilterRules()
SyncFilterRules Sync QtLogging filter rules from Options.
Definition: ksutils.cpp:1036
QUrl fromLocalFile(const QString &localFile)
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:89
void setupUi(QWidget *widget)
static void Disable()
Disable logging.
Definition: ksutils.cpp:1029
QString path(const QString &relativePath)
static void UseDefault()
Use the default logging mechanism.
Definition: ksutils.cpp:1024
QString filePath(const QString &fileName) const const
void valueChanged(int value)
void activated(int index)
void accepted()
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Tue Jun 6 2023 03:56:49 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.