Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for 'Import Image(s)...' menu items in Linux and Windows #1416

Merged
merged 1 commit into from
Oct 24, 2018
Merged

Fix for 'Import Image(s)...' menu items in Linux and Windows #1416

merged 1 commit into from
Oct 24, 2018

Conversation

jkmdev
Copy link
Contributor

@jkmdev jkmdev commented Oct 24, 2018

Fix for bug #1312

Removes the openDirectory property in the dialog.showOpenDialog options object for importImagesDialogue. This will prevent a user's directory or images from being inaccessible when they select the Import Images to New Boards... or Import Image and Replace... options from the File menu on Linux or Windows.

I took this approach because:

  1. The openFile and openDirectory properties seem incompatible; openDirectory will override openFile in Linux and Windows, making it so that users can't select individual files, only directories. In Windows the files are hidden entirely.
  2. When in Linux, the image extension filters in the dialog.showOpenDialog options object aren't compatible with openDirectory. Electron itself is checking for these extensions against directories instead of files, making them inaccessible to the user. For example with the jpg filter applied, Documents.jpg will be accessible to a Linux user, but not Documents.
  3. Since the filters don't seem to apply to directory contents, this creates a bug since their contents won't be properly filtered. If the folder contains an incompatible file format (e.g. gif), the import will crash.

The downside to this fix is that users will lose the ability to import images by choosing a directory. So I thought - if the idea is viable - that it might be worth it to add a new Import Folder Contents to New Boards... menu option that will handle folder imports. That way there won't be any conflicts between the openFile and openDirectory properties, and new logic could be added to the dialog.showOpenDialog callback that will check if directory contents are an image or not.

@jkmdev jkmdev changed the title Fix 'Import Image(s)...' menu items for Linux and Windows Fix for 'Import Image(s)...' menu items for Linux and Windows Oct 24, 2018
@jkmdev jkmdev changed the title Fix for 'Import Image(s)...' menu items for Linux and Windows Fix for 'Import Image(s)...' menu items in Linux and Windows Oct 24, 2018
@audionerd
Copy link
Member

audionerd commented Oct 24, 2018

So with this fix applied, directories in the dialog listing are shown but appear disabled, and can't be selected?

@audionerd
Copy link
Member

This seems like a good fix to me.

Artists would still be able to drag a folder onto the window to import multiple images as a workaround.

I wonder if we should apply this fix conditionally -- only for Windows/Linux. Artists on macOS would still be able to select folders then.

@jkmdev
Copy link
Contributor Author

jkmdev commented Oct 24, 2018

The directories won't be disabled. However if the user selects the directory and clicks 'Open', instead of importing the directory into the project the folder will be opened within the dialog window. From there they'd have to select individual files from inside that folder before they actually import anything.

The idea of a conditional fix seems viable since the select-by-directory feature is still there for Linux/Windows users through drag and drop. If you want I could add that sort of change to my current pull request or a new one, however I'd need to create a macOS VM to test it fully on my end. Currently I'm only working with Linux and Windows.

@audionerd
Copy link
Member

Ok, so they would see inside the folder but could still select multiple files from it from the dialog right?
That sounds fine.
I'll add the conditional.

Thanks for putting this together!

@audionerd audionerd merged commit fc24ffb into wonderunit:master Oct 24, 2018
audionerd added a commit that referenced this pull request Oct 24, 2018
@audionerd
Copy link
Member

@jkmdev Can you try the latest master and let me know if the bug is fixed on your machine?

@jkmdev
Copy link
Contributor Author

jkmdev commented Oct 24, 2018

@audionerd Looks like it works fine in master. Didn't see any errors.

As an aside I tried dragging the file folder into storyboarder's sketch plane on Linux and Windows and it didn't import anything; I can only import by selecting files within the folder, then dragging and dropping those. I tested this on a commit earlier than the one including this merge and the issue was still there.

If this is an issue you'd want to have fixed I can take a look at it.

@audionerd
Copy link
Member

Oh right – can't drag a folder, but can drag multiple images from a folder. I think that's fine for now.

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