From a339e4a1e3b53d852c1e6a445e3159dbd8bc0e80 Mon Sep 17 00:00:00 2001 From: Alessandro Portale <alessandro.portale@qt.io> Date: Mon, 21 Oct 2019 23:25:07 +0200 Subject: [PATCH] pixeltool: Show color under mouse in the window title Hint which color will be picked when pressing 'c'. Change-Id: If48392b288732b30d88bff18b3a3bbf5074947ed Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> --- src/pixeltool/qpixeltool.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/pixeltool/qpixeltool.cpp b/src/pixeltool/qpixeltool.cpp index 81923d1ed..b41f5e942 100644 --- a/src/pixeltool/qpixeltool.cpp +++ b/src/pixeltool/qpixeltool.cpp @@ -493,7 +493,7 @@ QSize QPixelTool::sizeHint() const return m_initialSize; } -static inline QString pixelToolTitle(QPoint pos) +static inline QString pixelToolTitle(QPoint pos, const QColor ¤tColor) { if (QHighDpiScaling::isActive()) { if (auto screen = QGuiApplication::screenAt(pos)) @@ -501,7 +501,8 @@ static inline QString pixelToolTitle(QPoint pos) } return QCoreApplication::applicationName() + QLatin1String(" [") + QString::number(pos.x()) - + QLatin1String(", ") + QString::number(pos.y()) + QLatin1Char(']'); + + QLatin1String(", ") + QString::number(pos.y()) + QLatin1String("] ") + + currentColor.name(); } void QPixelTool::grabScreen() @@ -519,7 +520,7 @@ void QPixelTool::grabScreen() return; if (m_lastMousePos != mousePos) - setWindowTitle(pixelToolTitle(mousePos)); + setWindowTitle(pixelToolTitle(mousePos, m_currentColor)); int w = int(width() / float(m_zoom)); int h = int(height() / float(m_zoom)); -- GitLab