diff --git a/modules/highgui/src/window_QT.cpp b/modules/highgui/src/window_QT.cpp index e83a442c6a..d77975f9ba 100644 --- a/modules/highgui/src/window_QT.cpp +++ b/modules/highgui/src/window_QT.cpp @@ -1856,7 +1856,7 @@ void CvWindow::displayStatusBar(QString text, int delayms) void CvWindow::enablePropertiesButton() { if (!vect_QActions.empty()) - vect_QActions[9]->setDisabled(false); + vect_QActions[10]->setDisabled(false); } @@ -1991,7 +1991,7 @@ void CvWindow::createView() void CvWindow::createActions() { - vect_QActions.resize(10); + vect_QActions.resize(11); QWidget* view = myView->getWidget(); @@ -2032,18 +2032,22 @@ void CvWindow::createActions() vect_QActions[8]->setIconVisibleInMenu(true); QObject::connect(vect_QActions[8], SIGNAL(triggered()), view, SLOT(saveView())); - vect_QActions[9] = new QAction(QIcon(":/properties-icon"), "Display properties window (CTRL+P)", this); + vect_QActions[9] = new QAction(QIcon(":/copy_clipbrd-icon"), "Copy image to clipboard (CTRL+C)", this); vect_QActions[9]->setIconVisibleInMenu(true); - QObject::connect(vect_QActions[9], SIGNAL(triggered()), this, SLOT(displayPropertiesWin())); + QObject::connect(vect_QActions[9], SIGNAL(triggered()), view, SLOT(copy2Clipbrd())); + + vect_QActions[10] = new QAction(QIcon(":/properties-icon"), "Display properties window (CTRL+P)", this); + vect_QActions[10]->setIconVisibleInMenu(true); + QObject::connect(vect_QActions[10], SIGNAL(triggered()), this, SLOT(displayPropertiesWin())); if (global_control_panel->myLayout->count() == 0) - vect_QActions[9]->setDisabled(true); + vect_QActions[10]->setDisabled(true); } void CvWindow::createShortcuts() { - vect_QShortcuts.resize(10); + vect_QShortcuts.resize(11); QWidget* view = myView->getWidget(); @@ -2074,8 +2078,11 @@ void CvWindow::createShortcuts() vect_QShortcuts[8] = new QShortcut(shortcut_save_img, this); QObject::connect(vect_QShortcuts[8], SIGNAL(activated()), view, SLOT(saveView())); - vect_QShortcuts[9] = new QShortcut(shortcut_properties_win, this); - QObject::connect(vect_QShortcuts[9], SIGNAL(activated()), this, SLOT(displayPropertiesWin())); + vect_QShortcuts[9] = new QShortcut(shortcut_copy_clipbrd, this); + QObject::connect(vect_QShortcuts[9], SIGNAL(activated()), view, SLOT(copy2Clipbrd())); + + vect_QShortcuts[10] = new QShortcut(shortcut_properties_win, this); + QObject::connect(vect_QShortcuts[10], SIGNAL(activated()), this, SLOT(displayPropertiesWin())); } @@ -2698,6 +2705,18 @@ void DefaultViewPort::saveView() } +//copy image to clipboard +void DefaultViewPort::copy2Clipbrd() +{ + // Create a new pixmap to render the viewport into + QPixmap viewportPixmap(viewport()->size()); + viewport()->render(&viewportPixmap); + + QClipboard *pClipboard = QApplication::clipboard(); + pClipboard->setPixmap(viewportPixmap); +} + + void DefaultViewPort::contextMenuEvent(QContextMenuEvent* evnt) { if (centralWidget->vect_QActions.size() > 0) diff --git a/modules/highgui/src/window_QT.h b/modules/highgui/src/window_QT.h index b132f41ede..dbeacf2edf 100644 --- a/modules/highgui/src/window_QT.h +++ b/modules/highgui/src/window_QT.h @@ -76,6 +76,7 @@ #include #include #include +#include #include #include @@ -91,6 +92,7 @@ enum { CV_MODE_NORMAL = 0, CV_MODE_OPENGL = 1 }; enum { shortcut_zoom_normal = Qt::CTRL + Qt::Key_Z, shortcut_zoom_imgRegion = Qt::CTRL + Qt::Key_X, shortcut_save_img = Qt::CTRL + Qt::Key_S, + shortcut_copy_clipbrd = Qt::CTRL + Qt::Key_C, shortcut_properties_win = Qt::CTRL + Qt::Key_P, shortcut_zoom_in = Qt::CTRL + Qt::Key_Plus,//QKeySequence(QKeySequence::ZoomIn), shortcut_zoom_out = Qt::CTRL + Qt::Key_Minus,//QKeySequence(QKeySequence::ZoomOut), @@ -518,6 +520,7 @@ public slots: void ZoomOut(); void saveView(); + void copy2Clipbrd(); protected: void contextMenuEvent(QContextMenuEvent* event) CV_OVERRIDE; diff --git a/modules/highgui/src/window_QT.qrc b/modules/highgui/src/window_QT.qrc index 7bcdc24541..efdd8c29a9 100644 --- a/modules/highgui/src/window_QT.qrc +++ b/modules/highgui/src/window_QT.qrc @@ -9,6 +9,7 @@ files_Qt/Milky/48/106.png files_Qt/Milky/48/107.png files_Qt/Milky/48/7.png + files_Qt/Milky/48/43.png files_Qt/Milky/48/38.png files_Qt/stylesheet_trackbar.qss