Skip to content

fix(NFilePicker): Added multiSelection choice#2253

Merged
Ly-sec merged 2 commits intonoctalia-dev:mainfrom
spiros132:main
Mar 22, 2026
Merged

fix(NFilePicker): Added multiSelection choice#2253
Ly-sec merged 2 commits intonoctalia-dev:mainfrom
spiros132:main

Conversation

@spiros132
Copy link
Copy Markdown
Contributor

Pull Request

Added the choice to have a NFilePicker where you can choose multiple items at the same time

Motivation

The NFilePicker component currently only supports choosing one item but I believe it would be good for the developers to have the choice for multiple items to be chosen at the same time. The boolean to enable multiple choices at the same time is false by default since that's how it has been working so far. Right now you can select multiple items with the Shift button.

Type of Change

Mark the relevant option with an "x".

  • Bug fix
  • New feature
  • Breaking change
  • Refactoring

Related Issue

No related issue found.

Testing

The testing was done by using it, opening multiple file pickers and seeing that it works.

  • Tested on niri
  • Tested on Hyprland
  • Tested on sway
  • Tested with different bar positions and density settings
  • Tested at different interface scaling values
  • Tested with multiple monitors (if applicable)

Screenshots / Videos

A screenshot showing multiple folders being selected at the same time.
image

Checklist

  • Code follows project style guidelines
  • Self-reviewed my code
  • No new warnings or errors
  • Documentation or comments updated (if relevant)

Additional Notes

This PR only adds support for selecting multiple files / folders with holding the shift button. Some people are used to having the shift button select from the first item in a list to the last item in the list, so in that case maybe ctrl might have been better but I'm not really sure tbh.

Also the code is very repetitive, in that case I can refactor it to put everything under one function instead to make it less repetitive if that's wished for.

Copy link
Copy Markdown
Collaborator

@Ly-sec Ly-sec left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall it's quite good @spiros132 but as you said, maybe change it from Shift to Control given it makes more sense in terms of UX. If it's not too hard we should perhaps implement the Shift selection too - up to you though.

Comment thread Widgets/NFilePicker.qml Outdated
filePickerPanel.currentSelection = [model.filePath];
// Deep copy otherwise the isSelected might not get updated.
if (root.allowMultiSelection && (mouse.modifiers & Qt.ShiftModifier)) {
var list = JSON.parse(JSON.stringify(filePickerPanel.currentSelection));
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We think it would be better to replace this with something like var list = filePickerPanel.currentSelection.slice() for performance reasons, less json, less computing and all that.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, I didn't know that was an option!

Comment thread Widgets/NFilePicker.qml Outdated
filePickerPanel.currentSelection = [model.filePath];
if (root.allowMultiSelection && (mouse.modifiers & Qt.ShiftModifier)) {
// Deep copy otherwise the isSelected might not get updated.
var list = JSON.parse(JSON.stringify(filePickerPanel.currentSelection));
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same thing here

@spiros132 spiros132 marked this pull request as draft March 22, 2026 07:14
@spiros132 spiros132 marked this pull request as ready for review March 22, 2026 08:04
@spiros132
Copy link
Copy Markdown
Contributor Author

@Ly-sec I've reworked it a bit to make it easier to read, reduce the repetitive code and added so that shift can select multiple files at the same time.

@Ly-sec
Copy link
Copy Markdown
Collaborator

Ly-sec commented Mar 22, 2026

Awesome @spiros132 this is much nicer now. Going to merge it, thank you very much!

@Ly-sec Ly-sec merged commit 8b1bb35 into noctalia-dev:main Mar 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants