1 from qtpy
.QtCore
import Qt
10 def show(context
, message
):
11 """Display a window if the remote sent a message"""
13 view
= RemoteMessage(context
, message
, parent
=context
.view
)
18 def from_context(context
):
19 """Return a closure for the `result` callback from RunTask.start()"""
21 def show_result(result
):
22 """Display the asynchronous "result" when remote tasks complete"""
24 output
= '\n\n'.join(x
for x
in (out
, err
) if x
)
26 message
= N_('Right-click links to open:') + '\n\n' + output
30 return show(context
, message
)
35 class RemoteMessage(standard
.Dialog
):
36 """Provides a dialog to display remote messages"""
38 def __init__(self
, context
, message
, parent
=None):
39 standard
.Dialog
.__init
__(self
, parent
=parent
)
40 self
.context
= context
41 self
.model
= context
.model
43 self
.setWindowTitle(N_('Remote Messages'))
44 if parent
is not None:
45 self
.setWindowModality(Qt
.WindowModal
)
47 self
.text
= text
.VimTextEdit(context
, parent
=self
)
48 self
.text
.set_value(message
)
49 # Set a monospace font, as some remote git messages include ASCII art
50 self
.text
.setFont(qtutils
.default_monospace_font())
52 self
.close_button
= qtutils
.close_button()
53 self
.close_button
.setDefault(True)
55 self
.bottom_layout
= qtutils
.hbox(
56 defs
.no_margin
, defs
.button_spacing
, qtutils
.STRETCH
, self
.close_button
59 self
.main_layout
= qtutils
.vbox(
60 defs
.no_margin
, defs
.spacing
, self
.text
, self
.bottom_layout
62 self
.setLayout(self
.main_layout
)
64 qtutils
.connect_button(self
.close_button
, self
.close
)
66 self
.resize(defs
.scale(720), defs
.scale(400))