Mercurial > hg > octave-nkf
comparison gui/src/ResourceManager.cpp @ 13668:421afeae929b
Added a settings wizard that appears at first startup of Octave GUI.
author | Jacob Dawid <jacob.dawid@googlemail.com> |
---|---|
date | Sat, 10 Sep 2011 18:33:58 +0200 |
parents | ddc3c20d0e2f |
children | c0e66d6e3dc8 |
comparison
equal
deleted
inserted
replaced
13667:9b74f97919e1 | 13668:421afeae929b |
---|---|
23 ResourceManager ResourceManager::m_singleton; | 23 ResourceManager ResourceManager::m_singleton; |
24 | 24 |
25 ResourceManager::ResourceManager () | 25 ResourceManager::ResourceManager () |
26 { | 26 { |
27 m_settings = 0; | 27 m_settings = 0; |
28 QDesktopServices desktopServices; | 28 reloadSettings (); |
29 m_homePath = desktopServices.storageLocation (QDesktopServices::HomeLocation); | |
30 setSettings(m_homePath + "/.octave-gui"); | |
31 } | 29 } |
32 | 30 |
33 ResourceManager::~ResourceManager () | 31 ResourceManager::~ResourceManager () |
34 { | 32 { |
35 delete m_settings; | 33 delete m_settings; |
46 { | 44 { |
47 return m_homePath; | 45 return m_homePath; |
48 } | 46 } |
49 | 47 |
50 void | 48 void |
49 ResourceManager::reloadSettings () | |
50 { | |
51 QDesktopServices desktopServices; | |
52 m_homePath = desktopServices.storageLocation (QDesktopServices::HomeLocation); | |
53 setSettings(m_homePath + "/.octave-gui"); | |
54 } | |
55 | |
56 void | |
51 ResourceManager::setSettings (QString file) | 57 ResourceManager::setSettings (QString file) |
52 { | 58 { |
53 delete m_settings; | 59 delete m_settings; |
60 | |
61 m_firstRun = false; | |
54 if (!QFile::exists (file)) | 62 if (!QFile::exists (file)) |
55 { | 63 m_firstRun = true; |
56 QFile::copy("../default-settings/.octave-gui", file); | 64 |
57 } | 65 // If the settings file does not exist, QSettings automatically creates it. |
66 // Therefore we have to check if it exists before instantiating the settings object. | |
67 // That way we can detect if the user ran this application before. | |
58 m_settings = new QSettings (file, QSettings::IniFormat); | 68 m_settings = new QSettings (file, QSettings::IniFormat); |
59 } | 69 } |
60 | 70 |
61 QString | 71 QString |
62 ResourceManager::findTranslatorFile (QString language) | 72 ResourceManager::findTranslatorFile (QString language) |
71 if (m_icons.contains (icon)) | 81 if (m_icons.contains (icon)) |
72 { | 82 { |
73 return m_icons [icon]; | 83 return m_icons [icon]; |
74 } | 84 } |
75 return QIcon (); | 85 return QIcon (); |
86 } | |
87 | |
88 bool | |
89 ResourceManager::isFirstRun () | |
90 { | |
91 return m_firstRun; | |
76 } | 92 } |
77 | 93 |
78 void | 94 void |
79 ResourceManager::updateNetworkSettings () | 95 ResourceManager::updateNetworkSettings () |
80 { | 96 { |