Pencil2D Animation
Download Community News Docs Contribute
  • Overview
  • Articles
  • Code
  •  
  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
  • File List
Loading...
Searching...
No Matches
  • core_lib
  • src
  • util
pencilsettings.cpp
1/*
2
3Pencil2D - Traditional Animation Software
4Copyright (C) 2005-2007 Patrick Corrieri & Pascal Naidon
5Copyright (C) 2012-2020 Matthew Chiawen Chang
6
7This program is free software; you can redistribute it and/or
8modify it under the terms of the GNU General Public License
9as published by the Free Software Foundation; version 2 of the License.
10
11This program is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16*/
17#include "pencilsettings.h"
18
19#include <QStringList>
20#include <QDebug>
21
22
23// ==== Singleton ====
24
25QSettings& pencilSettings()
26{
27 static QSettings settings(PENCIL2D, PENCIL2D);
28
29 if ( !settings.contains("InitPencilSetting") )
30 {
31 restoreToDefaultSetting();
32 settings.setValue("InitPencilSetting", true);
33 }
34 return settings;
35}
36
37void restoreToDefaultSetting() // TODO: finish reset list
38{
39 QSettings s(PENCIL2D, PENCIL2D);
40
41 s.setValue(SETTING_AUTO_SAVE_NUMBER, 15);
42 s.setValue(SETTING_TOOL_CURSOR, true);
43
44 s.sync();
45 qDebug("restored default tools");
46}
47
48void checkExistingShortcuts()
49{
50 QSettings defaultKey(":resources/kb.ini", QSettings::IniFormat);
51
52 QSettings curSetting( PENCIL2D, PENCIL2D );
53 foreach (QString pShortcutsKey, defaultKey.allKeys())
54 {
55 if ( ! curSetting.contains( pShortcutsKey ) )
56 {
57 curSetting.setValue(pShortcutsKey, defaultKey.value(pShortcutsKey));
58 }
59 }
60
61 curSetting.beginGroup(SHORTCUTS_GROUP);
62 defaultKey.beginGroup(SHORTCUTS_GROUP);
63 foreach (QString pKey, curSetting.allKeys())
64 {
65 if ( !defaultKey.contains(pKey) )
66 {
67 curSetting.remove(pKey);
68 }
69 }
70 defaultKey.endGroup();
71 curSetting.endGroup();
72 curSetting.sync();
73}
74
75void restoreShortcutsToDefault()
76{
77 QSettings defaultKey(":resources/kb.ini", QSettings::IniFormat);
78
79 QSettings curSetting( PENCIL2D, PENCIL2D );
80 curSetting.remove("shortcuts");
81
82 foreach (QString pShortcutsKey, defaultKey.allKeys())
83 {
84 curSetting.setValue(pShortcutsKey, defaultKey.value(pShortcutsKey));
85 }
86}
QSettings
QSettings::IniFormat
IniFormat
QString
Generated on Wed Dec 24 2025 23:46:02 for Pencil2D by doxygen 1.9.6 based on revision 1be63043db1f7fc0545528fc3b6d5098a552755b