From dba624a9faca903504b1e5b5eb7f3a43b026aec7 Mon Sep 17 00:00:00 2001 From: Rodney Date: Apr 01 2023 10:24:24 +0000 Subject: Merge pull request #4801 from shun-iwasawa/fix_enabling_unit_preferences Fix enabling unit preferences --- diff --git a/toonz/sources/include/toonz/preferences.h b/toonz/sources/include/toonz/preferences.h index 736a19f..eac1ace 100644 --- a/toonz/sources/include/toonz/preferences.h +++ b/toonz/sources/include/toonz/preferences.h @@ -193,8 +193,8 @@ public: // Interface tab QStringList getStyleSheetList() const { return m_styleSheetList; } bool getIconTheme() const { return getBoolValue(iconTheme); } - void storeOldUnits(); // OK - void resetOldUnits(); // OK + void storeOldUnits(); + void resetOldUnits(); QStringList getLanguageList() const { return m_languageList; } QMap getRoomMap() const { return m_roomMaps; } diff --git a/toonz/sources/toonz/preferencespopup.cpp b/toonz/sources/toonz/preferencespopup.cpp index 78feef6..e0199df 100644 --- a/toonz/sources/toonz/preferencespopup.cpp +++ b/toonz/sources/toonz/preferencespopup.cpp @@ -579,6 +579,10 @@ void PreferencesPopup::onPixelsOnlyChanged() { //----------------------------------------------------------------------------- +void PreferencesPopup::beforeUnitChanged() { m_pref->storeOldUnits(); } + +//----------------------------------------------------------------------------- + void PreferencesPopup::onUnitChanged() { CheckBox* pixelsOnlyCB = getUI(pixelsOnly); if (!pixelsOnlyCB->isChecked() && @@ -1705,7 +1709,9 @@ QWidget* PreferencesPopup::createInterfacePage() { &PreferencesPopup::onStyleSheetTypeChanged); m_onEditedFuncMap.insert(iconTheme, &PreferencesPopup::onIconThemeChanged); m_onEditedFuncMap.insert(pixelsOnly, &PreferencesPopup::onPixelsOnlyChanged); + m_preEditedFuncMap.insert(linearUnits, &PreferencesPopup::beforeUnitChanged); m_onEditedFuncMap.insert(linearUnits, &PreferencesPopup::onUnitChanged); + m_preEditedFuncMap.insert(cameraUnits, &PreferencesPopup::beforeUnitChanged); m_onEditedFuncMap.insert(cameraUnits, &PreferencesPopup::onUnitChanged); m_preEditedFuncMap.insert(CurrentRoomChoice, &PreferencesPopup::beforeRoomChoiceChanged); diff --git a/toonz/sources/toonz/preferencespopup.h b/toonz/sources/toonz/preferencespopup.h index 25c2628..c1e1e1e 100644 --- a/toonz/sources/toonz/preferencespopup.h +++ b/toonz/sources/toonz/preferencespopup.h @@ -127,6 +127,7 @@ private: void onStyleSheetTypeChanged(); void onIconThemeChanged(); void onPixelsOnlyChanged(); + void beforeUnitChanged(); void onUnitChanged(); void beforeRoomChoiceChanged(); void onColorCalibrationChanged(); diff --git a/toonz/sources/toonzlib/preferences.cpp b/toonz/sources/toonzlib/preferences.cpp index 1f9aeaf..288a26c 100644 --- a/toonz/sources/toonzlib/preferences.cpp +++ b/toonz/sources/toonzlib/preferences.cpp @@ -983,8 +983,10 @@ void Preferences::setRasterBackgroundColor() { //----------------------------------------------------------------- void Preferences::storeOldUnits() { - setValue(oldUnits, getStringValue(linearUnits)); - setValue(oldCameraUnits, getStringValue(cameraUnits)); + QString linearU = getStringValue(linearUnits); + if (linearU != "pixel") setValue(oldUnits, linearU); + QString cameraU = getStringValue(cameraUnits); + if (cameraU != "pixel") setValue(oldCameraUnits, cameraU); } //-----------------------------------------------------------------