######################################################################################################################
# Copyright (C) 2017-2022 Spine project consortium
# Copyright Spine Toolbox contributors
# This file is part of Spine Toolbox.
# Spine Toolbox is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
# any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
# without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
# Public License for more details. You should have received a copy of the GNU Lesser General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.
######################################################################################################################
"""Contains the MultiTabSpecEditor class."""
from PySide6.QtCore import Qt
from PySide6.QtGui import QIcon
from PySide6.QtWidgets import QMenu
from .multi_tab_window import MultiTabWindow
[docs]class MultiTabSpecEditor(MultiTabWindow):
def __init__(self, toolbox, item_type):
super().__init__(toolbox.qsettings(), f"{item_type}SpecEditor")
self.setStyleSheet(toolbox.styleSheet())
self._toolbox = toolbox
self.item_type = item_type
self.setWindowTitle(f"{item_type} specification editor".capitalize())
icon = QIcon(self._toolbox.item_factories[item_type].icon())
self.setWindowIcon(icon)
[docs] def _make_other(self):
return MultiTabSpecEditor(self._toolbox, self.item_type)
[docs] def _make_new_tab(self, *args, **kwargs):
tab = self._toolbox.item_factories[self.item_type].make_specification_editor(self._toolbox, *args, **kwargs)
tab.setAttribute(Qt.WA_DeleteOnClose, True)
return tab
[docs] def _connect_tab_signals(self, tab):
"""Connects spec editor window (tab) signals.
Args:
tab (SpecificationEditorWindowBase): Specification editor window
Returns:
bool: True if ok, False otherwise
"""
if not super()._connect_tab_signals(tab):
return False
tab.spec_toolbar().close_action.triggered.connect(self.handle_close_request_from_tab)
return True
[docs] def _disconnect_tab_signals(self, index):
"""Disconnects signals of spec editor window (tab) in given index.
Args:
index (int): Tab index
Returns:
bool: True if ok, False otherwise
"""
if not super()._disconnect_tab_signals(index):
return False
tab = self.tab_widget.widget(index)
tab.spec_toolbar().close_action.triggered.disconnect(self.handle_close_request_from_tab)
return True
@property
[docs] def new_tab_title(self):
return "<unnamed specification>"