@@ -69,6 +69,7 @@ def __init__(self, parent=None, appicon=None):
6969
7070 self ._width = self .width ()
7171 self ._height = self .height ()
72+ self .reset_widgets ()
7273
7374 dialog_geometry = self ._cfg .getSettings ("promptDialog/geometry" )
7475 if dialog_geometry == QtCore .QByteArray :
@@ -155,6 +156,22 @@ def showEvent(self, event):
155156 self .adjust_size ()
156157 self .move_popup ()
157158
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+
158175 def adjust_size (self ):
159176 if self ._width is None or self ._height is None :
160177 self ._width = self .width ()
@@ -208,6 +225,8 @@ def _set_elide_text(self, widget, text, max_size=64):
208225 widget .setText (text )
209226
210227 def promptUser (self , connection , is_local , peer ):
228+ self .reset_widgets ()
229+
211230 # one at a time
212231 with self ._lock :
213232 # reset state
@@ -298,6 +317,7 @@ def _set_app_description(self, description):
298317 self .appDescriptionLabel .setVisible (False )
299318 self .appDescriptionLabel .setFixedHeight (0 )
300319 self .appDescriptionLabel .setText ("" )
320+ return
301321
302322 self .appDescriptionLabel .setText (
303323 "" .join (
@@ -322,12 +342,15 @@ def _set_app_path(self, app_name, app_args, con):
322342 else :
323343 self .appPathLabel .setVisible (False )
324344 self .appPathLabel .setText ("" )
345+ return
325346
326347 self .appPathLabel .setText (
327348 "" .join (
328349 filter (str .isprintable , self .appPathLabel .text ())
329350 )
330351 )
352+ if self .appPathLabel .width () >= self ._width :
353+ self .appPathLabel .setText ("\u200b " .join (self .appPathLabel .text ()))
331354
332355 def _set_app_args (self , app_name , app_args ):
333356 # 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):
339362 else :
340363 self .argsLabel .setVisible (False )
341364 self .argsLabel .setText ("" )
365+ return
342366
343367 self .argsLabel .setText (
344368 "" .join (
345369 filter (str .isprintable , self .argsLabel .text ())
346370 )
347371 )
372+ if self .argsLabel .width () >= self ._width :
373+ self .argsLabel .setText ("\u200b " .join (self .argsLabel .text ()))
348374
349375 def _set_default_target (self , combo , con , app_name , app_args ):
350376 # set appimage as default target if the process path starts with
@@ -560,6 +586,9 @@ def _get_popup_message(self, app_name, con):
560586 con .protocol .upper (),
561587 con .dst_port )
562588
589+ if self .messageLabel .width () >= self ._width :
590+ self .messageLabel .setText ("\u200b " .join (self .messageLabel .text ()))
591+
563592 return "%s %s" % (message , msg_action )
564593
565594 def _get_duration (self , duration_idx ):
0 commit comments