diff --git a/libs/ui/forms/wdgdlginternalcolorselector.ui b/libs/ui/forms/wdgdlginternalcolorselector.ui index 1ebf7bfd6c..4ad1fb8e03 100644 --- a/libs/ui/forms/wdgdlginternalcolorselector.ui +++ b/libs/ui/forms/wdgdlginternalcolorselector.ui @@ -1,225 +1,237 @@ WdgDlgInternalColorSelector 0 0 505 483 Dialog 0 0 90 90 0 0 0 50 - + QFrame::StyledPanel QFrame::Sunken - 0 + 2 2 0 + + 0 + + + 0 + + + 0 + + + 0 + 0 0 50 70 0 0 25 25 0 0 225 50 0 0 50 50 Qt::Horizontal QDialogButtonBox::Cancel|QDialogButtonBox::Ok KisSpinboxColorSelector QWidget
kis_spinbox_color_selector.h
1
KisScreenColorPicker QWidget
kis_screen_color_picker.h
1
KisVisualColorSelector QWidget
kis_visual_color_selector.h
1
KoColorPatch QWidget
KoColorPatch.h
1
KoColorSetWidget QFrame
KoColorSetWidget.h
1
buttonBox accepted() WdgDlgInternalColorSelector accept() 248 254 157 274 buttonBox rejected() WdgDlgInternalColorSelector reject() 316 260 286 274
diff --git a/plugins/dockers/digitalmixer/digitalmixer_dock.cc b/plugins/dockers/digitalmixer/digitalmixer_dock.cc index 8cb19dcbb4..6da7c7138d 100644 --- a/plugins/dockers/digitalmixer/digitalmixer_dock.cc +++ b/plugins/dockers/digitalmixer/digitalmixer_dock.cc @@ -1,161 +1,167 @@ /* * Copyright (c) 2009 Cyrille Berger * * This library is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; version 2.1 of the License. * * This library 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 Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser 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 "digitalmixer_dock.h" #include #include #include #include #include #include #include #include #include #include +#include + class DigitalMixerPatch : public KoColorPatch { public: DigitalMixerPatch(QWidget* parent) : KoColorPatch(parent) {} QSize sizeHint() const { return QSize(24,24); } }; DigitalMixerDock::DigitalMixerDock( ) : QDockWidget(i18n("Digital Colors Mixer")), m_canvas(0) , m_tellCanvas(true) { - QColor initColors[6] = { Qt::black, Qt::white, Qt::red, Qt::green, Qt::blue, Qt::yellow }; + const KoColorSpace *sRGB = KoColorSpaceRegistry::instance()->rgb8(); + KoColor initColors[6] = { KoColor(Qt::black, sRGB), + KoColor(Qt::white, sRGB), + KoColor(Qt::red, sRGB), + KoColor(Qt::green, sRGB), + KoColor(Qt::blue, sRGB), + KoColor(Qt::yellow, sRGB) }; QWidget* widget = new QWidget(this); QGridLayout* layout = new QGridLayout( widget ); // Current Color m_currentColorPatch = new KoColorPatch(this); m_currentColorPatch->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); m_currentColorPatch->setMinimumWidth(48); layout->addWidget(m_currentColorPatch, 0, 0,3,1); // Create the sliders QSignalMapper* signalMapperSelectColor = new QSignalMapper(this); connect(signalMapperSelectColor, SIGNAL(mapped(int)), SLOT(popupColorChanged(int))); QSignalMapper* signalMapperColorSlider = new QSignalMapper(this); connect(signalMapperColorSlider, SIGNAL(mapped(int)), SLOT(colorSliderChanged(int))); QSignalMapper* signalMapperTargetColor = new QSignalMapper(this); connect(signalMapperTargetColor, SIGNAL(mapped(int)), SLOT(targetColorChanged(int))); for(int i = 0; i < 6; ++i) { Mixer mixer; mixer.targetColor = new DigitalMixerPatch(this); mixer.targetColor->setFixedSize(32, 22); layout->addWidget(mixer.targetColor, 0, i + 1); mixer.targetSlider = new KoColorSlider(Qt::Vertical, this); mixer.targetSlider->setFixedWidth(22); mixer.targetSlider->setMinimumHeight(66); layout->addWidget(mixer.targetSlider, 1, i + 1); - QToolButton* colorSelector = new QToolButton( this ); - mixer.actionColor = new KoColorPopupAction(this); - mixer.actionColor->setCurrentColor(initColors[i]); - colorSelector->setDefaultAction(mixer.actionColor); - colorSelector->setFixedSize(colorSelector->sizeHint()); - layout->addWidget(colorSelector, 2, i + 1); + mixer.actionColor = new KisColorButton( this ); + mixer.actionColor->setColor(initColors[i]); + mixer.actionColor->setFixedWidth(22); + layout->addWidget(mixer.actionColor, 2, i + 1); m_mixers.push_back(mixer); - connect(mixer.actionColor, SIGNAL(colorChanged(KoColor)), signalMapperSelectColor, SLOT(map())); + connect(mixer.actionColor, SIGNAL(changed(KoColor)), signalMapperSelectColor, SLOT(map())); signalMapperSelectColor->setMapping(mixer.actionColor, i); connect(mixer.targetSlider, SIGNAL(valueChanged(int)), signalMapperColorSlider, SLOT(map())); signalMapperColorSlider->setMapping(mixer.targetSlider, i); mixer.targetSlider->setValue(125); connect(mixer.targetColor, SIGNAL(triggered(KoColorPatch*)), signalMapperTargetColor, SLOT(map())); signalMapperTargetColor->setMapping(mixer.targetColor, i); } setCurrentColor(KoColor(Qt::black, KoColorSpaceRegistry::instance()->rgb8())); setWidget( widget ); } void DigitalMixerDock::setCanvas(KoCanvasBase * canvas) { setEnabled(canvas != 0); if (m_canvas) { m_canvas->disconnectCanvasObserver(this); } m_canvas = canvas; if (m_canvas) { connect(m_canvas->resourceManager(), SIGNAL(canvasResourceChanged(int, const QVariant&)), this, SLOT(canvasResourceChanged(int, const QVariant&))); m_tellCanvas=false; setCurrentColor(m_canvas->resourceManager()->foregroundColor()); m_tellCanvas=true; } } void DigitalMixerDock::popupColorChanged(int i) { - KoColor color = m_mixers[i].actionColor->currentKoColor(); + KoColor color = m_mixers[i].actionColor->color(); color.convertTo(m_currentColor.colorSpace()); m_mixers[i].targetSlider->setColors( color, m_currentColor); colorSliderChanged(i); } void DigitalMixerDock::colorSliderChanged(int i) { m_mixers[i].targetColor->setColor(m_mixers[i].targetSlider->currentColor()); } void DigitalMixerDock::targetColorChanged(int i) { setCurrentColor(m_mixers[i].targetColor->color()); } void DigitalMixerDock::setCurrentColor(const KoColor& color) { m_currentColor = color; m_currentColorPatch->setColor(color); for(int i = 0; i < m_mixers.size(); ++i) { popupColorChanged(i); colorSliderChanged(i); } if (m_canvas && m_tellCanvas) { m_canvas->resourceManager()->setForegroundColor(m_currentColor); } } void DigitalMixerDock::canvasResourceChanged(int key, const QVariant& v) { m_tellCanvas = false; if (key == KoCanvasResourceManager::ForegroundColor) setCurrentColor(v.value()); m_tellCanvas = true; } diff --git a/plugins/dockers/digitalmixer/digitalmixer_dock.h b/plugins/dockers/digitalmixer/digitalmixer_dock.h index 1604b4b55f..21677b3d54 100644 --- a/plugins/dockers/digitalmixer/digitalmixer_dock.h +++ b/plugins/dockers/digitalmixer/digitalmixer_dock.h @@ -1,58 +1,59 @@ /* * Copyright (c) 2009 Cyrille Berger * * This library is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; version 2.1 of the License. * * This library 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 Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser 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 _DIGITALMIXER_DOCK_H_ #define _DIGITALMIXER_DOCK_H_ #include #include #include class KoColorPopupAction; class KoColorSlider; class KoColorPatch; +class KisColorButton; class DigitalMixerDock : public QDockWidget, public KoCanvasObserverBase { Q_OBJECT public: DigitalMixerDock( ); QString observerName() { return "DigitalMixerDock"; } /// reimplemented from KoCanvasObserverBase virtual void setCanvas(KoCanvasBase *canvas); virtual void unsetCanvas() { m_canvas = 0; setEnabled(false);} public Q_SLOTS: void setCurrentColor(const KoColor& ); void canvasResourceChanged(int, const QVariant&); private Q_SLOTS: void popupColorChanged(int i); void colorSliderChanged(int i); void targetColorChanged(int); private: KoCanvasBase* m_canvas; KoColor m_currentColor; KoColorPatch* m_currentColorPatch; struct Mixer { KoColorPatch* targetColor; KoColorSlider* targetSlider; - KoColorPopupAction* actionColor; + KisColorButton* actionColor; }; QList m_mixers; bool m_tellCanvas; }; #endif diff --git a/plugins/filters/indexcolors/kiswdgindexcolors.cpp b/plugins/filters/indexcolors/kiswdgindexcolors.cpp index 22a57c9ff9..c375e6ee8b 100644 --- a/plugins/filters/indexcolors/kiswdgindexcolors.cpp +++ b/plugins/filters/indexcolors/kiswdgindexcolors.cpp @@ -1,190 +1,192 @@ /* * Copyright 2014 Manuel Riecke * * Permission to use, copy, modify, and distribute this software * and its documentation for any purpose and without fee is hereby * granted, provided that the above copyright notice appear in all * copies and that both that the copyright notice and this * permission notice and warranty disclaimer appear in supporting * documentation, and that the name of the author not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * * The author disclaim all warranties with regard to this * software, including all implied warranties of merchantability * and fitness. In no event shall the author be liable for any * special, indirect or consequential damages or any damages * whatsoever resulting from loss of use, data or profits, whether * in an action of contract, negligence or other tortious action, * arising out of or in connection with the use or performance of * this software. */ #include "filter/kis_color_transformation_configuration.h" #include "kiswdgindexcolors.h" #include "palettegeneratorconfig.h" #include "ui_kiswdgindexcolors.h" #include "kis_int_parse_spin_box.h" -#include +#include KisWdgIndexColors::KisWdgIndexColors(QWidget* parent, Qt::WFlags f, int delay): KisConfigWidget(parent, f, delay) { ui = new Ui::KisWdgIndexColors; ui->setupUi(this); connect(ui->diagCheck, SIGNAL(toggled(bool)), SIGNAL(sigConfigurationItemChanged())); connect(ui->inbetweenSpinBox, SIGNAL(valueChanged(int)), SIGNAL(sigConfigurationItemChanged())); connect(ui->alphaStepsSpinBox, SIGNAL(valueChanged(int)), SIGNAL(sigConfigurationItemChanged())); connect(ui->colorLimit, SIGNAL(valueChanged(int)), SLOT(slotColorLimitChanged(int))); connect(ui->colorLimit, SIGNAL(valueChanged(int)), SIGNAL(sigConfigurationItemChanged())); connect(ui->colorLimitCheck, SIGNAL(toggled(bool)), SIGNAL(sigConfigurationItemChanged())); connect(ui->luminanceSlider, SIGNAL(valueChanged(int)), SIGNAL(sigConfigurationItemChanged())); connect(ui->aSlider, SIGNAL(valueChanged(int)), SIGNAL(sigConfigurationItemChanged())); connect(ui->bSlider, SIGNAL(valueChanged(int)), SIGNAL(sigConfigurationItemChanged())); } void KisWdgIndexColors::slotColorLimitChanged(int value) { ui->colorLimit->setSuffix(i18ncp("suffix for a spinbox", " color", " colors", value)); } void KisWdgIndexColors::setup(QStringList shadesLabels, int ramps) { int rows = shadesLabels.length(); int collumns = ramps; m_colorSelectors.resize(rows); m_stepSpinners.resize(rows-1); // Labels for the shades for(int row = 0; row < rows; ++row) { QLabel* l = new QLabel(shadesLabels[row], ui->colorsBox); ui->layoutColors->addWidget(l, row+1, 0); m_colorSelectors[row].resize(collumns); } // Labels for the ramps /*for(int col = 0; col < collumns; ++col) { QLabel* l = new QLabel(rampsLabels[col], ui->colorsBox); l->setAlignment(Qt::AlignRight | Qt::AlignVCenter); ui->layoutColors->addWidget(l, 0, col+1); }*/ // Step selectors for the shade gradients for(int row = 0; row < (rows-1); ++row) { QLabel* l0 = new QLabel(shadesLabels[row+1]); QLabel* l1 = new QLabel(QString::fromUtf8("↔")); QLabel* l2 = new QLabel(shadesLabels[row]); QSpinBox* s = new KisIntParseSpinBox(); s->setMinimum(0); s->setMaximum(32); s->setValue(2); connect(s, SIGNAL(valueChanged(int)), this, SIGNAL(sigConfigurationItemChanged())); m_stepSpinners[row] = s; ui->layoutRowSteps->addWidget(l0, row, 0); ui->layoutRowSteps->addWidget(l1, row, 1); ui->layoutRowSteps->addWidget(l2, row, 2); ui->layoutRowSteps->addWidget(s, row, 3); } // Color selectors for(int y = 0; y < rows; ++y) for(int x = 0; x < collumns; ++x) { - KColorButton* b = new KColorButton; + KisColorButton* b = new KisColorButton; QCheckBox* c = new QCheckBox; c->setChecked(false); b->setEnabled(false); b->setMaximumWidth(50); c->setMaximumWidth(21); // Ugh. I hope this won't be causing any issues. Trying to get rid of the unnecessary spacing after it. connect(c, SIGNAL(toggled(bool)), b, SLOT(setEnabled(bool))); connect(c, SIGNAL(toggled(bool)), this, SIGNAL(sigConfigurationItemChanged())); - connect(b, SIGNAL(changed(QColor)), this, SIGNAL(sigConfigurationItemChanged())); + connect(b, SIGNAL(changed(KoColor)), this, SIGNAL(sigConfigurationItemChanged())); QHBoxLayout* cell = new QHBoxLayout(); cell->setSpacing(0); cell->setContentsMargins(0, 0, 0, 0); cell->addWidget(c); cell->addWidget(b); ui->layoutColors->addLayout(cell, 1+y, 1+x); m_colorSelectors[y][x].button = b; m_colorSelectors[y][x].checkbox = c; } } KisPropertiesConfiguration* KisWdgIndexColors::configuration() const { KisColorTransformationConfiguration* config = new KisColorTransformationConfiguration("indexcolors", 1); PaletteGeneratorConfig palCfg; for(int y = 0; y < 4; ++y) for(int x = 0; x < 4; ++x) { - palCfg.colors[y][x] = m_colorSelectors[y][x].button->color(); + palCfg.colors[y][x] = m_colorSelectors[y][x].button->color().toQColor(); palCfg.colorsEnabled[y][x] = m_colorSelectors[y][x].button->isEnabled(); } for(int y = 0; y < 3; ++y) palCfg.gradientSteps[y] = m_stepSpinners[y]->value(); palCfg.diagonalGradients = ui->diagCheck->isChecked(); palCfg.inbetweenRampSteps = ui->inbetweenSpinBox->value(); IndexColorPalette pal = palCfg.generate(); ui->colorCount->setText(QString::number(pal.numColors())); config->setProperty("paletteGen", palCfg.toByteArray()); config->setProperty("LFactor", ui->luminanceSlider->value() / 100.f); config->setProperty("aFactor", ui->aSlider->value() / 100.f); config->setProperty("bFactor", ui->bSlider->value() / 100.f); config->setProperty("reduceColorsEnabled", ui->colorLimitCheck->isChecked()); config->setProperty("colorLimit", ui->colorLimit->value()); config->setProperty("alphaSteps", ui->alphaStepsSpinBox->value()); return config; } void KisWdgIndexColors::setConfiguration(const KisPropertiesConfiguration* config) { PaletteGeneratorConfig palCfg; palCfg.fromByteArray(config->getProperty("paletteGen").toByteArray()); ui->luminanceSlider->setValue(config->getFloat("LFactor")*100); ui->aSlider->setValue(config->getFloat("aFactor")*100); ui->bSlider->setValue(config->getFloat("bFactor")*100); ui->alphaStepsSpinBox->setValue(config->getInt("alphaSteps")); ui->colorLimitCheck->setChecked(config->getBool("reduceColorsEnabled")); ui->colorLimit->setEnabled(config->getBool("reduceColorsEnabled")); ui->colorLimit->setValue(config->getInt("colorLimit")); ui->diagCheck->setChecked(palCfg.diagonalGradients); ui->inbetweenSpinBox->setValue(palCfg.inbetweenRampSteps); for(int y = 0; y < 4; ++y) for(int x = 0; x < 4; ++x) { m_colorSelectors[y][x].checkbox->setChecked(palCfg.colorsEnabled[y][x]); m_colorSelectors[y][x].button->setEnabled(palCfg.colorsEnabled[y][x]); - m_colorSelectors[y][x].button->setColor(palCfg.colors[y][x]); + KoColor c; + c.fromQColor(palCfg.colors[y][x]); + m_colorSelectors[y][x].button->setColor(c); } for(int y = 0; y < 3; ++y) m_stepSpinners[y]->setValue(palCfg.gradientSteps[y]); IndexColorPalette pal = palCfg.generate(); ui->colorCount->setText(QString::number(pal.numColors())); } diff --git a/plugins/filters/indexcolors/kiswdgindexcolors.h b/plugins/filters/indexcolors/kiswdgindexcolors.h index 4f32831db7..f1d4605f3a 100644 --- a/plugins/filters/indexcolors/kiswdgindexcolors.h +++ b/plugins/filters/indexcolors/kiswdgindexcolors.h @@ -1,59 +1,59 @@ /* * Copyright 2014 Manuel Riecke * * Permission to use, copy, modify, and distribute this software * and its documentation for any purpose and without fee is hereby * granted, provided that the above copyright notice appear in all * copies and that both that the copyright notice and this * permission notice and warranty disclaimer appear in supporting * documentation, and that the name of the author not be used in * advertising or publicity pertaining to distribution of the * software without specific, written prior permission. * * The author disclaim all warranties with regard to this * software, including all implied warranties of merchantability * and fitness. In no event shall the author be liable for any * special, indirect or consequential damages or any damages * whatsoever resulting from loss of use, data or profits, whether * in an action of contract, negligence or other tortious action, * arising out of or in connection with the use or performance of * this software. */ #ifndef KISWDGINDEXCOLORS_H #define KISWDGINDEXCOLORS_H #include #include class QCheckBox; -class KColorButton; +class KisColorButton; namespace Ui { class KisWdgIndexColors; } class KisWdgIndexColors : public KisConfigWidget { Q_OBJECT public: KisWdgIndexColors(QWidget* parent = 0, Qt::WFlags f = 0, int delay = 500); virtual KisPropertiesConfiguration* configuration() const; virtual void setConfiguration(const KisPropertiesConfiguration* config); void setup(QStringList shadesLabels, int ramps); private Q_SLOTS: void slotColorLimitChanged(int value); private: struct ColorWidgets { - KColorButton* button; + KisColorButton* button; QCheckBox* checkbox; }; QVector< QVector > m_colorSelectors; QVector< QSpinBox* > m_stepSpinners; Ui::KisWdgIndexColors* ui; }; #endif // KISWDGINDEXCOLORS_H diff --git a/plugins/generators/pattern/wdgpatternoptions.ui b/plugins/generators/pattern/wdgpatternoptions.ui index bc75be6b05..47e3dd0916 100644 --- a/plugins/generators/pattern/wdgpatternoptions.ui +++ b/plugins/generators/pattern/wdgpatternoptions.ui @@ -1,86 +1,86 @@ WdgPatternOptions 0 0 158 78 0 0 0 0 &Pattern: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter patternChooser &Color: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter bnColor - + - + 0 0 - KColorButton + KisColorButton QPushButton -
kcolorbutton.h
+
kis_color_button.h
KisPatternChooser QWidget
kis_pattern_chooser.h
1
diff --git a/plugins/impex/jpeg/kis_jpeg_export.cc b/plugins/impex/jpeg/kis_jpeg_export.cc index 8169266783..c252383de6 100644 --- a/plugins/impex/jpeg/kis_jpeg_export.cc +++ b/plugins/impex/jpeg/kis_jpeg_export.cc @@ -1,226 +1,230 @@ /* * Copyright (c) 2005 Cyrille Berger * * 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_jpeg_export.h" #include #include #include #include #include #include #include #include #include #include +#include #include #include #include #include #include "kis_slider_spin_box.h" #include #include #include #include #include #include #include #include #include #include #include #include "kis_jpeg_converter.h" #include #include "ui_kis_wdg_options_jpeg.h" class KisExternalLayer; K_PLUGIN_FACTORY_WITH_JSON(KisJPEGExportFactory, "krita_jpeg_export.json", registerPlugin();) KisJPEGExport::KisJPEGExport(QObject *parent, const QVariantList &) : KisImportExportFilter(parent) { } KisJPEGExport::~KisJPEGExport() { } KisImportExportFilter::ConversionStatus KisJPEGExport::convert(const QByteArray& from, const QByteArray& to) { dbgFile << "JPEG export! From:" << from << ", To:" << to << ""; if (from != "application/x-krita") return KisImportExportFilter::NotImplemented; KisDocument *input = inputDocument(); if (!input) return KisImportExportFilter::NoDocumentCreated; KisImageWSP image = input->image(); Q_CHECK_PTR(image); KoDialog* kdb = new KoDialog(0); kdb->setWindowTitle(i18n("JPEG Export Options")); kdb->setButtons(KoDialog::Ok | KoDialog::Cancel); Ui::WdgOptionsJPEG wdgUi; QWidget* wdg = new QWidget(kdb); wdgUi.setupUi(wdg); KisMetaData::FilterRegistryModel frm; wdgUi.metaDataFilters->setModel(&frm); QString filterConfig = KisConfig().exportConfiguration("JPEG"); KisPropertiesConfiguration cfg; cfg.fromXML(filterConfig); wdgUi.progressive->setChecked(cfg.getBool("progressive", false)); wdgUi.qualityLevel->setValue(cfg.getInt("quality", 80)); wdgUi.qualityLevel->setRange(0, 100, 0); wdgUi.qualityLevel->setSuffix("%"); wdgUi.optimize->setChecked(cfg.getBool("optimize", true)); wdgUi.smoothLevel->setValue(cfg.getInt("smoothing", 0)); wdgUi.smoothLevel->setRange(0, 100, 0); wdgUi.smoothLevel->setSuffix("%"); wdgUi.baseLineJPEG->setChecked(cfg.getBool("baseline", true)); wdgUi.subsampling->setCurrentIndex(cfg.getInt("subsampling", 0)); wdgUi.exif->setChecked(cfg.getBool("exif", true)); wdgUi.iptc->setChecked(cfg.getBool("iptc", true)); wdgUi.xmp->setChecked(cfg.getBool("xmp", true)); const KoColorSpace* cs = image->projection()->colorSpace(); bool sRGB = cs->profile()->name().contains(QLatin1String("srgb"), Qt::CaseInsensitive); wdgUi.chkForceSRGB->setVisible(!sRGB); wdgUi.chkForceSRGB->setChecked(cfg.getBool("forceSRGB", false)); wdgUi.chkSaveProfile->setChecked(cfg.getBool("saveProfile", true)); QStringList rgb = cfg.getString("transparencyFillcolor", "255,255,255").split(','); - wdgUi.bnTransparencyFillColor->setDefaultColor(Qt::white); - wdgUi.bnTransparencyFillColor->setColor(QColor(rgb[0].toInt(), rgb[1].toInt(), rgb[2].toInt())); + KoColor background(KoColorSpaceRegistry::instance()->rgb8()); + background.fromQColor(Qt::white); + wdgUi.bnTransparencyFillColor->setDefaultColor(background); + background.fromQColor(QColor(rgb[0].toInt(), rgb[1].toInt(), rgb[2].toInt())); + wdgUi.bnTransparencyFillColor->setColor(background); frm.setEnabledFilters(cfg.getString("filters").split(',')); kdb->setMainWidget(wdg); QApplication::restoreOverrideCursor(); if (!getBatchMode()) { if (kdb->exec() == QDialog::Rejected) { delete kdb; return KisImportExportFilter::UserCancelled; } } KisJPEGOptions options; options.progressive = wdgUi.progressive->isChecked(); cfg.setProperty("progressive", options.progressive); options.quality = (int)wdgUi.qualityLevel->value(); cfg.setProperty("quality", options.quality); options.forceSRGB = wdgUi.chkForceSRGB->isChecked(); cfg.setProperty("forceSRGB", options.forceSRGB); options.saveProfile = wdgUi.chkSaveProfile->isChecked(); cfg.setProperty("saveProfile", options.saveProfile); // Advanced options.optimize = wdgUi.optimize->isChecked(); cfg.setProperty("optimize", options.optimize); options.smooth = (int)wdgUi.smoothLevel->value(); cfg.setProperty("smoothing", options.smooth); options.baseLineJPEG = wdgUi.baseLineJPEG->isChecked(); cfg.setProperty("baseline", options.baseLineJPEG); options.subsampling = wdgUi.subsampling->currentIndex(); cfg.setProperty("subsampling", options.subsampling); // Jpeg options.exif = wdgUi.exif->isChecked(); cfg.setProperty("exif", options.exif); options.iptc = wdgUi.iptc->isChecked(); cfg.setProperty("iptc", options.iptc); options.xmp = wdgUi.xmp->isChecked(); cfg.setProperty("xmp", options.xmp); - QColor c = wdgUi.bnTransparencyFillColor->color(); + QColor c = wdgUi.bnTransparencyFillColor->color().toQColor(); options.transparencyFillColor = c; cfg.setProperty("transparencyFillcolor", QString("%1,%2,%3").arg(c.red()).arg(c.green()).arg(c.blue())); options.filters = frm.enabledFilters(); QString enabledFilters; Q_FOREACH (const KisMetaData::Filter* filter, options.filters) { enabledFilters = enabledFilters + filter->id() + ','; } cfg.setProperty("filters", enabledFilters); KisConfig().setExportConfiguration("JPEG", cfg); delete kdb; // XXX: Add dialog about flattening layers here QString filename = outputFile(); if (filename.isEmpty()) return KisImportExportFilter::FileNotFound; // the image must be locked at the higher levels KIS_SAFE_ASSERT_RECOVER_NOOP(input->image()->locked()); KisPaintDeviceSP pd = new KisPaintDevice(*image->projection()); KisJPEGConverter kpc(input, getBatchMode()); KisPaintLayerSP l = new KisPaintLayer(image, "projection", OPACITY_OPAQUE_U8, pd); vKisAnnotationSP_it beginIt = image->beginAnnotations(); vKisAnnotationSP_it endIt = image->endAnnotations(); KisImageBuilder_Result res; KisExifInfoVisitor eIV; eIV.visit(image->rootLayer().data()); KisMetaData::Store* eI = 0; if (eIV.countPaintLayer() == 1) eI = eIV.exifInfo(); if (eI) { KisMetaData::Store* copy = new KisMetaData::Store(*eI); eI = copy; } if ((res = kpc.buildFile(filename, l, beginIt, endIt, options, eI)) == KisImageBuilder_RESULT_OK) { dbgFile << "success !"; delete eI; return KisImportExportFilter::OK; } delete eI; dbgFile << " Result =" << res; return KisImportExportFilter::InternalError; } #include diff --git a/plugins/impex/jpeg/kis_wdg_options_jpeg.ui b/plugins/impex/jpeg/kis_wdg_options_jpeg.ui index eb0dbbd183..c1596513af 100644 --- a/plugins/impex/jpeg/kis_wdg_options_jpeg.ui +++ b/plugins/impex/jpeg/kis_wdg_options_jpeg.ui @@ -1,368 +1,368 @@ WdgOptionsJPEG 0 0 - 537 + 545 390 0 Basic Progressive Force convert to sRGB 20 - + 0 0 0 0 <html><head/><body><p>These settings determine how much information is lost during compression. Low: small files, bad quality. High: big files, good quality.</p></body></html> 0 0 Compression: 0 0 Transparent pixel fill color: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - + 0 0 25 0 <html><head/><body><p>Background color to replace transparent pixels with.</p></body></html> Qt::Vertical 20 40 Save ICC Profile false Advanced quality 20 - + 0 0 60 20 0 0 Smooth: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter 0 0 Subsampling: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter 2x2, 1x1, 1x1 (smallest file) 2x1, 1x1, 1x1 1x2, 1x1, 1x1 1x1, 1x1, 1x1 (best quality) Force baseline JPEG true Optimize true Qt::Vertical 20 40 Metadata Formats: Exif true IPTC true XMP true Qt::Vertical 20 40 Filters: Qt::Vertical 505 16 - - KColorButton - QPushButton -
kcolorbutton.h
-
KisDoubleSliderSpinBox QWidget
kis_slider_spin_box.h
1
+ + KisColorButton + QPushButton +
kis_color_button.h
+
tabWidget progressive baseLineJPEG metaDataFilters exif iptc xmp
diff --git a/plugins/impex/png/kis_png_export.cc b/plugins/impex/png/kis_png_export.cc index 7edb7cdda6..0f3aaf0ef2 100644 --- a/plugins/impex/png/kis_png_export.cc +++ b/plugins/impex/png/kis_png_export.cc @@ -1,252 +1,256 @@ /* * Copyright (c) 2005 Cyrille Berger * * 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_png_export.h" #include #include #include #include #include #include #include +#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "kis_png_converter.h" #include K_PLUGIN_FACTORY_WITH_JSON(KisPNGExportFactory, "krita_png_export.json", registerPlugin();) KisPNGExport::KisPNGExport(QObject *parent, const QVariantList &) : KisImportExportFilter(parent) { } KisPNGExport::~KisPNGExport() { } bool hasVisibleWidgets() { QWidgetList wl = QApplication::allWidgets(); Q_FOREACH (QWidget* w, wl) { if (w->isVisible() && strcmp(w->metaObject()->className(), "QDesktopWidget")) { dbgFile << "Widget " << w << " " << w->objectName() << " " << w->metaObject()->className() << " is visible"; return true; } } return false; } KisImportExportFilter::ConversionStatus KisPNGExport::convert(const QByteArray& from, const QByteArray& to) { dbgFile << "Png export! From:" << from << ", To:" << to << ""; KisDocument *input = inputDocument(); QString filename = outputFile(); if (!input) return KisImportExportFilter::NoDocumentCreated; if (filename.isEmpty()) return KisImportExportFilter::FileNotFound; if (from != "application/x-krita") return KisImportExportFilter::NotImplemented; KoDialog* kdb = new KoDialog(0); kdb->setCaption(i18n("PNG Export Options")); kdb->setModal(false); kdb->setButtons(KoDialog::Ok | KoDialog::Cancel); KisImageWSP image = input->image(); // the image must be locked at the higher levels KIS_SAFE_ASSERT_RECOVER_NOOP(image->locked()); KisPaintDeviceSP pd; pd = new KisPaintDevice(*image->projection()); KisPaintLayerSP l = new KisPaintLayer(image, "projection", OPACITY_OPAQUE_U8, pd); if (!KisPNGConverter::isColorSpaceSupported(pd->colorSpace())) { if (!getBatchMode()) { QMessageBox::critical(0, i18nc("@title:window", "Krita PNG Export"), i18n("You can only save grayscale and RGB images to PNG. Convert your image before exporting to PNG.")); } return KisImportExportFilter::UsageError; } KisSequentialConstIterator it(l->paintDevice(), image->bounds()); const KoColorSpace* cs = l->paintDevice()->colorSpace(); KisPNGOptions options; bool isThereAlpha = false; do { if (cs->opacityU8(it.oldRawData()) != OPACITY_OPAQUE_U8) { isThereAlpha = true; break; } } while (it.nextPixel()); if (!qApp->applicationName().toLower().contains("test")) { bool sRGB = (cs->profile()->name().contains(QLatin1String("srgb"), Qt::CaseInsensitive) && !cs->profile()->name().contains(QLatin1String("g10"))); KisWdgOptionsPNG* wdg = new KisWdgOptionsPNG(kdb); QString filterConfig = KisConfig().exportConfiguration("PNG"); KisPropertiesConfiguration cfg; cfg.fromXML(filterConfig); wdg->alpha->setChecked(cfg.getBool("alpha", isThereAlpha)); if (cs->colorModelId() == RGBAColorModelID) { wdg->tryToSaveAsIndexed->setVisible(true); if (wdg->alpha->isChecked()) { wdg->tryToSaveAsIndexed->setChecked(false); } else { wdg->tryToSaveAsIndexed->setChecked(cfg.getBool("indexed", false)); } } else { wdg->tryToSaveAsIndexed->setVisible(false); } wdg->interlacing->setChecked(cfg.getBool("interlaced", false)); wdg->compressionLevel->setValue(cfg.getInt("compression", 9)); wdg->compressionLevel->setRange(1, 9 , 0); wdg->alpha->setEnabled(isThereAlpha); wdg->tryToSaveAsIndexed->setVisible(!isThereAlpha); wdg->bnTransparencyFillColor->setEnabled(!wdg->alpha->isChecked()); //This used to be 'cfg.getBool("saveSRGBProfile", true)' but firefox and ColorD are incredibly awkward about sRGB management //on Linux devices, as indicated by the same distorted colours with using the sRGB chunk, meaning it's unrelated to the profile. //We can somewhat assume sRGB is the default color space for the web, but it's still a darn pity we cannot rely on firefox and colord //to manage sRGB-marked images properly. wdg->chkSRGB->setEnabled(sRGB); wdg->chkSRGB->setChecked(cfg.getBool("saveSRGBProfile", false)); wdg->chkForceSRGB->setEnabled(!sRGB); wdg->chkForceSRGB->setChecked(cfg.getBool("forceSRGB", false)); QStringList rgb = cfg.getString("transparencyFillcolor", "0,0,0").split(','); - wdg->bnTransparencyFillColor->setDefaultColor(Qt::white); - wdg->bnTransparencyFillColor->setColor(QColor(rgb[0].toInt(), rgb[1].toInt(), rgb[2].toInt())); + KoColor background(KoColorSpaceRegistry::instance()->rgb8()); + background.fromQColor(Qt::white); + wdg->bnTransparencyFillColor->setDefaultColor(background); + background.fromQColor(QColor(rgb[0].toInt(), rgb[1].toInt(), rgb[2].toInt())); + wdg->bnTransparencyFillColor->setColor(background); kdb->setMainWidget(wdg); QApplication::restoreOverrideCursor(); if (hasVisibleWidgets()) { if (!getBatchMode()) { if (kdb->exec() == QDialog::Rejected) { return KisImportExportFilter::UserCancelled; } } } bool alpha = wdg->alpha->isChecked(); bool interlace = wdg->interlacing->isChecked(); int compression = (int)wdg->compressionLevel->value(); bool tryToSaveAsIndexed = wdg->tryToSaveAsIndexed->isChecked(); - QColor c = wdg->bnTransparencyFillColor->color(); + QColor c = wdg->bnTransparencyFillColor->color().toQColor(); bool saveSRGB = wdg->chkSRGB->isChecked(); bool forceSRGB = wdg->chkForceSRGB->isChecked(); cfg.setProperty("alpha", alpha); cfg.setProperty("indexed", tryToSaveAsIndexed); cfg.setProperty("compression", compression); cfg.setProperty("interlaced", interlace); cfg.setProperty("transparencyFillcolor", QString("%1,%2,%3").arg(c.red()).arg(c.green()).arg(c.blue())); cfg.setProperty("saveSRGBProfile", saveSRGB); cfg.setProperty("forceSRGB", forceSRGB); KisConfig().setExportConfiguration("PNG", cfg); options.alpha = alpha; options.interlace = interlace; options.compression = compression; options.tryToSaveAsIndexed = tryToSaveAsIndexed; options.transparencyFillColor = c; options.saveSRGBProfile = saveSRGB; options.forceSRGB = forceSRGB; } else { options.alpha = true; options.interlace = false; options.compression = 9; options.tryToSaveAsIndexed = false; options.transparencyFillColor = QColor(0,0,0); options.saveSRGBProfile = false; options.forceSRGB = false; } delete kdb; KisPNGConverter kpc(input); vKisAnnotationSP_it beginIt = image->beginAnnotations(); vKisAnnotationSP_it endIt = image->endAnnotations(); KisImageBuilder_Result res; KisExifInfoVisitor eIV; eIV.visit(image->rootLayer().data()); KisMetaData::Store* eI = 0; if (eIV.countPaintLayer() == 1) eI = eIV.exifInfo(); if (eI) { KisMetaData::Store* copy = new KisMetaData::Store(*eI); eI = copy; } if ((res = kpc.buildFile(filename, image->bounds(), image->xRes(), image->yRes(), l->paintDevice(), beginIt, endIt, options, eI)) == KisImageBuilder_RESULT_OK) { dbgFile << "success !"; delete eI; return KisImportExportFilter::OK; } delete eI; dbgFile << " Result =" << res; return KisImportExportFilter::InternalError; } #include "kis_png_export.moc" void KisWdgOptionsPNG::on_alpha_toggled(bool checked) { bnTransparencyFillColor->setEnabled(!checked); } diff --git a/plugins/impex/png/kis_wdg_options_png.ui b/plugins/impex/png/kis_wdg_options_png.ui index 3e4eb99bc6..405c28ee77 100644 --- a/plugins/impex/png/kis_wdg_options_png.ui +++ b/plugins/impex/png/kis_wdg_options_png.ui @@ -1,215 +1,215 @@ KisWdgOptionsPNG 0 0 - 476 + 546 243 PNG Options 0 0 0 0 0 6 <html><head/><body><p><span style=" font-weight:600;">PNG</span> files have <span style=" font-style:italic;">two</span> options to save <span style=" font-weight:600;">sRGB</span> information: as a tag or as an explicit profile. For use with in websites, <span style=" font-style:italic;">disable</span> this option. For interchange with other applications, <span style=" font-style:italic;">enable</span> this option.</p></body></html> Embed sRGB profile Force convert to sRGB - + Note: the compression level does not change the quality of the result <p>Adjust the compression time. Better compression takes longer. <br>Note: the compression level does not change the quality of the result.</p> Note: the compression level does not change the quality of the result <p>Adjust the compression time. Better compression takes longer. <br>Note: the compression level does not change the quality of the result.</p> Compression (Lossless): Qt::AlignRight|Qt::AlignTop|Qt::AlignTrailing <p>Adjust the compression time. Better compression takes longer. <br>Note: the compression level does not change the quality of the result.</p> Small File Size Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter <p>Adjust the compression time. Better compression takes longer. <br>Note: the compression level does not change the quality of the result.</p> Large file size Disable to get smaller files if your image has no transparency <p>The Portable Network Graphics (PNG) file format allows transparency in your image to be stored by saving an alpha channel. You can uncheck the box if you are not using transparency and you want to make the resulting file smaller .<br>Always saving the alpha channel is recommended.</p> Store alpha channel (transparency) true Use interlacing when publishing on the Internet. <p>Interlacing is useful if you intend to publish your image on the Internet.<br> Enabling interlacing will cause the image to be displayed by the browser even while downloading.</p> Interlacing Indexed PNG images are smaller. If you enabled this option, your image will be analyzed to see whether it is possible to save as an indexed PNG. Save as indexed PNG, if possible true Transparent color: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - + 0 0 50 0 <html><head/><body><p>Background color to replace transparent pixels with.</p></body></html> Qt::Vertical QSizePolicy::Expanding 414 16 KisDoubleSliderSpinBox QWidget
kis_slider_spin_box.h
1
- KColorButton + KisColorButton QPushButton -
kcolorbutton.h
+
kis_color_button.h