Skip to content

Commit

Permalink
Add on-launch code to set Document Icon in windows registry
Browse files Browse the repository at this point in the history
Since OpenSCAD doesn't distribute with additional image files, this means a new icon needs to be built into the .exe. This is accomplished by adding a line to the end of openscad_win32.rc file consisting of something like the following:
IDI_ICON2 ICON DISCARDABLE "icons/openscad_doc.ico"
which will get built into the exe as icon index 1 (icon index 0 is the current app icon.)

In the cmdline and gui functions in openscad.cc I added code to set the HKEY_CURRENT_USER/Software/Classes/OpenSCAD_File/DefaultIcon/Default value to the icon index 1 of openscad.exe

	modified:   openscad_win32.rc
	modified:   src/openscad.cc
  • Loading branch information
TDeagan committed Jan 12, 2015
1 parent 9f6b7b1 commit ce5b38d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions openscad_win32.rc
Expand Up @@ -33,5 +33,6 @@ VS_VERSION_INFO VERSIONINFO
/* End of Version info */

IDI_ICON1 ICON DISCARDABLE "icons/openscad.ico"
IDI_ICON2 ICON DISCARDABLE "icons/openscad_doc.ico"


15 changes: 14 additions & 1 deletion src/openscad.cc
Expand Up @@ -43,6 +43,8 @@
#include "CocoaUtils.h"
#include "FontCache.h"

#include <QDir>

#include <string>
#include <vector>
#include <fstream>
Expand Down Expand Up @@ -318,6 +320,12 @@ int cmdline(const char *deps_output_file, const std::string &filename, Camera &c
parser_init();
localization_init();

#ifdef Q_OS_WIN
QSettings reg_setting(QLatin1String("HKEY_CURRENT_USER"), QSettings::NativeFormat);
QString appPath = QDir::toNativeSeparators(app.applicationFilePath() + QLatin1String(",1"));
reg_setting.setValue(QLatin1String("Software/Classes/OpenSCAD_File/DefaultIcon/Default"),QVariant(appPath));
#endif

Tree tree;
#ifdef ENABLE_CGAL
GeometryEvaluator geomevaluator(tree);
Expand Down Expand Up @@ -664,6 +672,12 @@ int gui(vector<string> &inputFiles, const fs::path &original_path, int argc, cha
installAppleEventHandlers();
#endif

#ifdef Q_OS_WIN
QSettings reg_setting(QLatin1String("HKEY_CURRENT_USER"), QSettings::NativeFormat);
QString appPath = QDir::toNativeSeparators(app.applicationFilePath() + QLatin1String(",1"));
reg_setting.setValue(QLatin1String("Software/Classes/OpenSCAD_File/DefaultIcon/Default"),QVariant(appPath));
#endif

#ifdef OPENSCAD_UPDATER
AutoUpdater *updater = new SparkleAutoUpdater;
AutoUpdater::setUpdater(updater);
Expand Down Expand Up @@ -901,4 +915,3 @@ int main(int argc, char **argv)

return rc;
}

0 comments on commit ce5b38d

Please sign in to comment.