Skip to content

Commit

Permalink
feat(notification): Make the number of banner notification on the scr…
Browse files Browse the repository at this point in the history
…een configurable
  • Loading branch information
Belphemur committed Apr 11, 2024
1 parent f5ceed7 commit cc15647
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 21 deletions.
29 changes: 17 additions & 12 deletions SoundSwitch/Framework/Configuration/ISoundSwitchConfiguration.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
/********************************************************************
* Copyright (C) 2015-2017 Antoine Aflalo
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
********************************************************************/
* Copyright (C) 2015-2017 Antoine Aflalo
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
********************************************************************/

using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -98,5 +98,10 @@ public interface ISoundSwitchConfiguration : IConfiguration
/// Is keep volume enabled
/// </summary>
bool KeepVolumeEnabled { get; set; }

/// <summary>
/// How many banner notification can be displayed at the same time on the screen
/// </summary>
int MaxNumberNotification { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public SoundSwitchConfiguration()
// Notification Settings
NotificationSettings = NotificationTypeEnum.BannerNotification;
BannerPosition = BannerPositionEnum.TopLeft;
MaxNumberNotification = 5;

AutoAddNewConnectedDevices = false;

Expand All @@ -72,7 +73,7 @@ public SoundSwitchConfiguration()
MigratedFields = new HashSet<string>();
}


public int MaxNumberNotification { get; set; }
public HashSet<string> SelectedPlaybackDeviceListId { get; }
public HashSet<string> SelectedRecordingDeviceListId { get; }
public HashSet<DeviceInfo> SelectedDevices { get; set; }
Expand Down
27 changes: 19 additions & 8 deletions SoundSwitch/Model/AppModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public class AppModel : IAppModel
private readonly NotificationManager _notificationManager;
private UpdateChecker _updateChecker;
private DeviceCollection<DeviceInfo> _selectedDevices;

private AppModel()
{
_notificationManager = new NotificationManager(this);
Expand All @@ -69,6 +70,19 @@ private AppModel()

public ProfileManager ProfileManager { get; private set; }

/// <summary>
/// How many notification to show at the same time
/// </summary>
public int MaxNumberNotification
{
get => AppConfigs.Configuration.MaxNumberNotification;
set
{
AppConfigs.Configuration.MaxNumberNotification = value;
AppConfigs.Configuration.Save();
}
}

public CachedSound CustomNotificationSound
{
get
Expand Down Expand Up @@ -284,13 +298,10 @@ public void InitializeMain(IAudioDeviceLister active)
Log.Fatal("AppModel already initialized");
throw new InvalidOperationException("Already initialized");
}

AudioDeviceLister = active;
JobScheduler.Instance.ScheduleJob(new ProcessNotificationEventsJob());
AudioDeviceLister.DefaultDeviceChanged.Subscribe((@event) =>
{
DefaultDeviceChanged?.Invoke(this, new DeviceDefaultChangedEvent(@event.Device, @event.Role));
});
AudioDeviceLister.DefaultDeviceChanged.Subscribe((@event) => { DefaultDeviceChanged?.Invoke(this, new DeviceDefaultChangedEvent(@event.Device, @event.Role)); });

RegisterHotKey(AppConfigs.Configuration.PlaybackHotKey);
var saveConfig = false;
Expand Down Expand Up @@ -452,10 +463,10 @@ public bool SetHotkeyCombination(HotKey hotKey, HotKeyAction action, bool force
{
var confHotKey = action switch
{
HotKeyAction.Playback => AppConfigs.Configuration.PlaybackHotKey,
HotKeyAction.Playback => AppConfigs.Configuration.PlaybackHotKey,
HotKeyAction.Recording => AppConfigs.Configuration.RecordingHotKey,
HotKeyAction.Mute => AppConfigs.Configuration.MuteRecordingHotKey,
_ => throw new ArgumentOutOfRangeException(nameof(action), action, null)
HotKeyAction.Mute => AppConfigs.Configuration.MuteRecordingHotKey,
_ => throw new ArgumentOutOfRangeException(nameof(action), action, null)
};

if (!force && confHotKey == hotKey)
Expand Down
5 changes: 5 additions & 0 deletions SoundSwitch/Model/IAppModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@ public interface IAppModel : IDisposable
bool QuickMenuEnabled { get; set; }
bool KeepVolumeEnabled { get; set; }

/// <summary>
/// How many notification to show at the same time
/// </summary>
int MaxNumberNotification { get; set; }

#endregion

#region Events
Expand Down

0 comments on commit cc15647

Please sign in to comment.