| #pragma once |
| |
| #ifndef PREFERENCES_H |
| #define PREFERENCES_H |
| |
| #include <memory> |
| |
| |
| #include "tcommon.h" |
| #include "tgeometry.h" |
| #include "tpixel.h" |
| #include "tfilepath.h" |
| |
| |
| #include "toonz/levelproperties.h" |
| #include "toonz/preferencesitemids.h" |
| |
| |
| #include <QString> |
| #include <QObject> |
| #include <QMap> |
| #include <QRegExp> |
| #include <QVariant> |
| #include <QDataStream> |
| |
| #undef DVAPI |
| #undef DVVAR |
| #ifdef TOONZLIB_EXPORTS |
| #define DVAPI DV_EXPORT_API |
| #define DVVAR DV_EXPORT_VAR |
| #else |
| #define DVAPI DV_IMPORT_API |
| #define DVVAR DV_IMPORT_VAR |
| #endif |
| |
| |
| |
| |
| |
| class QSettings; |
| |
| |
| |
| |
| |
| |
| |
| class Preferences; |
| typedef void (Preferences::*OnEditedFunc)(); |
| class DVAPI PreferencesItem final { |
| public: |
| QString idString; |
| QMetaType::Type type; |
| QVariant value; |
| QVariant min = 0; |
| QVariant max = -1; |
| OnEditedFunc onEditedFunc = nullptr; |
| |
| PreferencesItem(QString _idString, QMetaType::Type _type, QVariant _value, |
| QVariant _min = 0, QVariant _max = -1, |
| OnEditedFunc _onEditedFunc = nullptr) |
| : idString(_idString) |
| , type(_type) |
| , value(_value) |
| , min(_min) |
| , max(_max) |
| , onEditedFunc(_onEditedFunc) {} |
| PreferencesItem() {} |
| }; |
| |
| class DVAPI Preferences final : public QObject |
| { |
| Q_OBJECT |
| |
| public: |
| struct LevelFormat { |
| QString m_name; |
| QRegExp |
| m_pathFormat; |
| |
| LevelOptions m_options; |
| int m_priority; |
| |
| public: |
| LevelFormat(const QString &name = QString()) |
| : m_name(name) |
| , m_pathFormat(".*", Qt::CaseInsensitive) |
| , m_priority(1) {} |
| |
| bool matches(const TFilePath &fp) const; |
| }; |
| |
| enum ColumnIconLoadingPolicy { |
| LoadAtOnce, |
| |
| LoadOnDemand |
| |
| |
| }; |
| |
| enum SnappingTarge { SnapStrokes, SnapGuides, SnapAll }; |
| |
| enum PathAliasPriority { |
| ProjectFolderAliases = 0, |
| SceneFolderAlias, |
| ProjectFolderOnly |
| }; |
| |
| enum FunctionEditorToggle { |
| ShowGraphEditorInPopup = 0, |
| ShowFunctionSpreadsheetInPopup, |
| ToggleBetweenGraphAndSpreadsheet |
| }; |
| |
| enum LevelNameDisplayType { |
| ShowLevelName_Default = 0, |
| ShowLevelNameOnEachMarker, |
| ShowLevelNameOnColumnHeader |
| }; |
| |
| |
| |
| void enableAutosave(); |
| void setAutosavePeriod(); |
| void setUndoMemorySize(); |
| |
| void setPixelsOnly(); |
| void setUnits(); |
| void setCameraUnits(); |
| |
| void setRasterBackgroundColor(); |
| |
| public: |
| static Preferences *instance(); |
| |
| QMap<PreferencesItemId, PreferencesItem> m_items; |
| void initializeOptions(); |
| void definePreferenceItems(); |
| void define(PreferencesItemId id, QString idString, QMetaType::Type type, |
| QVariant defaultValue, QVariant min = 0, QVariant max = -1); |
| |
| void setCallBack(const PreferencesItemId id, OnEditedFunc func); |
| void resolveCompatibility(); |
| |
| PreferencesItem &getItem(const PreferencesItemId id); |
| bool getBoolValue(const PreferencesItemId id) const; |
| int getIntValue(const PreferencesItemId id) const; |
| double getDoubleValue(const PreferencesItemId id) const; |
| QString getStringValue(const PreferencesItemId id) const; |
| TPixel getColorValue(const PreferencesItemId id) const; |
| TDimension getSizeValue(const PreferencesItemId id) const; |
| |
| void setValue(const PreferencesItemId id, QVariant value, |
| bool saveToFile = true); |
| |
| |
| bool isDefaultViewerEnabled() const { |
| return getBoolValue(defaultViewerEnabled); |
| } |
| bool isRasterOptimizedMemory() const { |
| return getBoolValue(rasterOptimizedMemory); |
| } |
| bool isAutosaveEnabled() const { return getBoolValue(autosaveEnabled); } |
| int getAutosavePeriod() const { |
| return getIntValue(autosavePeriod); |
| } |
| bool isAutosaveSceneEnabled() const { |
| return getBoolValue(autosaveSceneEnabled); |
| } |
| bool isAutosaveOtherFilesEnabled() const { |
| return getBoolValue(autosaveOtherFilesEnabled); |
| } |
| bool isStartupPopupEnabled() { return getBoolValue(startupPopupEnabled); } |
| int getUndoMemorySize() const { return getIntValue(undoMemorySize); } |
| int getDefaultTaskChunkSize() const { return getIntValue(taskchunksize); } |
| bool isReplaceAfterSaveLevelAsEnabled() const { |
| return getBoolValue(replaceAfterSaveLevelAs); |
| } |
| bool isBackupEnabled() const { return getBoolValue(backupEnabled); } |
| int getBackupKeepCount() { return getIntValue(backupKeepCount); } |
| bool isSceneNumberingEnabled() const { |
| return getBoolValue(sceneNumberingEnabled); |
| } |
| bool isWatchFileSystemEnabled() { |
| return getBoolValue(watchFileSystemEnabled); |
| } |
| int getProjectRoot() { return getIntValue(projectRoot); } |
| QString getCustomProjectRoot() { return getStringValue(customProjectRoot); } |
| PathAliasPriority getPathAliasPriority() const { |
| return PathAliasPriority(getIntValue(pathAliasPriority)); |
| } |
| |
| |
| QStringList getStyleSheetList() const { return m_styleSheetList; } |
| bool getIconTheme() const { return getBoolValue(iconTheme); } |
| void storeOldUnits(); |
| void resetOldUnits(); |
| QStringList getLanguageList() const { return m_languageList; } |
| QMap<int, QString> getRoomMap() const { return m_roomMaps; } |
| |
| QString getCurrentStyleSheet() const; |
| QString getAdditionalStyleSheet() const { |
| return getStringValue(additionalStyleSheet); |
| } |
| bool getPixelsOnly() const { return getBoolValue(pixelsOnly); } |
| QString getOldUnits() const { return getStringValue(oldUnits); } |
| QString getOldCameraUnits() const { return getStringValue(oldCameraUnits); } |
| QString getUnits() const { return getStringValue(linearUnits); } |
| QString getCameraUnits() const { return getStringValue(cameraUnits); } |
| QString getCurrentRoomChoice() const { |
| return getStringValue(CurrentRoomChoice); |
| } |
| FunctionEditorToggle getFunctionEditorToggle() { |
| return FunctionEditorToggle(getIntValue(functionEditorToggle)); |
| } |
| bool isMoveCurrentEnabled() const { |
| return getBoolValue(moveCurrentFrameByClickCellArea); |
| } |
| bool isActualPixelViewOnSceneEditingModeEnabled() const { |
| return getBoolValue(actualPixelViewOnSceneEditingMode); |
| } |
| bool isShowRasterImagesDarkenBlendedInViewerEnabled() const { |
| return getBoolValue(showRasterImagesDarkenBlendedInViewer); |
| } |
| TDimension getIconSize() const { return getSizeValue(iconSize); } |
| void getViewValues(int &shrink, int &step) const { |
| shrink = getIntValue(viewShrink), step = getIntValue(viewStep); |
| } |
| int getViewerZoomCenter() const { return getIntValue(viewerZoomCenter); } |
| QString getCurrentLanguage() const; |
| QString getInterfaceFont() { return getStringValue(interfaceFont); } |
| QString getInterfaceFontStyle() { return getStringValue(interfaceFontStyle); } |
| bool isColorCalibrationEnabled() const { |
| return getBoolValue(colorCalibrationEnabled); |
| } |
| void setColorCalibrationLutPath(QString monitorName, QString path); |
| QString getColorCalibrationLutPath(QString &monitorName) const; |
| bool is30bitDisplayEnabled() const { return getBoolValue(displayIn30bit); } |
| |
| bool getShow0ThickLines() const { return getBoolValue(show0ThickLines); } |
| bool getRegionAntialias() const { return getBoolValue(regionAntialias); } |
| |
| |
| int getDefaultImportPolicy() { return getIntValue(importPolicy); } |
| bool isAutoExposeEnabled() const { return getBoolValue(autoExposeEnabled); } |
| bool isSubsceneFolderEnabled() const { |
| return getBoolValue(subsceneFolderEnabled); |
| } |
| bool isRemoveSceneNumberFromLoadedLevelNameEnabled() const { |
| return getBoolValue(removeSceneNumberFromLoadedLevelName); |
| } |
| bool isIgnoreImageDpiEnabled() const { return getBoolValue(IgnoreImageDpi); } |
| int getRasterLevelCachingBehavior() const { |
| return getIntValue(rasterLevelCachingBehavior); |
| } |
| ColumnIconLoadingPolicy getColumnIconLoadingPolicy() const { |
| return ColumnIconLoadingPolicy(getIntValue(columnIconLoadingPolicy)); |
| } |
| |
| int addLevelFormat(const LevelFormat &format); |
| |
| |
| void removeLevelFormat(int formatIdx); |
| const LevelFormat &levelFormat( |
| int formatIdx) const; |
| int levelFormatsCount() |
| const; |
| |
| |
| int matchLevelFormat(const TFilePath &fp) |
| const; |
| |
| bool isAutoRemoveUnusedLevelsEnabled() const { |
| return isAutoExposeEnabled() && getBoolValue(autoRemoveUnusedLevels); |
| } |
| |
| |
| TPixel getRasterBackgroundColor() const { |
| return getColorValue(rasterBackgroundColor); |
| } |
| |
| |
| QString getFfmpegPath() const { return getStringValue(ffmpegPath); } |
| int getFfmpegTimeout() { return getIntValue(ffmpegTimeout); } |
| QString getFastRenderPath() const { return getStringValue(fastRenderPath); } |
| bool getFfmpegMultiThread() const { return getBoolValue(ffmpegMultiThread); } |
| QString getRhubarbPath() const { return getStringValue(rhubarbPath); } |
| int getRhubarbTimeout() { return getIntValue(rhubarbTimeout); } |
| |
| |
| QString getDefRasterFormat() const { return getStringValue(DefRasterFormat); } |
| |
| int getDefLevelType() const { return getIntValue(DefLevelType); } |
| bool isNewLevelSizeToCameraSizeEnabled() const { |
| return getBoolValue(newLevelSizeToCameraSizeEnabled); |
| } |
| double getDefLevelWidth() const { return getDoubleValue(DefLevelWidth); } |
| double getDefLevelHeight() const { return getDoubleValue(DefLevelHeight); } |
| double getDefLevelDpi() const { return getDoubleValue(DefLevelDpi); } |
| bool isAutoCreateEnabled() const { return getBoolValue(EnableAutocreation); } |
| int getNumberingSystem() const { return getIntValue(NumberingSystem); } |
| bool isAutoStretchEnabled() const { return getBoolValue(EnableAutoStretch); } |
| bool isCreationInHoldCellsEnabled() const { |
| return getBoolValue(EnableCreationInHoldCells); |
| } |
| bool isAutorenumberEnabled() const { |
| return getBoolValue(EnableAutoRenumber); |
| } |
| int getVectorSnappingTarget() { return getIntValue(vectorSnappingTarget); } |
| bool isSaveUnpaintedInCleanupEnable() const { |
| return getBoolValue(saveUnpaintedInCleanup); |
| } |
| bool isMinimizeSaveboxAfterEditing() const { |
| return getBoolValue(minimizeSaveboxAfterEditing); |
| } |
| bool isUseNumpadForSwitchingStylesEnabled() const { |
| return getBoolValue(useNumpadForSwitchingStyles); |
| } |
| bool getDownArrowLevelStripNewFrame() { |
| return getBoolValue(downArrowInLevelStripCreatesNewFrame); |
| } |
| bool getKeepFillOnVectorSimplify() { |
| return getBoolValue(keepFillOnVectorSimplify); |
| } |
| bool getUseHigherDpiOnVectorSimplify() { |
| return getBoolValue(useHigherDpiOnVectorSimplify); |
| } |
| |
| |
| |
| |
| |
| bool getFillOnlySavebox() const { return getBoolValue(FillOnlysavebox); } |
| bool isMultiLayerStylePickerEnabled() const { |
| return getBoolValue(multiLayerStylePickerEnabled); |
| } |
| QString getCursorBrushType() const { return getStringValue(cursorBrushType); } |
| QString getCursorBrushStyle() const { |
| return getStringValue(cursorBrushStyle); |
| } |
| bool isCursorOutlineEnabled() const { |
| return getBoolValue(cursorOutlineEnabled); |
| } |
| int getLevelBasedToolsDisplay() const { |
| return getIntValue(levelBasedToolsDisplay); |
| } |
| bool useCtrlAltToResizeBrushEnabled() const { |
| return getBoolValue(useCtrlAltToResizeBrush); |
| } |
| int getTempToolSwitchTimer() const { |
| return getIntValue(tempToolSwitchTimer); |
| } |
| |
| |
| QString getXsheetLayoutPreference() const { |
| return getStringValue(xsheetLayoutPreference); |
| } |
| QString getLoadedXsheetLayout() const { |
| return getStringValue(xsheetLayoutPreference); |
| } |
| int getXsheetStep() const { |
| return getIntValue(xsheetStep); |
| } |
| bool isXsheetAutopanEnabled() const { |
| return getBoolValue(xsheetAutopanEnabled); |
| } |
| int getDragCellsBehaviour() const { return getIntValue(DragCellsBehaviour); } |
| int getDeleteCommandBehaviour() const { |
| return getIntValue(deleteCommandBehavior); |
| } |
| int getPasteCellsBehavior() const { return getIntValue(pasteCellsBehavior); } |
| bool isIgnoreAlphaonColumn1Enabled() const { |
| return getBoolValue(ignoreAlphaonColumn1Enabled); |
| } |
| bool isShowKeyframesOnXsheetCellAreaEnabled() const { |
| return getBoolValue(showKeyframesOnXsheetCellArea); |
| } |
| bool isXsheetCameraColumnEnabled() const { |
| return getBoolValue(showXsheetCameraColumn); |
| } |
| bool isUseArrowKeyToShiftCellSelectionEnabled() const { |
| return getBoolValue(useArrowKeyToShiftCellSelection); |
| } |
| bool isInputCellsWithoutDoubleClickingEnabled() const { |
| return getBoolValue(inputCellsWithoutDoubleClickingEnabled); |
| } |
| bool isShortcutCommandsWhileRenamingCellEnabled() const { |
| return getBoolValue(shortcutCommandsWhileRenamingCellEnabled); |
| } |
| bool isShowXSheetToolbarEnabled() const { |
| return getBoolValue(showXSheetToolbar); |
| } |
| bool isExpandFunctionHeaderEnabled() const { |
| return getBoolValue(expandFunctionHeader); |
| } |
| bool isShowColumnNumbersEnabled() const { |
| return getBoolValue(showColumnNumbers); |
| } |
| bool isParentColorsInXsheetColumnEnabled() const { |
| return getBoolValue(parentColorsInXsheetColumn); |
| } |
| bool isSyncLevelRenumberWithXsheetEnabled() const { |
| return getBoolValue(syncLevelRenumberWithXsheet); |
| } |
| bool isCurrentTimelineIndicatorEnabled() const { |
| return getBoolValue(currentTimelineEnabled); |
| } |
| void getCurrentColumnData(TPixel &color) const { |
| color = getColorValue(currentColumnColor); |
| } |
| |
| LevelNameDisplayType getLevelNameDisplayType() const { |
| return LevelNameDisplayType(getIntValue(levelNameDisplayType)); |
| } |
| bool isLevelNameOnEachMarkerEnabled() const { |
| return getLevelNameDisplayType() == ShowLevelNameOnEachMarker; |
| } |
| bool isShowFrameNumberWithLettersEnabled() const { |
| return getBoolValue(showFrameNumberWithLetters); |
| } |
| |
| |
| int getKeyframeType() const { return getIntValue(keyframeType); } |
| int getAnimationStep() const { return getIntValue(animationStep); } |
| bool isModifyExpressionOnMovingReferencesEnabled() const { |
| return getBoolValue(modifyExpressionOnMovingReferences); |
| } |
| |
| |
| void getBlankValues(int &bCount, TPixel32 &bColor) const { |
| bCount = getIntValue(blanksCount), bColor = getColorValue(blankColor); |
| } |
| bool rewindAfterPlaybackEnabled() const { |
| return getBoolValue(rewindAfterPlayback); |
| } |
| int getShortPlayFrameCount() const { |
| return getIntValue(shortPlayFrameCount); |
| } |
| bool previewAlwaysOpenNewFlipEnabled() const { |
| return getBoolValue(previewAlwaysOpenNewFlip); |
| } |
| bool fitToFlipbookEnabled() const { return getBoolValue(fitToFlipbook); } |
| bool isGeneratedMovieViewEnabled() const { |
| return getBoolValue(generatedMovieViewEnabled); |
| } |
| |
| |
| bool isOnionSkinEnabled() const { return getBoolValue(onionSkinEnabled); } |
| int getOnionPaperThickness() const { |
| return getIntValue(onionPaperThickness); |
| } |
| |
| void getOnionData(TPixel &frontColor, TPixel &backColor, |
| bool &inksOnly) const { |
| frontColor = getColorValue(frontOnionColor), |
| backColor = getColorValue(backOnionColor), |
| inksOnly = getBoolValue(onionInksOnly); |
| } |
| bool getOnionSkinDuringPlayback() { |
| return getBoolValue(onionSkinDuringPlayback); |
| } |
| bool areOnionColorsUsedForShiftAndTraceGhosts() const { |
| return getBoolValue(useOnionColorsForShiftAndTraceGhosts); |
| } |
| bool getAnimatedGuidedDrawing() const { |
| return getIntValue(animatedGuidedDrawing) == 1; |
| } |
| |
| |
| TPixel getViewerBgColor() const { return getColorValue(viewerBGColor); } |
| TPixel getPreviewBgColor() const { return getColorValue(previewBGColor); } |
| TPixel getLevelEditorBoxColor() const { |
| return getColorValue(levelEditorBoxColor); |
| } |
| void getChessboardColors(TPixel32 &col1, TPixel32 &col2) const { |
| col1 = getColorValue(chessboardColor1); |
| col2 = getColorValue(chessboardColor2); |
| } |
| void getTranspCheckData(TPixel &bg, TPixel &ink, TPixel &paint) const { |
| bg = getColorValue(transpCheckInkOnBlack); |
| ink = getColorValue(transpCheckInkOnWhite); |
| paint = getColorValue(transpCheckPaint); |
| } |
| |
| |
| bool isSVNEnabled() const { return getBoolValue(SVNEnabled); } |
| bool isAutomaticSVNFolderRefreshEnabled() const { |
| return getBoolValue(automaticSVNFolderRefreshEnabled); |
| } |
| bool isLatestVersionCheckEnabled() const { |
| return getBoolValue(latestVersionCheckEnabled); |
| } |
| |
| |
| bool isWinInkEnabled() const { return getBoolValue(winInkEnabled); } |
| bool isQtNativeWinInkEnabled() const { |
| return getBoolValue(useQtNativeWinInk); |
| } |
| |
| |
| |
| QString getShortcutPreset() { return getStringValue(shortcutPreset); } |
| |
| bool isGuidedDrawingEnabled() { return getIntValue(guidedDrawingType) > 0; } |
| int getGuidedDrawingType() { return getIntValue(guidedDrawingType); } |
| bool getGuidedAutoInbetween() { return getBoolValue(guidedAutoInbetween); } |
| int getGuidedInterpolation() { return getIntValue(guidedInterpolationType); } |
| #if defined(MACOSX) && defined(__LP64__) |
| int getShmMax() const { |
| return getIntValue(shmmax); |
| } |
| int getShmSeg() const { |
| return getIntValue(shmseg); |
| } |
| int getShmAll() const { |
| return getIntValue(shmall); |
| } |
| int getShmMni() const { |
| return getIntValue(shmmni); |
| } |
| #endif |
| |
| void setPrecompute(bool enabled); |
| bool getPrecompute() { return m_precompute; } |
| bool isAnimationSheetEnabled() const { |
| return getIntValue(NumberingSystem) == 1; |
| } |
| bool isXsheetCameraColumnVisible() const { |
| return getBoolValue(showXsheetCameraColumn) && |
| getBoolValue(showKeyframesOnXsheetCellArea); |
| } |
| int getTextureSize() const { return m_textureSize; } |
| bool useDrawPixel() { return m_textureSize == 0; } |
| std::string getLayerNameEncoding() const { return m_layerNameEncoding; }; |
| |
| Q_SIGNALS: |
| |
| void stopAutoSave(); |
| void startAutoSave(); |
| void autoSavePeriodChanged(); |
| |
| private: |
| std::unique_ptr<QSettings> m_settings; |
| |
| QStringList m_languageList, m_styleSheetList; |
| QMap<int, QString> m_roomMaps; |
| |
| std::vector<LevelFormat> m_levelFormats; |
| |
| bool m_precompute = true; |
| int m_textureSize = 0; |
| |
| std::string m_layerNameEncoding = "SJIS"; |
| |
| private: |
| Preferences(); |
| ~Preferences(); |
| }; |
| |
| #endif |