1 //////////////////////////////////////////////////////////////////////// 2 // 3 // Copyright (C) 2019-2021 The Octave Project Developers 4 // 5 // See the file COPYRIGHT.md in the top-level directory of this 6 // distribution or <https://octave.org/copyright/>. 7 // 8 // This file is part of Octave. 9 // 10 // Octave is free software: you can redistribute it and/or modify it 11 // under the terms of the GNU General Public License as published by 12 // the Free Software Foundation, either version 3 of the License, or 13 // (at your option) any later version. 14 // 15 // Octave is distributed in the hope that it will be useful, but 16 // WITHOUT ANY WARRANTY; without even the implied warranty of 17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 // GNU General Public License for more details. 19 // 20 // You should have received a copy of the GNU General Public License 21 // along with Octave; see the file COPYING. If not, see 22 // <https://www.gnu.org/licenses/>. 23 // 24 //////////////////////////////////////////////////////////////////////// 25 26 #if defined (HAVE_CONFIG_H) 27 # include "config.h" 28 #endif 29 30 #include <QApplication> 31 #include <QMetaType> 32 #include <QThread> 33 34 #include "graphics-init.h" 35 #include "octave-qobject.h" 36 #include "qt-graphics-toolkit.h" 37 #include "QtHandlesUtils.h" 38 39 #include "graphics.h" 40 #include "gtk-manager.h" 41 #include "interpreter.h" 42 43 namespace octave 44 { graphics_init(interpreter & interp,base_qobject & oct_qobj)45 void graphics_init (interpreter& interp, base_qobject& oct_qobj) 46 { 47 #if defined (HAVE_QT_GRAPHICS) 48 49 gh_manager& gh_mgr = interp.get_gh_manager (); 50 51 autolock guard (gh_mgr.graphics_lock ()); 52 53 qRegisterMetaType<graphics_object> ("graphics_object"); 54 55 gh_mgr.enable_event_processing (true); 56 57 QtHandles::qt_graphics_toolkit *qt_gtk 58 = new QtHandles::qt_graphics_toolkit (interp, oct_qobj); 59 60 if (QThread::currentThread () 61 != QApplication::instance ()->thread ()) 62 qt_gtk->moveToThread (QApplication::instance ()->thread ()); 63 64 graphics_toolkit tk (qt_gtk); 65 66 octave::gtk_manager& gtk_mgr = interp.get_gtk_manager (); 67 68 gtk_mgr.register_toolkit ("qt"); 69 70 gtk_mgr.load_toolkit (tk); 71 72 #else 73 74 octave_unused_parameter (interp); 75 octave_unused_parameter (oct_qobj); 76 77 #endif 78 } 79 } 80