[numerical boxes] Icons for warning in parseSpinBoxes.

parent b48a6fb1
......@@ -13,7 +13,6 @@ set(kritaglobal_LIB_SRCS
kis_shared.cpp
kis_dom_utils.cpp
kis_painting_tweaks.cpp
kis_numparser.cpp
)
add_library(kritaglobal SHARED ${kritaglobal_LIB_SRCS} )
......
......@@ -362,6 +362,8 @@ set(kritaui_LIB_SRCS
KisPaletteModel.cpp
KisColorsetChooser.cpp
KisSaveGroupVisitor.cpp
utils/kis_numparser.cpp
)
if(WIN32)
......@@ -525,6 +527,7 @@ target_include_directories(kritaui
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/flake>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/ora>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/tool>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/utils>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/widgets>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/input/wintab>
)
......
......@@ -20,6 +20,10 @@
#include "kis_numparser.h"
#include <QLabel>
#include <QPixmap>
#include <QIcon>
KisDoubleParseSpinBox::KisDoubleParseSpinBox(QWidget *parent) :
QDoubleSpinBox(parent),
_isLastValid(true)
......@@ -39,6 +43,12 @@ KisDoubleParseSpinBox::KisDoubleParseSpinBox(QWidget *parent) :
_oldValue = value();
_warningIcon = new QLabel(this);
_warningIcon->setPixmap(QIcon(":/./16_light_warning.svg").pixmap(16, 16));
_warningIcon->setStyleSheet("background:transparent;");
_warningIcon->move(1, 1);
_warningIcon->setVisible(false);
}
KisDoubleParseSpinBox::~KisDoubleParseSpinBox()
......@@ -121,14 +131,17 @@ void KisDoubleParseSpinBox::setValue(double value)
void KisDoubleParseSpinBox::setErrorStyle()
{
if (!_isLastValid) {
setStyleSheet("Background: red; color: white;");
setStyleSheet("Background: red; color: white; padding-left: 18px;");
_warningIcon->move(-14, size().height()/2 - 16/2);
_warningIcon->setVisible(true);
}
}
void KisDoubleParseSpinBox::clearErrorStyle()
{
if (_isLastValid) {
setStyleSheet("");
_warningIcon->setVisible(false);
setStyleSheet("");
}
}
void KisDoubleParseSpinBox::clearError()
......
......@@ -23,6 +23,8 @@
#include <kritaui_export.h>
class QLabel;
/*!
* \brief The KisDoubleParseSpinBox class is a cleverer doubleSpinBox, able to parse arithmetic expressions.
*
......@@ -42,7 +44,7 @@ public:
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 usefull.
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.
Q_SIGNALS:
......@@ -53,9 +55,9 @@ Q_SIGNALS:
public Q_SLOTS:
//! \brief usefull to let the widget change it's stylesheet when an error occured in the last expression.
//! \brief useful to let the widget change it's stylesheet when an error occured in the last expression.
void setErrorStyle();
//! \brief usefull to let the widget reset it's stylesheet when there's no more error.
//! \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();
......@@ -65,6 +67,8 @@ protected:
mutable QString* _lastExprParsed;
mutable bool _isLastValid;
mutable double _oldValue;
QLabel* _warningIcon;
};
#endif // KISDOUBLEPARSESPINBOX_H
......@@ -20,8 +20,9 @@
#include "kis_numparser.h"
#include <QDebug>
#include <iostream>
#include <QLabel>
#include <QPixmap>
#include <QIcon>
KisIntParseSpinBox::KisIntParseSpinBox(QWidget *parent) :
QSpinBox(parent),
......@@ -39,6 +40,14 @@ KisIntParseSpinBox::KisIntParseSpinBox(QWidget *parent) :
connect(this, SIGNAL(errorWhileParsing(QString)),
this, SLOT(setErrorStyle()));
_oldVal = value();
_warningIcon = new QLabel(this);
_warningIcon->setPixmap(QIcon(":/./16_light_warning.svg").pixmap(16, 16));
_warningIcon->setStyleSheet("background:transparent;");
_warningIcon->move(1, 1);
_warningIcon->setVisible(false);
}
KisIntParseSpinBox::~KisIntParseSpinBox()
......@@ -133,13 +142,16 @@ void KisIntParseSpinBox::setValue(int val)
void KisIntParseSpinBox::setErrorStyle()
{
if (!_isLastValid) {
setStyleSheet("Background: red; color: white;");
setStyleSheet("Background: red; color: white; padding-left: 18px;");
_warningIcon->move(-14, size().height()/2 - 16/2);
_warningIcon->setVisible(true);
}
}
void KisIntParseSpinBox::clearErrorStyle()
{
if (_isLastValid) {
_warningIcon->setVisible(false);
setStyleSheet("");
}
}
......
......@@ -23,6 +23,8 @@
#include "kritaui_export.h"
class QLabel;
/*!
* \brief The KisDoubleParseSpinBox class is a cleverer doubleSpinBox, able to parse arithmetic expressions.
*
......@@ -42,7 +44,7 @@ public:
virtual void stepBy(int steps);
void setValue(int val); //polymorphism won't work directly, we use a signal/slot hack to do so but if signals are disabled this function will still be usefull.
void setValue(int val); //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.
Q_SIGNALS:
......@@ -53,9 +55,9 @@ Q_SIGNALS:
public Q_SLOTS:
//! \brief usefull to let the widget change it's stylesheet when an error occured in the last expression.
//! \brief useful to let the widget change it's stylesheet when an error occured in the last expression.
void setErrorStyle();
//! \brief usefull to let the widget reset it's stylesheet when there's no more error.
//! \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();
......@@ -64,7 +66,9 @@ protected:
mutable QString* _lastExprParsed;
mutable bool _isLastValid;
mutable int _oldVal; //store the last correctly evaluated value, to
mutable int _oldVal; //store the last correctly evaluated value.
QLabel* _warningIcon;
};
#endif // KISINTPARSESPINBOX_H
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="16"
height="16"
viewBox="0 0 16 16"
id="svg2"
version="1.1"
inkscape:version="0.91 r13725"
sodipodi:docname="16_dark_warning.svg">
<defs
id="defs4" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="16"
inkscape:cx="9.4075593"
inkscape:cy="11.806452"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="false"
fit-margin-top="0"
fit-margin-left="0"
fit-margin-right="0"
fit-margin-bottom="0"
inkscape:window-width="1855"
inkscape:window-height="1056"
inkscape:window-x="65"
inkscape:window-y="24"
inkscape:window-maximized="1"
units="px" />
<metadata
id="metadata7">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Calque 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(-176.29465,-380.67742)">
<path
sodipodi:type="star"
style="opacity:1;fill:#4d4d4d;fill-opacity:1;stroke:none;stroke-width:1.20599997;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="path8068"
sodipodi:sides="3"
sodipodi:cx="185.56091"
sodipodi:cy="391.30777"
sodipodi:r1="10.709662"
sodipodi:r2="5.3548312"
sodipodi:arg1="0.52200053"
sodipodi:arg2="1.5691981"
inkscape:flatsided="false"
inkscape:rounded="-3.469447e-18"
inkscape:randomized="0"
d="m 194.8443,396.64777 -9.27483,0.0148 -9.27483,0.0148 4.62458,-8.03965 4.62458,-8.03965 4.65025,8.02483 z"
inkscape:transform-center-x="0.03785892"
inkscape:transform-center-y="-2.4009558"
transform="matrix(0.8625497,0,0,0.90178074,24.231758,37.961365)" />
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:12.54406357px;line-height:125%;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;"
x="185.87758"
y="385.91849"
id="text8070"
sodipodi:linespacing="125%"
transform="scale(0.9780062,1.0224884)"><tspan
sodipodi:role="line"
id="tspan8072"
x="185.87758"
y="385.91849"
style="fill:#ffffff;fill-opacity:1;">!</tspan></text>
</g>
</svg>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="16"
height="16"
viewBox="0 0 16 16"
id="svg2"
version="1.1"
inkscape:version="0.91 r13725"
sodipodi:docname="16_light_warning.svg">
<defs
id="defs4" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="16"
inkscape:cx="9.4075593"
inkscape:cy="11.806452"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="false"
fit-margin-top="0"
fit-margin-left="0"
fit-margin-right="0"
fit-margin-bottom="0"
inkscape:window-width="1855"
inkscape:window-height="1056"
inkscape:window-x="65"
inkscape:window-y="24"
inkscape:window-maximized="1"
units="px" />
<metadata
id="metadata7">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Calque 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(-176.29465,-380.67742)">
<path
sodipodi:type="star"
style="opacity:1;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1.20599997;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="path8068"
sodipodi:sides="3"
sodipodi:cx="185.56091"
sodipodi:cy="391.30777"
sodipodi:r1="10.709662"
sodipodi:r2="5.3548312"
sodipodi:arg1="0.52200053"
sodipodi:arg2="1.5691981"
inkscape:flatsided="false"
inkscape:rounded="-3.469447e-18"
inkscape:randomized="0"
d="m 194.8443,396.64777 -9.27483,0.0148 -9.27483,0.0148 4.62458,-8.03965 4.62458,-8.03965 4.65025,8.02483 z"
inkscape:transform-center-x="0.03785892"
inkscape:transform-center-y="-2.4009558"
transform="matrix(0.8625497,0,0,0.90178074,24.231758,37.961365)" />
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:12.54406357px;line-height:125%;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;"
x="185.87758"
y="385.91849"
id="text8070"
sodipodi:linespacing="125%"
transform="scale(0.9780062,1.0224884)"><tspan
sodipodi:role="line"
id="tspan8072"
x="185.87758"
y="385.91849"
style="fill:#000000;fill-opacity:1;">!</tspan></text>
</g>
</svg>
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment