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  CURVE_SMOOTHING,
43  BACKGROUND_STYLE,
44  AUTO_SAVE,
45  AUTO_SAVE_NUMBER,
46  SHORT_SCRUB,
47  FPS,
48  FIELD_W,
49  FIELD_H,
50  FRAME_SIZE,
51  TIMELINE_SIZE,
52  LABEL_FONT_SIZE,
53  DRAW_LABEL,
54  ONION_MAX_OPACITY,
55  ONION_MIN_OPACITY,
56  ONION_PREV_FRAMES_NUM,
57  ONION_NEXT_FRAMES_NUM,
58  ONION_WHILE_PLAYBACK,
59  ONION_TYPE,
60  FLIP_ROLL_MSEC,
61  FLIP_ROLL_DRAWINGS,
62  FLIP_INBETWEEN_MSEC,
63  SOUND_SCRUB_ACTIVE,
64  SOUND_SCRUB_MSEC,
65  LAYER_VISIBILITY,
66  LAYER_VISIBILITY_THRESHOLD,
67  GRID_SIZE_W,
68  GRID_SIZE_H,
69  OVERLAY_CENTER,
70  OVERLAY_THIRDS,
71  OVERLAY_GOLDEN,
72  OVERLAY_SAFE,
73  OVERLAY_SAFE_HELPER_TEXT_ON,
74  ACTION_SAFE_ON,
75  ACTION_SAFE,
76  TIMECODE_TEXT,
77  TITLE_SAFE_ON,
78  TITLE_SAFE,
79  QUICK_SIZING,
80  MULTILAYER_ONION,
81  LANGUAGE,
82  LAYOUT_LOCK,
83  DRAW_ON_EMPTY_FRAME_ACTION,
84  FRAME_POOL_SIZE,
85  ROTATION_INCREMENT,
86  ASK_FOR_PRESET,
87  LOAD_MOST_RECENT,
88  LOAD_DEFAULT_PRESET,
89  DEFAULT_PRESET,
90  COUNT, // COUNT must always be the last one.
91 };
92 
93 // Actions for drawing on an empty frame.
94 enum DrawOnEmptyFrameAction
95 {
96  CREATE_NEW_KEY,
97  DUPLICATE_PREVIOUS_KEY,
98  KEEP_DRAWING_ON_PREVIOUS_KEY
99 };
100 
102 {
103  Q_OBJECT
104 
105 public:
106  explicit PreferenceManager(Editor* editor);
107  ~PreferenceManager() override;
108 
109  virtual bool init() override;
110  Status load(Object*) override;
111  Status save(Object*) override;
112 
113  void loadPrefs();
114  void set(SETTING option, QString value);
115  void set(SETTING option, int value);
116  void set(SETTING option, bool value);
117  void set(SETTING option, float value);
118 
119  void turnOn(SETTING option);
120  void turnOff(SETTING option);
121  bool isOn(SETTING option);
122 
123  QString getString(SETTING option);
124  int getInt(SETTING option);
125  float getFloat(SETTING option);
126 
127 signals:
128  void optionChanged(SETTING e);
129 
130 private:
131  QHash<int, QString> mStringSet;
132  QHash<int, int> mIntegerSet;
133  QHash<int, bool> mBooleanSet;
134  QHash<int, float> mFloatingPointSet;
135 };
136 
137 #endif // PREFERENCEMANAGER_H
Q_OBJECTQ_OBJECT
Definition: object.h:54
Definition: editor.h:51