示例#1
0
    def __init__(self, state=None, **args):
        super().__init__(**args)
        self.criterion = None
        self.domain = domains.domains[0]

        self.worker = utils.worker.Worker()
        self.worker.done.connect(self.updateTable)
        self.worker.start()

        self.flagFilter = []

        # Initialize GUI
        layout = QtWidgets.QVBoxLayout(self)
        topLayout = QtWidgets.QHBoxLayout()
        layout.addLayout(topLayout)

        self.searchBox = searchgui.SearchBox()
        self.searchBox.criterionChanged.connect(self._handleCriterionChanged)
        topLayout.addWidget(self.searchBox)

        self.instantSearchBox = QtWidgets.QCheckBox(self.tr("Instant search"))
        self.instantSearchBox.setChecked(True)
        self.instantSearchBox.clicked.connect(self.searchBox.setInstantSearch)
        topLayout.addWidget(self.instantSearchBox)

        self.domainBox = guiwidgets.DomainBox()
        self.domainBox.domainChanged.connect(self.setDomain)
        topLayout.addWidget(self.domainBox)

        topLayout.addStretch(1)

        self.table = QtWidgets.QTableWidget()
        self.table.horizontalHeader().hide()
        layout.addWidget(self.table)
示例#2
0
    def createOptionDialog(self, button=None):
        from maestro.gui import widgets as guiwidgets, dialogs
        dialog = dialogs.FancyPopup(button)
        layout = QtWidgets.QVBoxLayout(dialog)

        def setDomain(domain):
            self.view.scene().domain = domain

        domainBox = guiwidgets.DomainBox(self.view.scene().domain)
        domainBox.domainChanged.connect(setDomain)
        layout.addWidget(domainBox)
        layout.addStretch()
        dialog.show()
示例#3
0
    def __init__(self, parent, browser):
        super().__init__(parent, 300, 200)
        self.browser = browser
        self.viewConfigurations = []

        filterTab = QtWidgets.QWidget()
        filterTab.setLayout(QtWidgets.QVBoxLayout())
        self.tabWidget.addTab(filterTab, self.tr("Filter"))

        domainLayout = QtWidgets.QHBoxLayout()
        domainLayout.addWidget(QtWidgets.QLabel(self.tr("Domain:")))
        self.domainBox = guiwidgets.DomainBox(self.browser.getDomain())
        self.domainBox.domainChanged.connect(self.browser.setDomain)
        domainLayout.addWidget(self.domainBox)
        filterTab.layout().addLayout(domainLayout)

        filterTab.layout().addWidget(QtWidgets.QLabel(self.tr("Flags:")))
        flagList = self.browser.flagCriterion.flags if self.browser.flagCriterion is not None else []

        self.flagView = searchgui.FlagView(flagList)
        self.flagView.selectionChanged.connect(browser.setFlagFilter)
        filterTab.layout().addWidget(self.flagView)

        filterCriterionLayout = QtWidgets.QHBoxLayout()
        filterCriterionLayout.addWidget(QtWidgets.QLabel(self.tr("General:")))
        filterCriterionLine = searchgui.CriterionLineEdit(
            self.browser.filterCriterion)
        filterCriterionLine.criterionChanged.connect(
            self.browser.setFilterCriterion)
        filterCriterionLine.criterionCleared.connect(
            functools.partial(self.browser.setFilterCriterion, None))

        filterCriterionLayout.addWidget(filterCriterionLine)
        filterTab.layout().addLayout(filterCriterionLayout)

        self.optionTab = QtWidgets.QWidget()
        self.optionTab.setLayout(QtWidgets.QVBoxLayout())
        self.tabWidget.addTab(self.optionTab, self.tr("Options"))
示例#4
0
    def __init__(self, model, wrappers, parent=None):
        """Set up the dialog for *wrappers* (all with the same parent) in *model*.
        
        *parent* refers to the Qt parent object.
        """
        super().__init__(parent)
        self.setMinimumSize(400, 250)
        self.setWindowTitle(self.tr("Merge elements"))
        self.model = model
        self.wrappers = wrappers
        self.elements = [wrapper.element for wrapper in wrappers]
        self.level = self.elements[0].level
        self.parentNode = wrappers[0].parent

        domain = self.wrappers[0].element.domain
        containerType = config.storage.gui.merge_dialog_container_type or self.DefaultType

        titleHint = ''
        prefix = ''
        if len(self.elements) > 1:
            allTitles = []
            for element in self.elements:
                if tags.TITLE in element.tags:
                    allTitles.extend(element.tags[tags.TITLE])
            # We require that the common title is separated from the rest by whitespace or punctuation
            # Otherwise elements that happen to start with the same letter would give a common prefix.
            prefix = utils.strings.commonPrefix(allTitles, separated=True)
            if len(prefix) > 0:
                import string
                titleHint = prefix.strip(string.punctuation +
                                         string.whitespace)
        elif len(self.elements) == 1:
            titleHint = ' - '.join(self.elements[0].tags[tags.TITLE])

        layout = QtWidgets.QGridLayout()
        self.setLayout(layout)

        row = 0
        titleLineLayout = QtWidgets.QHBoxLayout()
        layout.addLayout(titleLineLayout, row, 0, 1, 2)
        titleLineLayout.addWidget(
            QtWidgets.QLabel(self.tr('Title of new container:')))
        self.titleEdit = QtWidgets.QLineEdit(titleHint)
        titleLineLayout.addWidget(self.titleEdit)

        from maestro.gui import widgets as guiwidgets

        row += 1
        label = QtWidgets.QLabel(self.tr('Domain:'))
        layout.addWidget(label, row, 0)
        self.domainBox = guiwidgets.DomainBox(domain)
        layout.addWidget(self.domainBox, row, 1)

        row += 1
        label = QtWidgets.QLabel(self.tr('Container type:'))
        layout.addWidget(label, row, 0)
        self.parentTypeBox = guiwidgets.ContainerTypeBox(containerType)
        layout.addWidget(self.parentTypeBox, row, 1)

        row += 1
        label = QtWidgets.QLabel(self.tr("Options"))
        label.setStyleSheet("QLabel { font-weight: bold }")
        label.setContentsMargins(0, 10, 0, 0)
        layout.addWidget(label, row, 0, 1, 2)

        row += 1
        self.commonTagsBox = QtWidgets.QCheckBox(
            self.tr("Assign common tags and flags"))
        self.commonTagsBox.setChecked(True)
        layout.addWidget(self.commonTagsBox, row, 0, 1, 2)

        if isinstance(self.parentNode, nodes.Wrapper):
            row += 1
            self.positionCheckBox = QtWidgets.QCheckBox(
                self.tr('Auto-adjust positions'))
            self.positionCheckBox.setChecked(True)
            layout.addWidget(self.positionCheckBox, row, 0, 1, 2)

        if any(element.isContainer() for element in self.elements):
            row += 1
            self.changeTypeBox = QtWidgets.QCheckBox(
                self.tr("Change content container types to:"))
            self.changeTypeBox.setChecked(False)
            layout.addWidget(self.changeTypeBox, row, 0)
            self.childrenTypeBox = guiwidgets.ContainerTypeBox(
                ContainerType.Container)
            layout.addWidget(self.childrenTypeBox, row, 1)
            self.childrenTypeBox.setEnabled(False)
            self.changeTypeBox.toggled.connect(self.childrenTypeBox.setEnabled)

        if len(prefix) > 0:
            row += 1
            self.removePrefixBox = QtWidgets.QCheckBox(
                self.tr("Remove common title prefix:"))
            self.removePrefixBox.setChecked(True)
            layout.addWidget(self.removePrefixBox, row, 0)
            self.removeEdit = QtWidgets.QLineEdit(prefix)
            layout.addWidget(self.removeEdit, row, 1)
            self.removePrefixBox.toggled.connect(self.removeEdit.setEnabled)

        if len(self.elements) > 1 and any(
                utils.strings.numberFromPrefix(title[len(prefix):])[0]
                is not None for title in allTitles):
            row += 1
            self.removeNumbersBox = QtWidgets.QCheckBox(
                self.tr("Remove numbers from title start"))
            self.removeNumbersBox.setChecked(True)
            layout.addWidget(self.removeNumbersBox, row, 0)

        row += 1
        layout.setRowStretch(row, 1)

        row += 1
        buttons = QtWidgets.QDialogButtonBox(QtWidgets.QDialogButtonBox.Cancel
                                             | QtWidgets.QDialogButtonBox.Ok)
        buttons.accepted.connect(self.performMerge)
        buttons.rejected.connect(self.reject)
        layout.addWidget(buttons, row, 0, 1, 2)
示例#5
0
    def __init__(self, profile, parent=None):
        super().__init__(profile, parent)
        self.setLayout(QtWidgets.QVBoxLayout())
        self.layout().setContentsMargins(1, 1, 1, 1)

        layout = QtWidgets.QFormLayout()
        self.domainBox = widgets.DomainBox(profile.domain)
        self.domainBox.domainChanged.connect(self._handleDomainChanged)
        if profile.domain is None:
            profile.domain = self.domainBox.currentDomain()
        layout.addRow(self.tr("Domain:"), self.domainBox)
        lineLayout = QtWidgets.QHBoxLayout()
        self.criterionLineEdit = searchgui.CriterionLineEdit(profile.criterion)
        self.criterionLineEdit.criterionChanged.connect(
            self._handleCriterionLineEdit)
        self.criterionLineEdit.criterionCleared.connect(
            self._handleCriterionLineEdit)
        lineLayout.addWidget(self.criterionLineEdit, 1)
        layout.addRow(self.tr("Filter:"), lineLayout)
        self.flagButton = QtWidgets.QPushButton()
        self.flagButton.setIcon(utils.images.icon('flag'))
        self.flagButton.setIconSize(QtCore.QSize(16, 16))
        self.flagButton.clicked.connect(self._handleFlagButton)
        lineLayout.addWidget(self.flagButton)
        self.layout().addLayout(layout)
        #self.layout().addWidget(
        #                    collapsiblepanel.CollapsiblePanel(self.tr("Choose elements to export"), layout))

        layout = QtWidgets.QFormLayout()
        self.pathLineEdit = lineedits.PathLineEdit(
            self.tr("Choose an export directory"),
            pathType="existingDirectory",
            path=profile.path)
        self.pathLineEdit.textChanged.connect(self._handlePathEditingFinished)
        layout.addRow(self.tr("Path:"), self.pathLineEdit)
        self.structureBox = QtWidgets.QComboBox()
        self.structureBox.addItem(self.tr("Keep directory structure"),
                                  STRUCTURE_KEEP)
        self.structureBox.addItem(
            self.tr("Put all files into target directory"), STRUCTURE_FLAT)
        self.structureBox.setCurrentIndex(profile.structure)
        self.structureBox.currentIndexChanged.connect(self._handleStructureBox)
        layout.addRow(self.tr("Structure:"), self.structureBox)
        self.deleteBox = QtWidgets.QCheckBox(
            self.tr("Delete unexported files from target directory"))
        self.deleteBox.toggled.connect(
            lambda x: self.profile.setOption(OPTION_DELETE, x))
        layout.addRow(self.deleteBox)
        self.layout().addLayout(layout)
        #self.layout().addWidget(collapsiblepanel.CollapsiblePanel(self.tr("Export location"), layout))

        layout = QtWidgets.QFormLayout()
        self.includeWorkTitlesBox = QtWidgets.QCheckBox(
            self.tr("Include titles of works into the works' contents."))
        self.includeWorkTitlesBox.toggled.connect(
            lambda x: self.profile.setOption(OPTION_INCLUDE_WORK_TITLES, x))
        layout.addRow(self.includeWorkTitlesBox)
        self.layout().addLayout(layout)
        #self.layout().addWidget(collapsiblepanel.CollapsiblePanel(self.tr("Tag modifications"), layout))

        self.layout().addStretch(1)
        self.setProfile(profile)