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

Windows: Use the application icon for the sidebar #5955

Merged
merged 2 commits into from
Aug 15, 2017

Conversation

jturcotte
Copy link
Member

By setting the icon in Desktop.ini of the root folder, this adds the icon
both when browsing the folder directly and to the sidebar shortcut.

To avoid overwriting any user setting that could exist in Desktop.ini,
only do this if the file doesn't exist. Editing .ini files on Windows
isn't trivial and isn't worth it given that this file won't exist most
of the time.

Fixes #2446

@jturcotte jturcotte added this to the 2.4.0 milestone Aug 11, 2017
@jturcotte
Copy link
Member Author

One thing to think about: do we allow the default ignore list to be edited in order to allow syncing Desktop.ini files?
This would mean that every new device starting to sync a folder would probably propagate its new Desktop.ini to other machines (possibly with an icon path that won't work for them).

Copy link
Contributor

@ogoffart ogoffart left a comment

Choose a reason for hiding this comment

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

desktop.ini is in the default sync exclude list and cannot be removed. (altought maybe we want to hardcode the rule to be sure)

qCInfo(lcUtility) << "Creating" << desktopIni.fileName() << "to set a folder icon in Explorer.";
desktopIni.open(QFile::WriteOnly);
desktopIni.write("[.ShellClassInfo]\r\nIconResource=");
desktopIni.write(qApp->applicationFilePath().toUtf8().replace('/', '\\'));
Copy link
Contributor

Choose a reason for hiding this comment

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

should any other character be escaped?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's not escaped (besides the C++ literal), it converts slashes to backslashes.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah right.

Then maybe QDir::toNativeSeparators would be better

Copy link
Contributor

Choose a reason for hiding this comment

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

Are you sure UTF-8 is the right encoding for desktop.ini?

Copy link
Member Author

@jturcotte jturcotte Aug 14, 2017

Choose a reason for hiding this comment

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

Ah yes, forgot about toNativeSeparators again, I'll fix it.
I thought I saw a note on some documentation that this should be UTF-8, but I can't find it anymore. If there are non-latin1 characters in the path, it won't work if I use toLatin1 either, so I'd keep it that way.

Copy link
Member Author

Choose a reason for hiding this comment

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

done

By setting the icon in Desktop.ini of the root folder, this adds the icon
both when browsing the folder directly and to the sidebar shortcut.

To avoid overwriting any user setting that could exist in Desktop.ini,
only do this if the file doesn't exist. Editing .ini files on Windows
isn't trivial and isn't worth it given that this file won't exist most
of the time.

Fixes #2446
@jturcotte jturcotte force-pushed the windows-sidebar-icon branch from 793a7f6 to b5a1270 Compare August 14, 2017 09:45
@jturcotte
Copy link
Member Author

I also added b5a1270 to hardcode the desktop.ini exclusion, could you quickly review?

@guruz
Copy link
Contributor

guruz commented Aug 14, 2017

@jturcotte Could you harmonize Desktop.ini vs desktop.ini to whatever Windows normally does?
I know it doesn't really play a role on Windows, but still :/

(btw, does csync_fnmatch watch case?)

@jturcotte jturcotte force-pushed the windows-sidebar-icon branch from b5a1270 to 37a8f6d Compare August 14, 2017 12:01
This prevents it from being removed from the exclude list, which
would be an issue since the client itself creates this file in a way
that wouldn't match on machines with different installation paths.
@jturcotte jturcotte force-pushed the windows-sidebar-icon branch from 37a8f6d to 84240f2 Compare August 15, 2017 09:33
Copy link
Contributor

@guruz guruz left a comment

Choose a reason for hiding this comment

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

(btw you need to ping people if you push more, there is no notification)

@jturcotte
Copy link
Member Author

Thanks, I was waiting for the CI to pass, the previous build didn't pass.

@jturcotte jturcotte merged commit a480a31 into master Aug 15, 2017
@jturcotte jturcotte deleted the windows-sidebar-icon branch August 15, 2017 11:37
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.

3 participants