Esempio n. 1
0
    def __init__(self, MODULE = None):
        """ Init function.
        """

        super(XnatViewer, self).__init__(self)
        self.MODULE = MODULE

        

        #--------------------
        # Make label to display when no search
        # results are found.
        #--------------------       
        self.noSearchResultsFound = qt.QLabel("<i>No results found.</i>", self)
        self.noSearchResultsFound.setStyleSheet('color: gray; margin-left: 150px; text-align: center')


        
        #--------------------
        # Make a stackedLayout and stackedWidget
        # of the XnatView and the 'noSearchResultsFound'
        # label.  We create a 'stackedWidget' because we need
        # a widget to feed into the viewerLayout, which is a 
        # QGridLayout. We then set the index to the XnatView --
        # the XnatView will call 'setNoResultsWidgetVisible'
        # if there are no search results.
        #--------------------          
        self.stackedLayout = qt.QStackedLayout(self)
        self.stackedLayout.addWidget(self.noSearchResultsFound)
        self.stackedLayout.addWidget(self.MODULE.XnatView)
        self.stackedLayout.setCurrentIndex(1)
        self.stackedLayout.setStackingMode(1)
        self.stackedWidget = qt.QWidget(self)
        self.stackedWidget.setLayout(self.stackedLayout)


        
        #--------------------
        # Make main layout.
        #-------------------- 
        self.viewerLayout = qt.QGridLayout()  
        self.viewerLayout.addWidget(self.MODULE.XnatSearchBar, 0, 0, 1, 1)        
        self.viewerLayout.addWidget(self.stackedWidget, 2, 0)
        self.viewerLayout.addLayout(self.MODULE.XnatButtons.loadSaveButtonLayout, 2, 1)
        self.setLayout(self.viewerLayout)
Esempio n. 2
0
    def __init__(self, parent, title, maxHeight=1000, minHeight=60):
        """ Init function.
        """

        if parent:
            super(AnimatedCollapsible, self).__init__(parent)
        else:
            super(AnimatedCollapsible, self).__init__(self)

        #--------------------
        # We want to grab the sizeGrip right off
        # the bat so we can control its visibility.
        #--------------------
        self.sizeGrip = self.children()[0]
        self.sizeGrip.hide()

        #--------------------
        # We hide the module first because
        # it creates a flikering on loadup
        #--------------------
        self.hide()

        #--------------------
        # Set the arrow characters,
        # described accordingly.
        #--------------------
        self.rightArrowChar = u'\u25b8'
        self.downArrowChar = u'\u25be'

        #--------------------
        # Set Collapsed Height
        #--------------------
        self.collapsedHeight = 30

        #--------------------
        # Set the min/max heights.
        #--------------------
        self.minHeight = minHeight
        self.maxHeight = maxHeight

        #--------------------
        # Set the toggleButton's height and width
        #--------------------
        self.toggleHeight = 16
        self.toggleWidth = 80

        #--------------------
        # Make sure the widget is 100% its parent's width.
        #--------------------
        self.setStyleSheet('width: 100%')

        #--------------------
        # Set the animation duration
        #--------------------
        self.animDuration = 300

        #--------------------
        # Set the size policy
        #--------------------
        self.setSizePolicy(qt.QSizePolicy.Ignored,
                           qt.QSizePolicy.MinimumExpanding)

        #----------------
        # Set the animation's easing curve.  See:
        # http://harmattan-dev.nokia.com/docs/library/html/qt4/qeasingcurve.html
        # for more options.
        #----------------
        self.easingCurve = qt.QEasingCurve(2)

        #----------------
        # Set the minimum hieght
        #----------------
        self.setMinimumHeight(self.minHeight)

        #----------------
        # set the Title
        #----------------
        self.title = title

        #----------------
        # Make the toggle button
        #----------------
        self.toggleButton = HoverButton(self)
        self.toggleButton.hide()
        self.toggleButton.setParent(self)
        self.toggleButton.setFixedHeight(self.toggleHeight)
        self.toggleButton.setCheckable(True)
        self.toggleButton.setObjectName('animatedCollapsibleToggleButton')
        self.toggleButton.setDefaultStyleSheet(
            '#animatedCollapsibleToggleButton {border: 1px solid transparent; background-color: white; margin-left: 5px; text-align: left; padding-left: 5px;}'
        )
        self.toggleButton.setHoverStyleSheet(
            '#animatedCollapsibleToggleButton {border: 1px solid rgb(200,200,200); background-color: white; border-radius: 2px; margin-left: 5px; text-align: left; padding-left: 5px;}'
        )
        self.configureButton(True)

        #----------------
        # Make the internal 'frame' and set the style
        # accordingly.
        #----------------
        self.frame = qt.QFrame(self)
        #
        # Prevent style sheet inheritance from
        # inner contents
        #
        self.frame.setObjectName('animateCollapsibleFrame')
        self.frame.setStyleSheet(
            '#animateCollapsibleFrame {margin-top: 9px; border: 2px solid lightgray; padding-top: 5px; padding-left: 2px; padding-right: 2px; padding-bottom: 2px}'
        )

        #----------------
        # Stack the button on top of the frame via a
        # QStackedLayout
        #----------------
        self.stackedLayout = qt.QStackedLayout()
        self.stackedLayout.addWidget(self.toggleButton)
        self.stackedLayout.addWidget(self.frame)

        #----------------
        # To make sure the button is on top.
        #----------------
        self.stackedLayout.setCurrentIndex(0)
        self.stackedLayout.setStackingMode(1)

        #----------------
        # Set the sayout
        #----------------
        self.setLayout(self.stackedLayout)

        #----------------
        # Init the animation group and callbacks.
        #----------------
        self.animations = qt.QParallelAnimationGroup()
        self.onAnimate = None
        self.onCollapse = None
        self.onExpand = None
        self.ContentsWidgets = []

        #----------------
        # Set the default states after creation.
        #----------------
        self.toggleButton.connect('toggled(bool)', self.setChecked)
        self.toggled = True

        #----------------
        # Set the stretch height.
        #
        # NOTE: This is different from the maximumHeight,
        # it's a target height that the user sets so that
        # the collapsible will stretch as far as self.stretchHeight
        # dictates once its expanded.  If we didn't have this
        # variable, the the widget would have a sendentary height
        # within a layout, not stretching to the layout's
        # maximum extents.
        #
        #
        # TODO: Ideally this parameter would be more of a percentage
        # but setting stylesheet percentages is not possible, becase
        # we are manipulating the .maximumHeight' property of the widget
        # during the animation.
        # Need to determine a more elegant way of of setting the 'stretch'
        # height to '100%' or equivalent.
        #----------------
        self.stretchHeight = None
Esempio n. 3
0
    def __init__(self, parent, *args, **kwargs):
        """ Init function.
        """

        super(FingerTabWidget, self).__init__(parent)

        
        
        #--------------------
        # Define sizing parameters.
        #--------------------          
        self.marginVal = 5
        self.currentIndex = 0
        self.tabWidth = 120


    
        #--------------------
        # Make and style 'tabColumn', which is a qFrame.
        #--------------------  
        self.tabColumn = qt.QFrame(self)
        self.tabColumn.setFixedWidth(self.tabWidth)
        self.tabColumn.setObjectName('tabColumn')
        self.tabColumn.setStyleSheet('#tabColumn {background:#E8E8E8 ; height: 4000px;' + 
                                     'border-right-width: 1px;  border-right-color: gray;' + 
                                     'border-right-style: solid; margin-top: 5px;' +  
                                     'margin-left: 5px; margin-bottom: 5px}')



        #--------------------
        # Define the layout of the 'tabColumn' qFrame, 
        # set the layout to the 'tabColumn' qFrame.
        #--------------------  
        self.tabColumnLayout = qt.QVBoxLayout()
        self.tabColumnLayout.setContentsMargins(0,0,0,0)
        self.tabColumnLayout.setSpacing(0)
        self.tabColumnLayout.addStretch()
        self.tabColumn.setLayout(self.tabColumnLayout)

        

        #--------------------
        # Define the 'innerWindowLayout'.
        #--------------------  
        self.innerWindowLayout = qt.QStackedLayout()
        self.innerWindowLayout.setStackingMode(1)
        self.innerWindowLayout.setSpacing(0)
        self.innerWindowLayout.setContentsMargins(0,0,0,0)


        
        #--------------------
        # Define the 'widgetStack' object, which takes
        # the whole span of the window.
        #--------------------  
        self.widgetStack = qt.QWidget(self)
        self.widgetStack.setObjectName("widgetStack")
        self.widgetStack.setStyleSheet("#widgetStack{ border: none; background: transparent}")



        #--------------------
        # The layout for the 'widgetStack' is 
        # 'widgetStackLayout', which is an HBoxLayout.  We set 
        # a left spacing the length of the tabs-1 to accomodate for the border
        # and tabs of the widget.
        #--------------------  
        self.widgetStackLayout = qt.QHBoxLayout()
        self.widgetStackLayout.setContentsMargins(0,self.marginVal,self.marginVal,self.marginVal)
        self.widgetStackLayout.addSpacing(self.tabWidth - 1)
        self.widgetStack.setLayout(self.widgetStackLayout)



        #--------------------
        # Define the 'tabPageStack', add to the widgetStackLayout.
        #
        # NOTE: The 'tabPageStack' is the stacked layout were all
        # of the tab pages reside.
        #--------------------         
        self.tabPageStack = qt.QStackedLayout()
        self.widgetStackLayout.addLayout(self.tabPageStack)

        
        
        #--------------------
        # Define the tabButtons as part of a 
        # button group, for easier event listening.
        #
        # Set their styles as well.
        #--------------------    
        self.buttonGroup = qt.QButtonGroup(self)
        self.buttonGroup.connect('buttonClicked(QAbstractButton*)', self.onTabClicked)
        self.tabButtons = []
        self.tabWidgets = []
        self.tabObjectName = 'fingerTab'
        self.tabToggledStyle =  '#fingerTab {border: 1px solid gray;    border-right-width: 1px;  border-right-color: white; background-color: white;}'
        self.tabUntoggledStyle ='#fingerTab {border: 1px solid #D0D0D0; border-right-width: 1px;  border-right-color: gray;  background-color: #C0C0C0;}'
        self.tabToggledFont = qt.QFont('Arial', 12, 100, False)
        self.tabUntoggledFont = qt.QFont('Arial', 12, 25, False)


        
        #--------------------
        # Add 'tabColumn' and 'widgetStack' to 'innerWindowLayout'.  Set the current
        # index of the widgetStack (this will allow for the black
        # borders between the tabs and the windows to connect).
        #--------------------  
        self.innerWindowLayout.addWidget(self.tabColumn)
        self.innerWindowLayout.addWidget(self.widgetStack)
        self.innerWindowLayout.setCurrentIndex(1)

        

        #--------------------
        # Set 'mainWidgetLayout' to hold the 'innerWindowLayout'.
        # The 'mainWidgetLayout' exists because subclasses of 
        # 'FingerTabWidget' and others that use it can add
        # further rows to the window (such as 'Done' and 'Cancel'
        # buttons).
        #--------------------  
        self.mainWidgetLayout = qt.QVBoxLayout()
        self.mainWidgetLayout.setContentsMargins(5,5,5,5)
        self.mainWidgetLayout.addLayout(self.innerWindowLayout)


        
        #--------------------
        # Set the primary layout to the 'mainWidgetLayout'
        #--------------------
        self.setLayout(self.mainWidgetLayout)
Esempio n. 4
0
    def __init__(self, parent, MODULE=None):
        """ Init function.
        """

        self.MODULE = MODULE

        #--------------------
        # Call parent init.
        #--------------------
        super(XnatFolderMaker, self).__init__()

        #--------------------
        # Adjust window features.
        #--------------------
        self.setWindowTitle("Add Folder to Xnat")
        self.setWindowModality(2)

        #--------------------
        # Hide the widget initially.
        #--------------------
        self.hide()

        #--------------------
        # Set fixed width.
        #--------------------
        self.setFixedWidth(500)
        self.setFixedHeight(250)

        #--------------------
        # Make the xsiList for experiment
        # creation.
        #--------------------
        self.xsiList = qt.QComboBox()
        self.xsiList.addItems([
            key
            for key, value in self.MODULE.GLOBALS.XNAT_XSI_TYPES.iteritems()
        ])

        #--------------------
        # Displayable wigets.
        #--------------------
        self.levelLabels = {}
        self.nameLabels = {}
        self.lineEdits = {}
        self.errorLines = {}
        self.levelLayouts = {}
        self.labelLineStacks = {}
        self.levelRows = {}

        #--------------------
        # Make the buttons:
        # create, cancel,
        # etc.
        #--------------------
        self.addButton = qt.QPushButton()
        self.addButton.setText("Add")
        self.addButton.setEnabled(False)
        self.cancelButton = qt.QPushButton()
        self.cancelButton.setText("Cancel")
        buttonRow = qt.QDialogButtonBox()
        buttonRow.addButton(self.cancelButton, 2)
        buttonRow.addButton(self.addButton, 0)

        #-------------------
        # Create the keys in the displayable widgets.
        #--------------------
        self.addFolderXnatLevels = ['projects', 'subjects', 'experiments']
        for level in self.addFolderXnatLevels:

            #
            # Labels (name and level)
            #
            self.levelLabels[level] = qt.QLabel(self)
            self.levelLabels[level].setFixedHeight(25)
            self.nameLabels[level] = qt.QLabel(self)
            self.nameLabels[level].setFixedHeight(25)

            #
            # Line edits
            #
            self.lineEdits[level] = qt.QLineEdit(self)
            self.lineEdits[level].installEventFilter(self)
            self.lineEdits[level].setFixedHeight(25)

            #
            # Error lines
            #
            self.errorLines[level] = qt.QLabel(self)
            self.errorLines[level].setTextFormat(1)
            self.errorLines[level].setFixedHeight(25)

            #
            # Make the label-line stacks, adjusting
            # for 'experiments' as necessary.
            #
            self.labelLineStacks[level] = qt.QStackedLayout()
            if level == 'experiments':
                experimentRow = qt.QHBoxLayout()
                experimentRow.addWidget(self.xsiList)
                experimentRow.addWidget(self.lineEdits[level])
                experimentWidget = qt.QWidget()
                experimentWidget.setLayout(experimentRow)
                self.labelLineStacks[level].addWidget(experimentWidget)
            else:
                self.labelLineStacks[level].addWidget(self.nameLabels[level])
                self.labelLineStacks[level].addWidget(self.lineEdits[level])

            #
            # make row widgets
            #
            self.levelRows[level] = qt.QWidget(self)
            levelRowLayout = qt.QGridLayout()
            levelRowLayout.addWidget(self.levelLabels[level], 0, 0)
            levelRowLayout.addLayout(self.labelLineStacks[level], 0, 1)
            levelRowLayout.addWidget(self.errorLines[level], 1, 1)
            self.levelRows[level].setLayout(levelRowLayout)

        #--------------------
        # Connect button click events.
        #--------------------
        buttonRow.connect('clicked(QAbstractButton*)', self.onAddButtonClicked)

        #--------------------
        # Make the mainLayout and add all widgets.
        #--------------------
        self.mainLayout = qt.QVBoxLayout()
        for level in self.addFolderXnatLevels:
            self.mainLayout.addWidget(self.levelRows[level])
        self.mainLayout.addStretch()
        self.mainLayout.addWidget(buttonRow)
        self.setLayout(self.mainLayout)
Esempio n. 5
0
    def __init__(self, parent, title):
        """ 
        Init function.
        """

        if parent:
            super(AnimatedCollapsible, self).__init__(parent)
        else:
            super(AnimatedCollapsible, self).__init__(self)

        #--------------------
        # We want to grab the sizeGrip right off
        # the bat so we can control its visibility.
        #--------------------
        self.sizeGrip = self.children()[0]
        self.sizeGrip.hide()
        #self.setSizeGripInside(False)

        #--------------------
        # We hide the module first because
        # it creates a flikering on loadup
        #--------------------
        self.hide()

        #--------------------
        # Set the arrow characters,
        # described accordingly.
        #--------------------
        self.rightArrowChar = u'\u25b8'
        self.downArrowChar = u'\u25be'

        #--------------------
        # Set Collapsed Height
        #--------------------
        self.collapsedHeight = 30

        #--------------------
        # Set the min/max heights.
        #--------------------
        self.minExpandedHeight = 60
        self.maxExpandedHeight = 1000

        #--------------------
        # Set the toggleButton's height and width
        #--------------------
        self.toggleHeight = 16
        self.toggleWidth = 80

        #--------------------
        # Make sure the widget is 100% its parent's width.
        #--------------------
        self.setStyleSheet('width: 100%')

        #--------------------
        # Set the animation duration
        #--------------------
        self.animDuration = 250

        #--------------------
        # Set the size policy
        #--------------------
        self.setSizePolicy(qt.QSizePolicy.Ignored,
                           qt.QSizePolicy.MinimumExpanding)

        #----------------
        # Set the animation's easing curve.  See:
        # http://harmattan-dev.nokia.com/docs/library/html/qt4/qeasingcurve.html
        # for more options.
        #----------------
        self.__easingCurve = qt.QEasingCurve(6)

        #----------------
        # Set the minimum hieght
        #----------------
        self.setMinimumHeight(self.minExpandedHeight)

        #----------------
        # set the Title
        #----------------
        self.title = title

        #----------------
        # Make the toggle button
        #----------------
        self.toggleButton = HoverButton(self)
        self.toggleButton.hide()
        self.toggleButton.setParent(self)
        self.toggleButton.setFixedHeight(self.toggleHeight)
        self.toggleButton.setCheckable(True)
        self.toggleButton.setObjectName('animatedCollapsibleToggleButton')

        buttonDefault = '#animatedCollapsibleToggleButton '
        buttonDefault += '{border: 1px solid transparent; '
        buttonDefault += 'background-color: white; margin-left: '
        buttonDefault += '5px; text-align: left; padding-left: 5px;}'
        self.toggleButton.setDefaultStyleSheet(buttonDefault)

        buttonHover = '#animatedCollapsibleToggleButton {'
        buttonHover += 'border: 1px solid rgb(200,200,200); '
        buttonHover += 'background-color: white; border-radius: 2px; '
        buttonHover += 'margin-left: 5px; text-align: left; padding-left: 5px;}'
        self.toggleButton.setHoverStyleSheet(buttonHover)
        self.__modifyToggleButton(True)

        #----------------
        # Make the internal 'frame' and set the style
        # accordingly.
        #----------------
        self.frame = qt.QFrame(self)
        #
        # Prevent style sheet inheritance from
        # inner contents
        #
        self.frame.setObjectName('animateCollapsibleFrame')

        frameStyle = '#animateCollapsibleFrame '
        frameStyle += '{margin-top: 9px; border: '
        frameStyle += '2px solid lightgray; border-radius: 4px; padding-top: 5px; '
        frameStyle += 'padding-left: 2px; padding-right: 2px; padding-bottom: 2px}'
        self.frame.setStyleSheet(frameStyle)

        #----------------
        # Stack the button on top of the frame via a
        # QStackedLayout
        #----------------
        self.stackedLayout = qt.QStackedLayout()
        self.stackedLayout.addWidget(self.toggleButton)
        self.stackedLayout.addWidget(self.frame)

        #----------------
        # To make sure the button is on top.
        #----------------
        self.stackedLayout.setCurrentIndex(0)
        self.stackedLayout.setStackingMode(1)

        #----------------
        # Set the sayout
        #----------------
        self.setLayout(self.stackedLayout)

        #----------------
        # Init the animation group and callbacks.
        #----------------
        self.animations = qt.QParallelAnimationGroup()
        self.__eventCallbacks = {}
        for key in AnimatedCollapsible.EVENT_TYPES:
            self.__eventCallbacks[key] = []
        self.__contents = []

        #----------------
        # Set the default states after creation.
        #----------------
        self.toggleButton.connect('toggled(bool)', self.setChecked)
        self.toggled = True

        self.sizeGrip.installEventFilter(self)
        self.installEventFilter(self)