Skip to content

Commit

Permalink
fix: notify user when first use of lock. clear text when paused.
Browse files Browse the repository at this point in the history
  • Loading branch information
am009 committed Nov 18, 2024
1 parent f247606 commit a8289e1
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/TMSpeech.Core/ConfigTypes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public static class NotificationConfigTypes

public const string NotificationType = "notification.NotificationType";
public const string SensitiveWords = "notification.SensitiveWords";
public const string HasShownLockUsage = "notification.ShownLockUsage";

public static class NotificationTypeEnum
{
Expand Down
3 changes: 3 additions & 0 deletions src/TMSpeech.Core/JobManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,9 @@ private void StopRecognize()

_audioSource = null;
_recognizer = null;

OnSentenceDone(new SpeechEventArgs());
OnTextChanged(new SpeechEventArgs());
}

public override void Start()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public void UnregistNotificationService(INotificationService service)
public void Notify(string content, string? title, NotificationType type = NotificationType.Info)
{
if (ConfigManagerFactory.Instance.Get<int>(NotificationConfigTypes.NotificationType) == NotificationConfigTypes.NotificationTypeEnum.None) return;
if (type > _level)
if (type >= _level)
{
foreach (var service in _services)
{
Expand Down
12 changes: 11 additions & 1 deletion src/TMSpeech.GUI/ViewModels/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using ReactiveUI.Fody.Helpers;
using TMSpeech.Core;
using TMSpeech.Core.Plugins;
using TMSpeech.Core.Services.Notification;

namespace TMSpeech.GUI.ViewModels;

Expand Down Expand Up @@ -164,7 +165,16 @@ public MainViewModel()
.Select(x => x == JobStatus.Running || x == JobStatus.Paused)
.ToPropertyEx(this, x => x.StopButtonVisible);

this.LockCommand = ReactiveCommand.Create(() => { IsLocked = true; });
this.LockCommand = ReactiveCommand.Create(() => {
IsLocked = true;
// Inform user if user uses it for the first time.
var lockedShown = ConfigManagerFactory.Instance.Get<bool>(NotificationConfigTypes.HasShownLockUsage);
if (!lockedShown)
{
ConfigManagerFactory.Instance.Apply(NotificationConfigTypes.HasShownLockUsage, true);
NotificationManager.Instance.Notify("锁定成功", "右键托盘图标以解锁", NotificationType.Info);
}
});

this.PlayCommand = ReactiveCommand.CreateFromTask(
async () => { await Task.Run(() => { _jobManager.Start(); }); },
Expand Down

0 comments on commit a8289e1

Please sign in to comment.