1 from __future__
import absolute_import
, division
, print_function
, unicode_literals
3 from qtpy
import QtWidgets
4 from qtpy
.QtCore
import Qt
10 from ..qtutils
import get
12 from . import completion
13 from . import standard
17 def new_create_tag(context
, name
='', ref
='', sign
=False, parent
=None):
18 """Entry point for external callers."""
19 opts
= TagOptions(name
, ref
, sign
)
20 view
= CreateTag(context
, opts
, parent
=parent
)
24 def create_tag(context
, name
='', ref
='', sign
=False):
25 """Entry point for external callers."""
26 view
= new_create_tag(
31 parent
=qtutils
.active_window(),
38 class TagOptions(object):
39 """Simple data container for the CreateTag dialog."""
41 def __init__(self
, name
, ref
, sign
):
42 self
.name
= name
or ''
43 self
.ref
= ref
or 'HEAD'
47 class CreateTag(standard
.Dialog
):
48 def __init__(self
, context
, opts
, parent
=None):
49 standard
.Dialog
.__init
__(self
, parent
=parent
)
51 self
.context
= context
52 self
.model
= model
= context
.model
55 self
.setWindowTitle(N_('Create Tag'))
56 if parent
is not None:
57 self
.setWindowModality(Qt
.WindowModal
)
60 self
.tag_name_label
= QtWidgets
.QLabel(self
)
61 self
.tag_name_label
.setText(N_('Name'))
63 self
.tag_name
= text
.HintedLineEdit(context
, N_('vX.Y.Z'), parent
=self
)
64 self
.tag_name
.set_value(opts
.name
)
65 self
.tag_name
.setToolTip(N_('Specifies the tag name'))
67 qtutils
.add_completer(self
.tag_name
, model
.tags
)
70 self
.sign_label
= QtWidgets
.QLabel(self
)
71 self
.sign_label
.setText(N_('Sign Tag'))
73 tooltip
= N_('Whether to sign the tag (git tag -s)')
74 self
.sign_tag
= qtutils
.checkbox(checked
=True, tooltip
=tooltip
)
77 self
.tag_msg_label
= QtWidgets
.QLabel(self
)
78 self
.tag_msg_label
.setText(N_('Message'))
80 self
.tag_msg
= text
.HintedPlainTextEdit(context
, N_('Tag message...'), self
)
81 self
.tag_msg
.setToolTip(N_('Specifies the tag message'))
83 self
.rev_label
= QtWidgets
.QLabel(self
)
84 self
.rev_label
.setText(N_('Revision'))
86 self
.revision
= completion
.GitRefLineEdit(context
)
87 self
.revision
.setText(self
.opts
.ref
)
88 self
.revision
.setToolTip(N_('Specifies the SHA-1 to tag'))
90 self
.create_button
= qtutils
.create_button(
91 text
=N_('Create Tag'), icon
=icons
.tag(), default
=True
93 self
.close_button
= qtutils
.close_button()
95 # Form layout for inputs
96 self
.input_layout
= qtutils
.form(
99 (self
.tag_name_label
, self
.tag_name
),
100 (self
.tag_msg_label
, self
.tag_msg
),
101 (self
.rev_label
, self
.revision
),
102 (self
.sign_label
, self
.sign_tag
),
105 self
.button_layout
= qtutils
.hbox(
113 self
.main_layt
= qtutils
.vbox(
114 defs
.margin
, defs
.spacing
, self
.input_layout
, self
.button_layout
116 self
.setLayout(self
.main_layt
)
118 qtutils
.connect_button(self
.close_button
, self
.close
)
119 qtutils
.connect_button(self
.create_button
, self
.create_tag
)
121 settings
= context
.settings
122 self
.init_state(settings
, self
.resize
, defs
.scale(720), defs
.scale(210))
124 def create_tag(self
):
125 """Verifies inputs and emits a notifier tag message."""
127 context
= self
.context
128 revision
= get(self
.revision
)
129 tag_name
= get(self
.tag_name
)
130 tag_msg
= get(self
.tag_msg
)
131 sign_tag
= get(self
.sign_tag
)
134 cmds
.Tag
, context
, tag_name
, revision
, sign
=sign_tag
, message
=tag_msg