def _constructToolbarMenu(self): """Add items to edit/add graph toolbar and menu.""" iconsize = setting.settingdb['toolbar_size'] self.addtoolbar.setIconSize( qt4.QSize(iconsize, iconsize) ) self.edittoolbar.setIconSize( qt4.QSize(iconsize, iconsize) ) self.addslots = {} self.vzactions = actions = self.parent.vzactions for widgettype in ('page', 'grid', 'graph', 'axis', 'xy', 'bar', 'fit', 'function', 'boxplot', 'image', 'contour', 'vectorfield', 'key', 'label', 'colorbar', 'rect', 'ellipse', 'imagefile', 'line', 'polygon', 'polar', 'ternary', 'nonorthpoint', 'nonorthfunc'): wc = document.thefactory.getWidgetClass(widgettype) slot = utils.BoundCaller(self.slotMakeWidgetButton, wc) self.addslots[wc] = slot actionname = 'add.' + widgettype actions[actionname] = utils.makeAction( self, wc.description, 'Add %s' % widgettype, slot, icon='button_%s' % widgettype) a = utils.makeAction actions.update({ 'edit.cut': a(self, 'Cut the selected item', 'Cu&t', self.slotWidgetCut, icon='veusz-edit-cut', key='Ctrl+X'), 'edit.copy': a(self, 'Copy the selected item', '&Copy', self.slotWidgetCopy, icon='kde-edit-copy', key='Ctrl+C'), 'edit.paste': a(self, 'Paste item from the clipboard', '&Paste', self.slotWidgetPaste, icon='kde-edit-paste', key='Ctrl+V'), 'edit.moveup': a(self, 'Move the selected item up', 'Move &up', utils.BoundCaller(self.slotWidgetMove, -1), icon='kde-go-up'), 'edit.movedown': a(self, 'Move the selected item down', 'Move d&own', utils.BoundCaller(self.slotWidgetMove, 1), icon='kde-go-down'), 'edit.delete': a(self, 'Remove the selected item', '&Delete', self.slotWidgetDelete, icon='kde-edit-delete'), 'edit.rename': a(self, 'Renames the selected item', '&Rename', self.slotWidgetRename, icon='kde-edit-rename'), 'add.shapemenu': a(self, 'Add a shape to the plot', 'Shape', self.slotShowShapeMenu, icon='veusz-shape-menu'), }) # add actions to menus for adding widgets and editing addact = [('add.'+w) for w in ('page', 'grid', 'graph', 'axis', 'xy', 'nonorthpoint', 'bar', 'fit', 'function', 'nonorthfunc', 'boxplot', 'image', 'contour', 'vectorfield', 'key', 'label', 'colorbar', 'polar', 'ternary')] menuitems = [ ('insert', '', addact + [ ['insert.shape', 'Add shape', ['add.rect', 'add.ellipse', 'add.line', 'add.imagefile', 'add.polygon'] ]]), ('edit', '', [ 'edit.cut', 'edit.copy', 'edit.paste', 'edit.moveup', 'edit.movedown', 'edit.delete', 'edit.rename' ]), ] utils.constructMenus( self.parent.menuBar(), self.parent.menus, menuitems, actions ) # create shape toolbar button # attach menu to insert shape button actions['add.shapemenu'].setMenu(self.parent.menus['insert.shape']) # add actions to toolbar to create widgets utils.addToolbarActions(self.addtoolbar, actions, addact + ['add.shapemenu']) # add action to toolbar for editing utils.addToolbarActions(self.edittoolbar, actions, ('edit.cut', 'edit.copy', 'edit.paste', 'edit.moveup', 'edit.movedown', 'edit.delete', 'edit.rename')) self.connect( self.parent.menus['edit.select'], qt4.SIGNAL('aboutToShow()'), self.updateSelectMenu )
def createToolbar(self, parent, menu=None): """Make a view toolbar, and optionally update menu.""" self.viewtoolbar = qt4.QToolBar(_("View toolbar - Veusz"), parent) self.viewtoolbar.setObjectName("veuszviewtoolbar") iconsize = setting.settingdb["toolbar_size"] self.viewtoolbar.setIconSize(qt4.QSize(iconsize, iconsize)) self.viewtoolbar.hide() if parent: parent.addToolBar(qt4.Qt.TopToolBarArea, self.viewtoolbar) if parent and hasattr(parent, "vzactions"): # share actions with parent if possible # as plot windows can be isolated from mainwindows, we need this self.vzactions = actions = parent.vzactions else: self.vzactions = actions = {} a = utils.makeAction actions.update( { "view.zoomin": a( self, _("Zoom into the plot"), _("Zoom &In"), self.slotViewZoomIn, icon="kde-zoom-in", key="Ctrl++" ), "view.zoomout": a( self, _("Zoom out of the plot"), _("Zoom &Out"), self.slotViewZoomOut, icon="kde-zoom-out", key="Ctrl+-", ), "view.zoom11": a( self, _("Restore plot to natural size"), _("Zoom 1:1"), self.slotViewZoom11, icon="kde-zoom-1-veuszedit", key="Ctrl+1", ), "view.zoomwidth": a( self, _("Zoom plot to show whole width"), _("Zoom to width"), self.slotViewZoomWidth, icon="kde-zoom-width-veuszedit", ), "view.zoomheight": a( self, _("Zoom plot to show whole height"), _("Zoom to height"), self.slotViewZoomHeight, icon="kde-zoom-height-veuszedit", ), "view.zoompage": a( self, _("Zoom plot to show whole page"), _("Zoom to page"), self.slotViewZoomPage, icon="kde-zoom-page-veuszedit", ), "view.zoommenu": a( self, _("Zoom functions menu"), _("Zoom"), self.doZoomMenuButton, icon="kde-zoom-veuszedit" ), "view.prevpage": a( self, _("Move to the previous page"), _("&Previous page"), self.slotViewPreviousPage, icon="kde-go-previous", key="Ctrl+PgUp", ), "view.nextpage": a( self, _("Move to the next page"), _("&Next page"), self.slotViewNextPage, icon="kde-go-next", key="Ctrl+PgDown", ), "view.select": a( self, _("Select items from the graph or scroll"), _("Select items or scroll"), None, icon="kde-mouse-pointer", ), "view.pick": a( self, _("Read data points on the graph"), _("Read data points"), None, icon="veusz-pick-data" ), "view.zoomgraph": a(self, _("Zoom into graph"), _("Zoom graph"), None, icon="veusz-zoom-graph"), "view.fullscreen": a( self, _("View plot full screen"), _("Full screen"), self.slotFullScreen, icon="veusz-view-fullscreen", key="Ctrl+F11", ), } ) if menu: # only construct menu if required menuitems = [ ( "view", "", [ "view.zoomin", "view.zoomout", "view.zoom11", "view.zoomwidth", "view.zoomheight", "view.zoompage", "", "view.prevpage", "view.nextpage", "view.fullscreen", "", "view.select", "view.pick", "view.zoomgraph", ], ) ] utils.constructMenus(menu, {"view": menu}, menuitems, actions) # populate menu on zoom menu toolbar icon zoommenu = qt4.QMenu(self) zoomag = qt4.QActionGroup(self) for act in ("view.zoomin", "view.zoomout", "view.zoom11", "view.zoomwidth", "view.zoomheight", "view.zoompage"): a = actions[act] zoommenu.addAction(a) zoomag.addAction(a) a.vzname = act actions["view.zoommenu"].setMenu(zoommenu) self.connect(zoomag, qt4.SIGNAL("triggered(QAction*)"), self.zoomActionTriggered) lastzoom = setting.settingdb.get("view_defaultzoom", "view.zoompage") self.updateZoomMenuButton(actions[lastzoom]) # add items to toolbar utils.addToolbarActions( self.viewtoolbar, actions, ( "view.prevpage", "view.nextpage", "view.fullscreen", "view.select", "view.pick", "view.zoomgraph", "view.zoommenu", ), ) # define action group for various different selection models grp = self.selectactiongrp = qt4.QActionGroup(self) grp.setExclusive(True) for a in ("view.select", "view.pick", "view.zoomgraph"): actions[a].setActionGroup(grp) actions[a].setCheckable(True) actions["view.select"].setChecked(True) self.connect(grp, qt4.SIGNAL("triggered(QAction*)"), self.slotSelectMode) return self.viewtoolbar
def createToolbar(self, parent, menu=None): """Make a view toolbar, and optionally update menu.""" self.viewtoolbar = qt4.QToolBar("View toolbar - Veusz", parent) self.viewtoolbar.setObjectName('veuszviewtoolbar') iconsize = setting.settingdb['toolbar_size'] self.viewtoolbar.setIconSize(qt4.QSize(iconsize, iconsize)) self.viewtoolbar.hide() parent.addToolBar(qt4.Qt.TopToolBarArea, self.viewtoolbar) if hasattr(parent, 'vzactions'): # share actions with parent if possible # as plot windows can be isolated from mainwindows, we need this self.vzactions = actions = parent.vzactions else: self.vzactions = actions = {} a = utils.makeAction actions.update({ 'view.zoomin': a(self, 'Zoom into the plot', 'Zoom &In', self.slotViewZoomIn, icon='kde-zoom-in', key='Ctrl++'), 'view.zoomout': a(self, 'Zoom out of the plot', 'Zoom &Out', self.slotViewZoomOut, icon='kde-zoom-out', key='Ctrl+-'), 'view.zoom11': a(self, 'Restore plot to natural size', 'Zoom 1:1', self.slotViewZoom11, icon='kde-zoom-1-veuszedit', key='Ctrl+1'), 'view.zoomwidth': a(self, 'Zoom plot to show whole width', 'Zoom to width', self.slotViewZoomWidth, icon='kde-zoom-width-veuszedit'), 'view.zoomheight': a(self, 'Zoom plot to show whole height', 'Zoom to height', self.slotViewZoomHeight, icon='kde-zoom-height-veuszedit'), 'view.zoompage': a(self, 'Zoom plot to show whole page', 'Zoom to page', self.slotViewZoomPage, icon='kde-zoom-page-veuszedit'), 'view.zoommenu': a(self, 'Zoom functions menu', 'Zoom', self.doZoomMenuButton, icon='kde-zoom-veuszedit'), 'view.prevpage': a(self, 'Move to the previous page', '&Previous page', self.slotViewPreviousPage, icon='kde-go-previous', key='Ctrl+PgUp'), 'view.nextpage': a(self, 'Move to the next page', '&Next page', self.slotViewNextPage, icon='kde-go-next', key='Ctrl+PgDown'), 'view.select': a(self, 'Select items from the graph or scroll', 'Select items or scroll', None, icon='kde-mouse-pointer'), 'view.pick': a(self, 'Read data points on the graph', 'Read data points', None, icon='veusz-pick-data'), 'view.zoomgraph': a(self, 'Zoom into graph', 'Zoom graph', None, icon='veusz-zoom-graph'), }) if menu: # only construct menu if required menuitems = [ ('view', '', [ 'view.zoomin', 'view.zoomout', 'view.zoom11', 'view.zoomwidth', 'view.zoomheight', 'view.zoompage', '', 'view.prevpage', 'view.nextpage', 'view.select', 'view.pick', 'view.zoomgraph', ]), ] utils.constructMenus(menu, {'view': menu}, menuitems, actions) # populate menu on zoom menu toolbar icon zoommenu = qt4.QMenu(self) zoomag = qt4.QActionGroup(self) for act in ('view.zoomin', 'view.zoomout', 'view.zoom11', 'view.zoomwidth', 'view.zoomheight', 'view.zoompage'): a = actions[act] zoommenu.addAction(a) zoomag.addAction(a) a.vzname = act actions['view.zoommenu'].setMenu(zoommenu) self.connect(zoomag, qt4.SIGNAL('triggered(QAction*)'), self.zoomActionTriggered) lastzoom = setting.settingdb.get('view_defaultzoom', 'view.zoompage') self.updateZoomMenuButton(actions[lastzoom]) # add items to toolbar utils.addToolbarActions(self.viewtoolbar, actions, ('view.prevpage', 'view.nextpage', 'view.select', 'view.pick', 'view.zoomgraph', 'view.zoommenu')) # define action group for various different selection models grp = self.selectactiongrp = qt4.QActionGroup(self) grp.setExclusive(True) for a in ('view.select', 'view.pick', 'view.zoomgraph'): actions[a].setActionGroup(grp) actions[a].setCheckable(True) actions['view.select'].setChecked(True) self.connect( grp, qt4.SIGNAL('triggered(QAction*)'), self.slotSelectMode ) return self.viewtoolbar
def _constructToolbarMenu(self): """Add items to edit/add graph toolbar and menu.""" iconsize = setting.settingdb['toolbar_size'] self.addtoolbar.setIconSize( qt4.QSize(iconsize, iconsize) ) self.edittoolbar.setIconSize( qt4.QSize(iconsize, iconsize) ) self.addslots = {} self.vzactions = actions = self.parentwin.vzactions for widgettype in ('page', 'grid', 'graph', 'axis', 'xy', 'bar', 'fit', 'function', 'boxplot', 'image', 'contour', 'vectorfield', 'key', 'label', 'colorbar', 'rect', 'ellipse', 'imagefile', 'line', 'polygon', 'polar', 'ternary', 'nonorthpoint', 'nonorthfunc'): wc = document.thefactory.getWidgetClass(widgettype) slot = utils.BoundCaller(self.slotMakeWidgetButton, wc) self.addslots[wc] = slot actionname = 'add.' + widgettype actions[actionname] = utils.makeAction( self, wc.description, _('Add %s') % widgettype, slot, icon='button_%s' % widgettype) a = utils.makeAction actions.update({ 'edit.cut': a(self, _('Cut the selected widget'), _('Cu&t'), self.slotWidgetCut, icon='veusz-edit-cut', key='Ctrl+X'), 'edit.copy': a(self, _('Copy the selected widget'), _('&Copy'), self.slotWidgetCopy, icon='kde-edit-copy', key='Ctrl+C'), 'edit.paste': a(self, _('Paste widget from the clipboard'), _('&Paste'), self.slotWidgetPaste, icon='kde-edit-paste', key='Ctrl+V'), 'edit.moveup': a(self, _('Move the selected widget up'), _('Move &up'), utils.BoundCaller(self.slotWidgetMove, -1), icon='kde-go-up'), 'edit.movedown': a(self, _('Move the selected widget down'), _('Move d&own'), utils.BoundCaller(self.slotWidgetMove, 1), icon='kde-go-down'), 'edit.delete': a(self, _('Remove the selected widget'), _('&Delete'), self.slotWidgetDelete, icon='kde-edit-delete'), 'edit.rename': a(self, _('Renames the selected widget'), _('&Rename'), self.slotWidgetRename, icon='kde-edit-rename'), 'add.shapemenu': a(self, _('Add a shape to the plot'), _('Shape'), self.slotShowShapeMenu, icon='veusz-shape-menu'), }) # add actions to menus for adding widgets and editing addact = [('add.'+w) for w in ('page', 'grid', 'graph', 'axis', 'xy', 'nonorthpoint', 'bar', 'fit', 'function', 'nonorthfunc', 'boxplot', 'image', 'contour', 'vectorfield', 'key', 'label', 'colorbar', 'polar', 'ternary')] menuitems = [ ('insert', '', addact + [ ['insert.shape', 'Add shape', ['add.rect', 'add.ellipse', 'add.line', 'add.imagefile', 'add.polygon'] ]]), ('edit', '', [ 'edit.cut', 'edit.copy', 'edit.paste', 'edit.moveup', 'edit.movedown', 'edit.delete', 'edit.rename' ]), ] utils.constructMenus( self.parentwin.menuBar(), self.parentwin.menus, menuitems, actions ) # create shape toolbar button # attach menu to insert shape button actions['add.shapemenu'].setMenu(self.parentwin.menus['insert.shape']) # add actions to toolbar to create widgets utils.addToolbarActions(self.addtoolbar, actions, addact + ['add.shapemenu']) # add action to toolbar for editing utils.addToolbarActions(self.edittoolbar, actions, ('edit.cut', 'edit.copy', 'edit.paste', 'edit.moveup', 'edit.movedown', 'edit.delete', 'edit.rename')) self.connect( self.parentwin.menus['edit.select'], qt4.SIGNAL('aboutToShow()'), self.updateSelectMenu )
def _defineMenus(self): """Initialise the menus and toolbar.""" # these are actions for main menu toolbars and menus a = utils.makeAction self.vzactions = { 'file.new': a(self, 'New document', '&New', self.slotFileNew, icon='kde-document-new', key='Ctrl+N'), 'file.open': a(self, 'Open a document', '&Open...', self.slotFileOpen, icon='kde-document-open', key='Ctrl+O'), 'file.save': a(self, 'Save the document', '&Save', self.slotFileSave, icon='kde-document-save', key='Ctrl+S'), 'file.saveas': a(self, 'Save the current graph under a new name', 'Save &As...', self.slotFileSaveAs, icon='kde-document-save-as'), 'file.print': a(self, 'Print the document', '&Print...', self.slotFilePrint, icon='kde-document-print', key='Ctrl+P'), 'file.export': a(self, 'Export the current page', '&Export...', self.slotFileExport, icon='kde-document-export'), 'file.close': a(self, 'Close current window', 'Close Window', self.slotFileClose, icon='kde-window-close', key='Ctrl+W'), 'file.quit': a(self, 'Exit the program', '&Quit', self.slotFileQuit, icon='kde-application-exit', key='Ctrl+Q'), 'edit.undo': a(self, 'Undo the previous operation', 'Undo', self.slotEditUndo, icon='kde-edit-undo', key='Ctrl+Z'), 'edit.redo': a(self, 'Redo the previous operation', 'Redo', self.slotEditRedo, icon='kde-edit-redo', key='Ctrl+Shift+Z'), 'edit.prefs': a(self, 'Edit preferences', 'Preferences...', self.slotEditPreferences, icon='veusz-edit-prefs'), 'edit.custom': a(self, 'Edit custom functions and constants', 'Custom definitions...', self.slotEditCustom, icon='veusz-edit-custom'), 'edit.stylesheet': a(self, 'Edit stylesheet to change default widget settings', 'Default styles...', self.slotEditStylesheet, icon='settings_stylesheet'), 'view.edit': a(self, 'Show or hide edit window', 'Edit window', None, checkable=True), 'view.props': a(self, 'Show or hide property window', 'Properties window', None, checkable=True), 'view.format': a(self, 'Show or hide formatting window', 'Formatting window', None, checkable=True), 'view.console': a(self, 'Show or hide console window', 'Console window', None, checkable=True), 'view.datanav': a(self, 'Show or hide data navigator window', 'Data navigator window', None, checkable=True), 'view.maintool': a(self, 'Show or hide main toolbar', 'Main toolbar', None, checkable=True), 'view.datatool': a(self, 'Show or hide data toolbar', 'Data toolbar', None, checkable=True), 'view.viewtool': a(self, 'Show or hide view toolbar', 'View toolbar', None, checkable=True), 'view.edittool': a(self, 'Show or hide editing toolbar', 'Editing toolbar', None, checkable=True), 'view.addtool': a(self, 'Show or hide insert toolbar', 'Insert toolbar', None, checkable=True), 'data.import': a(self, 'Import data into Veusz', '&Import...', self.slotDataImport, icon='kde-vzdata-import'), 'data.edit': a(self, 'Edit existing datasets', '&Edit...', self.slotDataEdit, icon='kde-edit-veuszedit'), 'data.create': a(self, 'Create new datasets', '&Create...', self.slotDataCreate, icon='kde-dataset-new-veuszedit'), 'data.create2d': a(self, 'Create new 2D datasets', 'Create &2D...', self.slotDataCreate2D, icon='kde-dataset2d-new-veuszedit'), 'data.capture': a(self, 'Capture remote data', 'Ca&pture...', self.slotDataCapture, icon='veusz-capture-data'), 'data.histogram': a(self, 'Histogram data', '&Histogram...', self.slotDataHistogram, icon='button_bar'), 'data.reload': a(self, 'Reload linked datasets', '&Reload', self.slotDataReload, icon='kde-view-refresh'), 'help.home': a(self, 'Go to the Veusz home page on the internet', 'Home page', self.slotHelpHomepage), 'help.project': a(self, 'Go to the Veusz project page on the internet', 'GNA Project page', self.slotHelpProjectPage), 'help.bug': a(self, 'Report a bug on the internet', 'Suggestions and bugs', self.slotHelpBug), 'help.about': a(self, 'Displays information about the program', 'About...', self.slotHelpAbout, icon='veusz') } # create main toolbar tb = self.maintoolbar = qt4.QToolBar("Main toolbar - Veusz", self) iconsize = setdb['toolbar_size'] tb.setIconSize(qt4.QSize(iconsize, iconsize)) tb.setObjectName('veuszmaintoolbar') self.addToolBar(qt4.Qt.TopToolBarArea, tb) utils.addToolbarActions(tb, self.vzactions, ('file.new', 'file.open', 'file.save', 'file.print', 'file.export')) # data toolbar tb = self.datatoolbar = qt4.QToolBar("Data toolbar - Veusz", self) tb.setIconSize(qt4.QSize(iconsize, iconsize)) tb.setObjectName('veuszdatatoolbar') self.addToolBar(qt4.Qt.TopToolBarArea, tb) utils.addToolbarActions(tb, self.vzactions, ('data.import', 'data.edit', 'data.create', 'data.capture', 'data.reload')) # menu structure filemenu = [ 'file.new', 'file.open', ['file.filerecent', 'Open &Recent', []], '', 'file.save', 'file.saveas', '', 'file.print', 'file.export', '', 'file.close', 'file.quit' ] editmenu = [ 'edit.undo', 'edit.redo', '', ['edit.select', '&Select', []], '', 'edit.prefs', 'edit.stylesheet', 'edit.custom', '' ] viewwindowsmenu = [ 'view.edit', 'view.props', 'view.format', 'view.console', 'view.datanav', '', 'view.maintool', 'view.viewtool', 'view.addtool', 'view.edittool' ] viewmenu = [ ['view.viewwindows', '&Windows', viewwindowsmenu], '' ] insertmenu = [ ] # load dataset plugins and create menu datapluginsmenu = self.definePlugins( plugins.datasetpluginregistry, self.vzactions, 'data.ops' ) datamenu = [ ['data.ops', '&Operations', datapluginsmenu], 'data.import', 'data.edit', 'data.create', 'data.create2d', 'data.capture', 'data.histogram', 'data.reload', ] helpmenu = [ 'help.home', 'help.project', 'help.bug', '', 'help.about' ] # load tools plugins and create menu toolsmenu = self.definePlugins( plugins.toolspluginregistry, self.vzactions, 'tools' ) menus = [ ['file', '&File', filemenu], ['edit', '&Edit', editmenu], ['view', '&View', viewmenu], ['insert', '&Insert', insertmenu], ['data', '&Data', datamenu], ['tools', '&Tools', toolsmenu], ['help', '&Help', helpmenu], ] self.menus = {} utils.constructMenus(self.menuBar(), self.menus, menus, self.vzactions)
def createToolbar(self, parent, menu=None): """Make a view toolbar, and optionally update menu.""" self.viewtoolbar = qt4.QToolBar(_("View toolbar - Veusz"), parent) self.viewtoolbar.setObjectName('veuszviewtoolbar') iconsize = setting.settingdb['toolbar_size'] self.viewtoolbar.setIconSize(qt4.QSize(iconsize, iconsize)) self.viewtoolbar.hide() if parent: parent.addToolBar(qt4.Qt.TopToolBarArea, self.viewtoolbar) if parent and hasattr(parent, 'vzactions'): # share actions with parent if possible # as plot windows can be isolated from mainwindows, we need this self.vzactions = actions = parent.vzactions else: self.vzactions = actions = {} a = utils.makeAction actions.update({ 'view.zoomin': a(self, _('Zoom into the plot'), _('Zoom &In'), self.slotViewZoomIn, icon='kde-zoom-in', key='Ctrl++'), 'view.zoomout': a(self, _('Zoom out of the plot'), _('Zoom &Out'), self.slotViewZoomOut, icon='kde-zoom-out', key='Ctrl+-'), 'view.zoom11': a(self, _('Restore plot to natural size'), _('Zoom 1:1'), self.slotViewZoom11, icon='kde-zoom-1-veuszedit', key='Ctrl+1'), 'view.zoomwidth': a(self, _('Zoom plot to show whole width'), _('Zoom to width'), self.slotViewZoomWidth, icon='kde-zoom-width-veuszedit'), 'view.zoomheight': a(self, _('Zoom plot to show whole height'), _('Zoom to height'), self.slotViewZoomHeight, icon='kde-zoom-height-veuszedit'), 'view.zoompage': a(self, _('Zoom plot to show whole page'), _('Zoom to page'), self.slotViewZoomPage, icon='kde-zoom-page-veuszedit'), 'view.zoommenu': a(self, _('Zoom functions menu'), _('Zoom'), self.doZoomMenuButton, icon='kde-zoom-veuszedit'), 'view.prevpage': a(self, _('Move to the previous page'), _('&Previous page'), self.slotViewPreviousPage, icon='kde-go-previous', key='Ctrl+PgUp'), 'view.nextpage': a(self, _('Move to the next page'), _('&Next page'), self.slotViewNextPage, icon='kde-go-next', key='Ctrl+PgDown'), 'view.select': a(self, _('Select items from the graph or scroll'), _('Select items or scroll'), None, icon='kde-mouse-pointer'), 'view.pick': a(self, _('Read data points on the graph'), _('Read data points'), None, icon='veusz-pick-data'), 'view.zoomgraph': a(self, _('Zoom into graph'), _('Zoom graph'), None, icon='veusz-zoom-graph'), 'view.fullscreen': a(self, _('View plot full screen'), _('Full screen'), self.slotFullScreen, icon='veusz-view-fullscreen', key='Ctrl+F11'), }) if menu: # only construct menu if required menuitems = [ ('view', '', [ 'view.zoomin', 'view.zoomout', 'view.zoom11', 'view.zoomwidth', 'view.zoomheight', 'view.zoompage', '', 'view.prevpage', 'view.nextpage', 'view.fullscreen', '', 'view.select', 'view.pick', 'view.zoomgraph', ]), ] utils.constructMenus(menu, {'view': menu}, menuitems, actions) # populate menu on zoom menu toolbar icon zoommenu = qt4.QMenu(self) zoomag = qt4.QActionGroup(self) for act in ('view.zoomin', 'view.zoomout', 'view.zoom11', 'view.zoomwidth', 'view.zoomheight', 'view.zoompage'): a = actions[act] zoommenu.addAction(a) zoomag.addAction(a) a.vzname = act actions['view.zoommenu'].setMenu(zoommenu) self.connect(zoomag, qt4.SIGNAL('triggered(QAction*)'), self.zoomActionTriggered) lastzoom = setting.settingdb.get('view_defaultzoom', 'view.zoompage') self.updateZoomMenuButton(actions[lastzoom]) # add items to toolbar utils.addToolbarActions( self.viewtoolbar, actions, ('view.prevpage', 'view.nextpage', 'view.fullscreen', 'view.select', 'view.pick', 'view.zoomgraph', 'view.zoommenu')) # define action group for various different selection models grp = self.selectactiongrp = qt4.QActionGroup(self) grp.setExclusive(True) for a in ('view.select', 'view.pick', 'view.zoomgraph'): actions[a].setActionGroup(grp) actions[a].setCheckable(True) actions['view.select'].setChecked(True) self.connect(grp, qt4.SIGNAL('triggered(QAction*)'), self.slotSelectMode) return self.viewtoolbar