<commit_before>
from functools import partial

import pulse
from pulse.vendor.Qt import QtCore, QtWidgets
from pulse.prefs import optionVarProperty

from .core import PulseWindow
from .blueprinteditor import BlueprintEditorWidget
from .buildtoolbar import BuildToolbarWidget
from .actiontree import ActionTreeWidget, ActionPaletteWidget
from .actioneditor import ActionEditorWidget
from .designview import DesignViewWidget


__all__ = [
    'PulseEditorWindow',
]


class PulseEditorWindow(PulseWindow):
    """
    An all-in-one window that contains all pulse editors.
    """

    OBJECT_NAME = 'pulseEditorWindow'

    mainTabIndex = optionVarProperty('pulse.editor.mainTabIndex', 0)
    actionsTabIndex = optionVarProperty('pulse.editor.actionsTabIndex', 0)

    def __init__(self, parent=None):
        super(PulseEditorWindow, self).__init__(parent=parent)

        self.setWindowTitle('Pulse')

        pulse.loadBuiltinActions()

        self.setupUi(self)

        self.mainTabWidget.setCurrentIndex(self.mainTabIndex)
        self.actionsTabWidget.setCurrentIndex(self.actionsTabIndex)

        # connect signals
        self.mainTabWidget.currentChanged.connect(
            partial(setattr, self, 'mainTabIndex'))
        self.actionsTabWidget.currentChanged.connect(
            partial(setattr, self, 'actionsTabIndex'))

    def setupUi(self, parent):
        widget = QtWidgets.QWidget(parent)
        widget.setMinimumWidth(300)
        self.setCentralWidget(widget)

        layout = QtWidgets.QVBoxLayout(parent)
        layout.setMargin(0)
        widget.setLayout(layout)

        buildToolbar = BuildToolbarWidget(parent)
        layout.addWidget(buildToolbar)

        # main tab widget (Config / Design / Actions)
        tabWidget = QtWidgets.QTabWidget(parent)

        # config tab
        configTab = BlueprintEditorWidget(parent)
        tabWidget.addTab(configTab, "Config")

        # design tab
        designTab = DesignViewWidget(parent)
        tabWidget.addTab(designTab, "Design")

        # actions tab
        actionsTab = QtWidgets.QWidget(parent)
        actionsLayout = QtWidgets.QVBoxLayout(actionsTab)

        actionsSplitter = QtWidgets.QSplitter(parent)
        actionsSplitter.setOrientation(QtCore.Qt.Orientation.Vertical)
        actionsLayout.addWidget(actionsSplitter)

        actionTree = ActionTreeWidget(actionsTab)
        actionTree.layout().setMargin(0)
        actionsSplitter.addWidget(actionTree)

        # actions tab widget (Palette / Editor)
        actionsTabWidget = QtWidgets.QTabWidget(parent)
        actionsSplitter.addWidget(actionsTabWidget)

        actionPalette = ActionPaletteWidget(actionsTab)
        actionPalette.layout().setMargin(0)
        actionsTabWidget.addTab(actionPalette, "Palette")

        actionEditor = ActionEditorWidget(actionsTab)
        actionEditor.layout().setMargin(0)
        actionsTabWidget.addTab(actionEditor, "Editor")

        tabWidget.addTab(actionsTab, "Actions")

        layout.addWidget(tabWidget)

        self.mainTabWidget = tabWidget
        self.actionsTabWidget = actionsTabWidget
<commit_msg>simplifies how tab indeces are saved<commit_after>
from functools import partial

import pulse
from pulse.vendor.Qt import QtCore, QtWidgets
from pulse.prefs import optionVarProperty

from .core import PulseWindow
from .blueprinteditor import BlueprintEditorWidget
from .buildtoolbar import BuildToolbarWidget
from .actiontree import ActionTreeWidget, ActionPaletteWidget
from .actioneditor import ActionEditorWidget
from .designview import DesignViewWidget


__all__ = [
    'PulseEditorWindow',
]


class PulseEditorWindow(PulseWindow):
    """
    An all-in-one window that contains all pulse editors.
    """

    OBJECT_NAME = 'pulseEditorWindow'

    mainTabIndex = optionVarProperty('pulse.editor.mainTabIndex', 0)
    actionsTabIndex = optionVarProperty('pulse.editor.actionsTabIndex', 0)

    def setMainTabIndex(self, index):
        self.mainTabIndex = index

    def setActionsTabIndex(self, index):
        self.actionsTabIndex = index

    def __init__(self, parent=None):
        super(PulseEditorWindow, self).__init__(parent=parent)

        self.setWindowTitle('Pulse')

        pulse.loadBuiltinActions()

        self.setupUi(self)

        self.mainTabWidget.setCurrentIndex(self.mainTabIndex)
        self.actionsTabWidget.setCurrentIndex(self.actionsTabIndex)

        # connect signals
        self.mainTabWidget.currentChanged.connect(self.setMainTabIndex)
        self.actionsTabWidget.currentChanged.connect(self.setActionsTabIndex)

    def setupUi(self, parent):
        widget = QtWidgets.QWidget(parent)
        widget.setMinimumWidth(300)
        self.setCentralWidget(widget)

        layout = QtWidgets.QVBoxLayout(parent)
        layout.setMargin(0)
        widget.setLayout(layout)

        buildToolbar = BuildToolbarWidget(parent)
        layout.addWidget(buildToolbar)

        # main tab widget (Config / Design / Actions)
        tabWidget = QtWidgets.QTabWidget(parent)

        # config tab
        configTab = BlueprintEditorWidget(parent)
        tabWidget.addTab(configTab, "Config")

        # design tab
        designTab = DesignViewWidget(parent)
        tabWidget.addTab(designTab, "Design")

        # actions tab
        actionsTab = QtWidgets.QWidget(parent)
        actionsLayout = QtWidgets.QVBoxLayout(actionsTab)

        actionsSplitter = QtWidgets.QSplitter(parent)
        actionsSplitter.setOrientation(QtCore.Qt.Orientation.Vertical)
        actionsLayout.addWidget(actionsSplitter)

        actionTree = ActionTreeWidget(actionsTab)
        actionTree.layout().setMargin(0)
        actionsSplitter.addWidget(actionTree)

        # actions tab widget (Palette / Editor)
        actionsTabWidget = QtWidgets.QTabWidget(parent)
        actionsSplitter.addWidget(actionsTabWidget)

        actionPalette = ActionPaletteWidget(actionsTab)
        actionPalette.layout().setMargin(0)
        actionsTabWidget.addTab(actionPalette, "Palette")

        actionEditor = ActionEditorWidget(actionsTab)
        actionEditor.layout().setMargin(0)
        actionsTabWidget.addTab(actionEditor, "Editor")

        tabWidget.addTab(actionsTab, "Actions")

        layout.addWidget(tabWidget)

        self.mainTabWidget = tabWidget
        self.actionsTabWidget = actionsTabWidget

{'fraction_non_alphanumeric': 0.08037825059101655, 'fraction_numerical': 0.0028368794326241137, 'mean_word_length': 3.3585164835164836, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2392296', 'n_tokens_mistral': 1763, 'n_tokens_neox': 1717, 'n_words': 317}