Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions Signal-Windows.Lib/GlobalSettingsManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public enum ShowNotificationTextSettings
private const string BlockScreenshots = "BlockScreenshots";
private const string EnableReadReceipts = "EnableReadReceipts";
private const string SpellCheck = "SpellCheck";
private const string SendMessageWithEnter = "SendMessageWithEnter";

private static ApplicationDataContainer localSettings;
private static IReadOnlyDictionary<string, ApplicationDataContainer> Containers
Expand Down Expand Up @@ -108,6 +109,18 @@ public static bool SpellCheckSetting
}
}

public static bool SendMessageWithEnterSetting
{
get
{
return GetSetting(Containers[ChatsAndMediaContainer], SendMessageWithEnter, true);
}
set
{
Containers[ChatsAndMediaContainer].Values[SendMessageWithEnter] = value;
}
}

private static T GetSetting<T>(ApplicationDataContainer container, string key, T defaultValue)
{
if (container.Values.ContainsKey(key))
Expand Down
10 changes: 7 additions & 3 deletions Signal-Windows/Controls/Conversation.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ public void Load(SignalConversation conversation)
*/
ConversationItemsControl.ItemsSource = new List<object>();
UpdateLayout();
Collection = new VirtualizedCollection(conversation);
Collection = new VirtualizedCollection(conversation);
ConversationItemsControl.ItemsSource = Collection;
UpdateLayout();
SendButtonEnabled = conversation.CanReceive;
Expand Down Expand Up @@ -304,8 +304,12 @@ public void HandleDeleteMesage(SignalMessage message)

private async void UserInputBar_OnEnterKeyPressed()
{
bool shift = CoreWindow.GetForCurrentThread().GetKeyState(VirtualKey.Shift).HasFlag(CoreVirtualKeyStates.Down);
if (shift)
CoreWindow coreWindow = CoreWindow.GetForCurrentThread();
bool shift = coreWindow.GetKeyState(VirtualKey.Shift).HasFlag(CoreVirtualKeyStates.Down);
bool control = coreWindow.GetKeyState(VirtualKey.Control).HasFlag(CoreVirtualKeyStates.Down);
// If SendMessageWithEnterSetting is true then add new if shift key is pressed.
// If SendMessageWithEnterSetting is false then send message if control key is pressed.
if (GlobalSettingsManager.SendMessageWithEnterSetting ? shift : !control)
{
UserInputBar.AddLinefeed();
}
Expand Down
13 changes: 13 additions & 0 deletions Signal-Windows/ViewModels/ChatsAndMediaSettingsPageViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,27 @@ public bool SpellCheck
set { spellCheck = value; RaisePropertyChanged(nameof(SpellCheck)); }
}

private bool sendMessageWithEnter;
public bool SendMessageWithEnter
{
get { return sendMessageWithEnter; }
set { sendMessageWithEnter = value; RaisePropertyChanged(nameof(SendMessageWithEnter)); }
}

public void OnNavigatedTo()
{
SpellCheck = GlobalSettingsManager.SpellCheckSetting;
SendMessageWithEnter = GlobalSettingsManager.SendMessageWithEnterSetting;
}

public void SpellCheckToggleSwitch_Toggled(bool value)
{
GlobalSettingsManager.SpellCheckSetting = value;
}

public void SendMessageWithEnterToggleSwitch_Toggled(bool value)
{
GlobalSettingsManager.SendMessageWithEnterSetting = value;
}
}
}
9 changes: 9 additions & 0 deletions Signal-Windows/Views/ChatsAndMediaSettingsPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid>
<Grid.RowDefinitions>
Expand Down Expand Up @@ -79,6 +80,14 @@
<TextBlock Text="Spell Check" Style="{StaticResource SubtitleTextBlockStyle}"/>
<ToggleSwitch x:Name="SpellCheckToggleSwitch" Grid.Row="1" Margin="0,8" IsOn="{x:Bind Vm.SpellCheck, Mode=TwoWay}" Toggled="SpellCheckToggleSwitch_Toggled"/>
</Grid>
<Grid Grid.Row="3" Margin="0,16,0,0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition/>
</Grid.RowDefinitions>
<TextBlock Text="Send Message With Enter" Style="{StaticResource SubtitleTextBlockStyle}"/>
<ToggleSwitch x:Name="SendMessageWithEnterToggleSwitch" Grid.Row="1" Margin="0,8" IsOn="{x:Bind Vm.SendMessageWithEnter, Mode=TwoWay}" Toggled="SendMessageWithEnterToggleSwitch_Toggled"/>
</Grid>
</Grid>
</ScrollViewer>
</Grid>
Expand Down
6 changes: 6 additions & 0 deletions Signal-Windows/Views/ChatsAndMediaSettingsPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,11 @@ private void SpellCheckToggleSwitch_Toggled(object sender, RoutedEventArgs e)
var toggleSwitch = sender as ToggleSwitch;
Vm.SpellCheckToggleSwitch_Toggled(toggleSwitch.IsOn);
}

private void SendMessageWithEnterToggleSwitch_Toggled(object sender, RoutedEventArgs e)
{
var toggleSwitch = sender as ToggleSwitch;
Vm.SendMessageWithEnterToggleSwitch_Toggled(toggleSwitch.IsOn);
}
}
}