29
29
30
30
from PyQt5 .QtCore import Qt , QPoint , QRectF , QEvent
31
31
from PyQt5 .QtGui import *
32
- from PyQt5 .QtWidgets import QLabel , QWidget , QDockWidget , QVBoxLayout , QHBoxLayout , QPushButton , QToolButton , QCheckBox
32
+ from PyQt5 .QtWidgets import QLabel , QWidget , QDockWidget , QVBoxLayout , QHBoxLayout , QPushButton , QToolButton , QCheckBox , QAction
33
33
34
34
from classes .logger import log
35
35
from classes .settings import get_settings
@@ -77,23 +77,6 @@ def checkbox_metrics_callback(self, state):
77
77
# Disable metric sending
78
78
s .set ("send_metrics" , False )
79
79
80
- def keyPressEvent (self , event ):
81
- """ Process key press events and match with known shortcuts"""
82
- # Detect the current KeySequence pressed (including modifier keys)
83
- key_value = event .key ()
84
- modifiers = int (event .modifiers ())
85
-
86
- # Abort handling if the key sequence is invalid
87
- if (key_value <= 0 or key_value in
88
- [Qt .Key_Shift , Qt .Key_Alt , Qt .Key_Control , Qt .Key_Meta ]):
89
- return
90
-
91
- # A valid keysequence was detected
92
- key = QKeySequence (modifiers + key_value )
93
- if key == Qt .Key_Escape :
94
- # User hit Escape key, hide tutorial permanently
95
- self .manager .hide_tips (self .id , True )
96
-
97
80
def mouseReleaseEvent (self , event ):
98
81
"""Process click events on tutorial. Especially useful when tutorial messages are partially
99
82
obscured or offscreen (i.e. on small screens). Just click any part of the tutorial, and it will
@@ -148,12 +131,20 @@ def __init__(self, id, text, arrow, manager, *args):
148
131
hbox = QHBoxLayout ()
149
132
hbox .setContentsMargins (20 , 10 , 0 , 0 )
150
133
134
+ # Close action
135
+ self .close_action = QAction (_ ("Hide Tutorial" ))
136
+ self .close_action .setShortcut (QKeySequence (Qt .Key_Escape ))
137
+ self .close_action .setShortcutContext (Qt .ApplicationShortcut )
138
+
151
139
# Create buttons
152
140
self .btn_close_tips = QPushButton (self )
153
141
self .btn_close_tips .setText (_ ("Hide Tutorial" ))
142
+ self .btn_close_tips .addAction (self .close_action )
143
+
154
144
self .btn_next_tip = QPushButton (self )
155
145
self .btn_next_tip .setText (_ ("Next" ))
156
146
self .btn_next_tip .setStyleSheet ("font-weight:bold;" )
147
+
157
148
hbox .addWidget (self .btn_close_tips )
158
149
hbox .addWidget (self .btn_next_tip )
159
150
vbox .addLayout (hbox )
@@ -170,6 +161,10 @@ def __init__(self, id, text, arrow, manager, *args):
170
161
self .setAttribute (Qt .WA_TranslucentBackground , True )
171
162
self .setAttribute (Qt .WA_DeleteOnClose , True )
172
163
164
+ # Connect close action signal
165
+ self .close_action .triggered .connect (
166
+ functools .partial (self .manager .hide_tips , self .id , True ))
167
+
173
168
174
169
class TutorialManager (object ):
175
170
""" Manage and present a list of tutorial dialogs """
0 commit comments