Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Update Windows document icon #1082
On Windows, the document icon is the same as the application icon. This is confusing.
The mechanism for this appears to be documented at:
It's a registry key entry: Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Classes\OpenSCAD_File\DefaultIcon
Given that the distribution doesn't include any ico files, the registry method is appealing. However, I don't see the SCAD.png file in the openscad.qrc resource file.
I'll set up a branch, add the SCAD.png to resources and see if I can force the doc icon to it.
First pass suggests a QSettings approach:
Or somesuch depending on the resource ID. I'll also have to come up to speed on how/when in the install the .exe location is determined and where the OS dependent code is managed.
I see decent Qt example code around the web dealing with windows registries. (http://phonon-vlc-mplayer.googlecode.com/svn/trunk/quarkplayer/WinDefaultApplication.cpp)
I've built OpenSCAD on windows many dozens of times by now, but I've haven't built the installer (which I'm imagining could be an appealing place for this.) So that's also on my list.
I'm new to nullsoft, but it kinda looks like this might end up being a one-liner in /scripts/installer.nsi
Of course, if everyone is getting excited about a preferences pile-on, the doc icon could be editable there as well ;-)
This is a super fun project. I'm new to Qt, C++, MSYS2, OpenGL, NSIS and Git so there's lots of interesting things to learn. (I have worked in wxWidgets/Tkinter, C/C#, Cygwin, DirectX, Windows Installer and SVN, so it's mostly a through the looking glass translation thing :-)
Excellent point. That suggests some check on startup to guarantee the icon or something in preferences to allow it to change if the user wants something different.
To go after the first (which I think is the desired behavior,) I'll look at how/where things like file associations are set up to see what that pattern is like.
Whew, after a long slog through std::string and QVariant conversion then a lengthy hike through the intricacies of HKEY_CLASSES_ROOT vs. HKEY_CURRENT_USER, I've got working code.
In the cmdline and gui functions in openscad.cc I added:
I tried moving this into PlatformUtils_win.cc and as a separate function in openscad.cc, but I kept running into problems with complaints about private nature of the app object and the way it's a QApplication object in gui and a QCoreApplication object in cmdline and such. Ultimately, there was a lot less surgery all around to just dupe the block above in gui and cmdline. I'm happy to keep working on that if it provides value in some way.
So, if that works for everyone, I'm ready to do a pull request. But I'm happy to keep working on this if changes are desired. I've gone back and forth about only writing the registry key if it's not already populated with the desired value. It's a tiny bit more elegant, but there are some arguments for the bulletproof nature of just setting it every launch.
Currently, the only two files with changes are: