Skip to content

Commit bfce212

Browse files
Add a copy Gerrit change link button (#75)
* [Feature] Add a copy Gerrit change link button * Fix README typo * Update following reviews --------- Co-authored-by: Ruslan Lekhman <[email protected]>
1 parent 76fae48 commit bfce212

File tree

3 files changed

+71
-12
lines changed

3 files changed

+71
-12
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@ Use the following pattern to link revision data to Gerrit:
3232
| 4.0.1 <= v <= 4.0.2 | 2.0.5 |
3333
| 4.1 <= v | master-branch |
3434

35-
## GitExtensions Plugin Template infomration
35+
## GitExtensions Plugin Template information
3636

3737
The [GitExtensions Plugin Template](https://github.com/gitextensions/gitextensions.plugintemplate) gives additional information about the pluign development.

src/GitExtensions.GerritPlugin/FormGerritChangeSubmitted.Designer.cs

Lines changed: 25 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,65 @@
1+
using System;
12
using System.Windows.Forms;
23
using GitCommands;
34
using GitUI;
5+
using GitUI.Properties;
46

57
namespace GitExtensions.GerritPlugin
68
{
79
public partial class FormGerritChangeSubmitted : GitExtensionsForm
810
{
9-
public FormGerritChangeSubmitted()
11+
private string _changeUri;
12+
private Timer _btnCopyIconTimer;
13+
14+
private FormGerritChangeSubmitted()
1015
{
1116
InitializeComponent();
1217
InitializeComplete();
1318
}
1419

15-
public static void ShowSubmitted(IWin32Window owner, string change)
20+
private void Initialize(string changeUri)
21+
{
22+
_changeUri = changeUri;
23+
_NO_TRANSLATE_TargetLabel.Text = changeUri;
24+
25+
_btnCopyIconTimer = new Timer
26+
{
27+
Enabled = false,
28+
Interval = 3 * 1000
29+
};
30+
_btnCopyIconTimer.Tick += OnRefreshCopyButtonIcon;
31+
}
32+
33+
private void OnRefreshCopyButtonIcon(object sender, EventArgs e)
1634
{
17-
var form = new FormGerritChangeSubmitted();
35+
Invoke(() => btnCopy.Image = Images.CopyToClipboard);
36+
}
1837

19-
form._NO_TRANSLATE_TargetLabel.Text = change;
20-
form._NO_TRANSLATE_TargetLabel.Click += (s, e) => OsShellUtil.OpenUrlInDefaultBrowser(change);
38+
public static void ShowSubmitted(IWin32Window owner, string changeUri)
39+
{
40+
if (owner == null || string.IsNullOrEmpty(changeUri))
41+
{
42+
return;
43+
}
2144

45+
using var form = new FormGerritChangeSubmitted();
46+
form.Initialize(changeUri);
2247
form.ShowDialog(owner);
2348
}
49+
50+
private void OnChangeLinkClicked(object sender, EventArgs e)
51+
{
52+
OsShellUtil.OpenUrlInDefaultBrowser(_changeUri);
53+
}
54+
55+
private void OnCopyToClipboardClicked(object sender, EventArgs e)
56+
{
57+
_btnCopyIconTimer.Stop();
58+
59+
Clipboard.SetText(_changeUri);
60+
btnCopy.Image = Images.BisectGood;
61+
62+
_btnCopyIconTimer.Start();
63+
}
2464
}
2565
}

0 commit comments

Comments
 (0)