[numerical boxes] make use of parsespinboxes in the forms of the tools option widgets.

For the moment the KoUnitSpinBoxes have not been replaced.
Spinboxes instancied in the code but not in a form are not changed.

The main problem that have been spot is that the old way of making
the parsespinboxes red (using a stylesheet) cause style issue in the
tools option widget. A new way of making the spinboxes red has been develloped
that used a Palette and the margins of the inner line edit.

Another thing that have been spot is that Qt Creator will simplifiy the
forms file when edited. While doing so it can collapse a QWidget and a
Layout in just a Layout. But it can be problematic if the widget is called
explicitly in the code. To fix those issue one can add a native="true"
agrument to the QWidget tag mannualy.
parent d2386f8d
......@@ -24,6 +24,7 @@
#include <QPixmap>
#include <QIcon>
#include <QFile>
#include <QLineEdit>
KisDoubleParseSpinBox::KisDoubleParseSpinBox(QWidget *parent) :
QDoubleSpinBox(parent),
......@@ -56,6 +57,9 @@ KisDoubleParseSpinBox::KisDoubleParseSpinBox(QWidget *parent) :
_warningIcon->move(1, 1);
_warningIcon->setVisible(false);
_isOldPaletteSaved = false;
_areOldMarginsSaved = false;
}
KisDoubleParseSpinBox::~KisDoubleParseSpinBox()
......@@ -164,9 +168,32 @@ void KisDoubleParseSpinBox::setValue(double value)
void KisDoubleParseSpinBox::setErrorStyle()
{
if (!_isLastValid) {
setStyleSheet("Background: red; color: white; padding-left: 18px;");
_warningIcon->move(-14, size().height()/2 - 16/2);
//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;
QMargins newMargins = _oldMargins;
newMargins.setLeft( newMargins.left() + height() - 4 );
lineEdit()->setTextMargins(newMargins);
_warningIcon->resize(height()-2, height()-2);
_warningIcon->move(_oldMargins.left()+5, 1);
_warningIcon->setVisible(true);
}
}
......@@ -175,7 +202,14 @@ void KisDoubleParseSpinBox::clearErrorStyle()
{
if (_isLastValid) {
_warningIcon->setVisible(false);
setStyleSheet("");
//setStyleSheet("");
setPalette(_oldPalette);
_isOldPaletteSaved = false;
lineEdit()->setTextMargins(_oldMargins);
_areOldMarginsSaved = false;
}
}
void KisDoubleParseSpinBox::clearError()
......
......@@ -71,6 +71,12 @@ protected:
mutable double _oldValue;
QLabel* _warningIcon;
QPalette _oldPalette;
bool _isOldPaletteSaved;
QMargins _oldMargins;
bool _areOldMarginsSaved;
};
#endif // KISDOUBLEPARSESPINBOX_H
......@@ -24,6 +24,7 @@
#include <QPixmap>
#include <QIcon>
#include <QFile>
#include <QLineEdit>
KisIntParseSpinBox::KisIntParseSpinBox(QWidget *parent) :
QSpinBox(parent),
......@@ -55,6 +56,9 @@ KisIntParseSpinBox::KisIntParseSpinBox(QWidget *parent) :
_warningIcon->move(1, 1);
_warningIcon->setVisible(false);
_isOldPaletteSaved = false;
_areOldMarginsSaved = false;
}
KisIntParseSpinBox::~KisIntParseSpinBox()
......@@ -171,9 +175,32 @@ void KisIntParseSpinBox::setValue(int val)
void KisIntParseSpinBox::setErrorStyle()
{
if (!_isLastValid) {
setStyleSheet("Background: red; color: white; padding-left: 18px;");
_warningIcon->move(-14, size().height()/2 - 16/2);
//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;
QMargins newMargins = _oldMargins;
newMargins.setLeft( newMargins.left() + height() - 4 );
lineEdit()->setTextMargins(newMargins);
_warningIcon->resize(height()-2, height()-2);
_warningIcon->move(_oldMargins.left()+5, 1);
_warningIcon->setVisible(true);
}
}
......@@ -182,7 +209,14 @@ void KisIntParseSpinBox::clearErrorStyle()
{
if (_isLastValid) {
_warningIcon->setVisible(false);
setStyleSheet("");
//setStyleSheet("");
setPalette(_oldPalette);
_isOldPaletteSaved = false;
lineEdit()->setTextMargins(_oldMargins);
_areOldMarginsSaved = false;
}
}
......
......@@ -71,6 +71,12 @@ protected:
mutable int _oldVal; //store the last correctly evaluated value.
QLabel* _warningIcon;
QPalette _oldPalette;
bool _isOldPaletteSaved;
QMargins _oldMargins;
bool _areOldMarginsSaved;
};
#endif // KISINTPARSESPINBOX_H
......@@ -59,7 +59,7 @@
</widget>
</item>
<item>
<widget class="QSpinBox" name="radius">
<widget class="KisIntParseSpinBox" name="radius">
<property name="suffix">
<string> px</string>
</property>
......@@ -156,6 +156,11 @@
<extends>QComboBox</extends>
<header>squeezedcombobox.h</header>
</customwidget>
<customwidget>
<class>KisIntParseSpinBox</class>
<extends>QSpinBox</extends>
<header>kis_intparsespinbox.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
......
......@@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>269</width>
<width>271</width>
<height>394</height>
</rect>
</property>
......@@ -23,7 +23,7 @@
<string>Move the layer that you have currently selected in the layerbox with its masks. Shortcut: ctrl-click.</string>
</property>
<property name="text">
<string>Move current layer</string>
<string>&amp;Move current layer</string>
</property>
<property name="checked">
<bool>true</bool>
......@@ -36,7 +36,7 @@
<string>Move the first layer with visible content at the place where you click. This will also select that layer in the layerbox.</string>
</property>
<property name="text">
<string>Move layer with content</string>
<string>Mo&amp;ve layer with content</string>
</property>
<property name="checked">
<bool>false</bool>
......@@ -49,7 +49,7 @@
<string>Move the group containing the first layer that contains visible content. Shortcut: ctrl-shift-click.</string>
</property>
<property name="text">
<string>Move the whole group</string>
<string>Move &amp;the whole group</string>
</property>
</widget>
</item>
......@@ -57,13 +57,16 @@
</widget>
</item>
<item row="1" column="0">
<widget class="QWidget" name="SpecialSpacer" native="true"/>
</item>
<item row="2" column="0">
<widget class="QGroupBox" name="grpMoveStep">
<property name="title">
<string>Shortcut Move Distance</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="QDoubleSpinBox" name="spinMoveStep">
<widget class="KisDoubleParseSpinBox" name="spinMoveStep">
<property name="toolTip">
<string>Number of pixels to move after move shortcut keypress.</string>
</property>
......@@ -82,7 +85,7 @@
<widget class="QComboBox" name="cmbUnit"/>
</item>
<item row="1" column="0">
<widget class="QDoubleSpinBox" name="spinMoveScale">
<widget class="KisDoubleParseSpinBox" name="spinMoveScale">
<property name="toolTip">
<string>When holding shift, move keyboard shortcuts scale up by this amount.</string>
</property>
......@@ -107,7 +110,7 @@
</layout>
</widget>
</item>
<item row="2" column="0">
<item row="3" column="0">
<widget class="QCheckBox" name="chkShowCoordinates">
<property name="toolTip">
<string>Show coordinates on canvas</string>
......@@ -117,7 +120,7 @@
</property>
</widget>
</item>
<item row="3" column="0">
<item row="4" column="0">
<widget class="QGroupBox" name="moveGroup">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
......@@ -176,7 +179,7 @@
<enum>Qt::LeftToRight</enum>
</property>
<property name="text">
<string>x:</string>
<string>&amp;x:</string>
</property>
<property name="buddy">
<cstring>translateXBox</cstring>
......@@ -184,7 +187,7 @@
</widget>
</item>
<item row="0" column="1">
<widget class="QSpinBox" name="translateXBox">
<widget class="KisIntParseSpinBox" name="translateXBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
......@@ -200,7 +203,7 @@
</widget>
</item>
<item row="2" column="1">
<widget class="QSpinBox" name="translateYBox">
<widget class="KisIntParseSpinBox" name="translateYBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
......@@ -224,7 +227,7 @@
<string>Vertical Translation</string>
</property>
<property name="text">
<string>y:</string>
<string>&amp;y:</string>
</property>
<property name="buddy">
<cstring>translateYBox</cstring>
......@@ -236,11 +239,23 @@
</layout>
</widget>
</item>
<item row="4" column="0">
<item row="5" column="0">
<widget class="QWidget" name="SpecialSpacer" native="true"/>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>KisDoubleParseSpinBox</class>
<extends>QDoubleSpinBox</extends>
<header>kis_doubleparsespinbox.h</header>
</customwidget>
<customwidget>
<class>KisIntParseSpinBox</class>
<extends>QSpinBox</extends>
<header>kis_intparsespinbox.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>
......@@ -33,5 +33,5 @@ ki18n_wrap_ui(defaulttools_SRCS
qt5_add_resources(defaulttools_SRCS defaulttools.qrc)
add_library(krita_flaketools MODULE ${defaulttools_SRCS})
target_link_libraries(krita_flaketools kritaflake kritawidgets)
target_link_libraries(krita_flaketools kritaflake kritawidgets kritaui)
install(TARGETS krita_flaketools DESTINATION ${KRITA_PLUGIN_INSTALL_DIR})
<ui version="4.0" >
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DefaultToolTransformWidget</class>
<widget class="QMenu" name="DefaultToolTransformWidget" >
<property name="geometry" >
<widget class="QMenu" name="DefaultToolTransformWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
......@@ -9,178 +10,181 @@
<height>293</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout" >
<item row="0" column="0" >
<widget class="QDoubleSpinBox" name="rotateSpinBox" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Minimum" >
<property name="title">
<string/>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="KisDoubleParseSpinBox" name="rotateSpinBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>2</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="alignment" >
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="suffix" >
<property name="suffix">
<string>°</string>
</property>
<property name="minimum" >
<property name="minimum">
<double>-360.000000000000000</double>
</property>
<property name="maximum" >
<property name="maximum">
<double>360.000000000000000</double>
</property>
</widget>
</item>
<item row="0" column="1" >
<widget class="QPushButton" name="rotateButton" >
<property name="text" >
<item row="0" column="1">
<widget class="QPushButton" name="rotateButton">
<property name="text">
<string>Rotate</string>
</property>
</widget>
</item>
<item row="1" column="0" >
<widget class="KoUnitDoubleSpinBox" name="shearXSpinBox" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Minimum" >
<item row="1" column="0">
<widget class="KoUnitDoubleSpinBox" name="shearXSpinBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>2</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimum" >
<property name="minimum">
<double>-100.000000000000000</double>
</property>
<property name="maximum" >
<property name="maximum">
<double>100.000000000000000</double>
</property>
<property name="singleStep" >
<property name="singleStep">
<double>0.100000000000000</double>
</property>
</widget>
</item>
<item row="1" column="1" >
<widget class="QPushButton" name="shearXButton" >
<property name="text" >
<item row="1" column="1">
<widget class="QPushButton" name="shearXButton">
<property name="text">
<string>Shear X</string>
</property>
</widget>
</item>
<item row="2" column="0" >
<widget class="KoUnitDoubleSpinBox" name="shearYSpinBox" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Minimum" >
<item row="2" column="0">
<widget class="KoUnitDoubleSpinBox" name="shearYSpinBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>2</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimum" >
<property name="minimum">
<double>-100.000000000000000</double>
</property>
<property name="maximum" >
<property name="maximum">
<double>100.000000000000000</double>
</property>
<property name="singleStep" >
<property name="singleStep">
<double>0.100000000000000</double>
</property>
</widget>
</item>
<item row="2" column="1" >
<widget class="QPushButton" name="shearYButton" >
<property name="text" >
<item row="2" column="1">
<widget class="QPushButton" name="shearYButton">
<property name="text">
<string>Shear Y</string>
</property>
</widget>
</item>
<item row="3" column="0" >
<widget class="QDoubleSpinBox" name="scaleXSpinBox" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Minimum" >
<item row="3" column="0">
<widget class="KisDoubleParseSpinBox" name="scaleXSpinBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>2</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="alignment" >
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="suffix" >
<property name="suffix">
<string>%</string>
</property>
<property name="minimum" >
<property name="minimum">
<double>-1000.000000000000000</double>
</property>
<property name="maximum" >
<property name="maximum">
<double>1000.000000000000000</double>
</property>
<property name="value" >
<property name="value">
<double>100.000000000000000</double>
</property>
</widget>
</item>
<item row="3" column="1" >
<widget class="QPushButton" name="scaleXButton" >
<property name="text" >
<item row="3" column="1">
<widget class="QPushButton" name="scaleXButton">
<property name="text">
<string>Scale X</string>
</property>
</widget>
</item>
<item row="4" column="0" >
<widget class="QDoubleSpinBox" name="scaleYSpinBox" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Minimum" >
<item row="4" column="0">
<widget class="KisDoubleParseSpinBox" name="scaleYSpinBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>2</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="alignment" >
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="suffix" >
<property name="suffix">
<string>%</string>
</property>
<property name="minimum" >
<property name="minimum">
<double>-1000.000000000000000</double>
</property>
<property name="maximum" >
<property name="maximum">
<double>1000.000000000000000</double>
</property>
<property name="value" >
<property name="value">
<double>100.000000000000000</double>
</property>
</widget>
</item>
<item row="4" column="1" >
<widget class="QPushButton" name="scaleYButton" >
<property name="text" >
<item row="4" column="1">
<widget class="QPushButton" name="scaleYButton">
<property name="text">
<string>Scale Y</string>
</property>
</widget>
</item>
<item row="5" column="0" colspan="2" >
<widget class="QCheckBox" name="scaleAspectCheckBox" >
<property name="text" >
<item row="5" column="0" colspan="2">
<widget class="QCheckBox" name="scaleAspectCheckBox">
<property name="text">
<string>Keep aspect ratio</string>
</property>
</widget>
</item>
<item row="6" column="0" colspan="2" >
<widget class="QPushButton" name="resetButton" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
<item row="6" column="0" colspan="2">
<widget class="QPushButton" name="resetButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text" >
<property name="text">
<string>Reset Transformations</string>
</property>
</widget>
</item>
<item row="7" column="0" colspan="2" >
<spacer name="spacer" >
<property name="orientation" >
<item row="7" column="0" colspan="2">
<spacer name="spacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0" >
<property name="sizeHint" stdset="0">
<size>
<width>191</width>
<height>58</height>
......@@ -191,6 +195,11 @@
</layout>
</widget>
<customwidgets>
<customwidget>
<class>KisDoubleParseSpinBox</class>
<extends>QDoubleSpinBox</extends>
<header>kis_doubleparsespinbox.h</header>
</customwidget>
<customwidget>
<class>KoUnitDoubleSpinBox</class>
<extends>QDoubleSpinBox</extends>
......
......@@ -44,7 +44,7 @@ qt5_add_resources(karbon_tools_SOURCES karbontools.qrc)
add_library(krita_karbontools MODULE ${karbon_tools_SOURCES})
target_link_libraries(krita_karbontools kritawidgets KF5::Completion)
target_link_libraries(krita_karbontools kritaui kritawidgets KF5::Completion)
install(TARGETS krita_karbontools DESTINATION ${KRITA_PLUGIN_INSTALL_DIR})
<ui version="4.0" >
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PatternOptionsWidget</class>
<widget class="QWidget" name="PatternOptionsWidget" >
<property name="geometry" >
<widget class="QWidget" name="PatternOptionsWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
......@@ -9,117 +10,126 @@
<height>253</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout" >
<property name="margin" >
<layout class="QGridLayout" name="gridLayout">
<property name="leftMargin">
<number>0</number>
</property>
<item row="0" column="0" colspan="3" >
<widget class="QLabel" name="label" >
<property name="text" >
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="0" colspan="3">
<widget class="QLabel" name="label">
<property name="text">
<string>Repeat:</string>
</property>
</widget>
</item>
<item row="0" column="3" colspan="2" >
<widget class="KComboBox" name="patternRepeat" />
<item row="0" column="3" colspan="2">
<widget class="KComboBox" name="patternRepeat"/>
</item>
<item row="1" column="0" colspan="3" >
<widget class="QLabel" name="label_2" >
<property name="text" >
<item row="1" column="0" colspan="3">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Reference Point:</string>
</property>
</widget>
</item>
<item row="1" column="3" colspan="2" >
<widget class="KComboBox" name="referencePoint" />
<item row="1" column="3" colspan="2">
<widget class="KComboBox" name="referencePoint"/>
</item>
<item row="2" column="0" colspan="5" >
<widget class="QLabel" name="label_9" >
<property name="text" >
<item row="2" column="0" colspan="5">
<widget class="QLabel" name="label_9">
<property name="text">
<string>Reference Point Offset</string>
</property>
</widget>
</item>
<item row="3" column="0" >
<widget class="QLabel" name="label_4" >
<property name="text" >
<item row="3" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>X:</string>
</property>
</widget>
</item>
<item row="3" column="1" >
<widget class="QDoubleSpinBox" name="refPointOffsetX" />
<item row="3" column="1">
<widget class="KisDoubleParseSpinBox" name="refPointOffsetX"/>
</item>
<item row="3" column="2" colspan="2" >
<widget class="QLabel" name="label_5" >
<property name="text" >
<item row="3" column="2" colspan="2">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Y:</string>
</property>
</widget>
</item>
<item row="3" column="4" >
<widget class="QDoubleSpinBox" name="refPointOffsetY" />
<item row="3" column="4">
<widget class="KisDoubleParseSpinBox" name="refPointOffsetY"/>
</item>
<item row="4" column="0" colspan="4" >
<widget class="QLabel" name="label_10" >
<property name="text" >
<item row="4" column="0" colspan="4">
<widget class="QLabel" name="label_10">
<property name="text">
<string>Tile Offset</string>
</property>
</widget>
</item>
<item row="5" column="0" >
<widget class="QLabel" name="label_7" >