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++
Allow some whitespaces in the hex color input
Luna Lovecraft0e1ea8d82b56
diff --git a/libs/widgets/kis_color_input.cpp b/libs/widgets/kis_color_input.cppindex 7e981ec790..9a3fa28efb 100644--- a/libs/widgets/kis_color_input.cpp+++ b/libs/widgets/kis_color_input.cpp@@ -348,10 +348,16 @@ KisHexColorInput::KisHexColorInput(QWidget* parent, KoColor* color, KoColorDispl}connect(m_input, SIGNAL(textChanged(const QString&)), SLOT(setValue()));+ connect(m_input, SIGNAL(textEdited(const QString &)), SLOT(textChanged(const QString &)));m_layout->addWidget(m_input);}+void KisHexColorInput::textChanged(const QString &text)+{+ this->m_hexInput->setText(text.trimmed());+}+void KisHexColorInput::setValue(){QString valueString = m_hexInput->text();@@ -397,7 +403,7 @@ QWidget* KisHexColorInput::createInput()m_hexInput->setAlignment(Qt::AlignRight);int digits = 2*m_color->colorSpace()->colorChannelCount();- QString pattern = QString("#?[a-fA-F0-9]{%1,%2}").arg(digits).arg(digits);+ QString pattern = QString("\\s*#?[a-fA-F0-9]{%1,%2}\\s*").arg(digits).arg(digits);m_hexInput->setValidator(new QRegularExpressionValidator(QRegularExpression(pattern), this));connect(m_hexInput, SIGNAL(editingFinished()), this, SLOT(setValue()));return m_hexInput;diff --git a/libs/widgets/kis_color_input.h b/libs/widgets/kis_color_input.hindex 0bfe070c75..d1d869002d 100644--- a/libs/widgets/kis_color_input.h+++ b/libs/widgets/kis_color_input.h@@ -96,6 +96,7 @@ protected:QWidget* createInput() override;public Q_SLOTS:void setValue();+ void textChanged(const QString &text);void update();private:QLineEdit* m_hexInput {nullptr};