Commit cbf81220 authored by Dmitry Kazakov's avatar Dmitry Kazakov

Merge remote-tracking branch 'origin/master' into kazakov/hdr-support

parents fce99ed1 7d4289d8
......@@ -3,8 +3,8 @@ SET(PREFIX_ext_gmic "${EXTPREFIX}" )
# Download the gmic sources
ExternalProject_Add( ext_gmic_base
DOWNLOAD_DIR ${EXTERNALS_DOWNLOAD_DIR}
URL https://gmic.eu/files/source/gmic_2.4.2.tar.gz
URL_MD5 a43389984672136ab04e0a170ed233b7
URL https://gmic.eu/files/source/gmic_2.4.5.tar.gz
URL_MD5 e1bc34379800d9b1330419a695824caf
SOURCE_DIR gmic
......@@ -19,8 +19,8 @@ ExternalProject_Add( ext_gmic_base
# FIXME: Forcing CMAKE_BUILD_TYPE to Release
ExternalProject_Add( ext_gmic_qt
DOWNLOAD_DIR ${EXTERNALS_DOWNLOAD_DIR}
URL https://github.com/c-koi/gmic-qt/archive/v.2.4.2.tar.gz
URL_MD5 09d952786980d76df8feb2aca0167b17
URL https://github.com/c-koi/gmic-qt/archive/v.2.4.5.tar.gz
URL_MD5 664ecce5516c2f7995882487b317dcb0
PATCH_COMMAND ${PATCH_COMMAND} -p1 -i ${CMAKE_CURRENT_SOURCE_DIR}/desktop_icon.diff
SOURCE_DIR gmic-qt
......
......@@ -7,8 +7,8 @@ if (UNIX)
endif()
ExternalProject_Add( ext_pyqt
DOWNLOAD_DIR ${EXTERNALS_DOWNLOAD_DIR}
URL https://files.kde.org/krita/build/dependencies/PyQt5_gpl-5.9.2.zip
URL_MD5 67eacf2f486f77136c9758e03fe6889e
URL https://www.riverbankcomputing.com/static/Downloads/PyQt5/PyQt5_gpl-5.12.zip
URL_MD5 102062aff7435c03114e02c456dfd01f
CONFIGURE_COMMAND ${PYTHON_EXECUTABLE_PATH} <SOURCE_DIR>/configure.py --confirm-license --qmake ${PREFIX_ext_pyqt}/bin/qmake --sip ${PREFIX_ext_pyqt}/bin/sip --sip-incdir ${PREFIX_ext_pyqt}/include --sipdir ${PREFIX_ext_pyqt}/share/sip
BUILD_COMMAND make
......@@ -19,6 +19,7 @@ if (UNIX)
UPDATE_COMMAND ""
)
elseif(MINGW)
list(APPEND _PYQT_conf
--confirm-license
--target-py-version 3.6
......@@ -32,17 +33,17 @@ elseif(MINGW)
--destdir ${PREFIX_ext_pyqt}/lib/krita-python-libs
--stubsdir ${PREFIX_ext_pyqt}/lib/krita-python-libs/PyQt5
--no-qml-plugin --no-python-dbus --no-qsci-api --no-tools
--disable QtSql --disable QtTest --disable QtWinExtras
--disable QtSql --disable QtTest --disable QtWinExtras --disable QtHelp
)
ExternalProject_Add( ext_pyqt
DOWNLOAD_DIR ${EXTERNALS_DOWNLOAD_DIR}
URL https://files.kde.org/krita/build/dependencies/PyQt5_gpl-5.9.2.zip
URL_MD5 67eacf2f486f77136c9758e03fe6889e
URL https://www.riverbankcomputing.com/static/Downloads/PyQt5/PyQt5_gpl-5.12.tar.gz
URL_MD5 757161fc19a2da788962fbc5d18480c0
PATCH_COMMAND ${PATCH_COMMAND} -p1 -i ${CMAKE_CURRENT_SOURCE_DIR}/pyqt-configure-fix.patch
CONFIGURE_COMMAND ${PYTHON_EXECUTABLE} <SOURCE_DIR>/configure.py ${_PYQT_conf}
BUILD_COMMAND mingw32-make -j${SUBMAKE_JOBS} CXXFLAGS=-D_hypot=hypot LDFLAGS=${SECURITY_SHARED_LINKER_FLAGS}
INSTALL_COMMAND mingw32-make -j${SUBMAKE_JOBS} install
INSTALL_COMMAND mingw32-make install
BUILD_IN_SOURCE 1
......
......@@ -29,12 +29,12 @@ if (WIN32)
else (QT_ENABLE_DYNAMIC_OPENGL)
list(APPEND _QT_conf -opengl desktop -no-angle)
endif (QT_ENABLE_DYNAMIC_OPENGL)
ExternalProject_Add(
ext_qt
DOWNLOAD_DIR ${EXTERNALS_DOWNLOAD_DIR}
URL https://download.qt.io/archive/qt/5.12/5.12.1/single/qt-everywhere-src-5.12.1.zip
URL_HASH SHA1=5ba3e56475912e8784f825fd8d0d139ec5eca8b3
URL https://download.qt.io/archive/qt/5.12/5.12.1/single/qt-everywhere-src-5.12.1.tar.xz
URL_HASH SHA1=018b7467faeda9979fe6b4a435214903c3a20018
PATCH_COMMAND ${PATCH_COMMAND} -p1 -d qtbase -i ${CMAKE_CURRENT_SOURCE_DIR}/0001-disable-wintab.patch
COMMAND ${PATCH_COMMAND} -p1 -d qtbase -i ${CMAKE_CURRENT_SOURCE_DIR}/0002-Don-t-request-the-MIME-image-every-time-Windows-asks.patch
COMMAND ${PATCH_COMMAND} -p1 -d qtbase -i ${CMAKE_CURRENT_SOURCE_DIR}/0003-Hack-always-return-we-support-DIBV5.patch
......@@ -56,11 +56,12 @@ elseif (NOT APPLE)
ExternalProject_Add(
ext_qt
DOWNLOAD_DIR ${EXTERNALS_DOWNLOAD_DIR}
URL https://download.qt.io/official_releases/qt/5.10/5.10.0/single/qt-everywhere-src-5.10.0.tar.xz
URL https://download.qt.io/archive/qt/5.12/5.12.1/single/qt-everywhere-src-5.12.1.tar.xz
URL_HASH SHA1=018b7467faeda9979fe6b4a435214903c3a20018
URL_MD5 c5e275ab0ed7ee61d0f4b82cd471770d
#PATCH_COMMAND ${PATCH_COMMAND} -p1 -i ${CMAKE_CURRENT_SOURCE_DIR}/qt-no-motion-compression.diff
CONFIGURE_COMMAND <SOURCE_DIR>/configure -prefix ${EXTPREFIX_qt} -opensource -confirm-license -verbose -nomake examples -skip qt3d -skip qtactiveqt -skip qtcanvas3d -skip qtconnectivity -skip qtgraphicaleffects -skip qtlocation -skip qtwayland -skip qtwebchannel -skip qtwebengine -skip qtwebsockets -skip qtwebview -skip qtandroidextras -skip qtserialport -skip qtdatavis3d -skip qtvirtualkeyboard -skip qtspeech -skip qtsensors -skip qtgamepad -skip qtscxml -skip qtremoteobjects -skip qtxmlpatterns -skip qtnetworkauth -skip qtcharts -skip qtdatavis3d -skip qtgamepad -skip qtpurchasing -skip qtscxml -skip qtserialbus -skip qtspeech -skip qtvirtualkeyboard
CONFIGURE_COMMAND <SOURCE_DIR>/configure -prefix ${EXTPREFIX_qt} -opensource -confirm-license -verbose -nomake examples -skip qt3d -skip qtactiveqt -skip qtcanvas3d -skip qtconnectivity -skip qtgraphicaleffects -skip qtlocation -skip qtwayland -skip qtwebchannel -skip qtwebengine -skip qtwebsockets -skip qtwebview -skip qtandroidextras -skip qtserialport -skip qtdatavis3d -skip qtvirtualkeyboard -skip qtspeech -skip qtsensors -skip qtgamepad -skip qtscxml -skip qtremoteobjects -skip qtxmlpatterns -skip qtnetworkauth -skip qtcharts -skip qtdatavis3d -skip qtgamepad -skip qtpurchasing -skip qtscxml -skip qtserialbus -skip qtspeech -skip qtvirtualkeyboard -xcb
INSTALL_DIR ${EXTPREFIX_qt}
BUILD_COMMAND $(MAKE)
......@@ -185,7 +186,7 @@ else( APPLE )
set(PARALLEL_MAKE "make")
endif()
ExternalProject_Add(ext_qt
DOWNLOAD_DIR ${EXTERNALS_DOWNLOAD_DIR}
......@@ -197,15 +198,13 @@ else( APPLE )
LOG_INSTALL ON
BUILD_IN_SOURCE ON
URL https://download.qt.io/official_releases/qt/5.10/5.10.0/single/qt-everywhere-src-5.10.0.tar.xz
URL_MD5 c5e275ab0ed7ee61d0f4b82cd471770d
PATCH_COMMAND ${ext_qt_PATCH_COMMAND}
URL https://download.qt.io/archive/qt/5.12/5.12.1/single/qt-everywhere-src-5.12.1.zip
URL_HASH SHA1=5ba3e56475912e8784f825fd8d0d139ec5eca8b3
INSTALL_DIR ${EXTPREFIX_qt}
CONFIGURE_COMMAND <SOURCE_DIR>/configure
CONFIGURE_COMMAND <SOURCE_DIR>/configure
-skip qt3d -skip qtactiveqt -skip qtcanvas3d -skip qtconnectivity -skip qtdoc -skip qtgraphicaleffects -skip qtlocation -skip qtsensors -skip qtserialport -skip qtwayland
-skip qtwebchannel -skip qtwebengine -skip qtwebsockets -skip qtwebview -skip qtxmlpatterns -no-sql-sqlite -skip qtcharts -skip qtdatavis3d -skip qtgamepad -skip qtnetworkauth -skip qtpurchasing -skip qtremoteobjects -skip qtscxml -skip qtserialbus -skip qtspeech -skip qtvirtualkeyboard -nomake examples -nomake tools -no-compile-examples -no-dbus -no-iconv -no-qml-debug -no-libproxy -no-system-proxies -no-icu -no-mtdev -system-zlib -qt-pcre -opensource -confirm-license -prefix ${EXTPREFIX_qt}
-skip qtwebchannel -skip qtwebsockets -skip qtwebview -skip qtxmlpatterns -no-sql-sqlite -skip qtcharts -skip qtdatavis3d -skip qtgamepad -skip qtnetworkauth -skip qtpurchasing -skip qtremoteobjects -skip qtscxml -skip qtserialbus -skip qtspeech -skip qtvirtualkeyboard -nomake examples -nomake tools -no-compile-examples -no-dbus -no-iconv -no-qml-debug -no-libproxy -no-system-proxies -no-icu -no-mtdev -system-zlib -qt-pcre -opensource -confirm-license -prefix ${EXTPREFIX_qt}
BUILD_COMMAND ${PARALLEL_MAKE}
INSTALL_COMMAND make install
UPDATE_COMMAND ""
......
......@@ -8,8 +8,8 @@ if (UNIX)
ExternalProject_Add( ext_sip
DOWNLOAD_DIR ${EXTERNALS_DOWNLOAD_DIR}
URL https://files.kde.org/krita/build/dependencies/sip-4.19.6.tar.gz
URL_MD5 6be5cb2c43915ed450a9f74ec110dada
URL https://www.riverbankcomputing.com/static/Downloads/sip/sip-4.19.14.tar.gz
URL_MD5 bba62b2ea7e16193c7dfcfadb8dd0d05
CONFIGURE_COMMAND ${PYTHON_EXECUTABLE_PATH} <SOURCE_DIR>/configure.py -b ${PREFIX_ext_sip}/bin -d ${PREFIX_ext_sip}/sip -e ${PREFIX_ext_sip}/include --sipdir ${PREFIX_ext_sip}/sip --target-py-version 3.5
BUILD_COMMAND make
......@@ -30,8 +30,8 @@ elseif (MINGW)
)
ExternalProject_Add( ext_sip
DOWNLOAD_DIR ${EXTERNALS_DOWNLOAD_DIR}
URL https://files.kde.org/krita/build/dependencies/sip-4.19.6.zip
URL_MD5 6a4080268c2aa9225965415fe8706967
URL https://www.riverbankcomputing.com/static/Downloads/sip/sip-4.19.14.tar.gz
URL_MD5 bba62b2ea7e16193c7dfcfadb8dd0d05
CONFIGURE_COMMAND ${PYTHON_EXECUTABLE} <SOURCE_DIR>/configure.py ${_SIP_conf}
BUILD_COMMAND mingw32-make -j${SUBMAKE_JOBS} LDFLAGS=${SECURITY_SHARED_LINKER_FLAGS}
......
......@@ -61,7 +61,7 @@ if (APPLE)
endif()
if (CMAKE_COMPILER_IS_GNUCXX AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9 AND NOT WIN32)
add_definitions(-Wno-suggest-override)
endif()
######################
......
......@@ -562,7 +562,7 @@
<Actions category="View">
<text>View</text>
<Action name="view_show_canvas_only">
<icon></icon>
<icon>document-new</icon>
<text>&amp;Show Canvas Only</text>
<whatsThis></whatsThis>
<toolTip>Show just the canvas or the whole window</toolTip>
......
......@@ -31,6 +31,7 @@ public:
/**
* Constructor
* @param node the layer to add
* @param newPropertyList the property list to which the node to be added
*/
KisNodePropertyListCommand(KisNodeSP node, KisBaseNode::PropertyList newPropertyList);
......
......@@ -116,7 +116,7 @@ struct Q_DECL_HIDDEN KisSafeTransform::Private
prevCross = cross;
}
if (!result.isClosed()) {
if (result.size() > 0 && !result.isClosed()) {
result << result.first();
}
......
......@@ -30,6 +30,10 @@ IconImageProvider::IconImageProvider()
QImage IconImageProvider::requestImage(const QString &id, QSize */*size*/, const QSize &requestedSize)
{
QIcon icon = KisIconUtils::loadIcon(id);
Q_ASSERT(!icon.isNull());
if (icon.isNull()) {
QImage img = QImage(requestedSize, QImage::Format_ARGB32);
img.fill(Qt::transparent);
return img;
}
return icon.pixmap(requestedSize).toImage();
}
......@@ -66,7 +66,6 @@ KoCompositeOpRegistry::KoCompositeOpRegistry()
m_map.insert(m_categories[1], KoID(COMPOSITE_NOT_CONVERSE , i18n("NOT CONVERSE")));
m_map.insert(m_categories[2], KoID(COMPOSITE_BURN , i18n("Burn")));
m_map.insert(m_categories[2], KoID(COMPOSITE_BURN_LOGARITHMIC , i18n("Burn - Logarithmic")));
m_map.insert(m_categories[2], KoID(COMPOSITE_LINEAR_BURN, i18n("Linear Burn")));
m_map.insert(m_categories[2], KoID(COMPOSITE_DARKEN , i18n("Darken")));
m_map.insert(m_categories[2], KoID(COMPOSITE_GAMMA_DARK , i18n("Gamma Dark")));
......@@ -76,7 +75,6 @@ KoCompositeOpRegistry::KoCompositeOpRegistry()
m_map.insert(m_categories[2], KoID(COMPOSITE_EASY_BURN , i18n("Easy Burn")));
m_map.insert(m_categories[3], KoID(COMPOSITE_DODGE , i18n("Color Dodge")));
m_map.insert(m_categories[3], KoID(COMPOSITE_DODGE_LOGARITHMIC , i18n("Color Dodge - Logarithmic")));
m_map.insert(m_categories[3], KoID(COMPOSITE_LINEAR_DODGE, i18n("Linear Dodge")));
m_map.insert(m_categories[3], KoID(COMPOSITE_LIGHTEN , i18n("Lighten")));
m_map.insert(m_categories[3], KoID(COMPOSITE_LINEAR_LIGHT, i18n("Linear Light")));
......
......@@ -93,7 +93,6 @@ const QString COMPOSITE_PENUMBRAD = "penumbra d";
const QString COMPOSITE_DARKEN = "darken";
const QString COMPOSITE_BURN = "burn";//this is also known as 'color burn'.
const QString COMPOSITE_BURN_LOGARITHMIC = "burn_logarithmic";
const QString COMPOSITE_LINEAR_BURN = "linear_burn";
const QString COMPOSITE_GAMMA_DARK = "gamma_dark";
const QString COMPOSITE_SHADE_IFS_ILLUSIONS = "shade_ifs_illusions";
......@@ -102,7 +101,6 @@ const QString COMPOSITE_EASY_BURN = "easy burn";
const QString COMPOSITE_LIGHTEN = "lighten";
const QString COMPOSITE_DODGE = "dodge";
const QString COMPOSITE_DODGE_LOGARITHMIC = "dodge_logarithmic";
const QString COMPOSITE_LINEAR_DODGE = "linear_dodge";
const QString COMPOSITE_SCREEN = "screen";
const QString COMPOSITE_HARD_LIGHT = "hard_light";
......
......@@ -896,29 +896,6 @@ inline T cfModuloContinuous(T src, T dst) {
return cfMultiply(cfDivisiveModuloContinuous(src,dst),src);
}
template<class T>
inline T cfColorBurnLogarithmic(T src, T dst) {
using namespace Arithmetic;
//Also known as Darken from EffectBank/Illusions.hu. IFS Illusions had used this blending mode.
qreal fsrc = scale<qreal>(src);
qreal fdst = scale<qreal>(dst);
if (inv(fdst) == zeroValue<T>()) {
return scale<T>(log2(1.0 + abs(fsrc)/abs(inv(.999999))/8));
}
return scale<T>(log2(1.0 + abs(fsrc)/abs(inv(fdst))/8));
}
template<class T>
inline T cfColorDodgeLogarithmic(T src, T dst) {
using namespace Arithmetic;
//Also known as Lighten from EffectBank/Illusions.hu. IFS Illusions had used this blending mode.
return inv(cfColorBurnLogarithmic(inv(src),inv(dst)));
}
template<class T>
inline T cfEasyDodge(T src, T dst) {
using namespace Arithmetic;
......
......@@ -161,7 +161,6 @@ struct AddGeneralOps<Traits, true>
add<&cfSuperLight<Arg> >(cs, COMPOSITE_SUPER_LIGHT , i18n("Super Light") , KoCompositeOp::categoryLight());
add<&cfTintIFSIllusions<Arg> >(cs, COMPOSITE_TINT_IFS_ILLUSIONS , i18n("Tint (IFS Illusions)") , KoCompositeOp::categoryLight());
add<&cfFogLightenIFSIllusions<Arg> >(cs, COMPOSITE_FOG_LIGHTEN_IFS_ILLUSIONS , i18n("Fog Lighten (IFS Illusions)") , KoCompositeOp::categoryLight());
add<&cfColorDodgeLogarithmic<Arg> >(cs, COMPOSITE_DODGE_LOGARITHMIC , i18n("Color Dodge - Logarithmic") , KoCompositeOp::categoryLight());
add<&cfEasyDodge<Arg> >(cs, COMPOSITE_EASY_DODGE , i18n("Easy Dodge") , KoCompositeOp::categoryLight());
add<&cfColorBurn<Arg> >(cs, COMPOSITE_BURN , i18n("Color Burn") , KoCompositeOp::categoryDark());
......@@ -170,7 +169,6 @@ struct AddGeneralOps<Traits, true>
add<&cfGammaDark<Arg> >(cs, COMPOSITE_GAMMA_DARK , i18n("Gamma Dark") , KoCompositeOp::categoryDark());
add<&cfShadeIFSIllusions<Arg> >(cs, COMPOSITE_SHADE_IFS_ILLUSIONS , i18n("Shade (IFS_Illusions)") , KoCompositeOp::categoryDark());
add<&cfFogDarkenIFSIllusions<Arg> >(cs, COMPOSITE_FOG_DARKEN_IFS_ILLUSIONS , i18n("Fog Darken (IFS Illusions)") , KoCompositeOp::categoryDark());
add<&cfColorBurnLogarithmic<Arg> >(cs, COMPOSITE_BURN_LOGARITHMIC , i18n("Color Burn - Logarithmic") , KoCompositeOp::categoryDark());
add<&cfEasyBurn<Arg> >(cs, COMPOSITE_EASY_BURN , i18n("Easy Burn") , KoCompositeOp::categoryDark());
add<&cfAddition<Arg> >(cs, COMPOSITE_ADD , i18n("Addition") , KoCompositeOp::categoryArithmetic());
......
......@@ -43,7 +43,8 @@ set(kritaui_LIB_SRCS
canvas/kis_snap_config.cpp
canvas/kis_snap_line_strategy.cpp
canvas/KisSnapPointStrategy.cpp
dialogs/kis_about_application.cpp
canvas/KisMirrorAxisConfig.cpp
dialogs/kis_about_application.cpp
dialogs/kis_dlg_adj_layer_props.cc
dialogs/kis_dlg_adjustment_layer.cc
dialogs/kis_dlg_filter.cpp
......@@ -266,6 +267,7 @@ set(kritaui_LIB_SRCS
widgets/KoStrokeConfigWidget.cpp
widgets/KoFillConfigWidget.cpp
widgets/KisLayerStyleAngleSelector.cpp
widgets/KisMemoryReportButton.cpp
KisPaletteEditor.cpp
dialogs/KisDlgPaletteEditor.cpp
......
......@@ -121,6 +121,8 @@
#include "kis_async_action_feedback.h"
#include "KisCloneDocumentStroke.h"
#include <KisMirrorAxisConfig.h>
// Define the protocol used here for embedded documents' URL
// This used to "store" but QUrl didn't like it,
......@@ -256,6 +258,7 @@ public:
, autoSaveTimer(new QTimer(q))
, undoStack(new UndoStack(q))
, guidesConfig(rhs.guidesConfig)
, mirrorAxisConfig(rhs.mirrorAxisConfig)
, m_bAutoDetectedMime(rhs.m_bAutoDetectedMime)
, m_url(rhs.m_url)
, m_file(rhs.m_file)
......@@ -302,6 +305,7 @@ public:
KUndo2Stack *undoStack = 0;
KisGuidesConfig guidesConfig;
KisMirrorAxisConfig mirrorAxisConfig;
bool m_bAutoDetectedMime = false; // whether the mimetype in the arguments was detected by the part itself
QUrl m_url; // local url - the one displayed to the user.
......@@ -1585,6 +1589,23 @@ void KisDocument::setGuidesConfig(const KisGuidesConfig &data)
emit sigGuidesConfigChanged(d->guidesConfig);
}
const KisMirrorAxisConfig& KisDocument::mirrorAxisConfig() const
{
return d->mirrorAxisConfig;
}
void KisDocument::setMirrorAxisConfig(const KisMirrorAxisConfig &config)
{
if (d->mirrorAxisConfig == config) {
return;
}
d->mirrorAxisConfig = config;
setModified(true);
emit sigMirrorAxisConfigChanged();
}
void KisDocument::resetURL() {
setUrl(QUrl());
setLocalFilePath(QString());
......
......@@ -64,6 +64,7 @@ class KisUndoStore;
class KisPart;
class KisGridConfig;
class KisGuidesConfig;
class KisMirrorAxisConfig;
class QDomDocument;
class KisReferenceImagesLayer;
......@@ -350,6 +351,9 @@ public:
const KisGuidesConfig& guidesConfig() const;
void setGuidesConfig(const KisGuidesConfig &data);
const KisMirrorAxisConfig& mirrorAxisConfig() const;
void setMirrorAxisConfig(const KisMirrorAxisConfig& config);
QList<KoColorSet *> &paletteList();
void setPaletteList(const QList<KoColorSet *> &paletteList);
......@@ -452,6 +456,8 @@ Q_SIGNALS:
void sigReferenceImagesChanged();
void sigMirrorAxisConfigChanged();
private Q_SLOTS:
void finishExportInBackground();
void slotChildCompletedSavingInBackground(KisImportExportFilter::ConversionStatus status, const QString &errorMessage);
......
/*
* Copyright (c) 2019 Anna Medonosova <anna.medonosova@gmail.com>
*
* This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 2.1 of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <kis_dom_utils.h>
#include <QPointF>
#include "KisMirrorAxisConfig.h"
class Q_DECL_HIDDEN KisMirrorAxisConfig::Private
{
public:
Private()
: mirrorHorizontal(false)
, mirrorVertical(false)
, lockHorizontal(false)
, lockVertical(false)
, hideVerticalDecoration(false)
, hideHorizontalDecoration(false)
, handleSize(32.f)
, horizontalHandlePosition(64.f)
, verticalHandlePosition(64.f)
{}
bool operator==(const Private& rhs) {
return mirrorHorizontal == rhs.mirrorHorizontal &&
mirrorVertical == rhs.mirrorVertical &&
lockHorizontal == rhs.lockHorizontal &&
lockVertical == rhs.lockVertical &&
hideHorizontalDecoration == rhs.hideHorizontalDecoration &&
hideVerticalDecoration == rhs.hideVerticalDecoration &&
handleSize == rhs.handleSize &&
horizontalHandlePosition == rhs.horizontalHandlePosition &&
verticalHandlePosition == rhs.verticalHandlePosition &&
axisPosition == rhs.axisPosition;
}
bool mirrorHorizontal;
bool mirrorVertical;
bool lockHorizontal;
bool lockVertical;
bool hideVerticalDecoration;
bool hideHorizontalDecoration;
float handleSize;
float horizontalHandlePosition;
float verticalHandlePosition;
QPointF axisPosition;
};
KisMirrorAxisConfig::KisMirrorAxisConfig()
: QObject()
, d(new Private())
{
}
KisMirrorAxisConfig::~KisMirrorAxisConfig()
{
}
KisMirrorAxisConfig::KisMirrorAxisConfig(const KisMirrorAxisConfig &rhs)
: QObject()
, d(new Private(*rhs.d))
{
}
KisMirrorAxisConfig &KisMirrorAxisConfig::operator=(const KisMirrorAxisConfig &rhs)
{
if (&rhs != this) {
*d = *rhs.d;
}
return *this;
}
bool KisMirrorAxisConfig::operator==(const KisMirrorAxisConfig &rhs) const
{
return *d == *rhs.d;
}
bool KisMirrorAxisConfig::mirrorHorizontal()
{
return d->mirrorHorizontal;
}
void KisMirrorAxisConfig::setMirrorHorizontal(bool state)
{
d->mirrorHorizontal = state;
}
bool KisMirrorAxisConfig::mirrorVertical()
{
return d->mirrorVertical;
}
void KisMirrorAxisConfig::setMirrorVertical(bool state)
{
d->mirrorVertical = state;
}
bool KisMirrorAxisConfig::lockHorizontal()
{
return d->lockHorizontal;
}
void KisMirrorAxisConfig::setLockHorizontal(bool state)
{
d->lockHorizontal = state;
}
bool KisMirrorAxisConfig::lockVertical()
{
return d->lockVertical;
}
void KisMirrorAxisConfig::setLockVertical(bool state)
{
d->lockVertical = state;
}
bool KisMirrorAxisConfig::hideVerticalDecoration()
{
return d->hideVerticalDecoration;
}
void KisMirrorAxisConfig::setHideVerticalDecoration(bool state)
{
d->hideVerticalDecoration = state;
}
bool KisMirrorAxisConfig::hideHorizontalDecoration()
{
return d->hideHorizontalDecoration;
}
void KisMirrorAxisConfig::setHideHorizontalDecoration(bool state)
{
d->hideHorizontalDecoration = state;
}
float KisMirrorAxisConfig::handleSize()
{
return d->handleSize;
}
void KisMirrorAxisConfig::setHandleSize(float size)
{
d->handleSize = size;
}
float KisMirrorAxisConfig::horizontalHandlePosition()
{
return d->horizontalHandlePosition;
}
void KisMirrorAxisConfig::setHorizontalHandlePosition(float position)
{
d->horizontalHandlePosition = position;
}
float KisMirrorAxisConfig::verticalHandlePosition()
{
return d->verticalHandlePosition;
}
void KisMirrorAxisConfig::setVerticalHandlePosition(float position)
{
d->verticalHandlePosition = position;
}
QPointF KisMirrorAxisConfig::axisPosition()
{
return d->axisPosition;
}
void KisMirrorAxisConfig::setAxisPosition(QPointF position)
{
d->axisPosition = position;
}
QDomElement KisMirrorAxisConfig::saveToXml(QDomDocument &doc, const QString &tag) const
{
QDomElement mirrorAxisElement = doc.createElement(tag);
KisDomUtils::saveValue(&mirrorAxisElement, "mirrorHorizontal", d->mirrorHorizontal);
KisDomUtils::saveValue(&mirrorAxisElement, "mirrorVertical", d->mirrorVertical);
KisDomUtils::saveValue(&mirrorAxisElement, "lockHorizontal", d->lockHorizontal);
KisDomUtils::saveValue(&mirrorAxisElement, "lockVertical", d->lockVertical);
KisDomUtils::saveValue(&mirrorAxisElement, "hideHorizontalDecoration", d->hideHorizontalDecoration);
KisDomUtils::saveValue(&mirrorAxisElement, "hideVerticalDecoration", d->hideVerticalDecoration);
KisDomUtils::saveValue(&mirrorAxisElement, "handleSize", d->handleSize);
KisDomUtils::saveValue(&mirrorAxisElement, "horizontalHandlePosition", d->horizontalHandlePosition);
KisDomUtils::saveValue(&mirrorAxisElement, "verticalHandlePosition", d->verticalHandlePosition);
KisDomUtils::saveValue(&mirrorAxisElement, "axisPosition", d->axisPosition);
return mirrorAxisElement;
}
bool KisMirrorAxisConfig::loadFromXml(const QDomElement &parent)
{
bool result = true;
result &= KisDomUtils::loadValue(parent, "mirrorHorizontal", &d->mirrorHorizontal);
result &= KisDomUtils::loadValue(parent, "mirrorVertical", &d->mirrorVertical);
result &= KisDomUtils::loadValue(parent, "lockHorizontal", &d->lockHorizontal);
result &= KisDomUtils::loadValue(parent, "lockVertical", &d->lockVertical);
result &= KisDomUtils::loadValue(parent, "hideHorizontalDecoration", &d->hideHorizontalDecoration);
result &= KisDomUtils::loadValue(parent, "hideVerticalDecoration", &d->hideVerticalDecoration);
result &= KisDomUtils::loadValue(parent, "handleSize", &d->handleSize);
result &= KisDomUtils::loadValue(parent, "horizontalHandlePosition", &d->horizontalHandlePosition);
result &= KisDomUtils::loadValue(parent, "verticalHandlePosition", &d->verticalHandlePosition);
result &= KisDomUtils::loadValue(parent, "axisPosition", &d->axisPosition);
return result;
}
bool KisMirrorAxisConfig::isDefault() const
{
KisMirrorAxisConfig defaultConfig;
return *this == defaultConfig;
}
/*
* Copyright (c) 2019 Anna Medonosova <anna.medonosova@gmail.com>
*
* This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 2.1 of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef KISMIRRORAXISCONFIG_H
#define KISMIRRORAXISCONFIG_H
#include <QScopedPointer>
#include "kritaui_export.h"
#include <boost/operators.hpp>
class QDomElement;
class QDomDocument;
/**
* @brief The KisMirrorAxisConfig class stores configuration for the KisMirrorAxis
* canvas decoration. Contents are saved to/loaded from KRA documents.
*/
class KRITAUI_EXPORT KisMirrorAxisConfig : public QObject, boost::equality_comparable<KisMirrorAxisConfig>
{
Q_OBJECT
public:
KisMirrorAxisConfig();
~KisMirrorAxisConfig();
KisMirrorAxisConfig(const KisMirrorAxisConfig &rhs);
KisMirrorAxisConfig& operator=(const KisMirrorAxisConfig& rhs);
bool operator==(const KisMirrorAxisConfig& rhs) const;
bool mirrorHorizontal();
void setMirrorHorizontal(bool state);
bool mirrorVertical();
void setMirrorVertical(bool state);
bool lockHorizontal();
void setLockHorizontal(bool state);
bool lockVertical();
void setLockVertical(bool state);
bool hideVerticalDecoration();
void setHideVerticalDecoration(bool state);
bool hideHorizontalDecoration();
void setHideHorizontalDecoration(bool state);
float handleSize();
void setHandleSize(float size);
float horizontalHandlePosition();
void setHorizontalHandlePosition(float position);
float verticalHandlePosition();
void setVerticalHandlePosition(float position);
QPointF axisPosition();
void setAxisPosition(QPointF position);
/**
* @brief saveToXml() function for KisKraSaver
* @param doc
* @param tag
* @return
*/
QDomElement saveToXml(QDomDocument& doc, const QString &tag) const;
/**
* @brief loadFromXml() function for KisKraLoader
* @param parent element
* @return
*/
bool loadFromXml(const QDomElement &parent);
/**
* @brief Check whether the config object was changed, or is the class default.
* @return true, if the object is default; false, if the config was changed
*/
bool isDefault() const;
private:
class Private;
const QScopedPointer<Private> d;
};