summaryrefslogtreecommitdiff
path: root/src/settings.cc
blob: 14b40ecd698f468267c00eb140023cfb95c6030f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40

#ifdef _WIN32
#include <windows.h>
#include <shlobj.h>
#endif

#include "settings.h"

Settings m_globalSettings;

const Settings & globalSettings()
{
	return m_globalSettings;
}
Settings::Settings() :
	m_homePath(),
	m_colorInvalidValue(255, 0, 0),
	m_colorInputError(195, 195, 195),
	m_colorSolved(192, 255, 192),
	m_colorHintUnique(255, 255, 127)
{
#ifdef _WIN32
	// get the full path for "Applicaton Data"
	TCHAR appdatapath[512];
	memset(appdatapath, 0, sizeof(appdatapath));
	SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, 0, appdatapath);
	
	// FIXME detect Unicode support
	// m_homePath = QString::fromAscii(appdatapath);
	m_homePath = QString::fromUtf16((const ushort *)appdatapath);
	m_homePath += "\\Sudoku Solver";
#else
	m_homePath = QDir::homePath() + "/.sudokusolver";
#endif
	QDir directory;
	if (!directory.exists(m_homePath)) {
		// create home directory
		directory.mkdir(m_homePath);
	}
}