diff --git a/krita/pics/svg/dark_ratio.svg b/krita/pics/svg/dark_ratio.svg new file mode 100644 --- /dev/null +++ b/krita/pics/svg/dark_ratio.svg @@ -0,0 +1,1522 @@ + + + + + + + + + + + image/svg+xml + + + 2016 + + + Timothée Giet + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/krita/pics/svg/light_ratio.svg b/krita/pics/svg/light_ratio.svg new file mode 100644 --- /dev/null +++ b/krita/pics/svg/light_ratio.svg @@ -0,0 +1,1522 @@ + + + + + + + + + + + image/svg+xml + + + 2016 + + + Timothée Giet + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/krita/pics/svg/svg-icons.qrc b/krita/pics/svg/svg-icons.qrc --- a/krita/pics/svg/svg-icons.qrc +++ b/krita/pics/svg/svg-icons.qrc @@ -151,5 +151,7 @@ dark_gamut-mask-off.svg light_gamut-mask-off.svg light_gamut-mask-on.svg + dark_ratio.svg + light_ratio.svg diff --git a/libs/widgets/kis_color_input.h b/libs/widgets/kis_color_input.h --- a/libs/widgets/kis_color_input.h +++ b/libs/widgets/kis_color_input.h @@ -41,9 +41,10 @@ inline bool usePercentage() const { return m_usePercentage; } - inline void setPercentageWise(bool val) { + virtual inline void setPercentageWise(bool val) { m_usePercentage = val; } + protected: void init(); virtual QWidget* createInput() = 0; @@ -64,6 +65,7 @@ KisIntegerColorInput(QWidget* parent, const KoChannelInfo*, KoColor* color, KoColorDisplayRendererInterface *displayRenderer = KoDumbColorDisplayRenderer::instance(), bool usePercentage = false); protected: QWidget* createInput() override; + void setPercentageWise(bool val) override; public Q_SLOTS: void setValue(int); void update(); diff --git a/libs/widgets/kis_color_input.cpp b/libs/widgets/kis_color_input.cpp --- a/libs/widgets/kis_color_input.cpp +++ b/libs/widgets/kis_color_input.cpp @@ -152,6 +152,13 @@ m_intNumInput = new KisIntParseSpinBox(this); m_intNumInput->setMinimum(0); m_colorSlider->setMinimum(0); + + if (m_usePercentage) { + m_intNumInput->setSuffix("%"); + } else { + m_intNumInput->setSuffix(""); + } + switch (m_channelInfo->channelValueType()) { case KoChannelInfo::UINT8: if (m_usePercentage) { @@ -185,6 +192,17 @@ return m_intNumInput; } +void KisIntegerColorInput::setPercentageWise(bool val) +{ + m_usePercentage = val; + + if (m_usePercentage) { + m_intNumInput->setSuffix("%"); + } else { + m_intNumInput->setSuffix(""); + } +} + void KisIntegerColorInput::onColorSliderChanged(int val) { m_intNumInput->blockSignals(true); @@ -387,6 +405,7 @@ QWidget* KisHexColorInput::createInput() { m_hexInput = new QLineEdit(this); + 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); diff --git a/libs/widgets/kis_double_parse_spin_box.cpp b/libs/widgets/kis_double_parse_spin_box.cpp --- a/libs/widgets/kis_double_parse_spin_box.cpp +++ b/libs/widgets/kis_double_parse_spin_box.cpp @@ -32,6 +32,8 @@ boolLastValid(true), lastExprParsed(QStringLiteral("0.0")) { + setAlignment(Qt::AlignRight); + connect(this, SIGNAL(noMoreParsingError()), this, SLOT(clearErrorStyle())); diff --git a/libs/widgets/kis_int_parse_spin_box.cpp b/libs/widgets/kis_int_parse_spin_box.cpp --- a/libs/widgets/kis_int_parse_spin_box.cpp +++ b/libs/widgets/kis_int_parse_spin_box.cpp @@ -30,6 +30,8 @@ QSpinBox(parent), boolLastValid(true) { + setAlignment(Qt::AlignRight); + lastExprParsed = new QString("0"); connect(this, SIGNAL(noMoreParsingError()), diff --git a/plugins/dockers/specificcolorselector/CMakeLists.txt b/plugins/dockers/specificcolorselector/CMakeLists.txt --- a/plugins/dockers/specificcolorselector/CMakeLists.txt +++ b/plugins/dockers/specificcolorselector/CMakeLists.txt @@ -3,6 +3,12 @@ specificcolorselector_dock.cc kis_specific_color_selector_widget.cc ) + +ki18n_wrap_ui(KRITA_SPECIFICCOLORSELECTOR_SOURCES + wdgSpecificColorSelectorWidget.ui +) + + add_library(kritaspecificcolorselector MODULE ${KRITA_SPECIFICCOLORSELECTOR_SOURCES}) target_link_libraries(kritaspecificcolorselector kritaui ${OPENEXR_LIBRARIES}) install(TARGETS kritaspecificcolorselector DESTINATION ${KRITA_PLUGIN_INSTALL_DIR}) diff --git a/plugins/dockers/specificcolorselector/kis_specific_color_selector_widget.h b/plugins/dockers/specificcolorselector/kis_specific_color_selector_widget.h --- a/plugins/dockers/specificcolorselector/kis_specific_color_selector_widget.h +++ b/plugins/dockers/specificcolorselector/kis_specific_color_selector_widget.h @@ -23,22 +23,30 @@ #include #include "kis_signal_auto_connection.h" +#include "ui_wdgSpecificColorSelectorWidget.h" + + class KoColorSpace; class QVBoxLayout; class KisColorInput; class KisColorSpaceSelector; class QCheckBox; class KisSignalCompressor; class QSpacerItem; class KisDisplayColorConverter; +class KisPopupButton; class KisSpecificColorSelectorWidget : public QWidget { Q_OBJECT public: KisSpecificColorSelectorWidget(QWidget* parent); ~KisSpecificColorSelectorWidget() override; bool customColorSpaceUsed(); + +protected: + void resizeEvent(QResizeEvent* event) override; + public Q_SLOTS: void setDisplayConverter(KisDisplayColorConverter *colorConverter); @@ -56,15 +64,14 @@ private: QList m_inputs; const KoColorSpace* m_colorSpace; - QVBoxLayout *m_layout; QSpacerItem *m_spacer; KoColor m_color; bool m_updateAllowed; KisSignalCompressor *m_updateCompressor; KisColorSpaceSelector *m_colorspaceSelector; bool m_customColorSpaceSelected; - QCheckBox *m_chkShowColorSpaceSelector; - QCheckBox *m_chkUsePercentage; + Ui_wdgSpecificColorSelectorWidget* m_ui; + KisDisplayColorConverter *m_displayConverter; KisSignalAutoConnectionsStore m_converterConnection; diff --git a/plugins/dockers/specificcolorselector/kis_specific_color_selector_widget.cc b/plugins/dockers/specificcolorselector/kis_specific_color_selector_widget.cc --- a/plugins/dockers/specificcolorselector/kis_specific_color_selector_widget.cc +++ b/plugins/dockers/specificcolorselector/kis_specific_color_selector_widget.cc @@ -38,7 +38,10 @@ #include #include #include +#include +#include +#include "ui_wdgSpecificColorSelectorWidget.h" KisSpecificColorSelectorWidget::KisSpecificColorSelectorWidget(QWidget* parent) : QWidget(parent) @@ -49,49 +52,53 @@ , m_displayConverter(0) { - m_layout = new QVBoxLayout(this); - m_layout->setContentsMargins(0,0,0,0); - m_layout->setSpacing(1); + m_ui = new Ui_wdgSpecificColorSelectorWidget(); + m_ui->setupUi(this); + m_updateAllowed = true; connect(m_updateCompressor, SIGNAL(timeout()), SLOT(updateTimeout())); m_colorspaceSelector = new KisColorSpaceSelector(this); - m_colorspaceSelector->layout()->setSpacing(1); connect(m_colorspaceSelector, SIGNAL(colorSpaceChanged(const KoColorSpace*)), this, SLOT(setCustomColorSpace(const KoColorSpace*))); - m_chkShowColorSpaceSelector = new QCheckBox(i18n("Show Colorspace Selector"), this); - connect(m_chkShowColorSpaceSelector, SIGNAL(toggled(bool)), m_colorspaceSelector, SLOT(setVisible(bool))); + m_ui->colorspacePopupButton->setPopupWidget(m_colorspaceSelector); - m_chkUsePercentage = new QCheckBox(i18n("Use Percentage"), this); - connect(m_chkUsePercentage, SIGNAL(toggled(bool)), this, SLOT(onChkUsePercentageChanged(bool))); + connect(m_ui->chkUsePercentage, SIGNAL(toggled(bool)), this, SLOT(onChkUsePercentageChanged(bool))); KConfigGroup cfg = KSharedConfig::openConfig()->group(QString()); - m_chkShowColorSpaceSelector->setChecked(cfg.readEntry("SpecificColorSelector/ShowColorSpaceSelector", true)); - m_chkUsePercentage->setChecked(cfg.readEntry("SpecificColorSelector/UsePercentage", false)); + m_ui->chkUsePercentage->setChecked(cfg.readEntry("SpecificColorSelector/UsePercentage", false)); + m_ui->chkUsePercentage->setIcon(KisIconUtils::loadIcon("ratio")); - m_colorspaceSelector->setVisible(m_chkShowColorSpaceSelector->isChecked()); m_colorspaceSelector->showColorBrowserButton(false); - m_layout->addWidget(m_chkShowColorSpaceSelector); - m_layout->addWidget(m_chkUsePercentage); - m_layout->addWidget(m_colorspaceSelector); - m_spacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Expanding); - m_layout->addItem(m_spacer); + m_ui->slidersLayout->addItem(m_spacer); } KisSpecificColorSelectorWidget::~KisSpecificColorSelectorWidget() { KConfigGroup cfg = KSharedConfig::openConfig()->group(QString()); - cfg.writeEntry("SpecificColorSelector/ShowColorSpaceSelector", m_chkShowColorSpaceSelector->isChecked()); - cfg.writeEntry("SpecificColorSelector/UsePercentage", m_chkUsePercentage->isChecked()); + cfg.writeEntry("SpecificColorSelector/UsePercentage", m_ui->chkUsePercentage->isChecked()); } bool KisSpecificColorSelectorWidget::customColorSpaceUsed() { return m_customColorSpaceSelected; } +void KisSpecificColorSelectorWidget::resizeEvent(QResizeEvent *event) +{ + QWidget::resizeEvent(event); + + if (m_colorSpace) { + QString elidedColorspaceName = m_ui->colorspacePopupButton->fontMetrics().elidedText( + m_colorSpace->name(), Qt::ElideRight, + m_ui->colorspacePopupButton->width() + ); + m_ui->colorspacePopupButton->setText(elidedColorspaceName); + } +} + void KisSpecificColorSelectorWidget::setDisplayConverter(KisDisplayColorConverter *displayConverter) { const bool needsForceUpdate = m_displayConverter != displayConverter; @@ -130,21 +137,28 @@ } if (cs->colorDepthId() == Integer8BitsColorDepthID || cs->colorDepthId() == Integer16BitsColorDepthID) { - m_chkUsePercentage->setVisible(true); + m_ui->chkUsePercentage->setVisible(true); } else { - m_chkUsePercentage->setVisible(false); + m_ui->chkUsePercentage->setVisible(false); } m_colorSpace = KoColorSpaceRegistry::instance()->colorSpace(cs->colorModelId().id(), cs->colorDepthId().id(), cs->profile()); Q_ASSERT(m_colorSpace); Q_ASSERT(*m_colorSpace == *cs); + + QString elidedColorspaceName = m_ui->colorspacePopupButton->fontMetrics().elidedText( + m_colorSpace->name(), Qt::ElideRight, + m_ui->colorspacePopupButton->width() + ); + m_ui->colorspacePopupButton->setText(elidedColorspaceName); + m_color = KoColor(m_color, m_colorSpace); Q_FOREACH (KisColorInput* input, m_inputs) { delete input; } m_inputs.clear(); - m_layout->removeItem(m_spacer); + m_ui->slidersLayout->removeItem(m_spacer); QList channels = KoChannelInfo::displayOrderSorted(m_colorSpace->channels()); @@ -160,7 +174,7 @@ case KoChannelInfo::UINT8: case KoChannelInfo::UINT16: case KoChannelInfo::UINT32: { - input = new KisIntegerColorInput(this, channel, &m_color, displayRenderer, m_chkUsePercentage->isChecked()); + input = new KisIntegerColorInput(this, channel, &m_color, displayRenderer, m_ui->chkUsePercentage->isChecked()); } break; case KoChannelInfo::FLOAT16: @@ -177,7 +191,7 @@ connect(this, SIGNAL(updated()), input, SLOT(update())); m_inputs.append(input); - m_layout->addWidget(input); + m_ui->slidersLayout->addWidget(input); } } } @@ -205,11 +219,11 @@ if (allChannels8Bit) { KisColorInput* input = new KisHexColorInput(this, &m_color, displayRenderer); m_inputs.append(input); - m_layout->addWidget(input); + m_ui->slidersLayout->addWidget(input); connect(input, SIGNAL(updated()), this, SLOT(update())); connect(this, SIGNAL(updated()), input, SLOT(update())); } - m_layout->addItem(m_spacer); + m_ui->slidersLayout->addItem(m_spacer); m_colorspaceSelector->blockSignals(true); m_colorspaceSelector->setCurrentColorSpace(cs); @@ -253,4 +267,3 @@ } emit(updated()); } -#include "moc_kis_specific_color_selector_widget.cpp" diff --git a/plugins/dockers/specificcolorselector/wdgSpecificColorSelectorWidget.ui b/plugins/dockers/specificcolorselector/wdgSpecificColorSelectorWidget.ui new file mode 100644 --- /dev/null +++ b/plugins/dockers/specificcolorselector/wdgSpecificColorSelectorWidget.ui @@ -0,0 +1,116 @@ + + + wdgSpecificColorSelectorWidget + + + + 0 + 0 + 268 + 207 + + + + Form + + + + + + QLayout::SetDefaultConstraint + + + + + + 0 + 2 + + + + + 72 + 0 + + + + + + + + + + Set color space + + + + 22 + 22 + + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + Use percentage + + + + + + + + + + 20 + 20 + + + + true + + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + KisPopupButton + QPushButton +
kis_popup_button.h
+
+
+ + +