diff --git a/src/pixeltool/qpixeltool.cpp b/src/pixeltool/qpixeltool.cpp index f699ec828f0ec714da18940b61fab23381cc5c41..81923d1ed6086d5414398299d729aad5d5d8621a 100644 --- a/src/pixeltool/qpixeltool.cpp +++ b/src/pixeltool/qpixeltool.cpp @@ -307,8 +307,10 @@ void QPixelTool::keyPressEvent(QKeyEvent *e) break; #if QT_CONFIG(clipboard) case Qt::Key_C: - if (e->modifiers() & Qt::ControlModifier) + if (e->modifiers().testFlag(Qt::ControlModifier)) copyToClipboard(); + else + copyColorToClipboard(); break; #endif // QT_CONFIG(clipboard) case Qt::Key_S: @@ -448,6 +450,8 @@ void QPixelTool::contextMenuEvent(QContextMenuEvent *e) #if QT_CONFIG(clipboard) menu.addAction(QLatin1String("Copy to clipboard"), this, &QPixelTool::copyToClipboard, QKeySequence::Copy); + menu.addAction(QLatin1String("Copy color value to clipboard"), + this, &QPixelTool::copyColorToClipboard, Qt::Key_C); #endif // QT_CONFIG(clipboard) menu.addSeparator(); @@ -640,6 +644,11 @@ void QPixelTool::copyToClipboard() { QGuiApplication::clipboard()->setPixmap(m_buffer); } + +void QPixelTool::copyColorToClipboard() +{ + QGuiApplication::clipboard()->setText(QColor(m_currentColor).name()); +} #endif // QT_CONFIG(clipboard) void QPixelTool::saveToFile() diff --git a/src/pixeltool/qpixeltool.h b/src/pixeltool/qpixeltool.h index beb786fd25cf0b5fb8613716b9c185f460d72729..3fa9f1e7e83d0b8c43c93ff6f50645428bf9017b 100644 --- a/src/pixeltool/qpixeltool.h +++ b/src/pixeltool/qpixeltool.h @@ -53,6 +53,7 @@ public slots: void setZoomVisible(bool visible); #if QT_CONFIG(clipboard) void copyToClipboard(); + void copyColorToClipboard(); #endif void saveToFile(); void increaseGridSize() { setGridSize(m_gridSize + 1); }