def handleContextMenu(self, item, pos, col): """ handleContextMenu(item, pos, col) -> display a context menu """ self.context = item title = '%s' % (item.ticker.symbol, ) pop = kdeui.KPopupMenu(self) pop.insertTitle(item.pixmap(0), title) position = item.ticker.current_data.get('position', 0) if position: label = i18n('&Close %s shares...' % (abs(position), )) pop.insertItem(label, self.closePosition) pop.insertSeparator() pop.insertItem(util.loadIconSet('chart'), i18n('&Chart...'), self.showChart) pop.insertItem(util.loadIconSet('kcalc'), i18n('&Order...'), self.handleOrderDialog) pop.insertSeparator() setups = enumerate(util.TickerUrl.request_defs) handler = self.requestBrowser for key, (label, icon, url) in setups: item = pop.insertItem(util.loadIconSet(icon), i18n(label), handler) pop.setItemParameter(item, key) pop.popup(pos)
def handleContextMenu(self, item, pos, col): """ handleContextMenu(item, pos, col) -> display a context menu """ self.context = item title = "%s" % (item.ticker.symbol,) pop = kdeui.KPopupMenu(self) pop.insertTitle(item.pixmap(0), title) position = item.ticker.current_data.get("position", 0) if position: label = i18n("&Close %s shares..." % (abs(position),)) pop.insertItem(label, self.closePosition) pop.insertSeparator() pop.insertItem(util.loadIconSet("chart"), i18n("&Chart..."), self.showChart) pop.insertItem(util.loadIconSet("kcalc"), i18n("&Order..."), self.handleOrderDialog) pop.insertSeparator() setups = enumerate(util.TickerUrl.request_defs) handler = self.requestBrowser for key, (label, icon, url) in setups: item = pop.insertItem(util.loadIconSet(icon), i18n(label), handler) pop.setItemParameter(item, key) pop.popup(pos)
def contextMenuEvent(self, event): """ contextMenuEvent(event) -> display context menu """ widget = self.childAt(event.pos()) children, labels, lcds = self.summaryChildren() if widget in lcds: key = lcds[widget] lcd = widget label = self.summaries[key][0] elif widget in labels: key = labels[widget] lcd = self.summaries[key][1] label = widget else: event.ignore() return pop = kdeui.KPopupMenu(self) self.context = (key, label, lcd) item = pop.insertItem(util.loadIconSet('up'), i18n('Move Up'), self.moveSummary) pop.setItemParameter(item, 0) if not children.index(label): pop.setItemEnabled(item, False) item = pop.insertItem(util.loadIconSet('down'), i18n('Move Down'), self.moveSummary) pop.setItemParameter(item, 1) if children.index(lcd) + 1 == len(children): pop.setItemEnabled(item, False) pop.insertSeparator() item = pop.insertItem(util.loadIconSet('remove'), i18n('Remove "%s"' % (key, )), self.removeSummary) pop.insertSeparator() for index, label, color in ((0, 'Background color...', lcd.paletteBackgroundColor()), (1, 'Foreground color...', lcd.paletteForegroundColor())): item = pop.insertItem('', self.selectColor) pixmap = qt.QPixmap(16, 16) pixmap.fill(color) icons = qt.QIconSet(pixmap) pop.changeItem(item, icons, i18n(label)) pop.setItemParameter(item, index) pop.insertSeparator() for label, style, icon in lcdStyles: item = pop.insertItem(util.loadIconSet(icon), i18n(label), self.selectSegmentStyle) pop.setItemParameter(item, style) pop.setItemChecked(item, style == lcd.segmentStyle()) pop.popup(event.globalPos())
def contextMenuEvent(self, event): """ contextMenuEvent(event) -> display context menu """ widget = self.childAt(event.pos()) children, labels, lcds = self.summaryChildren() if widget in lcds: key = lcds[widget] lcd = widget label = self.summaries[key][0] elif widget in labels: key = labels[widget] lcd = self.summaries[key][1] label = widget else: event.ignore() return pop = kdeui.KPopupMenu(self) self.context = (key, label, lcd) item = pop.insertItem(util.loadIconSet('up'), i18n('Move Up'), self.moveSummary) pop.setItemParameter(item, 0) if not children.index(label): pop.setItemEnabled(item, False) item = pop.insertItem(util.loadIconSet('down'), i18n('Move Down'), self.moveSummary) pop.setItemParameter(item, 1) if children.index(lcd) + 1 == len(children): pop.setItemEnabled(item, False) pop.insertSeparator() item = pop.insertItem(util.loadIconSet('remove'), i18n('Remove "%s"' % (key, )), self.removeSummary) pop.insertSeparator() for index, label, color in ( (0, 'Background color...', lcd.paletteBackgroundColor()), (1, 'Foreground color...', lcd.paletteForegroundColor())): item = pop.insertItem('', self.selectColor) pixmap = qt.QPixmap(16, 16) pixmap.fill(color) icons = qt.QIconSet(pixmap) pop.changeItem(item, icons, i18n(label)) pop.setItemParameter(item, index) pop.insertSeparator() for label, style, icon in lcdStyles: item = pop.insertItem(util.loadIconSet(icon), i18n(label), self.selectSegmentStyle) pop.setItemParameter(item, style) pop.setItemChecked(item, style==lcd.segmentStyle()) pop.popup(event.globalPos())
def setupActions(self): """ setupActions() -> create the action attributes for the widget """ config = util.appConfig() actions = self.actionCollection() stdaction = kdeui.KStdAction actions.readShortcutSettings(util.groups.shortcuts, config) self.newAction = stdaction.openNew(self.newSession, actions) self.newAction.setIconSet(util.loadIconSet('blockdevice')) self.newAction.setIcon('blockdevice') self.newAction.setText(i18n('New Session')) self.quitAction = stdaction.quit(self.close, actions) self.closeWindowAction = stdaction.close(self.closeDockWindow, actions) self.toggleMenubarAction = \ stdaction.showMenubar(self.showMenubar, actions) self.toggleToolbarAction = \ stdaction.showToolbar(self.showToolbar, actions) self.toggleStatusbarAction = \ stdaction.showStatusbar(self.showStatusbar, actions) self.configureKeysAction = \ stdaction.keyBindings(self.showConfigureKeys, actions) self.configureToolbarAction = \ stdaction.configureToolbars(self.showConfigureToolbars, actions) self.configureAppAction = \ stdaction.preferences(self.showConfiguration, actions) self.webBrowserAction = util.buildAction('web_browser', 'Web Browser', 'konqueror', 'Ctrl+B', 'Show a web browser window', actions) self.startTwsAction = util.buildAction('start_tws', 'Start TWS', 'exec', 'Ctrl+T', 'Start the TWS application', actions) self.connectTwsAction = util.buildAction('connect_tws', 'Connect to TWS', 'network', 'Ctrl+G', 'Connect to the TWS application', actions) sigAct = util.sigActivated self.connect(self.startTwsAction, sigAct, self.startTws) self.connect(self.connectTwsAction, sigAct, self.connectTws) self.connect(self.webBrowserAction, sigAct, util.invokeBrowser)
def setupActions(self): """ setupActions() -> create the action attributes for the widget """ config = util.appConfig() actions = self.actionCollection() stdaction = kdeui.KStdAction actions.readShortcutSettings(util.groups.shortcuts, config) self.newAction = stdaction.openNew(self.newSession, actions) self.newAction.setIconSet(util.loadIconSet("blockdevice")) self.newAction.setIcon("blockdevice") self.newAction.setText(i18n("New Session")) self.quitAction = stdaction.quit(self.close, actions) self.closeWindowAction = stdaction.close(self.closeDockWindow, actions) self.toggleMenubarAction = stdaction.showMenubar(self.showMenubar, actions) self.toggleToolbarAction = stdaction.showToolbar(self.showToolbar, actions) self.toggleStatusbarAction = stdaction.showStatusbar(self.showStatusbar, actions) self.configureKeysAction = stdaction.keyBindings(self.showConfigureKeys, actions) self.configureToolbarAction = stdaction.configureToolbars(self.showConfigureToolbars, actions) self.configureAppAction = stdaction.preferences(self.showConfiguration, actions) self.webBrowserAction = util.buildAction( "web_browser", "Web Browser", "konqueror", "Ctrl+B", "Show a web browser window", actions ) self.startTwsAction = util.buildAction( "start_tws", "Start TWS", "exec", "Ctrl+T", "Start the TWS application", actions ) self.connectTwsAction = util.buildAction( "connect_tws", "Connect to TWS", "network", "Ctrl+G", "Connect to the TWS application", actions ) sigAct = util.sigActivated self.connect(self.startTwsAction, sigAct, self.startTws) self.connect(self.connectTwsAction, sigAct, self.connectTws) self.connect(self.webBrowserAction, sigAct, util.invokeBrowser)