diff --git a/cmake/modules/FindPyQt5.py b/cmake/modules/FindPyQt5.py index e0ef9d7bdb..353021d7bf 100644 --- a/cmake/modules/FindPyQt5.py +++ b/cmake/modules/FindPyQt5.py @@ -1,47 +1,47 @@ # Copyright (c) 2014, Simon Edwards # Redistribution and use is allowed according to the terms of the BSD license. # For details see the accompanying COPYING-CMAKE-SCRIPTS file. -import sys +import sys, site import os try: # On Windows and Python 3.8+ python doesn't load module DLL's # from the current PATH environment, therefore we should add # path to Qt's DLL's manually. This variable is passed from # FindPyQt5.cmake for path in os.environ['PYTHONDLLPATH'].split(';'): os.add_dll_directory(path) except: pass import PyQt5.QtCore print("pyqt_version:%06.0x" % PyQt5.QtCore.PYQT_VERSION) print("pyqt_version_str:%s" % PyQt5.QtCore.PYQT_VERSION_STR) pyqt_version_tag = "" in_t = False pyqt_config_list = PyQt5.QtCore.PYQT_CONFIGURATION["sip_flags"].split(' ') for item in pyqt_config_list: if item == "-t": in_t = True elif in_t: if item.startswith("Qt_5"): pyqt_version_tag = item else: in_t = False print("pyqt_version_tag:%s" % pyqt_version_tag) try: index_n = pyqt_config_list.index('-n') pyqt_sip_name = '-n' + pyqt_config_list[index_n + 1] print("pyqt_sip_name:%s" % pyqt_sip_name) except ValueError: pass # FIXME This next line is just a little bit too crude. -pyqt_sip_dir = os.path.join(sys.prefix, "share", "sip", "PyQt5") +pyqt_sip_dir = os.path.join(site.getsitepackages()[0], "PyQt5", "bindings") print("pyqt_sip_dir:%s" % pyqt_sip_dir) print("pyqt_sip_flags:%s" % PyQt5.QtCore.PYQT_CONFIGURATION["sip_flags"]) diff --git a/libs/libqml/plugins/kritasketchplugin/ColorSelectorItem.cpp b/libs/libqml/plugins/kritasketchplugin/ColorSelectorItem.cpp index 535f149358..0870a1d3a4 100644 --- a/libs/libqml/plugins/kritasketchplugin/ColorSelectorItem.cpp +++ b/libs/libqml/plugins/kritasketchplugin/ColorSelectorItem.cpp @@ -1,337 +1,339 @@ /* This file is part of the KDE project * Copyright (C) 2012 Dan Leinir Turthra Jensen * * 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 "ColorSelectorItem.h" #include #include #include #include #include #include #include #include #include #include #include #include #include "kis_display_color_converter.h" #include class ColorSelectorItem::Private { public: Private(ColorSelectorItem* qq) : q(qq) , selector(new KisColorSelector) , view(0) , colorRole(Acs::Foreground) , grabbingComponent(0) , colorUpdateAllowed(true) , changeBackground(false) , shown(true) , repaintTimer(new QTimer) { ring = new KisColorSelectorRing(selector); ring->setInnerRingRadiusFraction(0.7); triangle = new KisColorSelectorTriangle(selector); slider = new KisColorSelectorSimple(selector); square = new KisColorSelectorSimple(selector); wheel = new KisColorSelectorWheel(selector); main = triangle; sub = ring; connect(main, SIGNAL(paramChanged(qreal,qreal,qreal,qreal,qreal,qreal,qreal,qreal,qreal)), sub, SLOT(setParam(qreal,qreal,qreal,qreal,qreal,qreal,qreal,qreal,qreal)), Qt::UniqueConnection); connect(sub, SIGNAL(paramChanged(qreal,qreal,qreal,qreal,qreal,qreal,qreal,qreal,qreal)), main, SLOT(setParam(qreal,qreal,qreal,qreal,qreal,qreal,qreal,qreal,qreal)), Qt::UniqueConnection); main->setConfiguration(selector->configuration().mainTypeParameter, selector->configuration().mainType); sub->setConfiguration(selector->configuration().subTypeParameter, selector->configuration().subType); repaintTimer->setInterval(50); repaintTimer->setSingleShot(true); connect(repaintTimer, SIGNAL(timeout()), q, SLOT(repaint())); } ~Private() { selector->deleteLater(); } void repaint(); QImage paintedItem; ColorSelectorItem* q; KisColorSelector* selector; KisColorSelectorRing* ring; KisColorSelectorTriangle* triangle; KisColorSelectorSimple* slider; KisColorSelectorSimple* square; KisColorSelectorWheel* wheel; KisColorSelectorComponent* main; KisColorSelectorComponent* sub; KisViewManager* view; Acs::ColorRole colorRole; KoColor currentColor; KisColorSelectorComponent* grabbingComponent; void commitColor(const KoColor& color, Acs::ColorRole role); bool colorUpdateAllowed; bool changeBackground; bool shown; QTimer* repaintTimer; void colorChangedImpl(const KoColor &color, Acs::ColorRole role); }; void ColorSelectorItem::Private::commitColor(const KoColor& color, Acs::ColorRole role) { if (!view->canvas()) return; KoColor currentColor = Acs::currentColor(view->canvasResourceProvider(), role); if (color == currentColor) return; colorUpdateAllowed = false; Acs::setCurrentColor(view->canvasResourceProvider(), role, color); QColor qcolor = selector->converter()->toQColor(currentColor); emit q->colorChanged(qcolor, color.opacityF(), false); colorUpdateAllowed = true; } ColorSelectorItem::ColorSelectorItem(QQuickItem* parent) : QQuickPaintedItem(parent) , d(new Private(this)) { setFlag(QQuickItem::ItemHasContents, true); setAcceptedMouseButtons( Qt::LeftButton | Qt::RightButton ); } ColorSelectorItem::~ColorSelectorItem() { delete d; } void ColorSelectorItem::paint(QPainter* painter) { if(!d->shown) return; painter->drawImage(boundingRect(), d->paintedItem); } void ColorSelectorItem::Private::repaint() { paintedItem = QImage(q->boundingRect().size().toSize(), QImage::Format_ARGB32_Premultiplied); if(paintedItem.isNull()) return; paintedItem.fill(Qt::transparent); QPainter painter; painter.begin(&paintedItem); main->paintEvent(&painter); sub->paintEvent(&painter); painter.end(); q->update(); } void ColorSelectorItem::geometryChanged(const QRectF& newGeometry, const QRectF& oldGeometry) { // QRectF bounds = boundingRect(); // if (d->selector->configuration().subType==KisColorSelector::Ring) // { // d->ring->setGeometry(bounds.x(),bounds.y(),bounds.width(), bounds.height()); // if (d->selector->configuration().mainType==KisColorSelector::Triangle) // { // d->triangle->setGeometry(bounds.width()/2 - d->ring->innerRadius(), // bounds.height()/2 - d->ring->innerRadius(), // d->ring->innerRadius()*2, // d->ring->innerRadius()*2); // } // else // { // int size = d->ring->innerRadius()*2/sqrt(2.); // d->square->setGeometry(bounds.width()/2 - size/2, // bounds.height()/2 - size/2, // size, // size); // } // } // else // { // // type wheel and square // if (d->selector->configuration().mainType==KisColorSelector::Wheel) // { // d->main->setGeometry(bounds.x(), bounds.y() + height()*0.1, bounds.width(), bounds.height()*0.9); // d->sub->setGeometry( bounds.x(), bounds.y(), bounds.width(), bounds.height()*0.1); // } // else // { // if (bounds.height()>bounds.width()) // { // d->main->setGeometry(bounds.x(), bounds.y() + bounds.height()*0.1, bounds.width(), bounds.height()*0.9); // d->sub->setGeometry( bounds.x(), bounds.y(), bounds.width(), bounds.height()*0.1); // } // else // { // d->main->setGeometry(bounds.x(), bounds.y() + bounds.height()*0.1, bounds.width(), bounds.height()*0.9); // d->sub->setGeometry( bounds.x(), bounds.y(), bounds.width(), bounds.height()*0.1); // } // } // } if (d->view) { d->selector->setColor(Acs::currentColor(d->view->canvasResourceProvider(), d->colorRole)); } d->repaintTimer->start(); QQuickPaintedItem::geometryChanged(newGeometry, oldGeometry); } void ColorSelectorItem::mousePressEvent(QMouseEvent* event) { d->colorRole = d->changeBackground ? Acs::Background : Acs::buttonToRole(event->button()); if (d->main->wantsGrab(event->pos().x(), event->pos().y())) { d->grabbingComponent = d->main; } else if (d->sub->wantsGrab(event->pos().x(), event->pos().y())) { d->grabbingComponent = d->sub; } mouseEvent(event); } void ColorSelectorItem::mouseMoveEvent(QMouseEvent* event) { mouseEvent(event); } void ColorSelectorItem::mouseReleaseEvent(QMouseEvent* /*event*/) { d->grabbingComponent=0; } void ColorSelectorItem::mouseEvent(QMouseEvent* event) { if (d->grabbingComponent && (event->buttons()&Qt::LeftButton || event->buttons()&Qt::RightButton)) { d->grabbingComponent->mouseEvent(event->pos().x(), event->pos().y()); qreal alpha = d->currentColor.opacityF(); d->currentColor = d->main->currentColor(); d->currentColor.setOpacity(alpha); d->commitColor(d->currentColor, d->colorRole); d->repaintTimer->start(); } } QObject* ColorSelectorItem::view() const { return d->view; } void ColorSelectorItem::setView(QObject* newView) { d->view = qobject_cast( newView ); if (d->view) { + connect(d->view->mainWindow(), SIGNAL(themeChanged()), this, SLOT(repaint())); + connect(d->view->canvasResourceProvider(), SIGNAL(sigFGColorChanged(KoColor)), this, SLOT(fgColorChanged(KoColor))); connect(d->view->canvasResourceProvider(), SIGNAL(sigBGColorChanged(KoColor)), this, SLOT(bgColorChanged(KoColor))); d->commitColor(d->currentColor, d->colorRole); setChangeBackground(changeBackground()); } emit viewChanged(); } bool ColorSelectorItem::changeBackground() const { return d->changeBackground; } void ColorSelectorItem::setChangeBackground(bool newChangeBackground) { d->changeBackground = newChangeBackground; d->colorRole = newChangeBackground ? Acs::Background : Acs::Foreground; emit changeBackgroundChanged(); if (!d->view) return; d->currentColor = Acs::currentColor(d->view->canvasResourceProvider(), d->colorRole); d->main->setColor(d->currentColor); d->sub->setColor(d->currentColor); d->repaintTimer->start(); } bool ColorSelectorItem::shown() const { return d->shown; } void ColorSelectorItem::setShown(bool newShown) { d->shown = newShown; emit shownChanged(); } void ColorSelectorItem::setAlpha(int percentValue) { qreal alpha = (float)percentValue / 100.0; d->currentColor.setOpacity(alpha); if (d->view) { d->commitColor(d->currentColor, d->colorRole); } } void ColorSelectorItem::Private::colorChangedImpl(const KoColor &newColor, Acs::ColorRole role) { if (colorRole != role) return; if (colorUpdateAllowed == false) return; if(newColor == currentColor) return; currentColor = newColor; main->setColor(newColor); sub->setColor(newColor); commitColor(currentColor, colorRole); QColor qcolor = selector->converter()->toQColor(currentColor); emit q->colorChanged(qcolor, currentColor.opacityF(), false); repaintTimer->start(); } void ColorSelectorItem::fgColorChanged(const KoColor& newColor) { d->colorChangedImpl(newColor, Acs::Foreground); } void ColorSelectorItem::bgColorChanged(const KoColor& newColor) { d->colorChangedImpl(newColor, Acs::Background); } void ColorSelectorItem::repaint() { d->repaint(); } diff --git a/plugins/dockers/advancedcolorselector/kis_color_selector.cpp b/plugins/dockers/advancedcolorselector/kis_color_selector.cpp index 5180ad2a1e..a4c8e0a8ab 100644 --- a/plugins/dockers/advancedcolorselector/kis_color_selector.cpp +++ b/plugins/dockers/advancedcolorselector/kis_color_selector.cpp @@ -1,426 +1,430 @@ /* * Copyright (c) 2010 Adam Celarek * * 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 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 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 "kis_color_selector.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "kis_color_selector_ring.h" #include "kis_color_selector_triangle.h" #include "kis_color_selector_simple.h" #include "kis_color_selector_wheel.h" #include "kis_color_selector_container.h" #include "kis_canvas2.h" #include "kis_signal_compressor.h" #include "KisViewManager.h" KisColorSelector::KisColorSelector(KisColorSelectorConfiguration conf, QWidget* parent) : KisColorSelectorBase(parent), m_ring(0), m_triangle(0), m_slider(0), m_square(0), m_wheel(0), m_mainComponent(0), m_subComponent(0), m_grabbingComponent(0), m_blipDisplay(true) { init(); updateSettings(); setConfiguration(conf); } KisColorSelector::KisColorSelector(QWidget* parent) : KisColorSelectorBase(parent), m_ring(0), m_triangle(0), m_slider(0), m_square(0), m_wheel(0), m_button(0), m_mainComponent(0), m_subComponent(0), m_grabbingComponent(0), m_blipDisplay(true) { init(); updateSettings(); } KisColorSelectorBase* KisColorSelector::createPopup() const { KisColorSelectorBase* popup = new KisColorSelector(0); popup->setColor(m_lastRealColor); return popup; } void KisColorSelector::setConfiguration(KisColorSelectorConfiguration conf) { m_configuration = conf; if(m_mainComponent!=0) { Q_ASSERT(m_subComponent!=0); m_mainComponent->setGeometry(0, 0, 0, 0); m_subComponent->setGeometry(0, 0, 0, 0); m_mainComponent->disconnect(); m_subComponent->disconnect(); } switch (m_configuration.mainType) { case KisColorSelectorConfiguration::Square: m_mainComponent=m_square; break; case KisColorSelectorConfiguration::Wheel: m_mainComponent=m_wheel; break; case KisColorSelectorConfiguration::Triangle: m_mainComponent=m_triangle; break; default: Q_ASSERT(false); } switch (m_configuration.subType) { case KisColorSelectorConfiguration::Ring: m_subComponent=m_ring; break; case KisColorSelectorConfiguration::Slider: m_subComponent=m_slider; break; default: Q_ASSERT(false); } connect(m_mainComponent, SIGNAL(paramChanged(qreal,qreal,qreal,qreal,qreal,qreal,qreal,qreal,qreal)), m_subComponent, SLOT(setParam(qreal,qreal,qreal,qreal,qreal,qreal,qreal,qreal,qreal)), Qt::UniqueConnection); connect(m_subComponent, SIGNAL(paramChanged(qreal,qreal,qreal,qreal,qreal,qreal,qreal,qreal,qreal)), m_mainComponent, SLOT(setParam(qreal,qreal,qreal,qreal,qreal,qreal,qreal,qreal,qreal)), Qt::UniqueConnection); connect(m_mainComponent, SIGNAL(update()), m_signalCompressor, SLOT(start()), Qt::UniqueConnection); connect(m_subComponent, SIGNAL(update()), m_signalCompressor, SLOT(start()), Qt::UniqueConnection); m_mainComponent->setConfiguration(m_configuration.mainTypeParameter, m_configuration.mainType); m_subComponent->setConfiguration(m_configuration.subTypeParameter, m_configuration.subType); QResizeEvent event(QSize(width(), height()), QSize()); resizeEvent(&event); } KisColorSelectorConfiguration KisColorSelector::configuration() const { return m_configuration; } void KisColorSelector::updateSettings() { KisColorSelectorBase::updateSettings(); KConfigGroup cfg = KSharedConfig::openConfig()->group("advancedColorSelector"); setConfiguration(KisColorSelectorConfiguration::fromString(cfg.readEntry("colorSelectorConfiguration", KisColorSelectorConfiguration().toString()))); if (m_canvas && m_canvas->viewManager() && m_canvas->viewManager()->canvasResourceProvider()) { bool gamutMaskActive = m_canvas->viewManager()->canvasResourceProvider()->gamutMaskActive(); if (gamutMaskActive) { KoGamutMaskSP currentMask = m_canvas->viewManager()->canvasResourceProvider()->currentGamutMask(); if (currentMask) { slotGamutMaskSet(currentMask); } } else { slotGamutMaskToggle(false); } } } void KisColorSelector::slotGamutMaskSet(KoGamutMaskSP gamutMask) { m_mainComponent->setGamutMask(gamutMask); m_subComponent->setGamutMask(gamutMask); slotGamutMaskToggle(true); } void KisColorSelector::slotGamutMaskUnset() { m_mainComponent->unsetGamutMask(); m_subComponent->unsetGamutMask(); slotGamutMaskToggle(false); } void KisColorSelector::slotGamutMaskPreviewUpdate() { m_mainComponent->updateGamutMaskPreview(); m_subComponent->updateGamutMaskPreview(); } void KisColorSelector::slotGamutMaskDeactivate() { slotGamutMaskToggle(false); } void KisColorSelector::slotGamutMaskToggle(bool state) { m_mainComponent->toggleGamutMask(state); m_subComponent->toggleGamutMask(state); } void KisColorSelector::updateIcons() { if (m_button) { m_button->setIcon(KisIconUtils::loadIcon("configure")); } } void KisColorSelector::hasAtLeastOneDocument(bool value) { m_hasAtLeastOneDocumentOpen = value; } void KisColorSelector::reset() { if (m_mainComponent) { m_mainComponent->setDirty(); } if (m_subComponent) { m_subComponent->setDirty(); } KisColorSelectorBase::reset(); } void KisColorSelector::paintEvent(QPaintEvent* e) { Q_UNUSED(e); QPainter p(this); - KisConfig cfg(true); - KConfigGroup cfgSelector = KSharedConfig::openConfig()->group("advancedColorSelector"); - - bool usesBackgroundColor = cfgSelector.readEntry("useBackgroundColorForSelector", true); + KConfigGroup cfg = KSharedConfig::openConfig()->group("advancedColorSelector"); - if (usesBackgroundColor) { - QColor background = cfg.readEntry("colorEditorBackground", qApp->palette().window().color()); - p.fillRect(0,0,width(), height(), background); + if (cfg.readEntry("useBackgroundColorForSelector", true)) { + //p.fillRect(0,0,width(), height(), cfg.readEntry("colorEditorBackground", qApp->palette().window().color())); + p.fillRect(0,0,width(), height(), QColor(128,128,128)); } else { p.fillRect(0,0,width(), height(), QColor(128,128,128)); } p.setRenderHint(QPainter::Antialiasing); // this variable name isn't entirely accurate to what always happens. see definition in header file to understand it better if (!m_hasAtLeastOneDocumentOpen) { p.setOpacity(0.2); } m_mainComponent->paintEvent(&p); m_subComponent->paintEvent(&p); p.setOpacity(1.0); } inline int iconSize(qreal width, qreal height) { qreal radius = qMin(width, height)/2.; qreal xm = width/2.; qreal ym = height/2.; if(xm>=2*ym || ym>=2*xm) return qBound(5., radius, 32.); qreal a=-2; qreal b=2.*(xm+ym); qreal c=radius*radius-xm*xm-ym*ym; return qBound(5., ((-b+sqrt(b*b-4*a*c))/(2*a)), 32.); } void KisColorSelector::resizeEvent(QResizeEvent* e) { if (m_configuration.subType == KisColorSelectorConfiguration::Ring) { m_ring->setGeometry(0,0,width(), height()); if (displaySettingsButton()) { int size = iconSize(width(), height()); m_button->setGeometry(0, 0, size, size); } if (m_configuration.mainType == KisColorSelectorConfiguration::Triangle) { m_triangle->setGeometry(width()/2-m_ring->innerRadius(), height()/2-m_ring->innerRadius(), m_ring->innerRadius()*2, m_ring->innerRadius()*2); } else { int size = m_ring->innerRadius()*2/sqrt(2.); m_square->setGeometry(width()/2-size/2, height()/2-size/2, size, size); } } else { // type wheel and square if (m_configuration.mainType == KisColorSelectorConfiguration::Wheel) { if(displaySettingsButton()) { int size = iconSize(width(), height()*0.9); m_button->setGeometry(0, height()*0.1, size, size); } m_mainComponent->setGeometry(0, height()*0.1, width(), height()*0.9); m_subComponent->setGeometry( 0, 0, width(), height()*0.1); } else { int buttonSize = 0; if(displaySettingsButton()) { buttonSize = qBound(20, int(0.1*height()), 32); m_button->setGeometry(0, 0, buttonSize, buttonSize); } if(height()>width()) { int selectorHeight=height()-buttonSize; m_mainComponent->setGeometry(0, buttonSize+selectorHeight*0.1, width(), selectorHeight*0.9); m_subComponent->setGeometry( 0, buttonSize, width(), selectorHeight*0.1); } else { int selectorWidth=width()-buttonSize; m_mainComponent->setGeometry(buttonSize, height()*0.1, selectorWidth, height()*0.9); m_subComponent->setGeometry( buttonSize, 0, selectorWidth, height()*0.1); } } } // reset the correct color after resizing the widget setColor(m_lastRealColor); KisColorSelectorBase::resizeEvent(e); } +/* +void KisColorSelector::setViewManager(KisViewManager *kisview) +{ + connect(kisview->mainWindow(), SIGNAL(themeChanged()), this, SLOT(slotUpdateIcons())); + slotUpdateIcons(); +} */ + void KisColorSelector::mousePressEvent(QMouseEvent* e) { e->setAccepted(false); KisColorSelectorBase::mousePressEvent(e); if(!e->isAccepted()) { if(m_mainComponent->wantsGrab(e->x(), e->y())) m_grabbingComponent=m_mainComponent; else if(m_subComponent->wantsGrab(e->x(), e->y())) m_grabbingComponent=m_subComponent; mouseEvent(e); updatePreviousColorPreview(); e->accept(); } } void KisColorSelector::mouseMoveEvent(QMouseEvent* e) { KisColorSelectorBase::mouseMoveEvent(e); mouseEvent(e); e->accept(); } void KisColorSelector::mouseReleaseEvent(QMouseEvent* e) { e->setAccepted(false); KisColorSelectorBase::mouseReleaseEvent(e); if(!e->isAccepted() && !(m_lastRealColor == m_currentRealColor)) { m_lastRealColor = m_currentRealColor; m_lastColorRole = Acs::buttonToRole(e->button()); updateColor(m_lastRealColor, m_lastColorRole, false); updateBaseColorPreview(m_currentRealColor); e->accept(); } m_grabbingComponent=0; } bool KisColorSelector::displaySettingsButton() { return dynamic_cast(parent()); } void KisColorSelector::setColor(const KoColor &color) { m_mainComponent->setColor(color); m_subComponent->setColor(color); m_lastRealColor = color; m_signalCompressor->start(); } void KisColorSelector::mouseEvent(QMouseEvent *e) { if (m_grabbingComponent && (e->buttons() & Qt::LeftButton || e->buttons() & Qt::RightButton)) { m_grabbingComponent->mouseEvent(e->x(), e->y()); KoColor color = m_mainComponent->currentColor(); Acs::ColorRole role = Acs::buttonsToRole(e->button(), e->buttons()); m_currentRealColor = color; requestUpdateColorAndPreview(color, role); } } void KisColorSelector::init() { setAcceptDrops(true); m_lastColorRole = Acs::Foreground; m_ring = new KisColorSelectorRing(this); m_triangle = new KisColorSelectorTriangle(this); m_slider = new KisColorSelectorSimple(this); m_square = new KisColorSelectorSimple(this); m_wheel = new KisColorSelectorWheel(this); if(displaySettingsButton()) { m_button = new QPushButton(this); m_button->setIcon(KisIconUtils::loadIcon("configure")); m_button->setFlat(true); connect(m_button, SIGNAL(clicked()), SIGNAL(settingsButtonClicked())); } // a tablet can send many more signals, than a mouse // this causes many repaints, if updating after every signal. m_signalCompressor = new KisSignalCompressor(20, KisSignalCompressor::FIRST_INACTIVE, this); connect(m_signalCompressor, SIGNAL(timeout()), SLOT(update())); setMinimumSize(40, 40); } diff --git a/plugins/dockers/advancedcolorselector/kis_color_selector.h b/plugins/dockers/advancedcolorselector/kis_color_selector.h index e0533b4d5a..d7d7e7809f 100644 --- a/plugins/dockers/advancedcolorselector/kis_color_selector.h +++ b/plugins/dockers/advancedcolorselector/kis_color_selector.h @@ -1,107 +1,109 @@ /* * Copyright (c) 2010 Adam Celarek * * 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 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 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 KIS_COLOR_SELECTOR_H #define KIS_COLOR_SELECTOR_H #include "kis_color_selector_base.h" #include #include class KisColorSelectorRing; class KisColorSelectorComponent; class KisColorSelectorSimple; class KisColorSelectorWheel; class QPushButton; +//class KisViewManager; class KisSignalCompressor; class KisColorSelector : public KisColorSelectorBase { Q_OBJECT public: KisColorSelector(KisColorSelectorConfiguration conf, QWidget* parent = 0); KisColorSelector(QWidget* parent=0); KisColorSelectorBase* createPopup() const override; void setConfiguration(KisColorSelectorConfiguration conf); KisColorSelectorConfiguration configuration() const; void setColor(const KoColor &color) override; + //void setViewManager(KisViewManager *kisview) override; /// update icons when a theme update happens void updateIcons(); void hasAtLeastOneDocument(bool value); public Q_SLOTS: void reset() override; void updateSettings() override; void slotGamutMaskSet(KoGamutMaskSP gamutMask); void slotGamutMaskUnset(); void slotGamutMaskPreviewUpdate(); void slotGamutMaskToggle(bool state); void slotGamutMaskDeactivate(); Q_SIGNALS: void settingsButtonClicked(); protected: void paintEvent(QPaintEvent*) override; void resizeEvent(QResizeEvent*) override; void mousePressEvent(QMouseEvent*) override; void mouseMoveEvent(QMouseEvent*) override; void mouseReleaseEvent(QMouseEvent*) override; bool displaySettingsButton(); private: void mouseEvent(QMouseEvent* e); void init(); KisColorSelectorRing* m_ring; KisColorSelectorComponent* m_triangle; KisColorSelectorSimple* m_slider; KisColorSelectorSimple* m_square; KisColorSelectorWheel* m_wheel; QPushButton* m_button; KisColorSelectorComponent* m_mainComponent; KisColorSelectorComponent* m_subComponent; KisColorSelectorComponent* m_grabbingComponent; KisSignalCompressor *m_signalCompressor; KisColorSelectorConfiguration m_configuration; KoColor m_lastRealColor; KoColor m_currentRealColor; bool m_blipDisplay; Acs::ColorRole m_lastColorRole; /// if Krita starts with a reference to this component that is attached to a canvas, it will call setCanvas() /// that check will be what ultimately decides whether this component will look enabled or disabled /// This color selector is sometimes not attached to the canvas, so we shouldn't disable it in that situation /// One instance of that is when you select the color wheel type from the settings. bool m_hasAtLeastOneDocumentOpen = true; public: void setDisplayBlip(bool disp) {m_blipDisplay = disp;} bool displayBlip() const {return m_blipDisplay;} }; #endif // KIS_COLSELNG_COLOR_SELECTOR_H diff --git a/plugins/dockers/advancedcolorselector/kis_color_selector_container.cpp b/plugins/dockers/advancedcolorselector/kis_color_selector_container.cpp index e44952784e..37bd0cc892 100644 --- a/plugins/dockers/advancedcolorselector/kis_color_selector_container.cpp +++ b/plugins/dockers/advancedcolorselector/kis_color_selector_container.cpp @@ -1,229 +1,238 @@ /* * Copyright (c) 2010 Adam Celarek * * 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 */ #include "kis_color_selector_container.h" #include "kis_color_selector.h" #include "kis_my_paint_shade_selector.h" #include "kis_minimal_shade_selector.h" #include #include #include #include #include #include #include #include #include #include #include "KisViewManager.h" #include "kis_canvas2.h" #include "kis_canvas_resource_provider.h" #include "kis_node_manager.h" #include "kis_node.h" #include "kis_paint_device.h" #include "kis_action_registry.h" KisColorSelectorContainer::KisColorSelectorContainer(QWidget *parent) : QWidget(parent), m_colorSelector(new KisColorSelector(this)), m_myPaintShadeSelector(new KisMyPaintShadeSelector(this)), m_minimalShadeSelector(new KisMinimalShadeSelector(this)), m_shadeSelector(m_myPaintShadeSelector), m_gamutMaskToolbar(new KisGamutMaskToolbar(this)), m_showColorSelector(true), m_canvas(0) { m_widgetLayout = new QBoxLayout(QBoxLayout::TopToBottom, this); m_widgetLayout->setSpacing(0); m_widgetLayout->setMargin(0); m_gamutMaskToolbar->setContentsMargins(0, 0, 0, 5); m_gamutMaskToolbar->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum); m_colorSelector->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); m_myPaintShadeSelector->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); m_minimalShadeSelector->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); m_widgetLayout->addWidget(m_gamutMaskToolbar); m_widgetLayout->addWidget(m_colorSelector); m_widgetLayout->addWidget(m_myPaintShadeSelector); m_widgetLayout->addWidget(m_minimalShadeSelector); m_gamutMaskToolbar->hide(); m_myPaintShadeSelector->hide(); m_minimalShadeSelector->hide(); connect(m_colorSelector,SIGNAL(settingsButtonClicked()), SIGNAL(openSettings())); + connect(m_canvas->viewManager()->mainWindow(), SIGNAL(themeChanged()), m_colorSelector, SLOT(updateSettings())); + connect(m_canvas->viewManager()->mainWindow(), SIGNAL(signalThemeChanged()), m_colorSelector, SLOT(updateSettings())); + connect(m_canvas->viewManager()->mainWindow(), SIGNAL(themeChanged()), m_myPaintShadeSelector, SLOT(updateSettings())); + connect(m_canvas->viewManager()->mainWindow(), SIGNAL(signalThemeChanged()), m_myPaintShadeSelector, SLOT(updateSettings())); + connect(m_canvas->viewManager()->mainWindow(), SIGNAL(themeChanged()), this, SLOT(updateSettings())); + connect(m_canvas->viewManager()->mainWindow(), SIGNAL(signalThemeChanged()), this, SLOT(updateSettings())); + connect(m_canvas->viewManager()->mainWindow(), SIGNAL(themeChanged()), m_minimalShadeSelector, SLOT(updateSettings())); + connect(m_canvas->viewManager()->mainWindow(), SIGNAL(signalThemeChanged()), m_minimalShadeSelector, SLOT(updateSettings())); connect(this, SIGNAL(settingsChanged()), m_colorSelector, SLOT(updateSettings())); connect(this, SIGNAL(settingsChanged()), m_myPaintShadeSelector, SLOT(updateSettings())); connect(this, SIGNAL(settingsChanged()), this, SLOT(updateSettings())); connect(this, SIGNAL(settingsChanged()), m_minimalShadeSelector, SLOT(updateSettings())); m_colorSelAction = KisActionRegistry::instance()->makeQAction("show_color_selector", this); connect(m_colorSelAction, SIGNAL(triggered()), m_colorSelector, SLOT(showPopup()), Qt::UniqueConnection); m_mypaintAction = KisActionRegistry::instance()->makeQAction("show_mypaint_shade_selector", this); connect(m_mypaintAction, SIGNAL(triggered()), m_myPaintShadeSelector, SLOT(showPopup()), Qt::UniqueConnection); m_minimalAction = KisActionRegistry::instance()->makeQAction("show_minimal_shade_selector", this); connect(m_minimalAction, SIGNAL(triggered()), m_minimalShadeSelector, SLOT(showPopup()), Qt::UniqueConnection); } void KisColorSelectorContainer::unsetCanvas() { m_colorSelector->hasAtLeastOneDocument(doesAtleastOneDocumentExist()); m_colorSelector->unsetCanvas(); m_myPaintShadeSelector->unsetCanvas(); m_minimalShadeSelector->unsetCanvas(); m_canvas = 0; } bool KisColorSelectorContainer::doesAtleastOneDocumentExist() { if (m_canvas && m_canvas->viewManager() && m_canvas->viewManager()->document() ) { if (m_canvas->viewManager()->document()->image()->height() == 0) { return false; } else { return true; } } else { return false; } } void KisColorSelectorContainer::slotUpdateIcons() { m_colorSelector->updateIcons(); } void KisColorSelectorContainer::setCanvas(KisCanvas2* canvas) { if (m_canvas) { m_canvas->disconnectCanvasObserver(this); m_canvas->viewManager()->nodeManager()->disconnect(this); KActionCollection *ac = m_canvas->viewManager()->actionCollection(); ac->takeAction(ac->action("show_color_selector")); ac->takeAction(ac->action("show_mypaint_shade_selector")); ac->takeAction(ac->action("show_minimal_shade_selector")); } m_canvas = canvas; m_colorSelector->setCanvas(canvas); m_myPaintShadeSelector->setCanvas(canvas); m_minimalShadeSelector->setCanvas(canvas); m_colorSelector->hasAtLeastOneDocument(doesAtleastOneDocumentExist()); if (m_canvas && m_canvas->viewManager()) { connect(m_canvas->viewManager()->canvasResourceProvider(), SIGNAL(sigGamutMaskChanged(KoGamutMaskSP)), m_colorSelector, SLOT(slotGamutMaskSet(KoGamutMaskSP)), Qt::UniqueConnection); connect(m_canvas->viewManager()->canvasResourceProvider(), SIGNAL(sigGamutMaskUnset()), m_colorSelector, SLOT(slotGamutMaskUnset()), Qt::UniqueConnection); connect(m_canvas->viewManager()->canvasResourceProvider(), SIGNAL(sigGamutMaskPreviewUpdate()), m_colorSelector, SLOT(slotGamutMaskPreviewUpdate()), Qt::UniqueConnection); connect(m_canvas->viewManager()->canvasResourceProvider(), SIGNAL(sigGamutMaskDeactivated()), m_colorSelector, SLOT(slotGamutMaskDeactivate()), Qt::UniqueConnection); m_gamutMaskToolbar->connectMaskSignals(m_canvas->viewManager()->canvasResourceProvider()); KActionCollection* actionCollection = canvas->viewManager()->actionCollection(); actionCollection->addAction("show_color_selector", m_colorSelAction); actionCollection->addAction("show_mypaint_shade_selector", m_mypaintAction); actionCollection->addAction("show_minimal_shade_selector", m_minimalAction); } } void KisColorSelectorContainer::updateSettings() { + fprintf( stderr, "MERDA"); KConfigGroup cfg = KSharedConfig::openConfig()->group("advancedColorSelector"); m_onDockerResizeSetting = (int)cfg.readEntry("onDockerResize", 0); m_showColorSelector = (bool) cfg.readEntry("showColorSelector", true); if (m_showColorSelector) { m_colorSelector->show(); if (m_colorSelector->configuration().mainType == KisColorSelectorConfiguration::Wheel) { m_gamutMaskToolbar->show(); } else { m_gamutMaskToolbar->hide(); } } else { m_colorSelector->hide(); m_gamutMaskToolbar->hide(); } QString type = cfg.readEntry("shadeSelectorType", "Minimal"); QWidget* newShadeSelector; if(type=="MyPaint") newShadeSelector = m_myPaintShadeSelector; else if (type=="Minimal") newShadeSelector = m_minimalShadeSelector; else newShadeSelector = 0; if(m_shadeSelector!=newShadeSelector && m_shadeSelector!=0) { m_shadeSelector->hide(); } m_shadeSelector=newShadeSelector; if(m_shadeSelector!=0) m_shadeSelector->show(); } void KisColorSelectorContainer::resizeEvent(QResizeEvent * e) { if(m_shadeSelector!=0) { int minimumHeightForBothWidgets = m_colorSelector->minimumHeight()+m_shadeSelector->minimumHeight()+30; //+30 for the buttons (temporarily) if(height()hide(); } else { m_shadeSelector->show(); } // m_onDockerResizeSetting==0 is allow horizontal layout if(height() < width() && m_onDockerResizeSetting==0 && m_shadeSelector!=m_minimalShadeSelector) { m_widgetLayout->setDirection(QBoxLayout::LeftToRight); } else { m_widgetLayout->setDirection(QBoxLayout::TopToBottom); } } QWidget::resizeEvent(e); } diff --git a/plugins/dockers/advancedcolorselector/kis_minimal_shade_selector.cpp b/plugins/dockers/advancedcolorselector/kis_minimal_shade_selector.cpp index b33c736e6a..c568e00b02 100644 --- a/plugins/dockers/advancedcolorselector/kis_minimal_shade_selector.cpp +++ b/plugins/dockers/advancedcolorselector/kis_minimal_shade_selector.cpp @@ -1,183 +1,191 @@ /* * Copyright (c) 2010 Adam Celarek * * 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 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 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 "kis_minimal_shade_selector.h" #include #include #include #include +#include #include #include #include #include "KoCanvasResourceProvider.h" #include "kis_shade_selector_line.h" #include "kis_color_selector_base_proxy.h" KisMinimalShadeSelector::KisMinimalShadeSelector(QWidget *parent) : KisColorSelectorBase(parent) , m_canvas(0) , m_proxy(new KisColorSelectorBaseProxyObject(this)) { setAcceptDrops(true); QVBoxLayout* l = new QVBoxLayout(this); l->setSpacing(0); l->setMargin(0); updateSettings(); setMouseTracking(true); } KisMinimalShadeSelector::~KisMinimalShadeSelector() { } void KisMinimalShadeSelector::unsetCanvas() { KisColorSelectorBase::unsetCanvas(); m_canvas = 0; } void KisMinimalShadeSelector::setCanvas(KisCanvas2 *canvas) { KisColorSelectorBase::setCanvas(canvas); m_canvas = canvas; } void KisMinimalShadeSelector::setColor(const KoColor& color) { m_lastRealColor = color; for(int i=0; isetColor(color); } } void KisMinimalShadeSelector::updateSettings() { KisColorSelectorBase::updateSettings(); KConfigGroup cfg = KSharedConfig::openConfig()->group("advancedColorSelector"); QString stri = cfg.readEntry("minimalShadeSelectorLineConfig", "0|0.2|0|0"); QStringList strili = stri.split(';', QString::SkipEmptyParts); int lineCount = strili.size(); while(lineCount-m_shadingLines.size() > 0) { KisShadeSelectorLine *line = new KisShadeSelectorLine(m_proxy.data(), this); m_shadingLines.append(line); m_shadingLines.last()->setLineNumber(m_shadingLines.size()-1); layout()->addWidget(m_shadingLines.last()); } while(lineCount-m_shadingLines.size() < 0) { layout()->removeWidget(m_shadingLines.last()); delete m_shadingLines.takeLast(); } for(int i=0; ifromString(strili.at(i)); } int lineHeight = cfg.readEntry("minimalShadeSelectorLineHeight", 20); setMinimumHeight(lineCount*lineHeight+2*lineCount); setMaximumHeight(lineCount*lineHeight+2*lineCount); for(int i=0; iupdateSettings(); setPopupBehaviour(false, false); } void KisMinimalShadeSelector::mousePressEvent(QMouseEvent * e) { Q_FOREACH (KisShadeSelectorLine* line, m_shadingLines) { QMouseEvent newEvent(e->type(), line->mapFromGlobal(e->globalPos()), e->button(), e->buttons(), e->modifiers()); if(line->rect().contains(newEvent.pos())) line->mousePressEvent(&newEvent); } KisColorSelectorBase::mousePressEvent(e); } void KisMinimalShadeSelector::mouseMoveEvent(QMouseEvent * e) { Q_FOREACH (KisShadeSelectorLine* line, m_shadingLines) { QMouseEvent newEvent(e->type(), line->mapFromGlobal(e->globalPos()), e->button(), e->buttons(), e->modifiers()); if(line->rect().contains(newEvent.pos())) line->mouseMoveEvent(&newEvent); } KisColorSelectorBase::mouseMoveEvent(e); } void KisMinimalShadeSelector::mouseReleaseEvent(QMouseEvent * e) { Q_FOREACH (KisShadeSelectorLine* line, m_shadingLines) { QMouseEvent newEvent(e->type(), line->mapFromGlobal(e->globalPos()), e->button(), e->buttons(), e->modifiers()); if(line->rect().contains(newEvent.pos())) line->mouseReleaseEvent(&newEvent); } KisColorSelectorBase::mouseReleaseEvent(e); } void KisMinimalShadeSelector::canvasResourceChanged(int key, const QVariant &v) { if(m_colorUpdateAllowed==false) return; KConfigGroup cfg = KSharedConfig::openConfig()->group("advancedColorSelector"); bool onForeground = cfg.readEntry("shadeSelectorUpdateOnForeground", false); bool onBackground = cfg.readEntry("shadeSelectorUpdateOnBackground", true); if ((key == KoCanvasResourceProvider::ForegroundColor && onForeground) || (key == KoCanvasResourceProvider::BackgroundColor && onBackground)) { setColor(v.value()); } } void KisMinimalShadeSelector::paintEvent(QPaintEvent *) { - QPainter painter(this); - painter.fillRect(0,0,width(), height(), QColor(128,128,128)); + QPainter p(this); + KConfigGroup cfg = KSharedConfig::openConfig()->group("advancedColorSelector"); + + if (cfg.readEntry("useBackgroundColorForSelector", true)) { + //p.fillRect(0,0,width(), height(), cfg.readEntry("colorEditorBackground", qApp->palette().window().color())); + p.fillRect(0,0,width(), height(), QColor(128,128,128)); + } else { + p.fillRect(0,0,width(), height(), QColor(128,128,128)); + } } KisColorSelectorBase* KisMinimalShadeSelector::createPopup() const { KisMinimalShadeSelector* popup = new KisMinimalShadeSelector(0); popup->setColor(m_lastRealColor); return popup; } diff --git a/plugins/dockers/advancedcolorselector/kis_shade_selector_line_combo_box_popup.cpp b/plugins/dockers/advancedcolorselector/kis_shade_selector_line_combo_box_popup.cpp index 5920fef600..aa8ca4d733 100644 --- a/plugins/dockers/advancedcolorselector/kis_shade_selector_line_combo_box_popup.cpp +++ b/plugins/dockers/advancedcolorselector/kis_shade_selector_line_combo_box_popup.cpp @@ -1,171 +1,183 @@ /* * Copyright (c) 2010 Adam Celarek * Copyright (c) 2013 Dmitry Kazakov * * 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_shade_selector_line_combo_box.h" #include "kis_shade_selector_line_combo_box_popup.h" #include #include #include +#include +#include +#include +#include #include "kis_global.h" #include "kis_shade_selector_line.h" #include "kis_shade_selector_line_editor.h" #include "kis_color_selector_base_proxy.h" KisShadeSelectorLineComboBoxPopup::KisShadeSelectorLineComboBoxPopup(QWidget* parent) : QWidget(parent, Qt::Popup), spacing(10), m_lastHighlightedItem(0), m_lastSelectedItem(0), m_lineEditor(0), m_parentProxy(new KisColorSelectorBaseProxyNoop()) { setMouseTracking(true); QVBoxLayout* layout = new QVBoxLayout(this); layout->setSpacing(spacing); layout->addWidget(new KisShadeSelectorLine(1.0, 0.0, 0.0, m_parentProxy.data(), this)); layout->addWidget(new KisShadeSelectorLine(0.1, 0.0, 0.0, m_parentProxy.data(), this)); layout->addWidget(new KisShadeSelectorLine(0.2, 0.0, 0.0, m_parentProxy.data(), this)); layout->addWidget(new KisShadeSelectorLine(0.0, 0.5, 0.0, m_parentProxy.data(), this)); layout->addWidget(new KisShadeSelectorLine(0.0, 1.0, 0.0, m_parentProxy.data(), this)); layout->addWidget(new KisShadeSelectorLine(0.0, 0.0, 0.5, m_parentProxy.data(), this)); layout->addWidget(new KisShadeSelectorLine(0.0, 0.0, 1.0, m_parentProxy.data(), this)); layout->addWidget(new KisShadeSelectorLine(0.0, 0.5, 0.5, m_parentProxy.data(), this)); layout->addWidget(new KisShadeSelectorLine(0.0, 1.0, 1.0, m_parentProxy.data(), this)); layout->addWidget(new KisShadeSelectorLine(0.0, -0.5, 0.5, m_parentProxy.data(), this)); layout->addWidget(new KisShadeSelectorLine(0.0, -1.0, 1.0, m_parentProxy.data(), this)); layout->addWidget(new KisShadeSelectorLine(0.0, 0.5, 0.5, m_parentProxy.data(), this, -0.04)); layout->addWidget(new KisShadeSelectorLine(0.0, 0.5, 0.5, m_parentProxy.data(), this, +0.04)); layout->addWidget(new KisShadeSelectorLine(0.0, -0.5, 0.5, m_parentProxy.data(), this, -0.04)); KisShadeSelectorLine* preview = new KisShadeSelectorLine(0.0, -0.5, 0.5, m_parentProxy.data(), this, +0.04); m_lineEditor = new KisShadeSelectorLineEditor(this, preview); layout->addWidget(preview); layout->addWidget(m_lineEditor); connect(m_lineEditor, SIGNAL(requestActivateLine(QWidget*)), SLOT(activateItem(QWidget*))); for(int i=0; ilayout()->count(); i++) { KisShadeSelectorLine* item = dynamic_cast(this->layout()->itemAt(i)->widget()); if(item!=0) { item->setMouseTracking(true); item->setEnabled(false); KoColor color; color.fromQColor(QColor(190, 50, 50)); item->setColor(color); item->showHelpText(); } } } KisShadeSelectorLineComboBoxPopup::~KisShadeSelectorLineComboBoxPopup() { } void KisShadeSelectorLineComboBoxPopup::setConfiguration(const QString &string) { m_lineEditor->fromString(string); } void KisShadeSelectorLineComboBoxPopup::updateSelectedArea(const QRect &newRect) { QRect oldSelectedArea = m_selectedArea; m_selectedArea = newRect; update(oldSelectedArea); update(m_selectedArea); } void KisShadeSelectorLineComboBoxPopup::updateHighlightedArea(const QRect &newRect) { QRect oldHighlightArea = m_highlightedArea; m_highlightedArea = newRect; update(oldHighlightArea); update(m_highlightedArea); } void KisShadeSelectorLineComboBoxPopup::activateItem(QWidget *widget) { KisShadeSelectorLineBase* item = dynamic_cast(widget); KIS_ASSERT_RECOVER_RETURN(item); QRect itemRect = kisGrowRect(item->geometry(), spacing / 2 - 1); m_lastSelectedItem = item; updateSelectedArea(itemRect); } void KisShadeSelectorLineComboBoxPopup::paintEvent(QPaintEvent *) { QPainter painter(this); - painter.fillRect(0,0,width(), height(), QColor(128,128,128)); + QPainter p(this); + KConfigGroup cfg = KSharedConfig::openConfig()->group("advancedColorSelector"); + + if (cfg.readEntry("useBackgroundColorForSelector", true)) { + //p.fillRect(0,0,width(), height(), cfg.readEntry("colorEditorBackground", qApp->palette().window().color())); + p.fillRect(0,0,width(), height(), QColor(128,128,128)); + } else { + p.fillRect(0,0,width(), height(), QColor(128,128,128)); + } painter.fillRect(m_selectedArea, palette().highlight()); painter.setPen(QPen(palette().highlight(), 2)); painter.drawRect(m_highlightedArea); } void KisShadeSelectorLineComboBoxPopup::mouseMoveEvent(QMouseEvent * e) { if(rect().contains(e->pos())) { for(int i = 0; i < layout()->count(); i++) { KisShadeSelectorLineBase* item = dynamic_cast(layout()->itemAt(i)->widget()); KIS_ASSERT_RECOVER_RETURN(item); QRect itemRect = kisGrowRect(item->geometry(), spacing / 2 - 1); if(itemRect.contains(e->pos())) { m_lastHighlightedItem = item; updateHighlightedArea(itemRect); } } } else { updateHighlightedArea(QRect()); } } void KisShadeSelectorLineComboBoxPopup::mousePressEvent(QMouseEvent* e) { if(rect().contains(e->pos())) { mouseMoveEvent(e); m_lastSelectedItem = m_lastHighlightedItem; if (m_lastSelectedItem != m_lineEditor) { m_lineEditor->blockSignals(true); m_lineEditor->fromString(m_lastSelectedItem->toString()); m_lineEditor->blockSignals(false); } updateSelectedArea(m_highlightedArea); } if (m_lastSelectedItem) { KisShadeSelectorLineComboBox *parent = dynamic_cast(this->parent()); Q_ASSERT(parent); parent->setConfiguration(m_lastSelectedItem->toString()); } e->accept(); this->parentWidget()->update(); hide(); } diff --git a/sip-patch b/sip-patch new file mode 100644 index 0000000000..5d88a3b623 --- /dev/null +++ b/sip-patch @@ -0,0 +1,22 @@ +diff --git a/cmake/modules/FindPyQt5.py b/cmake/modules/FindPyQt5.py +index 5849f40868..a42ba6c624 100644 +--- a/cmake/modules/FindPyQt5.py ++++ b/cmake/modules/FindPyQt5.py +@@ -2,7 +2,7 @@ + # Redistribution and use is allowed according to the terms of the BSD license. + # For details see the accompanying COPYING-CMAKE-SCRIPTS file. + +-import sys ++import sys, site + import os + + try: +@@ -41,7 +41,7 @@ except ValueError: + pass + + # FIXME This next line is just a little bit too crude. +-pyqt_sip_dir = os.path.join(sys.prefix, "share", "sip", "PyQt5") ++pyqt_sip_dir = os.path.join(site.getsitepackages()[0], "PyQt5", "bindings") + print("pyqt_sip_dir:%s" % pyqt_sip_dir) + + print("pyqt_sip_flags:%s" % PyQt5.QtCore.PYQT_CONFIGURATION["sip_flags"])