Skip to content

Commit

Permalink
Double-click on tag in tags editor opens browser
Browse files Browse the repository at this point in the history
  • Loading branch information
electroly committed Nov 27, 2024
1 parent 619dd1b commit 7474feb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/J.App/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,7 @@ TagsControl tagsControl
_tagsControl.Dock = DockStyle.Fill;
_tagsControl.TagTypeChanged += EditTagsControl_TagTypeChanged;
_tagsControl.TagChanged += EditTagsControl_TagChanged;
_tagsControl.TagActivated += TagsControl_TagActivated;
}

_searchDebounceTimer = new() { Interval = 500, Enabled = false };
Expand Down Expand Up @@ -435,6 +436,15 @@ TagsControl tagsControl
KeyPreview = true;
}

private void TagsControl_TagActivated(object? sender, TagsControl.TagActivatedEventArgs e)
{
var query = HttpUtility.ParseQueryString("");
query["sessionPassword"] = _client.SessionPassword;
query["tagId"] = e.Id.Value;
SwitchTab(_browserTabButton);
Navigate($"/tag.html?{query}");
}

private void AboutButton_Click(object? sender, EventArgs e)
{
var assembly = typeof(MainForm).Assembly;
Expand Down
8 changes: 7 additions & 1 deletion src/J.App/TagsControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ public sealed class TagsControl : UserControl
public event EventHandler? TagTypeChanged;
public event EventHandler? TagChanged;

public readonly record struct TagActivatedEventArgs(TagId Id);

public event EventHandler<TagActivatedEventArgs>? TagActivated;

public TagsControl(LibraryProviderAdapter libraryProvider, IServiceProvider serviceProvider)
{
_libraryProvider = libraryProvider;
Expand Down Expand Up @@ -439,7 +443,9 @@ private void RightRenameTagButton_Click(object? sender, EventArgs e)

private void RightGrid_CellDoubleClick(object? sender, DataGridViewCellEventArgs e)
{
EditTag(GetSelectedTagIds().First());
var ids = GetSelectedTagIds();
if (ids.Any())
TagActivated?.Invoke(this, new(ids.First()));
}

private void EditTag(TagId? id)
Expand Down

0 comments on commit 7474feb

Please sign in to comment.