Pencil2D  ff90c0872e88be3bf81c548cd60f01983012ec49
Pencil2D is an animation software for both bitmap and vector graphics. It is free, multi-platform, and open source.
 All Classes Functions
pencilsettings.cpp
1 #include <QStringList>
2 #include <QDebug>
3 #include "pencilsettings.h"
4 
5 // ==== Singleton ====
6 
7 QSettings& pencilSettings()
8 {
9  static QSettings settings(PENCIL2D, PENCIL2D);
10 
11  if ( !settings.contains("InitPencilSetting") )
12  {
13  restoreToDefaultSetting();
14  settings.setValue("InitPencilSetting", true);
15  }
16  return settings;
17 }
18 
19 void restoreToDefaultSetting() // TODO: finish reset list
20 {
21  QSettings s(PENCIL2D, PENCIL2D);
22 
23  s.setValue("penWidth", 2.0);
24  s.setValue("pencilWidth", 4.0);
25  s.setValue("polyLineWidth", 1.5);
26  s.setValue("eraserWidth", 10.0);
27  s.setValue("brushWidth", 15.0);
28  s.setValue("brushFeather", 15.0);
29  s.setValue("brushUseFeather", true);
30 
31  s.setValue(SETTING_AUTO_SAVE_NUMBER, 15);
32  s.setValue(SETTING_TOOL_CURSOR, true);
33 
34  s.sync();
35  qDebug("restored default tools");
36 }
37 
38 void checkExistingShortcuts()
39 {
40  QSettings defaultKey(":resources/kb.ini", QSettings::IniFormat);
41 
42  QSettings curSetting( PENCIL2D, PENCIL2D );
43  foreach (QString pShortcutsKey, defaultKey.allKeys())
44  {
45  if ( ! curSetting.contains( pShortcutsKey ) )
46  {
47  curSetting.setValue(pShortcutsKey, defaultKey.value(pShortcutsKey));
48  }
49  }
50 
51  curSetting.beginGroup(SHORTCUTS_GROUP);
52  defaultKey.beginGroup(SHORTCUTS_GROUP);
53  foreach (QString pKey, curSetting.allKeys())
54  {
55  if ( !defaultKey.contains(pKey) )
56  {
57  curSetting.remove(pKey);
58  }
59  }
60  defaultKey.endGroup();
61  curSetting.endGroup();
62  curSetting.sync();
63 }
64 
65 void restoreShortcutsToDefault()
66 {
67  QSettings defaultKey(":resources/kb.ini", QSettings::IniFormat);
68 
69  QSettings curSetting( PENCIL2D, PENCIL2D );
70  curSetting.remove("shortcuts");
71 
72  foreach (QString pShortcutsKey, defaultKey.allKeys())
73  {
74  curSetting.setValue(pShortcutsKey, defaultKey.value(pShortcutsKey));
75  }
76 }