File indexing completed on 2025-01-05 03:53:13

0001 /* ===============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 2010-10-01
0007  * Description : Dialog to allow a custom page layout
0008  *
0009  * SPDX-FileCopyrightText: 2010-2012 by Angelo Naselli <anaselli at linux dot it>
0010  * SPDX-FileCopyrightText: 2006-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 "advprintcustomdlg.h"
0017 
0018 // KDE includes
0019 
0020 #include <ksharedconfig.h>
0021 #include <kconfiggroup.h>
0022 
0023 namespace DigikamGenericPrintCreatorPlugin
0024 {
0025 
0026 AdvPrintCustomLayoutDlg::AdvPrintCustomLayoutDlg(QWidget* const parent)
0027     : QDialog(parent)
0028 {
0029     setupUi(this);
0030 
0031     connect(m_doneButton, SIGNAL(clicked()),
0032             this, SLOT(accept()));
0033 
0034     m_photoGridCheck->setToolTip(i18n("Choose your grid size"));
0035     m_photoGridCheck->setWhatsThis(i18n("Choose your grid size"));
0036     m_gridRows->setToolTip(i18n("Number of rows"));
0037     m_gridRows->setWhatsThis(i18n("Insert number of rows"));
0038     m_gridColumns->setToolTip(i18n("Number of columns"));
0039     m_gridColumns->setWhatsThis(i18n("Insert number of columns"));
0040 
0041     m_fitAsManyCheck->setToolTip(i18n("Choose to have a custom photo size album"));
0042     m_fitAsManyCheck->setWhatsThis(i18n("Choose to have a custom photo size album"));
0043     m_photoHeight->setToolTip(i18n("Photo height"));
0044     m_photoHeight->setWhatsThis(i18n("Insert photo height"));
0045     m_photoWidth->setToolTip(i18n("Photo width"));
0046     m_photoWidth->setWhatsThis(i18n("Insert photo width"));
0047 
0048     m_autorotate->setToolTip(i18n("Rotate photo automatically on layout accordingly "
0049                                   "with camera orientation information"));
0050 }
0051 
0052 AdvPrintCustomLayoutDlg:: ~AdvPrintCustomLayoutDlg()
0053 {
0054 }
0055 
0056 void AdvPrintCustomLayoutDlg::readSettings()
0057 {
0058     KSharedConfigPtr config = KSharedConfig::openConfig();
0059     KConfigGroup group      = config->group(QLatin1String("PrintCreator"));
0060 
0061     QSize gridSize     = group.readEntry(QLatin1String("Custom-gridSize"), QSize(3, 8));
0062     m_gridRows->setValue(gridSize.width());
0063     m_gridColumns->setValue(gridSize.height());
0064 
0065     QSizeF photoSize   = group.readEntry (QLatin1String("Custom-photoSize"), QSizeF(5.0, 4.0));
0066     m_photoHeight->setValue(photoSize.height());
0067     m_photoWidth->setValue(photoSize.width());
0068 
0069     int index          = group.readEntry(QLatin1String("Custom-photoUnits"), 0);
0070     m_photoUnits->setCurrentIndex(index);
0071 
0072     bool autorotate    = group.readEntry(QLatin1String("Custom-autorotate"), false);
0073     m_autorotate->setChecked(autorotate);
0074 
0075     int choice         = group.readEntry(QLatin1String("Custom-choice"), (int)PHOTO_GRID);
0076 
0077     if (choice == FIT_AS_MANY_AS_POSSIBLE)
0078     {
0079         m_fitAsManyCheck->setChecked(true);
0080     }
0081     else
0082     {
0083         m_photoGridCheck->setChecked(true);
0084     }
0085 }
0086 
0087 void AdvPrintCustomLayoutDlg::saveSettings()
0088 {
0089     KSharedConfigPtr config = KSharedConfig::openConfig();
0090     KConfigGroup group      = config->group(QLatin1String("PrintCreator"));
0091     int choice              = PHOTO_GRID;
0092 
0093     if (m_fitAsManyCheck->isChecked())
0094     {
0095         choice = FIT_AS_MANY_AS_POSSIBLE;
0096     }
0097 
0098     group.writeEntry(QLatin1String("Custom-choice"),     choice);
0099     group.writeEntry(QLatin1String("Custom-gridSize"),   QSize(m_gridRows->value(),    m_gridColumns->value()));
0100     group.writeEntry(QLatin1String("Custom-photoSize"),  QSizeF(m_photoWidth->value(), m_photoHeight->value()));
0101     group.writeEntry(QLatin1String("Custom-photoUnits"), m_photoUnits->currentIndex());
0102     group.writeEntry(QLatin1String("Custom-autorotate"), m_autorotate->isChecked());
0103 }
0104 
0105 } // namespace DigikamGenericPrintCreatorPlugin
0106 
0107 #include "moc_advprintcustomdlg.cpp"