@@ -69,6 +69,7 @@ def __init__(self, parent=None, appicon=None):
69
69
70
70
self ._width = self .width ()
71
71
self ._height = self .height ()
72
+ self .reset_widgets ()
72
73
73
74
dialog_geometry = self ._cfg .getSettings ("promptDialog/geometry" )
74
75
if dialog_geometry == QtCore .QByteArray :
@@ -155,6 +156,22 @@ def showEvent(self, event):
155
156
self .adjust_size ()
156
157
self .move_popup ()
157
158
159
+ def reset_widgets (self ):
160
+ # Don't allow labels to grow more than the dialog's width.
161
+ # This can happen if the path or the binary name is too large.
162
+
163
+ self .appNameLabel .setMaximumWidth (self ._width - 5 )
164
+ self .appDescriptionLabel .setMaximumWidth (self ._width - 5 )
165
+ self .appPathLabel .setMaximumWidth (self ._width - 5 )
166
+ self .argsLabel .setMaximumWidth (self ._width - 5 )
167
+ self .messageLabel .setMaximumWidth (self ._width - 5 )
168
+
169
+ self .appNameLabel .setText ("" )
170
+ self .appDescriptionLabel .setText ("" )
171
+ self .appPathLabel .setText ("" )
172
+ self .argsLabel .setText ("" )
173
+ self .messageLabel .setText ("" )
174
+
158
175
def adjust_size (self ):
159
176
if self ._width is None or self ._height is None :
160
177
self ._width = self .width ()
@@ -208,6 +225,8 @@ def _set_elide_text(self, widget, text, max_size=64):
208
225
widget .setText (text )
209
226
210
227
def promptUser (self , connection , is_local , peer ):
228
+ self .reset_widgets ()
229
+
211
230
# one at a time
212
231
with self ._lock :
213
232
# reset state
@@ -298,6 +317,7 @@ def _set_app_description(self, description):
298
317
self .appDescriptionLabel .setVisible (False )
299
318
self .appDescriptionLabel .setFixedHeight (0 )
300
319
self .appDescriptionLabel .setText ("" )
320
+ return
301
321
302
322
self .appDescriptionLabel .setText (
303
323
"" .join (
@@ -322,12 +342,15 @@ def _set_app_path(self, app_name, app_args, con):
322
342
else :
323
343
self .appPathLabel .setVisible (False )
324
344
self .appPathLabel .setText ("" )
345
+ return
325
346
326
347
self .appPathLabel .setText (
327
348
"" .join (
328
349
filter (str .isprintable , self .appPathLabel .text ())
329
350
)
330
351
)
352
+ if self .appPathLabel .width () >= self ._width :
353
+ self .appPathLabel .setText ("\u200b " .join (self .appPathLabel .text ()))
331
354
332
355
def _set_app_args (self , app_name , app_args ):
333
356
# if the app name and the args are the same, there's no need to display
@@ -339,12 +362,15 @@ def _set_app_args(self, app_name, app_args):
339
362
else :
340
363
self .argsLabel .setVisible (False )
341
364
self .argsLabel .setText ("" )
365
+ return
342
366
343
367
self .argsLabel .setText (
344
368
"" .join (
345
369
filter (str .isprintable , self .argsLabel .text ())
346
370
)
347
371
)
372
+ if self .argsLabel .width () >= self ._width :
373
+ self .argsLabel .setText ("\u200b " .join (self .argsLabel .text ()))
348
374
349
375
def _set_default_target (self , combo , con , app_name , app_args ):
350
376
# set appimage as default target if the process path starts with
@@ -560,6 +586,9 @@ def _get_popup_message(self, app_name, con):
560
586
con .protocol .upper (),
561
587
con .dst_port )
562
588
589
+ if self .messageLabel .width () >= self ._width :
590
+ self .messageLabel .setText ("\u200b " .join (self .messageLabel .text ()))
591
+
563
592
return "%s %s" % (message , msg_action )
564
593
565
594
def _get_duration (self , duration_idx ):
0 commit comments