summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel/qplatformservices.cpp
diff options
context:
space:
mode:
authorHarald Sitter <sitter@kde.org>2022-07-11 14:45:40 +0200
committerHarald Sitter <sitter@kde.org>2022-08-26 13:33:15 +0200
commitb646c7b76c7787cff57bca0fde04d9f58abdfbb8 (patch)
tree68c4a986a69fcaddee8a89023f9f7de1d80c196c /src/gui/kernel/qplatformservices.cpp
parentf8409b6e9c7f9a303fc78061182ce06de9bc795e (diff)
add color picking support on wayland using the XDG desktop portal
On wayland applications are not trusted to perform screen grabs by default, it is however possible to let the user specifically pick the color of a pixel using the XDG desktop portal (otherwise used for sandboxing etc.). Try to use this portal on unix systems by default. To support this use case some extra abstraction is necessary as this constitutes a platformservice rather than a platform feature. To that end the QPlatformService has gained a capability system and a pure virtual helper class to facilitate asynchronous color picking. When supported the color picking capability takes precedence over the custom picking code in QColorDialog. Fixes: QTBUG-81538 Change-Id: I4acb3af11d459e9d5ebefe5abbb41e50e3ccf7f0 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/gui/kernel/qplatformservices.cpp')
-rw-r--r--src/gui/kernel/qplatformservices.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/gui/kernel/qplatformservices.cpp b/src/gui/kernel/qplatformservices.cpp
index a0db26dda3..1c8062389d 100644
--- a/src/gui/kernel/qplatformservices.cpp
+++ b/src/gui/kernel/qplatformservices.cpp
@@ -19,6 +19,19 @@ QT_BEGIN_NAMESPACE
\brief The QPlatformServices provides the backend for desktop-related functionality.
*/
+/*!
+ \enum QPlatformServices::Capability
+
+ Capabilities are used to determine a specific platform service's availability.
+
+ \value ColorPickingFromScreen The platform natively supports color picking from screen.
+ This capability indicates that the platform supports "opaque" color picking, where the
+ platform implements a complete user experience for color picking and outputs a color.
+ This is in contrast to the application implementing the color picking user experience
+ (taking care of showing a cross hair, instructing the platform integration to obtain
+ the color at a given pixel, etc.). The related service function is pickColor().
+ */
+
QPlatformServices::QPlatformServices()
{ }
@@ -49,5 +62,16 @@ QByteArray QPlatformServices::desktopEnvironment() const
return QByteArray("UNKNOWN");
}
+QPlatformServiceColorPicker *QPlatformServices::colorPicker(QWindow *parent)
+{
+ Q_UNUSED(parent);
+ return nullptr;
+}
+
+bool QPlatformServices::hasCapability(Capability capability) const
+{
+ Q_UNUSED(capability)
+ return false;
+}
QT_END_NAMESPACE