# HG changeset patch # User Stefan Mahr # Date 1425058565 -3600 # Node ID 781adfc2958c5e7c5e655b817f5a1b6d3d70aed2 # Parent c7c50030e76c6110ca47571e785f8699f68cbb95 Build qt graphics toolkit menus with uimenu * libgui/graphics/Figure.cc, libgui/graphics/Figure.h: Revert cset 7335cc071ab0 and remove all menu items. * scripts/gui/private/__get_funcname__.m: Fix typo * scripts/plot/util/private/__add_default_menu__.m: Enable uimenu for qt graphics toolkit and fix setting pan/rotate/zoom for qt and fltk diff -r c7c50030e76c -r 781adfc2958c libgui/graphics/Figure.cc --- a/libgui/graphics/Figure.cc Fri Feb 27 09:44:58 2015 -0500 +++ b/libgui/graphics/Figure.cc Fri Feb 27 18:36:05 2015 +0100 @@ -29,8 +29,6 @@ #include #include #include -#include -#include #include #include #include @@ -47,10 +45,6 @@ #include "MouseModeActionGroup.h" #include "QtHandlesUtils.h" -#include "octave-qt-link.h" - -#include "builtin-defun-decls.h" - namespace QtHandles { @@ -221,26 +215,6 @@ return NoMode; } -QString Figure::fileName (void) -{ - gh_manager::auto_lock lock; - - const figure::properties& fp = properties
(); - - std::string name = fp.get_filename (); - - return QString::fromStdString (name); -} - -void Figure::setFileName (const QString& name) -{ - gh_manager::auto_lock lock; - - figure::properties& fp = properties
(); - - fp.set_filename (name.toStdString ()); -} - MouseMode Figure::mouseMode (void) { gh_manager::auto_lock lock; @@ -285,31 +259,6 @@ m_menuBar = new MenuBar (win); win->setMenuBar (m_menuBar); - QMenu* fileMenu = m_menuBar->addMenu (tr ("&File")); - fileMenu->menuAction ()->setObjectName ("builtinMenu"); - fileMenu->addAction (tr ("&Save"), this, SLOT (fileSaveFigure (bool))); - fileMenu->addAction (tr ("Save &As"), this, SLOT (fileSaveFigureAs (void))); - fileMenu->addSeparator (); - fileMenu->addAction (tr ("&Close Figure"), this, - SLOT (fileCloseFigure (void)), Qt::CTRL|Qt::Key_W); - - QMenu* editMenu = m_menuBar->addMenu (tr ("&Edit")); - editMenu->menuAction ()->setObjectName ("builtinMenu"); - editMenu->addAction (tr ("Cop&y"), this, SLOT (editCopy (void)), - Qt::CTRL|Qt::Key_C)->setEnabled (false); - editMenu->addAction (tr ("Cu&t"), this, SLOT (editCut (void)), - Qt::CTRL|Qt::Key_X)->setEnabled (false); - editMenu->addAction (tr ("&Paste"), this, SLOT (editPaste(void)), - Qt::CTRL|Qt::Key_V)->setEnabled (false); - editMenu->addSeparator (); - editMenu->addActions (m_mouseModeGroup->actions ()); - - QMenu* helpMenu = m_menuBar->addMenu (tr ("&Help")); - helpMenu->menuAction ()->setObjectName ("builtinMenu"); - helpMenu->addAction (tr ("&About QtHandles"), this, - SLOT (helpAboutQtHandles (void))); - helpMenu->addAction (tr ("About &Qt"), qApp, SLOT (aboutQt (void))); - m_menuBar->addReceiver (this); } @@ -732,48 +681,6 @@ canvas->setCursor (mode); } -void Figure::fileSaveFigure (bool prompt) -{ - QString file = fileName (); - - if (file.isEmpty ()) - { - prompt = true; - - file = "untitled.pdf"; - } - - if (prompt || file.isEmpty ()) - { - QFileInfo finfo (file); - - file = QFileDialog::getSaveFileName (qWidget (), - tr ("Save Figure As"), - finfo.absoluteFilePath (), 0, 0, - QFileDialog::DontUseNativeDialog); - } - - if (! file.isEmpty ()) - { - QFileInfo finfo (file); - - setFileName (finfo.absoluteFilePath ()); - - octave_link::post_event (this, &Figure::save_figure_callback, - file.toStdString ()); - } -} - -void Figure::save_figure_callback (const std::string& file) -{ - Ffeval (ovl ("print", file)); -} - -void Figure::fileSaveFigureAs (void) -{ - fileSaveFigure (true); -} - void Figure::fileCloseFigure (void) { qWidget ()->close (); diff -r c7c50030e76c -r 781adfc2958c libgui/graphics/Figure.h --- a/libgui/graphics/Figure.h Fri Feb 27 09:44:58 2015 -0500 +++ b/libgui/graphics/Figure.h Fri Feb 27 18:36:05 2015 +0100 @@ -71,9 +71,6 @@ static Figure* create (const graphics_object& go); - QString fileName (void); - void setFileName (const QString& name); - MouseMode mouseMode (void); Container* innerContainer (void); @@ -108,12 +105,8 @@ static void updateBoundingBoxHelper (void*); - void save_figure_callback (const std::string& file); - private slots: void setMouseMode (MouseMode mode); - void fileSaveFigure (bool prompt = false); - void fileSaveFigureAs (void); void fileCloseFigure (void); void editCopy (void); void editCut (void); diff -r c7c50030e76c -r 781adfc2958c scripts/gui/private/__get_funcname__.m --- a/scripts/gui/private/__get_funcname__.m Fri Feb 27 09:44:58 2015 -0500 +++ b/scripts/gui/private/__get_funcname__.m Fri Feb 27 18:36:05 2015 +0100 @@ -32,7 +32,7 @@ tk = graphics_toolkit (); funcname = strcat ("__", basename, "_", tk, "__"); if (numel (tk) > 0 && ! strcmp (tk, "fltk") - && ! __is_function__ (funcname))) + && ! __is_function__ (funcname)) warning ("%s: no implementation for toolkit '%s', using 'fltk' instead", basename, tk); endif diff -r c7c50030e76c -r 781adfc2958c scripts/plot/util/private/__add_default_menu__.m --- a/scripts/plot/util/private/__add_default_menu__.m Fri Feb 27 09:44:58 2015 -0500 +++ b/scripts/plot/util/private/__add_default_menu__.m Fri Feb 27 18:36:05 2015 +0100 @@ -27,7 +27,8 @@ function __add_default_menu__ (fig) ## Only FLTK toolkit currently provides menubar - if (! strcmp (get (fig, "__graphics_toolkit__"), "fltk")) + tk = get (fig, "__graphics_toolkit__"); + if (! any (strcmp (tk, {"fltk", "qt"}))) return; endif @@ -45,6 +46,7 @@ uimenu (__e, "label", "Show grid on all axes", "tag", "on", "callback", @grid_cb); uimenu (__e, "label", "Hide grid on all axes", "tag", "off", "callback", @grid_cb); uimenu (__e, "label", "Auto&scale all axes", "callback", @autoscale_cb); + gm = uimenu (__e, "label", "GUI &Mode (on all axes)"); uimenu (gm, "label", "Pan x and y", "tag", "pan_on", "callback", @guimode_cb); uimenu (gm, "label", "Pan x only", "tag", "pan_xon", "callback", @guimode_cb); @@ -85,8 +87,7 @@ endif endfunction - -function hax = __get_axes__ (h) +function [hax, fig] = __get_axes__ (h) ## Get parent figure fig = ancestor (h, "figure"); @@ -113,23 +114,23 @@ endfunction function guimode_cb (h, e) - hax = __get_axes__ (h); + [hax, fig] = __get_axes__ (h); id = get (h, "tag"); switch (id) case "pan_on" - arrayfun (@(h) pan (h, "on"), hax) + arrayfun (@(h) pan (fig, "on"), hax) case "pan_xon" - arrayfun (@(h) pan (h, "xon"), hax) + arrayfun (@(h) pan (fig, "xon"), hax) case "pan_yon" - arrayfun (@(h) pan (h, "yon"), hax) + arrayfun (@(h) pan (fig, "yon"), hax) case "rotate3d" - arrayfun (@(h) rotate3d (h, "on"), hax) + arrayfun (@(h) rotate3d (fig, "on"), hax) case "no_pan_rotate" - arrayfun (@(h) pan (h, "off"), hax) - arrayfun (@(h) rotate3d (h, "off"), hax) + arrayfun (@(h) pan (fig, "off"), hax) + arrayfun (@(h) rotate3d (fig, "off"), hax) case "zoom_on" - arrayfun (@(h) set (h, "mouse_wheel_zoom", 0.05), hax); + arrayfun (@(tax) set (tax, "mousewheelzoom", 0.05), hax); case "zoom_off" - arrayfun (@(h) set (h, "mouse_wheel_zoom", 0.0), hax); + arrayfun (@(tax) set (tax, "mousewheelzoom", 0.0), hax); endswitch endfunction