File indexing completed on 2025-01-19 03:51:10
0001 /* ============================================================ 0002 * 0003 * This file is a part of digiKam project 0004 * https://www.digikam.org 0005 * 0006 * Date : 2009-02-06 0007 * Description : image editor printing interface. 0008 * 0009 * SPDX-FileCopyrightText: 2009 by Angelo Naselli <anaselli at linux dot it> 0010 * SPDX-FileCopyrightText: 2009-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 "printconfig.h" 0017 0018 // Qt includes 0019 0020 #include <qglobal.h> 0021 #include <QFile> 0022 0023 namespace DigikamEditorPrintToolPlugin 0024 { 0025 0026 class Q_DECL_HIDDEN PrintConfigHelper 0027 { 0028 public: 0029 0030 PrintConfigHelper() 0031 : q(nullptr) 0032 { 0033 } 0034 0035 ~PrintConfigHelper() 0036 { 0037 delete q; 0038 } 0039 0040 PrintConfig* q; 0041 }; 0042 0043 Q_GLOBAL_STATIC(PrintConfigHelper, s_globalPrintConfig) 0044 0045 // ------------------------------------------------------- 0046 0047 PrintConfig* PrintConfig::self() 0048 { 0049 if (!s_globalPrintConfig()->q) 0050 { 0051 new PrintConfig; 0052 s_globalPrintConfig()->q->read(); 0053 } 0054 0055 return s_globalPrintConfig()->q; 0056 } 0057 0058 PrintConfig::PrintConfig() 0059 : KConfigSkeleton(QLatin1String("digikamrc")) 0060 { 0061 Q_ASSERT(!s_globalPrintConfig()->q); 0062 0063 s_globalPrintConfig()->q = this; 0064 setCurrentGroup(QLatin1String("Print")); 0065 0066 KConfigSkeleton::ItemInt* const itemPrintPosition 0067 = new KConfigSkeleton::ItemInt(currentGroup(), QLatin1String("PrintPosition"), 0068 mPrintPosition, Qt::AlignHCenter | Qt::AlignVCenter); 0069 0070 addItem( itemPrintPosition, QLatin1String("PrintPosition")); 0071 0072 QList<KConfigSkeleton::ItemEnum::Choice> valuesPrintScaleMode; 0073 { 0074 KConfigSkeleton::ItemEnum::Choice choice; 0075 choice.name = QLatin1String("PrintOptionsPage::NoScale"); 0076 valuesPrintScaleMode.append(choice); 0077 } 0078 0079 { 0080 KConfigSkeleton::ItemEnum::Choice choice; 0081 choice.name = QLatin1String("PrintOptionsPage::ScaleToPage"); 0082 valuesPrintScaleMode.append(choice); 0083 } 0084 0085 { 0086 KConfigSkeleton::ItemEnum::Choice choice; 0087 choice.name = QLatin1String("PrintOptionsPage::ScaleToCustomSize"); 0088 valuesPrintScaleMode.append(choice); 0089 } 0090 0091 KConfigSkeleton::ItemEnum* const itemPrintScaleMode 0092 = new KConfigSkeleton::ItemEnum(currentGroup(), QLatin1String("PrintScaleMode"), 0093 mPrintScaleMode, valuesPrintScaleMode, 0094 PrintOptionsPage::ScaleToPage); 0095 addItem(itemPrintScaleMode, QLatin1String("PrintScaleMode")); 0096 0097 KConfigSkeleton::ItemBool* const itemPrintEnlargeSmallerImages 0098 = new KConfigSkeleton::ItemBool(currentGroup(), QLatin1String("PrintEnlargeSmallerImages"), 0099 mPrintEnlargeSmallerImages, false); 0100 addItem(itemPrintEnlargeSmallerImages, QLatin1String("PrintEnlargeSmallerImages")); 0101 0102 KConfigSkeleton::ItemDouble* const itemPrintWidth 0103 = new KConfigSkeleton::ItemDouble(currentGroup(), QLatin1String("PrintWidth"), 0104 mPrintWidth, 15.0); 0105 addItem(itemPrintWidth, QLatin1String("PrintWidth")); 0106 0107 KConfigSkeleton::ItemDouble* const itemPrintHeight 0108 = new KConfigSkeleton::ItemDouble(currentGroup(), QLatin1String("PrintHeight"), 0109 mPrintHeight, 10.0); 0110 addItem(itemPrintHeight, QLatin1String("PrintHeight")); 0111 0112 QList<KConfigSkeleton::ItemEnum::Choice> valuesPrintUnit; 0113 { 0114 KConfigSkeleton::ItemEnum::Choice choice; 0115 choice.name = QLatin1String("PrintOptionsPage::Millimeters"); 0116 valuesPrintUnit.append(choice); 0117 } 0118 0119 { 0120 KConfigSkeleton::ItemEnum::Choice choice; 0121 choice.name = QLatin1String("PrintOptionsPage::Centimeters"); 0122 valuesPrintUnit.append(choice); 0123 } 0124 0125 { 0126 KConfigSkeleton::ItemEnum::Choice choice; 0127 choice.name = QLatin1String("PrintOptionsPage::Inches"); 0128 valuesPrintUnit.append(choice); 0129 } 0130 0131 KConfigSkeleton::ItemEnum* const itemPrintUnit 0132 = new KConfigSkeleton::ItemEnum(currentGroup(), QLatin1String("PrintUnit"), 0133 mPrintUnit, valuesPrintUnit, PrintOptionsPage::Centimeters); 0134 addItem(itemPrintUnit, QLatin1String("PrintUnit")); 0135 0136 KConfigSkeleton::ItemBool* const itemPrintKeepRatio 0137 = new KConfigSkeleton::ItemBool(currentGroup(), QLatin1String("PrintKeepRatio"), 0138 mPrintKeepRatio, true); 0139 addItem( itemPrintKeepRatio, QLatin1String("PrintKeepRatio")); 0140 0141 KConfigSkeleton::ItemBool* const itemPrintColorManaged 0142 = new KConfigSkeleton::ItemBool(currentGroup(), QLatin1String("PrintColorManaged"), 0143 mPrintColorManaged, false); 0144 addItem(itemPrintColorManaged, QLatin1String("PrintColorManaged")); 0145 0146 KConfigSkeleton::ItemBool* const itemPrintAutoRotate 0147 = new KConfigSkeleton::ItemBool(currentGroup(), QLatin1String("PrintAutoRotate"), 0148 mPrintAutoRotate, false); 0149 addItem(itemPrintAutoRotate, QLatin1String("PrintAutoRotate")); 0150 } 0151 0152 PrintConfig::~PrintConfig() 0153 { 0154 s_globalPrintConfig()->q = nullptr; 0155 } 0156 0157 } // namespace DigikamEditorPrintToolPlugin 0158 0159 #include "moc_printconfig.cpp"