From 536f217e78cf62aa078b4da83cb89441fa4ceb18 Mon Sep 17 00:00:00 2001 From: Robin Stuart Date: Sat, 22 Apr 2017 12:21:27 +0100 Subject: [PATCH] Add option to copy to clipboard --- frontend_qt/mainWindow.ui | 17 +++++++++++++++-- frontend_qt/mainwindow.cpp | 19 +++++++++++++++++++ frontend_qt/mainwindow.h | 1 + 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/frontend_qt/mainWindow.ui b/frontend_qt/mainWindow.ui index ac697409..caf9b72a 100644 --- a/frontend_qt/mainWindow.ui +++ b/frontend_qt/mainWindow.ui @@ -308,8 +308,8 @@ Remember to place [square brackets] around AI data <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Noto Sans [monotype]'; font-size:9pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Sans Serif';">Your Data Here!</span></p></body></html> +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Your Data Here!</p></body></html> false @@ -619,6 +619,19 @@ p, li { white-space: pre-wrap; } + + + + + 100 + 0 + + + + &Copy + + + diff --git a/frontend_qt/mainwindow.cpp b/frontend_qt/mainwindow.cpp index 85e6b136..1a56713f 100644 --- a/frontend_qt/mainwindow.cpp +++ b/frontend_qt/mainwindow.cpp @@ -24,6 +24,8 @@ #include #include #include +#include +#include #include "mainwindow.h" #include "datawindow.h" @@ -148,6 +150,7 @@ MainWindow::MainWindow(QWidget* parent, Qt::WindowFlags fl) connect(btnMoreData, SIGNAL(clicked( bool )), SLOT(open_data_dialog())); connect(btnSequence, SIGNAL(clicked( bool )), SLOT(open_sequence_dialog())); connect(chkHRTHide, SIGNAL(stateChanged( int )), SLOT(update_preview())); + connect(btnCopy, SIGNAL(clicked( bool )), SLOT(copy_to_clipboard())); } MainWindow::~MainWindow() @@ -267,6 +270,22 @@ void MainWindow::quit_now() close(); } +void MainWindow::copy_to_clipboard() +{ + QClipboard *clipboard = QGuiApplication::clipboard(); + QMimeData *data = new QMimeData; + QString filename = ".zint.gif"; + + if (!m_bc.bc.save_to_file(filename)) { + return; + } + + data->setImageData(QImage(filename)); + clipboard->setMimeData(data, QClipboard::Clipboard); + + QFile::remove(filename); +} + void MainWindow::change_options() { QUiLoader uiload; diff --git a/frontend_qt/mainwindow.h b/frontend_qt/mainwindow.h index 82af4b1c..e2cded0a 100644 --- a/frontend_qt/mainwindow.h +++ b/frontend_qt/mainwindow.h @@ -130,6 +130,7 @@ private slots: void reset_view(); int open_data_dialog(); int open_sequence_dialog(); + void copy_to_clipboard(); private: /* void createActions();