def getPixmapForImageName(name, smallIcon=True): """ Returns the pixmap for the given name. If the pixmap can not be found a default icons will be returned. @param name: Name of the image. @type name: C{unicode} @param smallIcon: Flag indicating whether a small icon (16 pixels) or a large icon (24 pixels) is required. @type smallIcon: C{bool} @return: The Qt pixmap. @rtype: L{QPixmap<qt.QPixmap>} """ result = None if not name is None: if smallIcon: name += "16.png" else: name += "24.png" result = QPixmap.fromMimeSource(name) if result is None or result.isNull(): if smallIcon: result = QPixmap.fromMimeSource(_defaultSmallIconName) else: result = QPixmap.fromMimeSource(_defaultLargeIconName) return result
def __init__(self, icnPxmp, icnLbl, icnCnvs): """ Constructor.""" QCanvasRectangle.__init__(self, icnCnvs) self.isMarked = 0 self.partialRelations = [] self.iconType = 0 self.iconLabel = icnLbl self.iconLabelWidth = 0 self.iconLabelHeight = 0 self.iconPainterWidth = 0 self.iconPixmap = icnPxmp self.iconImage = None self.scaleMaskUnmarked = QPixmap.convertToImage( QPixmap.fromMimeSource("layer01.png")) self.scaleMaskMarked = QPixmap.convertToImage( QPixmap.fromMimeSource("layer02.png")) self.scaleMaskHighlight = QPixmap.convertToImage( QPixmap.fromMimeSource("layer03.png")) self.scaledMaskUnmarked = self.scaleMaskUnmarked self.scaledMaskMarked = self.scaleMaskMarked self.scaledMaskHighlight = self.scaleMaskHighlight self.setIconPixmap(icnPxmp) self.setIconLabel(self.iconLabel)
def __init__(self, icnPxmp, icnLbl, icnCnvs): """ Constructor.""" QCanvasRectangle.__init__(self, icnCnvs) self.isMarked = 0 self.partialRelations = [] self.iconType = 0 self.iconLabel = icnLbl self.iconLabelWidth = 0 self.iconLabelHeight = 0 self.iconPainterWidth = 0 self.iconPixmap = icnPxmp self.iconImage = None self.scaleMaskUnmarked = QPixmap.convertToImage(QPixmap.fromMimeSource("layer01.png")) self.scaleMaskMarked = QPixmap.convertToImage(QPixmap.fromMimeSource("layer02.png")) self.scaleMaskHighlight = QPixmap.convertToImage(QPixmap.fromMimeSource("layer03.png")) self.scaledMaskUnmarked = self.scaleMaskUnmarked self.scaledMaskMarked = self.scaleMaskMarked self.scaledMaskHighlight = self.scaleMaskHighlight self.setIconPixmap(icnPxmp) self.setIconLabel(self.iconLabel)
def showSplash(splashImageName): """ Function which shows a nice splash screen. @param splashImageName: Name of the splash screen image. @type splashImageName: C{unicode} """ screen = QApplication.desktop().screenGeometry() if not _haveImagesAsModule: addQtImagePath(constants.LOCAL_INSTALLED_ICONS_DIRECTORY_PATH) dfPicture = QPixmap.fromMimeSource(splashImageName) dfSplash = QLabel(None, "splash", Qt.WDestructiveClose | Qt.WStyle_Customize | Qt.WStyle_NoBorder |\ Qt.WX11BypassWM | Qt.WStyle_StaysOnTop) dfSplash.setFrameStyle(QFrame.WinPanel | QFrame.Raised) dfSplash.setPixmap(dfPicture) dfSplash.setCaption("DataFinder") dfSplash.setAutoResize(1) dfSplash.move( QPoint(screen.center().x() - dfSplash.width() / 2, screen.center().y() - dfSplash.height() / 2)) dfSplash.show() dfSplash.repaint(0) QApplication.flush() return dfSplash
def showSplash(splashImageName): """ Function which shows a nice splash screen. @param splashImageName: Name of the splash screen image. @type splashImageName: C{unicode} """ screen = QApplication.desktop().screenGeometry() if not _haveImagesAsModule: addQtImagePath(constants.LOCAL_INSTALLED_ICONS_DIRECTORY_PATH) dfPicture = QPixmap.fromMimeSource(splashImageName) dfSplash = QLabel(None, "splash", Qt.WDestructiveClose | Qt.WStyle_Customize | Qt.WStyle_NoBorder |\ Qt.WX11BypassWM | Qt.WStyle_StaysOnTop) dfSplash.setFrameStyle(QFrame.WinPanel | QFrame.Raised) dfSplash.setPixmap(dfPicture) dfSplash.setCaption("DataFinder") dfSplash.setAutoResize(1) dfSplash.move(QPoint(screen.center().x() - dfSplash.width() / 2, screen.center().y() - dfSplash.height() / 2)) dfSplash.show() dfSplash.repaint(0) QApplication.flush() return dfSplash
def getIconName(self, iconList, preselected=None): """ Show and handle dialog, and return name of selected icon. @param iconList: List of icons. @type iconList: List of strings. @param preselected: name of icon selected when opening dialog (opt.) @type preselected: C{String} @return: The selected items. @rtype: C{list} of C{unicode}. """ self.iconListBox.clear() iconList.sort() for icon in iconList: pixmap = QPixmap.fromMimeSource(icon.largeName) self.iconListBox.insertItem(pixmap, icon.baseName, -1) if preselected: preselectedItem = self.iconListBox.findItem(preselected, Qt.ExactMatch | Qt.CaseSensitive) if preselectedItem != 0: self.iconListBox.setSelected(preselectedItem, True) self.exec_loop() result = list() if self.button == "ok": for index in range(0, self.iconListBox.numRows()): item = self.iconListBox.item(index) if item.isSelected(): result.append(unicode(item.text())) return result
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 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 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__(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)
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)