File indexing completed on 2024-04-28 15:14:02

0001 /***************************************************************************
0002     File                 : SettingsSpreadsheetPage.cpp
0003     Project              : LabPlot
0004     Description          : settings page for Spreadsheet
0005     --------------------------------------------------------------------
0006     Copyright            : (C) 2020 Alexander Semke (alexander.semke@web.de)
0007 
0008  ***************************************************************************/
0009 
0010 /***************************************************************************
0011  *                                                                         *
0012  *  This program is free software; you can redistribute it and/or modify   *
0013  *  it under the terms of the GNU General Public License as published by   *
0014  *  the Free Software Foundation; either version 2 of the License, or      *
0015  *  (at your option) any later version.                                    *
0016  *                                                                         *
0017  *  This program is distributed in the hope that it will be useful,        *
0018  *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
0019  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
0020  *  GNU General Public License for more details.                           *
0021  *                                                                         *
0022  *   You should have received a copy of the GNU General Public License     *
0023  *   along with this program; if not, write to the Free Software           *
0024  *   Foundation, Inc., 51 Franklin Street, Fifth Floor,                    *
0025  *   Boston, MA  02110-1301  USA                                           *
0026  *                                                                         *
0027  ***************************************************************************/
0028 
0029 #include "SettingsSpreadsheetPage.h"
0030 
0031 #include <KLocalizedString>
0032 #include <KSharedConfig>
0033 #include <KConfigGroup>
0034 
0035 /**
0036  * \brief Page for Spreadsheet settings of the Labplot settings dialog.
0037  */
0038 SettingsSpreadsheetPage::SettingsSpreadsheetPage(QWidget* parent) : SettingsPage(parent) {
0039     ui.setupUi(this);
0040     connect(ui.chkShowColumnType, &QCheckBox::stateChanged, this, &SettingsSpreadsheetPage::changed);
0041     connect(ui.chkShowPlotDesignation, &QCheckBox::stateChanged, this, &SettingsSpreadsheetPage::changed);
0042     loadSettings();
0043 }
0044 
0045 void SettingsSpreadsheetPage::applySettings() {
0046     if (!m_changed)
0047         return;
0048 
0049     KConfigGroup group = KSharedConfig::openConfig()->group(QLatin1String("Settings_Spreadsheet"));
0050     group.writeEntry(QLatin1String("ShowColumnType"), ui.chkShowColumnType->isChecked());
0051     group.writeEntry(QLatin1String("ShowPlotDesignation"), ui.chkShowPlotDesignation->isChecked());
0052 }
0053 
0054 void SettingsSpreadsheetPage::restoreDefaults() {
0055     ui.chkShowColumnType->setChecked(true);
0056     ui.chkShowPlotDesignation->setChecked(true);
0057 }
0058 
0059 void SettingsSpreadsheetPage::loadSettings() {
0060     const KConfigGroup group = KSharedConfig::openConfig()->group(QLatin1String("Settings_Spreadsheet"));
0061     ui.chkShowColumnType->setChecked(group.readEntry(QLatin1String("ShowColumnType"), true));
0062     ui.chkShowPlotDesignation->setChecked(group.readEntry(QLatin1String("ShowPlotDesignation"), true));
0063 }
0064 
0065 void SettingsSpreadsheetPage::changed() {
0066     m_changed = true;
0067     emit settingsChanged();
0068 }