From 7bed166ae3b8971e805addd0791ed0b3953e845c Mon Sep 17 00:00:00 2001 From: konero Date: Jul 01 2023 17:33:05 +0000 Subject: refactor icon code --- diff --git a/stuff/config/qss/Blue/Blue.qss b/stuff/config/qss/Blue/Blue.qss index 73e6677..7ccf8fa 100644 --- a/stuff/config/qss/Blue/Blue.qss +++ b/stuff/config/qss/Blue/Blue.qss @@ -367,6 +367,7 @@ TPanelTitleBar { qproperty-ActiveBorderPixmap: url('../Default/imgs/white/none'); qproperty-FloatBorderPixmap: url('none'); qproperty-FloatActiveBorderPixmap: url('../Default/imgs/white/none'); + qproperty-OverColor: #C34040; } TPanelTitleBarButton { qproperty-PressedColor: #5385a6; @@ -2345,8 +2346,8 @@ XsheetViewer { qproperty-MeshColumnBorderColor: #423956; qproperty-SelectedMeshColumnColor: #656692; qproperty-MetaColumnColor: #8c8c8c; - qproperty-MetaColumnBorderColor: #c8c8c8; - qproperty-SelectedMetaColumnColor: #a6a6a6; + qproperty-MetaColumnBorderColor: #737373; + qproperty-SelectedMetaColumnColor: #94a0a8; qproperty-SoundTextColumnColor: #a7a7a7; qproperty-SoundTextColumnBorderColor: #8e8e8e; qproperty-SelectedSoundTextColumnColor: #adb9c0; @@ -2389,25 +2390,19 @@ XsheetViewer { qproperty-TimelinePreviewButtonBgOnColor: #414345; qproperty-TimelinePreviewButtonOnImage: url('../Default/imgs/white/preview_small.svg'); qproperty-TimelinePreviewButtonBgOffColor: #414345; - qproperty-TimelinePreviewButtonOffImage: url('none'); + qproperty-TimelinePreviewButtonOffImage: url('../Default/imgs/white/transparent.svg'); qproperty-TimelineUnifiedButtonTranspImage: url('../Default/imgs/white/preview_trans_small.svg'); qproperty-TimelineCamstandButtonBgOnColor: #414345; qproperty-TimelineCamstandButtonOnImage: url('../Default/imgs/white/table_small.svg'); qproperty-TimelineCamstandButtonTranspImage: url('../Default/imgs/white/trans_small.svg'); qproperty-TimelineCamstandButtonBgOffColor: #414345; - qproperty-TimelineCamstandButtonOffImage: url('none'); + qproperty-TimelineCamstandButtonOffImage: url('../Default/imgs/white/transparent.svg'); qproperty-TimelineLockButtonBgOnColor: #414345; qproperty-TimelineLockButtonOnImage: url('../Default/imgs/white/lock_on_small.svg'); qproperty-TimelineLockButtonBgOffColor: #414345; - qproperty-TimelineLockButtonOffImage: url('none'); + qproperty-TimelineLockButtonOffImage: url('../Default/imgs/white/transparent.svg'); qproperty-TimelineConfigButtonBgColor: #414345; qproperty-TimelineConfigButtonImage: url('../Default/imgs/white/timeline_config.svg'); - qproperty-LayerHeaderPreviewImage: url('../Default/imgs/white/layer_header_prev_eye.svg'); - qproperty-LayerHeaderPreviewOverImage: url('../Default/imgs/white/layer_header_prev_eye_over.svg'); - qproperty-LayerHeaderCamstandImage: url('../Default/imgs/white/layer_header_table_view.svg'); - qproperty-LayerHeaderCamstandOverImage: url('../Default/imgs/white/layer_header_table_view_over.svg'); - qproperty-LayerHeaderLockImage: url('../Default/imgs/white/layer_lock_on.svg'); - qproperty-LayerHeaderLockOverImage: url('../Default/imgs/white/layer_lock_on_over.svg'); } /* ----------------------------------------------------------------------------- Function Editor diff --git a/stuff/config/qss/Dark/Dark.qss b/stuff/config/qss/Dark/Dark.qss index 10652ea..891ba3d 100644 --- a/stuff/config/qss/Dark/Dark.qss +++ b/stuff/config/qss/Dark/Dark.qss @@ -367,6 +367,7 @@ TPanelTitleBar { qproperty-ActiveBorderPixmap: url('../Default/imgs/white/none'); qproperty-FloatBorderPixmap: url('none'); qproperty-FloatActiveBorderPixmap: url('../Default/imgs/white/none'); + qproperty-OverColor: #C34040; } TPanelTitleBarButton { qproperty-PressedColor: #5385a6; @@ -2345,8 +2346,8 @@ XsheetViewer { qproperty-MeshColumnBorderColor: #423956; qproperty-SelectedMeshColumnColor: #656692; qproperty-MetaColumnColor: #8c8c8c; - qproperty-MetaColumnBorderColor: #c8c8c8; - qproperty-SelectedMetaColumnColor: #a6a6a6; + qproperty-MetaColumnBorderColor: #737373; + qproperty-SelectedMetaColumnColor: #94a0a8; qproperty-SoundTextColumnColor: #a7a7a7; qproperty-SoundTextColumnBorderColor: #8e8e8e; qproperty-SelectedSoundTextColumnColor: #adb9c0; @@ -2389,25 +2390,19 @@ XsheetViewer { qproperty-TimelinePreviewButtonBgOnColor: #303030; qproperty-TimelinePreviewButtonOnImage: url('../Default/imgs/white/preview_small.svg'); qproperty-TimelinePreviewButtonBgOffColor: #303030; - qproperty-TimelinePreviewButtonOffImage: url('none'); + qproperty-TimelinePreviewButtonOffImage: url('../Default/imgs/white/transparent.svg'); qproperty-TimelineUnifiedButtonTranspImage: url('../Default/imgs/white/preview_trans_small.svg'); qproperty-TimelineCamstandButtonBgOnColor: #303030; qproperty-TimelineCamstandButtonOnImage: url('../Default/imgs/white/table_small.svg'); qproperty-TimelineCamstandButtonTranspImage: url('../Default/imgs/white/trans_small.svg'); qproperty-TimelineCamstandButtonBgOffColor: #303030; - qproperty-TimelineCamstandButtonOffImage: url('none'); + qproperty-TimelineCamstandButtonOffImage: url('../Default/imgs/white/transparent.svg'); qproperty-TimelineLockButtonBgOnColor: #303030; qproperty-TimelineLockButtonOnImage: url('../Default/imgs/white/lock_on_small.svg'); qproperty-TimelineLockButtonBgOffColor: #303030; - qproperty-TimelineLockButtonOffImage: url('none'); + qproperty-TimelineLockButtonOffImage: url('../Default/imgs/white/transparent.svg'); qproperty-TimelineConfigButtonBgColor: #303030; qproperty-TimelineConfigButtonImage: url('../Default/imgs/white/timeline_config.svg'); - qproperty-LayerHeaderPreviewImage: url('../Default/imgs/white/layer_header_prev_eye.svg'); - qproperty-LayerHeaderPreviewOverImage: url('../Default/imgs/white/layer_header_prev_eye_over.svg'); - qproperty-LayerHeaderCamstandImage: url('../Default/imgs/white/layer_header_table_view.svg'); - qproperty-LayerHeaderCamstandOverImage: url('../Default/imgs/white/layer_header_table_view_over.svg'); - qproperty-LayerHeaderLockImage: url('../Default/imgs/white/layer_lock_on.svg'); - qproperty-LayerHeaderLockOverImage: url('../Default/imgs/white/layer_lock_on_over.svg'); } /* ----------------------------------------------------------------------------- Function Editor diff --git a/stuff/config/qss/Default/Default.qss b/stuff/config/qss/Default/Default.qss index f502d4d..65b69ab 100644 --- a/stuff/config/qss/Default/Default.qss +++ b/stuff/config/qss/Default/Default.qss @@ -367,6 +367,7 @@ TPanelTitleBar { qproperty-ActiveBorderPixmap: url('imgs/white/none'); qproperty-FloatBorderPixmap: url('none'); qproperty-FloatActiveBorderPixmap: url('imgs/white/none'); + qproperty-OverColor: #C34040; } TPanelTitleBarButton { qproperty-PressedColor: #5385a6; @@ -2345,8 +2346,8 @@ XsheetViewer { qproperty-MeshColumnBorderColor: #423956; qproperty-SelectedMeshColumnColor: #656692; qproperty-MetaColumnColor: #8c8c8c; - qproperty-MetaColumnBorderColor: #c8c8c8; - qproperty-SelectedMetaColumnColor: #a6a6a6; + qproperty-MetaColumnBorderColor: #737373; + qproperty-SelectedMetaColumnColor: #94a0a8; qproperty-SoundTextColumnColor: #a7a7a7; qproperty-SoundTextColumnBorderColor: #8e8e8e; qproperty-SelectedSoundTextColumnColor: #adb9c0; @@ -2389,25 +2390,19 @@ XsheetViewer { qproperty-TimelinePreviewButtonBgOnColor: #484848; qproperty-TimelinePreviewButtonOnImage: url('imgs/white/preview_small.svg'); qproperty-TimelinePreviewButtonBgOffColor: #484848; - qproperty-TimelinePreviewButtonOffImage: url('none'); + qproperty-TimelinePreviewButtonOffImage: url('imgs/white/transparent.svg'); qproperty-TimelineUnifiedButtonTranspImage: url('imgs/white/preview_trans_small.svg'); qproperty-TimelineCamstandButtonBgOnColor: #484848; qproperty-TimelineCamstandButtonOnImage: url('imgs/white/table_small.svg'); qproperty-TimelineCamstandButtonTranspImage: url('imgs/white/trans_small.svg'); qproperty-TimelineCamstandButtonBgOffColor: #484848; - qproperty-TimelineCamstandButtonOffImage: url('none'); + qproperty-TimelineCamstandButtonOffImage: url('imgs/white/transparent.svg'); qproperty-TimelineLockButtonBgOnColor: #484848; qproperty-TimelineLockButtonOnImage: url('imgs/white/lock_on_small.svg'); qproperty-TimelineLockButtonBgOffColor: #484848; - qproperty-TimelineLockButtonOffImage: url('none'); + qproperty-TimelineLockButtonOffImage: url('imgs/white/transparent.svg'); qproperty-TimelineConfigButtonBgColor: #484848; qproperty-TimelineConfigButtonImage: url('imgs/white/timeline_config.svg'); - qproperty-LayerHeaderPreviewImage: url('imgs/white/layer_header_prev_eye.svg'); - qproperty-LayerHeaderPreviewOverImage: url('imgs/white/layer_header_prev_eye_over.svg'); - qproperty-LayerHeaderCamstandImage: url('imgs/white/layer_header_table_view.svg'); - qproperty-LayerHeaderCamstandOverImage: url('imgs/white/layer_header_table_view_over.svg'); - qproperty-LayerHeaderLockImage: url('imgs/white/layer_lock_on.svg'); - qproperty-LayerHeaderLockOverImage: url('imgs/white/layer_lock_on_over.svg'); } /* ----------------------------------------------------------------------------- Function Editor diff --git a/stuff/config/qss/Default/imgs/black/layer_header_prev_eye.svg b/stuff/config/qss/Default/imgs/black/layer_header_prev_eye.svg deleted file mode 100644 index c608dd0..0000000 --- a/stuff/config/qss/Default/imgs/black/layer_header_prev_eye.svg +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/stuff/config/qss/Default/imgs/black/layer_header_prev_eye_over.svg b/stuff/config/qss/Default/imgs/black/layer_header_prev_eye_over.svg deleted file mode 100644 index 1fc0fec..0000000 --- a/stuff/config/qss/Default/imgs/black/layer_header_prev_eye_over.svg +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/stuff/config/qss/Default/imgs/black/layer_header_table_view.svg b/stuff/config/qss/Default/imgs/black/layer_header_table_view.svg deleted file mode 100644 index 39873e8..0000000 --- a/stuff/config/qss/Default/imgs/black/layer_header_table_view.svg +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/stuff/config/qss/Default/imgs/black/layer_header_table_view_over.svg b/stuff/config/qss/Default/imgs/black/layer_header_table_view_over.svg deleted file mode 100644 index 3511282..0000000 --- a/stuff/config/qss/Default/imgs/black/layer_header_table_view_over.svg +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/stuff/config/qss/Default/imgs/black/layer_lock_on.svg b/stuff/config/qss/Default/imgs/black/layer_lock_on.svg deleted file mode 100644 index dd94307..0000000 --- a/stuff/config/qss/Default/imgs/black/layer_lock_on.svg +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/stuff/config/qss/Default/imgs/black/layer_lock_on_over.svg b/stuff/config/qss/Default/imgs/black/layer_lock_on_over.svg deleted file mode 100644 index d7ce8d5..0000000 --- a/stuff/config/qss/Default/imgs/black/layer_lock_on_over.svg +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - - diff --git a/stuff/config/qss/Default/imgs/black/transparent.svg b/stuff/config/qss/Default/imgs/black/transparent.svg new file mode 100644 index 0000000..d3f1714 --- /dev/null +++ b/stuff/config/qss/Default/imgs/black/transparent.svg @@ -0,0 +1,4 @@ + + + + diff --git a/stuff/config/qss/Default/imgs/white/layer_header_prev_eye.svg b/stuff/config/qss/Default/imgs/white/layer_header_prev_eye.svg deleted file mode 100644 index 8eb5be6..0000000 --- a/stuff/config/qss/Default/imgs/white/layer_header_prev_eye.svg +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/stuff/config/qss/Default/imgs/white/layer_header_prev_eye_over.svg b/stuff/config/qss/Default/imgs/white/layer_header_prev_eye_over.svg deleted file mode 100644 index e800436..0000000 --- a/stuff/config/qss/Default/imgs/white/layer_header_prev_eye_over.svg +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/stuff/config/qss/Default/imgs/white/layer_header_table_view.svg b/stuff/config/qss/Default/imgs/white/layer_header_table_view.svg deleted file mode 100644 index a2a280a..0000000 --- a/stuff/config/qss/Default/imgs/white/layer_header_table_view.svg +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/stuff/config/qss/Default/imgs/white/layer_header_table_view_over.svg b/stuff/config/qss/Default/imgs/white/layer_header_table_view_over.svg deleted file mode 100644 index 3dfe1c6..0000000 --- a/stuff/config/qss/Default/imgs/white/layer_header_table_view_over.svg +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/stuff/config/qss/Default/imgs/white/layer_lock_on.svg b/stuff/config/qss/Default/imgs/white/layer_lock_on.svg deleted file mode 100644 index 00d0372..0000000 --- a/stuff/config/qss/Default/imgs/white/layer_lock_on.svg +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/stuff/config/qss/Default/imgs/white/layer_lock_on_over.svg b/stuff/config/qss/Default/imgs/white/layer_lock_on_over.svg deleted file mode 100644 index f5e9a7c..0000000 --- a/stuff/config/qss/Default/imgs/white/layer_lock_on_over.svg +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - - diff --git a/stuff/config/qss/Default/imgs/white/transparent.svg b/stuff/config/qss/Default/imgs/white/transparent.svg new file mode 100644 index 0000000..d3f1714 --- /dev/null +++ b/stuff/config/qss/Default/imgs/white/transparent.svg @@ -0,0 +1,4 @@ + + + + diff --git a/stuff/config/qss/Default/less/Default.less b/stuff/config/qss/Default/less/Default.less index 121ac30..055b11c 100644 --- a/stuff/config/qss/Default/less/Default.less +++ b/stuff/config/qss/Default/less/Default.less @@ -34,6 +34,8 @@ @label-title: rgb(159, 218, 255); @label-error: rgb(255, 0, 0); +@lock-color: #C34040; + // ----------------------------------------------------------------------------- // Tabs // ----------------------------------------------------------------------------- @@ -198,7 +200,7 @@ @toolbutton-border-color-disabled: @toolbutton-bg-color-disabled; // Lock -@toolbutton-lock-bg-color-checked: #C34040; +@toolbutton-lock-bg-color-checked: @lock-color; @toolbutton-lock-border-color-checked: @toolbutton-lock-bg-color-checked; @toolbutton-lock-bg-color-checked-hover: lighten(@toolbutton-lock-bg-color-checked, 15); @toolbutton-lock-border-color-checked-hover: @toolbutton-lock-bg-color-checked-hover; @@ -325,8 +327,9 @@ // Title pane icon colors @title-button-rollover-color: @button-bg-color-hover; @title-button-pressed-color: @hl-bg-color; -@title-button-freeze-color: @toolbutton-lock-bg-color-checked; +@title-button-freeze-color: @lock-color; @title-button-preview-color: #1baf7e; +@title-close-over-color: @lock-color; // ----------------------------------------------------------------------------- // File Browser / Trees diff --git a/stuff/config/qss/Default/less/layouts/mainwindow.less b/stuff/config/qss/Default/less/layouts/mainwindow.less index 86fc349..e16a9f0 100644 --- a/stuff/config/qss/Default/less/layouts/mainwindow.less +++ b/stuff/config/qss/Default/less/layouts/mainwindow.less @@ -195,6 +195,9 @@ TPanelTitleBar { qproperty-ActiveBorderPixmap: url('@{img-url}/@{title-active-border-pixmap}'); qproperty-FloatBorderPixmap: url('none'); qproperty-FloatActiveBorderPixmap: url('@{img-url}/@{title-active-border-pixmap}'); + + // Buttons + qproperty-OverColor: @title-close-over-color; } TPanelTitleBarButton { diff --git a/stuff/config/qss/Default/less/layouts/xsheet.less b/stuff/config/qss/Default/less/layouts/xsheet.less index 5d7cbca..2010139 100644 --- a/stuff/config/qss/Default/less/layouts/xsheet.less +++ b/stuff/config/qss/Default/less/layouts/xsheet.less @@ -193,7 +193,7 @@ XsheetViewer { qproperty-TimelinePreviewButtonBgOnColor: @bg; qproperty-TimelinePreviewButtonOnImage: url('@{img-url}/preview_small.svg'); qproperty-TimelinePreviewButtonBgOffColor: @bg; - qproperty-TimelinePreviewButtonOffImage: url('none'); + qproperty-TimelinePreviewButtonOffImage: url('@{img-url}/transparent.svg'); qproperty-TimelineUnifiedButtonTranspImage: url('@{img-url}/preview_trans_small.svg'); @@ -201,23 +201,15 @@ XsheetViewer { qproperty-TimelineCamstandButtonOnImage: url('@{img-url}/table_small.svg'); qproperty-TimelineCamstandButtonTranspImage: url('@{img-url}/trans_small.svg'); qproperty-TimelineCamstandButtonBgOffColor: @bg; - qproperty-TimelineCamstandButtonOffImage: url('none'); + qproperty-TimelineCamstandButtonOffImage: url('@{img-url}/transparent.svg'); qproperty-TimelineLockButtonBgOnColor: @bg; qproperty-TimelineLockButtonOnImage: url('@{img-url}/lock_on_small.svg'); qproperty-TimelineLockButtonBgOffColor: @bg; - qproperty-TimelineLockButtonOffImage: url('none'); + qproperty-TimelineLockButtonOffImage: url('@{img-url}/transparent.svg'); qproperty-TimelineConfigButtonBgColor: @bg; qproperty-TimelineConfigButtonImage: url('@{img-url}/timeline_config.svg'); - - // Header Control - qproperty-LayerHeaderPreviewImage: url('@{img-url}/layer_header_prev_eye.svg'); - qproperty-LayerHeaderPreviewOverImage: url('@{img-url}/layer_header_prev_eye_over.svg'); - qproperty-LayerHeaderCamstandImage: url('@{img-url}/layer_header_table_view.svg'); - qproperty-LayerHeaderCamstandOverImage: url('@{img-url}/layer_header_table_view_over.svg'); - qproperty-LayerHeaderLockImage: url('@{img-url}/layer_lock_on.svg'); - qproperty-LayerHeaderLockOverImage: url('@{img-url}/layer_lock_on_over.svg'); } /* ----------------------------------------------------------------------------- diff --git a/stuff/config/qss/Default/less/themes/Light.less b/stuff/config/qss/Default/less/themes/Light.less index 72b8aed..c9e993f 100644 --- a/stuff/config/qss/Default/less/themes/Light.less +++ b/stuff/config/qss/Default/less/themes/Light.less @@ -20,6 +20,8 @@ @hl-text-color: #000; @hl-bg-color-secondary: darken(@bg, 15); +@lock-color: #e0625c; + // ----------------------------------------------------------------------------- // Tabs // ----------------------------------------------------------------------------- @@ -52,7 +54,7 @@ // Title pane icon colors @title-button-pressed-color: darken(@hl-bg-color, 8); @title-button-rollover-color: darken(@title-bg-color, 20); -@title-button-freeze-color: #e0625c; +@title-button-freeze-color: @lock-color; @title-button-preview-color: #2cb856; // ----------------------------------------------------------------------------- @@ -75,7 +77,7 @@ @toolbutton-border-color-checked: darken(@toolbutton-bg-color-checked, 10); @toolbutton-bg-color-hover: darken(@bg, 15); -@toolbutton-lock-bg-color-checked: @title-button-freeze-color; +@toolbutton-lock-bg-color-checked: @lock-color; @toolbutton-lock-border-color-checked: darken(@toolbutton-lock-bg-color-checked, 20); // ----------------------------------------------------------------------------- diff --git a/stuff/config/qss/Default/less/themes/Neutral.less b/stuff/config/qss/Default/less/themes/Neutral.less index 9226fed..5e45f23 100644 --- a/stuff/config/qss/Default/less/themes/Neutral.less +++ b/stuff/config/qss/Default/less/themes/Neutral.less @@ -21,6 +21,8 @@ @dock-bg-color: darken(@bg, 30); @label-title: rgb(0, 0, 0); +@lock-color: #bd5454; + // ----------------------------------------------------------------------------- // Tabs // ----------------------------------------------------------------------------- @@ -115,8 +117,7 @@ @toolbutton-border-color-checked-hover: @toolbutton-border-color-checked; // Lock -@toolbutton-lock-bg-color-checked: #bd5454; -@toolbutton-lock-border-color-checked: darken(@toolbutton-lock-bg-color-checked, 20); +@toolbutton-lock-border-color-checked: darken(@lock-color, 20); @toolbutton-lock-border-color-checked-hover: @toolbutton-lock-border-color-checked; // ----------------------------------------------------------------------------- diff --git a/stuff/config/qss/Light/Light.qss b/stuff/config/qss/Light/Light.qss index ebe296f..e35a573 100644 --- a/stuff/config/qss/Light/Light.qss +++ b/stuff/config/qss/Light/Light.qss @@ -367,6 +367,7 @@ TPanelTitleBar { qproperty-ActiveBorderPixmap: url('../Default/imgs/black/none'); qproperty-FloatBorderPixmap: url('none'); qproperty-FloatActiveBorderPixmap: url('../Default/imgs/black/none'); + qproperty-OverColor: #e0625c; } TPanelTitleBarButton { qproperty-PressedColor: #82add2; @@ -2345,8 +2346,8 @@ XsheetViewer { qproperty-MeshColumnBorderColor: #9278ac; qproperty-SelectedMeshColumnColor: #a49dc2; qproperty-MetaColumnColor: #a8a8a8; - qproperty-MetaColumnBorderColor: #686868; - qproperty-SelectedMetaColumnColor: #c2c2c2; + qproperty-MetaColumnBorderColor: #828282; + qproperty-SelectedMetaColumnColor: #99a1a7; qproperty-SoundTextColumnColor: #c2c2c2; qproperty-SoundTextColumnBorderColor: #9c9c9c; qproperty-SelectedSoundTextColumnColor: #abb3b9; @@ -2389,25 +2390,19 @@ XsheetViewer { qproperty-TimelinePreviewButtonBgOnColor: #DBDBDB; qproperty-TimelinePreviewButtonOnImage: url('../Default/imgs/black/preview_small.svg'); qproperty-TimelinePreviewButtonBgOffColor: #DBDBDB; - qproperty-TimelinePreviewButtonOffImage: url('none'); + qproperty-TimelinePreviewButtonOffImage: url('../Default/imgs/black/transparent.svg'); qproperty-TimelineUnifiedButtonTranspImage: url('../Default/imgs/black/preview_trans_small.svg'); qproperty-TimelineCamstandButtonBgOnColor: #DBDBDB; qproperty-TimelineCamstandButtonOnImage: url('../Default/imgs/black/table_small.svg'); qproperty-TimelineCamstandButtonTranspImage: url('../Default/imgs/black/trans_small.svg'); qproperty-TimelineCamstandButtonBgOffColor: #DBDBDB; - qproperty-TimelineCamstandButtonOffImage: url('none'); + qproperty-TimelineCamstandButtonOffImage: url('../Default/imgs/black/transparent.svg'); qproperty-TimelineLockButtonBgOnColor: #DBDBDB; qproperty-TimelineLockButtonOnImage: url('../Default/imgs/black/lock_on_small.svg'); qproperty-TimelineLockButtonBgOffColor: #DBDBDB; - qproperty-TimelineLockButtonOffImage: url('none'); + qproperty-TimelineLockButtonOffImage: url('../Default/imgs/black/transparent.svg'); qproperty-TimelineConfigButtonBgColor: #DBDBDB; qproperty-TimelineConfigButtonImage: url('../Default/imgs/black/timeline_config.svg'); - qproperty-LayerHeaderPreviewImage: url('../Default/imgs/black/layer_header_prev_eye.svg'); - qproperty-LayerHeaderPreviewOverImage: url('../Default/imgs/black/layer_header_prev_eye_over.svg'); - qproperty-LayerHeaderCamstandImage: url('../Default/imgs/black/layer_header_table_view.svg'); - qproperty-LayerHeaderCamstandOverImage: url('../Default/imgs/black/layer_header_table_view_over.svg'); - qproperty-LayerHeaderLockImage: url('../Default/imgs/black/layer_lock_on.svg'); - qproperty-LayerHeaderLockOverImage: url('../Default/imgs/black/layer_lock_on_over.svg'); } /* ----------------------------------------------------------------------------- Function Editor diff --git a/stuff/config/qss/Neutral/Neutral.qss b/stuff/config/qss/Neutral/Neutral.qss index 7ac5da9..f194e5c 100644 --- a/stuff/config/qss/Neutral/Neutral.qss +++ b/stuff/config/qss/Neutral/Neutral.qss @@ -367,6 +367,7 @@ TPanelTitleBar { qproperty-ActiveBorderPixmap: url('../Default/imgs/black/none'); qproperty-FloatBorderPixmap: url('none'); qproperty-FloatActiveBorderPixmap: url('../Default/imgs/black/none'); + qproperty-OverColor: #bd5454; } TPanelTitleBarButton { qproperty-PressedColor: #8FA0B2; @@ -2345,8 +2346,8 @@ XsheetViewer { qproperty-MeshColumnBorderColor: #654f7e; qproperty-SelectedMeshColumnColor: #a18fc3; qproperty-MetaColumnColor: #8c8c8c; - qproperty-MetaColumnBorderColor: #c8c8c8; - qproperty-SelectedMetaColumnColor: #a6a6a6; + qproperty-MetaColumnBorderColor: #666666; + qproperty-SelectedMetaColumnColor: #a2a6aa; qproperty-SoundTextColumnColor: #a7a7a7; qproperty-SoundTextColumnBorderColor: #818181; qproperty-SelectedSoundTextColumnColor: #bbbfc3; @@ -2389,25 +2390,19 @@ XsheetViewer { qproperty-TimelinePreviewButtonBgOnColor: #808080; qproperty-TimelinePreviewButtonOnImage: url('../Default/imgs/black/preview_small.svg'); qproperty-TimelinePreviewButtonBgOffColor: #808080; - qproperty-TimelinePreviewButtonOffImage: url('none'); + qproperty-TimelinePreviewButtonOffImage: url('../Default/imgs/black/transparent.svg'); qproperty-TimelineUnifiedButtonTranspImage: url('../Default/imgs/black/preview_trans_small.svg'); qproperty-TimelineCamstandButtonBgOnColor: #808080; qproperty-TimelineCamstandButtonOnImage: url('../Default/imgs/black/table_small.svg'); qproperty-TimelineCamstandButtonTranspImage: url('../Default/imgs/black/trans_small.svg'); qproperty-TimelineCamstandButtonBgOffColor: #808080; - qproperty-TimelineCamstandButtonOffImage: url('none'); + qproperty-TimelineCamstandButtonOffImage: url('../Default/imgs/black/transparent.svg'); qproperty-TimelineLockButtonBgOnColor: #808080; qproperty-TimelineLockButtonOnImage: url('../Default/imgs/black/lock_on_small.svg'); qproperty-TimelineLockButtonBgOffColor: #808080; - qproperty-TimelineLockButtonOffImage: url('none'); + qproperty-TimelineLockButtonOffImage: url('../Default/imgs/black/transparent.svg'); qproperty-TimelineConfigButtonBgColor: #808080; qproperty-TimelineConfigButtonImage: url('../Default/imgs/black/timeline_config.svg'); - qproperty-LayerHeaderPreviewImage: url('../Default/imgs/black/layer_header_prev_eye.svg'); - qproperty-LayerHeaderPreviewOverImage: url('../Default/imgs/black/layer_header_prev_eye_over.svg'); - qproperty-LayerHeaderCamstandImage: url('../Default/imgs/black/layer_header_table_view.svg'); - qproperty-LayerHeaderCamstandOverImage: url('../Default/imgs/black/layer_header_table_view_over.svg'); - qproperty-LayerHeaderLockImage: url('../Default/imgs/black/layer_lock_on.svg'); - qproperty-LayerHeaderLockOverImage: url('../Default/imgs/black/layer_lock_on_over.svg'); } /* ----------------------------------------------------------------------------- Function Editor diff --git a/toonz/sources/include/toonzqt/gutil.h b/toonz/sources/include/toonzqt/gutil.h index 234f986..00c0817 100644 --- a/toonz/sources/include/toonzqt/gutil.h +++ b/toonz/sources/include/toonzqt/gutil.h @@ -39,6 +39,11 @@ const QColor grey225(225, 225, 225); const QColor grey190(190, 190, 190); const QColor grey150(150, 150, 150); +struct SvgRenderParams { + QSize size; + QRectF rect; +}; + } // namespace class QPainter; @@ -95,12 +100,25 @@ QPixmap DVAPI scalePixmapKeepingAspectRatio(QPixmap p, QSize size, //----------------------------------------------------------------------------- +SvgRenderParams calculateSvgRenderParams(const QSize &desiredSize, + QSize &imageSize, + Qt::AspectRatioMode aspectRatioMode); + +//----------------------------------------------------------------------------- + QPixmap DVAPI -svgToPixmap(const QString &svgFilePath, const QSize &size = QSize(), +svgToPixmap(const QString &svgFilePath, QSize size = QSize(), Qt::AspectRatioMode aspectRatioMode = Qt::IgnoreAspectRatio, QColor bgColor = Qt::transparent); //----------------------------------------------------------------------------- + +QImage DVAPI +svgToImage(const QString &svgFilePath, QSize size = QSize(), + Qt::AspectRatioMode aspectRatioMode = Qt::IgnoreAspectRatio, + QColor bgColor = Qt::transparent); + +//----------------------------------------------------------------------------- // returns device-pixel ratio. It is 1 for normal monitors and 2 (or higher // ratio) for high DPI monitors. Setting "Display > Set custom text size(DPI)" // for Windows corresponds to this ratio. @@ -108,18 +126,47 @@ int DVAPI getDevicePixelRatio(const QWidget *widget = nullptr); //----------------------------------------------------------------------------- -QPixmap DVAPI compositePixmap(QPixmap pixmap, const qreal &opacity = 0.8, - const QSize &size = QSize(), - const int leftAdj = 0, const int topAdj = 0, - QColor bgColor = Qt::transparent); -QPixmap DVAPI recolorPixmap( - QPixmap pixmap, QColor color = Preferences::instance()->getIconTheme() - ? Qt::black - : Qt::white); -QIcon DVAPI createQIcon(const char *iconSVGName, bool useFullOpacity = false, - bool isForMenuItem = false); -void DVAPI addSpecifiedSizedImageToIcon(QIcon &icon, const char *iconSVGName, - QSize newSize); +QImage DVAPI adjustImageOpacity(const QImage &input, qreal opacity = 1.0); + +//----------------------------------------------------------------------------- + +QImage DVAPI compositeImage(const QImage &input, QSize newSize = QSize(), + bool scaleInput = false, + QColor bgColor = Qt::transparent); + +//----------------------------------------------------------------------------- + +QPixmap DVAPI convertImageToPixmap(const QImage &image); + +//----------------------------------------------------------------------------- + +QImage DVAPI +generateIconImage(const QString &iconSVGName, qreal opacity = qreal(1.0), + QSize newSize = QSize(), + Qt::AspectRatioMode aspectRatioMode = Qt::IgnoreAspectRatio); + +//----------------------------------------------------------------------------- + +QPixmap DVAPI +generateIconPixmap(const QString &iconSVGName, qreal opacity = qreal(1.0), + QSize newSize = QSize(), + Qt::AspectRatioMode aspectRatioMode = Qt::IgnoreAspectRatio); + +//----------------------------------------------------------------------------- + +void DVAPI addImagesToIcon(QIcon &icon, const QImage &baseImg, + const QImage &overImg = QImage(), + const QImage &onImg = QImage(), + bool useFullOpacity = false); + +//----------------------------------------------------------------------------- + +void DVAPI addPixmapToAllModesAndStates(QIcon &icon, const QPixmap &pixmap); + +//----------------------------------------------------------------------------- + +QIcon DVAPI createQIcon(const QString &iconSVGName, bool useFullOpacity = false, + bool isForMenuItem = false, QSize newSize = QSize()); QIcon DVAPI createQIconPNG(const char *iconPNGName); QIcon DVAPI createQIconOnOffPNG(const char *iconPNGName, bool withOver = true); QIcon DVAPI createTemporaryIconFromName(const char *commandName); @@ -219,4 +266,39 @@ protected: QString DVAPI operator+(const QString &a, const TFilePath &fp); +//----------------------------------------------------------------------------- +// Theme Manager +// For managing icon themes + +class DVAPI ThemeManager { // singleton +public: + static ThemeManager &getInstance(); + + void buildIconPathsMap(const QString &path); + bool hasIcon(const QString &iconName) const; + QString getIconPath(const QString &iconName) const; + + qreal getOnOpacity() const; + qreal getOffOpacity() const; + qreal getDisabledOpacity() const; + + QImage recolorBlackPixels(const QImage &image, QColor color = QColor()); + QPixmap recolorBlackPixels(const QPixmap &input, QColor color = QColor()); + + // Debug + void printiconPathsMap(); + + ThemeManager(ThemeManager const &) = delete; + void operator=(ThemeManager const &) = delete; + ~ThemeManager(); + +private: + ThemeManager(); + + class ThemeManagerImpl; // forward declaration + std::unique_ptr impl; // opaque pointer +}; + +QString DVAPI getIconPath(const QString &path); + #endif // GUTIL_H diff --git a/toonz/sources/toonz/castselection.cpp b/toonz/sources/toonz/castselection.cpp index 7083050..e3079d7 100644 --- a/toonz/sources/toonz/castselection.cpp +++ b/toonz/sources/toonz/castselection.cpp @@ -38,7 +38,7 @@ void CastSelection::getSelectedLevels(std::vector &levels) { CastItems const &castItems = m_browser->getCastItems(); for (int i = 0; i < castItems.getItemCount(); i++) { if (!isSelected(i)) continue; - TXshLevel *level = castItems.getItem(i)->getSimpleLevel(); + TXshLevel *level = castItems.getItem(i)->getSimpleLevel(); if (!level) level = castItems.getItem(i)->getPaletteLevel(); if (!level) level = castItems.getItem(i)->getSoundLevel(); if (level) levels.push_back(level); @@ -93,7 +93,7 @@ QPixmap LevelCastItem::getPixmap(bool isSelected) const { bool onDemand = false; if (Preferences::instance()->getColumnIconLoadingPolicy() == Preferences::LoadOnDemand) - onDemand = !isSelected; + onDemand = !isSelected; QPixmap icon = IconGenerator::instance()->getIcon(sl, sl->getFirstFid(), false, onDemand); return scalePixmapKeepingAspectRatio(icon, m_itemPixmapSize, Qt::transparent); @@ -138,9 +138,8 @@ int SoundCastItem::getFrameCount() const { //----------------------------------------------------------------------------- QPixmap SoundCastItem::getPixmap(bool isSelected) const { - static QPixmap loudspeaker( - svgToPixmap(getIconThemePath("mimetypes/60/audio_icon.svg"), - m_itemPixmapSize, Qt::KeepAspectRatio)); + static QPixmap loudspeaker(generateIconPixmap( + "audio_icon", qreal(1.0), m_itemPixmapSize, Qt::KeepAspectRatio)); return loudspeaker; } diff --git a/toonz/sources/toonz/dvitemview.cpp b/toonz/sources/toonz/dvitemview.cpp index 6141bc7..8b2ca42 100644 --- a/toonz/sources/toonz/dvitemview.cpp +++ b/toonz/sources/toonz/dvitemview.cpp @@ -1028,8 +1028,7 @@ void DvItemViewerPanel::paintThumbnailItem(QPainter &p, int index) { if (!thumbnail.isNull()) p.drawPixmap(iconRect.topLeft(), thumbnail); //} else { - static QPixmap missingPixmap = - QPixmap(getIconThemePath("mimetypes/60/missing_icon.svg")); + static QPixmap missingPixmap = generateIconPixmap("missing_icon"); QRect pixmapRect(rect.left() + (rect.width() - missingPixmap.width()) / 2, rect.top(), missingPixmap.width(), missingPixmap.height()); p.drawPixmap(pixmapRect.topLeft(), missingPixmap); @@ -1251,7 +1250,7 @@ void DvItemViewerPanel::mousePressEvent(QMouseEvent *event) { } if (m_globalSelectionEnabled) m_selection->makeCurrent(); m_currentIndex = index; - //if (m_viewer ) m_viewer->notifyClick(index); + // if (m_viewer ) m_viewer->notifyClick(index); m_startDragPosition = event->pos(); update(); } @@ -1302,7 +1301,7 @@ void DvItemViewerPanel::mouseMoveEvent(QMouseEvent *event) { //----------------------------------------------------------------------------- void DvItemViewerPanel::mouseReleaseEvent(QMouseEvent *) { - if (m_viewer ) m_viewer->notifyClick(m_currentIndex); + if (m_viewer) m_viewer->notifyClick(m_currentIndex); } //----------------------------------------------------------------------------- diff --git a/toonz/sources/toonz/exportscenepopup.cpp b/toonz/sources/toonz/exportscenepopup.cpp index 4dc3f0c..ed6b98f 100644 --- a/toonz/sources/toonz/exportscenepopup.cpp +++ b/toonz/sources/toonz/exportscenepopup.cpp @@ -122,10 +122,8 @@ ExportSceneDvDirModelFileFolderNode::createExposeSceneNode( // ExportSceneDvDirModelProjectNode QPixmap ExportSceneDvDirModelProjectNode::getPixmap(bool isOpen) const { - static QPixmap openProjectPixmap(recolorPixmap( - svgToPixmap(getIconThemePath("actions/18/folder_project_on.svg")))); - static QPixmap closeProjectPixmap(recolorPixmap( - svgToPixmap(getIconThemePath("actions/18/folder_project.svg")))); + static QPixmap openProjectPixmap(generateIconPixmap("folder_project_on")); + static QPixmap closeProjectPixmap(generateIconPixmap("folder_project")); return isOpen ? openProjectPixmap : closeProjectPixmap; } @@ -193,8 +191,8 @@ void ExportSceneDvDirModelRootNode::refreshChildren() { ExportSceneDvDirModelSpecialFileFolderNode *projectRootNode = new ExportSceneDvDirModelSpecialFileFolderNode( this, L"Project root (" + rootDir + L")", projectRoot); - projectRootNode->setPixmap(QPixmap(recolorPixmap( - svgToPixmap(getIconThemePath("actions/18/folder_project_root.svg"))))); + projectRootNode->setPixmap( + QPixmap(generateIconPixmap("folder_project_root"))); m_projectRootNodes.push_back(projectRootNode); addChild(projectRootNode); } diff --git a/toonz/sources/toonz/filebrowser.cpp b/toonz/sources/toonz/filebrowser.cpp index 62491cc..1565d69 100644 --- a/toonz/sources/toonz/filebrowser.cpp +++ b/toonz/sources/toonz/filebrowser.cpp @@ -897,22 +897,19 @@ QVariant FileBrowser::getItemData(int index, DataType dataType, QSize iconSize = m_itemViewer->getPanel()->getIconSize(); // parent folder icons if (item.m_path == m_folder.getParentDir()) { - static QPixmap folderUpPixmap( - svgToPixmap(getIconThemePath("actions/60/folder_browser_up.svg"), - iconSize, Qt::KeepAspectRatio)); + static QPixmap folderUpPixmap(generateIconPixmap( + "folder_browser_up", qreal(1.0), iconSize, Qt::KeepAspectRatio)); return folderUpPixmap; } // folder icons else if (item.m_isFolder) { if (item.m_isLink) { - static QPixmap folderLinkPixmap( - svgToPixmap(getIconThemePath("actions/60/folder_browser_link.svg"), - iconSize, Qt::KeepAspectRatio)); + static QPixmap folderLinkPixmap(generateIconPixmap( + "folder_browser_link", qreal(1.0), iconSize, Qt::KeepAspectRatio)); return folderLinkPixmap; } else { - static QPixmap folderPixmap( - svgToPixmap(getIconThemePath("actions/60/folder_browser.svg"), - iconSize, Qt::KeepAspectRatio)); + static QPixmap folderPixmap(generateIconPixmap( + "folder_browser", qreal(1.0), iconSize, Qt::KeepAspectRatio)); return folderPixmap; } } diff --git a/toonz/sources/toonz/filebrowsermodel.cpp b/toonz/sources/toonz/filebrowsermodel.cpp index 3371b58..35e1ded 100644 --- a/toonz/sources/toonz/filebrowsermodel.cpp +++ b/toonz/sources/toonz/filebrowsermodel.cpp @@ -353,10 +353,8 @@ DvDirModelNode *DvDirModelFileFolderNode::getNodeByPath(const TFilePath &path) { //----------------------------------------------------------------------------- QPixmap DvDirModelFileFolderNode::getPixmap(bool isOpen) const { - static QPixmap openFolderPixmap( - svgToPixmap(getIconThemePath("actions/18/folder_on.svg"))); - static QPixmap closeFolderPixmap( - svgToPixmap(getIconThemePath("actions/18/folder.svg"))); + static QPixmap openFolderPixmap = generateIconPixmap("folder_on"); + static QPixmap closeFolderPixmap = generateIconPixmap("folder"); return isOpen ? openFolderPixmap : closeFolderPixmap; } @@ -506,10 +504,8 @@ DvDirModelNode *DvDirVersionControlNode::makeChild(std::wstring name) { //----------------------------------------------------------------------------- QPixmap DvDirVersionControlNode::getPixmap(bool isOpen) const { - static QPixmap openFolderPixmap( - svgToPixmap(getIconThemePath("actions/18/folder_on.svg"))); - static QPixmap closeFolderPixmap( - svgToPixmap(getIconThemePath("actions/18/folder.svg"))); + static QPixmap openFolderPixmap(generateIconPixmap("folder_on")); + static QPixmap closeFolderPixmap(generateIconPixmap("folder")); static QPixmap openMissingPixmap( svgToPixmap(":Resources/vcfolder_mis_open.svg")); static QPixmap closeMissingPixmap( @@ -782,10 +778,8 @@ void DvDirModelProjectNode::makeCurrent() { //----------------------------------------------------------------------------- QPixmap DvDirModelProjectNode::getPixmap(bool isOpen) const { - static QPixmap openProjectPixmap( - svgToPixmap(getIconThemePath("actions/18/folder_project_on.svg"))); - static QPixmap closeProjectPixmap( - svgToPixmap(getIconThemePath("actions/18/folder_project.svg"))); + static QPixmap openProjectPixmap = generateIconPixmap("folder_project_on"); + static QPixmap closeProjectPixmap = generateIconPixmap("folder_project"); return isOpen ? openProjectPixmap : closeProjectPixmap; } @@ -866,10 +860,8 @@ void DvDirModelDayNode::visualizeContent(FileBrowser *browser) { //----------------------------------------------------------------------------- QPixmap DvDirModelDayNode::getPixmap(bool isOpen) const { - static QPixmap openFolderPixmap( - svgToPixmap(getIconThemePath("actions/18/folder_on.svg"))); - static QPixmap closeFolderPixmap( - svgToPixmap(getIconThemePath("actions/18/folder.svg"))); + static QPixmap openFolderPixmap = generateIconPixmap("folder_on"); + static QPixmap closeFolderPixmap = generateIconPixmap("folder"); return isOpen ? openFolderPixmap : closeFolderPixmap; } @@ -1072,22 +1064,19 @@ void DvDirModelRootNode::refreshChildren() { DvDirModelSpecialFileFolderNode *child; child = new DvDirModelSpecialFileFolderNode(this, L"My Documents", getMyDocumentsPath()); - child->setPixmap(recolorPixmap( - svgToPixmap(getIconThemePath("actions/16/my_documents.svg")))); + child->setPixmap(generateIconPixmap("my_documents")); m_specialNodes.push_back(child); addChild(child); child = new DvDirModelSpecialFileFolderNode(this, L"Desktop", getDesktopPath()); - child->setPixmap( - recolorPixmap(svgToPixmap(getIconThemePath("actions/16/desktop.svg")))); + child->setPixmap(generateIconPixmap("desktop")); m_specialNodes.push_back(child); addChild(child); child = new DvDirModelSpecialFileFolderNode( this, L"Library", ToonzFolder::getLibraryFolder()); - child->setPixmap( - recolorPixmap(svgToPixmap(getIconThemePath("actions/16/library.svg")))); + child->setPixmap(generateIconPixmap("library")); m_specialNodes.push_back(child); addChild(child); @@ -1104,8 +1093,8 @@ void DvDirModelRootNode::refreshChildren() { DvDirModelSpecialFileFolderNode *projectRootNode = new DvDirModelSpecialFileFolderNode( this, L"Project root (" + roothDir + L")", projectRoot); - projectRootNode->setPixmap(QPixmap(recolorPixmap(svgToPixmap( - getIconThemePath("actions/18/folder_project_root.svg"))))); + projectRootNode->setPixmap( + QPixmap(generateIconPixmap("folder_project_root"))); m_projectRootNodes.push_back(projectRootNode); addChild(projectRootNode); } diff --git a/toonz/sources/toonz/flipbook.cpp b/toonz/sources/toonz/flipbook.cpp index ae5e341..4b946dc 100644 --- a/toonz/sources/toonz/flipbook.cpp +++ b/toonz/sources/toonz/flipbook.cpp @@ -265,8 +265,8 @@ void FlipBook::addFreezeButtonToTitleBar() { TPanel *panel = qobject_cast(parentWidget()); if (panel) { TPanelTitleBar *titleBar = panel->getTitleBar(); - m_freezeButton = new TPanelTitleBarButton( - titleBar, getIconThemePath("actions/20/pane_freeze.svg")); + m_freezeButton = + new TPanelTitleBarButton(titleBar, getIconPath("pane_freeze")); m_freezeButton->setToolTip("Freeze"); titleBar->add(QPoint(-64, 0), m_freezeButton); connect(m_freezeButton, SIGNAL(toggled(bool)), this, SLOT(freeze(bool))); diff --git a/toonz/sources/toonz/icons/dark/actions/16/lock.svg b/toonz/sources/toonz/icons/dark/actions/16/lock.svg new file mode 100644 index 0000000..aedeaa5 --- /dev/null +++ b/toonz/sources/toonz/icons/dark/actions/16/lock.svg @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/toonz/sources/toonz/icons/dark/actions/16/lock_on.svg b/toonz/sources/toonz/icons/dark/actions/16/lock_on.svg new file mode 100644 index 0000000..b4d14e9 --- /dev/null +++ b/toonz/sources/toonz/icons/dark/actions/16/lock_on.svg @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/toonz/sources/toonz/icons/dark/actions/16/new_note_level.svg b/toonz/sources/toonz/icons/dark/actions/16/new_note_level.svg index 892069e..7b6bdbc 100644 --- a/toonz/sources/toonz/icons/dark/actions/16/new_note_level.svg +++ b/toonz/sources/toonz/icons/dark/actions/16/new_note_level.svg @@ -2,10 +2,10 @@ - + - + diff --git a/toonz/sources/toonz/icons/dark/actions/16/table.svg b/toonz/sources/toonz/icons/dark/actions/16/table.svg new file mode 100644 index 0000000..caa347b --- /dev/null +++ b/toonz/sources/toonz/icons/dark/actions/16/table.svg @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/toonz/sources/toonz/icons/dark/actions/18/.svg b/toonz/sources/toonz/icons/dark/actions/18/.svg deleted file mode 100644 index f7ad3c7..0000000 --- a/toonz/sources/toonz/icons/dark/actions/18/.svg +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/toonz/sources/toonz/icons/dark/index.theme b/toonz/sources/toonz/icons/dark/index.theme deleted file mode 100644 index d38bc9a..0000000 --- a/toonz/sources/toonz/icons/dark/index.theme +++ /dev/null @@ -1,62 +0,0 @@ -[Icon Theme] -Name=dark -Comment=a dark icon set for use in light themes -Inherits=light - -Directories=actions/11,actions/15,actions/16,actions/18,actions/20,actions/30,actions/35,actions/48,actions/60,actions/74,console/20,tools/18,tools/20,devices/20 - -[actions/11] -Size=11 -Type=Scalable - -[actions/15] -Size=15 -Type=Scalable - -[actions/16] -Size=16 -Type=Scalable - -[actions/18] -Size=18 -Type=Scalable - -[actions/20] -Size=20 -Type=Scalable - -[actions/30] -Size=30 -Type=Scalable - -[actions/35] -Size=35 -Type=Scalable - -[actions/48] -Size=48 -Type=Scalable - -[actions/60] -Size=60 -Type=Scalable - -[actions/74] -Size=74 -Type=Scalable - -[console/20] -Size=20 -Type=Scalable - -[tools/18] -Size=18 -Type=Scalabe - -[tools/20] -Size=20 -Type=Scalabe - -[devices/20] -Size=20 -Type=Scalable diff --git a/toonz/sources/toonz/icons/dark/mimetypes/60/audio_icon.svg b/toonz/sources/toonz/icons/dark/mimetypes/60/audio_icon.svg deleted file mode 100644 index 1af6f27..0000000 --- a/toonz/sources/toonz/icons/dark/mimetypes/60/audio_icon.svg +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/toonz/sources/toonz/icons/dark/mimetypes/60/broken_icon.svg b/toonz/sources/toonz/icons/dark/mimetypes/60/broken_icon.svg deleted file mode 100644 index 97397c7..0000000 --- a/toonz/sources/toonz/icons/dark/mimetypes/60/broken_icon.svg +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - diff --git a/toonz/sources/toonz/icons/dark/mimetypes/60/cleanup_icon.svg b/toonz/sources/toonz/icons/dark/mimetypes/60/cleanup_icon.svg deleted file mode 100644 index d8a4b16..0000000 --- a/toonz/sources/toonz/icons/dark/mimetypes/60/cleanup_icon.svg +++ /dev/null @@ -1,67 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/toonz/sources/toonz/icons/dark/mimetypes/60/curve_icon.svg b/toonz/sources/toonz/icons/dark/mimetypes/60/curve_icon.svg deleted file mode 100644 index 8c82f98..0000000 --- a/toonz/sources/toonz/icons/dark/mimetypes/60/curve_icon.svg +++ /dev/null @@ -1,59 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/toonz/sources/toonz/icons/dark/mimetypes/60/json_icon.svg b/toonz/sources/toonz/icons/dark/mimetypes/60/json_icon.svg deleted file mode 100644 index e9d83f3..0000000 --- a/toonz/sources/toonz/icons/dark/mimetypes/60/json_icon.svg +++ /dev/null @@ -1,110 +0,0 @@ - -image/svg+xml - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/toonz/sources/toonz/icons/dark/mimetypes/60/missing_icon.svg b/toonz/sources/toonz/icons/dark/mimetypes/60/missing_icon.svg deleted file mode 100644 index 925f318..0000000 --- a/toonz/sources/toonz/icons/dark/mimetypes/60/missing_icon.svg +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/toonz/sources/toonz/icons/dark/mimetypes/60/motionpath_icon.svg b/toonz/sources/toonz/icons/dark/mimetypes/60/motionpath_icon.svg deleted file mode 100644 index 609c264..0000000 --- a/toonz/sources/toonz/icons/dark/mimetypes/60/motionpath_icon.svg +++ /dev/null @@ -1,59 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/toonz/sources/toonz/icons/dark/mimetypes/60/psd_icon.svg b/toonz/sources/toonz/icons/dark/mimetypes/60/psd_icon.svg deleted file mode 100644 index 9aa9524..0000000 --- a/toonz/sources/toonz/icons/dark/mimetypes/60/psd_icon.svg +++ /dev/null @@ -1,62 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/toonz/sources/toonz/icons/dark/mimetypes/60/script_icon.svg b/toonz/sources/toonz/icons/dark/mimetypes/60/script_icon.svg deleted file mode 100644 index 651a4c8..0000000 --- a/toonz/sources/toonz/icons/dark/mimetypes/60/script_icon.svg +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/toonz/sources/toonz/icons/dark/mimetypes/60/svg_icon.svg b/toonz/sources/toonz/icons/dark/mimetypes/60/svg_icon.svg deleted file mode 100644 index 776c80e..0000000 --- a/toonz/sources/toonz/icons/dark/mimetypes/60/svg_icon.svg +++ /dev/null @@ -1,71 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/toonz/sources/toonz/icons/dark/mimetypes/60/tasklist_icon.svg b/toonz/sources/toonz/icons/dark/mimetypes/60/tasklist_icon.svg deleted file mode 100644 index 22cadeb..0000000 --- a/toonz/sources/toonz/icons/dark/mimetypes/60/tasklist_icon.svg +++ /dev/null @@ -1,73 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/toonz/sources/toonz/icons/dark/mimetypes/60/unknown_icon.svg b/toonz/sources/toonz/icons/dark/mimetypes/60/unknown_icon.svg deleted file mode 100644 index 69c008f..0000000 --- a/toonz/sources/toonz/icons/dark/mimetypes/60/unknown_icon.svg +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - diff --git a/toonz/sources/toonz/icons/dark/mimetypes/60/xdts_icon.svg b/toonz/sources/toonz/icons/dark/mimetypes/60/xdts_icon.svg deleted file mode 100644 index 769ed59..0000000 --- a/toonz/sources/toonz/icons/dark/mimetypes/60/xdts_icon.svg +++ /dev/null @@ -1,107 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/toonz/sources/toonz/icons/dark/mimetypes/audio_icon.svg b/toonz/sources/toonz/icons/dark/mimetypes/audio_icon.svg new file mode 100644 index 0000000..85ef8b3 --- /dev/null +++ b/toonz/sources/toonz/icons/dark/mimetypes/audio_icon.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/toonz/sources/toonz/icons/dark/mimetypes/broken_icon.svg b/toonz/sources/toonz/icons/dark/mimetypes/broken_icon.svg new file mode 100644 index 0000000..86591a2 --- /dev/null +++ b/toonz/sources/toonz/icons/dark/mimetypes/broken_icon.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/toonz/sources/toonz/icons/dark/mimetypes/cleanup_icon.svg b/toonz/sources/toonz/icons/dark/mimetypes/cleanup_icon.svg new file mode 100644 index 0000000..e6aa48d --- /dev/null +++ b/toonz/sources/toonz/icons/dark/mimetypes/cleanup_icon.svg @@ -0,0 +1,11 @@ + + + + + + + + + CLN + + diff --git a/toonz/sources/toonz/icons/dark/mimetypes/curve_icon.svg b/toonz/sources/toonz/icons/dark/mimetypes/curve_icon.svg new file mode 100644 index 0000000..0da5e11 --- /dev/null +++ b/toonz/sources/toonz/icons/dark/mimetypes/curve_icon.svg @@ -0,0 +1,16 @@ + + + + + + + + + CURVE + + + + + + + diff --git a/toonz/sources/toonz/icons/dark/mimetypes/json_icon.svg b/toonz/sources/toonz/icons/dark/mimetypes/json_icon.svg new file mode 100644 index 0000000..9b05c29 --- /dev/null +++ b/toonz/sources/toonz/icons/dark/mimetypes/json_icon.svg @@ -0,0 +1,13 @@ + + + + + + + + + JSON + + + + diff --git a/toonz/sources/toonz/icons/dark/mimetypes/missing_icon.svg b/toonz/sources/toonz/icons/dark/mimetypes/missing_icon.svg new file mode 100644 index 0000000..a0d39a2 --- /dev/null +++ b/toonz/sources/toonz/icons/dark/mimetypes/missing_icon.svg @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/toonz/sources/toonz/icons/dark/mimetypes/motionpath_icon.svg b/toonz/sources/toonz/icons/dark/mimetypes/motionpath_icon.svg new file mode 100644 index 0000000..870566a --- /dev/null +++ b/toonz/sources/toonz/icons/dark/mimetypes/motionpath_icon.svg @@ -0,0 +1,13 @@ + + + + + + + + + MPATH + + + + diff --git a/toonz/sources/toonz/icons/dark/mimetypes/psd_icon.svg b/toonz/sources/toonz/icons/dark/mimetypes/psd_icon.svg new file mode 100644 index 0000000..4eab0fa --- /dev/null +++ b/toonz/sources/toonz/icons/dark/mimetypes/psd_icon.svg @@ -0,0 +1,22 @@ + + + + + + + + + PSD + + + + + + + + + + + + + diff --git a/toonz/sources/toonz/icons/dark/mimetypes/script_icon.svg b/toonz/sources/toonz/icons/dark/mimetypes/script_icon.svg new file mode 100644 index 0000000..d4f1e48 --- /dev/null +++ b/toonz/sources/toonz/icons/dark/mimetypes/script_icon.svg @@ -0,0 +1,11 @@ + + + + + + + + + JS + + diff --git a/toonz/sources/toonz/icons/dark/mimetypes/svg_icon.svg b/toonz/sources/toonz/icons/dark/mimetypes/svg_icon.svg new file mode 100644 index 0000000..fc0d8f7 --- /dev/null +++ b/toonz/sources/toonz/icons/dark/mimetypes/svg_icon.svg @@ -0,0 +1,13 @@ + + + + + + + + + SVG + + + + diff --git a/toonz/sources/toonz/icons/dark/mimetypes/tasklist_icon.svg b/toonz/sources/toonz/icons/dark/mimetypes/tasklist_icon.svg new file mode 100644 index 0000000..a6a421d --- /dev/null +++ b/toonz/sources/toonz/icons/dark/mimetypes/tasklist_icon.svg @@ -0,0 +1,26 @@ + + + + + + + + + TNZBAT + + + + + + + + + + + + + + + + + diff --git a/toonz/sources/toonz/icons/dark/mimetypes/unknown_icon.svg b/toonz/sources/toonz/icons/dark/mimetypes/unknown_icon.svg new file mode 100644 index 0000000..0de22a0 --- /dev/null +++ b/toonz/sources/toonz/icons/dark/mimetypes/unknown_icon.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/toonz/sources/toonz/icons/dark/mimetypes/xdts_icong.svg b/toonz/sources/toonz/icons/dark/mimetypes/xdts_icong.svg new file mode 100644 index 0000000..5416416 --- /dev/null +++ b/toonz/sources/toonz/icons/dark/mimetypes/xdts_icong.svg @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/toonz/sources/toonz/icons/dark/misc/opentoonz_logo.svg b/toonz/sources/toonz/icons/dark/misc/opentoonz_logo.svg new file mode 100644 index 0000000..6f4c6f0 --- /dev/null +++ b/toonz/sources/toonz/icons/dark/misc/opentoonz_logo.svg @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/toonz/sources/toonz/icons/dark/misc/startup.png b/toonz/sources/toonz/icons/dark/misc/startup.png deleted file mode 100644 index 9a54126..0000000 Binary files a/toonz/sources/toonz/icons/dark/misc/startup.png and /dev/null differ diff --git a/toonz/sources/toonz/icons/light/index.theme b/toonz/sources/toonz/icons/light/index.theme deleted file mode 100644 index 03245f7..0000000 --- a/toonz/sources/toonz/icons/light/index.theme +++ /dev/null @@ -1,66 +0,0 @@ -[Icon Theme] -Name=light -Comment=a light icon set for use in dark themes -Inherits=dark - -Directories=actions/11,actions/15,actions/16,actions/18,actions/20,actions/30,actions/35,actions/48,actions/60,actions/74,console/20,tools/18,tools/20,devices/20 - -[actions/11] -Size=11 -Type=Scalable - -[actions/15] -Size=15 -Type=Scalable - -[actions/16] -Size=16 -Type=Scalable - -[actions/18] -Size=18 -Type=Scalable - -[actions/20] -Size=20 -Type=Scalable - -[actions/30] -Size=30 -Type=Scalable - -[actions/35] -Size=35 -Type=Scalable - -[actions/48] -Size=48 -Type=Scalable - -[actions/60] -Size=60 -Type=Scalable - -[actions/74] -Size=74 -Type=Scalable - -[console/20] -Size=20 -Type=Scalable - -[tools/18] -Size=18 -Type=Scalabe - -[tools/20] -Size=20 -Type=Scalabe - -[devices/20] -Size=20 -Type=Scalable - -[mimetypes/60] -Size=60 -Type=Scalable diff --git a/toonz/sources/toonz/icons/light/misc/startup.png b/toonz/sources/toonz/icons/light/misc/startup.png deleted file mode 100644 index 8a5e602..0000000 Binary files a/toonz/sources/toonz/icons/light/misc/startup.png and /dev/null differ diff --git a/toonz/sources/toonz/layerfooterpanel.cpp b/toonz/sources/toonz/layerfooterpanel.cpp index 660444f..e424e19 100644 --- a/toonz/sources/toonz/layerfooterpanel.cpp +++ b/toonz/sources/toonz/layerfooterpanel.cpp @@ -84,17 +84,13 @@ void LayerFooterPanel::paintEvent(QPaintEvent *event) { QRect sliderObjRect = o->rect(PredefinedRect::ZOOM_SLIDER); m_frameZoomSlider->setGeometry(sliderObjRect); - static QPixmap zoomIn = - recolorPixmap(svgToPixmap(getIconThemePath("actions/15/zoom_in.svg"))); - static QPixmap zoomInRollover = recolorPixmap( - svgToPixmap(getIconThemePath("actions/15/zoom_in_rollover.svg"))); - const QRect zoomInImgRect = o->rect(PredefinedRect::ZOOM_IN); - - static QPixmap zoomOut = - recolorPixmap(svgToPixmap(getIconThemePath("actions/15/zoom_out.svg"))); - static QPixmap zoomOutRollover = recolorPixmap( - svgToPixmap(getIconThemePath("actions/15/zoom_out_rollover.svg"))); - const QRect zoomOutImgRect = o->rect(PredefinedRect::ZOOM_OUT); + static QPixmap zoomIn = generateIconPixmap("zoom_in"); + static QPixmap zoomInRollover = generateIconPixmap("zoom_in_rollover"); + const QRect zoomInImgRect = o->rect(PredefinedRect::ZOOM_IN); + + static QPixmap zoomOut = generateIconPixmap("zoom_out"); + static QPixmap zoomOutRollover = generateIconPixmap("zoom_out_rollover"); + const QRect zoomOutImgRect = o->rect(PredefinedRect::ZOOM_OUT); p.setRenderHint(QPainter::SmoothPixmapTransform, true); if (m_zoomInHighlighted) diff --git a/toonz/sources/toonz/layerheaderpanel.cpp b/toonz/sources/toonz/layerheaderpanel.cpp index b188fb6..84564d2 100644 --- a/toonz/sources/toonz/layerheaderpanel.cpp +++ b/toonz/sources/toonz/layerheaderpanel.cpp @@ -2,6 +2,7 @@ #include #include +#include #include "xsheetviewer.h" #include "xshcolumnviewer.h" @@ -12,200 +13,80 @@ #include "toonz/tobjecthandle.h" #include "toonz/preferences.h" +#include "../include/toonzqt/gutil.h" using XsheetGUI::ColumnArea; LayerHeaderPanel::LayerHeaderPanel(XsheetViewer *viewer, QWidget *parent, Qt::WindowFlags flags) : QWidget(parent, flags), m_viewer(viewer) { - const Orientation *o = Orientations::leftToRight(); - QRect rect = o->rect(PredefinedRect::LAYER_HEADER_PANEL); - + QHBoxLayout *layout = new QHBoxLayout(this); setObjectName("layerHeaderPanel"); - setFixedSize(rect.size()); - setMouseTracking(true); -} - -LayerHeaderPanel::~LayerHeaderPanel() {} - -namespace { - -QColor mix(const QColor &a, const QColor &b, double w) { - return QColor(a.red() * w + b.red() * (1 - w), - a.green() * w + b.green() * (1 - w), - a.blue() * w + b.blue() * (1 - w)); -} - -QColor withAlpha(const QColor &color, double alpha) { - QColor result(color); - result.setAlpha(alpha * 255); - return result; -} - -QRect shorter(const QRect original) { return original.adjusted(0, 2, 0, -2); } - -QLine leftSide(const QRect &r) { return QLine(r.topLeft(), r.bottomLeft()); } - -QLine rightSide(const QRect &r) { return QLine(r.topRight(), r.bottomRight()); } -} // namespace - -void LayerHeaderPanel::paintEvent(QPaintEvent *event) { - QPainter p(this); - p.setRenderHint(QPainter::SmoothPixmapTransform, true); - - const Orientation *o = Orientations::leftToRight(); - - QImage preview = (m_buttonHighlighted == PreviewButton - ? m_viewer->getLayerHeaderPreviewOverImage() - : m_viewer->getLayerHeaderPreviewImage()); - QImage camstand = (m_buttonHighlighted == CamstandButton - ? m_viewer->getLayerHeaderCamstandOverImage() - : m_viewer->getLayerHeaderCamstandImage()); - QImage lock = (m_buttonHighlighted == LockButton - ? m_viewer->getLayerHeaderLockOverImage() - : m_viewer->getLayerHeaderLockImage()); - - drawIcon(p, PredefinedRect::PANEL_EYE, boost::none, preview); - if (!Preferences::instance()->isUnifyColumnVisibilityTogglesEnabled()) - drawIcon(p, PredefinedRect::PANEL_PREVIEW_LAYER, boost::none, camstand); - drawIcon(p, PredefinedRect::PANEL_LOCK, boost::none, lock); -} - -void LayerHeaderPanel::drawIcon(QPainter &p, PredefinedRect rect, - optional fill, - const QImage &image) const { - QRect iconRect = - Orientations::leftToRight()->rect(rect).adjusted(-2, 0, -2, 0); - - if (fill) p.fillRect(iconRect, *fill); - p.drawImage(iconRect, image); -} - -void LayerHeaderPanel::drawLines(QPainter &p, const QRect &numberRect, - const QRect &nameRect) const { - p.setPen(withAlpha(m_viewer->getTextColor(), 0.5)); - - QLine line = {leftSide(shorter(numberRect)).translated(-2, 0)}; - p.drawLine(line); - - if (Preferences::instance()->isShowColumnNumbersEnabled()) { - line = rightSide(shorter(numberRect)).translated(-2, 0); - p.drawLine(line); + layout->setContentsMargins(0, 0, 0, 0); + layout->setSpacing(0); + + m_previewButton = new QToolButton(this); + m_camstandButton = new QToolButton(this); + m_lockButton = new QToolButton(this); + + // Define style and icon size for all buttons + QString buttonStyleSheet = + "QToolButton { padding: 0px; margin: 0px; }"; + QSize iconSize(16, 16); + QSize buttonSize(20, 20); + + QList buttonList = {m_previewButton, m_camstandButton, + m_lockButton}; + + for (auto &button : buttonList) { + button->setStyleSheet(buttonStyleSheet); + button->setIconSize(iconSize); + button->setFixedSize(buttonSize); } - - line = rightSide(shorter(nameRect)); - p.drawLine(line); + + m_previewButton->setIcon(createQIcon("preview")); + m_camstandButton->setIcon(createQIcon("table")); + m_lockButton->setIcon(createQIcon("lock_on")); + + connect(m_previewButton, &QToolButton::clicked, this, + &LayerHeaderPanel::onPreviewClicked); + connect(m_camstandButton, &QToolButton::clicked, this, + &LayerHeaderPanel::onCamstandClicked); + connect(m_lockButton, &QToolButton::clicked, this, + &LayerHeaderPanel::onLockClicked); + + // Add widgets to the layout + layout->addWidget(m_previewButton); + layout->addWidget(m_camstandButton); + layout->addWidget(m_lockButton); + layout->addStretch(); + + setLayout(layout); } -void LayerHeaderPanel::showOrHide(const Orientation *o) { - QRect rect = o->rect(PredefinedRect::LAYER_HEADER_PANEL); - if (rect.isEmpty()) - hide(); - else - show(); -} - -//----------------------------------------------------------------------------- -void LayerHeaderPanel::enterEvent(QEvent *) { - m_buttonHighlighted = NoButton; - - update(); -} - -void LayerHeaderPanel::leaveEvent(QEvent *) { - m_buttonHighlighted = NoButton; - - update(); -} - -void LayerHeaderPanel::mousePressEvent(QMouseEvent *event) { - const Orientation *o = Orientations::leftToRight(); - - m_doOnRelease = 0; - - if (event->button() == Qt::LeftButton) { - // get mouse position - QPoint pos = event->pos(); - - // preview button - if (o->rect(PredefinedRect::EYE_AREA).contains(pos)) { - m_doOnRelease = ToggleAllPreviewVisible; - } - // camstand button - else if (o->rect(PredefinedRect::PREVIEW_LAYER_AREA).contains(pos)) { - m_doOnRelease = ToggleAllTransparency; - } - // lock button - else if (o->rect(PredefinedRect::LOCK_AREA).contains(pos)) { - m_doOnRelease = ToggleAllLock; - } - } - - update(); -} - -void LayerHeaderPanel::mouseMoveEvent(QMouseEvent *event) { - const Orientation *o = Orientations::leftToRight(); - - QPoint pos = event->pos(); - m_buttonHighlighted = NoButton; - - // preview button - if (o->rect(PredefinedRect::EYE_AREA).contains(pos)) { - m_tooltip = tr("Preview Visibility Toggle All"); - m_buttonHighlighted = PreviewButton; - } - // camstand button - else if (o->rect(PredefinedRect::PREVIEW_LAYER_AREA).contains(pos)) { - m_tooltip = tr("Camera Stand Visibility Toggle All"); - m_buttonHighlighted = CamstandButton; - } - // lock button - else if (o->rect(PredefinedRect::LOCK).contains(pos)) { - m_tooltip = tr("Lock Toggle All"); - m_buttonHighlighted = LockButton; - } else { - m_tooltip = tr(""); - } - - m_pos = pos; - - update(); -} - -//----------------------------------------------------------------------------- - -bool LayerHeaderPanel::event(QEvent *event) { - if (event->type() == QEvent::ToolTip) { - if (!m_tooltip.isEmpty()) - QToolTip::showText(mapToGlobal(m_pos), m_tooltip); - else - QToolTip::hideText(); - } - return QWidget::event(event); -} +LayerHeaderPanel::~LayerHeaderPanel() {} //----------------------------------------------------------------------------- -void LayerHeaderPanel::mouseReleaseEvent(QMouseEvent *event) { +void LayerHeaderPanel::toggleColumnVisibility(int visibilityFlag) { TApp *app = TApp::instance(); TXsheet *xsh = m_viewer->getXsheet(); int col, totcols = xsh->getColumnCount(); bool sound_changed = false; - if (m_doOnRelease != 0 && totcols > 0) { + if (totcols > 0) { int startCol = Preferences::instance()->isXsheetCameraColumnVisible() ? -1 : 0; for (col = startCol; col < totcols; col++) { if (startCol < 0 || !xsh->isColumnEmpty(col)) { TXshColumn *column = xsh->getColumn(col); - if (m_doOnRelease == ToggleAllPreviewVisible) { + if (visibilityFlag == ToggleAllPreviewVisible) { column->setPreviewVisible(!column->isPreviewVisible()); - } else if (m_doOnRelease == ToggleAllTransparency) { + } else if (visibilityFlag == ToggleAllTransparency) { column->setCamstandVisible(!column->isCamstandVisible()); if (column->getSoundColumn()) sound_changed = true; - } else if (m_doOnRelease == ToggleAllLock) { + } else if (visibilityFlag == ToggleAllLock) { column->lock(!column->isLocked()); } } @@ -220,5 +101,28 @@ void LayerHeaderPanel::mouseReleaseEvent(QMouseEvent *event) { } m_viewer->updateColumnArea(); update(); - m_doOnRelease = 0; +} + +//----------------------------------------------------------------------------- + +void LayerHeaderPanel::onPreviewClicked() { + toggleColumnVisibility(ToggleAllPreviewVisible); +} + +void LayerHeaderPanel::onCamstandClicked() { + toggleColumnVisibility(ToggleAllTransparency); +} + +void LayerHeaderPanel::onLockClicked() { + toggleColumnVisibility(ToggleAllLock); +} + +//----------------------------------------------------------------------------- + +void LayerHeaderPanel::showOrHide(const Orientation *o) { + QRect rect = o->rect(PredefinedRect::LAYER_HEADER_PANEL); + if (rect.isEmpty()) + hide(); + else + show(); } diff --git a/toonz/sources/toonz/layerheaderpanel.h b/toonz/sources/toonz/layerheaderpanel.h index 110fa5c..926b6a8 100644 --- a/toonz/sources/toonz/layerheaderpanel.h +++ b/toonz/sources/toonz/layerheaderpanel.h @@ -4,6 +4,7 @@ #define LAYER_HEADER_PANEL_INCLUDED #include +#include #include #include "orientation.h" @@ -18,38 +19,27 @@ class LayerHeaderPanel final : public QWidget { enum { ToggleAllTransparency = 1, ToggleAllPreviewVisible, ToggleAllLock }; - enum { NoButton, PreviewButton, CamstandButton, LockButton }; +public: + void toggleColumnVisibility(int visibilityFlag); - int m_doOnRelease; - QString m_tooltip; - QPoint m_pos; - int m_buttonHighlighted; + QToolButton *m_previewButton; + QToolButton *m_camstandButton; + QToolButton *m_lockButton; private: XsheetViewer *m_viewer; public: - LayerHeaderPanel(XsheetViewer *viewer, QWidget *parent = 0, - Qt::WindowFlags flags = 0); + LayerHeaderPanel(XsheetViewer *viewer, QWidget *parent = nullptr, + Qt::WindowFlags flags = Qt::WindowFlags()); ~LayerHeaderPanel(); void showOrHide(const Orientation *o); -protected: - void paintEvent(QPaintEvent *event) override; - - void mousePressEvent(QMouseEvent *event) override; - void mouseMoveEvent(QMouseEvent *event) override; - void mouseReleaseEvent(QMouseEvent *event) override; - void enterEvent(QEvent *) override; - void leaveEvent(QEvent *) override; - bool event(QEvent *event) override; - -private: - void drawIcon(QPainter &p, PredefinedRect rect, optional fill, - const QImage &image) const; - void drawLines(QPainter &p, const QRect &numberRect, - const QRect &nameRect) const; +public slots: + void onPreviewClicked(); + void onCamstandClicked(); + void onLockClicked(); }; -#endif +#endif \ No newline at end of file diff --git a/toonz/sources/toonz/main.cpp b/toonz/sources/toonz/main.cpp index b7dc6fe..68671ba 100644 --- a/toonz/sources/toonz/main.cpp +++ b/toonz/sources/toonz/main.cpp @@ -256,6 +256,9 @@ int main(int argc, char *argv[]) { } #endif + // Build icon map + ThemeManager::getInstance().buildIconPathsMap(":/icons"); + // Install signal handlers to catch crashes CrashHandler::install(); @@ -410,6 +413,7 @@ int main(int argc, char *argv[]) { #endif #ifdef _WIN32 + // BUG_WORKAROUND: #20230627 // This attribute is set to make menubar icon to be always (16 x devPixRatio). // Without this attribute the menu bar icon size becomes the same as tool bar // when Windows scale is in 125%. Currently hiding the menu bar icon is done @@ -435,11 +439,6 @@ int main(int argc, char *argv[]) { } #endif - // Set icon theme search paths - QStringList themeSearchPathsList = {":/icons"}; - QIcon::setThemeSearchPaths(themeSearchPathsList); - // qDebug() << "All icon theme search paths:" << QIcon::themeSearchPaths(); - // Set show icons in menus flag (use iconVisibleInMenu to disable selectively) QApplication::instance()->setAttribute(Qt::AA_DontShowIconsInMenus, false); @@ -621,11 +620,6 @@ int main(int argc, char *argv[]) { Qt::white); a.processEvents(); - // Set default start icon theme - QIcon::setThemeName(Preferences::instance()->getIconTheme() ? "dark" - : "light"); - // qDebug() << "Icon theme name:" << QIcon::themeName(); - // stile QApplication::setStyle("windows"); diff --git a/toonz/sources/toonz/mainwindow.cpp b/toonz/sources/toonz/mainwindow.cpp index 505a8b2..821c8df 100644 --- a/toonz/sources/toonz/mainwindow.cpp +++ b/toonz/sources/toonz/mainwindow.cpp @@ -1408,6 +1408,7 @@ QAction *MainWindow::createAction(const char *id, const char *name, action->setIconVisibleInMenu(visible); #endif + // BUG_WORKAROUND: #20230627 // In Qt5.15.2 - Windows, QMenu stylesheet has alignment issue when one item // has icon and another has not one. (See // https://bugreports.qt.io/browse/QTBUG-90242 for details.) To avoid the @@ -1611,11 +1612,15 @@ QAction *MainWindow::createMiscAction(const char *id, const char *name, //----------------------------------------------------------------------------- QAction *MainWindow::createToolOptionsAction(const char *id, const char *name, - const QString &defaultShortcut) { + const QString &defaultShortcut, + const char *iconSVGName) { QAction *action = new DVAction(tr(name), this); + if (iconSVGName && *iconSVGName) + action->setIcon(createQIcon(iconSVGName, false, true)); addAction(action); CommandManager::instance()->define(id, ToolModifierCommandType, - defaultShortcut.toStdString(), action); + defaultShortcut.toStdString(), action, + iconSVGName); return action; } @@ -1950,7 +1955,7 @@ void MainWindow::defineActions() { createMenuXsheetAction(MI_MergeColumns, QT_TR_NOOP("&Merge Levels"), "", "merge_levels"); createMenuXsheetAction(MI_InsertFx, QT_TR_NOOP("&New FX..."), "Ctrl+F", - "fx_new"); + "fx_logo"); createMenuXsheetAction(MI_NewOutputFx, QT_TR_NOOP("&New Output"), "Alt+O", "output"); createMenuXsheetAction(MI_InsertSceneFrame, QT_TR_NOOP("Insert Frame"), "", @@ -2170,8 +2175,7 @@ void MainWindow::defineActions() { createMenuWindowsAction(MI_OpenFileBrowser, QT_TR_NOOP("&File Browser"), "", "filebrowser"); createMenuWindowsAction(MI_OpenPreproductionBoard, - QT_TR_NOOP("&Preproduction Board"), "", - "scenebrowser"); + QT_TR_NOOP("&Preproduction Board"), "", ""); createMenuWindowsAction(MI_OpenFileViewer, QT_TR_NOOP("&Flipbook"), "", "flipbook"); createMenuWindowsAction(MI_OpenFunctionEditor, QT_TR_NOOP("&Function Editor"), @@ -2476,7 +2480,8 @@ void MainWindow::defineActions() { createToolAction(T_Plastic, "plastic", QT_TR_NOOP("Plastic Tool"), "X"); createToolAction(T_Ruler, "ruler", QT_TR_NOOP("Ruler Tool"), ""); createToolAction(T_Finger, "finger", QT_TR_NOOP("Finger Tool"), ""); - createToolAction(T_EditAssistants, "assistant", QT_TR_NOOP("Edit Assistants"), ""); + createToolAction(T_EditAssistants, "assistant", QT_TR_NOOP("Edit Assistants"), + ""); /*-- Animate tool + mode switching shortcuts --*/ createAction(MI_EditNextMode, QT_TR_NOOP("Animate Tool - Next Mode"), "", @@ -2756,15 +2761,13 @@ void MainWindow::defineActions() { createToolOptionsAction("A_ToolOption_GeometricEdge", QT_TR_NOOP("Geometric Edge"), ""); createToolOptionsAction("A_ToolOption_Mode", QT_TR_NOOP("Mode"), ""); - menuAct = createToolOptionsAction("A_ToolOption_Mode:Areas", - QT_TR_NOOP("Mode - Areas"), ""); - menuAct->setIcon(createQIcon("mode_areas")); - menuAct = createToolOptionsAction("A_ToolOption_Mode:Lines", - QT_TR_NOOP("Mode - Lines"), ""); - menuAct->setIcon(createQIcon("mode_lines")); + menuAct = createToolOptionsAction( + "A_ToolOption_Mode:Areas", QT_TR_NOOP("Mode - Areas"), "", "mode_areas"); + menuAct = createToolOptionsAction( + "A_ToolOption_Mode:Lines", QT_TR_NOOP("Mode - Lines"), "", "mode_lines"); menuAct = createToolOptionsAction("A_ToolOption_Mode:Lines & Areas", - QT_TR_NOOP("Mode - Lines && Areas"), ""); - menuAct->setIcon(createQIcon("mode_areas_lines")); + QT_TR_NOOP("Mode - Lines && Areas"), "", + "mode_areas_lines"); createToolOptionsAction("A_ToolOption_Mode:Endpoint to Endpoint", QT_TR_NOOP("Mode - Endpoint to Endpoint"), ""); createToolOptionsAction("A_ToolOption_Mode:Endpoint to Line", @@ -2773,29 +2776,24 @@ void MainWindow::defineActions() { QT_TR_NOOP("Mode - Line to Line"), ""); createToolOptionsAction("A_ToolOption_Type", QT_TR_NOOP("Type"), ""); - menuAct = createToolOptionsAction("A_ToolOption_Type:Normal", - QT_TR_NOOP("Type - Normal"), ""); - menuAct->setIcon(createQIcon("type_normal")); - + menuAct = + createToolOptionsAction("A_ToolOption_Type:Normal", + QT_TR_NOOP("Type - Normal"), "", "type_normal"); menuAct = createToolOptionsAction("A_ToolOption_Type:Rectangular", - QT_TR_NOOP("Type - Rectangular"), "F5"); - menuAct->setIcon(createQIcon("type_rectangular")); - - menuAct = createToolOptionsAction("A_ToolOption_Type:Freehand", - QT_TR_NOOP("Type - Freehand"), ""); - menuAct->setIcon(createQIcon("type_lasso")); - + QT_TR_NOOP("Type - Rectangular"), "F5", + "type_rectangular"); + menuAct = + createToolOptionsAction("A_ToolOption_Type:Freehand", + QT_TR_NOOP("Type - Freehand"), "", "type_lasso"); menuAct = createToolOptionsAction("A_ToolOption_Type:Polyline", - QT_TR_NOOP("Type - Polyline"), ""); - menuAct->setIcon(createQIcon("type_polyline")); - + QT_TR_NOOP("Type - Polyline"), "", + "type_polyline"); menuAct = createToolOptionsAction("A_ToolOption_Type:Freepick", - QT_TR_NOOP("Type - Pick+Freehand"), ""); - menuAct->setIcon(createQIcon("type_pickerlasso")); - + QT_TR_NOOP("Type - Pick+Freehand"), "", + "type_pickerlasso"); menuAct = createToolOptionsAction("A_ToolOption_Type:Segment", - QT_TR_NOOP("Type - Segment"), ""); - menuAct->setIcon(createQIcon("type_erase_segment")); + QT_TR_NOOP("Type - Segment"), "", + "type_erase_segment"); createToolOptionsAction("A_ToolOption_TypeFont", QT_TR_NOOP("TypeTool Font"), ""); @@ -2854,7 +2852,7 @@ void MainWindow::defineActions() { menuAct = createToolOptionsAction("A_ToolOption_AutopaintLines", QT_TR_NOOP("Fill Tool - Autopaint Lines"), ""); - menuAct->setIcon(createQIcon("fill_auto")); + menuAct->setIcon(createQIcon("toggle_autofill")); createToolOptionsAction("A_ToolOption_FlipHorizontal", QT_TR_NOOP("Flip Selection/Object Horizontally"), ""); @@ -2911,9 +2909,9 @@ void MainWindow::defineActions() { createVisualizationButtonAction( VB_ActualPixelSize, QT_TR_NOOP("Actual Pixel Size"), "actual_pixel_size"); createVisualizationButtonAction( - VB_FlipX, QT_TR_NOOP("Flip Viewer Horizontally"), "fliphoriz_off"); + VB_FlipX, QT_TR_NOOP("Flip Viewer Horizontally"), "fliphoriz"); createVisualizationButtonAction( - VB_FlipY, QT_TR_NOOP("Flip Viewer Vertically"), "flipvert_off"); + VB_FlipY, QT_TR_NOOP("Flip Viewer Vertically"), "flipvert"); // Misc @@ -2926,7 +2924,6 @@ void MainWindow::defineActions() { menuAct = createMiscAction(MI_RefreshTree, QT_TR_NOOP("Refresh Folder Tree"), ""); menuAct->setIconText(tr("Refresh")); - menuAct->setIcon(createQIcon("refresh", false, true)); createMiscAction("A_FxSchematicToggle", QT_TR_NOOP("Toggle FX/Stage schematic"), ""); diff --git a/toonz/sources/toonz/mainwindow.h b/toonz/sources/toonz/mainwindow.h index f85d5c6..b7ecd87 100644 --- a/toonz/sources/toonz/mainwindow.h +++ b/toonz/sources/toonz/mainwindow.h @@ -190,7 +190,7 @@ private: QAction *createMiscAction(const char *id, const char *name, const char *defaultShortcut); QAction *createToolOptionsAction(const char *id, const char *name, - const QString &defaultShortcut); + const QString &defaultShortcut, const char *iconSVGName = ""); QAction *createStopMotionAction(const char *id, const char *name, const QString &defaultShortcut, const char *iconSVGName = ""); diff --git a/toonz/sources/toonz/pane.cpp b/toonz/sources/toonz/pane.cpp index 43e8f5b..2b8cc93 100644 --- a/toonz/sources/toonz/pane.cpp +++ b/toonz/sources/toonz/pane.cpp @@ -246,6 +246,7 @@ TPanelTitleBarButton::TPanelTitleBarButton(QWidget *parent, , m_buttonSet(0) , m_id(0) { setFixedSize(m_standardPixmap.size()); + QMap m_pixmaps; } //----------------------------------------------------------------------------- @@ -281,26 +282,52 @@ void TPanelTitleBarButton::setPressed(bool pressed) { //----------------------------------------------------------------------------- -void TPanelTitleBarButton::paintEvent(QPaintEvent *event) { - // Set unique pressed colors if filename contains the following words: - QColor bgColor = getPressedColor(); - if (m_standardPixmapName.contains("freeze", Qt::CaseInsensitive)) +void TPanelTitleBarButton::computePixmaps(const QString &standardPixmapName) { + // Get background color used by some icons and states + QColor bgColor; + if (m_standardPixmapName.contains("freeze", Qt::CaseInsensitive)) { bgColor = getFreezeColor(); - if (m_standardPixmapName.contains("preview", Qt::CaseInsensitive)) + } else if (m_standardPixmapName.contains("preview", Qt::CaseInsensitive)) { bgColor = getPreviewColor(); + } else { + bgColor = getPressedColor(); + } - QPixmap panePixmap = recolorPixmap(svgToPixmap(m_standardPixmapName)); - QPixmap panePixmapOff = compositePixmap(panePixmap, 0.8); - QPixmap panePixmapOver = - compositePixmap(panePixmap, 1, QSize(), 0, 0, getOverColor()); - QPixmap panePixmapOn = compositePixmap(panePixmap, 1, QSize(), 0, 0, bgColor); + ThemeManager &themeManager = ThemeManager::getInstance(); + const qreal offOpacity = themeManager.getOffOpacity(); + // Compute icon + QImage baseImg = svgToImage(standardPixmapName); + baseImg = themeManager.recolorBlackPixels(baseImg); + QImage onImg = compositeImage(baseImg, QSize(), false, bgColor); + QImage offImg = adjustImageOpacity(baseImg, offOpacity); + QImage overImg = compositeImage(baseImg, QSize(), false, getOverColor()); + + // Add to cache + m_pixmaps[standardPixmapName + "_on"] = convertImageToPixmap(onImg); + m_pixmaps[standardPixmapName + "_off"] = convertImageToPixmap(offImg); + m_pixmaps[standardPixmapName + "_over"] = convertImageToPixmap(overImg); +} + +//----------------------------------------------------------------------------- + +void TPanelTitleBarButton::paintEvent(QPaintEvent *event) { + // Note: For some reason unless m_standardPixmapName is a valid path to + // something in Qt resources (.qrc) this event will fail to be called. So + // passing a string like a base name will not work, for now we must use + // absolute paths when making TPanelTitleBarButtons. + + // Compute pixmaps if cache is empty + if (!m_pixmaps.contains(m_standardPixmapName + "_off")) { + computePixmaps(m_standardPixmapName); + } + + // Use cahced pixmaps QPainter painter(this); painter.drawPixmap(0, 0, - m_pressed ? panePixmapOn - : m_rollover ? panePixmapOver - : panePixmapOff); - painter.end(); + m_pressed ? m_pixmaps[m_standardPixmapName + "_on"] + : m_rollover ? m_pixmaps[m_standardPixmapName + "_over"] + : m_pixmaps[m_standardPixmapName + "_off"]); } //----------------------------------------------------------------------------- @@ -501,6 +528,36 @@ QSize TPanelTitleBar::minimumSizeHint() const { return QSize(20, 18); } //----------------------------------------------------------------------------- +// Cache close button image +QPixmap TPanelTitleBar::getPixmap(const QString &iconSVGName, bool rollover) { + if (!m_pixmaps.contains(iconSVGName)) { + // Icon theme vars + ThemeManager &themeManager = ThemeManager::getInstance(); + const qreal offOpacity = themeManager.getOffOpacity(); + const qreal onOpacity = themeManager.getOnOpacity(); + + // Use overColor from stylesheet for bgColor of rollover + QColor overColor = getOverColor(); + + // Generate base icon image + QImage baseImg = generateIconImage("pane_close"); + baseImg = compositeImage(baseImg, QSize(20, 18)); + + // Off icon image + QImage offImg = adjustImageOpacity(baseImg, offOpacity); + + // Over icon image + QImage overImg = compositeImage(baseImg, QSize(), false, overColor); + + m_pixmaps[iconSVGName] = convertImageToPixmap(offImg); + m_pixmaps[iconSVGName + "_over"] = convertImageToPixmap(overImg); + } + + return m_pixmaps[rollover ? iconSVGName + "_over" : iconSVGName]; +} + +//----------------------------------------------------------------------------- + void TPanelTitleBar::paintEvent(QPaintEvent *) { QPainter painter(this); QRect rect = this->rect(); @@ -533,13 +590,9 @@ void TPanelTitleBar::paintEvent(QPaintEvent *) { } if (dw->isFloating()) { - QIcon paneCloseIcon = createQIcon("pane_close"); - const static QPixmap closeButtonPixmap( - paneCloseIcon.pixmap(20, 18, QIcon::Normal, QIcon::Off)); - const static QPixmap closeButtonPixmapOver( - paneCloseIcon.pixmap(20, 18, QIcon::Active)); - - QPoint closeButtonPos(rect.right() - 20, rect.top()); + QPoint closeButtonPos(rect.right() - 19, rect.top()); + QPixmap closeButtonPixmap = getPixmap("pane_close", false); + QPixmap closeButtonPixmapOver = getPixmap("pane_close", true); if (m_closeButtonHighlighted) painter.drawPixmap(closeButtonPos, closeButtonPixmapOver); @@ -552,6 +605,19 @@ void TPanelTitleBar::paintEvent(QPaintEvent *) { //----------------------------------------------------------------------------- +void TPanelTitleBar::leaveEvent(QEvent *) { + TPanel *dw = qobject_cast(parentWidget()); + Q_ASSERT(dw != 0); + + // Mouse left the widget, reset the highlighted flag + if (dw->isFloating()) { + m_closeButtonHighlighted = false; + update(); + } +} + +//----------------------------------------------------------------------------- + void TPanelTitleBar::mousePressEvent(QMouseEvent *event) { TDockWidget *dw = static_cast(parentWidget()); diff --git a/toonz/sources/toonz/pane.h b/toonz/sources/toonz/pane.h index 2e91f13..e690ef8 100644 --- a/toonz/sources/toonz/pane.h +++ b/toonz/sources/toonz/pane.h @@ -14,13 +14,22 @@ class Room; //! icon buttons placed on the panel titlebar (cfr. viewerpane.h) class TPanelTitleBarButton : public QWidget { Q_OBJECT + + // Pixmaps QString m_standardPixmapName; QPixmap m_standardPixmap; + QMap m_pixmaps; + + // Colors QColor m_overColor; QColor m_pressedColor; QColor m_freezeColor; QColor m_previewColor; + // Methods + void computePixmaps(const QString &standardPixmapName); + + // Stylesheet Q_PROPERTY(QColor OverColor READ getOverColor WRITE setOverColor); Q_PROPERTY(QColor PressedColor READ getPressedColor WRITE setPressedColor); Q_PROPERTY(QColor FreezeColor READ getFreezeColor WRITE setFreezeColor); @@ -41,6 +50,7 @@ public: void setButtonSet(TPanelTitleBarButtonSet *buttonSet, int id); int getId() const { return m_id; } + // Stylesheet void setOverColor(const QColor &color) { m_overColor = color; } QColor getOverColor() const { return m_overColor; } void setPressedColor(const QColor &color) { m_pressedColor = color; } @@ -136,7 +146,9 @@ class TPanelTitleBar final : public QFrame { std::vector> m_buttons; QPixmap m_borderPm, m_activeBorderPm, m_floatBorderPm, m_floatActiveBorderPm; - QColor m_titleColor, m_activeTitleColor; + QColor m_titleColor, m_activeTitleColor, m_overColor; + + QMap m_pixmaps; // cache public: TPanelTitleBar(QWidget *parent = 0, @@ -164,6 +176,8 @@ public: void setTitleColor(const QColor &color) { m_titleColor = color; } QColor getActiveTitleColor() const { return m_activeTitleColor; } void setActiveTitleColor(const QColor &color) { m_activeTitleColor = color; } + QColor getOverColor() const { return m_overColor; } + void setOverColor(const QColor &color) { m_overColor = color; } protected: void resizeEvent(QResizeEvent *e) override; @@ -172,10 +186,13 @@ protected: void contextMenuEvent(QContextMenuEvent *) override {} void paintEvent(QPaintEvent *event) override; + void leaveEvent(QEvent *); void mouseMoveEvent(QMouseEvent *event) override; void mousePressEvent(QMouseEvent *event) override; void mouseDoubleClickEvent(QMouseEvent *) override; + QPixmap getPixmap(const QString &iconSVGName, bool rollover); + Q_PROPERTY(QPixmap BorderPixmap READ getBorderPixmap WRITE setBorderPixmap); Q_PROPERTY(QPixmap ActiveBorderPixmap READ getActiveBorderPixmap WRITE setActiveBorderPixmap); @@ -186,6 +203,7 @@ protected: Q_PROPERTY(QColor TitleColor READ getTitleColor WRITE setTitleColor); Q_PROPERTY(QColor ActiveTitleColor READ getActiveTitleColor WRITE setActiveTitleColor); + Q_PROPERTY(QColor OverColor READ getOverColor WRITE setOverColor); signals: diff --git a/toonz/sources/toonz/preferencespopup.cpp b/toonz/sources/toonz/preferencespopup.cpp index 9e8ef56..3add117 100644 --- a/toonz/sources/toonz/preferencespopup.cpp +++ b/toonz/sources/toonz/preferencespopup.cpp @@ -504,12 +504,7 @@ void PreferencesPopup::onStyleSheetTypeChanged() { //----------------------------------------------------------------------------- -void PreferencesPopup::onIconThemeChanged() { - // Switch between dark or light icons - QIcon::setThemeName(Preferences::instance()->getIconTheme() ? "dark" - : "light"); - // qDebug() << "Icon theme name (preference switch):" << QIcon::themeName(); -} +void PreferencesPopup::onIconThemeChanged() {} //----------------------------------------------------------------------------- diff --git a/toonz/sources/toonz/projectpopup.cpp b/toonz/sources/toonz/projectpopup.cpp index fd3eecb..a2b3e0f 100644 --- a/toonz/sources/toonz/projectpopup.cpp +++ b/toonz/sources/toonz/projectpopup.cpp @@ -50,10 +50,8 @@ enum { Rule_Standard = 0, Rule_Custom }; //----------------------------------------------------------------------------- QPixmap ProjectDvDirModelProjectNode::getPixmap(bool isOpen) const { - static QPixmap openProjectPixmap( - svgToPixmap(getIconThemePath("actions/18/folder_project_on.svg"))); - static QPixmap closeProjectPixmap( - svgToPixmap(getIconThemePath("actions/18/folder_project.svg"))); + static QPixmap openProjectPixmap(generateIconPixmap("folder_project_on")); + static QPixmap closeProjectPixmap(generateIconPixmap("folder_project.svg")); return isOpen ? openProjectPixmap : closeProjectPixmap; } @@ -106,8 +104,7 @@ void ProjectDvDirModelRootNode::refreshChildren() { ProjectDvDirModelSpecialFileFolderNode *projectRootNode = new ProjectDvDirModelSpecialFileFolderNode( this, L"Project root (" + rootDir + L")", projectRoot); - projectRootNode->setPixmap( - svgToPixmap(getIconThemePath("actions/18/folder_project_root.svg"))); + projectRootNode->setPixmap(generateIconPixmap("folder_project_root")); addChild(projectRootNode); } diff --git a/toonz/sources/toonz/startuppopup.cpp b/toonz/sources/toonz/startuppopup.cpp index 410dfc3..3d93b22 100644 --- a/toonz/sources/toonz/startuppopup.cpp +++ b/toonz/sources/toonz/startuppopup.cpp @@ -169,8 +169,7 @@ StartupPopup::StartupPopup() m_removePresetBtn->setStyleSheet( "QPushButton { padding-left: 4px; padding-right: 4px;}"); QLabel *label = new QLabel(); - label->setPixmap( - QPixmap(QString(":icons/") + QIcon::themeName() + "/misc/startup.png")); + label->setPixmap(QPixmap(generateIconPixmap("opentoonz_logo"))); m_projectBox->setObjectName("SolidLineFrame"); m_scenesTab->setObjectName("SolidLineFrame"); m_recentBox->setObjectName("SolidLineFrame"); @@ -195,7 +194,7 @@ StartupPopup::StartupPopup() guiLay->setVerticalSpacing(10); guiLay->setHorizontalSpacing(10); - guiLay->addWidget(label, 0, 0, 1, 2, Qt::AlignLeft); + guiLay->addWidget(label, 0, 0, 1, 2, Qt::AlignCenter); //--- Project projectLay->setSpacing(8); @@ -297,19 +296,19 @@ StartupPopup::StartupPopup() //---- signal-slot connections bool ret = true; ret = ret && connect(sceneHandle, SIGNAL(sceneChanged()), this, - SLOT(onSceneChanged())); + SLOT(onSceneChanged())); ret = ret && connect(sceneHandle, SIGNAL(sceneSwitched()), this, - SLOT(onSceneChanged())); + SLOT(onSceneChanged())); ret = ret && connect(newProjectButton, SIGNAL(clicked()), this, - SLOT(onNewProjectButtonPressed())); + SLOT(onNewProjectButtonPressed())); ret = ret && connect(openProjectButton, SIGNAL(clicked()), this, - SLOT(onOpenProjectButtonPressed())); + SLOT(onOpenProjectButtonPressed())); ret = ret && connect(exploreProjectButton, SIGNAL(clicked()), this, - SLOT(onExploreProjectButtonPressed())); + SLOT(onExploreProjectButtonPressed())); ret = ret && connect(loadOtherSceneButton, SIGNAL(clicked()), this, - SLOT(onLoadSceneButtonPressed())); + SLOT(onLoadSceneButtonPressed())); ret = ret && connect(m_projectsCB, SIGNAL(currentIndexChanged(int)), - SLOT(onProjectChanged(int))); + SLOT(onProjectChanged(int))); ret = ret && connect(createButton, SIGNAL(clicked()), this, SLOT(onCreateButton())); ret = ret && connect(m_showAtStartCB, SIGNAL(stateChanged(int)), this, @@ -974,7 +973,7 @@ void StartupPopup::onOpenProjectButtonPressed() { void StartupPopup::onExploreProjectButtonPressed() { TProjectManager *pm = TProjectManager::instance(); - TFilePath cfp = pm->getCurrentProject()->getProjectFolder(); + TFilePath cfp = pm->getCurrentProject()->getProjectFolder(); QDesktopServices::openUrl(QUrl("file:///" + cfp.getQString())); } @@ -1038,11 +1037,11 @@ void StartupPopup::onRecentSceneClicked(int index) { IoCmd::loadScene(TFilePath(path.toStdWString()), false, true); QString origProjectName = RecentFiles::instance()->getFileProject(index); QString projectName = QString::fromStdString(TApp::instance() - ->getCurrentScene() - ->getScene() - ->getProject() - ->getName() - .getName()); + ->getCurrentScene() + ->getScene() + ->getProject() + ->getName() + .getName()); if (origProjectName == "-" || origProjectName != projectName) { QString fileName = RecentFiles::instance()->getFilePath(index, RecentFiles::Scene); @@ -1222,8 +1221,7 @@ QPixmap StartupScenesList::createScenePreview(const QString &name, painter.setPen(pen); painter.drawRect((m_iconSize.width() - scaledPixmap.width()) / 2, (m_iconSize.height() - scaledPixmap.height()) / 2, - scaledPixmap.width() - 1, - scaledPixmap.height() - 1); + scaledPixmap.width() - 1, scaledPixmap.height() - 1); return pixmap; } } @@ -1232,15 +1230,13 @@ QPixmap StartupScenesList::createScenePreview(const QString &name, return pixmap; } -void StartupScenesList::clearScenes() { - clear(); -} +void StartupScenesList::clearScenes() { clear(); } void StartupScenesList::addScene(const QString &name, const QString &path) { QPixmap pixmap; if (path == ":") - pixmap = - svgToPixmap(getIconThemePath("actions/16/new_scene.svg"), m_iconSize, Qt::KeepAspectRatio); + pixmap = generateIconPixmap("new_scene", qreal(1.0), m_iconSize, + Qt::KeepAspectRatio); else pixmap = createScenePreview(name, TFilePath(path)); QIcon icon(pixmap); diff --git a/toonz/sources/toonz/tasksviewer.cpp b/toonz/sources/toonz/tasksviewer.cpp index 5bf78f4..2c188a5 100644 --- a/toonz/sources/toonz/tasksviewer.cpp +++ b/toonz/sources/toonz/tasksviewer.cpp @@ -1121,49 +1121,32 @@ QVariant TaskTreeModel::data(const QModelIndex &index, int role) const { bool sourceFileIsCLN = (t->m_taskFilePath.getType() == "cln"); switch (t->m_status) { case Suspended: - return QIcon( - t->m_isComposerTask - ? getIconThemePath("actions/35/task_render_suspended.svg") - : (sourceFileIsCLN - ? getIconThemePath("actions/35/task_cln_suspended.svg") - : getIconThemePath( - "actions/35/task_cleanup_suspended.svg"))); + return createQIcon(t->m_isComposerTask + ? "task_render_suspended" + : (sourceFileIsCLN ? "task_cln_suspended" + : "task_cleanup_suspended")); case Waiting: - return QIcon( - t->m_isComposerTask - ? getIconThemePath( - "actions/35/task_render_completed_with_errors.svg") - : (sourceFileIsCLN - ? getIconThemePath( - "actions/35/task_cln_completed_with_errors.svg") - : getIconThemePath( - "actions/35/" - "task_cleanup_completed_with_errors.svg"))); + return createQIcon(t->m_isComposerTask + ? "task_render_completed_with_errors" + : (sourceFileIsCLN + ? "task_cln_completed_with_errors" + : "task_cleanup_completed_with_errors")); case Running: - return QIcon( - t->m_isComposerTask - ? getIconThemePath("actions/35/task_render_computing.svg") - : (sourceFileIsCLN - ? getIconThemePath("actions/35/task_cln_computing.svg") - : getIconThemePath( - "actions/35/task_cleanup_computing.svg"))); + return createQIcon(t->m_isComposerTask + ? "task_render_computing" + : (sourceFileIsCLN ? "task_cln_computing" + : "task_cleanup_computing")); case Completed: - return QIcon( - t->m_isComposerTask - ? getIconThemePath("actions/35/task_render_completed.svg") - : (sourceFileIsCLN - ? getIconThemePath("actions/35/task_cln_completed.svg") - : getIconThemePath( - "actions/35/task_cleanup_completed.svg"))); + return createQIcon(t->m_isComposerTask + ? "task_render_completed" + : (sourceFileIsCLN ? "task_cln_completed" + : "task_cleanup_completed")); case Aborted: case TaskUnknown: - return QIcon( - t->m_isComposerTask - ? getIconThemePath("actions/35/task_render_failed.svg") - : (sourceFileIsCLN - ? getIconThemePath("actions/35/task_cln_failed.svg") - : getIconThemePath( - "actions/35/task_cleanup_failed.svg"))); + return createQIcon(t->m_isComposerTask + ? "task_render_failed" + : (sourceFileIsCLN ? "task_cln_failed" + : "task_cleanup_failed")); default: assert(false); } diff --git a/toonz/sources/toonz/toonz.qrc b/toonz/sources/toonz/toonz.qrc index 5070c00..f7179e6 100644 --- a/toonz/sources/toonz/toonz.qrc +++ b/toonz/sources/toonz/toonz.qrc @@ -1,9 +1,5 @@ - - icons/dark/index.theme - icons/light/index.theme - icons/dark/tools/20/animate.svg icons/dark/tools/20/brush.svg @@ -59,8 +55,8 @@ icons/dark/actions/16/export.svg icons/dark/actions/16/import.svg icons/dark/actions/16/load.svg - icons/dark/actions/18/lock.svg - icons/dark/actions/18/lock_on.svg + icons/dark/actions/16/lock.svg + icons/dark/actions/16/lock_on.svg icons/dark/actions/16/file_copy.svg icons/dark/actions/16/content_copy.svg icons/dark/actions/16/cut.svg @@ -161,19 +157,19 @@ icons/dark/actions/35/task_render_failed.svg - icons/dark/mimetypes/60/tasklist_icon.svg - icons/dark/mimetypes/60/xdts_icon.svg - icons/dark/mimetypes/60/missing_icon.svg - icons/dark/mimetypes/60/motionpath_icon.svg - icons/dark/mimetypes/60/curve_icon.svg - icons/dark/mimetypes/60/unknown_icon.svg - icons/dark/mimetypes/60/cleanup_icon.svg - icons/dark/mimetypes/60/psd_icon.svg - icons/dark/mimetypes/60/svg_icon.svg - icons/dark/mimetypes/60/audio_icon.svg - icons/dark/mimetypes/60/script_icon.svg - icons/dark/mimetypes/60/broken_icon.svg - icons/dark/mimetypes/60/json_icon.svg + icons/dark/mimetypes/tasklist_icon.svg + icons/dark/mimetypes/xdts_icon.svg + icons/dark/mimetypes/missing_icon.svg + icons/dark/mimetypes/motionpath_icon.svg + icons/dark/mimetypes/curve_icon.svg + icons/dark/mimetypes/unknown_icon.svg + icons/dark/mimetypes/cleanup_icon.svg + icons/dark/mimetypes/psd_icon.svg + icons/dark/mimetypes/svg_icon.svg + icons/dark/mimetypes/audio_icon.svg + icons/dark/mimetypes/script_icon.svg + icons/dark/mimetypes/broken_icon.svg + icons/dark/mimetypes/json_icon.svg icons/dark/actions/16/render.svg @@ -559,7 +555,7 @@ icons/dark/actions/48/colorchiporder_leftup.svg icons/dark/actions/48/colorchiporder_lowleft.svg icons/dark/actions/48/colorchiporder_upleft.svg - icons/dark/misc/startup.png + icons/dark/misc/opentoonz_logo.svg icons/dark/actions/20/touch.svg icons/dark/actions/16/quit.svg icons/dark/actions/16/clear_cache.svg @@ -579,6 +575,7 @@ icons/dark/actions/16/project_settings.svg icons/dark/actions/16/save_default_settings.svg icons/dark/actions/16/zero_thick_lines.svg + icons/dark/actions/16/table.svg icons/dark/actions/20/key_off.svg @@ -588,8 +585,6 @@ - - icons/light/misc/startup.png diff --git a/toonz/sources/toonz/tpanels.cpp b/toonz/sources/toonz/tpanels.cpp index bf8e406..26f86cc 100644 --- a/toonz/sources/toonz/tpanels.cpp +++ b/toonz/sources/toonz/tpanels.cpp @@ -542,8 +542,8 @@ void PaletteViewerPanel::reset() { //----------------------------------------------------------------------------- void PaletteViewerPanel::initializeTitleBar() { - m_freezeButton = new TPanelTitleBarButton( - getTitleBar(), getIconThemePath("actions/20/pane_freeze.svg")); + m_freezeButton = + new TPanelTitleBarButton(getTitleBar(), getIconPath("pane_freeze")); m_freezeButton->setToolTip(tr("Freeze")); getTitleBar()->add(QPoint(-54, 0), m_freezeButton); m_freezeButton->setPressed(m_isFrozen); @@ -1122,10 +1122,10 @@ void FlipbookPanel::initializeTitleBar(TPanelTitleBar *titleBar) { bool ret = true; int x = -91; int iconWidth = 20; + // safe area button TPanelTitleBarButtonForSafeArea *safeAreaButton = - new TPanelTitleBarButtonForSafeArea( - titleBar, getIconThemePath("actions/20/pane_safe.svg")); + new TPanelTitleBarButtonForSafeArea(titleBar, getIconPath("pane_safe")); safeAreaButton->setToolTip(tr("Safe Area (Right Click to Select)")); titleBar->add(QPoint(x, 0), safeAreaButton); ret = ret && connect(safeAreaButton, SIGNAL(toggled(bool)), @@ -1141,7 +1141,7 @@ void FlipbookPanel::initializeTitleBar(TPanelTitleBar *titleBar) { x += 28 + iconWidth; // minimize button m_button = new TPanelTitleBarButton( - titleBar, getIconThemePath("actions/20/pane_minimize.svg")); + titleBar, getIconPath("pane_minimize")); m_button->setToolTip(tr("Minimize")); m_button->setPressed(false); diff --git a/toonz/sources/toonz/viewerpane.cpp b/toonz/sources/toonz/viewerpane.cpp index 7f67340..e0d4e6a 100644 --- a/toonz/sources/toonz/viewerpane.cpp +++ b/toonz/sources/toonz/viewerpane.cpp @@ -332,7 +332,7 @@ void BaseViewerPanel::showEvent(QShowEvent *event) { ret = ret && connect(frameHandle, SIGNAL(frameTypeChanged()), this, SLOT(onFrameTypeChanged())); - // onXshLevelSwitched(TXshLevel*)�F changeWindowTitle() + updateFrameRange() + // onXshLevelSwitched(TXshLevel*)�F changeWindowTitle() + updateFrameRange() ret = ret && connect(levelHandle, SIGNAL(xshLevelSwitched(TXshLevel *)), this, SLOT(onXshLevelSwitched(TXshLevel *))); @@ -383,8 +383,7 @@ void BaseViewerPanel::initializeTitleBar(TPanelTitleBar *titleBar) { // buttons for show / hide toggle for the field guide and the safe area TPanelTitleBarButtonForSafeArea *safeAreaButton = - new TPanelTitleBarButtonForSafeArea( - titleBar, getIconThemePath("actions/20/pane_safe.svg")); + new TPanelTitleBarButtonForSafeArea(titleBar, getIconPath("pane_safe")); safeAreaButton->setToolTip(tr("Safe Area (Right Click to Select)")); titleBar->add(QPoint(x, 0), safeAreaButton); ret = ret && connect(safeAreaButton, SIGNAL(toggled(bool)), @@ -397,8 +396,7 @@ void BaseViewerPanel::initializeTitleBar(TPanelTitleBar *titleBar) { safeAreaButton->setPressed( CommandManager::instance()->getAction(MI_SafeArea)->isChecked()); - button = new TPanelTitleBarButton( - titleBar, getIconThemePath("actions/20/pane_grid.svg")); + button = new TPanelTitleBarButton(titleBar, getIconPath("pane_grid")); button->setToolTip(tr("Field Guide")); x += 1 + iconWidth; titleBar->add(QPoint(x, 0), button); @@ -412,23 +410,20 @@ void BaseViewerPanel::initializeTitleBar(TPanelTitleBar *titleBar) { CommandManager::instance()->getAction(MI_FieldGuide)->isChecked()); // view mode toggles - button = new TPanelTitleBarButton( - titleBar, getIconThemePath("actions/20/pane_table.svg")); + button = new TPanelTitleBarButton(titleBar, getIconPath("pane_table")); button->setToolTip(tr("Camera Stand View")); x += 10 + iconWidth; titleBar->add(QPoint(x, 0), button); button->setButtonSet(viewModeButtonSet, SceneViewer::NORMAL_REFERENCE); button->setPressed(true); - button = new TPanelTitleBarButton(titleBar, - getIconThemePath("actions/20/pane_3d.svg")); + button = new TPanelTitleBarButton(titleBar, getIconPath("pane_3d")); button->setToolTip(tr("3D View")); x += 1 + iconWidth; titleBar->add(QPoint(x, 0), button); button->setButtonSet(viewModeButtonSet, SceneViewer::CAMERA3D_REFERENCE); - button = new TPanelTitleBarButton( - titleBar, getIconThemePath("actions/20/pane_cam.svg")); + button = new TPanelTitleBarButton(titleBar, getIconPath("pane_cam")); button->setToolTip(tr("Camera View")); x += 1 + iconWidth; titleBar->add(QPoint(x, 0), button); @@ -437,8 +432,7 @@ void BaseViewerPanel::initializeTitleBar(TPanelTitleBar *titleBar) { SLOT(setReferenceMode(int))); // freeze button - button = new TPanelTitleBarButton( - titleBar, getIconThemePath("actions/20/pane_freeze.svg")); + button = new TPanelTitleBarButton(titleBar, getIconPath("pane_freeze")); x += 10 + iconWidth; button->setToolTip(tr("Freeze")); @@ -447,8 +441,8 @@ void BaseViewerPanel::initializeTitleBar(TPanelTitleBar *titleBar) { SLOT(freeze(bool))); // preview toggles - m_previewButton = new TPanelTitleBarButtonForPreview( - titleBar, getIconThemePath("actions/20/pane_preview.svg")); + m_previewButton = + new TPanelTitleBarButtonForPreview(titleBar, getIconPath("pane_preview")); x += 10 + iconWidth; titleBar->add(QPoint(x, 0), m_previewButton); m_previewButton->setToolTip(tr("Preview")); @@ -457,8 +451,8 @@ void BaseViewerPanel::initializeTitleBar(TPanelTitleBar *titleBar) { // SLOT(enableFullPreview(bool))); m_subcameraPreviewButton = new TPanelTitleBarButtonForPreview( - titleBar, getIconThemePath("actions/20/pane_subpreview.svg")); - x += 1 + 24; // width of pane_preview.svg = 24px + titleBar, getIconPath("pane_subpreview")); + x += 1 + 24; titleBar->add(QPoint(x, 0), m_subcameraPreviewButton); m_subcameraPreviewButton->setToolTip(tr("Sub-camera Preview")); @@ -602,7 +596,7 @@ void BaseViewerPanel::onPlayingStatusChanged(bool playing) { //----------------------------------------------------------------------------- -void BaseViewerPanel::changeWindowTitle() { // �v�m�F +void BaseViewerPanel::changeWindowTitle() { // �v�m�F TApp *app = TApp::instance(); ToonzScene *scene = app->getCurrentScene()->getScene(); if (!scene) return; diff --git a/toonz/sources/toonz/xshcolumnviewer.cpp b/toonz/sources/toonz/xshcolumnviewer.cpp index c3b0416..73ec62d 100644 --- a/toonz/sources/toonz/xshcolumnviewer.cpp +++ b/toonz/sources/toonz/xshcolumnviewer.cpp @@ -156,21 +156,20 @@ bool containsVectorLevel(int col) { } QIcon createLockIcon(XsheetViewer *viewer) { - QImage icon_on, icon_off; QColor bgColor_on, bgColor_off; - viewer->getButton(LOCK_ON_XSHBUTTON, bgColor_on, icon_on); - viewer->getButton(LOCK_OFF_XSHBUTTON, bgColor_off, icon_off); - QPainter p_on(&icon_on); - p_on.setCompositionMode(QPainter::CompositionMode_DestinationOver); - p_on.fillRect(0, 0, icon_on.width(), icon_on.height(), bgColor_on); - p_on.end(); - QPainter p_off(&icon_off); - p_off.setCompositionMode(QPainter::CompositionMode_DestinationOver); - p_off.fillRect(0, 0, icon_off.width(), icon_off.height(), bgColor_off); - p_off.end(); + + QString svgFilePath_on = viewer->getXsheetLockButtonOnImage(); + QString svgFilePath_off = viewer->getXsheetLockButtonOffImage(); + + QPixmap pm_on = svgToPixmap(svgFilePath_on, QSize(16, 16), + Qt::KeepAspectRatio, bgColor_on); + QPixmap pm_off = svgToPixmap(svgFilePath_off, QSize(16, 16), + Qt::KeepAspectRatio, bgColor_off); + QIcon lockIcon; - lockIcon.addPixmap(QPixmap::fromImage(icon_off)); - lockIcon.addPixmap(QPixmap::fromImage(icon_on), QIcon::Normal, QIcon::On); + lockIcon.addPixmap(pm_off); + lockIcon.addPixmap(pm_on, QIcon::Normal, QIcon::On); + return lockIcon; } @@ -804,13 +803,11 @@ void ColumnArea::DrawHeader::prepare() const { //----------------------------------------------------------------------------- const QPixmap &ColumnArea::Pixmaps::sound() { - static QPixmap sound = - svgToPixmap(getIconThemePath("actions/30/sound_header.svg")); + static QPixmap sound = generateIconPixmap("sound_header"); return sound; } const QPixmap &ColumnArea::Pixmaps::soundPlaying() { - static QPixmap soundPlaying = - svgToPixmap(getIconThemePath("actions/30/sound_header_on.svg")); + static QPixmap soundPlaying = generateIconPixmap("sound_header_on"); return soundPlaying; } @@ -931,16 +928,17 @@ void ColumnArea::DrawHeader::drawEye() const { if (col < 0 && o->isVerticalTimeline()) return; // no preview eye in the camera column QColor bgColor; - QImage icon; + QString svgFilePath; int buttonType = !column->isPreviewVisible() ? PREVIEW_OFF_XSHBUTTON : PREVIEW_ON_XSHBUTTON; - m_viewer->getButton(buttonType, bgColor, icon, !o->isVerticalTimeline()); + m_viewer->getButton(buttonType, bgColor, svgFilePath, + !o->isVerticalTimeline()); QRect prevViewRect = o->rect(PredefinedRect::EYE_AREA).translated(orig); QRect eyeRect = o->rect(PredefinedRect::EYE).translated(orig); // preview visible toggle if (o->isVerticalTimeline()) - p.setPen(m_viewer->getColumnIconLineColor()); // Preview border color + p.setPen(m_viewer->getColumnIconLineColor()); // Preview border color else p.setPen(m_viewer->getTimelineIconLineColor()); // Preview border color @@ -958,7 +956,10 @@ void ColumnArea::DrawHeader::drawEye() const { buttonType == PREVIEW_OFF_XSHBUTTON) return; - p.drawImage(eyeRect, icon); + QPixmap icon = + svgToPixmap(svgFilePath, eyeRect.size(), Qt::KeepAspectRatio, bgColor); + + p.drawPixmap(eyeRect, icon); } void ColumnArea::DrawHeader::drawPreviewToggle(int opacity) const { @@ -967,11 +968,12 @@ void ColumnArea::DrawHeader::drawPreviewToggle(int opacity) const { return; // no camstand toggle in the camera column // camstand visible toggle QColor bgColor; - QImage icon; + QString svgFilePath; int buttonType = !column->isCamstandVisible() ? CAMSTAND_OFF_XSHBUTTON : opacity < 255 ? CAMSTAND_TRANSP_XSHBUTTON : CAMSTAND_ON_XSHBUTTON; - m_viewer->getButton(buttonType, bgColor, icon, !o->isVerticalTimeline()); + m_viewer->getButton(buttonType, bgColor, svgFilePath, + !o->isVerticalTimeline()); QRect tableViewRect = o->rect(PredefinedRect::PREVIEW_LAYER_AREA).translated(orig); @@ -979,7 +981,7 @@ void ColumnArea::DrawHeader::drawPreviewToggle(int opacity) const { o->rect(PredefinedRect::PREVIEW_LAYER).translated(orig); if (o->isVerticalTimeline()) - p.setPen(m_viewer->getColumnIconLineColor()); // Camstand border color + p.setPen(m_viewer->getColumnIconLineColor()); // Camstand border color else p.setPen(m_viewer->getTimelineIconLineColor()); // Camstand border color @@ -998,7 +1000,11 @@ void ColumnArea::DrawHeader::drawPreviewToggle(int opacity) const { m_viewer->getXsheetLayout() == QString("Classic") && buttonType == CAMSTAND_OFF_XSHBUTTON) return; - p.drawImage(tableViewImgRect, icon); + + QPixmap icon = svgToPixmap(svgFilePath, tableViewImgRect.size(), + Qt::KeepAspectRatio, bgColor); + + p.drawPixmap(tableViewImgRect, icon); } // shows united visibility toggle, which has the same state as the camstand @@ -1009,11 +1015,12 @@ void ColumnArea::DrawHeader::drawUnifiedViewToggle(int opacity) const { return; // no camstand toggle in the camera column // camstand visible toggle QColor bgColor; - QImage icon; + QString svgFilePath; int buttonType = !column->isCamstandVisible() ? PREVIEW_OFF_XSHBUTTON : opacity < 255 ? UNIFIED_TRANSP_XSHBUTTON : PREVIEW_ON_XSHBUTTON; - m_viewer->getButton(buttonType, bgColor, icon, !o->isVerticalTimeline()); + m_viewer->getButton(buttonType, bgColor, svgFilePath, + !o->isVerticalTimeline()); QRect unifiedViewRect = o->rect(PredefinedRect::UNIFIEDVIEW_LAYER_AREA).translated(orig); @@ -1021,7 +1028,7 @@ void ColumnArea::DrawHeader::drawUnifiedViewToggle(int opacity) const { o->rect(PredefinedRect::UNIFIEDVIEW_LAYER).translated(orig); if (o->isVerticalTimeline()) - p.setPen(m_viewer->getColumnIconLineColor()); // border color + p.setPen(m_viewer->getColumnIconLineColor()); // border color else p.setPen(m_viewer->getTimelineIconLineColor()); // border color @@ -1035,15 +1042,19 @@ void ColumnArea::DrawHeader::drawUnifiedViewToggle(int opacity) const { if (o->flag(PredefinedFlag::PREVIEW_LAYER_AREA_BORDER)) p.drawRect(unifiedViewRect); - p.drawImage(unifiedViewImgRect, icon); + QPixmap icon = svgToPixmap(svgFilePath, unifiedViewImgRect.size(), + Qt::KeepAspectRatio, bgColor); + + p.drawPixmap(unifiedViewImgRect, icon); } void ColumnArea::DrawHeader::drawLock() const { if (isEmpty || !o->flag(PredefinedFlag::LOCK_AREA_VISIBLE)) return; QColor bgColor; - QImage icon; + QString svgFilePath; int buttonType = !column->isLocked() ? LOCK_OFF_XSHBUTTON : LOCK_ON_XSHBUTTON; - m_viewer->getButton(buttonType, bgColor, icon, !o->isVerticalTimeline()); + m_viewer->getButton(buttonType, bgColor, svgFilePath, + !o->isVerticalTimeline()); QRect lockModeRect = o->rect((col < 0) ? PredefinedRect::CAMERA_LOCK_AREA : PredefinedRect::LOCK_AREA) @@ -1059,7 +1070,7 @@ void ColumnArea::DrawHeader::drawLock() const { // lock button if (o->isVerticalTimeline()) - p.setPen(m_viewer->getColumnIconLineColor()); // Lock border color + p.setPen(m_viewer->getColumnIconLineColor()); // Lock border color else p.setPen(m_viewer->getTimelineIconLineColor()); // Lock border color @@ -1071,7 +1082,11 @@ void ColumnArea::DrawHeader::drawLock() const { m_viewer->getXsheetLayout() == QString("Classic") && buttonType == LOCK_OFF_XSHBUTTON) return; - p.drawImage(lockModeImgRect, icon); + + QPixmap icon = svgToPixmap(svgFilePath, lockModeImgRect.size(), + Qt::KeepAspectRatio, bgColor); + + p.drawPixmap(lockModeImgRect, icon); } void ColumnArea::DrawHeader::drawConfig() const { @@ -1079,9 +1094,12 @@ void ColumnArea::DrawHeader::drawConfig() const { (col < 0 && !o->flag(PredefinedFlag::CAMERA_CONFIG_AREA_VISIBLE))) return; QColor bgColor; - QImage icon; + QString svgIconPath; + int buttonType = CONFIG_XSHBUTTON; - m_viewer->getButton(buttonType, bgColor, icon, !o->isVerticalTimeline()); + + m_viewer->getButton(buttonType, bgColor, svgIconPath, + !o->isVerticalTimeline()); QRect configRect = o->rect((col < 0) ? PredefinedRect::CAMERA_CONFIG_AREA : PredefinedRect::CONFIG_AREA) @@ -1105,7 +1123,10 @@ void ColumnArea::DrawHeader::drawConfig() const { if (zColumn || column->getPaletteColumn() || column->getSoundTextColumn()) return; - p.drawImage(configImgRect, icon); + QPixmap icon = svgToPixmap(svgIconPath, configImgRect.size(), + Qt::KeepAspectRatio, bgColor); + + p.drawPixmap(configImgRect, icon); } void ColumnArea::DrawHeader::drawColumnNumber() const { @@ -1766,8 +1787,7 @@ void ColumnArea::drawSoundTextColumnHead(QPainter &p, int col) { // AREA drawHeader.drawConfig(); drawHeader.drawColumnName(); drawHeader.drawColumnNumber(); - static QPixmap iconPixmap( - recolorPixmap(svgToPixmap(getIconThemePath("actions/74/notelevel.svg")))); + static QPixmap iconPixmap(generateIconPixmap("notelevel")); drawHeader.drawThumbnail(iconPixmap); drawHeader.drawPegbarName(); drawHeader.drawParentHandleName(); diff --git a/toonz/sources/toonz/xsheetviewer.cpp b/toonz/sources/toonz/xsheetviewer.cpp index 56afdc0..1917065 100644 --- a/toonz/sources/toonz/xsheetviewer.cpp +++ b/toonz/sources/toonz/xsheetviewer.cpp @@ -158,66 +158,66 @@ void XsheetViewer::getColumnColor(QColor &color, QColor &sideColor, int index, //----------------------------------------------------------------------------- void XsheetViewer::getButton(const int &btype, QColor &bgColor, - QImage &iconImage, bool isTimeline) { + QString &svgIconPath, bool isTimeline) { switch (btype) { case PREVIEW_ON_XSHBUTTON: bgColor = (isTimeline) ? getTimelinePreviewButtonBgOnColor() : getXsheetPreviewButtonBgOnColor(); - iconImage = (isTimeline) ? getTimelinePreviewButtonOnImage() + svgIconPath = (isTimeline) ? getTimelinePreviewButtonOnImage() : getXsheetPreviewButtonOnImage(); break; case PREVIEW_OFF_XSHBUTTON: bgColor = (isTimeline) ? getTimelinePreviewButtonBgOffColor() : getXsheetPreviewButtonBgOffColor(); - iconImage = (isTimeline) ? getTimelinePreviewButtonOffImage() + svgIconPath = (isTimeline) ? getTimelinePreviewButtonOffImage() : getXsheetPreviewButtonOffImage(); break; case CAMSTAND_ON_XSHBUTTON: bgColor = (isTimeline) ? getTimelineCamstandButtonBgOnColor() : getXsheetCamstandButtonBgOnColor(); - iconImage = (isTimeline) ? getTimelineCamstandButtonOnImage() + svgIconPath = (isTimeline) ? getTimelineCamstandButtonOnImage() : getXsheetCamstandButtonOnImage(); break; case CAMSTAND_TRANSP_XSHBUTTON: bgColor = (isTimeline) ? getTimelineCamstandButtonBgOnColor() : getXsheetCamstandButtonBgOnColor(); - iconImage = (isTimeline) ? getTimelineCamstandButtonTranspImage() + svgIconPath = (isTimeline) ? getTimelineCamstandButtonTranspImage() : getXsheetCamstandButtonTranspImage(); break; case CAMSTAND_OFF_XSHBUTTON: bgColor = (isTimeline) ? getTimelineCamstandButtonBgOffColor() : getXsheetCamstandButtonBgOffColor(); - iconImage = (isTimeline) ? getTimelineCamstandButtonOffImage() + svgIconPath = (isTimeline) ? getTimelineCamstandButtonOffImage() : getXsheetCamstandButtonOffImage(); break; case LOCK_ON_XSHBUTTON: bgColor = (isTimeline) ? getTimelineLockButtonBgOnColor() : getXsheetLockButtonBgOnColor(); - iconImage = (isTimeline) ? getTimelineLockButtonOnImage() + svgIconPath = (isTimeline) ? getTimelineLockButtonOnImage() : getXsheetLockButtonOnImage(); break; case LOCK_OFF_XSHBUTTON: bgColor = (isTimeline) ? getTimelineLockButtonBgOffColor() : getXsheetLockButtonBgOffColor(); - iconImage = (isTimeline) ? getTimelineLockButtonOffImage() + svgIconPath = (isTimeline) ? getTimelineLockButtonOffImage() : getXsheetLockButtonOffImage(); break; case CONFIG_XSHBUTTON: bgColor = (isTimeline) ? getTimelineConfigButtonBgColor() : getXsheetConfigButtonBgColor(); - iconImage = (isTimeline) ? getTimelineConfigButtonImage() + svgIconPath = (isTimeline) ? getTimelineConfigButtonImage() : getXsheetConfigButtonImage(); break; case UNIFIED_TRANSP_XSHBUTTON: bgColor = (isTimeline) ? getTimelinePreviewButtonBgOnColor() : getXsheetPreviewButtonBgOnColor(); - iconImage = (isTimeline) ? getTimelineUnifiedButtonTranspImage() + svgIconPath = (isTimeline) ? getTimelineUnifiedButtonTranspImage() : getXsheetUnifiedButtonTranspImage(); break; default: bgColor = grey210; static QImage iconignored; - iconImage = iconignored; + svgIconPath = ""; } } diff --git a/toonz/sources/toonz/xsheetviewer.h b/toonz/sources/toonz/xsheetviewer.h index 515148d..e3686ef 100644 --- a/toonz/sources/toonz/xsheetviewer.h +++ b/toonz/sources/toonz/xsheetviewer.h @@ -447,153 +447,153 @@ class XsheetViewer final : public QFrame, public SaveLoadQSettings { // Xsheet Preview Button QColor m_xsheetPreviewButtonBgOnColor; - QImage m_xsheetPreviewButtonOnImage; + QString m_xsheetPreviewButtonOnImage; QColor m_xsheetPreviewButtonBgOffColor; - QImage m_xsheetPreviewButtonOffImage; - QImage m_xsheetUnifiedButtonTranspImage; + QString m_xsheetPreviewButtonOffImage; + QString m_xsheetUnifiedButtonTranspImage; Q_PROPERTY( QColor XsheetPreviewButtonBgOnColor READ getXsheetPreviewButtonBgOnColor WRITE setXsheetPreviewButtonBgOnColor) Q_PROPERTY( - QImage XsheetPreviewButtonOnImage READ getXsheetPreviewButtonOnImage WRITE + QString XsheetPreviewButtonOnImage READ getXsheetPreviewButtonOnImage WRITE setXsheetPreviewButtonOnImage) Q_PROPERTY( QColor XsheetPreviewButtonBgOffColor READ getXsheetPreviewButtonBgOffColor WRITE setXsheetPreviewButtonBgOffColor) Q_PROPERTY( - QImage XsheetPreviewButtonOffImage READ getXsheetPreviewButtonOffImage + QString XsheetPreviewButtonOffImage READ getXsheetPreviewButtonOffImage WRITE setXsheetPreviewButtonOffImage) - Q_PROPERTY(QImage XsheetUnifiedButtonTranspImage READ + Q_PROPERTY(QString XsheetUnifiedButtonTranspImage READ getXsheetUnifiedButtonTranspImage WRITE setXsheetUnifiedButtonTranspImage) // Xsheet Camstand Button QColor m_xsheetCamstandButtonBgOnColor; - QImage m_xsheetCamstandButtonOnImage; - QImage m_xsheetCamstandButtonTranspImage; + QString m_xsheetCamstandButtonOnImage; + QString m_xsheetCamstandButtonTranspImage; QColor m_xsheetCamstandButtonBgOffColor; - QImage m_xsheetCamstandButtonOffImage; + QString m_xsheetCamstandButtonOffImage; Q_PROPERTY( QColor XsheetCamstandButtonBgOnColor READ getXsheetCamstandButtonBgOnColor WRITE setXsheetCamstandButtonBgOnColor) Q_PROPERTY( - QImage XsheetCamstandButtonOnImage READ getXsheetCamstandButtonOnImage + QString XsheetCamstandButtonOnImage READ getXsheetCamstandButtonOnImage WRITE setXsheetCamstandButtonOnImage) - Q_PROPERTY(QImage XsheetCamstandButtonTranspImage READ + Q_PROPERTY(QString XsheetCamstandButtonTranspImage READ getXsheetCamstandButtonTranspImage WRITE setXsheetCamstandButtonTranspImage) Q_PROPERTY(QColor XsheetCamstandButtonBgOffColor READ getXsheetCamstandButtonBgOffColor WRITE setXsheetCamstandButtonBgOffColor) Q_PROPERTY( - QImage XsheetCamstandButtonOffImage READ getXsheetCamstandButtonOffImage + QString XsheetCamstandButtonOffImage READ getXsheetCamstandButtonOffImage WRITE setXsheetCamstandButtonOffImage) // Xsheet Lock Button QColor m_xsheetLockButtonBgOnColor; - QImage m_xsheetLockButtonOnImage; + QString m_xsheetLockButtonOnImage; QColor m_xsheetLockButtonBgOffColor; - QImage m_xsheetLockButtonOffImage; + QString m_xsheetLockButtonOffImage; Q_PROPERTY(QColor XsheetLockButtonBgOnColor READ getXsheetLockButtonBgOnColor WRITE setXsheetLockButtonBgOnColor) - Q_PROPERTY(QImage XsheetLockButtonOnImage READ getXsheetLockButtonOnImage + Q_PROPERTY(QString XsheetLockButtonOnImage READ getXsheetLockButtonOnImage WRITE setXsheetLockButtonOnImage) Q_PROPERTY( QColor XsheetLockButtonBgOffColor READ getXsheetLockButtonBgOffColor WRITE setXsheetLockButtonBgOffColor) - Q_PROPERTY(QImage XsheetLockButtonOffImage READ getXsheetLockButtonOffImage + Q_PROPERTY(QString XsheetLockButtonOffImage READ getXsheetLockButtonOffImage WRITE setXsheetLockButtonOffImage) // Xsheet Config Button QColor m_xsheetConfigButtonBgColor; - QImage m_xsheetConfigButtonImage; + QString m_xsheetConfigButtonImage; Q_PROPERTY(QColor XsheetConfigButtonBgColor READ getXsheetConfigButtonBgColor WRITE setXsheetConfigButtonBgColor) - Q_PROPERTY(QImage XsheetConfigButtonImage READ getXsheetConfigButtonImage + Q_PROPERTY(QString XsheetConfigButtonImage READ getXsheetConfigButtonImage WRITE setXsheetConfigButtonImage) // Timeline Preview Button QColor m_timelinePreviewButtonBgOnColor; - QImage m_timelinePreviewButtonOnImage; + QString m_timelinePreviewButtonOnImage; QColor m_timelinePreviewButtonBgOffColor; - QImage m_timelinePreviewButtonOffImage; - QImage m_timelineUnifiedButtonTranspImage; + QString m_timelinePreviewButtonOffImage; + QString m_timelineUnifiedButtonTranspImage; Q_PROPERTY(QColor TimelinePreviewButtonBgOnColor READ getTimelinePreviewButtonBgOnColor WRITE setTimelinePreviewButtonBgOnColor) Q_PROPERTY( - QImage TimelinePreviewButtonOnImage READ getTimelinePreviewButtonOnImage + QString TimelinePreviewButtonOnImage READ getTimelinePreviewButtonOnImage WRITE setTimelinePreviewButtonOnImage) Q_PROPERTY(QColor TimelinePreviewButtonBgOffColor READ getTimelinePreviewButtonBgOffColor WRITE setTimelinePreviewButtonBgOffColor) Q_PROPERTY( - QImage TimelinePreviewButtonOffImage READ getTimelinePreviewButtonOffImage + QString TimelinePreviewButtonOffImage READ getTimelinePreviewButtonOffImage WRITE setTimelinePreviewButtonOffImage) - Q_PROPERTY(QImage TimelineUnifiedButtonTranspImage READ + Q_PROPERTY(QString TimelineUnifiedButtonTranspImage READ getTimelineUnifiedButtonTranspImage WRITE setTimelineUnifiedButtonTranspImage) // Timeline Camstand Button QColor m_timelineCamstandButtonBgOnColor; - QImage m_timelineCamstandButtonOnImage; - QImage m_timelineCamstandButtonTranspImage; + QString m_timelineCamstandButtonOnImage; + QString m_timelineCamstandButtonTranspImage; QColor m_timelineCamstandButtonBgOffColor; - QImage m_timelineCamstandButtonOffImage; + QString m_timelineCamstandButtonOffImage; Q_PROPERTY(QColor TimelineCamstandButtonBgOnColor READ getTimelineCamstandButtonBgOnColor WRITE setTimelineCamstandButtonBgOnColor) Q_PROPERTY( - QImage TimelineCamstandButtonOnImage READ getTimelineCamstandButtonOnImage + QString TimelineCamstandButtonOnImage READ getTimelineCamstandButtonOnImage WRITE setTimelineCamstandButtonOnImage) - Q_PROPERTY(QImage TimelineCamstandButtonTranspImage READ + Q_PROPERTY(QString TimelineCamstandButtonTranspImage READ getTimelineCamstandButtonTranspImage WRITE setTimelineCamstandButtonTranspImage) Q_PROPERTY(QColor TimelineCamstandButtonBgOffColor READ getTimelineCamstandButtonBgOffColor WRITE setTimelineCamstandButtonBgOffColor) - Q_PROPERTY(QImage TimelineCamstandButtonOffImage READ + Q_PROPERTY(QString TimelineCamstandButtonOffImage READ getTimelineCamstandButtonOffImage WRITE setTimelineCamstandButtonOffImage) // Timeline Lock Button QColor m_timelineLockButtonBgOnColor; - QImage m_timelineLockButtonOnImage; + QString m_timelineLockButtonOnImage; QColor m_timelineLockButtonBgOffColor; - QImage m_timelineLockButtonOffImage; + QString m_timelineLockButtonOffImage; Q_PROPERTY( QColor TimelineLockButtonBgOnColor READ getTimelineLockButtonBgOnColor WRITE setTimelineLockButtonBgOnColor) - Q_PROPERTY(QImage TimelineLockButtonOnImage READ getTimelineLockButtonOnImage + Q_PROPERTY(QString TimelineLockButtonOnImage READ getTimelineLockButtonOnImage WRITE setTimelineLockButtonOnImage) Q_PROPERTY( QColor TimelineLockButtonBgOffColor READ getTimelineLockButtonBgOffColor WRITE setTimelineLockButtonBgOffColor) Q_PROPERTY( - QImage TimelineLockButtonOffImage READ getTimelineLockButtonOffImage WRITE + QString TimelineLockButtonOffImage READ getTimelineLockButtonOffImage WRITE setTimelineLockButtonOffImage) // Timeline Config Button QColor m_timelineConfigButtonBgColor; - QImage m_timelineConfigButtonImage; + QString m_timelineConfigButtonImage; Q_PROPERTY( QColor TimelineConfigButtonBgColor READ getTimelineConfigButtonBgColor WRITE setTimelineConfigButtonBgColor) - Q_PROPERTY(QImage TimelineConfigButtonImage READ getTimelineConfigButtonImage + Q_PROPERTY(QString TimelineConfigButtonImage READ getTimelineConfigButtonImage WRITE setTimelineConfigButtonImage) // Layer Header icons - QImage m_layerHeaderPreviewImage; - QImage m_layerHeaderPreviewOverImage; - QImage m_layerHeaderCamstandImage; - QImage m_layerHeaderCamstandOverImage; - QImage m_layerHeaderLockImage; - QImage m_layerHeaderLockOverImage; - Q_PROPERTY(QImage LayerHeaderPreviewImage READ getLayerHeaderPreviewImage + QString m_layerHeaderPreviewImage; + QString m_layerHeaderPreviewOverImage; + QString m_layerHeaderCamstandImage; + QString m_layerHeaderCamstandOverImage; + QString m_layerHeaderLockImage; + QString m_layerHeaderLockOverImage; + Q_PROPERTY(QString LayerHeaderPreviewImage READ getLayerHeaderPreviewImage WRITE setLayerHeaderPreviewImage) Q_PROPERTY( - QImage LayerHeaderPreviewOverImage READ getLayerHeaderPreviewOverImage + QString LayerHeaderPreviewOverImage READ getLayerHeaderPreviewOverImage WRITE setLayerHeaderPreviewOverImage) - Q_PROPERTY(QImage LayerHeaderCamstandImage READ getLayerHeaderCamstandImage + Q_PROPERTY(QString LayerHeaderCamstandImage READ getLayerHeaderCamstandImage WRITE setLayerHeaderCamstandImage) Q_PROPERTY( - QImage LayerHeaderCamstandOverImage READ getLayerHeaderCamstandOverImage + QString LayerHeaderCamstandOverImage READ getLayerHeaderCamstandOverImage WRITE setLayerHeaderCamstandOverImage) - Q_PROPERTY(QImage LayerHeaderLockImage READ getLayerHeaderLockImage WRITE + Q_PROPERTY(QString LayerHeaderLockImage READ getLayerHeaderLockImage WRITE setLayerHeaderLockImage) - Q_PROPERTY(QImage LayerHeaderLockOverImage READ getLayerHeaderLockOverImage + Q_PROPERTY(QString LayerHeaderLockOverImage READ getLayerHeaderLockOverImage WRITE setLayerHeaderLockOverImage) XsheetScrollArea *m_cellScrollArea; @@ -1098,239 +1098,239 @@ public: void setXsheetPreviewButtonBgOnColor(const QColor &color) { m_xsheetPreviewButtonBgOnColor = color; } - void setXsheetPreviewButtonOnImage(const QImage &image) { - m_xsheetPreviewButtonOnImage = image; + void setXsheetPreviewButtonOnImage(const QString &svgFilePath) { + m_xsheetPreviewButtonOnImage = svgFilePath; } void setXsheetPreviewButtonBgOffColor(const QColor &color) { m_xsheetPreviewButtonBgOffColor = color; } - void setXsheetPreviewButtonOffImage(const QImage &image) { - m_xsheetPreviewButtonOffImage = image; + void setXsheetPreviewButtonOffImage(const QString &svgFilePath) { + m_xsheetPreviewButtonOffImage = svgFilePath; } - void setXsheetUnifiedButtonTranspImage(const QImage &image) { - m_xsheetUnifiedButtonTranspImage = image; + void setXsheetUnifiedButtonTranspImage(const QString &svgFilePath) { + m_xsheetUnifiedButtonTranspImage = svgFilePath; } QColor getXsheetPreviewButtonBgOnColor() const { return m_xsheetPreviewButtonBgOnColor; } - QImage getXsheetPreviewButtonOnImage() const { + QString getXsheetPreviewButtonOnImage() const { return m_xsheetPreviewButtonOnImage; } QColor getXsheetPreviewButtonBgOffColor() const { return m_xsheetPreviewButtonBgOffColor; } - QImage getXsheetPreviewButtonOffImage() const { + QString getXsheetPreviewButtonOffImage() const { return m_xsheetPreviewButtonOffImage; } - QImage getXsheetUnifiedButtonTranspImage() const { + QString getXsheetUnifiedButtonTranspImage() const { return m_xsheetUnifiedButtonTranspImage; } // Xsheet Camstand Button void setXsheetCamstandButtonBgOnColor(const QColor &color) { m_xsheetCamstandButtonBgOnColor = color; } - void setXsheetCamstandButtonOnImage(const QImage &image) { - m_xsheetCamstandButtonOnImage = image; + void setXsheetCamstandButtonOnImage(const QString &svgFilePath) { + m_xsheetCamstandButtonOnImage = svgFilePath; } - void setXsheetCamstandButtonTranspImage(const QImage &image) { - m_xsheetCamstandButtonTranspImage = image; + void setXsheetCamstandButtonTranspImage(const QString &svgFilePath) { + m_xsheetCamstandButtonTranspImage = svgFilePath; } void setXsheetCamstandButtonBgOffColor(const QColor &color) { m_xsheetCamstandButtonBgOffColor = color; } - void setXsheetCamstandButtonOffImage(const QImage &image) { - m_xsheetCamstandButtonOffImage = image; + void setXsheetCamstandButtonOffImage(const QString &svgFilePath) { + m_xsheetCamstandButtonOffImage = svgFilePath; } QColor getXsheetCamstandButtonBgOnColor() const { return m_xsheetCamstandButtonBgOnColor; } - QImage getXsheetCamstandButtonOnImage() const { + QString getXsheetCamstandButtonOnImage() const { return m_xsheetCamstandButtonOnImage; } - QImage getXsheetCamstandButtonTranspImage() const { + QString getXsheetCamstandButtonTranspImage() const { return m_xsheetCamstandButtonTranspImage; } QColor getXsheetCamstandButtonBgOffColor() const { return m_xsheetCamstandButtonBgOffColor; } - QImage getXsheetCamstandButtonOffImage() const { + QString getXsheetCamstandButtonOffImage() const { return m_xsheetCamstandButtonOffImage; } // XsheetLock Button void setXsheetLockButtonBgOnColor(const QColor &color) { m_xsheetLockButtonBgOnColor = color; } - void setXsheetLockButtonOnImage(const QImage &image) { - m_xsheetLockButtonOnImage = image; + void setXsheetLockButtonOnImage(const QString &svgFilePath) { + m_xsheetLockButtonOnImage = svgFilePath; } void setXsheetLockButtonBgOffColor(const QColor &color) { m_xsheetLockButtonBgOffColor = color; } - void setXsheetLockButtonOffImage(const QImage &image) { - m_xsheetLockButtonOffImage = image; + void setXsheetLockButtonOffImage(const QString &svgFilePath) { + m_xsheetLockButtonOffImage = svgFilePath; } QColor getXsheetLockButtonBgOnColor() const { return m_xsheetLockButtonBgOnColor; } - QImage getXsheetLockButtonOnImage() const { + QString getXsheetLockButtonOnImage() const { return m_xsheetLockButtonOnImage; } QColor getXsheetLockButtonBgOffColor() const { return m_xsheetLockButtonBgOffColor; } - QImage getXsheetLockButtonOffImage() const { + QString getXsheetLockButtonOffImage() const { return m_xsheetLockButtonOffImage; } // Xsheet Config Button void setXsheetConfigButtonBgColor(const QColor &color) { m_xsheetConfigButtonBgColor = color; } - void setXsheetConfigButtonImage(const QImage &image) { - m_xsheetConfigButtonImage = image; + void setXsheetConfigButtonImage(const QString &svgFilePath) { + m_xsheetConfigButtonImage = svgFilePath; } QColor getXsheetConfigButtonBgColor() const { return m_xsheetConfigButtonBgColor; } - QImage getXsheetConfigButtonImage() const { + QString getXsheetConfigButtonImage() const { return m_xsheetConfigButtonImage; } // Timeline Preview Button void setTimelinePreviewButtonBgOnColor(const QColor &color) { m_timelinePreviewButtonBgOnColor = color; } - void setTimelinePreviewButtonOnImage(const QImage &image) { - m_timelinePreviewButtonOnImage = image; + void setTimelinePreviewButtonOnImage(const QString &svgFilePath) { + m_timelinePreviewButtonOnImage = svgFilePath; } void setTimelinePreviewButtonBgOffColor(const QColor &color) { m_timelinePreviewButtonBgOffColor = color; } - void setTimelinePreviewButtonOffImage(const QImage &image) { - m_timelinePreviewButtonOffImage = image; + void setTimelinePreviewButtonOffImage(const QString &svgFilePath) { + m_timelinePreviewButtonOffImage = svgFilePath; } - void setTimelineUnifiedButtonTranspImage(const QImage &image) { - m_timelineUnifiedButtonTranspImage = image; + void setTimelineUnifiedButtonTranspImage(const QString &svgFilePath) { + m_timelineUnifiedButtonTranspImage = svgFilePath; } QColor getTimelinePreviewButtonBgOnColor() const { return m_timelinePreviewButtonBgOnColor; } - QImage getTimelinePreviewButtonOnImage() const { + QString getTimelinePreviewButtonOnImage() const { return m_timelinePreviewButtonOnImage; } QColor getTimelinePreviewButtonBgOffColor() const { return m_timelinePreviewButtonBgOffColor; } - QImage getTimelinePreviewButtonOffImage() const { + QString getTimelinePreviewButtonOffImage() const { return m_timelinePreviewButtonOffImage; } - QImage getTimelineUnifiedButtonTranspImage() const { + QString getTimelineUnifiedButtonTranspImage() const { return m_timelineUnifiedButtonTranspImage; } // Timeline Camstand Button void setTimelineCamstandButtonBgOnColor(const QColor &color) { m_timelineCamstandButtonBgOnColor = color; } - void setTimelineCamstandButtonOnImage(const QImage &image) { - m_timelineCamstandButtonOnImage = image; + void setTimelineCamstandButtonOnImage(const QString &svgFilePath) { + m_timelineCamstandButtonOnImage = svgFilePath; } - void setTimelineCamstandButtonTranspImage(const QImage &image) { - m_timelineCamstandButtonTranspImage = image; + void setTimelineCamstandButtonTranspImage(const QString &svgFilePath) { + m_timelineCamstandButtonTranspImage = svgFilePath; } void setTimelineCamstandButtonBgOffColor(const QColor &color) { m_timelineCamstandButtonBgOffColor = color; } - void setTimelineCamstandButtonOffImage(const QImage &image) { - m_timelineCamstandButtonOffImage = image; + void setTimelineCamstandButtonOffImage(const QString &svgFilePath) { + m_timelineCamstandButtonOffImage = svgFilePath; } QColor getTimelineCamstandButtonBgOnColor() const { return m_timelineCamstandButtonBgOnColor; } - QImage getTimelineCamstandButtonOnImage() const { + QString getTimelineCamstandButtonOnImage() const { return m_timelineCamstandButtonOnImage; } - QImage getTimelineCamstandButtonTranspImage() const { + QString getTimelineCamstandButtonTranspImage() const { return m_timelineCamstandButtonTranspImage; } QColor getTimelineCamstandButtonBgOffColor() const { return m_timelineCamstandButtonBgOffColor; } - QImage getTimelineCamstandButtonOffImage() const { + QString getTimelineCamstandButtonOffImage() const { return m_timelineCamstandButtonOffImage; } // Timeline Lock Button void setTimelineLockButtonBgOnColor(const QColor &color) { m_timelineLockButtonBgOnColor = color; } - void setTimelineLockButtonOnImage(const QImage &image) { - m_timelineLockButtonOnImage = image; + void setTimelineLockButtonOnImage(const QString &svgFilePath) { + m_timelineLockButtonOnImage = svgFilePath; } void setTimelineLockButtonBgOffColor(const QColor &color) { m_timelineLockButtonBgOffColor = color; } - void setTimelineLockButtonOffImage(const QImage &image) { - m_timelineLockButtonOffImage = image; + void setTimelineLockButtonOffImage(const QString &svgFilePath) { + m_timelineLockButtonOffImage = svgFilePath; } QColor getTimelineLockButtonBgOnColor() const { return m_timelineLockButtonBgOnColor; } - QImage getTimelineLockButtonOnImage() const { + QString getTimelineLockButtonOnImage() const { return m_timelineLockButtonOnImage; } QColor getTimelineLockButtonBgOffColor() const { return m_timelineLockButtonBgOffColor; } - QImage getTimelineLockButtonOffImage() const { + QString getTimelineLockButtonOffImage() const { return m_timelineLockButtonOffImage; } // Timeline Config Button void setTimelineConfigButtonBgColor(const QColor &color) { m_timelineConfigButtonBgColor = color; } - void setTimelineConfigButtonImage(const QImage &image) { - m_timelineConfigButtonImage = image; + void setTimelineConfigButtonImage(const QString &svgFilePath) { + m_timelineConfigButtonImage = svgFilePath; } QColor getTimelineConfigButtonBgColor() const { return m_timelineConfigButtonBgColor; } - QImage getTimelineConfigButtonImage() const { + QString getTimelineConfigButtonImage() const { return m_timelineConfigButtonImage; } // Layer Header icons - void setLayerHeaderPreviewImage(const QImage &image) { - m_layerHeaderPreviewImage = image; + void setLayerHeaderPreviewImage(const QString &svgFilePath) { + m_layerHeaderPreviewImage = svgFilePath; } - void setLayerHeaderPreviewOverImage(const QImage &image) { - m_layerHeaderPreviewOverImage = image; + void setLayerHeaderPreviewOverImage(const QString &svgFilePath) { + m_layerHeaderPreviewOverImage = svgFilePath; } - void setLayerHeaderCamstandImage(const QImage &image) { - m_layerHeaderCamstandImage = image; + void setLayerHeaderCamstandImage(const QString &svgFilePath) { + m_layerHeaderCamstandImage = svgFilePath; } - void setLayerHeaderCamstandOverImage(const QImage &image) { - m_layerHeaderCamstandOverImage = image; + void setLayerHeaderCamstandOverImage(const QString &svgFilePath) { + m_layerHeaderCamstandOverImage = svgFilePath; } - void setLayerHeaderLockImage(const QImage &image) { - m_layerHeaderLockImage = image; + void setLayerHeaderLockImage(const QString &svgFilePath) { + m_layerHeaderLockImage = svgFilePath; } - void setLayerHeaderLockOverImage(const QImage &image) { - m_layerHeaderLockOverImage = image; + void setLayerHeaderLockOverImage(const QString &svgFilePath) { + m_layerHeaderLockOverImage = svgFilePath; } - QImage getLayerHeaderPreviewImage() const { + QString getLayerHeaderPreviewImage() const { return m_layerHeaderPreviewImage; } - QImage getLayerHeaderPreviewOverImage() const { + QString getLayerHeaderPreviewOverImage() const { return m_layerHeaderPreviewOverImage; } - QImage getLayerHeaderCamstandImage() const { + QString getLayerHeaderCamstandImage() const { return m_layerHeaderCamstandImage; } - QImage getLayerHeaderCamstandOverImage() const { + QString getLayerHeaderCamstandOverImage() const { return m_layerHeaderCamstandOverImage; } - QImage getLayerHeaderLockImage() const { return m_layerHeaderLockImage; } - QImage getLayerHeaderLockOverImage() const { + QString getLayerHeaderLockImage() const { return m_layerHeaderLockImage; } + QString getLayerHeaderLockOverImage() const { return m_layerHeaderLockOverImage; } - void getButton(const int &btype, QColor &bgColor, QImage &iconImage, + void getButton(const int &btype, QColor &bgColor, QString &svgIconPath, bool isTimeline = false); // convert the last one digit of the frame number to alphabet diff --git a/toonz/sources/toonzqt/functionsheet.cpp b/toonz/sources/toonzqt/functionsheet.cpp index 96ddedc..6cf78ba 100644 --- a/toonz/sources/toonzqt/functionsheet.cpp +++ b/toonz/sources/toonzqt/functionsheet.cpp @@ -196,8 +196,7 @@ FunctionSheetButtonArea::FunctionSheetButtonArea(QWidget *parent) m_syncSizeBtn = new QPushButton("", this); m_syncSizeBtn->setCheckable(true); m_syncSizeBtn->setFixedSize(20, 20); - static QPixmap syncScaleImg = - recolorPixmap(svgToPixmap(getIconThemePath("actions/17/syncscale.svg"))); + static QPixmap syncScaleImg = generateIconPixmap("syncscale"); QPixmap offPm(17, 17); offPm.fill(Qt::transparent); { diff --git a/toonz/sources/toonzqt/gutil.cpp b/toonz/sources/toonzqt/gutil.cpp index a02ec0d..0904f06 100644 --- a/toonz/sources/toonzqt/gutil.cpp +++ b/toonz/sources/toonzqt/gutil.cpp @@ -17,6 +17,7 @@ #include "tmsgcore.h" // Qt includes +#include #include #include #include @@ -33,6 +34,7 @@ #include #include #include +#include using namespace DVGui; @@ -185,40 +187,83 @@ QPixmap scalePixmapKeepingAspectRatio(QPixmap pixmap, QSize size, //----------------------------------------------------------------------------- -QPixmap svgToPixmap(const QString &svgFilePath, const QSize &size, - Qt::AspectRatioMode aspectRatioMode, QColor bgColor) { - static int devPixRatio = getHighestDevicePixelRatio(); - QSvgRenderer svgRenderer(svgFilePath); - QSize pixmapSize; - QRectF renderRect; - if (size.isEmpty()) { - pixmapSize = svgRenderer.defaultSize() * devPixRatio; - renderRect = QRectF(QPointF(), QSizeF(pixmapSize)); +int getDevicePixelRatio(const QWidget *widget) { + if (hasScreensWithDifferentDevPixRatio() && widget) { +#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)) + return widget->screen()->devicePixelRatio(); +#else + if (!widget->windowHandle()) widget->winId(); + if (widget->windowHandle()) + return widget->windowHandle()->devicePixelRatio(); +#endif + } + static int devPixRatio = QApplication::desktop()->devicePixelRatio(); + return devPixRatio; +} + +//----------------------------------------------------------------------------- + +// Calculate render params for use by svgToImage() and svgToPixmap() +SvgRenderParams calculateSvgRenderParams(const QSize &desiredSize, + QSize &imageSize, + Qt::AspectRatioMode aspectRatioMode) { + SvgRenderParams params; + if (desiredSize.isEmpty()) { + params.size = imageSize; + params.rect = QRectF(QPointF(), QSizeF(params.size)); } else { - pixmapSize = size * devPixRatio; + params.size = desiredSize; if (aspectRatioMode == Qt::KeepAspectRatio || aspectRatioMode == Qt::KeepAspectRatioByExpanding) { - QSize imgSize = svgRenderer.defaultSize(); - QPointF scaleFactor((float)pixmapSize.width() / (float)imgSize.width(), - (float)pixmapSize.height() / (float)imgSize.height()); + QPointF scaleFactor( + (float)params.size.width() / (float)imageSize.width(), + (float)params.size.height() / (float)imageSize.height()); float factor = (aspectRatioMode == Qt::KeepAspectRatio) ? std::min(scaleFactor.x(), scaleFactor.y()) : std::max(scaleFactor.x(), scaleFactor.y()); - QSizeF renderSize(factor * (float)imgSize.width(), - factor * (float)imgSize.height()); + QSizeF renderSize(factor * (float)imageSize.width(), + factor * (float)imageSize.height()); QPointF topLeft( - ((float)pixmapSize.width() - renderSize.width()) * 0.5f, - ((float)pixmapSize.height() - renderSize.height()) * 0.5f); - renderRect = QRectF(topLeft, renderSize); + ((float)params.size.width() - renderSize.width()) * 0.5f, + ((float)params.size.height() - renderSize.height()) * 0.5f); + params.rect = QRectF(topLeft, renderSize); } else { // Qt::IgnoreAspectRatio: - renderRect = QRectF(QPointF(), QSizeF(pixmapSize)); + params.rect = QRectF(QPointF(), QSizeF(params.size)); } } - QPixmap pixmap(pixmapSize); + return params; +} + +//----------------------------------------------------------------------------- + +QPixmap svgToPixmap(const QString &svgFilePath, QSize size, + Qt::AspectRatioMode aspectRatioMode, QColor bgColor) { + if (svgFilePath.isEmpty()) return QPixmap(); + + QSvgRenderer svgRenderer(svgFilePath); + + // Check if SVG file was loaded correctly + if (!svgRenderer.isValid()) { + qDebug() << "Invalid SVG file:" << svgFilePath; + return QPixmap(); + } + + static int devPixRatio = getHighestDevicePixelRatio(); + if (!size.isEmpty()) size *= devPixRatio; + + QSize imageSize = svgRenderer.defaultSize() * devPixRatio; + SvgRenderParams params = + calculateSvgRenderParams(size, imageSize, aspectRatioMode); + QPixmap pixmap(params.size); QPainter painter; pixmap.fill(bgColor); - painter.begin(&pixmap); - svgRenderer.render(&painter, renderRect); + + if (!painter.begin(&pixmap)) { + qDebug() << "Failed to begin QPainter on pixmap"; + return QPixmap(); + } + + svgRenderer.render(&painter, params.rect); painter.end(); pixmap.setDevicePixelRatio(devPixRatio); return pixmap; @@ -226,290 +271,256 @@ QPixmap svgToPixmap(const QString &svgFilePath, const QSize &size, //----------------------------------------------------------------------------- -int getDevicePixelRatio(const QWidget *widget) { - if (hasScreensWithDifferentDevPixRatio() && widget) { -#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)) - return widget->screen()->devicePixelRatio(); -#else - if (!widget->windowHandle()) widget->winId(); - if (widget->windowHandle()) - return widget->windowHandle()->devicePixelRatio(); -#endif +QImage svgToImage(const QString &svgFilePath, QSize size, + Qt::AspectRatioMode aspectRatioMode, QColor bgColor) { + if (svgFilePath.isEmpty()) return QImage(); + + QSvgRenderer svgRenderer(svgFilePath); + + // Check if SVG file was loaded correctly + if (!svgRenderer.isValid()) { + qDebug() << "Invalid SVG file:" << svgFilePath; + return QImage(); } - static int devPixRatio = QApplication::desktop()->devicePixelRatio(); - return devPixRatio; + + static int devPixRatio = getHighestDevicePixelRatio(); + + QSize imageSize = svgRenderer.defaultSize() * devPixRatio; + SvgRenderParams params = + calculateSvgRenderParams(size, imageSize, aspectRatioMode); + QImage image(params.size, QImage::Format_ARGB32_Premultiplied); + QPainter painter; + image.fill(bgColor); + + if (!painter.begin(&image)) { + qDebug() << "Failed to begin QPainter on image"; + return QImage(); + } + + svgRenderer.render(&painter, params.rect); + painter.end(); + return image; } //----------------------------------------------------------------------------- -QString getIconThemePath(const QString &fileSVGPath) { - // Use as follows: - // QPixmap pixmapIcon = getIconThemePath("path/to/file.svg"); - // Is equal to: :icons/*theme*/path/to/file.svg +// Change the opacity of a QImage (0.0 - 1.0) +QImage adjustImageOpacity(const QImage &input, qreal opacity) { + if (input.isNull()) return QImage(); + + QImage result(input.size(), QImage::Format_ARGB32_Premultiplied); - // Set themeable directory - static QString theme = Preferences::instance()->getIconTheme() - ? ":icons/dark/" - : ":icons/light/"; + QPainter painter(&result); + if (!painter.isActive()) return QImage(); - // If no file in light icon theme directory, fallback to dark directory - if (!QFile::exists(QString(theme + fileSVGPath))) theme = ":icons/dark/"; + painter.setCompositionMode(QPainter::CompositionMode_Source); + painter.fillRect(result.rect(), Qt::transparent); + painter.setCompositionMode(QPainter::CompositionMode_SourceOver); + painter.drawImage(0, 0, input); + painter.setCompositionMode(QPainter::CompositionMode_DestinationIn); + painter.fillRect( + result.rect(), + QColor(0, 0, 0, qBound(0, static_cast(opacity * 255), 255))); + painter.end(); - return theme + fileSVGPath; + return result; } //----------------------------------------------------------------------------- -QPixmap compositePixmap(QPixmap pixmap, const qreal &opacity, const QSize &size, - const int leftAdj, const int topAdj, QColor bgColor) { - static int devPixRatio = getHighestDevicePixelRatio(); +// Resizes a QImage, if scaleInput is true then input image will scale according +// to newSize otherwise the input image will be centered and not scaled +QImage compositeImage(const QImage &input, QSize newSize, bool scaleInput, + QColor bgColor) { + if (input.isNull()) return QImage(); + + int devPixRatio = getHighestDevicePixelRatio(); + + int w, h, x = 0, y = 0; + if (newSize.isEmpty()) { + w = input.width(); + h = input.height(); + } else { + w = newSize.width() * devPixRatio; + h = newSize.height() * devPixRatio; + if (!scaleInput) { + x = (w - input.width()) / 2; + y = (h - input.height()) / 2; + } + } + + QImage newImage(w, h, QImage::Format_ARGB32_Premultiplied); + newImage.fill(bgColor); + + if (scaleInput) { + return input.scaled(w, h, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); + } else { + QPainter painter(&newImage); + if (!painter.isActive()) return QImage(); + painter.drawImage(QPoint(x, y), input); + painter.end(); - // Sets size of destination pixmap for source to be drawn onto, if size is - // empty use source pixmap size, else use custom size. - QPixmap destination(size.isEmpty() ? pixmap.size() : size * devPixRatio); - destination.setDevicePixelRatio(devPixRatio); - destination.fill(bgColor); - - if (!pixmap.isNull()) { - QPainter p(&destination); - pixmap = pixmap.scaled(pixmap.size(), Qt::KeepAspectRatio); - pixmap.setDevicePixelRatio(devPixRatio); - p.setBackgroundMode(Qt::TransparentMode); - p.setBackground(QBrush(Qt::transparent)); - p.eraseRect(pixmap.rect()); - p.setOpacity(opacity); - p.drawPixmap(leftAdj, topAdj, pixmap); + return newImage; } - return destination; } //----------------------------------------------------------------------------- -QPixmap recolorPixmap(QPixmap pixmap, QColor color) { - // Change black pixels to any chosen color - QImage img = pixmap.toImage().convertToFormat(QImage::Format_ARGB32); - for (int y = 0; y < img.height(); y++) { - QRgb *pixel = reinterpret_cast(img.scanLine(y)); - QRgb *end = pixel + img.width(); - for (; pixel != end; pixel++) { - // Only recolor zero value (black) pixels - if (QColor::fromRgba(*pixel).value() == 0) - *pixel = - QColor(color.red(), color.green(), color.blue(), qAlpha(*pixel)) - .rgba(); - } - } - pixmap = QPixmap::fromImage(img); +// Convert QImage to QPixmap and set device pixel ratio +QPixmap convertImageToPixmap(const QImage &image) { + if (image.isNull()) return QPixmap(); + + QPixmap pixmap(QPixmap::fromImage(image)); + int devPixRatio = getHighestDevicePixelRatio(); + pixmap.setDevicePixelRatio(devPixRatio); + return pixmap; } //----------------------------------------------------------------------------- -QIcon createQIcon(const char *iconSVGName, bool useFullOpacity, - bool isForMenuItem) { - static int devPixRatio = getHighestDevicePixelRatio(); +// Load, theme colorize and change opacity of an icon image +QImage generateIconImage(const QString &iconSVGName, qreal opacity, + QSize newSize, Qt::AspectRatioMode aspectRatioMode) { + static ThemeManager &themeManager = ThemeManager::getInstance(); - QIcon themeIcon = QIcon::fromTheme(iconSVGName); + if (iconSVGName.isEmpty() || !themeManager.hasIcon(iconSVGName)) { + return QImage(); + } - // Get icon dimensions - QSize iconSize(0, 0); - for (QList sizes = themeIcon.availableSizes(); !sizes.isEmpty(); - sizes.removeFirst()) - if (sizes.first().width() > iconSize.width()) - iconSize = sizes.first() * devPixRatio; + int devPixRatio = getHighestDevicePixelRatio(); + newSize *= devPixRatio; - // Control lightness of the icons - const qreal activeOpacity = 1; - const qreal baseOpacity = useFullOpacity ? 1 : 0.8; - const qreal disabledOpacity = 0.15; + // Path to icon image + const QString imgPath = themeManager.getIconPath(iconSVGName); - // Pseudo state name strings - QString overStr = QString(iconSVGName) + "_over"; - QString onStr = QString(iconSVGName) + "_on"; + // Convert SVG to QImage + QImage image(svgToImage(imgPath, newSize, aspectRatioMode)); - //---------- + // Colorize QImage + image = themeManager.recolorBlackPixels(image); - // Base pixmap - QPixmap themeIconPixmap(recolorPixmap(themeIcon.pixmap(iconSize))); - if (!themeIconPixmap.isNull()) { // suppress message - themeIconPixmap.setDevicePixelRatio(devPixRatio); - themeIconPixmap = themeIconPixmap.scaled(iconSize, Qt::KeepAspectRatio, - Qt::SmoothTransformation); - } + // Change opacity if required + if (opacity != qreal(1.0)) image = adjustImageOpacity(image, opacity); - // Over pixmap - QPixmap overPixmap(recolorPixmap(QIcon::fromTheme(overStr).pixmap(iconSize))); - if (!overPixmap.isNull()) { // suppress message - overPixmap.setDevicePixelRatio(devPixRatio); - overPixmap = overPixmap.scaled(iconSize, Qt::KeepAspectRatio, - Qt::SmoothTransformation); - } + return image; +} - // On pixmap - QPixmap onPixmap(recolorPixmap(QIcon::fromTheme(onStr).pixmap(iconSize))); - if (!onPixmap.isNull()) { // suppress message - onPixmap.setDevicePixelRatio(devPixRatio); - onPixmap = onPixmap.scaled(iconSize, Qt::KeepAspectRatio, - Qt::SmoothTransformation); - } +//----------------------------------------------------------------------------- - //---------- +// Load, theme colorize and change opacity of an icon image file +QPixmap generateIconPixmap(const QString &iconSVGName, qreal opacity, + QSize newSize, Qt::AspectRatioMode aspectRatioMode) { + QImage image = + generateIconImage(iconSVGName, opacity, newSize, aspectRatioMode); + return convertImageToPixmap(image); +} - QIcon icon; +//----------------------------------------------------------------------------- -#ifdef _WIN32 - bool showIconInMenu = Preferences::instance()->getBoolValue(showIconsInMenu); - // set transparent icon - if (isForMenuItem && - themeIconPixmap.size() == QSize(16 * devPixRatio, 16 * devPixRatio) && - !showIconInMenu) { - static QPixmap emptyPm(16 * devPixRatio, 16 * devPixRatio); - emptyPm.fill(Qt::transparent); +// Process and populate all modes and states of a QIcon +void addImagesToIcon(QIcon &icon, const QImage &baseImg, const QImage &overImg, + const QImage &onImg, bool useFullOpacity) { + if (baseImg.isNull()) return; - icon.addPixmap(emptyPm, QIcon::Normal, QIcon::Off); - icon.addPixmap(emptyPm, QIcon::Normal, QIcon::On); - icon.addPixmap(emptyPm, QIcon::Disabled, QIcon::Off); - icon.addPixmap(emptyPm, QIcon::Disabled, QIcon::On); - icon.addPixmap(emptyPm, QIcon::Active); - } else -#endif - { - // Base icon - icon.addPixmap(compositePixmap(themeIconPixmap, baseOpacity), QIcon::Normal, - QIcon::Off); - icon.addPixmap(compositePixmap(themeIconPixmap, disabledOpacity), - QIcon::Disabled, QIcon::Off); - - // Over icon - icon.addPixmap(!overPixmap.isNull() - ? compositePixmap(overPixmap, activeOpacity) - : compositePixmap(themeIconPixmap, activeOpacity), - QIcon::Active); - - // On icon - if (!onPixmap.isNull()) { - icon.addPixmap(compositePixmap(onPixmap, activeOpacity), QIcon::Normal, - QIcon::On); - icon.addPixmap(compositePixmap(onPixmap, disabledOpacity), - QIcon::Disabled, QIcon::On); - } else { - icon.addPixmap(compositePixmap(themeIconPixmap, activeOpacity), - QIcon::Normal, QIcon::On); - icon.addPixmap(compositePixmap(themeIconPixmap, disabledOpacity), - QIcon::Disabled, QIcon::On); - } - } - //---------- - - // For icons intended for menus that are 16x16 in dimensions, to repurpose - // them for use in toolbars that are set for 20x20 we want to draw them onto a - // 20x20 pixmap so they don't get resized in the GUI, they will be loaded into - // the icon along with the original 16x16 pixmap. - - if (themeIconPixmap.size() == QSize(16 * devPixRatio, 16 * devPixRatio)) { - const QSize drawOnSize(20, 20); - const int x = (drawOnSize.width() - 16) / 2; // left adjust - const int y = (drawOnSize.height() - 16) / 2; // top adjust - - // Base icon - icon.addPixmap( - compositePixmap(themeIconPixmap, baseOpacity, drawOnSize, x, y), - QIcon::Normal, QIcon::Off); - icon.addPixmap( - compositePixmap(themeIconPixmap, disabledOpacity, drawOnSize, x, y), - QIcon::Disabled, QIcon::Off); - - // Over icon - icon.addPixmap( - !overPixmap.isNull() - ? compositePixmap(overPixmap, activeOpacity, drawOnSize, x, y) - : compositePixmap(themeIconPixmap, activeOpacity, drawOnSize, x, y), - QIcon::Active); - - // On icon - if (!onPixmap.isNull()) { - icon.addPixmap(compositePixmap(onPixmap, activeOpacity, drawOnSize, x, y), - QIcon::Normal, QIcon::On); - icon.addPixmap( - compositePixmap(onPixmap, disabledOpacity, drawOnSize, x, y), - QIcon::Disabled, QIcon::On); - } else { - icon.addPixmap( - compositePixmap(themeIconPixmap, activeOpacity, drawOnSize, x, y), - QIcon::Normal, QIcon::On); - icon.addPixmap( - compositePixmap(themeIconPixmap, disabledOpacity, drawOnSize, x, y), - QIcon::Disabled, QIcon::On); - } - } + ThemeManager &themeManager = ThemeManager::getInstance(); + const qreal offOpacity = useFullOpacity ? 1.0 : themeManager.getOffOpacity(); + const qreal onOpacity = themeManager.getOnOpacity(); + const qreal disabledOpacity = themeManager.getDisabledOpacity(); - return icon; + // Generate more images using input images for other modes and states + QImage offImg = adjustImageOpacity(baseImg, offOpacity); + QImage disabledImg = adjustImageOpacity(baseImg, disabledOpacity); + QImage onDisabledImg = + !onImg.isNull() ? adjustImageOpacity(onImg, disabledOpacity) : QImage(); + + // Convert images to pixmaps and set device pixel ratio + QPixmap basePm(convertImageToPixmap(baseImg)); + QPixmap offPm(convertImageToPixmap(offImg)); + QPixmap disabledPm(convertImageToPixmap(disabledImg)); + QPixmap overPm(convertImageToPixmap(overImg)); + QPixmap onPm(convertImageToPixmap(onImg)); + QPixmap onDisabledPm(convertImageToPixmap(onDisabledImg)); + + // Add pixmaps to icon and fallback to basePm if 'over' and 'on' are null + icon.addPixmap(offPm, QIcon::Normal, QIcon::Off); + icon.addPixmap(disabledPm, QIcon::Disabled, QIcon::Off); + icon.addPixmap(!overPm.isNull() ? overPm : basePm, QIcon::Active); + icon.addPixmap(!onPm.isNull() ? onPm : basePm, QIcon::Normal, QIcon::On); + icon.addPixmap(!onPm.isNull() ? onDisabledPm : disabledPm, QIcon::Disabled, + QIcon::On); } //----------------------------------------------------------------------------- -void addSpecifiedSizedImageToIcon(QIcon &icon, const char *iconSVGName, - QSize newSize) { - static int devPixRatio = getHighestDevicePixelRatio(); - newSize *= devPixRatio; - QIcon themeIcon = QIcon::fromTheme(iconSVGName); - // Pseudo state name strings - QString overStr = QString(iconSVGName) + "_over"; - QString onStr = QString(iconSVGName) + "_on"; - // Control lightness of the icons - const qreal activeOpacity = 1; - const qreal baseOpacity = 0.8; - const qreal disabledOpacity = 0.15; - //---------- - - // Base pixmap - QPixmap themeIconPixmap(recolorPixmap(themeIcon.pixmap(newSize))); - if (!themeIconPixmap.isNull()) { // suppress message - themeIconPixmap.setDevicePixelRatio(devPixRatio); - themeIconPixmap = themeIconPixmap.scaled(newSize, Qt::KeepAspectRatio, - Qt::SmoothTransformation); +// Add the same pixmap to all modes and states of a QIcon +void addPixmapToAllModesAndStates(QIcon &icon, const QPixmap &pixmap) { + QIcon::Mode modes[] = {QIcon::Normal, QIcon::Disabled, QIcon::Active, + QIcon::Selected}; + QIcon::State states[] = {QIcon::On, QIcon::Off}; + + for (const auto &mode : modes) { + for (const auto &state : states) { + icon.addPixmap(pixmap, mode, state); + } } +} + +//----------------------------------------------------------------------------- - // Over pixmap - QPixmap overPixmap(recolorPixmap(QIcon::fromTheme(overStr).pixmap(newSize))); - if (!overPixmap.isNull()) { // suppress message - overPixmap.setDevicePixelRatio(devPixRatio); - overPixmap = overPixmap.scaled(newSize, Qt::KeepAspectRatio, - Qt::SmoothTransformation); +/// @brief Return a themed icon +/// @param iconSVGName Name of the icon (SVG file base name) +/// @param useFullOpacity If true the icon will be max brightness +/// @param isForMenuItem For special handling of menu icons +/// @param newSize Render the SVG images of the icon at the specified size +/// @return QIcon +QIcon createQIcon(const QString &iconSVGName, bool useFullOpacity, + bool isForMenuItem, QSize newSize) { + static ThemeManager &themeManager = ThemeManager::getInstance(); + if (iconSVGName.isEmpty() || !themeManager.hasIcon(iconSVGName)) { + // Use debug to check if something calls for an icon that doesn't exist + //qDebug () << "File not found:" << iconSVGName; + return QIcon(); } - // On pixmap - QPixmap onPixmap(recolorPixmap(QIcon::fromTheme(onStr).pixmap(newSize))); - if (!onPixmap.isNull()) { // suppress message - onPixmap.setDevicePixelRatio(devPixRatio); - onPixmap = - onPixmap.scaled(newSize, Qt::KeepAspectRatio, Qt::SmoothTransformation); + static int devPixRatio = getHighestDevicePixelRatio(); + + QImage baseImg(generateIconImage(iconSVGName, qreal(1.0), newSize)); + QImage overImg(generateIconImage(iconSVGName + "_over", qreal(1.0), newSize)); + QImage onImg(generateIconImage(iconSVGName + "_on", qreal(1.0), newSize)); + + QIcon icon; + + addImagesToIcon(icon, baseImg, overImg, onImg, useFullOpacity); + + // START_BUG_WORKAROUND: #20230627 + // Set an empty pixmap for menu icons when hiding icons from menus is true, + // search bug ID for more info. +#ifdef _WIN32 + bool showIconInMenu = Preferences::instance()->getBoolValue(showIconsInMenu); + if (isForMenuItem && baseImg.width() == (16 * devPixRatio) && + baseImg.height() == (16 * devPixRatio) && !showIconInMenu) { + static QPixmap emptyPm(16 * devPixRatio, 16 * devPixRatio); + emptyPm.fill(Qt::transparent); + addPixmapToAllModesAndStates(icon, emptyPm); + } else +#endif // END_BUG_WORKAROUND + { + addImagesToIcon(icon, baseImg, overImg, onImg, useFullOpacity); } - // Base icon - icon.addPixmap(compositePixmap(themeIconPixmap, baseOpacity), QIcon::Normal, - QIcon::Off); - icon.addPixmap(compositePixmap(themeIconPixmap, disabledOpacity), - QIcon::Disabled, QIcon::Off); - - // Over icon - icon.addPixmap(!overPixmap.isNull() - ? compositePixmap(overPixmap, activeOpacity) - : compositePixmap(themeIconPixmap, activeOpacity), - QIcon::Active); - - // On icon - if (!onPixmap.isNull()) { - icon.addPixmap(compositePixmap(onPixmap, activeOpacity), QIcon::Normal, - QIcon::On); - icon.addPixmap(compositePixmap(onPixmap, disabledOpacity), QIcon::Disabled, - QIcon::On); - } else { - icon.addPixmap(compositePixmap(themeIconPixmap, activeOpacity), - QIcon::Normal, QIcon::On); - icon.addPixmap(compositePixmap(themeIconPixmap, disabledOpacity), - QIcon::Disabled, QIcon::On); + // For tool bars we draw menu sized icons onto tool bar sized images otherwise + // there can be scaling artifacts with high dpi and load these in addition + if (baseImg.width() == (16 * devPixRatio) && + baseImg.height() == (16 * devPixRatio)) { + QSize expandSize(20, 20); + QImage toolBaseImg(compositeImage(baseImg, expandSize)); + QImage toolOverImg(compositeImage(overImg, expandSize)); + QImage toolOnImg(compositeImage(onImg, expandSize)); + addImagesToIcon(icon, toolBaseImg, toolOverImg, toolOnImg, useFullOpacity); } + + return icon; } //----------------------------------------------------------------------------- @@ -548,11 +559,8 @@ QIcon createQIconOnOffPNG(const char *iconPNGName, bool withOver) { //----------------------------------------------------------------------------- QIcon createTemporaryIconFromName(const char *commandName) { - const int visibleIconSize = 20; - const int menubarIconSize = 16; - const qreal activeOpacity = 1; - const qreal baseOpacity = 0.8; - const qreal disabledOpacity = 0.15; + const int visibleIconSize = 20; + const int menubarIconSize = 16; QString name(commandName); QList iconChar; @@ -577,18 +585,19 @@ QIcon createTemporaryIconFromName(const char *commandName) { for (auto c : iconChar) iconStr.append(c); QIcon icon; - // prepare for both normal and high dpi + // Prepare for both normal and high dpi for (int devPixelRatio = 1; devPixelRatio <= 2; devPixelRatio++) { - QPixmap transparentPm(menubarIconSize * devPixelRatio, - menubarIconSize * devPixelRatio); - transparentPm.fill(Qt::transparent); + QImage transparentImg(menubarIconSize * devPixelRatio, + menubarIconSize * devPixelRatio, + QImage::Format_ARGB32); + transparentImg.fill(Qt::transparent); int pxSize = visibleIconSize * devPixelRatio; - QPixmap pixmap(pxSize, pxSize); + QImage charImg(pxSize, pxSize, QImage::Format_ARGB32_Premultiplied); QPainter painter; - pixmap.fill(Qt::transparent); - painter.begin(&pixmap); + charImg.fill(Qt::transparent); + painter.begin(&charImg); painter.setPen(Preferences::instance()->getIconTheme() ? Qt::black : Qt::white); @@ -601,29 +610,17 @@ QIcon createTemporaryIconFromName(const char *commandName) { QFont font = painter.font(); font.setPixelSize(pxSize); painter.setFont(font); - painter.drawText(rect, Qt::AlignCenter, iconStr); painter.end(); // For menu only - icon.addPixmap(transparentPm, QIcon::Normal, QIcon::Off); - icon.addPixmap(transparentPm, QIcon::Active); - icon.addPixmap(transparentPm, QIcon::Normal, QIcon::On); - icon.addPixmap(transparentPm, QIcon::Disabled, QIcon::Off); - icon.addPixmap(transparentPm, QIcon::Disabled, QIcon::On); + addPixmapToAllModesAndStates(icon, QPixmap::fromImage(transparentImg)); // For toolbars - icon.addPixmap(compositePixmap(pixmap, baseOpacity), QIcon::Normal, - QIcon::Off); - icon.addPixmap(compositePixmap(pixmap, disabledOpacity), QIcon::Disabled, - QIcon::Off); - icon.addPixmap(compositePixmap(pixmap, activeOpacity), QIcon::Active); - icon.addPixmap(compositePixmap(pixmap, activeOpacity), QIcon::Normal, - QIcon::On); - icon.addPixmap(compositePixmap(pixmap, disabledOpacity), QIcon::Disabled, - QIcon::On); + addImagesToIcon(icon, charImg); } + return icon; } @@ -843,3 +840,150 @@ void ToolBarContainer::paintEvent(QPaintEvent *event) { QPainter p(this); } QString operator+(const QString &a, const TFilePath &fp) { return a + QString::fromStdWString(fp.getWideString()); } + +//============================================================================= +// Theme Manager +//----------------------------------------------------------------------------- + +class ThemeManager::ThemeManagerImpl { +public: + QMap m_iconPaths; + qreal m_onOpacity = 1.0; + qreal m_offOpacity = 0.8; + qreal m_disabledOpacity = 0.3; +}; + +//----------------------------------------------------------------------------- + +ThemeManager::ThemeManager() : impl(new ThemeManagerImpl) {} + +//----------------------------------------------------------------------------- + +ThemeManager::~ThemeManager() {} + +//----------------------------------------------------------------------------- + +ThemeManager &ThemeManager::getInstance() { + static ThemeManager instance; + return instance; +} + +//----------------------------------------------------------------------------- + +// Populate a QMap with icon filepaths and assign their basename as the key +void ThemeManager::buildIconPathsMap(const QString &path) { + QDir dir(path); + if (!dir.exists(path)) { + qDebug() << "Resource path does not exist:" << path; + return; + } + + QDirIterator it(path, + QStringList() << "*.svg" + << "*.png", + QDir::Files, QDirIterator::Subdirectories); + + while (it.hasNext()) { + it.next(); + + const QString iconPath = it.fileInfo().filePath(); + const QString iconName = it.fileInfo().baseName(); + + if (!impl->m_iconPaths.contains(iconName)) { + impl->m_iconPaths.insert(iconName, iconPath); + } else { + qDebug() << "Icon with file name already exists in iconPaths, ensure " + "icons have unique file names:" + << "\nCurrently added:" << getIconPath(iconName) + << "\nTried to add:" << iconPath; + } + } +} + +//----------------------------------------------------------------------------- + +// Get the full filepath of an icon image by basename +QString ThemeManager::getIconPath(const QString &iconName) const { + return impl->m_iconPaths.value(iconName); +} + +//----------------------------------------------------------------------------- + +// Boolean to check if iconName is contained within the iconPaths QMap +bool ThemeManager::hasIcon(const QString &iconName) const { + return impl->m_iconPaths.contains(iconName); +} + +//----------------------------------------------------------------------------- + +qreal ThemeManager::getOnOpacity() const { return impl->m_onOpacity; } + +//----------------------------------------------------------------------------- + +qreal ThemeManager::getOffOpacity() const { return impl->m_offOpacity; } + +//----------------------------------------------------------------------------- + +qreal ThemeManager::getDisabledOpacity() const { + return impl->m_disabledOpacity; +} + +//----------------------------------------------------------------------------- + +// Colorize black pixels in a QImage while retaining other colors, however be +// mindful that if black pixels overlap color pixels it can cause artifacting +QImage ThemeManager::recolorBlackPixels(const QImage &input, QColor color) { + if (input.isNull() || color == Qt::black) return QImage(); + + // Default is icon theme color + if (!color.isValid()) + color = Preferences::instance()->getIconTheme() ? Qt::black : Qt::white; + + QImage image = input.convertToFormat(QImage::Format_ARGB32); + QRgb targetColor = color.rgb(); + int height = image.height(); + int width = image.width(); + for (int y = 0; y < height; ++y) { + QRgb *pixel = reinterpret_cast(image.scanLine(y)); + QRgb *end = pixel + width; + for (; pixel != end; ++pixel) { + if (qGray(*pixel) == 0) { + *pixel = (targetColor & 0x00FFFFFF) | (qAlpha(*pixel) << 24); + } + } + } + + return image; +} + +//----------------------------------------------------------------------------- + +// Colorize black pixels in a QPixmap while retaining other colors, however be +// mindful that if black pixels overlap color pixels if can cause artifacting +QPixmap ThemeManager::recolorBlackPixels(const QPixmap &input, QColor color) { + if (input.isNull() || color == Qt::black) return QPixmap(); + + QImage image = input.toImage(); + QImage recoloredImage = recolorBlackPixels(image, color); + QPixmap pixmap = convertImageToPixmap(recoloredImage); + + return pixmap; +} + +//----------------------------------------------------------------------------- + +// For debugging contents +void ThemeManager::printiconPathsMap() { + const QMap map = impl->m_iconPaths; + qDebug() << "Contents of QMap:"; + for (auto it = map.constBegin(); it != map.constEnd(); ++it) { + qDebug() << it.key() << ":" << it.value(); + } +} + +//----------------------------------------------------------------------------- + +// Public version of ThemeManager::getIconPath() +QString getIconPath(const QString &path) { + return ThemeManager::getInstance().getIconPath(path); +} diff --git a/toonz/sources/toonzqt/icongenerator.cpp b/toonz/sources/toonzqt/icongenerator.cpp index 0314ce2..560f3c0 100644 --- a/toonz/sources/toonzqt/icongenerator.cpp +++ b/toonz/sources/toonzqt/icongenerator.cpp @@ -504,14 +504,15 @@ IconRenderer::~IconRenderer() {} class NoImageIconRenderer final : public IconRenderer { public: - NoImageIconRenderer(const std::string &id, const TDimension &iconSize): - IconRenderer(id, iconSize) { } + NoImageIconRenderer(const std::string &id, const TDimension &iconSize) + : IconRenderer(id, iconSize) {} void run() override { try { TRaster32P ras(getIconSize()); ras->fill(TPixel32::Gray); setIcon(ras); - } catch(...){} + } catch (...) { + } } }; @@ -1105,9 +1106,9 @@ Qt::transparent) bbox = (bbox * icon->getBounds()) .enlarge(-1); // Add a 1 pixel transparent margin - this - //if (bbox.getLx() > 0 && - // bbox.getLy() > 0) // way the actual content doesn't look trimmed. - // ::makeChessBackground(icon->extract(bbox)); + // if (bbox.getLx() > 0 && + // bbox.getLy() > 0) // way the actual content doesn't look trimmed. + // ::makeChessBackground(icon->extract(bbox)); } else icon->fill(TPixel32(255, 0, 0)); @@ -1188,30 +1189,30 @@ void FileIconRenderer::run() { setIcon(rasterFromQImage(palette)); return; } else if (type == "svg") { - QPixmap svg(svgToPixmap(getIconThemePath("mimetypes/60/svg_icon.svg"), - QSize(iconSize.lx, iconSize.ly), - Qt::KeepAspectRatio)); - setIcon(rasterFromQPixmap(svg)); + QImage svg(generateIconImage("svg_icon", qreal(1.0), + QSize(iconSize.lx, iconSize.ly), + Qt::KeepAspectRatio)); + setIcon(rasterFromQImage(svg)); return; } else if (type == "tzu") { QImage palette(":Resources/tzuicon.png"); setIcon(rasterFromQImage(palette)); return; } else if (TFileType::getInfo(m_path) == TFileType::AUDIO_LEVEL) { - QPixmap loudspeaker( - svgToPixmap(getIconThemePath("mimetypes/60/audio_icon.svg"), - QSize(iconSize.lx, iconSize.ly), Qt::KeepAspectRatio)); - setIcon(rasterFromQPixmap(loudspeaker)); + QImage loudspeaker(generateIconImage("audio_icon", qreal(1.0), + QSize(iconSize.lx, iconSize.ly), + Qt::KeepAspectRatio)); + setIcon(rasterFromQImage(loudspeaker)); return; } else if (type == "scr") { QImage screensaver(":Resources/savescreen.png"); setIcon(rasterFromQImage(screensaver)); return; } else if (type == "psd") { - QPixmap psdPath(svgToPixmap(getIconThemePath("mimetypes/60/psd_icon.svg"), - QSize(iconSize.lx, iconSize.ly), - Qt::KeepAspectRatio)); - setIcon(rasterFromQPixmap(psdPath)); + QImage psdPath(generateIconImage("psd_icon", qreal(1.0), + QSize(iconSize.lx, iconSize.ly), + Qt::KeepAspectRatio)); + setIcon(rasterFromQImage(psdPath)); return; } else if (type == "mesh") iconRaster = IconGenerator::generateMeshFileIcon(m_path, iconSize, m_fid); @@ -1219,80 +1220,80 @@ void FileIconRenderer::run() { iconRaster = IconGenerator::generateRasterFileIcon(m_path, iconSize, m_fid); else if (type == "mpath") { - QPixmap motionPath( - svgToPixmap(getIconThemePath("mimetypes/60/motionpath_icon.svg"), - QSize(iconSize.lx, iconSize.ly), Qt::KeepAspectRatio)); - setIcon(rasterFromQPixmap(motionPath)); + QImage motionPath(generateIconImage("motionpath_icon", qreal(1.0), + QSize(iconSize.lx, iconSize.ly), + Qt::KeepAspectRatio)); + setIcon(rasterFromQImage(motionPath)); return; } else if (type == "curve") { - QPixmap curve(svgToPixmap(getIconThemePath("mimetypes/60/curve_icon.svg"), - QSize(iconSize.lx, iconSize.ly), - Qt::KeepAspectRatio)); - setIcon(rasterFromQPixmap(curve)); + QImage curve(generateIconImage("curve_icon", qreal(1.0), + QSize(iconSize.lx, iconSize.ly), + Qt::KeepAspectRatio)); + setIcon(rasterFromQImage(curve)); return; } else if (type == "cln") { - QPixmap cln(svgToPixmap(getIconThemePath("mimetypes/60/cleanup_icon.svg"), - QSize(iconSize.lx, iconSize.ly), - Qt::KeepAspectRatio)); - setIcon(rasterFromQPixmap(cln)); + QImage cln(generateIconImage("cleanup_icon", qreal(1.0), + QSize(iconSize.lx, iconSize.ly), + Qt::KeepAspectRatio)); + setIcon(rasterFromQImage(cln)); return; } else if (type == "tnzbat") { - QPixmap tnzBat( - svgToPixmap(getIconThemePath("mimetypes/60/tasklist_icon.svg"), - QSize(iconSize.lx, iconSize.ly), Qt::KeepAspectRatio)); - setIcon(rasterFromQPixmap(tnzBat)); + QImage tnzBat(generateIconImage("tasklist_icon", qreal(1.0), + QSize(iconSize.lx, iconSize.ly), + Qt::KeepAspectRatio)); + setIcon(rasterFromQImage(tnzBat)); return; } else if (type == "tls") { - QPixmap tls(svgToPixmap(":Resources/magpie.svg", - QSize(iconSize.lx, iconSize.ly), - Qt::KeepAspectRatio)); - setIcon(rasterFromQPixmap(tls)); + QImage tls(svgToImage(":Resources/magpie.svg", + QSize(iconSize.lx, iconSize.ly), + Qt::KeepAspectRatio)); + setIcon(rasterFromQImage(tls)); return; } else if (type == "xdts") { - QPixmap xdts(svgToPixmap(getIconThemePath("mimetypes/60/xdts_icon.svg"), - QSize(iconSize.lx, iconSize.ly), - Qt::KeepAspectRatio)); - setIcon(rasterFromQPixmap(xdts)); + QImage xdts(generateIconImage("xdts_icon", qreal(1.0), + QSize(iconSize.lx, iconSize.ly), + Qt::KeepAspectRatio)); + setIcon(rasterFromQImage(xdts)); return; } else if (type == "js") { - QPixmap script( - svgToPixmap(getIconThemePath("mimetypes/60/script_icon.svg"), - QSize(iconSize.lx, iconSize.ly), Qt::KeepAspectRatio)); - setIcon(rasterFromQPixmap(script)); + QImage script(generateIconImage("script_icon", qreal(1.0), + QSize(iconSize.lx, iconSize.ly), + Qt::KeepAspectRatio)); + setIcon(rasterFromQImage(script)); return; } else if (type == "json") { - QPixmap json(svgToPixmap(getIconThemePath("mimetypes/60/json_icon.svg"), - QSize(iconSize.lx, iconSize.ly), - Qt::KeepAspectRatio)); - setIcon(rasterFromQPixmap(json)); + QImage json(generateIconImage("json_icon", qreal(1.0), + QSize(iconSize.lx, iconSize.ly), + Qt::KeepAspectRatio)); + setIcon(rasterFromQImage(json)); return; } else { - QPixmap unknown( - svgToPixmap(getIconThemePath("mimetypes/60/unknown_icon.svg"), - QSize(iconSize.lx, iconSize.ly), Qt::KeepAspectRatio)); - setIcon(rasterFromQPixmap(unknown)); + QImage unknown(generateIconImage("unknown_icon", qreal(1.0), + QSize(iconSize.lx, iconSize.ly), + Qt::KeepAspectRatio)); + setIcon(rasterFromQImage(unknown)); return; } if (!iconRaster) { - QPixmap broken( - svgToPixmap(getIconThemePath("mimetypes/60/broken_icon.svg"), - QSize(iconSize.lx, iconSize.ly), Qt::KeepAspectRatio)); - setIcon(rasterFromQPixmap(broken)); + QImage broken(generateIconImage("broken_icon", qreal(1.0), + QSize(iconSize.lx, iconSize.ly), + Qt::KeepAspectRatio)); + setIcon(rasterFromQImage(broken)); return; } setIcon(iconRaster); } catch (const TImageVersionException &) { - QPixmap unknown( - svgToPixmap(getIconThemePath("mimetypes/60/unknown_icon.svg"), - QSize(iconSize.lx, iconSize.ly), Qt::KeepAspectRatio)); - setIcon(rasterFromQPixmap(unknown)); + QImage unknown(generateIconImage("unknown_icon", qreal(1.0), + QSize(iconSize.lx, iconSize.ly), + Qt::KeepAspectRatio)); + setIcon(rasterFromQImage(unknown)); } catch (...) { - QPixmap broken(svgToPixmap(getIconThemePath("mimetypes/60/broken_icon.svg"), - QSize(iconSize.lx, iconSize.ly), - Qt::KeepAspectRatio)); - setIcon(rasterFromQPixmap(broken)); + QImage broken(generateIconImage("broken_icon", qreal(1.0), + QSize(iconSize.lx, iconSize.ly), + Qt::KeepAspectRatio)); + setIcon(rasterFromQImage(broken)); } } diff --git a/toonz/sources/toonzqt/menubarcommand.cpp b/toonz/sources/toonzqt/menubarcommand.cpp index e8cd8c6..e39dc45 100644 --- a/toonz/sources/toonzqt/menubarcommand.cpp +++ b/toonz/sources/toonzqt/menubarcommand.cpp @@ -410,8 +410,8 @@ void CommandManager::enlargeIcon(CommandId id, const QSize dstSize) { return; } - addSpecifiedSizedImageToIcon(icon, iconSVGName, dstSize); - + icon = createQIcon(iconSVGName, false, false, dstSize); + action->setIcon(icon); }