File indexing completed on 2024-04-28 11:20:42

0001 /*
0002     This program is free software; you can redistribute it and/or
0003     modify it under the terms of the GNU General Public License
0004     as published by the Free Software Foundation; either version 2
0005     of the License, or (at your option) any later version.
0006 
0007     This program is distributed in the hope that it will be useful,
0008     but WITHOUT ANY WARRANTY; without even the implied warranty of
0009     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0010     GNU General Public License for more details.
0011 
0012     You should have received a copy of the GNU General Public License
0013     along with this program; if not, write to the Free Software
0014     Foundation, Inc., 51 Franklin Street, Fifth Floor,
0015     Boston, MA  02110-1301, USA.
0016 
0017     ---
0018     Copyright (C) 2020-2022 Alexander Semke <alexander.semke@web.de>
0019  */
0020 
0021 #include "sagesettingswidget.h"
0022 #include <QTimer>
0023 
0024 SageSettingsWidget::SageSettingsWidget(QWidget* parent, const QString& id) : BackendSettingsWidget(parent, id)
0025 {
0026     setupUi(this);
0027 
0028     m_tabWidget = tabWidget;
0029     m_tabDocumentation = tabDocumentation;
0030     m_urlRequester = kcfg_Path;
0031 
0032     connect(tabWidget, &QTabWidget::currentChanged, this, &BackendSettingsWidget::tabChanged);
0033     connect(kcfg_Path, &KUrlRequester::textChanged, this, &BackendSettingsWidget::fileNameChanged);
0034     connect(kcfg_integratePlots, &QCheckBox::clicked, this, &SageSettingsWidget::integratePlotsChanged);
0035 
0036     kcfg_inlinePlotFormat->setItemIcon(0, QIcon::fromTheme(QLatin1String("application-pdf")));
0037     kcfg_inlinePlotFormat->setItemIcon(1, QIcon::fromTheme(QLatin1String("image-png")));
0038 
0039     // return to the event loop to show the settings
0040     // and then call the slot to update the state of the widgets
0041     QTimer::singleShot(0, this, [=]() {
0042         integratePlotsChanged(kcfg_integratePlots->isChecked());
0043     });
0044 }
0045 
0046 void SageSettingsWidget::integratePlotsChanged(bool state)
0047 {
0048     lPlotWidth->setEnabled(state);
0049     kcfg_plotWidth->setEnabled(state);
0050     lPlotHeight->setEnabled(state);
0051     kcfg_plotHeight->setEnabled(state);
0052     kcfg_inlinePlotFormat->setEnabled(state);
0053 }