def load_hotboxes(application): hotboxes_datas = load_hotboxes_datas(application.local_file) file_ = application.shared_file hotboxes_datas += [ ensure_old_data_compatible(load_json(f)) for f in load_json(file_)] for hotboxes_data in hotboxes_datas: name = hotboxes_data['general']['name'] reader = HotboxReader(hotboxes_data, parent=None) reader.hideSubmenusRequested.connect(hide_submenus) hotboxes[name] = reader
def __init__(self, software): parent = software.main_window super(HotboxManager, self).__init__(parent, QtCore.Qt.Tool) self.setWindowTitle('Hotbox Designer') self.software = software self.hotbox_editor = None hotboxes_data = load_hotboxes_datas(self.software.file) self.table_model = HotboxTableModel(hotboxes_data) self.table_view = HotboxTableView() self.table_view.set_model(self.table_model) self.table_view.selectedRowChanged.connect(self._selected_row_changed) self.toolbar = HotboxManagerToolbar() self.toolbar.newRequested.connect(self._call_create) self.toolbar.editRequested.connect(self._call_edit) self.toolbar.deleteRequested.connect(self._call_remove) self.toolbar.importRequested.connect(self._call_import) self.toolbar.exportRequested.connect(self._call_export) self.toolbar.reloadRequested.connect(self._call_reload) self.edit = HotboxGeneralSettingWidget() self.edit.optionSet.connect(self._call_option_set) self.edit.setEnabled(False) self.edit.open_command.released.connect(self._call_open_command) self.edit.close_command.released.connect(self._call_close_command) self.edit.switch_command.released.connect(self._call_switch_command) self.hlayout = QtWidgets.QHBoxLayout() self.hlayout.setContentsMargins(8, 0, 8, 8) self.hlayout.setSpacing(4) self.hlayout.addWidget(self.table_view) self.hlayout.addWidget(self.edit) self.layout = QtWidgets.QVBoxLayout(self) self.layout.setContentsMargins(0, 0, 0, 0) self.layout.setSpacing(0) self.layout.addWidget(self.toolbar) self.layout.addLayout(self.hlayout)
def __init__(self, application): parent = application.main_window super(HotboxManager, self).__init__(parent, QtCore.Qt.Tool) self.setWindowTitle('Hotbox Designer') self.application = application self.hotbox_designer = None hotboxes_data = load_hotboxes_datas(self.application.local_file) self.personnal_model = HotboxPersonalTableModel(hotboxes_data) self.personnal_view = HotboxTableView() self.personnal_view.set_model(self.personnal_model) method = self._personnal_selected_row_changed self.personnal_view.selectedRowChanged.connect(method) self.toolbar = HotboxManagerToolbar() self.toolbar.reload.setEnabled(True) self.toolbar.link.setEnabled(False) self.toolbar.unlink.setEnabled(False) self.toolbar.newRequested.connect(self._call_create) self.toolbar.linkRequested.connect(self._call_add_link) self.toolbar.unlinkRequested.connect(self._call_unlink) self.toolbar.editRequested.connect(self._call_edit) self.toolbar.deleteRequested.connect(self._call_remove) self.toolbar.importRequested.connect(self._call_import) self.toolbar.exportRequested.connect(self._call_export) self.toolbar.reloadRequested.connect(self._call_reload) self.toolbar.setHotkeyRequested.connect(self._call_set_hotkey) setter_enabled = bool(application.available_set_hotkey_modes) self.toolbar.hotkeyset.setEnabled(setter_enabled) self.edit = HotboxGeneralSettingWidget() self.edit.optionSet.connect(self._call_option_set) self.edit.setEnabled(False) self.edit.open_command.released.connect(self._call_open_command) method = self._call_play_open_command self.edit.open_command.playReleased.connect(method) self.edit.close_command.released.connect(self._call_close_command) method = self._call_play_close_command self.edit.close_command.playReleased.connect(method) self.edit.switch_command.released.connect(self._call_switch_command) method = self._call_play_switch_command self.edit.switch_command.playReleased.connect(method) self.personnal = QtWidgets.QWidget() self.hlayout = QtWidgets.QHBoxLayout(self.personnal) self.hlayout.setContentsMargins(8, 0, 8, 8) self.hlayout.setSpacing(4) self.hlayout.addWidget(self.personnal_view) self.hlayout.addWidget(self.edit) links = load_json(application.shared_file, default=[]) self.shared_model = HotboxSharedTableModel(links) self.shared_view = HotboxTableView() self.shared_view.set_model(self.shared_model) method = self._shared_selected_row_changed self.shared_view.selectedRowChanged.connect(method) self.infos = HotboxGeneralInfosWidget() self.infos.setEnabled(False) self.infos.open_command.released.connect(self._call_open_command) method = self._call_play_open_command self.infos.open_command.playReleased.connect(method) self.infos.close_command.released.connect(self._call_close_command) method = self._call_play_close_command self.infos.close_command.playReleased.connect(method) self.infos.switch_command.released.connect(self._call_switch_command) method = self._call_play_switch_command self.infos.switch_command.playReleased.connect(method) self.shared = QtWidgets.QWidget() self.hlayout2 = QtWidgets.QHBoxLayout(self.shared) self.hlayout2.setContentsMargins(8, 0, 8, 8) self.hlayout2.setSpacing(4) self.hlayout2.addWidget(self.shared_view) self.hlayout2.addWidget(self.infos) self.tabwidget = QtWidgets.QTabWidget() self.tabwidget.addTab(self.personnal, "Personal") self.tabwidget.addTab(self.shared, "Shared") self.tabwidget.currentChanged.connect(self.tab_index_changed) self.layout = QtWidgets.QVBoxLayout(self) self.layout.setContentsMargins(0, 0, 0, 0) self.layout.setSpacing(0) self.layout.addWidget(self.toolbar) self.layout.addWidget(self.tabwidget)
def load_hotboxes(software): hotboxes_datas = load_hotboxes_datas(software.file) for hotboxes_data in hotboxes_datas: name = hotboxes_data['general']['name'] reader = HotboxReader(hotboxes_data, parent=None) hotboxes[name] = reader