mirror of
https://github.com/QL-Win/QuickLook.git
synced 2025-09-11 17:59:17 +00:00
Global dark theme
This commit is contained in:
@@ -37,7 +37,7 @@ namespace QuickLook.Common.Plugin
|
||||
private bool _titlebarBlurVisibility;
|
||||
private bool _titlebarColourVisibility = true;
|
||||
private bool _titlebarOverlap;
|
||||
private bool _useDarkTheme;
|
||||
private Themes _theme = Themes.None;
|
||||
private object _viewerContent;
|
||||
|
||||
/// <summary>
|
||||
@@ -168,12 +168,12 @@ namespace QuickLook.Common.Plugin
|
||||
/// <summary>
|
||||
/// Switch to dark theme?
|
||||
/// </summary>
|
||||
public bool UseDarkTheme
|
||||
public Themes Theme
|
||||
{
|
||||
get => _useDarkTheme;
|
||||
get => _theme;
|
||||
set
|
||||
{
|
||||
_useDarkTheme = value;
|
||||
_theme = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
@@ -213,7 +213,7 @@ namespace QuickLook.Common.Plugin
|
||||
CanResize = true;
|
||||
FullWindowDragging = false;
|
||||
|
||||
UseDarkTheme = false;
|
||||
Theme = Themes.None;
|
||||
TitlebarOverlap = false;
|
||||
TitlebarAutoHide = false;
|
||||
TitlebarBlurVisibility = false;
|
||||
|
26
QuickLook.Common/Plugin/Themes.cs
Normal file
26
QuickLook.Common/Plugin/Themes.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
// Copyright © 2018 Paddy Xu
|
||||
//
|
||||
// This file is part of QuickLook program.
|
||||
//
|
||||
// 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 3 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
namespace QuickLook.Common.Plugin
|
||||
{
|
||||
public enum Themes
|
||||
{
|
||||
None,
|
||||
Dark,
|
||||
Light
|
||||
}
|
||||
}
|
@@ -57,6 +57,7 @@
|
||||
<Compile Include="Plugin\IViewer.cs" />
|
||||
<Compile Include="NativeMethods\Kernel32.cs" />
|
||||
<Compile Include="Helpers\ProcessHelper.cs" />
|
||||
<Compile Include="Plugin\Themes.cs" />
|
||||
<Compile Include="Properties\Annotations.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Helpers\SettingHelper.cs" />
|
||||
@@ -64,6 +65,19 @@
|
||||
<Compile Include="NativeMethods\User32.cs" />
|
||||
<Compile Include="Helpers\WindowHelper.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<ItemGroup>
|
||||
<Page Include="Styles\MainWindowStyles.Dark.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Include="Styles\MainWindowStyles.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Include="Styles\ScrollBarStyleDictionary.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
@@ -98,7 +98,7 @@
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
<Border Grid.RowSpan="3" CornerRadius="2" Background="#F0F0F0" />
|
||||
<Border Grid.RowSpan="3" CornerRadius="2" Background="Transparent" />
|
||||
<Track x:Name="PART_Track" Grid.Row="0" IsDirectionReversed="true">
|
||||
<Track.DecreaseRepeatButton>
|
||||
<RepeatButton Style="{StaticResource ScrollBarPageButton}" Command="ScrollBar.PageUpCommand" />
|
||||
@@ -124,7 +124,7 @@
|
||||
<Border
|
||||
Grid.ColumnSpan="3"
|
||||
CornerRadius="2"
|
||||
Background="#F0F0F0" />
|
||||
Background="Transparent" />
|
||||
<Track
|
||||
x:Name="PART_Track"
|
||||
Grid.Column="0"
|
@@ -130,13 +130,13 @@
|
||||
|
||||
<TreeView Grid.Row="1"
|
||||
x:Name="treeView"
|
||||
BorderThickness="0" Background="Transparent"
|
||||
BorderThickness="0" Background="Transparent" Foreground="{Binding Foreground, RelativeSource={RelativeSource AncestorType=local:ArchiveFileListView}}"
|
||||
ItemsSource="{Binding}">
|
||||
<!--<TreeView.ItemContainerStyle>
|
||||
<TreeView.ItemContainerStyle>
|
||||
<Style TargetType="{x:Type TreeViewItem}">
|
||||
<Setter Property="IsExpanded" Value="{Binding Level, Converter={StaticResource LevelToBooleanConverter}}" />
|
||||
<Setter Property="Foreground" Value="{Binding Foreground, RelativeSource={RelativeSource AncestorType=TreeView}}" />
|
||||
</Style>
|
||||
</TreeView.ItemContainerStyle>-->
|
||||
</TreeView.ItemContainerStyle>
|
||||
</TreeView>
|
||||
</Grid>
|
||||
</UserControl>
|
@@ -11,7 +11,7 @@
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<!-- only for design -->
|
||||
<ResourceDictionary Source="/QuickLook;component/Styles/MainWindowStyles.xaml" />
|
||||
<ResourceDictionary Source="/QuickLook.Common;component/Styles/MainWindowStyles.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
<local:Percent100ToVisibilityVisibleConverter x:Key="Percent100ToVisibilityVisibleConverter" />
|
||||
<local:Percent100ToVisibilityCollapsedConverter x:Key="Percent100ToVisibilityCollapsedConverter" />
|
||||
@@ -21,7 +21,7 @@
|
||||
<Grid ZIndex="9999"
|
||||
Visibility="{Binding ElementName=infoPanel, Path=LoadPercent, Mode=OneWay, Converter={StaticResource Percent100ToVisibilityCollapsedConverter}}">
|
||||
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
|
||||
<Label FontSize="14" HorizontalAlignment="Center">Loading archive ...</Label>
|
||||
<Label FontSize="14" HorizontalAlignment="Center" Foreground="{DynamicResource WindowTextForeground}">Loading archive ...</Label>
|
||||
<ProgressBar Height="13" Width="150"
|
||||
Value="{Binding ElementName=infoPanel, Path=LoadPercent, Mode=OneWay}" />
|
||||
</StackPanel>
|
||||
@@ -32,16 +32,16 @@
|
||||
<RowDefinition />
|
||||
<RowDefinition Height="30" />
|
||||
</Grid.RowDefinitions>
|
||||
<local:ArchiveFileListView Grid.Row="0" x:Name="fileListView" Focusable="False" />
|
||||
<local:ArchiveFileListView Grid.Row="0" x:Name="fileListView" Focusable="False" Foreground="{DynamicResource WindowTextForeground}" />
|
||||
<Grid Grid.Row="1">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="40*" />
|
||||
<ColumnDefinition Width="30*" />
|
||||
<ColumnDefinition Width="30*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Label x:Name="archiveCount" Grid.Column="0" HorizontalAlignment="Center" VerticalAlignment="Center">0 folders and 0 files, solid, password-protected</Label>
|
||||
<Label x:Name="archiveSizeC" Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Center">Compressed size 0 bytes</Label>
|
||||
<Label x:Name="archiveSizeU" Grid.Column="2" HorizontalAlignment="Center" VerticalAlignment="Center">Uncompressed size 0 bytes</Label>
|
||||
<Label x:Name="archiveCount" Grid.Column="0" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="{DynamicResource WindowTextForegroundAlternative}">0 folders and 0 files, solid, password-protected</Label>
|
||||
<Label x:Name="archiveSizeC" Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="{DynamicResource WindowTextForegroundAlternative}">Compressed size 0 bytes</Label>
|
||||
<Label x:Name="archiveSizeU" Grid.Column="2" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="{DynamicResource WindowTextForegroundAlternative}">Uncompressed size 0 bytes</Label>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
@@ -12,8 +12,8 @@
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<!-- only for design -->
|
||||
<ResourceDictionary Source="/QuickLook;component/Styles/MainWindowStyles.xaml" />
|
||||
<ResourceDictionary Source="/QuickLook;component/Styles/MainWindowStyles.Dark.xaml" />
|
||||
<ResourceDictionary Source="/QuickLook.Common;component/Styles/MainWindowStyles.xaml" />
|
||||
<ResourceDictionary Source="/QuickLook.Common;component/Styles/MainWindowStyles.Dark.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
</UserControl.Resources>
|
||||
|
@@ -64,7 +64,7 @@ namespace QuickLook.Plugin.ImageViewer
|
||||
else
|
||||
context.PreferredSize = new Size(800, 600);
|
||||
|
||||
context.UseDarkTheme = true;
|
||||
context.Theme = Themes.Dark;
|
||||
}
|
||||
|
||||
public void View(string path, ContextObject context)
|
||||
|
@@ -13,6 +13,7 @@
|
||||
<UserControl.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="/QuickLook.Common;component/Styles/MainWindowStyles.xaml" />
|
||||
<ResourceDictionary Source="ListBoxItemStyleNoFocusedBorder.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
@@ -26,9 +27,9 @@
|
||||
VirtualizingPanel.IsVirtualizing="True" Width="150"
|
||||
SelectedIndex="0"
|
||||
Focusable="False"
|
||||
Background="Transparent"
|
||||
Background="Transparent" BorderThickness="0"
|
||||
ItemsSource="{Binding PageThumbnails, ElementName=thisPdfViewer}"
|
||||
ScrollViewer.HorizontalScrollBarVisibility="Disabled" BorderThickness="0,0,1,0"
|
||||
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
|
||||
ItemContainerStyle="{Binding Mode=OneWay, Source={StaticResource ListBoxItemStyleNoFocusedBorder}}">
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
@@ -44,7 +45,7 @@
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="10" />
|
||||
</Grid.RowDefinitions>
|
||||
<Border x:Name="bbd" Grid.Row="1" Grid.Column="1" BorderThickness="1" BorderBrush="#FFE1E1E1">
|
||||
<Border x:Name="bbd" Grid.Row="1" Grid.Column="1" BorderThickness="1" BorderBrush="#33FFFFFF">
|
||||
<Image Source="{Binding}" />
|
||||
</Border>
|
||||
<!--
|
||||
@@ -55,13 +56,13 @@
|
||||
<DataTrigger
|
||||
Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ListBoxItem}}, Path=IsSelected}"
|
||||
Value="True">
|
||||
<Setter TargetName="bbd" Property="BorderBrush" Value="#FF0040FF" />
|
||||
<Setter TargetName="bbd" Property="BorderBrush" Value="#DD0027FF" />
|
||||
</DataTrigger>
|
||||
</DataTemplate.Triggers>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
<Grid Grid.Column="1" Background="#FFFAFAFA">
|
||||
<Grid Grid.Column="1" Background="#33FFFFFF">
|
||||
<imageViewer:ImagePanel x:Name="pagePanel" RenderMode="NearestNeighbor" ShowZoomLevelInfo="False"
|
||||
BackgroundVisibility="Collapsed" MetaIconVisibility="Collapsed" />
|
||||
</Grid>
|
||||
|
@@ -46,6 +46,9 @@ namespace QuickLook.Plugin.PDFViewer
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
// remove theme used in designer
|
||||
Resources.MergedDictionaries.RemoveAt(0);
|
||||
|
||||
listThumbnails.SelectionChanged += UpdatePageViewWhenSelectionChanged;
|
||||
|
||||
pagePanel.DelayedReRender += ReRenderCurrentPageDelayed;
|
||||
|
@@ -82,6 +82,8 @@ namespace QuickLook.Plugin.TextViewer
|
||||
|
||||
public void Prepare(string path, ContextObject context)
|
||||
{
|
||||
context.Theme = Themes.Light;
|
||||
|
||||
context.PreferredSize = new Size {Width = 800, Height = 600};
|
||||
}
|
||||
|
||||
|
@@ -80,7 +80,7 @@ namespace QuickLook.Plugin.VideoViewer
|
||||
else
|
||||
{
|
||||
context.TitlebarAutoHide = true;
|
||||
context.UseDarkTheme = true;
|
||||
context.Theme = Themes.Dark;
|
||||
context.TitlebarBlurVisibility = true;
|
||||
}
|
||||
}
|
||||
|
@@ -2,7 +2,7 @@
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<!-- only for design -->
|
||||
<ResourceDictionary Source="/QuickLook;component/Styles/MainWindowStyles.xaml" />
|
||||
<ResourceDictionary Source="/QuickLook.Common;component/Styles/MainWindowStyles.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
|
||||
<Style x:Key="ControlButtonStyle" TargetType="Button" BasedOn="{StaticResource CaptionButtonStyle}">
|
||||
|
@@ -285,13 +285,10 @@ namespace QuickLook.Plugin.VideoViewer
|
||||
if (CoverArt == null)
|
||||
return;
|
||||
|
||||
var dark = false;
|
||||
using (var bitmap = new Bitmap(CoverArt.ToBitmap()))
|
||||
{
|
||||
dark = bitmap.IsDarkImage();
|
||||
_context.Theme = bitmap.IsDarkImage() ? Themes.Dark : Themes.Light;
|
||||
}
|
||||
|
||||
_context.UseDarkTheme = dark;
|
||||
}
|
||||
|
||||
private void ChangeVolume(double delta)
|
||||
|
@@ -8,7 +8,7 @@
|
||||
<Application.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="Styles/ScrollBarStyleDictionary.xaml" />
|
||||
<ResourceDictionary Source="/QuickLook.Common;component/Styles/ScrollBarStyleDictionary.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
<FontFamily x:Key="SegoeMDL2">./Fonts/#Segoe MDL2 Assets</FontFamily>
|
||||
</ResourceDictionary>
|
||||
|
@@ -9,7 +9,7 @@
|
||||
<UserControl.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="../../Styles/MainWindowStyles.xaml" />
|
||||
<ResourceDictionary Source="/QuickLook.Common;component/Styles/MainWindowStyles.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
</UserControl.Resources>
|
||||
|
@@ -153,18 +153,6 @@
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Include="Styles\MainWindowStyles.Dark.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Include="Styles\MainWindowStyles.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Styles\ScrollBarStyleDictionary.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="ViewerWindow.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
|
@@ -19,6 +19,7 @@ using System;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Windows;
|
||||
using Microsoft.Win32;
|
||||
using QuickLook.Common.Annotations;
|
||||
using QuickLook.Common.Plugin;
|
||||
|
||||
@@ -28,7 +29,7 @@ namespace QuickLook
|
||||
{
|
||||
private readonly ResourceDictionary _darkDict = new ResourceDictionary
|
||||
{
|
||||
Source = new Uri("pack://application:,,,/QuickLook;component/Styles/MainWindowStyles.Dark.xaml")
|
||||
Source = new Uri("pack://application:,,,/QuickLook.Common;component/Styles/MainWindowStyles.Dark.xaml")
|
||||
};
|
||||
private bool _canOldPluginResize;
|
||||
private bool _pinned;
|
||||
@@ -57,17 +58,33 @@ namespace QuickLook
|
||||
{
|
||||
switch (e.PropertyName)
|
||||
{
|
||||
case nameof(ContextObject.UseDarkTheme):
|
||||
SwitchTheme(ContextObject.UseDarkTheme);
|
||||
case nameof(ContextObject.Theme):
|
||||
SwitchTheme(ContextObject.Theme);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void SwitchTheme(bool dark)
|
||||
public void SwitchTheme(Themes theme)
|
||||
{
|
||||
if (dark)
|
||||
var isDark = false;
|
||||
|
||||
switch (theme)
|
||||
{
|
||||
case Themes.None:
|
||||
var t = Registry.GetValue(
|
||||
@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize",
|
||||
"AppsUseLightTheme", 1);
|
||||
isDark = t != null && (int) t == 0;
|
||||
break;
|
||||
case Themes.Dark:
|
||||
case Themes.Light:
|
||||
isDark = theme == Themes.Dark;
|
||||
break;
|
||||
}
|
||||
|
||||
if (isDark)
|
||||
{
|
||||
if (!Resources.MergedDictionaries.Contains(_darkDict))
|
||||
Resources.MergedDictionaries.Add(_darkDict);
|
||||
|
@@ -22,7 +22,7 @@
|
||||
<Window.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="Styles/MainWindowStyles.xaml" />
|
||||
<ResourceDictionary Source="/QuickLook.Common;component/Styles/MainWindowStyles.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
<converters:WindowStateMaximizedToThicknessConverter x:Key="WindowStateMaximizedToThicknessConverter" />
|
||||
<converters:WindowStateNormalToThicknessConverter x:Key="WindowStateNormalToThicknessConverter" />
|
||||
|
Reference in New Issue
Block a user