Exemplo n.º 1
0
class ColorButton(QtGui.QPushButton):
    """
    Color choosing push button
    """
    colorChanged = QtCore.Signal(QtGui.QColor)

    def __init__(self, parent=None):
        QtGui.QPushButton.__init__(self, parent)
        self.setFixedSize(20, 20)
        self.setIconSize(QtCore.QSize(12, 12))
        self.clicked.connect(self.choose_color)
        self._color = QtGui.QColor()

    def choose_color(self):
        color = QtGui.QColorDialog.getColor(self._color, self.parentWidget(), '')
        if color.isValid():
            self.set_color(color)

    def get_color(self):
        return self._color

    @QtCore.Slot(QtGui.QColor)
    def set_color(self, color):
        if color != self._color:
            self._color = color
            self.colorChanged.emit(self._color)
            pixmap = QtGui.QPixmap(self.iconSize())
            pixmap.fill(color)
            self.setIcon(QtGui.QIcon(pixmap))

    color = QtCore.Property(QtGui.QColor, get_color, set_color)
Exemplo n.º 2
0
 def __init__(self, color, parent=None):
     QtGui.QHBoxLayout.__init__(self)
     assert isinstance(color, QtGui.QColor)
     self.lineedit = QtGui.QLineEdit(color.name(), parent)
     self.connect(self.lineedit, QtCore.SIGNAL("editingFinished()"),
                  self.update_color)
     self.addWidget(self.lineedit)
     self.colorbtn = ColorButton(parent)
     self.colorbtn.color = color
     self.connect(self.colorbtn, QtCore.SIGNAL("colorChanged(QColor)"),
                  self.update_text)
     self.addWidget(self.colorbtn)
Exemplo n.º 3
0
 def set_color(self, color):
     if color != self._color:
         self._color = color
         self.emit(QtCore.SIGNAL("colorChanged(QColor)"), self._color)
         pixmap = QtGui.QPixmap(self.iconSize())
         pixmap.fill(color)
         self.setIcon(QtGui.QIcon(pixmap))
Exemplo n.º 4
0
class FormTabWidget(QtGui.QWidget):
    update_buttons = QtCore.Signal()

    def __init__(self, datalist, comment="", parent=None):
        QtGui.QWidget.__init__(self, parent)
        layout = QtGui.QVBoxLayout()
        self.tabwidget = QtGui.QTabWidget()
        layout.addWidget(self.tabwidget)
        self.setLayout(layout)
        self.widgetlist = []
        for data, title, comment in datalist:
            if len(data[0]) == 3:
                widget = FormComboWidget(data, comment=comment, parent=self)
            else:
                widget = FormWidget(data, comment=comment, parent=self)
            index = self.tabwidget.addTab(widget, title)
            self.tabwidget.setTabToolTip(index, comment)
            self.widgetlist.append(widget)

    def setup(self):
        for widget in self.widgetlist:
            widget.setup()

    def get(self):
        return [widget.get() for widget in self.widgetlist]
Exemplo n.º 5
0
class FormComboWidget(QtGui.QWidget):
    update_buttons = QtCore.Signal()

    def __init__(self, datalist, comment="", parent=None):
        QtGui.QWidget.__init__(self, parent)
        layout = QtGui.QVBoxLayout()
        self.setLayout(layout)
        self.combobox = QtGui.QComboBox()
        layout.addWidget(self.combobox)

        self.stackwidget = QtGui.QStackedWidget(self)
        layout.addWidget(self.stackwidget)
        self.combobox.currentIndexChanged.connect(self.stackwidget.setCurrentIndex)

        self.widgetlist = []
        for data, title, comment in datalist:
            self.combobox.addItem(title)
            widget = FormWidget(data, comment=comment, parent=self)
            self.stackwidget.addWidget(widget)
            self.widgetlist.append(widget)

    def setup(self):
        for widget in self.widgetlist:
            widget.setup()

    def get(self):
        return [widget.get() for widget in self.widgetlist]
Exemplo n.º 6
0
    def __init__(self, datalist, comment="", parent=None):
        QtGui.QWidget.__init__(self, parent)
        layout = QtGui.QVBoxLayout()
        self.setLayout(layout)
        self.combobox = QtGui.QComboBox()
        layout.addWidget(self.combobox)

        self.stackwidget = QtGui.QStackedWidget(self)
        layout.addWidget(self.stackwidget)
        self.connect(self.combobox, QtCore.SIGNAL("currentIndexChanged(int)"),
                     self.stackwidget, QtCore.SLOT("setCurrentIndex(int)"))

        self.widgetlist = []
        for data, title, comment in datalist:
            self.combobox.addItem(title)
            widget = FormWidget(data, comment=comment, parent=self)
            self.stackwidget.addWidget(widget)
            self.widgetlist.append(widget)
Exemplo n.º 7
0
    def __init__(self,
                 data,
                 title="",
                 comment="",
                 icon=None,
                 parent=None,
                 apply=None):
        QtGui.QDialog.__init__(self, parent)

        self.apply_callback = apply

        # Form
        if isinstance(data[0][0], (list, tuple)):
            self.formwidget = FormTabWidget(data, comment=comment, parent=self)
        elif len(data[0]) == 3:
            self.formwidget = FormComboWidget(data,
                                              comment=comment,
                                              parent=self)
        else:
            self.formwidget = FormWidget(data, comment=comment, parent=self)
        layout = QtGui.QVBoxLayout()
        layout.addWidget(self.formwidget)

        self.float_fields = []
        self.formwidget.setup()

        # Button box
        self.bbox = bbox = QtGui.QDialogButtonBox(
            QtGui.QDialogButtonBox.Ok
            | QtGui.QDialogButtonBox.Cancel)
        self.connect(self.formwidget, QtCore.SIGNAL('update_buttons()'),
                     self.update_buttons)
        if self.apply_callback is not None:
            apply_btn = bbox.addButton(QtGui.QDialogButtonBox.Apply)
            self.connect(apply_btn, QtCore.SIGNAL("clicked()"), self.apply)
        self.connect(bbox, QtCore.SIGNAL("accepted()"),
                     QtCore.SLOT("accept()"))
        self.connect(bbox, QtCore.SIGNAL("rejected()"),
                     QtCore.SLOT("reject()"))
        layout.addWidget(bbox)

        self.setLayout(layout)

        self.setWindowTitle(title)
        if not isinstance(icon, QtGui.QIcon):
            icon = QtGui.QWidget().style().standardIcon(
                QtGui.QStyle.SP_MessageBoxQuestion)
        self.setWindowIcon(icon)
Exemplo n.º 8
0
 def __init__(self, parent=None):
     QtGui.QPushButton.__init__(self, parent)
     self.setFixedSize(20, 20)
     self.setIconSize(QtCore.QSize(12, 12))
     self.connect(self, QtCore.SIGNAL("clicked()"), self.choose_color)
     self._color = QtGui.QColor()
Exemplo n.º 9
0
 def setup(self):
     for label, value in self.data:
         if DEBUG:
             print("value:", value)
         if label is None and value is None:
             # Separator: (None, None)
             self.formlayout.addRow(QtGui.QLabel(" "), QtGui.QLabel(" "))
             self.widgets.append(None)
             continue
         elif label is None:
             # Comment
             self.formlayout.addRow(QtGui.QLabel(value))
             self.widgets.append(None)
             continue
         elif tuple_to_qfont(value) is not None:
             field = FontLayout(value, self)
         elif is_color_like(value):
             field = ColorLayout(to_qcolor(value), self)
         elif isinstance(value, six.string_types):
             field = QtGui.QLineEdit(value, self)
         elif isinstance(value, (list, tuple)):
             if isinstance(value, tuple):
                 value = list(value)
             selindex = value.pop(0)
             field = QtGui.QComboBox(self)
             if isinstance(value[0], (list, tuple)):
                 keys = [key for key, _val in value]
                 value = [val for _key, val in value]
             else:
                 keys = value
             field.addItems(value)
             if selindex in value:
                 selindex = value.index(selindex)
             elif selindex in keys:
                 selindex = keys.index(selindex)
             elif not isinstance(selindex, int):
                 print("Warning: '%s' index is invalid (label: " \
                                 "%s, value: %s)" % (selindex, label, value), file=STDERR)
                 selindex = 0
             field.setCurrentIndex(selindex)
         elif isinstance(value, bool):
             field = QtGui.QCheckBox(self)
             if value:
                 field.setCheckState(QtCore.Qt.Checked)
             else:
                 field.setCheckState(QtCore.Qt.Unchecked)
         elif isinstance(value, float):
             field = QtGui.QLineEdit(repr(value), self)
             field.setValidator(QtGui.QDoubleValidator(field))
             dialog = self.get_dialog()
             dialog.register_float_field(field)
             self.connect(field, QtCore.SIGNAL('textChanged(QString)'),
                          lambda text: dialog.update_buttons())
         elif isinstance(value, int):
             field = QtGui.QSpinBox(self)
             field.setRange(-1e9, 1e9)
             field.setValue(value)
         elif isinstance(value, datetime.datetime):
             field = QtGui.QDateTimeEdit(self)
             field.setDateTime(value)
         elif isinstance(value, datetime.date):
             field = QtGui.QDateEdit(self)
             field.setDate(value)
         else:
             field = QtGui.QLineEdit(repr(value), self)
         self.formlayout.addRow(label, field)
         self.widgets.append(field)
Exemplo n.º 10
0
class FormWidget(QtGui.QWidget):
    update_buttons = QtCore.Signal()
    def __init__(self, data, comment="", parent=None):
        QtGui.QWidget.__init__(self, parent)
        from copy import deepcopy
        self.data = deepcopy(data)
        self.widgets = []
        self.formlayout = QtGui.QFormLayout(self)
        if comment:
            self.formlayout.addRow(QtGui.QLabel(comment))
            self.formlayout.addRow(QtGui.QLabel(" "))
        if DEBUG:
            print("\n"+("*"*80))
            print("DATA:", self.data)
            print("*"*80)
            print("COMMENT:", comment)
            print("*"*80)

    def get_dialog(self):
        """Return FormDialog instance"""
        dialog = self.parent()
        while not isinstance(dialog, QtGui.QDialog):
            dialog = dialog.parent()
        return dialog

    def setup(self):
        for label, value in self.data:
            if DEBUG:
                print("value:", value)
            if label is None and value is None:
                # Separator: (None, None)
                self.formlayout.addRow(QtGui.QLabel(" "), QtGui.QLabel(" "))
                self.widgets.append(None)
                continue
            elif label is None:
                # Comment
                self.formlayout.addRow(QtGui.QLabel(value))
                self.widgets.append(None)
                continue
            elif tuple_to_qfont(value) is not None:
                field = FontLayout(value, self)
            elif is_color_like(value):
                field = ColorLayout(to_qcolor(value), self)
            elif isinstance(value, six.string_types):
                field = QtGui.QLineEdit(value, self)
            elif isinstance(value, (list, tuple)):
                if isinstance(value, tuple):
                    value = list(value)
                selindex = value.pop(0)
                field = QtGui.QComboBox(self)
                if isinstance(value[0], (list, tuple)):
                    keys = [key for key, _val in value]
                    value = [val for _key, val in value]
                else:
                    keys = value
                field.addItems(value)
                if selindex in value:
                    selindex = value.index(selindex)
                elif selindex in keys:
                    selindex = keys.index(selindex)
                elif not isinstance(selindex, int):
                    print("Warning: '%s' index is invalid (label: "
                                    "%s, value: %s)" % (selindex, label, value), file=STDERR)
                    selindex = 0
                field.setCurrentIndex(selindex)
            elif isinstance(value, bool):
                field = QtGui.QCheckBox(self)
                if value:
                    field.setCheckState(QtCore.Qt.Checked)
                else:
                    field.setCheckState(QtCore.Qt.Unchecked)
            elif isinstance(value, float):
                field = QtGui.QLineEdit(repr(value), self)
                field.setValidator(QtGui.QDoubleValidator(field))
                dialog = self.get_dialog()
                dialog.register_float_field(field)
                field.textChanged.connect(lambda text: dialog.update_buttons())
            elif isinstance(value, int):
                field = QtGui.QSpinBox(self)
                field.setRange(-1e9, 1e9)
                field.setValue(value)
            elif isinstance(value, datetime.datetime):
                field = QtGui.QDateTimeEdit(self)
                field.setDateTime(value)
            elif isinstance(value, datetime.date):
                field = QtGui.QDateEdit(self)
                field.setDate(value)
            else:
                field = QtGui.QLineEdit(repr(value), self)
            self.formlayout.addRow(label, field)
            self.widgets.append(field)

    def get(self):
        valuelist = []
        for index, (label, value) in enumerate(self.data):
            field = self.widgets[index]
            if label is None:
                # Separator / Comment
                continue
            elif tuple_to_qfont(value) is not None:
                value = field.get_font()
            elif isinstance(value, six.string_types) or is_color_like(value):
                value = unicode(field.text())
            elif isinstance(value, (list, tuple)):
                index = int(field.currentIndex())
                if isinstance(value[0], (list, tuple)):
                    value = value[index][0]
                else:
                    value = value[index]
            elif isinstance(value, bool):
                value = field.checkState() == QtCore.Qt.Checked
            elif isinstance(value, float):
                value = float(str(field.text()))
            elif isinstance(value, int):
                value = int(field.value())
            elif isinstance(value, datetime.datetime):
                value = field.dateTime().toPyDateTime()
            elif isinstance(value, datetime.date):
                value = field.date().toPyDate()
            else:
                value = eval(str(field.text()))
            valuelist.append(value)
        return valuelist
Exemplo n.º 11
0
    def __init__(self, *args, **kwargs):
        super(UiSubplotTool, self).__init__(*args, **kwargs)
        self.setObjectName('SubplotTool')
        self.resize(450, 265)

        gbox = QtGui.QGridLayout(self)
        self.setLayout(gbox)

        # groupbox borders
        groupbox = QtGui.QGroupBox('Borders', self)
        gbox.addWidget(groupbox, 6, 0, 1, 1)
        self.verticalLayout = QtGui.QVBoxLayout(groupbox)
        self.verticalLayout.setSpacing(0)

        # slider top
        self.hboxtop = QtGui.QHBoxLayout()
        self.labeltop = QtGui.QLabel('top', self)
        self.labeltop.setMinimumSize(QtCore.QSize(50, 0))
        self.labeltop.setAlignment(
            QtCore.Qt.AlignRight |
            QtCore.Qt.AlignTrailing |
            QtCore.Qt.AlignVCenter)

        self.slidertop = QtGui.QSlider(self)
        self.slidertop.setMouseTracking(False)
        self.slidertop.setProperty("value", 0)
        self.slidertop.setOrientation(QtCore.Qt.Horizontal)
        self.slidertop.setInvertedAppearance(False)
        self.slidertop.setInvertedControls(False)
        self.slidertop.setTickPosition(QtGui.QSlider.TicksAbove)
        self.slidertop.setTickInterval(100)

        self.topvalue = QtGui.QLabel('0', self)
        self.topvalue.setMinimumSize(QtCore.QSize(30, 0))
        self.topvalue.setAlignment(
            QtCore.Qt.AlignRight |
            QtCore.Qt.AlignTrailing |
            QtCore.Qt.AlignVCenter)

        self.verticalLayout.addLayout(self.hboxtop)
        self.hboxtop.addWidget(self.labeltop)
        self.hboxtop.addWidget(self.slidertop)
        self.hboxtop.addWidget(self.topvalue)

        # slider bottom
        hboxbottom = QtGui.QHBoxLayout()
        labelbottom = QtGui.QLabel('bottom', self)
        labelbottom.setMinimumSize(QtCore.QSize(50, 0))
        labelbottom.setAlignment(
            QtCore.Qt.AlignRight |
            QtCore.Qt.AlignTrailing |
            QtCore.Qt.AlignVCenter)

        self.sliderbottom = QtGui.QSlider(self)
        self.sliderbottom.setMouseTracking(False)
        self.sliderbottom.setProperty("value", 0)
        self.sliderbottom.setOrientation(QtCore.Qt.Horizontal)
        self.sliderbottom.setInvertedAppearance(False)
        self.sliderbottom.setInvertedControls(False)
        self.sliderbottom.setTickPosition(QtGui.QSlider.TicksAbove)
        self.sliderbottom.setTickInterval(100)

        self.bottomvalue = QtGui.QLabel('0', self)
        self.bottomvalue.setMinimumSize(QtCore.QSize(30, 0))
        self.bottomvalue.setAlignment(
            QtCore.Qt.AlignRight |
            QtCore.Qt.AlignTrailing |
            QtCore.Qt.AlignVCenter)

        self.verticalLayout.addLayout(hboxbottom)
        hboxbottom.addWidget(labelbottom)
        hboxbottom.addWidget(self.sliderbottom)
        hboxbottom.addWidget(self.bottomvalue)

        # slider left
        hboxleft = QtGui.QHBoxLayout()
        labelleft = QtGui.QLabel('left', self)
        labelleft.setMinimumSize(QtCore.QSize(50, 0))
        labelleft.setAlignment(
            QtCore.Qt.AlignRight |
            QtCore.Qt.AlignTrailing |
            QtCore.Qt.AlignVCenter)

        self.sliderleft = QtGui.QSlider(self)
        self.sliderleft.setMouseTracking(False)
        self.sliderleft.setProperty("value", 0)
        self.sliderleft.setOrientation(QtCore.Qt.Horizontal)
        self.sliderleft.setInvertedAppearance(False)
        self.sliderleft.setInvertedControls(False)
        self.sliderleft.setTickPosition(QtGui.QSlider.TicksAbove)
        self.sliderleft.setTickInterval(100)

        self.leftvalue = QtGui.QLabel('0', self)
        self.leftvalue.setMinimumSize(QtCore.QSize(30, 0))
        self.leftvalue.setAlignment(
            QtCore.Qt.AlignRight |
            QtCore.Qt.AlignTrailing |
            QtCore.Qt.AlignVCenter)

        self.verticalLayout.addLayout(hboxleft)
        hboxleft.addWidget(labelleft)
        hboxleft.addWidget(self.sliderleft)
        hboxleft.addWidget(self.leftvalue)

        # slider right
        hboxright = QtGui.QHBoxLayout()
        self.labelright = QtGui.QLabel('right', self)
        self.labelright.setMinimumSize(QtCore.QSize(50, 0))
        self.labelright.setAlignment(
            QtCore.Qt.AlignRight |
            QtCore.Qt.AlignTrailing |
            QtCore.Qt.AlignVCenter)

        self.sliderright = QtGui.QSlider(self)
        self.sliderright.setMouseTracking(False)
        self.sliderright.setProperty("value", 0)
        self.sliderright.setOrientation(QtCore.Qt.Horizontal)
        self.sliderright.setInvertedAppearance(False)
        self.sliderright.setInvertedControls(False)
        self.sliderright.setTickPosition(QtGui.QSlider.TicksAbove)
        self.sliderright.setTickInterval(100)

        self.rightvalue = QtGui.QLabel('0', self)
        self.rightvalue.setMinimumSize(QtCore.QSize(30, 0))
        self.rightvalue.setAlignment(
            QtCore.Qt.AlignRight |
            QtCore.Qt.AlignTrailing |
            QtCore.Qt.AlignVCenter)

        self.verticalLayout.addLayout(hboxright)
        hboxright.addWidget(self.labelright)
        hboxright.addWidget(self.sliderright)
        hboxright.addWidget(self.rightvalue)

        # groupbox spacings
        groupbox = QtGui.QGroupBox('Spacings', self)
        gbox.addWidget(groupbox, 7, 0, 1, 1)
        self.verticalLayout = QtGui.QVBoxLayout(groupbox)
        self.verticalLayout.setSpacing(0)

        # slider hspace
        hboxhspace = QtGui.QHBoxLayout()
        self.labelhspace = QtGui.QLabel('hspace', self)
        self.labelhspace.setMinimumSize(QtCore.QSize(50, 0))
        self.labelhspace.setAlignment(
            QtCore.Qt.AlignRight |
            QtCore.Qt.AlignTrailing |
            QtCore.Qt.AlignVCenter)

        self.sliderhspace = QtGui.QSlider(self)
        self.sliderhspace.setMouseTracking(False)
        self.sliderhspace.setProperty("value", 0)
        self.sliderhspace.setOrientation(QtCore.Qt.Horizontal)
        self.sliderhspace.setInvertedAppearance(False)
        self.sliderhspace.setInvertedControls(False)
        self.sliderhspace.setTickPosition(QtGui.QSlider.TicksAbove)
        self.sliderhspace.setTickInterval(100)

        self.hspacevalue = QtGui.QLabel('0', self)
        self.hspacevalue.setMinimumSize(QtCore.QSize(30, 0))
        self.hspacevalue.setAlignment(
            QtCore.Qt.AlignRight |
            QtCore.Qt.AlignTrailing |
            QtCore.Qt.AlignVCenter)

        self.verticalLayout.addLayout(hboxhspace)
        hboxhspace.addWidget(self.labelhspace)
        hboxhspace.addWidget(self.sliderhspace)
        hboxhspace.addWidget(self.hspacevalue)  # slider hspace

        # slider wspace
        hboxwspace = QtGui.QHBoxLayout()
        self.labelwspace = QtGui.QLabel('wspace', self)
        self.labelwspace.setMinimumSize(QtCore.QSize(50, 0))
        self.labelwspace.setAlignment(
            QtCore.Qt.AlignRight |
            QtCore.Qt.AlignTrailing |
            QtCore.Qt.AlignVCenter)

        self.sliderwspace = QtGui.QSlider(self)
        self.sliderwspace.setMouseTracking(False)
        self.sliderwspace.setProperty("value", 0)
        self.sliderwspace.setOrientation(QtCore.Qt.Horizontal)
        self.sliderwspace.setInvertedAppearance(False)
        self.sliderwspace.setInvertedControls(False)
        self.sliderwspace.setTickPosition(QtGui.QSlider.TicksAbove)
        self.sliderwspace.setTickInterval(100)

        self.wspacevalue = QtGui.QLabel('0', self)
        self.wspacevalue.setMinimumSize(QtCore.QSize(30, 0))
        self.wspacevalue.setAlignment(
            QtCore.Qt.AlignRight |
            QtCore.Qt.AlignTrailing |
            QtCore.Qt.AlignVCenter)

        self.verticalLayout.addLayout(hboxwspace)
        hboxwspace.addWidget(self.labelwspace)
        hboxwspace.addWidget(self.sliderwspace)
        hboxwspace.addWidget(self.wspacevalue)

        # button bar
        hbox2 = QtGui.QHBoxLayout()
        gbox.addLayout(hbox2, 8, 0, 1, 1)
        self.tightlayout = QtGui.QPushButton('Tight Layout', self)
        spacer = QtGui.QSpacerItem(
            5, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
        self.resetbutton = QtGui.QPushButton('Reset', self)
        self.donebutton = QtGui.QPushButton('Close', self)
        self.donebutton.setFocus(True)
        hbox2.addWidget(self.tightlayout)
        hbox2.addItem(spacer)
        hbox2.addWidget(self.resetbutton)
        hbox2.addWidget(self.donebutton)

        self.donebutton.clicked.connect(self.accept)
Exemplo n.º 12
0
class FigureWindow(QtGui.QMdiSubWindow):
    """
    A basic MDI sub-window, but with a closing signal, and an activate QAction,
    which allows for switching between all FigureWindows (e.g. by a
    Windows-menu). An exclusive, static action group makes sure only one
    window can be active at the time. If you want to split the windows into
    different groups that can be treated separately, you will need to create
    your own QActionGroups.
    """
    closing = QtCore.Signal()

    activeFigureActionGroup = QtGui.QActionGroup(None)
    activeFigureActionGroup.setExclusive(True)

    def __init__(self, *args, **kwargs):
        super(FigureWindow, self).__init__(*args, **kwargs)
        self._activate_action = None
        if os.environ['QT_API'] != 'pyside':
            self.windowStateChanged.connect(self._windowStateChanged)

    def closeEvent(self, event):
        self.closing.emit()
        super(FigureWindow, self).closeEvent(event)

    def activateAction(self):
        """
        Returns a QAction that will activate the window with setActiveSubWindow
        as long as it has an mdiArea set. If not, it will use activateWindow to
        try to make it the active window.
        """
        if self._activate_action is not None:
            return self._activate_action
        self._activate_action = QtGui.QAction(self.windowTitle(), self)
        self._activate_action.setCheckable(True)
        self._activate_action.triggered.connect(self._activate_triggered)
        self.activeFigureActionGroup.addAction(self._activate_action)
        return self._activate_action

    def setWindowTitle(self, title):
        # Overridden to keep action text updated
        super(FigureWindow, self).setWindowTitle(title)
        if self._activate_action is not None:
            self._activate_action.setText(title)

    def _windowStateChanged(self, oldState, newState):
        # Event for tracking if we're active or not
        isactive = newState & QtCore.Qt.WindowActive
        if isactive == oldState & QtCore.Qt.WindowActive:
            return  # Another window state changed, e.g. activation
        self._activate_action.setChecked(isactive)

    def _activate_triggered(self, checked=True):
        # Activate action triggered, make window active
        if self.mdiArea():
            self.mdiArea().setActiveSubWindow(self)
        else:
            self.activateWindow()  # If not subwindow

        if self.isMinimized():
            self.showNormal()  # Restore minimized window
        if not checked:
            # User unchecked, which makes no sense, recheck
            self._activate_action.setChecked(True)