All Classes Namespaces Functions Variables Enumerations Properties Pages
preferencemanager.h
1 /*
2 
3 Pencil2D - Traditional Animation Software
4 Copyright (C) 2005-2007 Patrick Corrieri & Pascal Naidon
5 Copyright (C) 2012-2020 Matthew Chiawen Chang
6 
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License
9 as published by the Free Software Foundation; version 2 of the License.
10 
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15 
16 */
17 
18 #ifndef PREFERENCEMANAGER_H
19 #define PREFERENCEMANAGER_H
20 
21 #include <bitset>
22 #include <QHash>
23 #include "basemanager.h"
24 #include "pencildef.h"
25 
26 
27 enum class SETTING
28 {
29  ANTIALIAS,
30  GRID,
31  SHADOW,
32  PREV_ONION,
33  NEXT_ONION,
34  INVISIBLE_LINES,
35  OUTLINES,
36  ONION_BLUE,
37  ONION_RED,
38  TOOL_CURSOR,
39  DOTTED_CURSOR,
40  HIGH_RESOLUTION,
41  WINDOW_OPACITY,
42  SHOW_STATUS_BAR,
43  CURVE_SMOOTHING,
44  BACKGROUND_STYLE,
45  AUTO_SAVE,
46  AUTO_SAVE_NUMBER,
47  SHORT_SCRUB,
48  FPS,
49  FIELD_W,
50  FIELD_H,
51  FRAME_SIZE,
52  TIMELINE_SIZE,
53  LABEL_FONT_SIZE,
54  DRAW_LABEL,
55  ONION_MAX_OPACITY,
56  ONION_MIN_OPACITY,
57  ONION_PREV_FRAMES_NUM,
58  ONION_NEXT_FRAMES_NUM,
59  ONION_WHILE_PLAYBACK,
60  ONION_TYPE,
61  FLIP_ROLL_MSEC,
62  FLIP_ROLL_DRAWINGS,
63  FLIP_INBETWEEN_MSEC,
64  SOUND_SCRUB_ACTIVE,
65  SOUND_SCRUB_MSEC,
66  LAYER_VISIBILITY,
67  LAYER_VISIBILITY_THRESHOLD,
68  GRID_SIZE_W,
69  GRID_SIZE_H,
70  OVERLAY_CENTER,
71  OVERLAY_THIRDS,
72  OVERLAY_GOLDEN,
73  OVERLAY_SAFE,
74  OVERLAY_PERSPECTIVE1,
75  OVERLAY_PERSPECTIVE2,
76  OVERLAY_PERSPECTIVE3,
77  OVERLAY_ANGLE,
78  OVERLAY_SAFE_HELPER_TEXT_ON,
79  ACTION_SAFE_ON,
80  ACTION_SAFE,
81  TIMECODE_TEXT,
82  TITLE_SAFE_ON,
83  TITLE_SAFE,
84  QUICK_SIZING,
85  MULTILAYER_ONION,
86  LANGUAGE,
87  LAYOUT_LOCK,
88  DRAW_ON_EMPTY_FRAME_ACTION,
89  FRAME_POOL_SIZE,
90  ROTATION_INCREMENT,
91  SHOW_SELECTION_INFO,
92  ASK_FOR_PRESET,
93  LOAD_MOST_RECENT,
94  LOAD_DEFAULT_PRESET,
95  DEFAULT_PRESET,
96  COUNT, // COUNT must always be the last one.
97 };
98 
99 // Actions for drawing on an empty frame.
100 enum DrawOnEmptyFrameAction
101 {
102  CREATE_NEW_KEY,
103  DUPLICATE_PREVIOUS_KEY,
104  KEEP_DRAWING_ON_PREVIOUS_KEY
105 };
106 
108 {
109  Q_OBJECT
110 
111 public:
112  explicit PreferenceManager(Editor* editor);
113  ~PreferenceManager() override;
114 
115  virtual bool init() override;
116  Status load(Object*) override;
117  Status save(Object*) override;
118 
119  void loadPrefs();
120  void set(SETTING option, QString value);
121  void set(SETTING option, int value);
122  void set(SETTING option, bool value);
123  void set(SETTING option, float value);
124 
125  void turnOn(SETTING option);
126  void turnOff(SETTING option);
127  bool isOn(SETTING option);
128 
129  QString getString(SETTING option);
130  int getInt(SETTING option);
131  float getFloat(SETTING option);
132 
133 signals:
134  void optionChanged(SETTING e);
135 
136 private:
137  QHash<int, QString> mStringSet;
138  QHash<int, int> mIntegerSet;
139  QHash<int, bool> mBooleanSet;
140  QHash<int, float> mFloatingPointSet;
141 };
142 
143 #endif // PREFERENCEMANAGER_H
Q_OBJECTQ_OBJECT
Definition: object.h:41
Definition: editor.h:55