File indexing completed on 2025-01-05 03:52:07
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 "invisiblebuttongroup.h" 0017 0018 // Qt includes 0019 0020 #include <QAbstractButton> 0021 #include <QButtonGroup> 0022 0023 // Local includes 0024 0025 #include "dconfigdlgmngr.h" 0026 0027 using namespace Digikam; 0028 0029 namespace DigikamGenericHtmlGalleryPlugin 0030 { 0031 0032 class Q_DECL_HIDDEN InvisibleButtonGroup::Private 0033 { 0034 public: 0035 0036 explicit Private() 0037 : group(nullptr) 0038 { 0039 } 0040 0041 QButtonGroup* group; 0042 }; 0043 0044 InvisibleButtonGroup::InvisibleButtonGroup(QWidget* const parent) 0045 : QWidget(parent), 0046 d (new Private) 0047 { 0048 hide(); 0049 0050 d->group = new QButtonGroup(this); 0051 d->group->setExclusive(true); 0052 0053 #if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)) 0054 0055 connect(d->group, SIGNAL(idClicked(int)), 0056 SIGNAL(selectionChanged(int)) ); 0057 0058 #else 0059 0060 connect(d->group, SIGNAL(buttonClicked(int)), 0061 SIGNAL(selectionChanged(int)) ); 0062 0063 #endif 0064 0065 const QString name = QString::fromLatin1(metaObject()->className()); 0066 0067 if (!DConfigDlgMngr::propertyMap()->contains(name)) 0068 { 0069 DConfigDlgMngr::propertyMap()->insert(name, "current"); 0070 DConfigDlgMngr::changedMap()->insert(name, SIGNAL(selectionChanged(int))); 0071 } 0072 } 0073 0074 InvisibleButtonGroup::~InvisibleButtonGroup() 0075 { 0076 delete d; 0077 } 0078 0079 int InvisibleButtonGroup::selected() const 0080 { 0081 return d->group->checkedId(); 0082 } 0083 0084 void InvisibleButtonGroup::addButton(QAbstractButton* button, int id) 0085 { 0086 d->group->addButton(button, id); 0087 } 0088 0089 void InvisibleButtonGroup::setSelected(int id) 0090 { 0091 QAbstractButton* const button = d->group->button(id); 0092 0093 if (button) 0094 { 0095 button->setChecked(true); 0096 } 0097 } 0098 0099 } // namespace DigikamGenericHtmlGalleryPlugin 0100 0101 #include "moc_invisiblebuttongroup.cpp"