def __init__(self, name=None, prefix=None): """Widget to build an item for the environments list.""" super(ListItemEnv, self).__init__() self._selected = False self._name = name self._prefix = prefix # Widgets self.button_options = ButtonEnvironmentOptions() self.button_name = ButtonEnvironmentName(name) self.label_icon = LabelEnvironmentIcon() self.movie = QMovie(SPINNER_GREEN_16_PATH) self.widget = WidgetEnvironment() self.widget.button_name = self.button_name self.widget.button_options = self.button_options # Widget setup self.button_name.setDefault(True) self.label_icon.setMovie(self.movie) self.widget.setFocusPolicy(Qt.NoFocus) self.button_name.setFocusPolicy(Qt.StrongFocus) self.button_options.setFocusPolicy(Qt.StrongFocus) # Layouts layout = QHBoxLayout() layout.addWidget(self.label_icon) layout.addWidget(self.button_name) layout.addWidget(self.button_options) layout.addStretch() self.widget.setLayout(layout) self.widget.setStyleSheet(load_style_sheet()) self.setSizeHint(self.widget.sizeHint())
def __init__(self, name=None, prefix=None): """Widget to build an item for the environments list.""" super(ListItemEnv, self).__init__() self._selected = False self._name = name self._prefix = prefix # Widgets self.button_options = ButtonEnvironmentOptions() self.button_name = ButtonEnvironmentName(name) self.frame_icon = FrameEnvironmentIcon() self.widget = WidgetEnvironment() self.widget.button_name = self.button_name self.widget.button_options = self.button_options self.spinner = NavigatorSpinner(parent=self.widget, total_width=20) # Widget setup self.button_name.setDefault(True) self.widget.setFocusPolicy(Qt.NoFocus) self.button_name.setFocusPolicy(Qt.StrongFocus) self.button_options.setFocusPolicy(Qt.StrongFocus) self.button_name.setToolTip(prefix if prefix else '') lay = QHBoxLayout() lay.addWidget(self.spinner) self.frame_icon.setLayout(lay) # Layouts layout = QHBoxLayout() layout.addWidget(self.frame_icon) layout.addWidget(self.button_name) layout.addWidget(self.button_options) layout.addStretch() self.widget.setLayout(layout) self.widget.setStyleSheet(load_style_sheet()) self.setSizeHint(self.widget.sizeHint())
class ListItemEnv(ListWidgetItemBase): """Widget to build an item for the environments list.""" def __init__(self, name=None, prefix=None): """Widget to build an item for the environments list.""" super(ListItemEnv, self).__init__() self._selected = False self._name = name self._prefix = prefix # Widgets self.button_options = ButtonEnvironmentOptions() self.button_name = ButtonEnvironmentName(name) self.label_icon = LabelEnvironmentIcon() self.movie = QMovie(SPINNER_GREEN_16_PATH) self.widget = WidgetEnvironment() self.widget.button_name = self.button_name self.widget.button_options = self.button_options # Widget setup self.button_name.setDefault(True) self.label_icon.setMovie(self.movie) self.widget.setFocusPolicy(Qt.NoFocus) self.button_name.setFocusPolicy(Qt.StrongFocus) self.button_options.setFocusPolicy(Qt.StrongFocus) # Layouts layout = QHBoxLayout() layout.addWidget(self.label_icon) layout.addWidget(self.button_name) layout.addWidget(self.button_options) layout.addStretch() self.widget.setLayout(layout) self.widget.setStyleSheet(load_style_sheet()) self.setSizeHint(self.widget.sizeHint()) def ordered_widgets(self): """Return a list of the ordered widgets.""" return [self.button_name, self.button_options] def text(self): """Resturn the name of item.""" return self._name @property def name(self): return self._name def prefix(self): """Return environment prefix.""" return self._prefix def set_hovered(self, value): """Set widget as hovered.""" self.widget.setProperty('hovered', value) self.button_name.set_hovered(value) def set_loading(self, value): """Set loading status of widget.""" # self.button_options.setDisabled(value) # if value: # self.label_icon.setMovie(self.movie) # self.movie.start() # else: # self.label_icon.setMovie(QMovie()) # self.button_options.setFocus() self.label_icon.setMovie(QMovie()) self.button_options.setFocus() def set_selected(self, value): """Set widget as selected.""" self._selected = value try: self.widget.setProperty('pressed', value) self.button_name.set_selected(value) except RuntimeError: pass self.button_name.setDisabled(value) if value: self.label_icon.setMovie(None) self.button_options.setVisible(True) else: self.label_icon.setMovie(None) self.button_options.setVisible(False) self.button_options.setVisible(False) @staticmethod def widget_size(): """Return the size defined in the SASS file.""" return QSize( SASS_VARIABLES.WIDGET_ENVIRONMENT_TOTAL_WIDTH, SASS_VARIABLES.WIDGET_ENVIRONMENT_TOTAL_HEIGHT )
class ListItemEnvironment(QListWidgetItem): """ Widget to build an item for the environments list. """ def __init__(self, name=None, prefix=None): super(ListItemEnvironment, self).__init__() self._selected = False self._name = name self._prefix = prefix # Widgets self.button_options = ButtonEnvironmentOptions() self.button_name = ButtonEnvironmentName(name) self.label_icon = LabelEnvironmentIcon() self.movie = QMovie(SPINNER_GREEN_16_PATH) self.widget = WidgetEnvironment() self.widget.setFocusPolicy(Qt.NoFocus) self.widget.button_name = self.button_name self.widget.button_options = self.button_options # Widget setup self.label_icon.setMovie(self.movie) self.button_name.setDefault(True) # Layouts layout = QHBoxLayout() layout.addWidget(self.label_icon) layout.addWidget(self.button_name) layout.addWidget(self.button_options) layout.addStretch() self.widget.setLayout(layout) self.widget.setStyleSheet(load_style_sheet()) self.setSizeHint(self.widget.sizeHint()) def text(self): return self._name def prefix(self): return self._prefix def set_hovered(self, value): self.widget.setProperty('_hovered', value) self.button_name.set_hovered(value) def set_loading(self, value): # self.button_options.setDisabled(value) if value: self.label_icon.setMovie(self.movie) self.movie.start() else: self.label_icon.setMovie(QMovie()) self.button_options.setFocus() def set_selected(self, value): self._selected = value try: self.widget.setProperty('_selected', value) self.button_name.set_selected(value) except RuntimeError: pass self.button_name.setDisabled(value) if value: self.label_icon.setMovie(None) self.button_name.setFocusPolicy(Qt.NoFocus) self.button_options.setVisible(True) self.button_options.setFocus() else: self.label_icon.setMovie(None) self.button_name.setFocusPolicy(Qt.TabFocus) self.button_options.setVisible(False)
class ListItemEnv(ListWidgetItemBase): """Widget to build an item for the environments list.""" def __init__(self, name=None, prefix=None): """Widget to build an item for the environments list.""" super(ListItemEnv, self).__init__() self._selected = False self._name = name self._prefix = prefix # Widgets self.button_options = ButtonEnvironmentOptions() self.button_name = ButtonEnvironmentName(name) self.frame_icon = FrameEnvironmentIcon() self.widget = WidgetEnvironment() self.widget.button_name = self.button_name self.widget.button_options = self.button_options self.spinner = NavigatorSpinner(parent=self.widget, total_width=20) # Widget setup self.button_name.setDefault(True) self.widget.setFocusPolicy(Qt.NoFocus) self.button_name.setFocusPolicy(Qt.StrongFocus) self.button_options.setFocusPolicy(Qt.StrongFocus) self.button_name.setToolTip(prefix if prefix else '') lay = QHBoxLayout() lay.addWidget(self.spinner) self.frame_icon.setLayout(lay) # Layouts layout = QHBoxLayout() layout.addWidget(self.frame_icon) layout.addWidget(self.button_name) layout.addWidget(self.button_options) layout.addStretch() self.widget.setLayout(layout) self.widget.setStyleSheet(load_style_sheet()) self.setSizeHint(self.widget.sizeHint()) def ordered_widgets(self): """Return a list of the ordered widgets.""" return [self.button_name, self.button_options] @property def name(self): """Resturn the environment name.""" return self._name @property def prefix(self): """Return the environment prefix.""" return self._prefix def set_hovered(self, value): """Set widget as hovered.""" self.widget.setProperty('hovered', value) self.button_name.set_hovered(value) def set_loading(self, value): """Set loading status of widget.""" if value: self.spinner.start() else: self.spinner.stop() def set_selected(self, value): """Set widget as selected.""" self._selected = value try: self.widget.setProperty('pressed', value) self.button_name.set_selected(value) except RuntimeError: pass self.button_name.setDisabled(value) self.spinner.stop() if value: self.button_options.setVisible(True) else: self.button_options.setVisible(False) @staticmethod def widget_size(): """Return the size defined in the SASS file.""" return QSize(SASS_VARIABLES.WIDGET_ENVIRONMENT_TOTAL_WIDTH, SASS_VARIABLES.WIDGET_ENVIRONMENT_TOTAL_HEIGHT)