File indexing completed on 2024-04-28 04:21:19
0001 // SPDX-FileCopyrightText: 2003-2010 Jesper K. Pedersen <blackie@kde.org> 0002 // SPDX-FileCopyrightText: 2021 Johannes Zarl-Zierl <johannes@zarl-zierl.at> 0003 // 0004 // SPDX-License-Identifier: GPL-2.0-or-later 0005 0006 #include "ExifPage.h" 0007 0008 #include <Exif/TreeView.h> 0009 #include <kpabase/SettingsData.h> 0010 #include <kpaexif/Info.h> 0011 0012 #include <KComboBox> 0013 #include <KLocalizedString> 0014 #include <QHBoxLayout> 0015 #include <QLabel> 0016 #include <QTextCodec> 0017 #include <QVBoxLayout> 0018 0019 Settings::ExifPage::ExifPage(QWidget *parent) 0020 : QWidget(parent) 0021 { 0022 QVBoxLayout *vlay = new QVBoxLayout(this); 0023 QHBoxLayout *hlay1 = new QHBoxLayout(); 0024 QHBoxLayout *hlay2 = new QHBoxLayout(); 0025 vlay->addLayout(hlay1); 0026 vlay->addLayout(hlay2); 0027 0028 m_exifForViewer = new Exif::TreeView(i18n("Exif/IPTC info to show in the viewer"), this); 0029 hlay1->addWidget(m_exifForViewer); 0030 0031 m_exifForDialog = new Exif::TreeView(i18n("Exif/IPTC info to show in the Exif dialog"), this); 0032 hlay1->addWidget(m_exifForDialog); 0033 0034 QLabel *iptcCharsetLabel = new QLabel(i18n("Character set for image metadata:"), this); 0035 m_iptcCharset = new KComboBox(this); 0036 QStringList charsets; 0037 QList<QByteArray> charsetsBA = QTextCodec::availableCodecs(); 0038 for (QList<QByteArray>::const_iterator it = charsetsBA.constBegin(); it != charsetsBA.constEnd(); ++it) 0039 charsets << QString::fromLatin1(*it); 0040 m_iptcCharset->insertItems(m_iptcCharset->count(), charsets); 0041 0042 hlay2->addStretch(1); 0043 hlay2->addWidget(iptcCharsetLabel); 0044 hlay2->addWidget(m_iptcCharset); 0045 } 0046 0047 void Settings::ExifPage::saveSettings(Settings::SettingsData *opt) 0048 { 0049 opt->setExifForViewer(m_exifForViewer->selected()); 0050 opt->setExifForDialog(m_exifForDialog->selected()); 0051 opt->setIptcCharset(m_iptcCharset->currentText()); 0052 } 0053 0054 void Settings::ExifPage::loadSettings(Settings::SettingsData *opt) 0055 { 0056 m_exifForViewer->reload(); 0057 m_exifForDialog->reload(); 0058 m_exifForViewer->setSelectedExif(Settings::SettingsData::instance()->exifForViewer()); 0059 m_exifForDialog->setSelectedExif(Settings::SettingsData::instance()->exifForDialog()); 0060 m_iptcCharset->setCurrentIndex(qMax(0, QTextCodec::availableCodecs().indexOf(opt->iptcCharset().toLatin1()))); 0061 } 0062 // vi:expandtab:tabstop=4 shiftwidth=4: