diff --git a/libs/widgets/kis_double_parse_spin_box.cpp b/libs/widgets/kis_double_parse_spin_box.cpp index 50bee97f30..1784fc8f6c 100644 --- a/libs/widgets/kis_double_parse_spin_box.cpp +++ b/libs/widgets/kis_double_parse_spin_box.cpp @@ -1,245 +1,250 @@ /* * Copyright (c) 2016 Laurent Valentin Jospin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU 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_double_parse_spin_box.h" #include "kis_num_parser.h" #include #include #include #include #include #include // for qIsNaN KisDoubleParseSpinBox::KisDoubleParseSpinBox(QWidget *parent) : QDoubleSpinBox(parent), boolLastValid(true) { lastExprParsed = new QString("0.0"); connect(this, SIGNAL(noMoreParsingError()), this, SLOT(clearErrorStyle())); //hack to let the clearError be called, even if the value changed method is the one from QDoubleSpinBox. connect(this, SIGNAL(valueChanged(double)), this, SLOT(clearError())); connect(this, SIGNAL(errorWhileParsing(QString)), this, SLOT(setErrorStyle())); oldValue = value(); warningIcon = new QLabel(this); if (QFile(":/./16_light_warning.svg").exists()) { warningIcon->setPixmap(QIcon(":/./16_light_warning.svg").pixmap(16, 16)); } else { warningIcon->setText("!"); } warningIcon->setStyleSheet("background:transparent;"); warningIcon->move(1, 1); warningIcon->setVisible(false); isOldPaletteSaved = false; areOldMarginsSaved = false; } KisDoubleParseSpinBox::~KisDoubleParseSpinBox() { //needed to avoid a segfault during destruction. delete lastExprParsed; } double KisDoubleParseSpinBox::valueFromText(const QString & text) const { *lastExprParsed = text; bool ok; double ret; if ( (suffix().isEmpty() || !text.endsWith(suffix())) && (prefix().isEmpty() || !text.startsWith(prefix())) ) { ret = KisNumericParser::parseSimpleMathExpr(text, &ok); } else { QString expr = text; if (text.endsWith(suffix())) { expr.remove(text.size()-suffix().size(), suffix().size()); } if(text.startsWith(prefix())){ expr.remove(0, prefix().size()); } *lastExprParsed = expr; ret = KisNumericParser::parseSimpleMathExpr(expr, &ok); } if(qIsNaN(ret) || qIsInf(ret)){ ok = false; } if (!ok) { if (boolLastValid) { oldValue = value(); } boolLastValid = false; ret = oldValue; //in case of error set to minimum. } else { if (!boolLastValid) { oldValue = ret; } boolLastValid = true; } return ret; } QString KisDoubleParseSpinBox::textFromValue(double val) const { if (!boolLastValid) { emit errorWhileParsing(*lastExprParsed); return *lastExprParsed; } emit noMoreParsingError(); - double v = KisNumericParser::parseSimpleMathExpr(cleanText()); + double v = KisNumericParser::parseSimpleMathExpr(veryCleanText()); v = QString("%1").arg(v, 0, 'f', decimals()).toDouble(); - if (hasFocus() && (v == value() || (v >= maximum() && value() == maximum()) || (v <= minimum() && value() == minimum())) ) { //solve a very annoying bug where the formula can collapse while editing. With this trick the formula is not lost until focus is lost. - return cleanText(); + if (hasFocus() && (v == value() || (v > maximum() && value() == maximum()) || (v < minimum() && value() == minimum())) ) { //solve a very annoying bug where the formula can collapse while editing. With this trick the formula is not lost until focus is lost. + return veryCleanText(); } return QDoubleSpinBox::textFromValue(val); } +QString KisDoubleParseSpinBox::veryCleanText() const +{ + return cleanText(); +} + QValidator::State KisDoubleParseSpinBox::validate ( QString & input, int & pos ) const { Q_UNUSED(input); Q_UNUSED(pos); return QValidator::Acceptable; } void KisDoubleParseSpinBox::stepBy(int steps) { boolLastValid = true; //reset to valid state so we can use the up and down buttons. emit noMoreParsingError(); QDoubleSpinBox::stepBy(steps); } void KisDoubleParseSpinBox::setValue(double value) { if(value == oldValue && hasFocus()){ //avoid to reset the button when it set the value of something that will recall this slot. return; } if (!hasFocus()) { clearError(); } QDoubleSpinBox::setValue(value); } void KisDoubleParseSpinBox::setErrorStyle() { if (!boolLastValid) { //setStyleSheet(_oldStyleSheet + "Background: red; color: white; padding-left: 18px;"); if (!isOldPaletteSaved) { oldPalette = palette(); } isOldPaletteSaved = true; QPalette nP = oldPalette; nP.setColor(QPalette::Background, Qt::red); nP.setColor(QPalette::Base, Qt::red); nP.setColor(QPalette::Text, Qt::white); setPalette(nP); if (!areOldMarginsSaved) { oldMargins = lineEdit()->textMargins(); } areOldMarginsSaved = true; if (width() - height() >= 3*height()) { //if we have twice as much place as needed by the warning icon then display it. QMargins newMargins = oldMargins; newMargins.setLeft( newMargins.left() + height() - 4 ); lineEdit()->setTextMargins(newMargins); int h = warningIcon->height(); int hp = height()-2; if (h != hp) { warningIcon->resize(hp, hp); if (QFile(":/./16_light_warning.svg").exists()) { warningIcon->setPixmap(QIcon(":/./16_light_warning.svg").pixmap(hp-7, hp-7)); } } warningIcon->move(oldMargins.left()+4, 1); warningIcon->setVisible(true); } } } void KisDoubleParseSpinBox::clearErrorStyle() { if (boolLastValid) { warningIcon->setVisible(false); //setStyleSheet(""); setPalette(oldPalette); isOldPaletteSaved = false; lineEdit()->setTextMargins(oldMargins); areOldMarginsSaved = false; } } void KisDoubleParseSpinBox::clearError() { boolLastValid = true; emit noMoreParsingError(); oldValue = value(); clearErrorStyle(); } diff --git a/libs/widgets/kis_double_parse_spin_box.h b/libs/widgets/kis_double_parse_spin_box.h index 4c2b920773..ab45bf25f5 100644 --- a/libs/widgets/kis_double_parse_spin_box.h +++ b/libs/widgets/kis_double_parse_spin_box.h @@ -1,82 +1,85 @@ /* * Copyright (c) 2016 Laurent Valentin Jospin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU 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 KISDOUBLEPARSESPINBOX_H #define KISDOUBLEPARSESPINBOX_H #include #include "kritawidgets_export.h" class QLabel; /*! * \brief The KisDoubleParseSpinBox class is a cleverer doubleSpinBox, able to parse arithmetic expressions. * * Use this spinbox instead of the basic one from Qt if you want it to be able to parse arithmetic expressions. */ class KRITAWIDGETS_EXPORT KisDoubleParseSpinBox : public QDoubleSpinBox { Q_OBJECT public: KisDoubleParseSpinBox(QWidget* parent = 0); ~KisDoubleParseSpinBox(); virtual double valueFromText(const QString & text) const; virtual QString textFromValue(double val) const; virtual QValidator::State validate ( QString & input, int & pos ) const; virtual void stepBy(int steps); void setValue(double value); //polymorphism won't work directly, we use a signal/slot hack to do so but if signals are disabled this function will still be useful. bool isLastValid() const{ return boolLastValid; } + //! \brief this virtual function is similar to cleanText(); for KisDoubleParseSpinBox. But child class may remove additionnal artifacts. + virtual QString veryCleanText() const; + Q_SIGNALS: //! \brief signal emmitted when the last parsed expression create an error. void errorWhileParsing(QString expr) const; //! \brief signal emmitted when the last parsed expression is valid. void noMoreParsingError() const; public Q_SLOTS: //! \brief useful to let the widget change it's stylesheet when an error occured in the last expression. void setErrorStyle(); //! \brief useful to let the widget reset it's stylesheet when there's no more error. void clearErrorStyle(); //! \brief say the widget to return to an error free state. void clearError(); protected: mutable QString* lastExprParsed; mutable bool boolLastValid; mutable double oldValue; QLabel* warningIcon; QPalette oldPalette; bool isOldPaletteSaved; QMargins oldMargins; bool areOldMarginsSaved; }; #endif // KISDOUBLEPARSESPINBOX_H diff --git a/libs/widgets/kis_double_parse_unit_spin_box.cpp b/libs/widgets/kis_double_parse_unit_spin_box.cpp index 47c10515dc..d221f417c2 100644 --- a/libs/widgets/kis_double_parse_unit_spin_box.cpp +++ b/libs/widgets/kis_double_parse_unit_spin_box.cpp @@ -1,172 +1,220 @@ /* * Copyright (c) 2016 Laurent Valentin Jospin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU 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_double_parse_unit_spin_box.h" +#include "kis_spin_box_unit_manager.h" class Q_DECL_HIDDEN KisDoubleParseUnitSpinBox::Private { public: Private(double low, double up, double step) : lowerInPoints(low), upperInPoints(up), stepInPoints(step), - unit(KoUnit(KoUnit::Point)) + unit(KoUnit(KoUnit::Point)), + unitManager() { } double lowerInPoints; ///< lowest value in points double upperInPoints; ///< highest value in points double stepInPoints; ///< step in points KoUnit unit; + + KisSpinBoxUnitManager unitManager; //manage more units than permitted by KoUnit. }; KisDoubleParseUnitSpinBox::KisDoubleParseUnitSpinBox(QWidget *parent) : KisDoubleParseSpinBox(parent), d(new Private(-9999, 9999, 1)) { setUnit( KoUnit(KoUnit::Point) ); setAlignment( Qt::AlignRight ); connect(this, SIGNAL(valueChanged( double )), SLOT(privateValueChanged())); } KisDoubleParseUnitSpinBox::~KisDoubleParseUnitSpinBox() { delete d; } void KisDoubleParseUnitSpinBox::changeValue( double newValue ) { - if (d->unit.toUserValue(newValue) == oldValue) { + if (d->unitManager.getApparentValue(newValue) == KisDoubleParseSpinBox::value()) { return; } - KisDoubleParseSpinBox::setValue( d->unit.toUserValue(newValue) ); + KisDoubleParseSpinBox::setValue( d->unitManager.getApparentValue(newValue) ); } void KisDoubleParseUnitSpinBox::setUnit( const KoUnit & unit) { - if( unit == d->unit) return; - double oldValue = d->unit.fromUserValue( KisDoubleParseSpinBox::value() ); + if (d->unitManager.getUnitDimensionType() != KisSpinBoxUnitManager::LENGTH) { + d->unitManager.setUnitDim(KisSpinBoxUnitManager::LENGTH); //setting the unit using a KoUnit mean you want to use a length. + } + + setUnit(unit.symbol()); + d->unit = unit; +} +void KisDoubleParseUnitSpinBox::setUnit(const QString &symbol) +{ + + double oldValue = d->unitManager.getReferenceValue(KisDoubleParseSpinBox::value()); + QString oldSymbol = d->unitManager.getApparentUnitSymbol(); + + if (symbol == oldSymbol) { + return; + } + + d->unitManager.setApparentUnitFromSymbol(symbol); + + if (d->unitManager.getApparentUnitSymbol() == oldSymbol) { //the setApparentUnitFromSymbol is a bit clever, for example in regard of Casesensitivity. So better check like this. + return; + } - KisDoubleParseSpinBox::setMinimum( unit.toUserValue( d->lowerInPoints ) ); - KisDoubleParseSpinBox::setMaximum( unit.toUserValue( d->upperInPoints ) ); + KisDoubleParseSpinBox::setMinimum( d->unitManager.getApparentValue( d->lowerInPoints ) ); + KisDoubleParseSpinBox::setMaximum( d->unitManager.getApparentValue( d->upperInPoints ) ); - qreal step = unit.toUserValue( d->stepInPoints ); + qreal step = d->unitManager.getApparentValue( d->stepInPoints ); - if (unit.type() == KoUnit::Pixel) { + if (symbol == KoUnit(KoUnit::Pixel).symbol()) { // limit the pixel step by 1.0 step = qMax(qreal(1.0), step); } KisDoubleParseSpinBox::setSingleStep( step ); - d->unit = unit; - KisDoubleParseSpinBox::setValue( KoUnit::ptToUnit( oldValue, unit ) ); - setSuffix( unit.symbol().prepend(QLatin1Char(' ')) ); + KisDoubleParseSpinBox::setValue( d->unitManager.getApparentValue( oldValue ) ); + +} + + +void KisDoubleParseUnitSpinBox::setDimensionType(int dim) +{ + if (!KisSpinBoxUnitManager::isUnitId(dim)) { + return; + } + + d->unitManager.setUnitDim((KisSpinBoxUnitManager::UnitDimension) dim); } double KisDoubleParseUnitSpinBox::value( ) const { - return d->unit.fromUserValue( KisDoubleParseSpinBox::value() ); + return d->unitManager.getReferenceValue( KisDoubleParseSpinBox::value() ); } void KisDoubleParseUnitSpinBox::setMinimum(double min) { d->lowerInPoints = min; - KisDoubleParseSpinBox::setMinimum( d->unit.toUserValue( min ) ); + KisDoubleParseSpinBox::setMinimum( d->unitManager.getApparentValue( min ) ); } void KisDoubleParseUnitSpinBox::setMaximum(double max) { d->upperInPoints = max; - KisDoubleParseSpinBox::setMaximum( d->unit.toUserValue( max ) ); + KisDoubleParseSpinBox::setMaximum( d->unitManager.getApparentValue( max ) ); } void KisDoubleParseUnitSpinBox::setLineStep(double step) { - d->stepInPoints = KoUnit(KoUnit::Point).toUserValue(step); + d->stepInPoints = d->unitManager.getReferenceValue(step); KisDoubleParseSpinBox::setSingleStep( step ); } void KisDoubleParseUnitSpinBox::setLineStepPt(double step) { d->stepInPoints = step; - KisDoubleParseSpinBox::setSingleStep( d->unit.toUserValue( step ) ); + KisDoubleParseSpinBox::setSingleStep( d->unitManager.getApparentValue( step ) ); } void KisDoubleParseUnitSpinBox::setMinMaxStep( double min, double max, double step ) { setMinimum( min ); setMaximum( max ); setLineStepPt( step ); } QValidator::State KisDoubleParseUnitSpinBox::validate(QString &input, int &pos) const { Q_UNUSED(pos); QRegExp regexp ("([ a-zA-Z]+)$"); // Letters or spaces at end const int res = input.indexOf( regexp ); if ( res == -1 ) { // Nothing like an unit? The user is probably editing the unit return QValidator::Intermediate; } QString expr ( input.left( res ) ); const QString unitName ( regexp.cap( 1 ).trimmed().toLower() ); bool ok = true; bool interm = false; QValidator::State exprState = KisDoubleParseSpinBox::validate(expr, pos); if (exprState == QValidator::Invalid) { return exprState; } else if (exprState == QValidator::Intermediate) { interm = true; } //check if we can parse the unit. - KoUnit::fromSymbol(unitName, &ok); + QStringList listOfSymbol = d->unitManager.getsUnitSymbolList(); + ok = listOfSymbol.contains(unitName); if (!ok || interm) { return QValidator::Intermediate; } return QValidator::Acceptable; } QString KisDoubleParseUnitSpinBox::textFromValue( double value ) const { - return KisDoubleParseSpinBox::textFromValue(value); + return KisDoubleParseSpinBox::textFromValue(value) + " " + d->unitManager.getApparentUnitSymbol(); +} + +QString KisDoubleParseUnitSpinBox::veryCleanText() const +{ + QString expr = cleanText(); + QString symbol = d->unitManager.getApparentUnitSymbol(); + + expr = expr.trimmed(); + + if ( expr.endsWith(symbol) ) { + expr.remove(expr.size()-symbol.size(), symbol.size()); + } + + return expr; + } double KisDoubleParseUnitSpinBox::valueFromText( const QString& str ) const { - //KisDoubleParseSpinBox is supposed to remove the suffix and prefix by itself. - return KisDoubleParseSpinBox::valueFromText(str); + return KisDoubleParseSpinBox::valueFromText(veryCleanText()); //this function will take care of prefix (and don't mind if suffix has been removed. } void KisDoubleParseUnitSpinBox::privateValueChanged() { emit valueChangedPt( value() ); } diff --git a/libs/widgets/kis_double_parse_unit_spin_box.h b/libs/widgets/kis_double_parse_unit_spin_box.h index 83094f8e85..e03a915737 100644 --- a/libs/widgets/kis_double_parse_unit_spin_box.h +++ b/libs/widgets/kis_double_parse_unit_spin_box.h @@ -1,100 +1,111 @@ /* * Copyright (c) 2016 Laurent Valentin Jospin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU 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 KIS_DOUBLEPARSEUNITSPINBOX_H #define KIS_DOUBLEPARSEUNITSPINBOX_H #include #include "kis_double_parse_spin_box.h" #include "kritawidgets_export.h" /*! * \brief The KisDoubleParseUnitSpinBox class is an evolution of the \see KoUnitDoubleSpinBox, but inherit from \see KisDoubleParseSpinBox to be able to parse math expressions. * * This class store the */ class KRITAWIDGETS_EXPORT KisDoubleParseUnitSpinBox : public KisDoubleParseSpinBox { Q_OBJECT public: KisDoubleParseUnitSpinBox(QWidget* parent = 0); ~KisDoubleParseUnitSpinBox(); /** * Set the new value in points which will then be converted to the current unit for display * @param newValue the new value * @see value() */ virtual void changeValue( double newValue ); /** * This spinbox shows the internal value after a conversion to the unit set here. */ virtual void setUnit(const KoUnit &unit); + virtual void setUnit(const QString &symbol); + + /** + * @brief setDimensionType set the dimension (for example length or angle) of the units the spinbox manage + * @param dim the dimension id. (if not an id in KisSpinBoxUnitManager::UnitDimension, then the function does nothing). + */ + virtual void setDimensionType(int dim); /// @return the current value, converted in points double value( ) const; /// Set minimum value in points. void setMinimum(double min); /// Set maximum value in points. void setMaximum(double max); /// Set step size in the current unit. void setLineStep(double step); /// Set step size in points. void setLineStepPt(double step); /// Set minimum, maximum value and the step size (all in points) void setMinMaxStep( double min, double max, double step ); /// reimplemented from superclass, will forward to KoUnitDoubleValidator virtual QValidator::State validate(QString &input, int &pos) const; /** * Transform the double in a nice text, using locale symbols * @param value the number as double * @return the resulting string */ virtual QString textFromValue( double value ) const; + + //! \brief get the text in the spinbox without prefix or suffix, and remove unit symbol if present. + virtual QString veryCleanText() const; + /** * Transfrom a string into a double, while taking care of locale specific symbols. * @param str the string to transform into a number * @return the value as double */ virtual double valueFromText( const QString& str ) const; Q_SIGNALS: /// emitted like valueChanged in the parent, but this one emits the point value void valueChangedPt( qreal ); private: class Private; Private * const d; private Q_SLOTS: // exists to do emits for valueChangedPt void privateValueChanged(); }; #endif // KIS_DOUBLEPARSEUNITSPINBOX_H diff --git a/libs/widgetutils/CMakeLists.txt b/libs/widgetutils/CMakeLists.txt index 182db0ab80..7a2bc38a13 100644 --- a/libs/widgetutils/CMakeLists.txt +++ b/libs/widgetutils/CMakeLists.txt @@ -1,127 +1,129 @@ add_subdirectory(tests) configure_file(xmlgui/config-xmlgui.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-xmlgui.h ) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/config) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/xmlgui) set(kritawidgetutils_LIB_SRCS WidgetUtilsDebug.cpp kis_icon_utils.cpp kis_action_registry.cpp KoGroupButton.cpp KoProgressBar.cpp KoProgressUpdater.cpp KoUpdater.cpp KoUpdaterPrivate_p.cpp KoProperties.cpp KoFileDialog.cpp KoResourcePaths.cpp kis_num_parser.cpp + kis_spin_box_unit_manager.cpp config/kcolorscheme.cpp config/kcolorschememanager.cpp config/khelpclient.cpp config/klanguagebutton.cpp config/krecentfilesaction.cpp config/kstandardaction.cpp xmlgui/KisShortcutsEditorItem.cpp xmlgui/KisShortcutEditWidget.cpp xmlgui/KisShortcutsEditorDelegate.cpp xmlgui/KisShortcutsDialog.cpp xmlgui/KisShortcutsDialog_p.cpp xmlgui/KisShortcutsEditor.cpp xmlgui/KisShortcutsEditor_p.cpp xmlgui/kshortcutschemeseditor.cpp xmlgui/kshortcutschemeshelper.cpp xmlgui/kaboutkdedialog_p.cpp xmlgui/kactioncategory.cpp xmlgui/kactioncollection.cpp xmlgui/kactionconflictdetector.cpp xmlgui/kbugreport.cpp xmlgui/kcheckaccelerators.cpp xmlgui/kedittoolbar.cpp xmlgui/kgesture.cpp xmlgui/kgesturemap.cpp xmlgui/khelpmenu.cpp xmlgui/kkeysequencewidget.cpp xmlgui/kmainwindow.cpp xmlgui/kmenumenuhandler_p.cpp xmlgui/kshortcutwidget.cpp xmlgui/kswitchlanguagedialog_p.cpp xmlgui/ktoggletoolbaraction.cpp xmlgui/ktoolbar.cpp xmlgui/ktoolbarhandler.cpp xmlgui/kundoactions.cpp xmlgui/kxmlguibuilder.cpp xmlgui/kxmlguiclient.cpp xmlgui/kxmlguifactory.cpp xmlgui/kxmlguifactory_p.cpp xmlgui/kxmlguiversionhandler.cpp xmlgui/kxmlguiwindow.cpp ) if (HAVE_DBUS) set(kritawidgetutils_LIB_SRCS ${kritawidgetutils_LIB_SRCS} xmlgui/kmainwindowiface.cpp ) endif() ki18n_wrap_ui(kritawidgetutils_LIB_SRCS xmlgui/KisShortcutsDialog.ui xmlgui/kshortcutwidget.ui ) qt5_add_resources(kritawidgetutils_LIB_SRCS xmlgui/kxmlgui.qrc) add_library(kritawidgetutils SHARED ${kritawidgetutils_LIB_SRCS}) target_include_directories(kritawidgetutils PUBLIC $ $ ) generate_export_header(kritawidgetutils BASE_NAME kritawidgetutils) if (HAVE_DBUS) set (KRITA_WIDGET_UTILS_EXTRA_LIBS ${KRITA_WIDGET_UTILS_EXTRA_LIBS} Qt5::DBus) endif () if (APPLE) find_library(FOUNDATION_LIBRARY Foundation) set(KRITA_WIDGET_UTILS_EXTRA_LIBS ${KRITA_WIDGET_UTILS_EXTRA_LIBS} ${FOUNDATION_LIBRARY}) endif () target_link_libraries(kritawidgetutils PUBLIC Qt5::Widgets Qt5::Gui Qt5::Xml Qt5::Core KF5::ItemViews kritaglobal PRIVATE Qt5::PrintSupport KF5::I18n KF5::ConfigCore KF5::CoreAddons KF5::ConfigGui KF5::GuiAddons KF5::WidgetsAddons KF5::WindowSystem kritaplugin + kritaodf ${KRITA_WIDGET_UTILS_EXTRA_LIBS} ) set_target_properties(kritawidgetutils PROPERTIES VERSION ${GENERIC_KRITA_LIB_VERSION} SOVERSION ${GENERIC_KRITA_LIB_SOVERSION} ) install(TARGETS kritawidgetutils ${INSTALL_TARGETS_DEFAULT_ARGS})