Skip to content

armgit / krita

Public Imported from GitHub
0

Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.

C++
2.4 KB
Raw Blame
/*
 * SPDX-FileCopyrightText: 2005 Thomas Zander <[email protected]>
 * SPDX-FileCopyrightText: 2005 C. Boemann <[email protected]>
 *
 *  SPDX-License-Identifier: GPL-2.0-or-later
 */
#ifndef KIS_CUSTOM_IMAGE_WIDGET_H
#define KIS_CUSTOM_IMAGE_WIDGET_H

#include "kis_global.h"
#include "KoUnit.h"
#include "kis_properties_configuration.h"
#include "KisOpenPane.h"

#include <ui_wdgnewimage.h>

class KisDocument;
class KisDocument;

enum CustomImageWidgetType { CUSTOM_DOCUMENT, NEW_IMG_FROM_CB };

class WdgNewImage : public QWidget, public Ui::WdgNewImage
{
    Q_OBJECT

public:
    WdgNewImage(QWidget *parent)
        : QWidget(parent)
    {
        setupUi(this);
    }
};

/**
 * The 'Custom Document' widget in the Krita startup widget.
 * This class embeds the image size and colorspace to allow the user to select the image properties
 * for a new empty image document.
 */
class KisCustomImageWidget : public WdgNewImage
{
    Q_OBJECT
public:
    /**
     * Constructor. Please note that this class is being used/created by KisDoc.
     * @param parent the parent widget
     * @param imageName the document that wants to be altered
     * @param dialogType is a prefix that will be used for fetching image layout settings
     */
    KisCustomImageWidget(QWidget *parent, const QString & imageName, const QLatin1String &dialogType);
    ~KisCustomImageWidget() override;
    
private Q_SLOTS:
    void widthUnitChanged(int index);
    void widthChanged(double value);
    void heightUnitChanged(int index);
    void heightChanged(double value);
    void resolutionChanged(double value);
    void predefinedClicked(int index);
    void saveAsPredefined();
    void setLandscape();
    void setPortrait();
    void switchWidthHeight();
    virtual void createImage();
    void switchPortraitLandscape();
    void changeDocumentInfoLabel();
    void resolutionUnitChanged();

protected:
    
    KisDocument *createNewImage();

    /// Set the number of layers that will be created
    void setNumberOfLayers(int layers);
    virtual bool shouldSaveImageDimensions() const;

    void showEvent(QShowEvent *) override;

    KisOpenPane *m_openPane;
private:

    double m_width, m_height;
    quint8 backgroundOpacity() const;
    void setBackgroundOpacity(quint8 value);

    void fillPredefined();

    
    KoUnit m_widthUnit, m_heightUnit;
    QList<KisPropertiesConfigurationSP> m_predefined;
    QLatin1String m_dialogType;
};

#endif