Mercurial > hg > octave-nkf
comparison libgui/graphics/Figure.cc @ 20323: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 | c58cf3a65519 |
children | 5f0cb9bb6a50 |
comparison
equal
deleted
inserted
replaced
20322:043dcb4da5fc | 20323:c36f2b083613 |
---|---|
814 Figure::save_figure_callback (const std::string& file) | 814 Figure::save_figure_callback (const std::string& file) |
815 { | 815 { |
816 Ffeval (ovl ("print", file)); | 816 Ffeval (ovl ("print", file)); |
817 } | 817 } |
818 | 818 |
819 static void | |
820 delete_file (const std::string& file) | |
821 { | |
822 octave_unlink (file); | |
823 } | |
824 | |
825 void | 819 void |
826 Figure::copy_figure_callback (const std::string& format) | 820 Figure::copy_figure_callback (const std::string& format) |
827 { | 821 { |
828 std::string msg; | 822 std::string msg; |
829 | |
830 unwind_protect frame; | |
831 | 823 |
832 std::string file = octave_tempnam ("", "oct-", msg) + "." + format; | 824 std::string file = octave_tempnam ("", "oct-", msg) + "." + format; |
833 | 825 |
834 if (file.empty ()) | 826 if (file.empty ()) |
835 { | 827 { |
836 // Report error? | 828 // Report error? |
837 return; | 829 return; |
838 } | 830 } |
839 | 831 |
840 frame.add_fcn (delete_file, file); | |
841 | |
842 std::string device = "-d" + format; | 832 std::string device = "-d" + format; |
843 | 833 |
844 Ffeval (ovl ("print", file, device)); | 834 Ffeval (ovl ("print", file, device)); |
845 | 835 |
846 QClipboard *clipboard = QApplication::clipboard (); | 836 octave_link::copy_image_to_clipboard (file); |
847 | |
848 QImage img (file.c_str (), format.c_str ()); | |
849 | |
850 if (img.isNull ()) | |
851 { | |
852 // Report error? | |
853 return; | |
854 } | |
855 | |
856 clipboard->setImage (img); | |
857 } | 837 } |
858 | 838 |
859 void | 839 void |
860 Figure::fileSaveFigureAs (void) | 840 Figure::fileSaveFigureAs (void) |
861 { | 841 { |