File indexing completed on 2025-01-19 03:51:20
0001 /* ============================================================ 0002 * 0003 * This file is a part of digiKam project 0004 * https://www.digikam.org 0005 * 0006 * Date : 2007-10-18 0007 * Description : a widget to edit multiple alternative 0008 * language string entries and an activation checkbox. 0009 * 0010 * SPDX-FileCopyrightText: 2007-2024 by Gilles Caulier <caulier dot gilles at gmail dot com> 0011 * SPDX-FileCopyrightText: 2013 by Victor Dodon <dodonvictor at gmail dot com> 0012 * 0013 * SPDX-License-Identifier: GPL-2.0-or-later 0014 * 0015 * ============================================================ */ 0016 0017 #include "altlangstringedit.h" 0018 0019 // Qt includes 0020 0021 #include <QGridLayout> 0022 #include <QApplication> 0023 0024 // Local includes 0025 0026 #include "squeezedcombobox.h" 0027 #include "metadatacheckbox.h" 0028 0029 namespace DigikamGenericMetadataEditPlugin 0030 { 0031 0032 class Q_DECL_HIDDEN AltLangStringsEdit::Private 0033 { 0034 public: 0035 0036 explicit Private() 0037 : valueCheck(nullptr) 0038 { 0039 } 0040 0041 DMetadata::AltLangMap oldValues; 0042 MetadataCheckBox* valueCheck; 0043 }; 0044 0045 AltLangStringsEdit::AltLangStringsEdit(QWidget* const parent, const QString& title, const QString& desc) 0046 : AltLangStrEdit(parent), 0047 d (new Private) 0048 { 0049 d->valueCheck = new MetadataCheckBox(title, parent); 0050 setLinesVisible(4); 0051 setPlaceholderText(desc); 0052 setTitleWidget(d->valueCheck); 0053 0054 // -------------------------------------------------------- 0055 0056 connect(d->valueCheck, SIGNAL(toggled(bool)), 0057 this, SIGNAL(signalToggled(bool))); 0058 0059 connect(d->valueCheck, SIGNAL(toggled(bool)), 0060 this, SLOT(slotEnabledInternalWidgets(bool))); 0061 0062 connect(d->valueCheck, SIGNAL(toggled(bool)), 0063 this, SIGNAL(signalModified())); 0064 0065 slotEnabledInternalWidgets(d->valueCheck->isChecked()); 0066 0067 // -------------------------------------------------------- 0068 0069 connect(this, SIGNAL(signalModified(QString,QString)), 0070 this, SIGNAL(signalModified())); 0071 0072 connect(this, SIGNAL(signalValueAdded(QString,QString)), 0073 this, SIGNAL(signalModified())); 0074 0075 connect(this, SIGNAL(signalValueDeleted(QString)), 0076 this, SIGNAL(signalModified())); 0077 0078 connect(this, SIGNAL(signalSelectionChanged(QString)), 0079 this, SLOT(slotSelectionChanged(QString))); 0080 } 0081 0082 AltLangStringsEdit::~AltLangStringsEdit() 0083 { 0084 delete d; 0085 } 0086 0087 void AltLangStringsEdit::setValid(bool v) 0088 { 0089 d->valueCheck->setValid(v); 0090 d->valueCheck->setChecked(v); 0091 } 0092 0093 bool AltLangStringsEdit::isValid() const 0094 { 0095 return d->valueCheck->isValid(); 0096 } 0097 0098 void AltLangStringsEdit::setValues(const DMetadata::AltLangMap& values) 0099 { 0100 d->oldValues = values; 0101 AltLangStrEdit::setValues(values); 0102 } 0103 0104 bool AltLangStringsEdit::getValues(DMetadata::AltLangMap& oldValues, 0105 DMetadata::AltLangMap& newValues) const 0106 { 0107 oldValues = d->oldValues; 0108 newValues = values(); 0109 0110 return d->valueCheck->isChecked(); 0111 } 0112 0113 void AltLangStringsEdit::slotSelectionChanged(const QString& lang) 0114 { 0115 Q_EMIT signalDefaultLanguageEnabled(lang == QLatin1String("x-default")); 0116 } 0117 0118 } // namespace DigikamGenericMetadataEditPlugin 0119 0120 #include "moc_altlangstringedit.cpp"