diff --git a/src/Greenshot.Addons/Core/ICoreConfiguration.cs b/src/Greenshot.Addons/Core/ICoreConfiguration.cs index ca77a48d1..126383072 100644 --- a/src/Greenshot.Addons/Core/ICoreConfiguration.cs +++ b/src/Greenshot.Addons/Core/ICoreConfiguration.cs @@ -214,6 +214,10 @@ namespace Greenshot.Addons.Core [Description("Comma separated list of destinations which should be disabled.")] IList ExcludeDestinations { get; set; } + [Description("Should Greenshot check for updates?")] + [DefaultValue(true)] + bool CheckForUpdates { get; set; } + [Description("How many days between every update check? (0=no checks)")] [DefaultValue(14)] int UpdateCheckInterval { get; set; } diff --git a/src/Greenshot.Addons/Core/INetworkConfiguration.cs b/src/Greenshot.Addons/Core/INetworkConfiguration.cs new file mode 100644 index 000000000..27022b4e1 --- /dev/null +++ b/src/Greenshot.Addons/Core/INetworkConfiguration.cs @@ -0,0 +1,49 @@ +#region Greenshot GNU General License + +// Greenshot - a free and open source screenshot tool +// Copyright (C) 2007-2018 Thomas Braun, Jens Klingen, Robin Krom +// +// For more information see: http://getgreenshot.org/ +// The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General License as published by +// the Free Software Foundation, either version 1 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 License for more details. +// +// You should have received a copy of the GNU General License +// along with this program. If not, see . + +#endregion + +#region Usings + +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using Dapplo.HttpExtensions; +using Dapplo.Ini; +using Dapplo.InterfaceImpl.Extensions; +using Dapplo.Windows.Common.Structs; +using Greenshot.Addons.Core.Enums; +using Greenshot.Addons.Interfaces; + +#endregion + +namespace Greenshot.Addons.Core +{ + /// + /// Network (HTTP) configuration. + /// + [IniSection("Network")] + [Description("Greenshot network configuration")] + public interface INetworkConfiguration : IIniSection, IHttpSettings, INotifyPropertyChanged, IWriteProtectProperties, IDefaultValue, ITransactionalProperties + { + } +} \ No newline at end of file diff --git a/src/Greenshot.Addons/Greenshot.Addons.csproj b/src/Greenshot.Addons/Greenshot.Addons.csproj index 2beaf9204..14fa251d1 100644 --- a/src/Greenshot.Addons/Greenshot.Addons.csproj +++ b/src/Greenshot.Addons/Greenshot.Addons.csproj @@ -210,6 +210,7 @@ + diff --git a/src/Greenshot.Addons/ViewModels/FileConfigPartViewModel.cs b/src/Greenshot.Addons/ViewModels/FileConfigPartViewModel.cs index 751873167..4925dcb13 100644 --- a/src/Greenshot.Addons/ViewModels/FileConfigPartViewModel.cs +++ b/src/Greenshot.Addons/ViewModels/FileConfigPartViewModel.cs @@ -42,11 +42,12 @@ namespace Greenshot.Addons.ViewModels private bool _useOwnSettings; [Import] - public ICoreConfiguration FileConfiguration { get; set; } + public ICoreConfiguration CoreConfiguration { get; set; } [Import] public IGreenshotLanguage GreenshotLanguage { get; set; } + /// /// A NPC wrapper for the UseOwnSettings in the IDestinationFileConfiguration, as this doesn't work when ITransactionalProperties is used /// @@ -62,9 +63,18 @@ namespace Greenshot.Addons.ViewModels _destinationFileConfiguration.UseOwnSettings = value; } NotifyOfPropertyChange(); + NotifyOfPropertyChange(nameof(AreSettingsEnabled)); + NotifyOfPropertyChange(nameof(FileConfiguration)); + NotifyOfPropertyChange(nameof(SelectedFormat)); + NotifyOfPropertyChange(nameof(JpegSettingsVisibility)); } } + public IFileConfiguration FileConfiguration => + DestinationFileConfiguration?.UseOwnSettings == true + ? (IFileConfiguration)DestinationFileConfiguration + : CoreConfiguration; + /// /// This needs to be set with the IDestinationFileConfiguration to have make local configuration for a destination possible /// @@ -73,10 +83,13 @@ namespace Greenshot.Addons.ViewModels get => _destinationFileConfiguration; set { - if (Equals(value, _destinationFileConfiguration)) return; + if (Equals(value, _destinationFileConfiguration)) + { + return; + } _destinationFileConfiguration = value; - NotifyOfPropertyChange(nameof(DestinationFileConfigurationVisiblity)); - NotifyOfPropertyChange(nameof(AreGlobalSettingsEnabled)); + NotifyOfPropertyChange(nameof(AreSettingsEnabled)); + NotifyOfPropertyChange(nameof(FileConfiguration)); NotifyOfPropertyChange(nameof(OwnSettingsVisibility)); } } @@ -84,60 +97,31 @@ namespace Greenshot.Addons.ViewModels /// /// Specifies if the global settings can be modified, which is the case when there are is no DestinationFileConfiguration /// - public bool AreGlobalSettingsEnabled => DestinationFileConfiguration == null; + public bool AreSettingsEnabled => DestinationFileConfiguration == null || DestinationFileConfiguration.UseOwnSettings; /// /// If there is a DestinationFileConfiguration, the checkbox is shown /// public Visibility OwnSettingsVisibility => DestinationFileConfiguration != null? Visibility.Visible : Visibility.Collapsed; - /// - /// If there is a DestinationFileConfiguration and use own settings is set the configuration is shown - /// - public Visibility DestinationFileConfigurationVisiblity => DestinationFileConfiguration != null && _useOwnSettings ? Visibility.Visible : Visibility.Collapsed; - - /// - /// If there is a DestinationFileConfiguration, the global configuration is not shown - /// - public Visibility GlobalFileConfigurationVisiblity => AreGlobalSettingsEnabled || !_useOwnSettings ? Visibility.Visible : Visibility.Collapsed; - /// /// The globally selected format /// public OutputFormats SelectedFormat { - get => FileConfiguration.OutputFileFormat ; + get => FileConfiguration.OutputFileFormat; set { FileConfiguration.OutputFileFormat = value; NotifyOfPropertyChange(); - NotifyOfPropertyChange(nameof(GlobalJpegSettingsVisibility)); + NotifyOfPropertyChange(nameof(JpegSettingsVisibility)); } } /// /// The global jpeg quality settings visibility /// - public Visibility GlobalJpegSettingsVisibility => SelectedFormat == OutputFormats.jpg ? Visibility.Visible : Visibility.Collapsed; - - /// - /// The locally selected format - /// - public OutputFormats DestinationSelectedFormat - { - get => DestinationFileConfiguration.OutputFileFormat; - set - { - DestinationFileConfiguration.OutputFileFormat = value; - NotifyOfPropertyChange(); - NotifyOfPropertyChange(nameof(DestinationJpegSettingsVisibility)); - } - } - - /// - /// The global jpeg quality settings visibility - /// - public Visibility DestinationJpegSettingsVisibility => DestinationSelectedFormat == OutputFormats.jpg ? Visibility.Visible : Visibility.Collapsed; + public Visibility JpegSettingsVisibility => SelectedFormat == OutputFormats.jpg ? Visibility.Visible : Visibility.Collapsed; /// /// The formats available, with their translation diff --git a/src/Greenshot.Addons/Views/FileConfigPartView.xaml b/src/Greenshot.Addons/Views/FileConfigPartView.xaml index 888233630..fd7d92d5e 100644 --- a/src/Greenshot.Addons/Views/FileConfigPartView.xaml +++ b/src/Greenshot.Addons/Views/FileConfigPartView.xaml @@ -11,25 +11,22 @@ - - - - - - - + + - + + + + + diff --git a/src/Greenshot/Greenshot.csproj b/src/Greenshot/Greenshot.csproj index 93f1be6e1..1bc1feb92 100644 --- a/src/Greenshot/Greenshot.csproj +++ b/src/Greenshot/Greenshot.csproj @@ -265,6 +265,9 @@ BugReportForm.cs + + + @@ -489,6 +492,18 @@ MSBuild:Compile Designer + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + Designer MSBuild:Compile diff --git a/src/Greenshot/Ui/Configuration/ViewModels/CaptureConfigViewModel.cs b/src/Greenshot/Ui/Configuration/ViewModels/CaptureConfigViewModel.cs index 8d6510d2d..bdbd5de39 100644 --- a/src/Greenshot/Ui/Configuration/ViewModels/CaptureConfigViewModel.cs +++ b/src/Greenshot/Ui/Configuration/ViewModels/CaptureConfigViewModel.cs @@ -21,14 +21,11 @@ #endregion -using System; using System.Collections.Generic; -using System.Collections.ObjectModel; using System.ComponentModel.Composition; using System.Reactive.Disposables; using Dapplo.CaliburnMicro.Configuration; using Dapplo.CaliburnMicro.Extensions; -using Dapplo.CaliburnMicro.Metro; using Greenshot.Addons; using Greenshot.Addons.Core; using Greenshot.Addons.Core.Enums; @@ -46,16 +43,6 @@ namespace Greenshot.Ui.Configuration.ViewModels /// private CompositeDisposable _disposables; - /// - /// The avaible theme accents - /// - public ObservableCollection> AvailableThemeAccents { get; set; } = new ObservableCollection>(); - - /// - /// The avaible themes - /// - public ObservableCollection> AvailableThemes { get; set; } = new ObservableCollection>(); - [Import] public ICoreConfiguration CoreConfiguration { get; set; } @@ -69,7 +56,6 @@ namespace Greenshot.Ui.Configuration.ViewModels { // Prepare disposables _disposables?.Dispose(); - _disposables = new CompositeDisposable(); // Place this under the Ui parent ParentId = nameof(ConfigIds.Capture); @@ -78,11 +64,11 @@ namespace Greenshot.Ui.Configuration.ViewModels config.Register(CoreConfiguration); // automatically update the DisplayName - var greenshotLanguageBinding = GreenshotLanguage.CreateDisplayNameBinding(this, nameof(IGreenshotLanguage.SettingsCapture)); - - // Make sure the greenshotLanguageBinding is disposed when this is no longer active - _disposables.Add(greenshotLanguageBinding); - + _disposables = new CompositeDisposable + { + GreenshotLanguage.CreateDisplayNameBinding(this, nameof(IGreenshotLanguage.SettingsCapture)) + }; + base.Initialize(config); } diff --git a/src/Greenshot/Ui/Configuration/ViewModels/GeneralConfigViewModel.cs b/src/Greenshot/Ui/Configuration/ViewModels/GeneralConfigViewModel.cs new file mode 100644 index 000000000..1fc7b8152 --- /dev/null +++ b/src/Greenshot/Ui/Configuration/ViewModels/GeneralConfigViewModel.cs @@ -0,0 +1,74 @@ +#region Greenshot GNU General Public License + +// Greenshot - a free and open source screenshot tool +// Copyright (C) 2007-2018 Thomas Braun, Jens Klingen, Robin Krom +// +// For more information see: http://getgreenshot.org/ +// The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot +// +// 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 1 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. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +#endregion + +using System.ComponentModel.Composition; +using System.Reactive.Disposables; +using Dapplo.CaliburnMicro.Configuration; +using Dapplo.CaliburnMicro.Extensions; +using Greenshot.Addons; +using Greenshot.Addons.Core; +using Greenshot.Configuration; + +namespace Greenshot.Ui.Configuration.ViewModels +{ + [Export(typeof(IConfigScreen))] + public sealed class GeneralConfigViewModel : SimpleConfigScreen + { + /// + /// Here all disposables are registered, so we can clean the up + /// + private CompositeDisposable _disposables; + + [Import] + public ICoreConfiguration CoreConfiguration { get; set; } + + [Import] + public IConfigTranslations ConfigTranslations { get; set; } + + [Import] + public IGreenshotLanguage GreenshotLanguage { get; set; } + + public override void Initialize(IConfig config) + { + // Prepare disposables + _disposables?.Dispose(); + + // Make sure Commit/Rollback is called on the IUiConfiguration + config.Register(CoreConfiguration); + + // automatically update the DisplayName + _disposables = new CompositeDisposable + { + GreenshotLanguage.CreateDisplayNameBinding(this, nameof(IGreenshotLanguage.SettingsGeneral)) + }; + + base.Initialize(config); + } + + protected override void OnDeactivate(bool close) + { + _disposables.Dispose(); + base.OnDeactivate(close); + } + } +} diff --git a/src/Greenshot/Ui/Configuration/ViewModels/NetworkConfigViewModel.cs b/src/Greenshot/Ui/Configuration/ViewModels/NetworkConfigViewModel.cs new file mode 100644 index 000000000..ca19f72f6 --- /dev/null +++ b/src/Greenshot/Ui/Configuration/ViewModels/NetworkConfigViewModel.cs @@ -0,0 +1,71 @@ +#region Greenshot GNU General Public License + +// Greenshot - a free and open source screenshot tool +// Copyright (C) 2007-2018 Thomas Braun, Jens Klingen, Robin Krom +// +// For more information see: http://getgreenshot.org/ +// The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot +// +// 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 1 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. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +#endregion + +using System.ComponentModel.Composition; +using System.Reactive.Disposables; +using Dapplo.CaliburnMicro.Configuration; +using Dapplo.CaliburnMicro.Extensions; +using Greenshot.Addons; +using Greenshot.Addons.Core; + +namespace Greenshot.Ui.Configuration.ViewModels +{ + [Export(typeof(IConfigScreen))] + public sealed class NetworkConfigViewModel : SimpleConfigScreen + { + /// + /// Here all disposables are registered, so we can clean the up + /// + private CompositeDisposable _disposables; + + [Import] + public INetworkConfiguration NetworkConfiguration { get; set; } + + [Import] + public IGreenshotLanguage GreenshotLanguage { get; set; } + + public override void Initialize(IConfig config) + { + // Prepare disposables + _disposables?.Dispose(); + + // Make sure Commit/Rollback is called on the IUiConfiguration + config.Register(NetworkConfiguration); + + // automatically update the DisplayName + _disposables = new CompositeDisposable + { + GreenshotLanguage.CreateDisplayNameBinding(this, nameof(IGreenshotLanguage.SettingsNetwork)) + }; + + base.Initialize(config); + } + + protected override void OnDeactivate(bool close) + { + _disposables.Dispose(); + base.OnDeactivate(close); + } + + } +} diff --git a/src/Greenshot/Ui/Configuration/ViewModels/OutputConfigViewModel.cs b/src/Greenshot/Ui/Configuration/ViewModels/OutputConfigViewModel.cs new file mode 100644 index 000000000..4308a54ad --- /dev/null +++ b/src/Greenshot/Ui/Configuration/ViewModels/OutputConfigViewModel.cs @@ -0,0 +1,78 @@ +#region Greenshot GNU General Public License + +// Greenshot - a free and open source screenshot tool +// Copyright (C) 2007-2018 Thomas Braun, Jens Klingen, Robin Krom +// +// For more information see: http://getgreenshot.org/ +// The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot +// +// 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 1 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. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +#endregion + +using System.ComponentModel.Composition; +using System.Reactive.Disposables; +using Dapplo.CaliburnMicro.Configuration; +using Dapplo.CaliburnMicro.Extensions; +using Greenshot.Addons; +using Greenshot.Addons.Core; +using Greenshot.Addons.ViewModels; +using Greenshot.Configuration; + +namespace Greenshot.Ui.Configuration.ViewModels +{ + [Export(typeof(IConfigScreen))] + public sealed class OutputConfigViewModel : SimpleConfigScreen + { + /// + /// Here all disposables are registered, so we can clean the up + /// + private CompositeDisposable _disposables; + + [Import] + public ICoreConfiguration CoreConfiguration { get; set; } + + [Import] + public IConfigTranslations ConfigTranslations { get; set; } + + [Import] + public IGreenshotLanguage GreenshotLanguage { get; set; } + + [Import] + public FileConfigPartViewModel FileConfigPartViewModel { get; set; } + + public override void Initialize(IConfig config) + { + // Prepare disposables + _disposables?.Dispose(); + + // Make sure Commit/Rollback is called on the IUiConfiguration + config.Register(CoreConfiguration); + + // automatically update the DisplayName + _disposables = new CompositeDisposable + { + GreenshotLanguage.CreateDisplayNameBinding(this, nameof(IGreenshotLanguage.SettingsOutput)) + }; + + base.Initialize(config); + } + + protected override void OnDeactivate(bool close) + { + _disposables.Dispose(); + base.OnDeactivate(close); + } + } +} diff --git a/src/Greenshot/Ui/Configuration/ViewModels/UiConfigViewModel.cs b/src/Greenshot/Ui/Configuration/ViewModels/UiConfigViewModel.cs index 1a0e36f4a..976b4064e 100644 --- a/src/Greenshot/Ui/Configuration/ViewModels/UiConfigViewModel.cs +++ b/src/Greenshot/Ui/Configuration/ViewModels/UiConfigViewModel.cs @@ -100,7 +100,6 @@ namespace Greenshot.Ui.Configuration.ViewModels { // Prepare disposables _disposables?.Dispose(); - _disposables = new CompositeDisposable(); AvailableThemeAccents.Clear(); foreach (var themeAccent in Enum.GetValues(typeof(ThemeAccents)).Cast()) @@ -123,10 +122,10 @@ namespace Greenshot.Ui.Configuration.ViewModels config.Register(MetroConfiguration); // automatically update the DisplayName - var greenshotLanguageBinding = GreenshotLanguage.CreateDisplayNameBinding(this, nameof(IGreenshotLanguage.SettingsTitle)); - - // Make sure the greenshotLanguageBinding is disposed when this is no longer active - _disposables.Add(greenshotLanguageBinding); + _disposables = new CompositeDisposable + { + GreenshotLanguage.CreateDisplayNameBinding(this, nameof(IGreenshotLanguage.SettingsTitle)) + }; base.Initialize(config); } diff --git a/src/Greenshot/Ui/Configuration/Views/GeneralConfigView.xaml b/src/Greenshot/Ui/Configuration/Views/GeneralConfigView.xaml new file mode 100644 index 000000000..6f1470e04 --- /dev/null +++ b/src/Greenshot/Ui/Configuration/Views/GeneralConfigView.xaml @@ -0,0 +1,17 @@ + + + + + + + diff --git a/src/Greenshot/Ui/Configuration/Views/NetworkConfigView.xaml b/src/Greenshot/Ui/Configuration/Views/NetworkConfigView.xaml new file mode 100644 index 000000000..8c64da25d --- /dev/null +++ b/src/Greenshot/Ui/Configuration/Views/NetworkConfigView.xaml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + diff --git a/src/Greenshot/Ui/Configuration/Views/OutputConfigView.xaml b/src/Greenshot/Ui/Configuration/Views/OutputConfigView.xaml new file mode 100644 index 000000000..2b13f071a --- /dev/null +++ b/src/Greenshot/Ui/Configuration/Views/OutputConfigView.xaml @@ -0,0 +1,13 @@ + + + + +