From 3ceab336f944f657c037330173ea4a136cfb1de2 Mon Sep 17 00:00:00 2001 From: Micah Lee Date: Sat, 26 Oct 2019 22:39:59 -0700 Subject: [PATCH] One attempt at making a new tab button --- onionshare_gui/gui_common.py | 10 ++++++++++ onionshare_gui/main_window.py | 20 +++++++++++++++++--- share/locale/en.json | 2 ++ 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/onionshare_gui/gui_common.py b/onionshare_gui/gui_common.py index 3344d879..9241dbf6 100644 --- a/onionshare_gui/gui_common.py +++ b/onionshare_gui/gui_common.py @@ -50,6 +50,16 @@ class GuiCommon: self.css = { # OnionShareGui styles + "tab_bar_new_tab": """ + QTabBar::tab:last { + border: 0; + margin: 3px; + }""", + "tab_bar_new_tab_button": """ + QToolButton { + font-weight: bold; + font-size: 20px; + }""", "new_tab_button": """ QPushButton { font-weight: bold; diff --git a/onionshare_gui/main_window.py b/onionshare_gui/main_window.py index 5d81feba..dfd6c10c 100644 --- a/onionshare_gui/main_window.py +++ b/onionshare_gui/main_window.py @@ -97,10 +97,24 @@ class MainWindow(QtWidgets.QMainWindow): # Tabs self.tabs = QtWidgets.QTabWidget() + self.tabs.setStyleSheet(self.common.gui.css["tab_bar_new_tab"]) + self.tabs.setMovable(True) + self.tabs.setTabsClosable(True) + self.tabs.setUsesScrollButtons(True) - # Start with one tab - self.tab = Tab(self.common, self.system_tray, self.status_bar, filenames) - self.tabs.addTab(self.tab, "New Tab") + # New tab button + new_tab_button = QtWidgets.QToolButton() + new_tab_button.setStyleSheet(self.common.gui.css["tab_bar_new_tab_button"]) + new_tab_button.setText("+") + new_tab_button.setAutoRaise(True) + self.tabs.insertTab(0, QtWidgets.QWidget(), "") + self.tabs.tabBar().setTabButton(0, QtWidgets.QTabBar.RightSide, new_tab_button) + self.tabs.tabBar().setTabToolTip(0, strings._("gui_new_tab_tooltip")) + + # Start with a tab + new_tab = Tab(self.common, self.system_tray, self.status_bar, filenames) + self.tabs.insertTab(0, new_tab, strings._("gui_new_tab")) + self.tabs.setCurrentIndex(0) # Layout layout = QtWidgets.QVBoxLayout() diff --git a/share/locale/en.json b/share/locale/en.json index df3b6a5d..b88e35a6 100644 --- a/share/locale/en.json +++ b/share/locale/en.json @@ -180,6 +180,8 @@ "hours_first_letter": "h", "minutes_first_letter": "m", "seconds_first_letter": "s", + "gui_new_tab": "New Tab", + "gui_new_tab_tooltip": "Open a new tab", "gui_new_tab_share_button": "Share Files", "gui_new_tab_share_description": "Choose files on your computer to send to someone else. The person or people who you want to send files to will need to use Tor Browser to download them from you.", "gui_new_tab_receive_button": "Receive Files",