示例#1
0
 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)
示例#2
0
    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, 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)
示例#4
0
 def __init__(self, parent=None):
     super(XZoomSlider, self).__init__(parent)
     
     # define the interface
     in_icon  = projexui.resources.find('img/zoom_in.png')
     out_icon = projexui.resources.find('img/zoom_out.png')
     
     self._zoomInButton = QToolButton(self)
     self._zoomInButton.setAutoRaise(True)
     self._zoomInButton.setToolTip('Zoom In')
     self._zoomInButton.setIcon(QIcon(in_icon))
     
     self._zoomOutButton = QToolButton(self)
     self._zoomOutButton.setAutoRaise(True)
     self._zoomOutButton.setToolTip('Zoom Out')
     self._zoomOutButton.setIcon(QIcon(out_icon))
     
     self._zoomSlider = QSlider(Qt.Horizontal, self)
     self._zoomSlider.setRange(10, 100)
     self._zoomSlider.setValue(100)
     
     # define the layout
     layout = QHBoxLayout()
     layout.setContentsMargins(0, 0, 0, 0)
     layout.setSpacing(0)
     layout.addWidget(self._zoomOutButton)
     layout.addWidget(self._zoomSlider)
     layout.addWidget(self._zoomInButton)
     
     self.setLayout(layout)
     
     # create connections
     self._zoomSlider.valueChanged.connect(self.emitZoomAmountChanged)
     self._zoomInButton.clicked.connect(self.zoomIn)
     self._zoomOutButton.clicked.connect(self.zoomOut)
示例#5
0
    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, 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)
示例#7
0
 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)
示例#8
0
 def __init__( self, parent = None ):
     super(XPagesWidget, self).__init__( parent )
     
     # define custom properties
     self._currentPage       = 1
     self._pageCount         = 10
     self._itemCount         = 0
     self._pageSize          = 50
     self._itemsTitle        = 'items'
     
     self._pagesSpinner  = QSpinBox()
     self._pagesSpinner.setMinimum(1)
     self._pagesSpinner.setMaximum(10)
     
     self._pageSizeCombo = XComboBox(self)
     self._pageSizeCombo.setHint('all')
     self._pageSizeCombo.addItems(['', '25', '50', '75', '100'])
     self._pageSizeCombo.setCurrentIndex(2)
     
     self._nextButton    = QToolButton(self)
     self._nextButton.setAutoRaise(True)
     self._nextButton.setArrowType(Qt.RightArrow)
     self._nextButton.setFixedWidth(16)
     
     self._prevButton    = QToolButton(self)
     self._prevButton.setAutoRaise(True)
     self._prevButton.setArrowType(Qt.LeftArrow)
     self._prevButton.setFixedWidth(16)
     self._prevButton.setEnabled(False)
     
     self._pagesLabel = QLabel('of 10 for ', self)
     self._itemsLabel = QLabel(' items per page', self)
     
     # define the interface
     layout = QHBoxLayout()
     layout.addWidget(QLabel('Page', self))
     layout.addWidget(self._prevButton)
     layout.addWidget(self._pagesSpinner)
     layout.addWidget(self._nextButton)
     layout.addWidget(self._pagesLabel)
     layout.addWidget(self._pageSizeCombo)
     layout.addWidget(self._itemsLabel)
     layout.addStretch(1)
     
     layout.setContentsMargins(0, 0, 0, 0)
     layout.setSpacing(0)
     
     self.setLayout(layout)
     self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred)
     
     # create connections
     self._pageSizeCombo.currentIndexChanged.connect(self.pageSizePicked)
     self._nextButton.clicked.connect(self.gotoNext)
     self._prevButton.clicked.connect(self.gotoPrevious)
     self._pagesSpinner.editingFinished.connect(self.assignCurrentPage)
示例#9
0
    def __init__(self, parent=None):
        super(XPagesWidget, self).__init__(parent)

        # define custom properties
        self._currentPage = 1
        self._pageCount = 10
        self._itemCount = 0
        self._pageSize = 50
        self._itemsTitle = 'items'

        self._pagesSpinner = QSpinBox()
        self._pagesSpinner.setMinimum(1)
        self._pagesSpinner.setMaximum(10)

        self._pageSizeCombo = XComboBox(self)
        self._pageSizeCombo.setHint('all')
        self._pageSizeCombo.addItems(['', '25', '50', '75', '100'])
        self._pageSizeCombo.setCurrentIndex(2)

        self._nextButton = QToolButton(self)
        self._nextButton.setAutoRaise(True)
        self._nextButton.setArrowType(Qt.RightArrow)
        self._nextButton.setFixedWidth(16)

        self._prevButton = QToolButton(self)
        self._prevButton.setAutoRaise(True)
        self._prevButton.setArrowType(Qt.LeftArrow)
        self._prevButton.setFixedWidth(16)
        self._prevButton.setEnabled(False)

        self._pagesLabel = QLabel('of 10 for ', self)
        self._itemsLabel = QLabel(' items per page', self)

        # define the interface
        layout = QHBoxLayout()
        layout.addWidget(QLabel('Page', self))
        layout.addWidget(self._prevButton)
        layout.addWidget(self._pagesSpinner)
        layout.addWidget(self._nextButton)
        layout.addWidget(self._pagesLabel)
        layout.addWidget(self._pageSizeCombo)
        layout.addWidget(self._itemsLabel)
        layout.addStretch(1)

        layout.setContentsMargins(0, 0, 0, 0)
        layout.setSpacing(0)

        self.setLayout(layout)
        self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred)

        # create connections
        self._pageSizeCombo.currentIndexChanged.connect(self.pageSizePicked)
        self._nextButton.clicked.connect(self.gotoNext)
        self._prevButton.clicked.connect(self.gotoPrevious)
        self._pagesSpinner.editingFinished.connect(self.assignCurrentPage)
示例#10
0
 def __init__(self, parent=None):
     super(XTimeDeltaEdit, self).__init__(parent)
     
     # define custom properties
     self.setStyleSheet(COMBO_STYLE)
     
     self._numberSpinner = QSpinBox(self)
     self._numberSpinner.setRange(0, 100000)
     self._numberSpinner.setFrame(False)
     self._numberSpinner.setButtonSymbols(QSpinBox.NoButtons)
     self._numberSpinner.setSizePolicy(QSizePolicy.Expanding,
                                       QSizePolicy.Expanding)
     
     self._unitCombo = QComboBox(self)
     self._unitCombo.setEditable(True)
     self._unitCombo.setInsertPolicy(QComboBox.NoInsert)
     self._unitCombo.setFrame(False)
     self._unitCombo.addItems(['year(s)',
                               'month(s)',
                               'week(s)',
                               'day(s)',
                               'hour(s)',
                               'minute(s)',
                               'second(s)'])
     
     self._unitCombo.setCurrentIndex(3)
     self._unitCombo.setSizePolicy(QSizePolicy.Expanding,
                                   QSizePolicy.Expanding)
     
     self._directionCombo = QComboBox(self)
     self._directionCombo.addItems(['ago', 'from now'])
     self._directionCombo.setEditable(True)
     self._directionCombo.setInsertPolicy(QComboBox.NoInsert)
     self._directionCombo.setFrame(False)
     self._directionCombo.setSizePolicy(QSizePolicy.Expanding,
                                        QSizePolicy.Expanding)
     
     # setup ui
     self.setFrameShape(QFrame.StyledPanel)
     self.setFrameShadow(QFrame.Sunken)
     self.setBackgroundRole(QPalette.Base)
     self.setAutoFillBackground(True)
     
     layout = QHBoxLayout()
     layout.setContentsMargins(2, 2, 2, 2)
     layout.setSpacing(0)
     layout.addWidget(self._numberSpinner)
     layout.addWidget(self._unitCombo)
     layout.addWidget(self._directionCombo)
     self.setLayout(layout)
示例#11
0
 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 )
示例#12
0
 def __init__( self, parent = None ):
     super(XOrbColumnEdit, self).__init__( parent )
     
     # define custom properties
     
     # set default properties
     self._columnType = None
     self._columnName = ''
     self._options    = None
     self._editor     = None
     
     # set the layout for this object
     layout = QHBoxLayout()
     layout.setContentsMargins(0, 0, 0, 0)
     self.setLayout(layout)
     
     if ( ColumnType ):
         self.setColumnType(ColumnType.String)
示例#13
0
 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)
示例#14
0
    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)
示例#15
0
 def __init__( self, parent = None ):
     super(XFindWidget, self).__init__( parent )
     
     # define custom properties
     self._textEdit   = None
     self._webView    = None
     self._lastCursor = QTextCursor()
     self._lastText = ''
     
     self._closeButton = QToolButton(self)
     self._closeButton.setIcon(QIcon(resources.find('img/close.png')))
     self._closeButton.setAutoRaise(True)
     self._closeButton.setToolTip('Hide the Find Field.')
     
     self._searchEdit = XLineEdit(self)
     self._searchEdit.setHint('search for...')
     
     self._previousButton = QToolButton(self)
     self._previousButton.setIcon(QIcon(resources.find('img/back.png')))
     self._previousButton.setAutoRaise(True)
     self._previousButton.setToolTip('Find Previous')
     
     self._nextButton = QToolButton(self)
     self._nextButton.setIcon(QIcon(resources.find('img/forward.png')))
     self._nextButton.setAutoRaise(True)
     self._nextButton.setToolTip('Find Next')
     
     self._caseSensitiveCheckbox = QCheckBox(self)
     self._caseSensitiveCheckbox.setText('Case Sensitive')
     
     self._wholeWordsCheckbox = QCheckBox(self)
     self._wholeWordsCheckbox.setText('Whole Words Only')
     
     self._regexCheckbox = QCheckBox(self)
     self._regexCheckbox.setText('Use Regex')
     
     self._findAction = QAction(self)
     self._findAction.setText('Find...')
     self._findAction.setIcon(QIcon(resources.find('img/search.png')))
     self._findAction.setToolTip('Find in Text')
     self._findAction.setShortcut(QKeySequence('Ctrl+F'))
     self._findAction.setShortcutContext(Qt.WidgetWithChildrenShortcut)
     
     # layout the widgets
     layout = QHBoxLayout()
     layout.setContentsMargins(0, 0, 0, 0)
     layout.addWidget( self._closeButton )
     layout.addWidget( self._searchEdit )
     layout.addWidget( self._previousButton )
     layout.addWidget( self._nextButton )
     layout.addWidget( self._caseSensitiveCheckbox )
     layout.addWidget( self._wholeWordsCheckbox )
     layout.addWidget( self._regexCheckbox )
     
     self.setLayout(layout)
     
     # create connections
     self._findAction.triggered.connect(          self.show )
     self._searchEdit.textChanged.connect(        self.findNext )
     self._closeButton.clicked.connect(           self.hide )
     self._previousButton.clicked.connect(        self.findPrev )
     self._nextButton.clicked.connect(            self.findNext )
     self._caseSensitiveCheckbox.clicked.connect( self.findNext )
     self._wholeWordsCheckbox.clicked.connect(    self.findNext )
     self._searchEdit.returnPressed.connect(      self.findNext )
     self._regexCheckbox.clicked.connect(         self.findNext )
示例#16
0
    def __init__(self, parent=None, buttons=None):
        super(XPopupWidget, self).__init__(parent)

        # define custom properties
        self._anchor = XPopupWidget.Anchor.TopCenter
        self._autoCalculateAnchor = False
        self._autoCloseOnAccept = True
        self._autoCloseOnReject = True
        self._autoCloseOnFocusOut = False
        self._autoDefault = True
        self._first = True
        self._animated = False
        self._currentMode = None
        self._positionLinkedTo = []
        self._possibleAnchors = XPopupWidget.Anchor.all()

        # define controls
        self._result = 0
        self._resizable = True
        self._popupPadding = 10
        self._titleBarVisible = True
        self._buttonBoxVisible = True
        self._dialogButton = QToolButton(self)
        self._closeButton = QToolButton(self)
        self._scrollArea = QScrollArea(self)
        self._sizeGrip = QSizeGrip(self)
        self._sizeGrip.setFixedWidth(12)
        self._sizeGrip.setFixedHeight(12)

        self._leftSizeGrip = QSizeGrip(self)
        self._leftSizeGrip.setFixedWidth(12)
        self._leftSizeGrip.setFixedHeight(12)

        if buttons is None:
            buttons = QDialogButtonBox.NoButton

        self._buttonBox = QDialogButtonBox(buttons, Qt.Horizontal, self)
        self._buttonBox.setContentsMargins(3, 0, 3, 9)

        self._scrollArea.setWidgetResizable(True)
        self._scrollArea.setFrameShape(QScrollArea.NoFrame)
        self._scrollArea.setSizePolicy(QSizePolicy.Expanding,
                                       QSizePolicy.Expanding)

        palette = self.palette()
        self._scrollArea.setPalette(palette)

        self._dialogButton.setToolTip('Popout to Dialog')
        self._closeButton.setToolTip('Close Popup')

        for btn in (self._dialogButton, self._closeButton):
            btn.setAutoRaise(True)
            btn.setIconSize(QSize(14, 14))
            btn.setMaximumSize(16, 16)

        # setup the icons
        icon = QIcon(projexui.resources.find('img/dialog.png'))
        self._dialogButton.setIcon(icon)

        icon = QIcon(projexui.resources.find('img/close.png'))
        self._closeButton.setIcon(icon)

        # define the ui
        hlayout = QHBoxLayout()
        hlayout.setSpacing(0)
        hlayout.addStretch(1)
        hlayout.addWidget(self._dialogButton)
        hlayout.addWidget(self._closeButton)
        hlayout.setContentsMargins(0, 0, 0, 0)

        hlayout2 = QHBoxLayout()
        hlayout2.addWidget(self._buttonBox)
        hlayout2.setContentsMargins(0, 0, 3, 0)

        vlayout = QVBoxLayout()
        vlayout.addLayout(hlayout)
        vlayout.addWidget(self._scrollArea)
        vlayout.addLayout(hlayout2)
        vlayout.setContentsMargins(3, 2, 3, 2)
        vlayout.setSpacing(0)

        self.setLayout(vlayout)
        self.setPositionLinkedTo(parent)

        # set default properties
        self.setAutoFillBackground(True)
        self.setBackgroundRole(QPalette.Window)
        self.setWindowTitle('Popup')
        self.setFocusPolicy(Qt.StrongFocus)
        self.setCurrentMode(XPopupWidget.Mode.Popup)

        # create connections
        self._dialogButton.clicked.connect(self.setDialogMode)
        self._closeButton.clicked.connect(self.reject)
        self._buttonBox.accepted.connect(self.accept)
        self._buttonBox.rejected.connect(self.reject)
        self._buttonBox.clicked.connect(self.handleButtonClick)
示例#17
0
 def __init__(self, parent=None, buttons=None):
     super(XPopupWidget, self).__init__(parent)
     
     # define custom properties
     self._anchor                = XPopupWidget.Anchor.TopCenter
     self._autoCalculateAnchor   = False
     self._autoCloseOnAccept     = True
     self._autoCloseOnReject     = True
     self._autoCloseOnFocusOut   = False
     self._autoDefault           = True
     self._first                 = True
     self._animated              = False
     self._currentMode           = None
     self._positionLinkedTo      = []
     self._possibleAnchors       = XPopupWidget.Anchor.all()
     
     # define controls
     self._result        = 0
     self._resizable     = True
     self._popupPadding  = 10
     self._titleBarVisible = True
     self._buttonBoxVisible = True
     self._dialogButton  = QToolButton(self)
     self._closeButton   = QToolButton(self)
     self._scrollArea    = QScrollArea(self)
     self._sizeGrip      = QSizeGrip(self)
     self._sizeGrip.setFixedWidth(12)
     self._sizeGrip.setFixedHeight(12)
     
     self._leftSizeGrip  = QSizeGrip(self)
     self._leftSizeGrip.setFixedWidth(12)
     self._leftSizeGrip.setFixedHeight(12)
     
     if buttons is None:
         buttons = QDialogButtonBox.NoButton
     
     self._buttonBox     = QDialogButtonBox(buttons, Qt.Horizontal, self)
     self._buttonBox.setContentsMargins(3, 0, 3, 9)
     
     self._scrollArea.setWidgetResizable(True)
     self._scrollArea.setFrameShape(QScrollArea.NoFrame)
     self._scrollArea.setSizePolicy(QSizePolicy.Expanding,
                                    QSizePolicy.Expanding)
     
     palette = self.palette()
     self._scrollArea.setPalette(palette)
     
     self._dialogButton.setToolTip('Popout to Dialog')
     self._closeButton.setToolTip('Close Popup')
     
     for btn in (self._dialogButton, self._closeButton):
         btn.setAutoRaise(True)
         btn.setIconSize(QSize(14, 14))
         btn.setMaximumSize(16, 16)
     
     # setup the icons
     icon = QIcon(projexui.resources.find('img/dialog.png'))
     self._dialogButton.setIcon(icon)
     
     icon = QIcon(projexui.resources.find('img/close.png'))
     self._closeButton.setIcon(icon)
     
     # define the ui
     hlayout = QHBoxLayout()
     hlayout.setSpacing(0)
     hlayout.addStretch(1)
     hlayout.addWidget(self._dialogButton)
     hlayout.addWidget(self._closeButton)
     hlayout.setContentsMargins(0, 0, 0, 0)
     
     hlayout2 = QHBoxLayout()
     hlayout2.addWidget(self._buttonBox)
     hlayout2.setContentsMargins(0, 0, 3, 0)
     
     vlayout = QVBoxLayout()
     vlayout.addLayout(hlayout)
     vlayout.addWidget(self._scrollArea)
     vlayout.addLayout(hlayout2)
     vlayout.setContentsMargins(3, 2, 3, 2)
     vlayout.setSpacing(0)
     
     self.setLayout(vlayout)
     self.setPositionLinkedTo(parent)
     
     # set default properties
     self.setAutoFillBackground(True)
     self.setBackgroundRole(QPalette.Window)
     self.setWindowTitle('Popup')
     self.setFocusPolicy(Qt.StrongFocus)
     self.setCurrentMode(XPopupWidget.Mode.Popup)
     
     # create connections
     self._dialogButton.clicked.connect(self.setDialogMode)
     self._closeButton.clicked.connect(self.reject)
     self._buttonBox.accepted.connect(self.accept)
     self._buttonBox.rejected.connect(self.reject)
     self._buttonBox.clicked.connect(self.handleButtonClick)
 def rebuild(self):
     """
     Rebuilds the data associated with this filter widget.
     """
     table = self.tableType()
     form  = nativestring(self.filterFormat())
     
     if not table and form:
         if self.layout().count() == 0:
             self.layout().addWidget(QLabel(form, self))
         else:
             self.layout().itemAt(0).widget().setText(form)
         return
     
     elif not form:
         return
     
     for child in self.findChildren(QWidget):
         child.close()
         child.setParent(None)
         child.deleteLater()
     
     self.setUpdatesEnabled(False)
     schema = table.schema()
     
     vlayout = self.layout()
     for i in range(vlayout.count()):
         vlayout.takeAt(0)
     
     self._plugins = []
     for line in form.split('\n'):
         row = QHBoxLayout()
         row.setContentsMargins(0, 0, 0, 0)
         row.setSpacing(0)
         
         for label, lookup in FORMAT_SPLITTER.findall(line):
             # create the label
             lbl = QLabel(label, self)
             row.addWidget(lbl)
             
             # create the query plugin
             opts = lookup.split(':')
             if len(opts) == 1:
                 opts.append('is')
             
             column = schema.column(opts[0])
             if not column:
                 continue
             
             plugin = self.pluginFactory().plugin(column)
             if not plugin:
                 continue
             
             editor = plugin.createEditor(self, column, opts[1], None)
             if editor:
                 editor.setObjectName(opts[0])
                 row.addWidget(editor)
                 self._plugins.append((opts[0], opts[1], plugin, editor))
         
         row.addStretch(1)
         vlayout.addLayout(row)
     
     self.setUpdatesEnabled(True)
     self.adjustSize()
示例#19
0
    def __init__(self, parent=None):
        super(XNavigationEdit, self).__init__(parent)

        # define custom properties
        self._separator = '/'
        self._partsEditingEnabled = True
        self._originalText = ''
        self._scrollWidget = QScrollArea(self)
        self._partsWidget = QWidget(self._scrollWidget)
        self._buttonGroup = QButtonGroup(self)
        self._scrollAmount = 0
        self._navigationModel = None

        # create the completer tree
        palette = self.palette()
        palette.setColor(palette.Base, palette.color(palette.Window))
        palette.setColor(palette.Text, palette.color(palette.WindowText))

        bg = palette.color(palette.Highlight)
        abg = bg.darker(115)
        fg = palette.color(palette.HighlightedText)
        sbg = 'rgb(%s, %s, %s)' % (bg.red(), bg.green(), bg.blue())
        sabg = 'rgb(%s, %s, %s)' % (abg.red(), abg.green(), abg.blue())
        sfg = 'rgb(%s, %s, %s)' % (fg.red(), fg.green(), fg.blue())
        style   = 'QTreeView::item:hover { '\
                  '     color: %s;'\
                  '     background: qlineargradient(x1:0,'\
                  '                                 y1:0,'\
                  '                                 x2:0,'\
                  '                                 y2:1,'\
                  '                                 stop: 0 %s,'\
                  '                                 stop: 1 %s);'\
                  '}' % (sfg, sbg, sabg)

        self._completerTree = QTreeView(self)
        self._completerTree.setStyleSheet(style)
        self._completerTree.header().hide()
        self._completerTree.setFrameShape(QTreeView.Box)
        self._completerTree.setFrameShadow(QTreeView.Plain)
        self._completerTree.setPalette(palette)
        self._completerTree.setEditTriggers(QTreeView.NoEditTriggers)
        self._completerTree.setWindowFlags(Qt.Popup)
        self._completerTree.installEventFilter(self)
        self._completerTree.setRootIsDecorated(False)
        self._completerTree.setItemsExpandable(False)

        # create the editing widget
        layout = QHBoxLayout()
        layout.setContentsMargins(0, 0, 0, 0)
        layout.setSpacing(0)
        layout.addStretch()

        self._scrollWidget.setFrameShape(QScrollArea.NoFrame)
        self._scrollWidget.setFocusPolicy(Qt.NoFocus)
        self._scrollWidget.setWidget(self._partsWidget)
        self._scrollWidget.setWidgetResizable(True)
        self._scrollWidget.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self._scrollWidget.setAlignment(Qt.AlignTop | Qt.AlignRight)
        self._scrollWidget.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self._scrollWidget.setContentsMargins(0, 0, 0, 0)
        self._scrollWidget.setViewportMargins(0, 0, 0, 0)
        self._scrollWidget.move(2, 2)

        self._partsWidget.setLayout(layout)
        self._partsWidget.setCursor(Qt.ArrowCursor)
        self._partsWidget.setAutoFillBackground(True)
        self._partsWidget.setFixedHeight(self.height() - 12)

        palette = self._partsWidget.palette()
        palette.setColor(palette.Background, palette.color(palette.Base))
        self._partsWidget.setPalette(palette)

        # create connections
        self._completerTree.clicked.connect(self.navigateToIndex)
        self._buttonGroup.buttonClicked.connect(self.handleButtonClick)
        self._scrollWidget.horizontalScrollBar().valueChanged.connect(
            self.scrollParts)
    def rebuild(self):
        """
        Rebuilds the data associated with this filter widget.
        """
        table = self.tableType()
        form = nativestring(self.filterFormat())

        if not table and form:
            if self.layout().count() == 0:
                self.layout().addWidget(QLabel(form, self))
            else:
                self.layout().itemAt(0).widget().setText(form)
            return

        elif not form:
            return

        for child in self.findChildren(QWidget):
            child.close()
            child.setParent(None)
            child.deleteLater()

        self.setUpdatesEnabled(False)
        schema = table.schema()

        vlayout = self.layout()
        for i in range(vlayout.count()):
            vlayout.takeAt(0)

        self._plugins = []
        for line in form.split('\n'):
            row = QHBoxLayout()
            row.setContentsMargins(0, 0, 0, 0)
            row.setSpacing(0)

            for label, lookup in FORMAT_SPLITTER.findall(line):
                # create the label
                lbl = QLabel(label, self)
                row.addWidget(lbl)

                # create the query plugin
                opts = lookup.split(':')
                if len(opts) == 1:
                    opts.append('is')

                column = schema.column(opts[0])
                if not column:
                    continue

                plugin = self.pluginFactory().plugin(column)
                if not plugin:
                    continue

                editor = plugin.createEditor(self, column, opts[1], None)
                if editor:
                    editor.setObjectName(opts[0])
                    row.addWidget(editor)
                    self._plugins.append((opts[0], opts[1], plugin, editor))

            row.addStretch(1)
            vlayout.addLayout(row)

        self.setUpdatesEnabled(True)
        self.adjustSize()
示例#21
0
 def __init__( self, parent = None ):
     super(XNavigationEdit, self).__init__( parent )
     
     # define custom properties
     self._separator             = '/'
     self._partsEditingEnabled   = True
     self._originalText          = ''
     self._scrollWidget          = QScrollArea(self)
     self._partsWidget           = QWidget(self._scrollWidget)
     self._buttonGroup           = QButtonGroup(self)
     self._scrollAmount          = 0
     self._navigationModel       = None
     
     # create the completer tree
     palette = self.palette()
     palette.setColor(palette.Base, palette.color(palette.Window))
     palette.setColor(palette.Text, palette.color(palette.WindowText))
     
     bg      = palette.color(palette.Highlight)
     abg     = bg.darker(115)
     fg      = palette.color(palette.HighlightedText)
     sbg     = 'rgb(%s, %s, %s)' % (bg.red(), bg.green(), bg.blue())
     sabg    = 'rgb(%s, %s, %s)' % (abg.red(), abg.green(), abg.blue())
     sfg     = 'rgb(%s, %s, %s)' % (fg.red(), fg.green(), fg.blue())
     style   = 'QTreeView::item:hover { '\
               '     color: %s;'\
               '     background: qlineargradient(x1:0,'\
               '                                 y1:0,'\
               '                                 x2:0,'\
               '                                 y2:1,'\
               '                                 stop: 0 %s,'\
               '                                 stop: 1 %s);'\
               '}' % (sfg, sbg, sabg)
     
     self._completerTree = QTreeView(self)
     self._completerTree.setStyleSheet(style)
     self._completerTree.header().hide()
     self._completerTree.setFrameShape(QTreeView.Box)
     self._completerTree.setFrameShadow(QTreeView.Plain)
     self._completerTree.setPalette(palette)
     self._completerTree.setEditTriggers(QTreeView.NoEditTriggers)
     self._completerTree.setWindowFlags(Qt.Popup)
     self._completerTree.installEventFilter(self)
     self._completerTree.setRootIsDecorated(False)
     self._completerTree.setItemsExpandable(False)
     
     # create the editing widget
     layout = QHBoxLayout()
     layout.setContentsMargins(0, 0, 0, 0)
     layout.setSpacing(0)
     layout.addStretch()
     
     self._scrollWidget.setFrameShape( QScrollArea.NoFrame )
     self._scrollWidget.setFocusPolicy(Qt.NoFocus)
     self._scrollWidget.setWidget(self._partsWidget)
     self._scrollWidget.setWidgetResizable(True)
     self._scrollWidget.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
     self._scrollWidget.setAlignment(Qt.AlignTop | Qt.AlignRight)
     self._scrollWidget.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
     self._scrollWidget.setContentsMargins(0, 0, 0, 0)
     self._scrollWidget.setViewportMargins(0, 0, 0, 0)
     self._scrollWidget.move(2, 2)
     
     self._partsWidget.setLayout(layout)
     self._partsWidget.setCursor(Qt.ArrowCursor)
     self._partsWidget.setAutoFillBackground(True)
     self._partsWidget.setFixedHeight(self.height() - 12)
     
     palette = self._partsWidget.palette()
     palette.setColor(palette.Background, palette.color(palette.Base))
     self._partsWidget.setPalette(palette)
     
     # create connections
     self._completerTree.clicked.connect( self.navigateToIndex )
     self._buttonGroup.buttonClicked.connect( self.handleButtonClick )
     self._scrollWidget.horizontalScrollBar().valueChanged.connect( 
                                                     self.scrollParts )