File indexing completed on 2025-01-05 03:53:06

0001 /* ============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 2021-07-24
0007  * Description : MJPEG Stream configuration dialog - Settings methods
0008  *
0009  * SPDX-FileCopyrightText: 2021-2024 by Gilles Caulier <caulier dot gilles at gmail dot com>
0010  * SPDX-FileCopyrightText: 2021      by Quoc Hưng Tran <quochungtran1999 at gmail dot com>
0011  *
0012  * SPDX-License-Identifier: GPL-2.0-or-later
0013  *
0014  * ============================================================ */
0015 
0016 #include "mjpegstreamdlg_p.h"
0017 
0018 namespace DigikamGenericMjpegStreamPlugin
0019 {
0020 
0021 void MjpegStreamDlg::readSettings()
0022 {
0023     KSharedConfig::Ptr config = KSharedConfig::openConfig();
0024     KConfigGroup group        = config->group(d->mngr->configGroupName());
0025 
0026     d->startOnStartup->setChecked(group.readEntry(d->mngr->configStartServerOnStartupEntry(), false));
0027     d->settings.readSettings(group);
0028 
0029     d->srvPort->blockSignals(true);
0030     d->delay->blockSignals(true);
0031     d->rate->blockSignals(true);
0032     d->quality->blockSignals(true);
0033     d->streamLoop->blockSignals(true);
0034     d->typeVal->blockSignals(true);
0035     d->effVal->blockSignals(true);
0036     d->transVal->blockSignals(true);
0037 
0038     d->srvPort->setValue(d->settings.port);
0039     d->delay->setValue(d->settings.delay);
0040     d->rate->setValue(d->settings.rate);
0041     d->quality->setValue(d->settings.quality);
0042     d->streamLoop->setChecked(d->settings.loop);
0043     d->typeVal->setCurrentIndex(d->settings.outSize);
0044     d->effVal->setCurrentIndex(d->settings.effect);
0045     d->transVal->setCurrentIndex(d->settings.transition);
0046 
0047     d->frameOsdWidget->setSettings(d->settings.osdSettings);
0048 
0049     d->srvPort->blockSignals(false);
0050     d->delay->blockSignals(false);
0051     d->rate->blockSignals(false);
0052     d->quality->blockSignals(false);
0053     d->streamLoop->blockSignals(false);
0054     d->typeVal->blockSignals(false);
0055     d->effVal->blockSignals(false);
0056     d->transVal->blockSignals(false);
0057 
0058     slotSettingsChanged();
0059 
0060     updateServerStatus();
0061 }
0062 
0063 void MjpegStreamDlg::saveSettings()
0064 {
0065     setMjpegServerContents();
0066 
0067     KSharedConfig::Ptr config = KSharedConfig::openConfig();
0068     KConfigGroup group        = config->group(d->mngr->configGroupName());
0069     group.writeEntry(d->mngr->configStartServerOnStartupEntry(), d->startOnStartup->isChecked());
0070     d->settings.writeSettings(group);
0071     config->sync();
0072 }
0073 
0074 void MjpegStreamDlg::slotSettingsChanged()
0075 {
0076     d->settings.port                              = d->srvPort->value();
0077     d->settings.delay                             = d->delay->value();
0078     d->settings.rate                              = d->rate->value();
0079     d->settings.quality                           = d->quality->value();
0080     d->settings.loop                              = d->streamLoop->isChecked();
0081     d->settings.outSize                           = d->typeVal->currentIndex();
0082     d->settings.effect                            = (EffectMngr::EffectType)d->effVal->currentIndex();
0083     d->settings.transition                        = (TransitionMngr::TransType)d->transVal->currentIndex();
0084 
0085     d->settings.osdSettings                       = d->frameOsdWidget->settings();
0086 
0087     d->effPreview->stopPreview();
0088     d->effPreview->startPreview(d->settings.effect);
0089     d->transPreview->stopPreview();
0090     d->transPreview->startPreview(d->settings.transition);
0091 }
0092 
0093 } // namespace DigikamGenericMjpegStreamPlugin