File indexing completed on 2025-01-05 03:56:18
0001 /* ============================================================ 0002 * 0003 * This file is a part of digiKam project 0004 * https://www.digikam.org 0005 * 0006 * Date : 2013-08-19 0007 * Description : Image Quality configuration selector widget 0008 * 0009 * SPDX-FileCopyrightText: 2013-2024 by Gilles Caulier <caulier dot gilles at gmail dot com> 0010 * SPDX-FileCopyrightText: 2013-2014 by Gowtham Ashok <gwty93 at gmail dot com> 0011 * SPDX-FileCopyrightText: 2021-2022 by Phuoc Khanh Le <phuockhanhnk94 at gmail dot com> 0012 * 0013 * SPDX-License-Identifier: GPL-2.0-or-later 0014 * 0015 * ============================================================ */ 0016 0017 #include "imagequalityconfselector.h" 0018 0019 // Qt includes 0020 0021 #include <QRadioButton> 0022 #include <QButtonGroup> 0023 #include <QGridLayout> 0024 #include <QVBoxLayout> 0025 #include <QApplication> 0026 #include <QStyle> 0027 #include <QPushButton> 0028 0029 // KDE includes 0030 0031 #include <klocalizedstring.h> 0032 0033 // Local includes 0034 0035 #include "dlayoutbox.h" 0036 #include "imagequalitysettings.h" 0037 0038 namespace Digikam 0039 { 0040 0041 class Q_DECL_HIDDEN ImageQualityConfSelector::Private 0042 { 0043 public: 0044 0045 explicit Private() 0046 : selButtonGroup(nullptr), 0047 selDefault (nullptr), 0048 selCustom (nullptr), 0049 qualitySetup (nullptr), 0050 customView (nullptr) 0051 { 0052 } 0053 0054 QButtonGroup* selButtonGroup; 0055 QRadioButton* selDefault; 0056 QRadioButton* selCustom; 0057 0058 QPushButton* qualitySetup; 0059 0060 ImageQualitySettings* customView; 0061 }; 0062 0063 ImageQualityConfSelector::ImageQualityConfSelector(QWidget* const parent) 0064 : QWidget(parent), 0065 d (new Private) 0066 { 0067 const int spacing = qMin(QApplication::style()->pixelMetric(QStyle::PM_LayoutHorizontalSpacing), 0068 QApplication::style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing)); 0069 0070 d->selButtonGroup = new QButtonGroup(this); 0071 d->selButtonGroup->setExclusive(true); 0072 0073 d->selDefault = new QRadioButton(i18nc("@option:radio", "Use default settings"), this); 0074 d->selDefault->setToolTip(i18nc("@info:tooltip", "Use the default quality sorting parameters " 0075 "configured in Setup dialog.")); 0076 0077 d->qualitySetup = new QPushButton(i18n("Settings..."), this); 0078 0079 d->selButtonGroup->addButton(d->selDefault, GlobalSettings); 0080 0081 d->selCustom = new QRadioButton(i18nc("@option:radio", "Use custom settings"), this); 0082 d->selCustom->setToolTip(i18nc("@info:tooltip", "Use custom parameters to perform quality " 0083 "sorting instead default one.")); 0084 0085 d->selButtonGroup->addButton(d->selCustom, CustomSettings); 0086 d->selDefault->setChecked(true); 0087 0088 d->customView = new ImageQualitySettings(this); 0089 0090 QGridLayout* const glay = new QGridLayout(this); 0091 glay->addWidget(d->selDefault, 0, 0, 1, 1); 0092 glay->addWidget(d->qualitySetup, 0, 2, 1, 1); 0093 glay->addWidget(d->selCustom, 1, 0, 1, 3); 0094 glay->addWidget(d->customView, 2, 0, 1, 3); 0095 glay->setColumnStretch(1, 10); 0096 glay->setContentsMargins(spacing, spacing, spacing, spacing); 0097 0098 #if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)) 0099 0100 connect(d->selButtonGroup, static_cast<void (QButtonGroup::*)(int)>(&QButtonGroup::idClicked), 0101 this, &ImageQualityConfSelector::slotSelectionChanged); 0102 0103 #else 0104 0105 connect(d->selButtonGroup, static_cast<void (QButtonGroup::*)(int)>(&QButtonGroup::buttonClicked), 0106 this, &ImageQualityConfSelector::slotSelectionChanged); 0107 0108 #endif 0109 0110 connect(d->qualitySetup, SIGNAL(clicked()), 0111 this, SIGNAL(signalQualitySetup())); 0112 0113 connect(d->customView, SIGNAL(signalSettingsChanged()), 0114 this, SIGNAL(signalSettingsChanged())); 0115 0116 slotSelectionChanged(); 0117 } 0118 0119 ImageQualityConfSelector::~ImageQualityConfSelector() 0120 { 0121 delete d; 0122 } 0123 0124 ImageQualityConfSelector::SettingsType ImageQualityConfSelector::settingsSelected() const 0125 { 0126 return ((SettingsType)(d->selButtonGroup->checkedId())); 0127 } 0128 0129 void ImageQualityConfSelector::setSettingsSelected(SettingsType type) 0130 { 0131 QAbstractButton* const btn = d->selButtonGroup->button((int)(type)); 0132 0133 if (btn) 0134 { 0135 btn->setChecked(true); 0136 } 0137 0138 slotSelectionChanged(); 0139 } 0140 0141 ImageQualityContainer ImageQualityConfSelector::customSettings() const 0142 { 0143 return d->customView->getImageQualityContainer(); 0144 } 0145 0146 void ImageQualityConfSelector::setCustomSettings(const ImageQualityContainer& settings) 0147 { 0148 d->customView->setImageQualityContainer(settings); 0149 } 0150 0151 void ImageQualityConfSelector::slotSelectionChanged() 0152 { 0153 d->qualitySetup->setDisabled(d->selCustom->isChecked()); 0154 d->customView->setDisabled(d->selDefault->isChecked()); 0155 0156 Q_EMIT signalSettingsChanged(); 0157 } 0158 0159 } // namespace Digikam 0160 0161 #include "moc_imagequalityconfselector.cpp"