File indexing completed on 2024-12-22 04:13:10

0001 /*
0002  * SPDX-FileCopyrightText: 2005 Thomas Zander <zander@kde.org>
0003  * SPDX-FileCopyrightText: 2005 C. Boemann <cbo@boemann.dk>
0004  *
0005  *  SPDX-License-Identifier: GPL-2.0-or-later
0006  */
0007 #ifndef KIS_CUSTOM_IMAGE_WIDGET_H
0008 #define KIS_CUSTOM_IMAGE_WIDGET_H
0009 
0010 #include "kis_global.h"
0011 #include "KoUnit.h"
0012 #include "kis_properties_configuration.h"
0013 #include "KisOpenPane.h"
0014 
0015 #include <ui_wdgnewimage.h>
0016 
0017 class KisDocument;
0018 class KisDocument;
0019 
0020 enum CustomImageWidgetType { CUSTOM_DOCUMENT, NEW_IMG_FROM_CB };
0021 
0022 class WdgNewImage : public QWidget, public Ui::WdgNewImage
0023 {
0024     Q_OBJECT
0025 
0026 public:
0027     WdgNewImage(QWidget *parent)
0028         : QWidget(parent)
0029     {
0030         setupUi(this);
0031     }
0032 };
0033 
0034 /**
0035  * The 'Custom Document' widget in the Krita startup widget.
0036  * This class embeds the image size and colorspace to allow the user to select the image properties
0037  * for a new empty image document.
0038  */
0039 class KisCustomImageWidget : public WdgNewImage
0040 {
0041     Q_OBJECT
0042 public:
0043     /**
0044      * Constructor. Please note that this class is being used/created by KisDoc.
0045      * @param parent the parent widget
0046      * @param defWidth The defined width
0047      * @param defHeight The defined height
0048      * @param resolution The image resolution
0049      * @param defColorModel The defined color model
0050      * @param defColorDepth The defined color depth
0051      * @param defColorProfile The defined color profile
0052      * @param imageName the document that wants to be altered
0053      */
0054     KisCustomImageWidget(QWidget *parent, qint32 defWidth, qint32 defHeight, double resolution, const QString & defColorModel, const QString & defColorDepth, const QString & defColorProfile, const QString & imageName);
0055     ~KisCustomImageWidget() override;
0056     
0057 private Q_SLOTS:
0058     void widthUnitChanged(int index);
0059     void widthChanged(double value);
0060     void heightUnitChanged(int index);
0061     void heightChanged(double value);
0062     void resolutionChanged(double value);
0063     void predefinedClicked(int index);
0064     void saveAsPredefined();
0065     void setLandscape();
0066     void setPortrait();
0067     void switchWidthHeight();
0068     void createImage();
0069     void switchPortraitLandscape();
0070     void changeDocumentInfoLabel();
0071     void resolutionUnitChanged();
0072 
0073 protected:
0074     
0075     KisDocument *createNewImage();
0076     
0077     /// Set the number of layers that will be created
0078     void setNumberOfLayers(int layers);
0079 
0080     void showEvent(QShowEvent *) override;
0081 
0082     KisOpenPane *m_openPane;
0083 private:
0084 
0085     double m_width, m_height;
0086     quint8 backgroundOpacity() const;
0087     void setBackgroundOpacity(quint8 value);
0088 
0089     void fillPredefined();
0090 
0091     
0092     KoUnit m_widthUnit, m_heightUnit;
0093     QList<KisPropertiesConfigurationSP> m_predefined;
0094 
0095 };
0096 
0097 #endif