18#include "preferencemanager.h"
23PreferenceManager::PreferenceManager(
Editor* editor) :
BaseManager(editor, __FUNCTION__)
27PreferenceManager::~PreferenceManager()
31bool PreferenceManager::init()
47void PreferenceManager::loadPrefs()
52 set(SETTING::GRID, settings.value(SETTING_SHOW_GRID,
false).toBool());
53 set(SETTING::INVISIBLE_LINES, settings.value(SETTING_INVISIBLE_LINES,
false).toBool());
54 set(SETTING::OUTLINES, settings.value(SETTING_OUTLINES,
false).toBool());
55 set(SETTING::OVERLAY_CENTER, settings.value(SETTING_OVERLAY_CENTER,
false).toBool());
56 set(SETTING::OVERLAY_THIRDS, settings.value(SETTING_OVERLAY_THIRDS,
false).toBool());
57 set(SETTING::OVERLAY_GOLDEN, settings.value(SETTING_OVERLAY_GOLDEN,
false).toBool());
58 set(SETTING::OVERLAY_SAFE, settings.value(SETTING_OVERLAY_SAFE,
false).toBool());
59 set(SETTING::OVERLAY_PERSPECTIVE1, settings.value(SETTING_OVERLAY_PERSPECTIVE1,
false).toBool());
60 set(SETTING::OVERLAY_PERSPECTIVE2, settings.value(SETTING_OVERLAY_PERSPECTIVE2,
false).toBool());
61 set(SETTING::OVERLAY_PERSPECTIVE3, settings.value(SETTING_OVERLAY_PERSPECTIVE3,
false).toBool());
62 set(SETTING::OVERLAY_ANGLE, settings.value(SETTING_OVERLAY_ANGLE, 15).toInt());
63 set(SETTING::ACTION_SAFE, settings.value(SETTING_ACTION_SAFE, 5).toInt());
64 set(SETTING::ACTION_SAFE_ON, settings.value(SETTING_ACTION_SAFE_ON,
true).toBool());
65 set(SETTING::OVERLAY_SAFE_HELPER_TEXT_ON, settings.value(SETTING_OVERLAY_SAFE_HELPER_TEXT_ON,
true).toBool());
66 set(SETTING::TITLE_SAFE, settings.value(SETTING_TITLE_SAFE, 10).toInt());
67 set(SETTING::TITLE_SAFE_ON, settings.value(SETTING_TITLE_SAFE_ON,
true).toBool());
70 set(SETTING::GRID_SIZE_W, settings.value(SETTING_GRID_SIZE_W, 100).toInt());
71 set(SETTING::GRID_SIZE_H, settings.value(SETTING_GRID_SIZE_H, 100).toInt());
74 set(SETTING::ANTIALIAS, settings.value(SETTING_ANTIALIAS,
true).toBool());
75 set(SETTING::TOOL_CURSOR, settings.value(SETTING_TOOL_CURSOR,
true).toBool());
76 set(SETTING::CANVAS_CURSOR, settings.value(SETTING_CANVAS_CURSOR,
true).toBool());
77 set(SETTING::HIGH_RESOLUTION, settings.value(SETTING_HIGH_RESOLUTION,
true).toBool());
78 set(SETTING::SHADOW, settings.value(SETTING_SHADOW,
false).toBool());
79 set(SETTING::QUICK_SIZING, settings.value(SETTING_QUICK_SIZING,
true).toBool());
80 set(SETTING::SHOW_SELECTION_INFO, settings.value(SETTING_SHOW_SELECTION_INFO,
false).toBool());
82 set(SETTING::INVERT_DRAG_ZOOM_DIRECTION, settings.value(SETTING_INVERT_DRAG_ZOOM_DIRECTION,
false).toBool());
83 set(SETTING::INVERT_SCROLL_ZOOM_DIRECTION, settings.value(SETTING_INVERT_SCROLL_ZOOM_DIRECTION,
false).toBool());
85 set(SETTING::ROTATION_INCREMENT, settings.value(SETTING_ROTATION_INCREMENT, 15).toInt());
87 set(SETTING::WINDOW_OPACITY, settings.value(SETTING_WINDOW_OPACITY, 0).toInt());
88 set(SETTING::SHOW_STATUS_BAR, settings.value(SETTING_SHOW_STATUS_BAR,
true).toBool());
89 set(SETTING::CURVE_SMOOTHING, settings.value(SETTING_CURVE_SMOOTHING, 20).toInt());
91 set(SETTING::BACKGROUND_STYLE, settings.value(SETTING_BACKGROUND_STYLE,
"white").toString());
93 set(SETTING::LAYOUT_LOCK, settings.value(SETTING_LAYOUT_LOCK,
false).toBool());
94 set(SETTING::FRAME_POOL_SIZE, settings.value(SETTING_FRAME_POOL_SIZE, 1024).toInt());
95 set(SETTING::NEW_UNDO_REDO_SYSTEM_ON, settings.value(SETTING_NEW_UNDO_REDO_ON,
false).toBool());
96 set(SETTING::UNDO_REDO_MAX_STEPS, settings.value(SETTING_UNDO_REDO_MAX_STEPS, 100).toInt());
98 set(SETTING::FPS, settings.value(SETTING_FPS, 12).toInt());
99 set(SETTING::FIELD_W, settings.value(SETTING_FIELD_W, 800).toInt());
100 set(SETTING::FIELD_H, settings.value(SETTING_FIELD_H, 600).toInt());
101 set(SETTING::TIMECODE_TEXT, settings.value(SETTING_TIMECODE_TEXT, 1).toInt());
104 set(SETTING::AUTO_SAVE, settings.value(SETTING_AUTO_SAVE,
false).toBool());
105 set(SETTING::AUTO_SAVE_NUMBER, settings.value(SETTING_AUTO_SAVE_NUMBER, 256).toInt());
106 set(SETTING::ASK_FOR_PRESET, settings.value(SETTING_ASK_FOR_PRESET,
false).toBool());
107 set(SETTING::LOAD_MOST_RECENT, settings.value(SETTING_LOAD_MOST_RECENT,
false).toBool());
108 set(SETTING::LOAD_DEFAULT_PRESET, settings.value(SETTING_LOAD_DEFAULT_PRESET,
true).toBool());
109 set(SETTING::DEFAULT_PRESET, settings.value(SETTING_DEFAULT_PRESET, 0).toInt());
112 set(SETTING::SHORT_SCRUB, settings.value(SETTING_SHORT_SCRUB,
false ).toBool());
113 set(SETTING::FRAME_SIZE, settings.value(SETTING_FRAME_SIZE, 12).toInt());
114 set(SETTING::TIMELINE_SIZE, settings.value(SETTING_TIMELINE_SIZE, 240).toInt());
115 set(SETTING::DRAW_LABEL, settings.value(SETTING_DRAW_LABEL,
false ).toBool());
116 set(SETTING::LABEL_FONT_SIZE, settings.value(SETTING_LABEL_FONT_SIZE, 12).toInt());
118 set( SETTING::DRAW_ON_EMPTY_FRAME_ACTION, settings.value( SETTING_DRAW_ON_EMPTY_FRAME_ACTION,
119 KEEP_DRAWING_ON_PREVIOUS_KEY).toInt() );
122 set(SETTING::PREV_ONION, settings.value(SETTING_PREV_ONION,
false).toBool());
123 set(SETTING::NEXT_ONION, settings.value(SETTING_NEXT_ONION,
false).toBool());
124 set(SETTING::MULTILAYER_ONION, settings.value(SETTING_MULTILAYER_ONION,
false).toBool());
125 set(SETTING::ONION_BLUE, settings.value(SETTING_ONION_BLUE,
false).toBool());
126 set(SETTING::ONION_RED, settings.value(SETTING_ONION_RED,
false).toBool());
128 set(SETTING::ONION_MAX_OPACITY, settings.value(SETTING_ONION_MAX_OPACITY, 50).toInt());
129 set(SETTING::ONION_MIN_OPACITY, settings.value(SETTING_ONION_MIN_OPACITY, 20).toInt());
130 set(SETTING::ONION_PREV_FRAMES_NUM, settings.value(SETTING_ONION_PREV_FRAMES_NUM, 5).toInt());
131 set(SETTING::ONION_NEXT_FRAMES_NUM, settings.value(SETTING_ONION_NEXT_FRAMES_NUM, 5).toInt());
132 set(SETTING::ONION_WHILE_PLAYBACK, settings.value(SETTING_ONION_WHILE_PLAYBACK, 0).toInt());
133 set(SETTING::ONION_TYPE, settings.value(SETTING_ONION_TYPE,
"relative").toString());
134 set(SETTING::LAYER_VISIBILITY, settings.value(SETTING_LAYER_VISIBILITY, 2).toInt());
135 set(SETTING::LAYER_VISIBILITY_THRESHOLD, settings.value(SETTING_LAYER_VISIBILITY_THRESHOLD, 0.5f).toFloat());
137 set(SETTING::FLIP_ROLL_MSEC, settings.value(SETTING_FLIP_ROLL_MSEC, 100).toInt());
138 set(SETTING::FLIP_ROLL_DRAWINGS, settings.value(SETTING_FLIP_ROLL_DRAWINGS, 5).toInt());
139 set(SETTING::FLIP_INBETWEEN_MSEC, settings.value(SETTING_FLIP_INBETWEEN_MSEC, 100).toInt());
140 set(SETTING::SOUND_SCRUB_ACTIVE, settings.value(SETTING_SOUND_SCRUB_ACTIVE,
false).toBool());
141 set(SETTING::SOUND_SCRUB_MSEC, settings.value(SETTING_SOUND_SCRUB_MSEC, 100).toInt());
143 set(SETTING::LANGUAGE, settings.value(SETTING_LANGUAGE).toString());
146void PreferenceManager::turnOn(SETTING option)
151void PreferenceManager::turnOff(SETTING option)
156bool PreferenceManager::isOn(SETTING option)
158 int optionId =
static_cast<int>(option);
159 return mBooleanSet.
value(optionId,
false);
162int PreferenceManager::getInt(SETTING option)
164 int optionId =
static_cast<int>(option);
165 return mIntegerSet.
value(optionId, -1);
168float PreferenceManager::getFloat(SETTING option)
170 int optionId =
static_cast<int>(option);
171 return mFloatingPointSet.
value(optionId, -1);
174QString PreferenceManager::getString(SETTING option)
176 int optionId =
static_cast<int>(option);
181 else if (mBooleanSet.
contains(optionId))
183 if (mBooleanSet.
value(optionId,
false))
192 return mStringSet.
value(optionId);
195void PreferenceManager::set(SETTING option,
QString value)
200 case SETTING::BACKGROUND_STYLE:
201 settings.setValue(SETTING_BACKGROUND_STYLE, value);
203 case SETTING::ONION_TYPE:
204 settings.setValue(SETTING_ONION_TYPE, value);
206 case SETTING::LANGUAGE:
207 settings.setValue(SETTING_LANGUAGE, value);
213 int optionId =
static_cast<int>(option);
214 if (mStringSet[optionId] != value)
216 mStringSet[optionId] = value;
217 emit optionChanged(option);
221void PreferenceManager::set(SETTING option,
float value)
226 case SETTING::LAYER_VISIBILITY_THRESHOLD:
227 settings.setValue(SETTING_LAYER_VISIBILITY_THRESHOLD, value);
235 int optionId =
static_cast<int>(option);
237 if (qFuzzyCompare(mFloatingPointSet[optionId], value) ==
false)
239 mFloatingPointSet[optionId] = value;
240 emit optionChanged(option);
244void PreferenceManager::set(SETTING option,
int value)
249 case SETTING::WINDOW_OPACITY:
250 settings.setValue(SETTING_WINDOW_OPACITY, value);
252 case SETTING::CURVE_SMOOTHING:
253 settings.setValue(SETTING_CURVE_SMOOTHING, value);
255 case SETTING::AUTO_SAVE_NUMBER:
256 settings.setValue(SETTING_AUTO_SAVE_NUMBER, value);
258 case SETTING::FRAME_SIZE:
259 if (value < 4) { value = 4; }
260 else if (value > 40) { value = 40; }
261 settings.setValue(SETTING_FRAME_SIZE, value);
263 case SETTING::TIMELINE_SIZE:
264 if (value < 2) { value = 2; }
265 settings.setValue(SETTING_TIMELINE_SIZE, value);
267 case SETTING::LABEL_FONT_SIZE:
268 if (value < 12) { value = 12; }
269 settings.setValue(SETTING_LABEL_FONT_SIZE, value);
271 case SETTING::ONION_MAX_OPACITY:
272 settings.setValue(SETTING_ONION_MAX_OPACITY, value);
274 case SETTING::ONION_MIN_OPACITY:
275 settings.setValue(SETTING_ONION_MIN_OPACITY, value);
277 case SETTING::ONION_PREV_FRAMES_NUM:
278 settings.setValue(SETTING_ONION_PREV_FRAMES_NUM, value);
280 case SETTING::ONION_NEXT_FRAMES_NUM:
281 settings.setValue(SETTING_ONION_NEXT_FRAMES_NUM, value);
283 case SETTING::OVERLAY_ANGLE:
284 settings.setValue(SETTING_OVERLAY_ANGLE, value);
286 case SETTING::FLIP_ROLL_MSEC :
287 settings.setValue(SETTING_FLIP_ROLL_MSEC, value);
289 case SETTING::FLIP_ROLL_DRAWINGS :
290 settings.setValue(SETTING_FLIP_ROLL_DRAWINGS, value);
292 case SETTING::FLIP_INBETWEEN_MSEC :
293 settings.setValue(SETTING_FLIP_INBETWEEN_MSEC, value);
295 case SETTING::SOUND_SCRUB_MSEC :
296 settings.setValue(SETTING_SOUND_SCRUB_MSEC, value);
298 case SETTING::GRID_SIZE_W:
299 settings.setValue(SETTING_GRID_SIZE_W, value);
301 case SETTING::TIMECODE_TEXT:
302 settings.setValue(SETTING_TIMECODE_TEXT, value);
304 case SETTING::GRID_SIZE_H:
305 settings.setValue(SETTING_GRID_SIZE_H, value);
307 case SETTING::ACTION_SAFE:
308 settings.setValue(SETTING_ACTION_SAFE, value);
310 case SETTING::TITLE_SAFE:
311 settings.setValue(SETTING_TITLE_SAFE, value);
313 case SETTING::FRAME_POOL_SIZE:
314 settings.setValue(SETTING_FRAME_POOL_SIZE, value);
316 case SETTING::UNDO_REDO_MAX_STEPS:
317 settings.setValue(SETTING_UNDO_REDO_MAX_STEPS, value);
319 case SETTING::DRAW_ON_EMPTY_FRAME_ACTION:
320 settings.setValue( SETTING_DRAW_ON_EMPTY_FRAME_ACTION, value);
322 case SETTING::ONION_WHILE_PLAYBACK:
323 settings.setValue(SETTING_ONION_WHILE_PLAYBACK, value);
325 case SETTING::ROTATION_INCREMENT:
326 settings.setValue(SETTING_ROTATION_INCREMENT, value);
329 settings.setValue(SETTING_FPS, value);
331 case SETTING::FIELD_W:
332 settings.setValue(SETTING_FIELD_W, value);
334 case SETTING::FIELD_H:
335 settings.setValue(SETTING_FIELD_H, value);
337 case SETTING::LAYER_VISIBILITY:
338 settings.setValue(SETTING_LAYER_VISIBILITY, value);
340 case SETTING::DEFAULT_PRESET:
341 settings.setValue(SETTING_DEFAULT_PRESET, value);
348 int optionId =
static_cast<int>(option);
349 if (mIntegerSet[optionId] != value)
351 mIntegerSet[optionId] = value;
352 emit optionChanged(option);
358void PreferenceManager::set(SETTING option,
bool value)
363 case SETTING::SHOW_STATUS_BAR:
364 settings.setValue(SETTING_SHOW_STATUS_BAR, value);
366 case SETTING::ANTIALIAS:
367 settings.setValue(SETTING_ANTIALIAS, value);
370 settings.setValue(SETTING_SHOW_GRID, value);
372 case SETTING::OVERLAY_CENTER:
373 settings.setValue(SETTING_OVERLAY_CENTER, value);
375 case SETTING::OVERLAY_THIRDS:
376 settings.setValue(SETTING_OVERLAY_THIRDS, value);
378 case SETTING::OVERLAY_GOLDEN:
379 settings.setValue(SETTING_OVERLAY_GOLDEN, value);
381 case SETTING::OVERLAY_SAFE:
382 settings.setValue(SETTING_OVERLAY_SAFE, value);
384 case SETTING::OVERLAY_PERSPECTIVE1:
385 settings.setValue(SETTING_OVERLAY_PERSPECTIVE1, value);
387 case SETTING::OVERLAY_PERSPECTIVE2:
388 settings.setValue(SETTING_OVERLAY_PERSPECTIVE2, value);
390 case SETTING::OVERLAY_PERSPECTIVE3:
391 settings.setValue(SETTING_OVERLAY_PERSPECTIVE3, value);
393 case SETTING::ACTION_SAFE_ON:
394 settings.setValue(SETTING_ACTION_SAFE_ON, value);
396 case SETTING::TITLE_SAFE_ON:
397 settings.setValue(SETTING_TITLE_SAFE_ON, value);
399 case SETTING::OVERLAY_SAFE_HELPER_TEXT_ON:
400 settings.setValue(SETTING_OVERLAY_SAFE_HELPER_TEXT_ON, value);
402 case SETTING::SHADOW:
403 settings.setValue(SETTING_SHADOW, value);
405 case SETTING::PREV_ONION:
406 settings.setValue(SETTING_PREV_ONION, value);
408 case SETTING::NEXT_ONION:
409 settings.setValue(SETTING_NEXT_ONION, value);
411 case SETTING::MULTILAYER_ONION:
412 settings.setValue(SETTING_MULTILAYER_ONION, value);
414 case SETTING::INVISIBLE_LINES:
415 settings.setValue(SETTING_INVISIBLE_LINES, value);
417 case SETTING::OUTLINES:
418 settings.setValue(SETTING_OUTLINES, value);
420 case SETTING::ONION_BLUE:
421 settings.setValue(SETTING_ONION_BLUE, value);
423 case SETTING::ONION_RED:
424 settings.setValue(SETTING_ONION_RED, value);
426 case SETTING::TOOL_CURSOR:
427 settings.setValue(SETTING_TOOL_CURSOR, value);
429 case SETTING::CANVAS_CURSOR:
430 settings.setValue(SETTING_CANVAS_CURSOR, value);
432 case SETTING::HIGH_RESOLUTION:
433 settings.setValue(SETTING_HIGH_RESOLUTION, value);
435 case SETTING::AUTO_SAVE:
436 settings.setValue(SETTING_AUTO_SAVE, value);
438 case SETTING::SHORT_SCRUB:
439 settings.setValue(SETTING_SHORT_SCRUB, value);
441 case SETTING::DRAW_LABEL:
442 settings.setValue(SETTING_DRAW_LABEL, value);
444 case SETTING::QUICK_SIZING:
445 settings.setValue(SETTING_QUICK_SIZING, value);
447 case SETTING::INVERT_DRAG_ZOOM_DIRECTION:
448 settings.setValue(SETTING_INVERT_DRAG_ZOOM_DIRECTION, value);
450 case SETTING::INVERT_SCROLL_ZOOM_DIRECTION:
451 settings.setValue(SETTING_INVERT_SCROLL_ZOOM_DIRECTION, value);
453 case SETTING::LAYOUT_LOCK:
454 settings.setValue(SETTING_LAYOUT_LOCK, value);
456 case SETTING::SHOW_SELECTION_INFO:
457 settings.setValue(SETTING_SHOW_SELECTION_INFO, value);
459 case SETTING::SOUND_SCRUB_ACTIVE:
460 settings.setValue(SETTING_SOUND_SCRUB_ACTIVE, value);
462 case SETTING::ASK_FOR_PRESET:
463 settings.setValue(SETTING_ASK_FOR_PRESET, value);
465 case SETTING::LOAD_MOST_RECENT:
466 settings.setValue(SETTING_LOAD_MOST_RECENT, value);
468 case SETTING::LOAD_DEFAULT_PRESET:
469 settings.setValue(SETTING_LOAD_DEFAULT_PRESET, value);
471 case SETTING::NEW_UNDO_REDO_SYSTEM_ON:
472 settings.setValue(SETTING_NEW_UNDO_REDO_ON, value);
479 int optionId =
static_cast<int>(option);
480 if (mBooleanSet[optionId] != value)
482 mBooleanSet[optionId] = value;
483 emit optionChanged(option);
bool contains(const Key &key) const const
const T value(const Key &key) const const
QString number(int n, int base)