Manually make close tab buttons in macOS, because PySide2 is not showing the button on its own

This commit is contained in:
Micah Lee 2020-11-04 16:08:11 -08:00
parent b2f30e90b3
commit 7a0436a216
No known key found for this signature in database
GPG Key ID: 403C2657CD994F73
2 changed files with 17 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 688 B

View File

@ -156,6 +156,23 @@ class TabWidget(QtWidgets.QTabWidget):
index = self.addTab(tab, strings._("gui_new_tab"))
self.setCurrentIndex(index)
# In macOS, manually create a close button because tabs don't seem to have them otherwise
if self.common.platform == "Darwin":
def close_tab():
self.tabBar().tabCloseRequested.emit(self.indexOf(tab))
tab.close_button = QtWidgets.QPushButton()
tab.close_button.setFlat(True)
tab.close_button.setFixedWidth(40)
tab.close_button.setIcon(
QtGui.QIcon(GuiCommon.get_resource_path("images/close_tab.png"))
)
tab.close_button.clicked.connect(close_tab)
self.tabBar().setTabButton(
index, QtWidgets.QTabBar.RightSide, tab.close_button
)
tab.init(mode_settings)
# If it's persistent, set the persistent image in the tab
self.change_persistent(tab.tab_id, tab.settings.get("persistent", "enabled"))