Mercurial > octave-antonio
comparison 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 |
comparison
equal
deleted
inserted
replaced
20112:043dcb4da5fc | 20113:c36f2b083613 |
---|---|
670 _settings_dlg->setAttribute (Qt::WA_DeleteOnClose); | 670 _settings_dlg->setAttribute (Qt::WA_DeleteOnClose); |
671 _settings_dlg->show (); | 671 _settings_dlg->show (); |
672 } | 672 } |
673 | 673 |
674 void | 674 void |
675 main_window::copy_image_to_clipboard (const QString& file, bool remove_file) | |
676 { | |
677 QClipboard *clipboard = QApplication::clipboard (); | |
678 | |
679 QImage img (file); | |
680 | |
681 if (img.isNull ()) | |
682 { | |
683 // Report error? | |
684 return; | |
685 } | |
686 | |
687 clipboard->setImage (img); | |
688 | |
689 if (remove_file) | |
690 QFile::remove (file); | |
691 } | |
692 | |
693 void | |
675 main_window::request_reload_settings () | 694 main_window::request_reload_settings () |
676 { | 695 { |
677 QSettings *settings = resource_manager::get_settings (); | 696 QSettings *settings = resource_manager::get_settings (); |
678 | 697 |
679 if (settings) | 698 if (settings) |
1521 | 1540 |
1522 connect (_octave_qt_link, | 1541 connect (_octave_qt_link, |
1523 SIGNAL (show_preferences_signal (void)), | 1542 SIGNAL (show_preferences_signal (void)), |
1524 this, SLOT (process_settings_dialog_request ())); | 1543 this, SLOT (process_settings_dialog_request ())); |
1525 | 1544 |
1545 connect (_octave_qt_link, | |
1546 SIGNAL (copy_image_to_clipboard_signal (const QString&, bool)), | |
1547 this, SLOT (copy_image_to_clipboard (const QString&, bool))); | |
1548 | |
1526 #ifdef HAVE_QSCINTILLA | 1549 #ifdef HAVE_QSCINTILLA |
1527 connect (_octave_qt_link, | 1550 connect (_octave_qt_link, |
1528 SIGNAL (edit_file_signal (const QString&)), | 1551 SIGNAL (edit_file_signal (const QString&)), |
1529 editor_window, | 1552 editor_window, |
1530 SLOT (handle_edit_file_request (const QString&))); | 1553 SLOT (handle_edit_file_request (const QString&))); |