Skip to content

Commit 8b6edc1

Browse files
committed
feat: Allow the activity popup window to stay open
This adds a new settings toggle (default disabled). If enabled, the activity popup window doesn't autoclose if the user clicks anywhere on screen (the old behaviour). Instead, the user can continue working on the PC, with the popup remaining available. If the toggle is disabled, the old behaviour is retained. Clicking the popup with the right mouse button will close it in all cases.
1 parent 1b558de commit 8b6edc1

7 files changed

Lines changed: 28 additions & 3 deletions

File tree

src/SyncTrayzor/NotifyIcon/NotifyIconViewModel.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public class NotifyIconViewModel : PropertyChangedBase, IDisposable
2424

2525
public bool Visible { get; set; }
2626
public bool MainWindowVisible { get; set; }
27+
public bool KeepActivityPopupOpen { get; set; }
2728
public BindableCollection<FolderViewModel> Folders { get; private set; }
2829
public FileTransfersTrayViewModel FileTransfersViewModel { get; private set; }
2930

@@ -73,7 +74,9 @@ public NotifyIconViewModel(
7374
this.alertsManager.AlertsStateChanged += AlertsStateChanged;
7475

7576
this.configurationProvider.ConfigurationChanged += ConfigurationChanged;
76-
iconAnimationmode = this.configurationProvider.Load().IconAnimationMode;
77+
var configuration = this.configurationProvider.Load();
78+
iconAnimationmode = configuration.IconAnimationMode;
79+
KeepActivityPopupOpen = configuration.KeepActivityPopupOpen;
7780
}
7881

7982
private void StateChanged(object sender, SyncthingStateChangedEventArgs e)
@@ -117,6 +120,7 @@ private void AlertsStateChanged(object sender, EventArgs e)
117120
private void ConfigurationChanged(object sender, ConfigurationChangedEventArgs e)
118121
{
119122
iconAnimationmode = e.NewConfiguration.IconAnimationMode;
123+
KeepActivityPopupOpen = e.NewConfiguration.KeepActivityPopupOpen;
120124
// Reset, just in case
121125
SyncthingSyncing = false;
122126
}

src/SyncTrayzor/NotifyIcon/TaskbarIconResources.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
MenuActivation="RightClick"
2222
ToolTipText="SyncTrayzor">
2323
<tb:TaskbarIcon.TrayPopup>
24-
<Popup StaysOpen="False" Placement="Relative" HorizontalOffset="-150" VerticalOffset="100" Width="300" PlacementTarget="{Binding ElementName=TaskbarIcon}" AllowsTransparency="True">
24+
<Popup StaysOpen="{Binding KeepActivityPopupOpen}" Placement="Relative" HorizontalOffset="-150" VerticalOffset="100" Width="300" PlacementTarget="{Binding ElementName=TaskbarIcon}" AllowsTransparency="True">
2525
<i:Interaction.Behaviors>
2626
<xaml:PopupConductorBehaviour DataContext="{Binding FileTransfersViewModel}"/>
2727
</i:Interaction.Behaviors>

src/SyncTrayzor/Pages/Settings/SettingsView.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
<CheckBox DockPanel.Dock="Top" IsChecked="{Binding ShowDeviceConnectivityBalloons.Value}" Content="{l:Loc SettingsView_ShowDeviceConnectivityBalloons}"/>
7575
<CheckBox DockPanel.Dock="Top" IsChecked="{Binding ShowDeviceOrFolderRejectedBalloons.Value}" Content="{l:Loc SettingsView_ShowDeviceOrFolderRejectedBalloons}"/>
7676
<CheckBox DockPanel.Dock="Top" IsChecked="{Binding ShowTrayIconOnlyOnClose.Value}" Content="{l:Loc SettingsView_OnlyShowTrayIconOnClose}"/>
77+
<CheckBox DockPanel.Dock="Top" IsChecked="{Binding KeepActivityPopupOpen.Value}" Content="{l:Loc SettingsView_KeepActivityPopupOpen}"/>
7778
<StackPanel DockPanel.Dock="Top" Orientation="Horizontal" Margin="0,5,0,0">
7879
<Label Padding="0,0,5,0" Target="{Binding ElementName=IconAnimationModeSelect}" VerticalAlignment="Center" Content="{l:Loc SettingsView_AnimateTrayIcon}"/>
7980
<ComboBox x:Name="IconAnimationModeSelect" ItemsSource="{Binding IconAnimationModes}" SelectedValuePath="Value" SelectedValue="{Binding IconAnimationMode.Value}"/>

src/SyncTrayzor/Pages/Settings/SettingsViewModel.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ public class SettingsViewModel : Screen
7070
public SettingItem<bool> ShowSynchronizedBalloonEvenIfNothingDownloaded { get; }
7171
public SettingItem<bool> ShowDeviceConnectivityBalloons { get; }
7272
public SettingItem<bool> ShowDeviceOrFolderRejectedBalloons { get; }
73+
public SettingItem<bool> KeepActivityPopupOpen { get; }
7374

7475
public BindableCollection<LabelledValue<IconAnimationMode>> IconAnimationModes { get; }
7576
public SettingItem<IconAnimationMode> IconAnimationMode { get; }
@@ -141,6 +142,7 @@ public SettingsViewModel(
141142
ShowSynchronizedBalloonEvenIfNothingDownloaded = CreateBasicSettingItem(x => x.ShowSynchronizedBalloonEvenIfNothingDownloaded);
142143
ShowDeviceConnectivityBalloons = CreateBasicSettingItem(x => x.ShowDeviceConnectivityBalloons);
143144
ShowDeviceOrFolderRejectedBalloons = CreateBasicSettingItem(x => x.ShowDeviceOrFolderRejectedBalloons);
145+
KeepActivityPopupOpen = CreateBasicSettingItem(x => x.KeepActivityPopupOpen);
144146

145147
IconAnimationModes = new BindableCollection<LabelledValue<IconAnimationMode>>()
146148
{

src/SyncTrayzor/Properties/Resources.resx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,4 +1002,7 @@ Please donate to my charity fundraising campaign.</value>
10021002
<data name="BarAlertsView_IntelXeGraphics_DismissLink" xml:space="preserve">
10031003
<value>Dismiss</value>
10041004
</data>
1005+
<data name="SettingsView_KeepActivityPopupOpen" xml:space="preserve">
1006+
<value>Keep activity popup open (right-click the popup to close)</value>
1007+
</data>
10051008
</root>

src/SyncTrayzor/Services/Config/Configuration.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public int Version
2828
public bool ShowDeviceConnectivityBalloons { get; set; }
2929
public bool ShowDeviceOrFolderRejectedBalloons { get; set; }
3030
public bool ShowSynchronizedBalloonEvenIfNothingDownloaded { get; set; }
31+
public bool KeepActivityPopupOpen { get; set; }
3132
public string SyncthingAddress { get; set; }
3233
public bool StartSyncthingAutomatically { get; set; }
3334

@@ -110,6 +111,7 @@ public Configuration()
110111
OpenFolderCommand = "explorer.exe \"{0}\"";
111112
ShowFileInFolderCommand = "explorer.exe /select, \"{0}\"";
112113
LogLevel = LogLevel.Info;
114+
KeepActivityPopupOpen = false;
113115
}
114116

115117
public Configuration(Configuration other)
@@ -148,6 +150,7 @@ public Configuration(Configuration other)
148150
OpenFolderCommand = other.OpenFolderCommand;
149151
ShowFileInFolderCommand = other.ShowFileInFolderCommand;
150152
LogLevel = other.LogLevel;
153+
KeepActivityPopupOpen = other.KeepActivityPopupOpen;
151154
}
152155

153156
public override string ToString()
@@ -166,7 +169,8 @@ public override string ToString()
166169
$"EnableConflictFileMonitoring={EnableConflictFileMonitoring} " +
167170
$"ConflictResolverDeletesToRecycleBin={ConflictResolverDeletesToRecycleBin} PauseDevicesOnMeteredNetworks={PauseDevicesOnMeteredNetworks} " +
168171
$"HaveDonated={HaveDonated} IconAnimationMode={IconAnimationMode} OpenFolderCommand={OpenFolderCommand} ShowFileInFolderCommand={ShowFileInFolderCommand}" +
169-
$"LogLevel={LogLevel}>";
172+
$"LogLevel={LogLevel}" +
173+
$"KeepActivityPopupOpen={KeepActivityPopupOpen}>";
170174
}
171175
}
172176
}

src/SyncTrayzor/Xaml/PopupConductorBehaviour.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System;
33
using System.Windows;
44
using System.Windows.Controls.Primitives;
5+
using System.Windows.Input;
56

67
namespace SyncTrayzor.Xaml
78
{
@@ -20,12 +21,14 @@ protected override void AttachHandlers()
2021
{
2122
AssociatedObject.Opened += Opened;
2223
AssociatedObject.Closed += Closed;
24+
AssociatedObject.PreviewMouseUp += ManualClose;
2325
}
2426

2527
protected override void DetachHandlers()
2628
{
2729
AssociatedObject.Opened -= Opened;
2830
AssociatedObject.Closed -= Closed;
31+
AssociatedObject.PreviewMouseUp -= ManualClose;
2932
}
3033

3134
private void Opened(object sender, EventArgs e)
@@ -39,5 +42,13 @@ private void Closed(object sender, EventArgs e)
3942
if (DataContext is IScreenState screenState)
4043
screenState.Close();
4144
}
45+
46+
private void ManualClose(object sender, MouseButtonEventArgs e)
47+
{
48+
if (e.ChangedButton == MouseButton.Right)
49+
{
50+
AssociatedObject.IsOpen = false;
51+
}
52+
}
4253
}
4354
}

0 commit comments

Comments
 (0)