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++

Update monitor profile of the scratch pad on settings change

Dmitry Kazakovdf95b4cec367
diff --git a/libs/ui/widgets/kis_scratch_pad.cpp b/libs/ui/widgets/kis_scratch_pad.cpp
index d9c6d7e6a7..ca41a190d3 100644
--- a/libs/ui/widgets/kis_scratch_pad.cpp
+++ b/libs/ui/widgets/kis_scratch_pad.cpp
@@ -45,6 +45,7 @@
#include <KisAdaptedLock.h>
#include <kis_async_action_feedback.h>
#include <KisScreenMigrationTracker.h>
+#include <kis_config_notifier.h>
namespace {
class KisUpdateSchedulerLockAdapter
@@ -198,6 +199,9 @@ KisScratchPad::KisScratchPad(QWidget *parent)
connect(m_screenMigrationTracker.data(), &KisScreenMigrationTracker::sigScreenChanged,
this, &KisScratchPad::slotScreenChanged);
slotScreenChanged(m_screenMigrationTracker->currentScreenSafe());
+
+ connect(KisConfigNotifier::instance(), &KisConfigNotifier::configChanged,
+ this, &KisScratchPad::slotConfigChanged);
}
KisScratchPad::~KisScratchPad()
@@ -674,6 +678,19 @@ void KisScratchPad::slotUpdateCanvas(const QRect &rect)
update(rect);
}
+void KisScratchPad::slotConfigChanged()
+{
+ KIS_SAFE_ASSERT_RECOVER_RETURN(m_screenMigrationTracker);
+
+ KisConfig cfg(true);
+ QScreen *screen = m_screenMigrationTracker->currentScreenSafe();
+ const int canvasScreenNumber = qApp->screens().indexOf(screen);
+ KisDisplayConfig newConfig(canvasScreenNumber, cfg);
+ if (newConfig != m_displayConfig) {
+ slotScreenChanged(screen);
+ }
+}
+
void KisScratchPad::paintEvent ( QPaintEvent * event ) {
if (!m_paintLayer) return;
diff --git a/libs/ui/widgets/kis_scratch_pad.h b/libs/ui/widgets/kis_scratch_pad.h
index 178e4390dd..5ba96e22ad 100644
--- a/libs/ui/widgets/kis_scratch_pad.h
+++ b/libs/ui/widgets/kis_scratch_pad.h
@@ -205,6 +205,7 @@ private Q_SLOTS:
void slotScreenChanged(QScreen *screen);
void setOnScreenResolution(qreal scaleX, qreal scaleY);
void slotUpdateCanvas(const QRect &rect);
+ void slotConfigChanged();
Q_SIGNALS:
void colorSelected(const KoColor& color);