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("penWidth", 2.0);
42 s.setValue("pencilWidth", 4.0);
43 s.setValue("polyLineWidth", 1.5);
44 s.setValue("eraserWidth", 10.0);
45 s.setValue("brushWidth", 15.0);
46 s.setValue("brushFeather", 15.0);
47 s.setValue("brushUseFeather", true);
48
49 s.setValue(SETTING_AUTO_SAVE_NUMBER, 15);
50 s.setValue(SETTING_TOOL_CURSOR, true);
51
52 s.sync();
53 qDebug("restored default tools");
54}
55
56void checkExistingShortcuts()
57{
58 QSettings defaultKey(":resources/kb.ini", QSettings::IniFormat);
59
60 QSettings curSetting( PENCIL2D, PENCIL2D );
61 foreach (QString pShortcutsKey, defaultKey.allKeys())
62 {
63 if ( ! curSetting.contains( pShortcutsKey ) )
64 {
65 curSetting.setValue(pShortcutsKey, defaultKey.value(pShortcutsKey));
66 }
67 }
68
69 curSetting.beginGroup(SHORTCUTS_GROUP);
70 defaultKey.beginGroup(SHORTCUTS_GROUP);
71 foreach (QString pKey, curSetting.allKeys())
72 {
73 if ( !defaultKey.contains(pKey) )
74 {
75 curSetting.remove(pKey);
76 }
77 }
78 defaultKey.endGroup();
79 curSetting.endGroup();
80 curSetting.sync();
81}
82
83void restoreShortcutsToDefault()
84{
85 QSettings defaultKey(":resources/kb.ini", QSettings::IniFormat);
86
87 QSettings curSetting( PENCIL2D, PENCIL2D );
88 curSetting.remove("shortcuts");
89
90 foreach (QString pShortcutsKey, defaultKey.allKeys())
91 {
92 curSetting.setValue(pShortcutsKey, defaultKey.value(pShortcutsKey));
93 }
94}
QSettings
QSettings::IniFormat
IniFormat
QString
Generated on Thu May 8 2025 04:47:53 for Pencil2D by doxygen 1.9.6 based on revision 4513250b1d5b1a3676ec0e67b06b7a885ceaae39