aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiguel Jacq <mig@mig5.net>2022-03-28 17:13:59 +1100
committerMiguel Jacq <mig@mig5.net>2022-03-28 17:18:58 +1100
commit594c11cfebe655e944ca874a6ca4a21474e3c950 (patch)
treea1331f3ffc68dea6c4d32cac0e7dc092e047c576
parent52cb5cf71aef4ad05d2345757f8e2a66abc86753 (diff)
downloadonionshare-594c11cfebe655e944ca874a6ca4a21474e3c950.tar.gz
onionshare-594c11cfebe655e944ca874a6ca4a21474e3c950.zip
Add shortcuts for modes and new/close tab. Set accessible string for modes on mode chooser
-rw-r--r--desktop/onionshare/tab/tab.py12
-rw-r--r--desktop/onionshare/tab_widget.py5
2 files changed, 16 insertions, 1 deletions
diff --git a/desktop/onionshare/tab/tab.py b/desktop/onionshare/tab/tab.py
index 7f4e4073..5e2d4af8 100644
--- a/desktop/onionshare/tab/tab.py
+++ b/desktop/onionshare/tab/tab.py
@@ -38,12 +38,18 @@ from ..widgets import Alert
class NewTabButton(QtWidgets.QPushButton):
- def __init__(self, common, image_filename, title, text):
+ def __init__(self, common, image_filename, title, text, shortcut):
super(NewTabButton, self).__init__()
self.common = common
self.setFixedSize(280, 280)
+ # Keyboard shortcut, using the first letter of the mode
+ sequence = QtGui.QKeySequence(QtCore.Qt.CTRL + shortcut)
+ self.setShortcut(sequence)
+
+ self.setAccessibleName(title)
+
# Image
self.image_label = QtWidgets.QLabel(parent=self)
self.image_label.setPixmap(
@@ -140,6 +146,7 @@ class Tab(QtWidgets.QWidget):
"images/{}_mode_new_tab_share.png".format(self.common.gui.color_mode),
strings._("gui_new_tab_share_button"),
strings._("gui_main_page_share_button"),
+ QtCore.Qt.Key_S,
)
self.share_button.clicked.connect(self.share_mode_clicked)
@@ -148,6 +155,7 @@ class Tab(QtWidgets.QWidget):
"images/{}_mode_new_tab_receive.png".format(self.common.gui.color_mode),
strings._("gui_new_tab_receive_button"),
strings._("gui_main_page_receive_button"),
+ QtCore.Qt.Key_R,
)
self.receive_button.clicked.connect(self.receive_mode_clicked)
@@ -156,6 +164,7 @@ class Tab(QtWidgets.QWidget):
"images/{}_mode_new_tab_website.png".format(self.common.gui.color_mode),
strings._("gui_new_tab_website_button"),
strings._("gui_main_page_website_button"),
+ QtCore.Qt.Key_W,
)
self.website_button.clicked.connect(self.website_mode_clicked)
@@ -164,6 +173,7 @@ class Tab(QtWidgets.QWidget):
"images/{}_mode_new_tab_chat.png".format(self.common.gui.color_mode),
strings._("gui_new_tab_chat_button"),
strings._("gui_main_page_chat_button"),
+ QtCore.Qt.Key_C,
)
self.chat_button.clicked.connect(self.chat_mode_clicked)
diff --git a/desktop/onionshare/tab_widget.py b/desktop/onionshare/tab_widget.py
index 3c1a1703..11e22878 100644
--- a/desktop/onionshare/tab_widget.py
+++ b/desktop/onionshare/tab_widget.py
@@ -55,6 +55,7 @@ class TabWidget(QtWidgets.QTabWidget):
# Define the new tab button
self.new_tab_button = QtWidgets.QPushButton("+", parent=self)
+ self.new_tab_button.setShortcut(QtCore.Qt.CTRL + QtCore.Qt.Key_T)
self.new_tab_button.setFlat(True)
self.new_tab_button.setFixedSize(40, 30)
self.new_tab_button.clicked.connect(self.new_tab_clicked)
@@ -195,6 +196,10 @@ class TabWidget(QtWidgets.QTabWidget):
index = self.addTab(tab, strings._("gui_new_tab"))
self.setCurrentIndex(index)
+ sequence = QtGui.QKeySequence(QtCore.Qt.CTRL + QtCore.Qt.Key_X)
+ close_shortcut = QtWidgets.QShortcut(sequence, tab)
+ close_shortcut.activated.connect(lambda: self.close_tab(index))
+
tab.init(mode_settings)
# Make sure the title is set