File indexing completed on 2025-01-05 03:53:14
0001 /* ============================================================ 0002 * 0003 * This file is a part of digiKam project 0004 * https://www.digikam.org 0005 * 0006 * Date : 2017-06-27 0007 * Description : a tool to create calendar. 0008 * 0009 * SPDX-FileCopyrightText: 2017-2024 by Gilles Caulier <caulier dot gilles at gmail dot com> 0010 * 0011 * SPDX-License-Identifier: GPL-2.0-or-later 0012 * 0013 * ============================================================ */ 0014 0015 #include "advprintintropage.h" 0016 0017 // Qt includes 0018 0019 #include <QLabel> 0020 #include <QIcon> 0021 #include <QGroupBox> 0022 #include <QGridLayout> 0023 #include <QComboBox> 0024 0025 // KDE includes 0026 0027 #include <klocalizedstring.h> 0028 0029 // Local includes 0030 0031 #include "digikam_config.h" 0032 #include "digikam_debug.h" 0033 #include "dlayoutbox.h" 0034 #include "gimpbinary.h" 0035 #include "dbinarysearch.h" 0036 #include "advprintwizard.h" 0037 0038 namespace DigikamGenericPrintCreatorPlugin 0039 { 0040 0041 class Q_DECL_HIDDEN AdvPrintIntroPage::Private 0042 { 0043 public: 0044 0045 explicit Private(QWizard* const dialog) 0046 : imageGetOption(nullptr), 0047 hbox (nullptr), 0048 binSearch (nullptr), 0049 iface (nullptr) 0050 { 0051 wizard = dynamic_cast<AdvPrintWizard*>(dialog); 0052 0053 if (wizard) 0054 { 0055 iface = wizard->iface(); 0056 } 0057 } 0058 0059 QComboBox* imageGetOption; 0060 DHBox* hbox; 0061 GimpBinary gimpBin; 0062 DBinarySearch* binSearch; 0063 AdvPrintWizard* wizard; 0064 DInfoInterface* iface; 0065 }; 0066 0067 AdvPrintIntroPage::AdvPrintIntroPage(QWizard* const dialog, const QString& title) 0068 : DWizardPage(dialog, title), 0069 d (new Private(dialog)) 0070 { 0071 DVBox* const vbox = new DVBox(this); 0072 QLabel* const desc = new QLabel(vbox); 0073 0074 desc->setWordWrap(true); 0075 desc->setOpenExternalLinks(true); 0076 desc->setText(i18n("<qt>" 0077 "<p><h1><b>Welcome to Print Creator</b></h1></p>" 0078 "<p>This assistant will guide you to assemble images " 0079 "to be printed following specific templates as Photo Album, " 0080 "Photo Collage, or Framed Photo.</p>" 0081 "<p>An adaptive photo collection page layout can be also used, " 0082 "based on Atkins algorithm.</p>" 0083 "</qt>")); 0084 0085 // ComboBox for image selection method 0086 0087 d->hbox = new DHBox(vbox); 0088 QLabel* const getImageLabel = new QLabel(i18n("&Choose image selection method:"), d->hbox); 0089 d->imageGetOption = new QComboBox(d->hbox); 0090 d->imageGetOption->insertItem(AdvPrintSettings::ALBUMS, i18n("Albums")); 0091 d->imageGetOption->insertItem(AdvPrintSettings::IMAGES, i18n("Images")); 0092 getImageLabel->setBuddy(d->imageGetOption); 0093 0094 // --------------------- 0095 0096 QGroupBox* const binaryBox = new QGroupBox(vbox); 0097 QGridLayout* const binaryLayout = new QGridLayout; 0098 binaryBox->setLayout(binaryLayout); 0099 binaryBox->setTitle(i18nc("@title:group", "Optional Gimp Binaries")); 0100 d->binSearch = new DBinarySearch(binaryBox); 0101 d->binSearch->addBinary(d->gimpBin); 0102 0103 #ifdef Q_OS_MACOS 0104 0105 // Gimp bundle PKG install 0106 0107 d->binSearch->addDirectory(QLatin1String("/Applications/Gimp.app/Contents/MacOS")); 0108 d->binSearch->addDirectory(QLatin1String("/Applications/GIMP-2.10.app/Contents/MacOS")); 0109 0110 // Std Macports install 0111 0112 d->binSearch->addDirectory(QLatin1String("/opt/local/bin")); 0113 0114 #endif 0115 0116 #ifdef Q_OS_WIN 0117 0118 d->binSearch->addDirectory(QLatin1String("C:/Program Files/GIMP 2/bin")); 0119 0120 d->binSearch->addDirectory(QLatin1String("C:/Program Files (x86)/GIMP 2/bin")); 0121 0122 #endif 0123 0124 vbox->setStretchFactor(desc, 2); 0125 vbox->setStretchFactor(d->hbox, 1); 0126 vbox->setStretchFactor(binaryBox, 3); 0127 0128 setPageWidget(vbox); 0129 setLeftBottomPix(QIcon::fromTheme(QLatin1String("document-print"))); 0130 } 0131 0132 AdvPrintIntroPage::~AdvPrintIntroPage() 0133 { 0134 delete d; 0135 } 0136 0137 void AdvPrintIntroPage::initializePage() 0138 { 0139 bool albumSupport = (d->iface && d->iface->supportAlbums()); 0140 0141 if (!albumSupport) 0142 { 0143 d->imageGetOption->setCurrentIndex(AdvPrintSettings::IMAGES); 0144 d->hbox->setEnabled(false); 0145 } 0146 else 0147 { 0148 d->imageGetOption->setCurrentIndex(d->wizard->settings()->selMode); 0149 } 0150 0151 d->binSearch->allBinariesFound(); 0152 } 0153 0154 bool AdvPrintIntroPage::validatePage() 0155 { 0156 d->wizard->settings()->selMode = (AdvPrintSettings::Selection)d->imageGetOption->currentIndex(); 0157 d->wizard->settings()->gimpPath = d->gimpBin.isValid() ? d->gimpBin.path() : QString(); 0158 0159 return true; 0160 } 0161 0162 } // namespace DigikamGenericPrintCreatorPlugin 0163 0164 #include "moc_advprintintropage.cpp"