Mercurial > octave-antonio
diff libgui/src/main-window.cc @ 20113:c36f2b083613
make copying figures to clipboard work (bug #44866)
* Figure.cc (Figure::copy_figure_callback): Just print the figure to a
file here, then call octave_link::copy_image_to_clipboard.
(delete_file): Delete unused static function.
* main-window.h, main-window.cc
(main_window::copy_image_to_clipboard): New function.
(main_window::construct_octave_qt_link): Connect
octave_qt_link::copy_image_to_clipboard_signal signal to
main_window::copy_image_to_clipboard slot.
* octave-qt-link.h, octave-qt-link.cc
(octave_qt_link::do_copy_image_to_clipboard): New function.
(octave_qt_link::copy_image_to_clipboard_signal): New signal.
* octave-link.h (octave_link::do_copy_image_to_clipboard):
New pure virtual function.
(octave_link::copy_image_to_clipboard): New static funtion.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 22 Apr 2015 00:36:24 -0500 |
parents | 89d843d6de14 |
children | d7bea5b11fc3 |
line wrap: on
line diff
--- a/libgui/src/main-window.cc Tue Apr 21 15:01:55 2015 +0100 +++ b/libgui/src/main-window.cc Wed Apr 22 00:36:24 2015 -0500 @@ -672,6 +672,25 @@ } void +main_window::copy_image_to_clipboard (const QString& file, bool remove_file) +{ + QClipboard *clipboard = QApplication::clipboard (); + + QImage img (file); + + if (img.isNull ()) + { + // Report error? + return; + } + + clipboard->setImage (img); + + if (remove_file) + QFile::remove (file); +} + +void main_window::request_reload_settings () { QSettings *settings = resource_manager::get_settings (); @@ -1523,6 +1542,10 @@ SIGNAL (show_preferences_signal (void)), this, SLOT (process_settings_dialog_request ())); + connect (_octave_qt_link, + SIGNAL (copy_image_to_clipboard_signal (const QString&, bool)), + this, SLOT (copy_image_to_clipboard (const QString&, bool))); + #ifdef HAVE_QSCINTILLA connect (_octave_qt_link, SIGNAL (edit_file_signal (const QString&)),