File indexing completed on 2024-05-12 07:41:28

0001 /*
0002     File                 : SettingsSpreadsheetPage.cpp
0003     Project              : LabPlot
0004     Description          : settings page for Spreadsheet
0005     --------------------------------------------------------------------
0006     SPDX-FileCopyrightText: 2020 Alexander Semke <alexander.semke@web.de>
0007     SPDX-License-Identifier: GPL-2.0-or-later
0008 */
0009 
0010 #include "SettingsSpreadsheetPage.h"
0011 #include "backend/core/Settings.h"
0012 
0013 #include <KConfigGroup>
0014 #include <KLocalizedString>
0015 
0016 /**
0017  * \brief Page for Spreadsheet settings of the Labplot settings dialog.
0018  */
0019 SettingsSpreadsheetPage::SettingsSpreadsheetPage(QWidget* parent)
0020     : SettingsPage(parent) {
0021     ui.setupUi(this);
0022     connect(ui.chkShowColumnType, &QCheckBox::toggled, this, &SettingsSpreadsheetPage::changed);
0023     connect(ui.chkShowPlotDesignation, &QCheckBox::toggled, this, &SettingsSpreadsheetPage::changed);
0024     loadSettings();
0025 }
0026 
0027 void SettingsSpreadsheetPage::applySettings() {
0028     if (!m_changed)
0029         return;
0030 
0031     KConfigGroup group = Settings::group(QStringLiteral("Settings_Spreadsheet"));
0032     group.writeEntry(QLatin1String("ShowColumnType"), ui.chkShowColumnType->isChecked());
0033     group.writeEntry(QLatin1String("ShowPlotDesignation"), ui.chkShowPlotDesignation->isChecked());
0034 }
0035 
0036 void SettingsSpreadsheetPage::restoreDefaults() {
0037     ui.chkShowColumnType->setChecked(true);
0038     ui.chkShowPlotDesignation->setChecked(true);
0039 }
0040 
0041 void SettingsSpreadsheetPage::loadSettings() {
0042     const KConfigGroup group = Settings::group(QStringLiteral("Settings_Spreadsheet"));
0043     ui.chkShowColumnType->setChecked(group.readEntry(QLatin1String("ShowColumnType"), true));
0044     ui.chkShowPlotDesignation->setChecked(group.readEntry(QLatin1String("ShowPlotDesignation"), true));
0045 }
0046 
0047 void SettingsSpreadsheetPage::changed() {
0048     m_changed = true;
0049     Q_EMIT settingsChanged();
0050 }