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

0001 /*
0002     SPDX-FileCopyrightText: 2020-2022 by Alexander Semke (alexander.semke@web.de)
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #include "octavesettingswidget.h"
0008 #include <QTimer>
0009 
0010 OctaveSettingsWidget::OctaveSettingsWidget(QWidget* parent, const QString& id) : BackendSettingsWidget(parent, id)
0011 {
0012     setupUi(this);
0013 
0014     m_tabWidget = tabWidget;
0015     m_tabDocumentation = tabDocumentation;
0016     m_urlRequester = kcfg_Path;
0017 
0018     connect(tabWidget, &QTabWidget::currentChanged, this, &BackendSettingsWidget::tabChanged);
0019     connect(kcfg_Path, &KUrlRequester::textChanged, this, &BackendSettingsWidget::fileNameChanged);
0020     connect(kcfg_integratePlots, &QCheckBox::clicked, this, &OctaveSettingsWidget::integratePlotsChanged);
0021 
0022     kcfg_inlinePlotFormat->setItemIcon(0, QIcon::fromTheme(QLatin1String("application-pdf")));
0023     kcfg_inlinePlotFormat->setItemIcon(1, QIcon::fromTheme(QLatin1String("image-svg+xml")));
0024     kcfg_inlinePlotFormat->setItemIcon(2, QIcon::fromTheme(QLatin1String("image-png")));
0025 
0026     // return to the event loop to show the settings
0027     // and then call the slot to update the state of the widgets
0028     QTimer::singleShot(0, this, [=]() {
0029         integratePlotsChanged(kcfg_integratePlots->isChecked());
0030     });
0031 }
0032 
0033 void OctaveSettingsWidget::integratePlotsChanged(bool state)
0034 {
0035     lPlotWidth->setEnabled(state);
0036     kcfg_plotWidth->setEnabled(state);
0037     lPlotHeight->setEnabled(state);
0038     kcfg_plotHeight->setEnabled(state);
0039     kcfg_inlinePlotFormat->setEnabled(state);
0040 }