def __init__(self, parent, grp, records=None, nextLevels=None): super(XOrbGroupItem, self).__init__(parent) # define custom properties self._loaded = False self._recordSet = None self._nextLevels = nextLevels # set local properties self.setFixedHeight(22) self.setText(0, nativestring(grp)) self.setFirstColumnSpanned(True) self.setChildIndicatorPolicy(self.ShowIndicator) # setup the icons icon = QIcon(resources.find('img/treeview/folder.png')) expanded_icon = QIcon(resources.find('img/treeview/folder_open.png')) self.setIcon(0, icon) self.setExpandedIcon(0, expanded_icon) # load the records for this group if isinstance(records, RecordSet): self.setRecordSet(records) elif type(records) in (dict, list, tuple): self.loadRecords(records)
def showMenu(self): """ Creates a menu to display for the editing of template information. """ item = self.uiMenuTREE.currentItem() menu = QMenu(self) act = menu.addAction('Add Menu...') act.setIcon(QIcon(projexui.resources.find('img/folder.png'))) act.triggered.connect(self.createMenu) if (item and item.data(0, Qt.UserRole) == 'menu'): act = menu.addAction('Rename Menu...') ico = QIcon(projexui.resources.find('img/edit.png')) act.setIcon(ico) act.triggered.connect(self.renameMenu) act = menu.addAction('Add Separator') act.setIcon(QIcon(projexui.resources.find('img/ui/splitter.png'))) act.triggered.connect(self.createSeparator) menu.addSeparator() act = menu.addAction('Remove Item') act.setIcon(QIcon(projexui.resources.find('img/remove.png'))) act.triggered.connect(self.removeItem) act.setEnabled(item is not None) menu.exec_(QCursor.pos())
def loadFromXml(self, xml, basepath): if not basepath: return filepath = os.path.join(basepath, xml.get('url', '')) filepath = filepath.replace('\\', '/') title = xml.get('title').split('.')[-1] self._loaded = True self._filepath = filepath self._url = 'file:///' + filepath self._isFolder = len(xml) != 0 self.setText(0, title) self.setText(1, os.path.basename(os.path.splitext(filepath)[0])) self.TITLE_MAP[self._url] = title if self._isFolder: self.setIcon(0, QIcon(projexui.resources.find('img/folder.png'))) self.setExpandedIcon( 0, QIcon(projexui.resources.find('img/folder_open.png'))) else: self.setIcon(0, QIcon(projexui.resources.find('img/file.png'))) for xchild in xml: item = XdkEntryItem(self, '') item.loadFromXml(xchild, basepath)
def __init__(self, parent, filepath, title=None, folder=False): super(XdkEntryItem, self).__init__(parent) # set custom properties filepath = nativestring(filepath).replace('\\', '/') self._isFolder = folder self._filepath = filepath self._url = 'file:///' + filepath self._loaded = False self.setFixedHeight(22) # define custom properties if folder: self.setIcon(0, QIcon(projexui.resources.find('img/folder.png'))) self.setExpandedIcon( 0, QIcon(projexui.resources.find('img/folder_open.png'))) self.setChildIndicatorPolicy(self.ShowIndicator) else: self.setIcon(0, QIcon(projexui.resources.find('img/file.png'))) self._loaded = True if filepath: if title is not None: self.TITLE_MAP[self._url] = title self.setText(0, title) else: self.setText(0, self.titleForFilepath(self._url)) # set default properties self.setSizeHint(0, QSize(20, 18)) self.setText(1, os.path.basename(os.path.splitext(filepath)[0]))
def __init__(self, *args): super(XTabWidget, self).__init__(*args) # create the tab bar self.setTabBar(XTabBar(self)) # create custom properties self._showAddButton = True self._showOptionsButton = True # create the add button self._addButton = XTabButton(self) self._addButton.setIcon(QIcon(resources.find('img/tab/add.png'))) self._addButton.setFixedSize(18, 18) self._addButton.setIconSize(QSize(10, 10)) # create the option button self._optionsButton = XTabButton(self) self._optionsButton.setFixedSize(22, 18) self._optionsButton.setIcon(QIcon(resources.find('img/tab/gear.png'))) self._optionsButton.setIconSize(QSize(10, 10)) # create connection self.connect(self.tabBar(), SIGNAL('currentChanged(int)'), self.adjustButtons) self.connect(self.tabBar(), SIGNAL('resized()'), self.adjustButtons) self.connect(self._optionsButton, SIGNAL('clicked()'), self.emitOptionsRequested) self.connect(self._addButton, SIGNAL('clicked()'), self.emitAddRequested)
def setHoverIcon(self, icon): """ Sets the icon that will be used when this hotspot is hovered. :param icon | <QIcon> || None """ icon = QIcon(icon) if not icon.isNull(): self._hoverIcon = QIcon(icon) else: self._hoverIcon = None
def createActionItem(self, key): """ Creates a new action item for the inputed key. :param key | <str> :return <QTreeWidgetItem> """ action = self._actions.get(key) if (not action): text = 'Missing Action: %s' % key item = QTreeWidgetItem([text]) ico = projexui.resources.find('img/log/warning.png') item.setIcon(0, QIcon(ico)) else: item = QTreeWidgetItem( [nativestring(action.text()).replace('&', '')]) item.setIcon(0, action.icon()) item.setSizeHint(0, QSize(120, 20)) item.setData(0, Qt.UserRole, wrapVariant(key)) flags = item.flags() flags ^= Qt.ItemIsDropEnabled item.setFlags(flags) return item
def __init__(self, parent=None): super(XViewProfileManager, self).__init__(parent) # define custom properties self._profiles = [] self._optionsMenuPolicy = Qt.DefaultContextMenu self._viewWidget = None # define the interface self._profileCombo = QComboBox(self) self._optionsButton = QToolButton(self) self._optionsButton.setAutoRaise(True) self._optionsButton.setToolTip('Advanced Options') self._optionsButton.setIcon(QIcon(resources.find('img/advanced.png'))) layout = QHBoxLayout() layout.setSpacing(0) layout.setContentsMargins(0, 0, 0, 0) layout.addWidget(self._profileCombo) layout.addWidget(self._optionsButton) self.setLayout(layout) # create connections self._profileCombo.currentIndexChanged.connect( self.handleProfileChange) self._optionsButton.clicked.connect(self.showOptionsMenu)
def setIcon( self, icon ): """ Sets the icon that will be used for this widget's tool button. :param icon | <QIcon> || <str> """ self._filepathButton.setIcon(QIcon(icon))
def setIcon(self, icon): """ Sets the path to the icon for this profile to the given icon. :param icon | <str> || <QIcon> """ self._icon = QIcon(icon)
def __init__(self): self._icon = QIcon() self._name = '' self._version = 1.0 self._description = '' self._customData = DataSet() self._xmlElement = None
def __init__(self, parent): super(XUrlWidget, self).__init__(parent) # define the interface self._urlEdit = XLineEdit(self) self._urlButton = QToolButton(self) self._urlButton.setAutoRaise(True) self._urlButton.setIcon(QIcon(resources.find('img/web.png'))) self._urlButton.setToolTip('Browse Link') self._urlButton.setFocusPolicy(Qt.NoFocus) self._urlEdit.setHint('http://') layout = QHBoxLayout() layout.setContentsMargins(0, 0, 0, 0) layout.setSpacing(0) layout.addWidget(self._urlEdit) layout.addWidget(self._urlButton) self.setLayout(layout) self.setFocusPolicy(Qt.StrongFocus) # create connections self._urlEdit.textChanged.connect(self.urlChanged) self._urlEdit.textEdited.connect(self.urlEdited) self._urlButton.clicked.connect(self.browse)
def __init__(self, *args): super(XLineEdit, self).__init__(*args) palette = self.palette() hint_clr = palette.color(palette.Disabled, palette.Text) # set the hint property self._hint = '' self._hintPrefix = '' self._hintSuffix = '' self._spacer = '_' self._encoding = 'utf-8' self._hintColor = hint_clr self._buttonWidth = 0 self._cornerRadius = 0 self._currentState = XLineEdit.State.Normal self._inputFormat = XLineEdit.InputFormat.Normal self._selectAllOnFocus = False self._focusedIn = False self._useHintValue = True self._icon = QIcon() self._iconSize = QSize(14, 14) self._buttons = {} self.textChanged.connect(self.adjustText) self.returnPressed.connect(self.emitTextEntered)
def __init__(self, parent): super(XLocationWidget, self).__init__(parent) # define the interface self._locationEdit = XLineEdit(self) self._locationButton = QToolButton(self) self._urlTemplate = 'http://maps.google.com/maps?%(params)s' self._urlQueryKey = 'q' self._locationButton.setAutoRaise(True) self._locationButton.setIcon(QIcon(resources.find('img/map.png'))) self._locationEdit.setHint('no location set') layout = QHBoxLayout() layout.setContentsMargins(0, 0, 0, 0) layout.setSpacing(0) layout.addWidget(self._locationEdit) layout.addWidget(self._locationButton) self.setLayout(layout) # create connections self._locationEdit.textChanged.connect(self.locationChanged) self._locationEdit.textEdited.connect(self.locationEdited) self._locationButton.clicked.connect(self.browseMaps)
def __init__( self, plugin ): super(PluginItem, self).__init__([plugin.title()]) self.setFixedHeight(22) self.setIcon(0, QIcon(plugin.iconFile())) self._plugin = plugin self._widget = None
def thumbnail(self, record): """ Creates a new thumbnail for the inputed record. :param record | <orb.Table> :return <QIcon> """ return QIcon(projexui.resources.find('img/missing_large.png'))
def setItemStyle(self, itemStyle): """ Sets the item style that will be used for this widget. If you are trying to set a style on an item that has children, make sure to turn off the useGroupStyleWithChildren option, or it will always display as a group. :param itemStyle | <XGanttWidgetItem.ItemStyle> """ self._itemStyle = itemStyle # initialize the group icon for group style if itemStyle == XGanttWidgetItem.ItemStyle.Group and \ self.icon(0).isNull(): ico = projexui.resources.find('img/folder_close.png') expand_ico = projexui.resources.find('img/folder_open.png') self.setIcon(0, QIcon(ico)) self.setExpandedIcon(0, QIcon(expand_ico))
def setIcon(self, icon): """ Sets the icon that will be used for this widget to the inputed icon. :param icon | <QIcon> || None """ self._icon = QIcon(icon) self.adjustStyleSheet()
def setupActions(self): viewWidget = self.viewWidget() self.setTitle('Add View') # collect the views and groups sorter = lambda x: x.viewGroup() + '/' + x.viewName() views = sorted(viewWidget.viewTypes(), key=sorter) grps = set([view.viewGroup() for view in views]) # for a non-hierarchical view setup, just add the views to this menu if len(grps) <= 1: for view in views: act = self.addAction(view.viewName()) act.setIcon(QIcon(view.viewIcon())) # otherwise, add the views to a submenu system else: self.addSearchAction() self.addSeparator() menus = {} for view in views: # separate the grouping levels for grp in view.viewGroup().split(';'): parts = grp.split('/') menu = self for i, part in enumerate(parts): key = ('/'.join(parts[:i]) + '/' + part).strip('/') menu = menus.get(key) if not menu: ico = QIcon(resources.find('img/folder.png')) parent_key = '/'.join(parts[:i]).strip('/') parent = menus.get(parent_key, self) menu = parent.addMenu(part) menu.setIcon(ico) menus[key] = menu # add to the last item act = menu.addAction(view.viewName()) act.setIcon(QIcon(view.viewIcon())) self.triggered.connect(self.addView) self.addSeparator()
def __init__(self, manager): super(XViewProfileManagerMenu, self).__init__(manager) # create actions act = self.addAction('Save Profile') act.setIcon(QIcon(resources.find('img/save.png'))) act.setEnabled(manager.currentProfile() is not None) act.triggered.connect(self.saveProfile) act = self.addAction('Save Profile as...') act.setIcon(QIcon(resources.find('img/save_as.png'))) act.setEnabled(manager.viewWidget() is not None) act.triggered.connect(self.saveProfileAs) self.addSeparator() act = self.addAction('Remove Profile') act.setIcon(QIcon(resources.find('img/remove.png'))) act.setEnabled(manager.currentProfile() is not None) act.triggered.connect(self.removeProfile)
def setFilepath( self, filepath ): """ Sets the filepath for this button to the inputed path. :param filepath | <str> """ self._filepath = nativestring(filepath) self.setIcon(QIcon(filepath)) if ( not self.signalsBlocked() ): self.filepathChanged.emit(filepath)
def __init__(self, parent=None): super(XCommentEdit, self).__init__(parent) # define custom properties self._attachments = {} self._showAttachments = True # create toolbar self._toolbar = QToolBar(self) self._toolbar.setMovable(False) self._toolbar.setFixedHeight(30) self._toolbar.setAutoFillBackground(True) self._toolbar.setFocusProxy(self) self._toolbar.hide() # create toolbar buttons self._attachButton = QToolButton(self) self._attachButton.setIcon(QIcon(resources.find('img/attach.png'))) self._attachButton.setToolTip('Add Attachment') self._attachButton.setAutoRaise(True) self._attachButton.setIconSize(QSize(24, 24)) self._attachButton.setFixedSize(26, 26) self._submitButton = QPushButton(self) self._submitButton.setText('Submit') self._submitButton.setFocusProxy(self) # create attachments widget self._attachmentsEdit = XMultiTagEdit(self) self._attachmentsEdit.setAutoResizeToContents(True) self._attachmentsEdit.setFrameShape(XMultiTagEdit.NoFrame) self._attachmentsEdit.setViewMode(XMultiTagEdit.ListMode) self._attachmentsEdit.setEditable(False) self._attachmentsEdit.setFocusProxy(self) self._attachmentsEdit.hide() # define toolbar layout spacer = QWidget(self) spacer.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred) self._attachAction = self._toolbar.addWidget(self._attachButton) self._toolbar.addWidget(spacer) self._toolbar.addWidget(self._submitButton) # set standard properties self.setAutoResizeToContents(True) self.setHint('add comment') self.setFocusPolicy(Qt.StrongFocus) self.setRequireShiftForNewLine(True) # create connections self._attachButton.clicked.connect(self.attachmentRequested) self._submitButton.clicked.connect(self.acceptText) self._attachmentsEdit.tagRemoved.connect(self.removeAttachment) self.focusChanged.connect(self.setToolbarVisible)
def __init__(self, xdk_filename): # create the new XdkItem super(XdkItem, self).__init__(None, xdk_filename) # creates the new XdkItem basename = os.path.basename(nativestring(xdk_filename)) name = os.path.splitext(basename)[0] temppath = nativestring(QDir.tempPath()) temp_path = os.path.join(temppath, 'xdk/%s' % name) # define custom properties self._tempFilepath = temp_path self._searchurls = {} # set the options self.setChildIndicatorPolicy(self.ShowIndicator) self.setIcon(0, QIcon(projexui.resources.find('img/sdk.png'))) toc_file = os.path.join(temp_path, 'toc.xml') toc_xml = None if toc_file: try: toc_xml = ElementTree.parse(toc_file).getroot()[0] except: pass if toc_xml is not None: self._url = 'file:///%s/index.html' % temp_path.strip('/') self.setText(0, toc_xml.get('title', self.text(0))) self.loadFromXml(toc_xml, temp_path) else: # load the url information for this entry for name in sorted(os.listdir(temp_path)): # ignore 'hidden' folders if name.startswith('_') and not name.startswith('__'): continue # ignore special cases (only want modules for this) if '-' in name or name == 'toc.xml': continue # use the index or __init__ information if name == '__init__.html': self._url = 'file:///%s/%s' % (temp_path, name) continue elif name == 'index.html': self._url = 'file:///%s/%s' % (temp_path, name) # otherwise, load a childitem filepath = os.path.join(temp_path, name) folder = os.path.isdir(filepath) XdkEntryItem(self, filepath, folder=folder)
def buildIcon(icon): """ Builds an icon from the inputed information. :param icon | <variant> """ if icon is None: return QIcon() if type(icon) == buffer: try: icon = QIcon(projexui.generatePixmap(icon)) except: icon = QIcon() else: try: icon = QIcon(icon) except: icon = QIcon() return icon
def setPlugins( self, plugins ): """ Loads the plugins for the inputed dialog. :param plugins | [<XWizardPlugin>, ..] """ langs = {} icons = {} for plugin in plugins: wlang = plugin.wizardType() wgrp = plugin.wizardGroup() langs.setdefault(wlang, {}) langs[wlang].setdefault(wgrp, []) langs[wlang][wgrp].append( plugin ) icons.setdefault(wgrp, plugin.groupIcon(wgrp)) self._plugins = langs self.blockSignals(True) self.setUpdatesEnabled(False) self.uiPluginTREE.clear() folder = QIcon(projexui.resources.find('img/folder_32.png')) for wlang in sorted(langs.keys()): langitem = XTreeWidgetItem(self.uiPluginTREE, [wlang]) langitem.setFixedHeight(28) langitem.initGroupStyle() langitem.setExpanded(True) for wgrp in sorted(langs[wlang].keys()): grpitem = XTreeWidgetItem(langitem, [wgrp]) grpitem.setIcon(0, QIcon(icons[wgrp])) grpitem.setFixedHeight(26) self.blockSignals(False) self.setUpdatesEnabled(True)
def setIcon(self, icon): """ Sets the icon for this hotspot. If this method is called with a valid icon, then the style will automatically switch to Icon, otherwise, the style will be set to Invisible. :param icon | <QIcon> || <str> || None """ icon = QIcon(icon) if icon.isNull(): self._icon = None self._style = XNodeHotspot.Style.Invisible else: self._icon = icon self._style = XNodeHotspot.Style.Icon
def createMenuItem(self, title): """ Creates a new menu item with the given title. :param title | <str> :return <QTreeWidgetItem> """ item = QTreeWidgetItem([title]) ico = projexui.resources.find('img/folder.png') item.setIcon(0, QIcon(ico)) item.setSizeHint(0, QSize(120, 20)) item.setData(0, Qt.UserRole, wrapVariant('menu')) return item
def __init__(self, parent, column): super(XOrbColumnItem, self).__init__(parent) # set custom options self._column = column self._loaded = False if column.isReference(): self.setChildIndicatorPolicy(self.ShowIndicator) # set default options typ = column.columnTypeText(baseOnly=True) ico = 'img/orb/coltypes/%s.png' % typ.lower() self.setText(0, column.name().strip('_')) self.setIcon(0, QIcon(resources.find(ico))) self.setFixedHeight(20)
def __init__( self, parent = None ): super(XFilepathEdit, self).__init__( parent ) # define custom properties self._validated = False self._validForeground = QColor(0, 120, 0) self._validBackground = QColor(0, 120, 0, 100) self._invalidForeground = QColor(255, 0, 0) self._invalidBackground = QColor(255, 0, 0, 100) self._normalizePath = False self._filepathMode = XFilepathEdit.Mode.OpenFile self._filepathEdit = XLineEdit(self) self._filepathButton = QToolButton(self) self._filepathTypes = 'All Files (*.*)' # set default properties ico = projexui.resources.find('img/folder.png') self._filepathEdit.setReadOnly(False) self._filepathEdit.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) self._filepathButton.setText('...') self._filepathButton.setFixedSize(25, 23) self._filepathButton.setAutoRaise(True) self._filepathButton.setIcon(QIcon(ico)) self._filepathEdit.setContextMenuPolicy(Qt.CustomContextMenu) self.setWindowTitle('Load File') self.setAcceptDrops(True) # define the layout layout = QHBoxLayout() layout.setContentsMargins(0, 0, 0, 0) layout.setSpacing(0) layout.addWidget(self._filepathEdit) layout.addWidget(self._filepathButton) self.setLayout(layout) # create connections self._filepathEdit.installEventFilter(self) self._filepathButton.clicked.connect( self.pickFilepath ) self._filepathEdit.textChanged.connect( self.emitFilepathChanged ) self._filepathEdit.textChanged.connect( self.validateFilepath ) self._filepathEdit.customContextMenuRequested.connect( self.showMenu )
def __init__(self, parent, action): super(XSearchActionWidget, self).__init__(parent) # define custom properties self._initialized = False self._triggerText = '' # define the interface self._searchEdit = XLineEdit(self) self._searchEdit.setIcon(QIcon(resources.find('img/search.png'))) self._searchEdit.setHint('enter search') self._searchEdit.setFixedHeight(24) # define the completer self._completer = XTreeWidget(self) self._completer.setHint('No actions were found.') self._completer.setWindowFlags(Qt.Popup) self._completer.setRootIsDecorated(False) self._completer.header().hide() self._completer.setSortingEnabled(True) self._completer.sortByColumn(0, Qt.AscendingOrder) self._completer.installEventFilter(self) self._completer.setFocusProxy(self._searchEdit) self._completer.setShowGrid(False) self._completer.setFrameShape(XTreeWidget.Box) self._completer.setFrameShadow(XTreeWidget.Plain) # match the look for the completer to the menu palette = self._completer.palette() palette.setColor(palette.Base, palette.color(palette.Window)) palette.setColor(palette.Text, palette.color(palette.WindowText)) palette.setColor(palette.WindowText, palette.color(palette.Mid)) self._completer.setPalette(palette) # create the layout layout = QHBoxLayout() layout.setContentsMargins(4, 4, 4, 4) layout.addWidget(self._searchEdit) self.setLayout(layout) # create connections self._searchEdit.textChanged.connect(self.filterOptions) self._completer.itemClicked.connect(self.triggerItem) parent.aboutToShow.connect(self.aboutToShow)