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