def __addDataTypeIconSlot(self): """ Edits the selected data type. """ item = self.dataTypeBrowser.selectedItem() if not item is None: dataType = self.repositoryConfiguration.getDataType( unicode(item.text(0))) title = dataType.name iconSet = QIconSet(utils.getPixmapForImageName(dataType.iconName)) if not self._isNodeExisting(title): iconSet = QIconSet( utils.getPixmapForImageName(dataType.iconName)) self.iconView.addDataTypeIcon(title, iconSet) self.__logger.info("Data Type %s was successfully loaded." % title) else: self.iconView.markDataTypeIcon(title)
def _setNodeIcon(self): """ Sets the node icon. """ pixmap = utils.getPixmapForImageName(self._dataTypeModel.myIconName) mask = QPixmap.fromMimeSource(u"newMask16.png") pixmap.setMask(mask.createHeuristicMask()) icon = QIconSet(pixmap) self._parentFrame.changeIconPixmap(icon, self.title, self._dataTypeModel.myTitle)
def __init__(self, *args): apply(KSystemTray.__init__, (self, ) + args) ''' comarInterface instance ''' self.comarInterface = comarInterface(self.winId()) ''' wirelessInterface instance ''' self.wirelessInterface = wirelessInterface() ''' dcopInterface instance''' self.dcopInterface = dcopInterface(self.wirelessInterface) ''' Add /usr/share/PyWireless to KStandardDirs ''' self.KStandardDirs = KStandardDirs() self.KStandardDirs.addResourceDir('icon', '/usr/share/PyWireless') ''' Create tray icon Loader ''' self.icons = KIconLoader('PyWireless', self.KStandardDirs) ''' Timer event triggered every 3 second Until i found a way to use inotify or libfam ''' self.time = QTimer(self) self.connect(self.time, SIGNAL('timeout()'), self.timeoutSlot) self.time.start(3000) self.connect(app, SIGNAL("shutDown()"), self.slotQuit) ''' Popup Menu ''' connectionsMenu = KPopupMenu(self.contextMenu()) ''' list all connections into Connections menu ''' for entry in self.comarInterface.listConnections(): if self.comarInterface.isActive(entry): id = connectionsMenu.insertItem( QIconSet( self.icons.loadIcon('wireless-online', KIcon.Desktop, 16)), entry) else: id = connectionsMenu.insertItem( QIconSet( self.icons.loadIcon('wireless-offline', KIcon.Desktop, 16)), entry) self.connect(connectionsMenu, SIGNAL("activated(int)"), self.switchConnection) self.contextMenu().insertItem(_('Wireless Connections Profiles'), connectionsMenu) # FIXME: Use net-kga self.contextMenu().insertItem(_('Create New Wireless Connection')) self.show()
def __init__(self, pluginContext): parentMenu = pluginContext.getPulldownMenu( 4) # should be the Tools menu self.typeMenu = QPopupMenu(parentMenu) iconWrapper = QIconSet(SearchByItemTypePlugin.resultIcon) parentMenu.insertItem(iconWrapper, _('Find Items By Type'), self.typeMenu) parentMenu.connect(self.typeMenu, SIGNAL('activated(int)'), self.doSearch) self.context = pluginContext self.context.setFileOpenCallback(self.updateTypeMenu)
def switchConnection(self, int): connection = self.contextMenu().text(int) if self.comarInterface.isActive(connection): ''' if selected is active then down it ''' self.comarInterface.deactivateConnection(connection) self.contextMenu().changeItem( int, QIconSet( self.icons.loadIcon('wireless-offline', KIcon.Desktop, 16)), self.contextMenu().text(int)) else: ''' if selected is not active then first down active one, up selected one ''' self.comarInterface.deactivateConnection( self.comarInterface.activeConnection()) self.comarInterface.activateConnection(connection) self.contextMenu().changeItem( int, QIconSet( self.icons.loadIcon('wireless-online', KIcon.Desktop, 16)), self.contextMenu().text(int))
def SimpleButton(parent, title, handler, page=None, image=None): tabpage = parent.getPage(page) button = QPushButton(tabpage) if image: bi = QPixmap() bi.loadFromData(image, "PNG") button.setIconSet(QIconSet(bi)) w = bi.width() + 3 h = bi.height() + 3 if w < 32: w = 32 if h < 32: h = 32 button.setMaximumSize(QSize(w, h)) else: button.setText(title) QToolTip.add(button, title) parent.connect(button, SIGNAL("clicked()"), handler) button.show() p = ToolbarPlugin(parent) p.getWidget = lambda: button
def initContextMenu(self, context): """ Initiates the popup menu depending on the context and adds appropriate menu items. """ #ACTION TO ARRANGE THE ICONS IN A LINE arrangeIcons01Action = QAction("Lines", QKeySequence(), self, "arrangeIcons01Actions") arrangeIcons01Action.setIconSet(QIconSet()) self.connect(arrangeIcons01Action, SIGNAL("activated()"), self.parent().arrangeIconsInLines) #ACTION TO ARRANGE THE ICONS IN A CIRCLE arrangeIcons02Action = QAction("Circle", QKeySequence(), self, "arrangeIcons02Actions") arrangeIcons02Action.setIconSet(QIconSet()) self.connect(arrangeIcons02Action, SIGNAL("activated()"), self.parent().arrangeIconsInCircle) #SUBMENU TO CHOOSE THE WAY OF ARRANGEMENT #---------------------------------------- subMenu01 = QPopupMenu(self, "Arrange Icons") arrangeIcons01Action.addTo(subMenu01) arrangeIcons02Action.addTo(subMenu01) #ACTION TO UPDATE THE SCREEN updateCanvasViewAction = QAction("Update Screen", QKeySequence(), self, "updateCanvasViewAction") updateCanvasViewAction.setIconSet(QIconSet()) self.connect(updateCanvasViewAction, SIGNAL("activated()"), self.parent().updateCanvasView) #ACTION TO ADD A NEW DATATYPE newDataTypeAction = QAction("New Data Type...", QKeySequence(), self, "newDataTypeAction") newDataTypeAction.setIconSet( QIconSet(QPixmap.fromMimeSource("newDataType16.png"))) self.connect(newDataTypeAction, SIGNAL("activated()"), self.myFrame.addDataTypeSlot) #ACTION TO ADD A NEW RELATIONTYPE newRelationTypeAction = QAction("New Relation Type...", QKeySequence(), self, "newRelationTypeAction") newRelationTypeAction.setIconSet( QIconSet(QPixmap.fromMimeSource("newRelationType16.png"))) self.connect(newRelationTypeAction, SIGNAL("activated()"), self.myFrame.addRelationTypeSlot) #ACTION TO EDIT THE MARKED DATATYPE editDataTypeAction = QAction("Edit Data Type...", QKeySequence(), self, "editDataTypeAction") editDataTypeAction.setIconSet( QIconSet(QPixmap.fromMimeSource("edit16.png"))) #ACTION TO EDIT THE MARKED RELATIONTYPE editRelationTypeAction = QAction("Edit Relation Type...", QKeySequence(), self, "editRelationTypeAction") editRelationTypeAction.setIconSet( QIconSet(QPixmap.fromMimeSource("edit16.png"))) #ACTION TO REMOVE THE MARKED ICON FROM SCREEN removeIconAction = QAction("Remove Icon", QKeySequence(), self, "removeIconAction") removeIconAction.setIconSet( QIconSet(QPixmap.fromMimeSource("delete16.png"))) self.connect(removeIconAction, SIGNAL("activated()"), self.parent().removeIcon) #ACTION TO DELETE THE MARKED DATATYPEICON deleteDataTypeAction = QAction("Delete Data Type", QKeySequence(), self, "deleteDataTypeAction") deleteDataTypeAction.setIconSet( QIconSet(QPixmap.fromMimeSource("delete16.png"))) self.connect(deleteDataTypeAction, SIGNAL("activated()"), self.myFrame.deleteSelectedDataType) #ACTION TO DELETE THE MARKED RELATIONTYPE deleteRelationTypeAction = QAction("Delete Relation Type", QKeySequence(), self, "deleteRelationTypeAction") deleteRelationTypeAction.setIconSet( QIconSet(QPixmap.fromMimeSource("delete16.png"))) self.connect(deleteRelationTypeAction, SIGNAL("activated()"), self.myFrame.deleteSelectedRelationType) #CONTEXT-MENU IF NOTHING IS MARKED if context == 0: newDataTypeAction.addTo(self) newRelationTypeAction.addTo(self) self.insertSeparator() self.insertItem("Arrange Icons...", subMenu01) updateCanvasViewAction.addTo(self) else: #CONTEXT-MENU IF A DATATYPE IS MARKED if context.iconType == 1: dataTypeController = data_type_dialog.DataTypeController( self.myFrame, context.iconLabel, self.myFrame.repositoryConfiguration) self.connect(editDataTypeAction, SIGNAL("activated()"), dataTypeController.show) editDataTypeAction.addTo(self) deleteDataTypeAction.addTo(self) self.insertSeparator() newDataTypeAction.addTo(self) newRelationTypeAction.addTo(self) self.insertSeparator() removeIconAction.addTo(self) self.insertItem("Arrange Icons...", subMenu01) updateCanvasViewAction.addTo(self) #CONTEXT-MENU IF A RELATIONTYPE IS MARKED if context.iconType == 2: relationTypeController = relation_type_dialog.RelationTypeController( self.myFrame, context.iconLabel, self.myFrame.repositoryConfiguration) self.connect(editRelationTypeAction, SIGNAL("activated()"), relationTypeController.show) editRelationTypeAction.addTo(self) deleteRelationTypeAction.addTo(self) self.insertSeparator() newDataTypeAction.addTo(self) newRelationTypeAction.addTo(self) self.insertSeparator() removeIconAction.addTo(self) self.insertItem("Arrange Icons...", subMenu01) updateCanvasViewAction.addTo(self)
def __init_toolbar(self): """Inicializa la toolbar""" self.__boton1 = QToolButton(self.Toolbar) self.__boton1.setTextLabel("ABRIR") iconos = QIconSet() iconos.setIconSize(QIconSet.Small, QSize(100, 100)) iconos.setPixmap(self.__gestortemas.icono_abrir(), QIconSet.Small) # iconos.setPixmap("images/flechaabajo.png", QIconSet.Automatic, QIconSet.Normal, QIconSet.Off) self.__boton1.setOn(True) self.__boton1.setIconSet(iconos) self.__boton2 = QToolButton(self.Toolbar) self.__boton2.setTextLabel("GUARDAR") iconos = QIconSet() iconos.setIconSize(QIconSet.Small, QSize(100, 100)) iconos.setPixmap(self.__gestortemas.icono_guardar(), QIconSet.Small) self.__boton2.setOn(True) self.__boton2.setIconSet(iconos) self.__boton3 = QToolButton(self.Toolbar) self.__boton3.setTextLabel("Ventana Salida") iconos = QIconSet() iconos.setIconSize(QIconSet.Small, QSize(100, 100)) iconos.setPixmap(self.__gestortemas.icono_nueva_ventana(), QIconSet.Small) self.__boton3.setOn(True) self.__boton3.setIconSet(iconos) self.__boton4 = QToolButton(self.Toolbar) self.__boton4.setTextLabel("Mostrar etiquetas") self.__boton4.setToggleButton(True) iconos = QIconSet() iconos.setIconSize(QIconSet.Small, QSize(100, 100)) iconos.setPixmap(self.__gestortemas.icono_etiquetas(), QIconSet.Small) self.__boton4.setIconSet(iconos)
def __inittoolbar(self): """Inicializa la toolbar""" self.__boton1 = QToolButton(self.Toolbar) self.__boton1.setTextLabel("Abrir fichero") iconos = QIconSet() iconos.setIconSize(QIconSet.Small, QSize(100, 100)) iconos.setPixmap(self.__gestortemas.icono_abrir(), QIconSet.Small) self.__boton1.setOn(True) self.__boton1.setIconSet(iconos) self.__boton2 = QToolButton(self.Toolbar) self.__boton2.setTextLabel("Guardar en fichero") iconos = QIconSet() iconos.setIconSize(QIconSet.Small, QSize(100, 100)) iconos.setPixmap(self.__gestortemas.icono_guardar(), QIconSet.Small) self.__boton2.setOn(True) self.__boton2.setIconSet(iconos) self.__boton3 = QToolButton(self.Toolbar) self.__boton3.setTextLabel("Exportar a html") iconos = QIconSet() iconos.setIconSize(QIconSet.Small, QSize(100, 100)) iconos.setPixmap(self.__gestortemas.icono_exportar(), QIconSet.Small) self.__boton3.setOn(True) self.__boton3.setIconSet(iconos) self.__boton4 = QToolButton(self.Toolbar) self.__boton4.setTextLabel("Mostrar Ventana principal") iconos = QIconSet() iconos.setIconSize(QIconSet.Small, QSize(100, 100)) iconos.setPixmap(self.__gestortemas.icono_nueva_ventana(), QIconSet.Small) self.__boton4.setOn(True) self.__boton4.setIconSet(iconos)
def __init__(self, repositoryManager): """ Constructor. """ # Init GUI AdminWindow.__init__(self) # set icon in window-title: self.setIcon(QPixmap.fromMimeSource("DF_Logo_24x24.png")) iconSet = QIconSet(QPixmap.fromMimeSource("dataType16.png")) self.dataNavigator.setTabIconSet(self.dataTypes, iconSet) iconSet = QIconSet(QPixmap.fromMimeSource("relationType16.png")) self.dataNavigator.setTabIconSet(self.relationTypes, iconSet) iconSet = QIconSet(QPixmap.fromMimeSource("dataStore16.png")) self.dataNavigator.setTabIconSet(self.dataStores, iconSet) logger_handler.installGuiLoggingHandler(self.__logger, self.logList) self.myStatusBar = self.statusBar() self.statusLabel1 = QLabel("DataFinder", self.myStatusBar) self.statusLabel2 = QLabel("OK", self.myStatusBar) self.myStatusBar.addWidget(self.statusLabel1, 80) self.myStatusBar.addWidget(self.statusLabel2, 20) self.statusLabel1.show() self.statusLabel2.show() self.myStatusBar.show() # prepare "About"-dialog: self.dfAboutDialog = about_dialog.AboutDialog() self.dfAboutDialog.setPixmap( QPixmap.fromMimeSource("about_datafinder_admin.png")) # Login-dialog: self.dfLoginDialog = login_dialog.LoginDialog( repositoryManager.preferences, parent=self, showurl=True) # IconView: propertyPanelLayout = QGridLayout(self.propertyPanel, 1, 1, 2, 6, "propertyPanelLayout") self.iconView = canvas_view.CanvasView(self.propertyPanel, self, "iconView", 0) propertyPanelLayout.addWidget(self.iconView, 0, 0) self.iconViewCanvas = self.iconView.canvas() self.connect(self.dfLoginDialog.okPushButton, PYSIGNAL("updateWebdavServerView"), self.updateWebdavServerSlot) self.connect(self.dataTypeBrowser, SIGNAL("doubleClicked(QListViewItem*)"), self.__addDataTypeIconSlot) self.connect(self.relationTypeBrowser, SIGNAL("doubleClicked(QListViewItem*)"), self.__addRelationTypeIconSlot) self.connect(self.dataStoreBrowser, SIGNAL("clicked(QListViewItem*)"), self.iconView.updateCanvasView) self.connect(self.dataStoreBrowser, SIGNAL("doubleClicked(QListViewItem*)"), self.editSlot) # Init model self._repositoryManager = repositoryManager self.repositoryConfiguration = None self._preferences = self._repositoryManager.preferences self._lastUploadDirectory = os.path.expanduser("~") self._dataTypes = list() self._relationTypes = list() self._dataStores = list() self.__setConnectionState(False)