Kstars

opsadvanced.cpp
1/*
2 SPDX-FileCopyrightText: 2004 Jason Harris <jharris@30doradus.org>
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
24OpsAdvanced::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
66void OpsAdvanced::slotChangeTimeScale(float newScale)
67{
68 Options::setSlewTimeScale(newScale);
69}
70
71void 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
86void OpsAdvanced::slotToggleVerbosityOptions()
87{
88 if (kcfg_DisableLogging->isChecked())
90}
91
92void OpsAdvanced::slotToggleOutputOptions()
93{
94 if (kcfg_LogToDefault->isChecked())
95 {
96 if (kcfg_DisableLogging->isChecked() == false)
98 }
99 else
101}
102
103void OpsAdvanced::slotShowLogFiles()
104{
105 QUrl path = QUrl::fromLocalFile(QDir(KSPaths::writableLocation(QStandardPaths::AppLocalDataLocation)).filePath("logs"));
106
108}
109
110void OpsAdvanced::slotApply()
111{
113}
114
115void 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}
static KConfigDialog * exists(const QString &name)
static void UseDefault()
Use the default logging mechanism.
Definition ksutils.cpp:1023
static void SyncFilterRules()
SyncFilterRules Sync QtLogging filter rules from Options.
Definition ksutils.cpp:1035
static void Disable()
Disable logging.
Definition ksutils.cpp:1028
static void UseFile()
Store all logs into the specified file.
Definition ksutils.cpp:926
This is the main window for KStars.
Definition kstars.h:89
void setMouseCursorShape(Cursor type)
Sets the shape of the default mouse cursor.
Definition skymap.cpp:1305
QString i18n(const char *text, const TYPE &arg...)
QString path(const QString &relativePath)
void clicked(bool checked)
void toggled(bool checked)
void valueChanged(int value)
void activated(int index)
bool openUrl(const QUrl &url)
void accepted()
void rejected()
QString filePath(const QString &fileName) const const
bool remove()
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
bool disconnect(const QMetaObject::Connection &connection)
QString writableLocation(StandardLocation type)
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
QUrl fromLocalFile(const QString &localFile)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:16:41 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.