diff --git a/.github/workflows/msbuild.yml b/.github/workflows/msbuild.yml index 0ba2e311c..5ef999eb4 100644 --- a/.github/workflows/msbuild.yml +++ b/.github/workflows/msbuild.yml @@ -30,11 +30,15 @@ jobs: with: submodules: recursive fetch-depth: 0 - ref: master - name: Add MSBuild to PATH uses: microsoft/setup-msbuild@v3 + - name: Set up .NET SDK for archive regression tests + uses: actions/setup-dotnet@v4 + with: + dotnet-version: '10.0.x' + - name: Restore NuGet packages working-directory: ${{env.GITHUB_WORKSPACE}} run: msbuild /t:Restore /p:Configuration=${{env.BUILD_CONFIGURATION}} ${{env.SOLUTION_FILE_PATH}} @@ -45,12 +49,22 @@ jobs: # See https://docs.microsoft.com/visualstudio/msbuild/msbuild-command-line-reference run: msbuild /m /p:BuildInParallel=true /p:Configuration=${{env.BUILD_CONFIGURATION}} ${{env.SOLUTION_FILE_PATH}} + # Preserve packaged build artifacts before the regression runner rebuilds referenced projects. # upload msi and zip artifacts so the publish job below can download and then update latest release via Linux - uses: actions/upload-artifact@v6 with: name: quicklook-build-files path: Build/QuickLook-*.* + - name: Test archive view interaction and virtualization + working-directory: ${{env.GITHUB_WORKSPACE}} + shell: pwsh + run: | + $solutionDir = (Get-Location).Path + '\' + dotnet run --project ./Tests/ArchiveViewer.Regression/ArchiveViewer.Regression.csproj --configuration Release -p:Platform=AnyCPU -p:SolutionDir=$solutionDir + if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } + + publish: # don't run in parallel - wait for build to complete first needs: build diff --git a/QuickLook.Plugin/QuickLook.Plugin.ArchiveViewer/ArchiveFile/ArchiveFileListBox.cs b/QuickLook.Plugin/QuickLook.Plugin.ArchiveViewer/ArchiveFile/ArchiveFileListBox.cs new file mode 100644 index 000000000..a9eadf0e7 --- /dev/null +++ b/QuickLook.Plugin/QuickLook.Plugin.ArchiveViewer/ArchiveFile/ArchiveFileListBox.cs @@ -0,0 +1,86 @@ +// Copyright © 2017-2026 QL-Win Contributors +// Licensed under the GNU General Public License, version 3 or later. + +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Windows.Automation; +using System.Windows.Automation.Peers; +using System.Windows.Automation.Provider; +using System.Windows.Controls; + +namespace QuickLook.Plugin.ArchiveViewer.ArchiveFile; + +/// +/// Keeps data-item automation peers when visual containers are recycled. +/// The flat list remains a List (not a falsely advertised hierarchical UIA tree). +/// +public sealed class ArchiveFileListBox : ListBox +{ + private ArchiveListPeer _peer; + internal Action ExpansionRequested { get; set; } + + protected override AutomationPeer OnCreateAutomationPeer() => _peer = new ArchiveListPeer(this); + + internal void ResetAutomationPeers() => _peer?.ClearRows(); + + internal void RaiseExpansionChanged(ArchiveFileRow row, bool previous) => _peer?.RaiseExpansionChanged(row, previous); + + private sealed class ArchiveListPeer(ArchiveFileListBox owner) : ListBoxAutomationPeer(owner) + { + private readonly Dictionary> _rows = []; + + protected override ItemAutomationPeer CreateItemAutomationPeer(object item) + { + var row = (ArchiveFileRow)item; + if (_rows.TryGetValue(row, out var reference) && reference.TryGetTarget(out var peer)) + return peer; + peer = new ArchiveRowPeer(item, this, owner); + _rows[row] = new WeakReference(peer); + return peer; + } + + public void ClearRows() => _rows.Clear(); + + public void RaiseExpansionChanged(ArchiveFileRow row, bool previous) + { + if (_rows.TryGetValue(row, out var reference) && reference.TryGetTarget(out var peer)) + peer.RaisePropertyChangedEvent(ExpandCollapsePatternIdentifiers.ExpandCollapseStateProperty, + previous ? ExpandCollapseState.Expanded : ExpandCollapseState.Collapsed, + row.IsExpanded ? ExpandCollapseState.Expanded : ExpandCollapseState.Collapsed); + } + } + + private sealed class ArchiveRowPeer(object item, ListBoxAutomationPeer parent, ArchiveFileListBox owner) + : ListBoxItemAutomationPeer(item, parent), IExpandCollapseProvider + { + private ArchiveFileRow Row => (ArchiveFileRow)Item; + + protected override string GetNameCore() => Row.Entry.Name; + + protected override string GetHelpTextCore() => + string.Format(CultureInfo.CurrentUICulture, ArchiveFileStrings.LevelFormat, Row.Depth + 1); + + public override object GetPattern(PatternInterface patternInterface) => + patternInterface == PatternInterface.ExpandCollapse && Row.HasChildren + ? this : base.GetPattern(patternInterface); + + ExpandCollapseState IExpandCollapseProvider.ExpandCollapseState => + !Row.HasChildren ? ExpandCollapseState.LeafNode : + Row.IsExpanded ? ExpandCollapseState.Expanded : ExpandCollapseState.Collapsed; + + void IExpandCollapseProvider.Expand() => SetExpanded(true); + void IExpandCollapseProvider.Collapse() => SetExpanded(false); + + private void SetExpanded(bool expanded) + { + owner.Dispatcher.Invoke(() => + { + if (!owner.IsEnabled) throw new ElementNotEnabledException(); + if (!owner.Items.Contains(Row) || owner.ExpansionRequested == null) + throw new ElementNotAvailableException(); + owner.ExpansionRequested(Row, expanded); + }); + } + } +} diff --git a/QuickLook.Plugin/QuickLook.Plugin.ArchiveViewer/ArchiveFile/ArchiveFileListView.xaml b/QuickLook.Plugin/QuickLook.Plugin.ArchiveViewer/ArchiveFile/ArchiveFileListView.xaml index a4ebca1ee..6903fa63e 100644 --- a/QuickLook.Plugin/QuickLook.Plugin.ArchiveViewer/ArchiveFile/ArchiveFileListView.xaml +++ b/QuickLook.Plugin/QuickLook.Plugin.ArchiveViewer/ArchiveFile/ArchiveFileListView.xaml @@ -1,133 +1,154 @@ - - + - - - - - - - + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - + + + + + + + + + + + + + + - - - - + + + - - + + + + + + + + + +