diff --git a/libs/ui/forms/wdgpreseticonlibrary.ui b/libs/ui/forms/wdgpreseticonlibrary.ui index 304caa50b9..9e6030030c 100644 --- a/libs/ui/forms/wdgpreseticonlibrary.ui +++ b/libs/ui/forms/wdgpreseticonlibrary.ui @@ -1,159 +1,198 @@ wdgpreseticonlibrary 0 0 536 505 Form - - - - - - - Tool image: - - - - - - - - 0 - 20 - - - - - - - + + + + + + 0 + 20 + + + + + + + + + 0 + 20 + + + + + + + + Color adjustment: + + + + + + + <html><head/><body><p>Choose the optional emblem icon that indicates extra information, such as the preset being a special effects brush, or just using tilt, or angled in some way.</p></body></html> + + + Emblem icon: + + + + + + + Upper left emblem indicating a special feature of the brush. + + + QAbstractItemView::NoEditTriggers + + + + 40 + 40 + + + + QListView::Adjust + + + + 42 + 42 + + + + QListView::IconMode + + + + + + + + + Qt::Horizontal + + - 0 + 40 20 - + - - - - <html><head/><body><p>Choose the optional emblem icon that indicates extra information, such as the preset being a special effects brush, or just using tilt, or angled in some way.</p></body></html> - - - Emblem icon: - - - - - - - Color adjustment: - - - - + 200 200 - - - - - 0 - 20 - - - - - - - - Base tool image to base this preset on. - - - QAbstractItemView::NoEditTriggers - - - - 75 - 75 - - - - QListView::Static - - - QListView::Adjust - - - - 77 - 77 - - - - QListView::IconMode - - - - - - - Upper left emblem indicating a special feature of the brush. - - - QAbstractItemView::NoEditTriggers + + + + Qt::Horizontal - + 40 - 40 - - - - QListView::Adjust - - - - 42 - 42 + 20 - - QListView::IconMode - - + + + + + Base tool image to base this preset on. + + + QAbstractItemView::NoEditTriggers + + + + 75 + 75 + + + + QListView::Static + + + QListView::Adjust + + + + 77 + 77 + + + + QListView::IconMode + + + + + + + + 0 + 20 + + + + + + + + Tool image: + + + + + + + Qt::Horizontal + + + + 40 + 6 + + + + KisDoubleSliderSpinBox QWidget
kis_slider_spin_box.h
1
diff --git a/libs/ui/widgets/kis_paintop_preset_icon_library.cpp b/libs/ui/widgets/kis_paintop_preset_icon_library.cpp index d96d87cc40..ceb7ca9caf 100644 --- a/libs/ui/widgets/kis_paintop_preset_icon_library.cpp +++ b/libs/ui/widgets/kis_paintop_preset_icon_library.cpp @@ -1,166 +1,166 @@ /* This file is part of the KDE project * Copyright (C) 2017 Wolthera van Hövell tot Westerflier * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #include "kis_paintop_preset_icon_library.h" #include #include #include #include #include #include #include #include #include #include KisPaintopPresetIconLibrary::KisPaintopPresetIconLibrary(QWidget *parent): QWidget(parent), ui(new Ui_wdgpreseticonlibrary) { ui->setupUi(this); ui->sldHue->setRange(0.0,360.0,1); ui->sldHue->setSingleStep(1.0); ui->sldHue->setPrefix(i18n("Hue:")); ui->sldSat->setRange(-50.0,50.0,1); ui->sldSat->setSingleStep(1.0); ui->sldSat->setPrefix(i18n("Saturation:")); ui->sldLevels->setRange(-50.0,50.0,1); ui->sldLevels->setSingleStep(1.0); ui->sldLevels->setPrefix(i18n("Mid-gray level:")); m_baseModel = new QStandardItemModel(); ui->vwBase->setModel(m_baseModel); m_optionalModel = new QStandardItemModel(); ui->vwOptional->setModel(m_optionalModel); QStringList background_paths = KoResourcePaths::findAllResources("data", "preset_icons/*.png"); if (background_paths.size()>0) { m_background.load(background_paths.at(0)); m_background = m_background.scaled(200, 200); } ui->lblIconPreview->setPixmap(QPixmap::fromImage(m_background)); //empty default: QImage empty = QImage(200, 200, QImage::Format_ARGB32); empty.fill(Qt::transparent); m_baseModel->appendRow(new QStandardItem(QIcon(QPixmap::fromImage(empty)), NULL)); QStringList toolIcon_paths = KoResourcePaths::findAllResources("data", "preset_icons/tool_icons/*.png"); for (int i=0; iappendRow(image); } empty = QImage(40, 40, QImage::Format_ARGB32); empty.fill(Qt::transparent); m_optionalModel->appendRow(new QStandardItem(QIcon(QPixmap::fromImage(empty)), NULL)); QStringList emblemIcon_paths = KoResourcePaths::findAllResources("data", "preset_icons/emblem_icons/*.png"); for (int i=0; iappendRow(image); } connect(ui->vwBase->selectionModel(), SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection &)), this, SLOT(updateIcon())); connect(ui->vwOptional->selectionModel(), SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection &)), this, SLOT(updateIcon())); connect(ui->sldHue, SIGNAL(valueChanged(qreal)), this, SLOT(updateIcon())); connect(ui->sldSat, SIGNAL(valueChanged(qreal)), this, SLOT(updateIcon())); connect(ui->sldLevels, SIGNAL(valueChanged(qreal)), this, SLOT(updateIcon())); } KisPaintopPresetIconLibrary::~KisPaintopPresetIconLibrary() { delete ui; m_optionalModel->clear(); delete m_optionalModel; m_baseModel->clear(); delete m_baseModel; } QImage KisPaintopPresetIconLibrary::getImage() { QImage preset = m_background; QImage base = QImage(200, 200, QImage::Format_ARGB32); base.fill(Qt::transparent); if (ui->vwBase->currentIndex().isValid()) { base = m_baseModel->itemFromIndex(ui->vwBase->currentIndex())->icon().pixmap(QSize(200, 200)).toImage(); } if (ui->sldHue->value()>0 || ui->sldSat->value()!=0.0 || ui->sldLevels->value()!=0.0) { base = hueTransform(base); } QImage optional = QImage(40, 40, QImage::Format_ARGB32); optional.fill(Qt::transparent); if (ui->vwOptional->currentIndex().isValid()) { optional = m_optionalModel->itemFromIndex(ui->vwOptional->currentIndex())->icon().pixmap(QSize(40, 40)).toImage(); } QPainter p(&preset); p.drawImage(0, 0, base); int x = 35; int y = 31; p.drawImage(x, y, optional); return preset; } QImage KisPaintopPresetIconLibrary::hueTransform(QImage img) { //This is a super simple levels operation instead of a regular lightness adjustment. //This is so that we can keep the contrasts in the icon instead of making it //just darker or lighter. QVector values(256); values.fill(255); int level = qMax(qMin( 28 + ( (int(ui->sldLevels->value()) + 50) * 2), 255), 0); - for (int v=0; vsldHue->value(); - if (hue>360) { - hue-=360; + if (hue > 360) { + hue -= 360; } - int sat = qMax(qMin(c.hslSaturation()+int(ui->sldSat->value()*(255/100)), 255), 0); + int sat = qMax(qMin(c.hslSaturation()+int(ui->sldSat->value() * (255/100)), 255), 0); c.setHsl(hue, sat, values.at(c.lightness()), c.alpha()); img.setPixelColor(x, y, c); } } return img; } void KisPaintopPresetIconLibrary::updateIcon() { ui->lblIconPreview->setPixmap(QPixmap::fromImage(getImage())); }