Skip to content

armgit / krita

Public Imported from GitHub
0

Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.

C++

Fix Visual Color Selector to behave correctly with display scaling on

Dmitry Kazakov1ebe20ba6f52
diff --git a/libs/widgets/KisVisualColorSelector.cpp b/libs/widgets/KisVisualColorSelector.cpp
index cdbe5f07e1..71231ae6cc 100644
--- a/libs/widgets/KisVisualColorSelector.cpp
+++ b/libs/widgets/KisVisualColorSelector.cpp
@@ -19,6 +19,8 @@
#include "kis_signal_compressor.h"
#include "kis_debug.h"
+#include <KisScreenMigrationTracker.h>
+
#include "KisVisualColorSelectorShape.h"
#include "KisVisualDiamondSelectorShape.h"
#include "KisVisualRectangleSelectorShape.h"
@@ -45,6 +47,7 @@ struct KisVisualColorSelector::Private
KisVisualColorModelSP selectorModel;
QPointer<const KoColorDisplayRendererInterface> displayRenderer;
KoGamutMaskSP gamutMask;
+ QPointer<KisScreenMigrationTracker> screenMigrationTracker;
};
KisVisualColorSelector::KisVisualColorSelector(QWidget *parent, KisVisualColorModelSP model)
@@ -64,6 +67,15 @@ KisVisualColorSelector::KisVisualColorSelector(QWidget *parent, KisVisualColorMo
m_d->updateTimer = new KisSignalCompressor(100 /* ms */, KisSignalCompressor::POSTPONE);
connect(m_d->updateTimer, SIGNAL(timeout()), SLOT(slotReloadConfiguration()), Qt::UniqueConnection);
+
+ m_d->screenMigrationTracker = new KisScreenMigrationTracker(this, this);
+ connect(m_d->screenMigrationTracker, &KisScreenMigrationTracker::sigScreenOrResolutionChanged,
+ this, [this] (QScreen *screen) {
+ Q_UNUSED(screen);
+ Q_FOREACH(KisVisualColorSelectorShape *shape, m_d->widgetlist) {
+ shape->notifyDevicePixelRationChanged();
+ }
+ });
}
KisVisualColorSelector::~KisVisualColorSelector()
diff --git a/libs/widgets/KisVisualColorSelectorShape.cpp b/libs/widgets/KisVisualColorSelectorShape.cpp
index 899b04df48..733b388556 100644
--- a/libs/widgets/KisVisualColorSelectorShape.cpp
+++ b/libs/widgets/KisVisualColorSelectorShape.cpp
@@ -375,6 +375,12 @@ void KisVisualColorSelectorShape::paintEvent(QPaintEvent*)
}
void KisVisualColorSelectorShape::resizeEvent(QResizeEvent *)
+{
+ // just reuse the content of notifyDevicePixelRationChanged()
+ notifyDevicePixelRationChanged();
+}
+
+void KisVisualColorSelectorShape::notifyDevicePixelRationChanged()
{
forceImageUpdate();
updateGamutMask();
diff --git a/libs/widgets/KisVisualColorSelectorShape.h b/libs/widgets/KisVisualColorSelectorShape.h
index f32f87d3d6..a45b8b39a6 100644
--- a/libs/widgets/KisVisualColorSelectorShape.h
+++ b/libs/widgets/KisVisualColorSelectorShape.h
@@ -137,6 +137,12 @@ public:
void setAcceptTabletEvents(bool on);
+ /**
+ * This signal is delivered in a centralized way by
+ * KisVisualColorSelector
+ */
+ void notifyDevicePixelRationChanged();
+
Q_SIGNALS:
void sigCursorMoved(QPointF pos);