mirror of
https://github.com/onionshare/onionshare.git
synced 2024-10-01 01:35:40 -04:00
Add shortcuts for modes and new/close tab. Set accessible string for modes on mode chooser
This commit is contained in:
parent
52cb5cf71a
commit
594c11cfeb
@ -38,12 +38,18 @@ from ..widgets import Alert
|
|||||||
|
|
||||||
|
|
||||||
class NewTabButton(QtWidgets.QPushButton):
|
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__()
|
super(NewTabButton, self).__init__()
|
||||||
self.common = common
|
self.common = common
|
||||||
|
|
||||||
self.setFixedSize(280, 280)
|
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
|
# Image
|
||||||
self.image_label = QtWidgets.QLabel(parent=self)
|
self.image_label = QtWidgets.QLabel(parent=self)
|
||||||
self.image_label.setPixmap(
|
self.image_label.setPixmap(
|
||||||
@ -140,6 +146,7 @@ class Tab(QtWidgets.QWidget):
|
|||||||
"images/{}_mode_new_tab_share.png".format(self.common.gui.color_mode),
|
"images/{}_mode_new_tab_share.png".format(self.common.gui.color_mode),
|
||||||
strings._("gui_new_tab_share_button"),
|
strings._("gui_new_tab_share_button"),
|
||||||
strings._("gui_main_page_share_button"),
|
strings._("gui_main_page_share_button"),
|
||||||
|
QtCore.Qt.Key_S,
|
||||||
)
|
)
|
||||||
self.share_button.clicked.connect(self.share_mode_clicked)
|
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),
|
"images/{}_mode_new_tab_receive.png".format(self.common.gui.color_mode),
|
||||||
strings._("gui_new_tab_receive_button"),
|
strings._("gui_new_tab_receive_button"),
|
||||||
strings._("gui_main_page_receive_button"),
|
strings._("gui_main_page_receive_button"),
|
||||||
|
QtCore.Qt.Key_R,
|
||||||
)
|
)
|
||||||
self.receive_button.clicked.connect(self.receive_mode_clicked)
|
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),
|
"images/{}_mode_new_tab_website.png".format(self.common.gui.color_mode),
|
||||||
strings._("gui_new_tab_website_button"),
|
strings._("gui_new_tab_website_button"),
|
||||||
strings._("gui_main_page_website_button"),
|
strings._("gui_main_page_website_button"),
|
||||||
|
QtCore.Qt.Key_W,
|
||||||
)
|
)
|
||||||
self.website_button.clicked.connect(self.website_mode_clicked)
|
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),
|
"images/{}_mode_new_tab_chat.png".format(self.common.gui.color_mode),
|
||||||
strings._("gui_new_tab_chat_button"),
|
strings._("gui_new_tab_chat_button"),
|
||||||
strings._("gui_main_page_chat_button"),
|
strings._("gui_main_page_chat_button"),
|
||||||
|
QtCore.Qt.Key_C,
|
||||||
)
|
)
|
||||||
self.chat_button.clicked.connect(self.chat_mode_clicked)
|
self.chat_button.clicked.connect(self.chat_mode_clicked)
|
||||||
|
|
||||||
|
@ -55,6 +55,7 @@ class TabWidget(QtWidgets.QTabWidget):
|
|||||||
|
|
||||||
# Define the new tab button
|
# Define the new tab button
|
||||||
self.new_tab_button = QtWidgets.QPushButton("+", parent=self)
|
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.setFlat(True)
|
||||||
self.new_tab_button.setFixedSize(40, 30)
|
self.new_tab_button.setFixedSize(40, 30)
|
||||||
self.new_tab_button.clicked.connect(self.new_tab_clicked)
|
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"))
|
index = self.addTab(tab, strings._("gui_new_tab"))
|
||||||
self.setCurrentIndex(index)
|
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)
|
tab.init(mode_settings)
|
||||||
|
|
||||||
# Make sure the title is set
|
# Make sure the title is set
|
||||||
|
Loading…
Reference in New Issue
Block a user