File indexing completed on 2025-01-05 03:52:04
0001 /* ============================================================ 0002 * 0003 * This file is a part of digiKam project 0004 * https://www.digikam.org 0005 * 0006 * Date : 2006-04-04 0007 * Description : a tool to generate HTML image galleries 0008 * 0009 * SPDX-FileCopyrightText: 2006-2010 by Aurelien Gateau <aurelien dot gateau at free dot fr> 0010 * SPDX-FileCopyrightText: 2012-2024 by Gilles Caulier <caulier dot gilles at gmail dot com> 0011 * 0012 * SPDX-License-Identifier: GPL-2.0-or-later 0013 * 0014 * ============================================================ */ 0015 0016 #include "intthemeparameter.h" 0017 0018 // Qt includes 0019 0020 #include <QSpinBox> 0021 0022 // KDE includes 0023 0024 #include <kconfiggroup.h> 0025 0026 static const char* MIN_VALUE_KEY = "Min"; 0027 static const char* MAX_VALUE_KEY = "Max"; 0028 0029 namespace DigikamGenericHtmlGalleryPlugin 0030 { 0031 0032 class Q_DECL_HIDDEN IntThemeParameter::Private 0033 { 0034 public: 0035 0036 explicit Private() 0037 : minValue(0), 0038 maxValue(99999) 0039 { 0040 } 0041 0042 int minValue; 0043 int maxValue; 0044 }; 0045 0046 IntThemeParameter::IntThemeParameter() 0047 : d(new Private) 0048 { 0049 } 0050 0051 IntThemeParameter::~IntThemeParameter() 0052 { 0053 delete d; 0054 } 0055 0056 void IntThemeParameter::init(const QByteArray& internalName, const KConfigGroup* configGroup) 0057 { 0058 AbstractThemeParameter::init(internalName, configGroup); 0059 0060 d->minValue = configGroup->readEntry(MIN_VALUE_KEY, 0); 0061 d->maxValue = configGroup->readEntry(MAX_VALUE_KEY, 99999); 0062 } 0063 0064 QWidget* IntThemeParameter::createWidget(QWidget* parent, const QString& value) const 0065 { 0066 QSpinBox* const spinBox = new QSpinBox(parent); 0067 spinBox->setValue(value.toInt()); 0068 spinBox->setMinimum(d->minValue); 0069 spinBox->setMaximum(d->maxValue); 0070 0071 return spinBox; 0072 } 0073 0074 QString IntThemeParameter::valueFromWidget(QWidget* widget) const 0075 { 0076 QSpinBox* const spinBox = static_cast<QSpinBox*>(widget); 0077 0078 return QString::number(spinBox->value()); 0079 } 0080 0081 } // namespace DigikamGenericHtmlGalleryPlugin