OpenToonz - An open-source full-featured 2D animation creation software
C
simplify
konero2be4595b8199
diff --git a/stuff/config/qss/Blue/Blue.qss b/stuff/config/qss/Blue/Blue.qssindex 7ccf8fa49..8f575e059 100644--- a/stuff/config/qss/Blue/Blue.qss+++ b/stuff/config/qss/Blue/Blue.qss@@ -363,10 +363,6 @@ TPanelTitleBar {min-height: 18;qproperty-TitleColor: #8c9093;qproperty-ActiveTitleColor: #43AEE5;- qproperty-BorderPixmap: url('none');- qproperty-ActiveBorderPixmap: url('../Default/imgs/white/none');- qproperty-FloatBorderPixmap: url('none');- qproperty-FloatActiveBorderPixmap: url('../Default/imgs/white/none');qproperty-OverColor: #C34040;}TPanelTitleBarButton {diff --git a/stuff/config/qss/Dark/Dark.qss b/stuff/config/qss/Dark/Dark.qssindex 891ba3d77..767bb7405 100644--- a/stuff/config/qss/Dark/Dark.qss+++ b/stuff/config/qss/Dark/Dark.qss@@ -363,10 +363,6 @@ TPanelTitleBar {min-height: 18;qproperty-TitleColor: #7d7d7d;qproperty-ActiveTitleColor: #fff;- qproperty-BorderPixmap: url('none');- qproperty-ActiveBorderPixmap: url('../Default/imgs/white/none');- qproperty-FloatBorderPixmap: url('none');- qproperty-FloatActiveBorderPixmap: url('../Default/imgs/white/none');qproperty-OverColor: #C34040;}TPanelTitleBarButton {diff --git a/stuff/config/qss/Default/Default.qss b/stuff/config/qss/Default/Default.qssindex 65b69ab7d..65e584642 100644--- a/stuff/config/qss/Default/Default.qss+++ b/stuff/config/qss/Default/Default.qss@@ -363,10 +363,6 @@ TPanelTitleBar {min-height: 18;qproperty-TitleColor: #949494;qproperty-ActiveTitleColor: #fff;- qproperty-BorderPixmap: url('none');- qproperty-ActiveBorderPixmap: url('imgs/white/none');- qproperty-FloatBorderPixmap: url('none');- qproperty-FloatActiveBorderPixmap: url('imgs/white/none');qproperty-OverColor: #C34040;}TPanelTitleBarButton {diff --git a/stuff/config/qss/Default/less/layouts/mainwindow.less b/stuff/config/qss/Default/less/layouts/mainwindow.lessindex e16a9f0ef..a02e5889e 100644--- a/stuff/config/qss/Default/less/layouts/mainwindow.less+++ b/stuff/config/qss/Default/less/layouts/mainwindow.less@@ -190,13 +190,8 @@ TPanelTitleBar {min-height: 18;qproperty-TitleColor: @title-text-color;qproperty-ActiveTitleColor: @title-text-color-active;- // QSS only works when pixmaps are set to 'none'- qproperty-BorderPixmap: url('none');- qproperty-ActiveBorderPixmap: url('@{img-url}/@{title-active-border-pixmap}');- qproperty-FloatBorderPixmap: url('none');- qproperty-FloatActiveBorderPixmap: url('@{img-url}/@{title-active-border-pixmap}');- // Buttons+ // Close button rollover colorqproperty-OverColor: @title-close-over-color;}diff --git a/stuff/config/qss/Light/Light.qss b/stuff/config/qss/Light/Light.qssindex e35a57396..56a505d64 100644--- a/stuff/config/qss/Light/Light.qss+++ b/stuff/config/qss/Light/Light.qss@@ -363,10 +363,6 @@ TPanelTitleBar {min-height: 18;qproperty-TitleColor: rgba(0, 0, 0, 0.5);qproperty-ActiveTitleColor: #000;- qproperty-BorderPixmap: url('none');- qproperty-ActiveBorderPixmap: url('../Default/imgs/black/none');- qproperty-FloatBorderPixmap: url('none');- qproperty-FloatActiveBorderPixmap: url('../Default/imgs/black/none');qproperty-OverColor: #e0625c;}TPanelTitleBarButton {diff --git a/stuff/config/qss/Neutral/Neutral.qss b/stuff/config/qss/Neutral/Neutral.qssindex f194e5cd8..75b9ed363 100644--- a/stuff/config/qss/Neutral/Neutral.qss+++ b/stuff/config/qss/Neutral/Neutral.qss@@ -363,10 +363,6 @@ TPanelTitleBar {min-height: 18;qproperty-TitleColor: #000;qproperty-ActiveTitleColor: rgba(255, 255, 255, 0.8);- qproperty-BorderPixmap: url('none');- qproperty-ActiveBorderPixmap: url('../Default/imgs/black/none');- qproperty-FloatBorderPixmap: url('none');- qproperty-FloatActiveBorderPixmap: url('../Default/imgs/black/none');qproperty-OverColor: #bd5454;}TPanelTitleBarButton {diff --git a/toonz/sources/toonz/pane.cpp b/toonz/sources/toonz/pane.cppindex 2b8cc93f9..d843e51a6 100644--- a/toonz/sources/toonz/pane.cpp+++ b/toonz/sources/toonz/pane.cpp@@ -239,14 +239,13 @@ void TPanel::zoomContentsAndFitGeometry(bool forward) {TPanelTitleBarButton::TPanelTitleBarButton(QWidget *parent,const QString &standardPixmapName): QWidget(parent)- , m_standardPixmap(standardPixmapName), m_standardPixmapName(standardPixmapName), m_rollover(false), m_pressed(false), m_buttonSet(0), m_id(0) {- setFixedSize(m_standardPixmap.size());- QMap<QString, QPixmap> m_pixmaps;+ updatePixmaps();+ setFixedSize(m_onPixmap.size());}//-----------------------------------------------------------------------------@@ -254,12 +253,14 @@ TPanelTitleBarButton::TPanelTitleBarButton(QWidget *parent,TPanelTitleBarButton::TPanelTitleBarButton(QWidget *parent,const QPixmap &standardPixmap): QWidget(parent)- , m_standardPixmap(standardPixmap)+ , m_onPixmap(standardPixmap)+ , m_offPixmap(standardPixmap)+ , m_overPixmap(standardPixmap), m_rollover(false), m_pressed(false), m_buttonSet(0), m_id(0) {- setFixedSize(m_standardPixmap.size() / m_standardPixmap.devicePixelRatio());+ setFixedSize(m_onPixmap.size() / m_onPixmap.devicePixelRatio());}//-----------------------------------------------------------------------------@@ -282,7 +283,51 @@ void TPanelTitleBarButton::setPressed(bool pressed) {//------------------------------------------------------------------------------void TPanelTitleBarButton::computePixmaps(const QString &standardPixmapName) {+void TPanelTitleBarButton::setOverColor(const QColor &color) {+ if (m_overColor != color) {+ m_overColor = color;+ updatePixmaps();+ }+}++QColor TPanelTitleBarButton::getOverColor() const { return m_overColor; }++//-----------------------------------------------------------------------------++void TPanelTitleBarButton::setPressedColor(const QColor &color) {+ if (m_pressedColor != color) {+ m_pressedColor = color;+ updatePixmaps();+ }+}++QColor TPanelTitleBarButton::getPressedColor() const { return m_pressedColor; }++//-----------------------------------------------------------------------------++void TPanelTitleBarButton::setFreezeColor(const QColor &color) {+ if (m_freezeColor != color) {+ m_freezeColor = color;+ updatePixmaps();+ }+}++QColor TPanelTitleBarButton::getFreezeColor() const { return m_freezeColor; }++//-----------------------------------------------------------------------------++void TPanelTitleBarButton::setPreviewColor(const QColor &color) {+ if (m_previewColor != color) {+ m_previewColor = color;+ updatePixmaps();+ }+}++QColor TPanelTitleBarButton::getPreviewColor() const { return m_previewColor; }++//-----------------------------------------------------------------------------++void TPanelTitleBarButton::updatePixmaps() {// Get background color used by some icons and statesQColor bgColor;if (m_standardPixmapName.contains("freeze", Qt::CaseInsensitive)) {@@ -297,37 +342,26 @@ void TPanelTitleBarButton::computePixmaps(const QString &standardPixmapName) {const qreal offOpacity = themeManager.getOffOpacity();// Compute icon- QImage baseImg = svgToImage(standardPixmapName);+ QImage baseImg = svgToImage(m_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);+ // Store in member variables+ m_onPixmap = convertImageToPixmap(onImg);+ m_offPixmap = convertImageToPixmap(offImg);+ m_overPixmap = 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 pixmapsQPainter painter(this);painter.drawPixmap(0, 0,- m_pressed ? m_pixmaps[m_standardPixmapName + "_on"]- : m_rollover ? m_pixmaps[m_standardPixmapName + "_over"]- : m_pixmaps[m_standardPixmapName + "_off"]);+ m_pressed ? m_onPixmap+ : m_rollover ? m_overPixmap+ : m_offPixmap);}//-----------------------------------------------------------------------------@@ -520,6 +554,7 @@ TPanelTitleBar::TPanelTitleBar(QWidget *parent,: QFrame(parent), m_closeButtonHighlighted(false) {setMouseTracking(true);setFocusPolicy(Qt::NoFocus);+ generateCloseButtonPixmaps();}//-----------------------------------------------------------------------------@@ -528,32 +563,27 @@ 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();+void TPanelTitleBar::generateCloseButtonPixmaps() {+ QString iconSVGName = "pane_close";+ // Icon theme vars+ ThemeManager &themeManager = ThemeManager::getInstance();+ const qreal offOpacity = themeManager.getOffOpacity();- // Use overColor from stylesheet for bgColor of rollover- QColor overColor = getOverColor();+ // 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));+ // Generate base icon image+ QImage baseImg = generateIconImage("pane_close");+ baseImg = compositeImage(baseImg, QSize(20, 18));- // Off icon image- QImage offImg = adjustImageOpacity(baseImg, offOpacity);+ // Off icon image+ QImage offImg = adjustImageOpacity(baseImg, offOpacity);- // Over icon image- QImage overImg = compositeImage(baseImg, QSize(), false, overColor);+ // 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];+ m_closeButtonPixmap = convertImageToPixmap(offImg);+ m_closeButtonOverPixmap = convertImageToPixmap(overImg);}//-----------------------------------------------------------------------------@@ -566,18 +596,11 @@ void TPanelTitleBar::paintEvent(QPaintEvent *) {TPanel *dw = qobject_cast<TPanel *>(parentWidget());Q_ASSERT(dw != 0);- // docked panel- if (!dw->isFloating()) {++ if (!dw->isFloating()) { // docked panelisPanelActive = dw->widgetInThisPanelIsFocused();- qDrawBorderPixmap(&painter, rect, QMargins(3, 3, 3, 3),- (isPanelActive) ? m_activeBorderPm : m_borderPm);- }- // floating panel- else {+ } else { // floating panelisPanelActive = isActiveWindow();- qDrawBorderPixmap(- &painter, rect, QMargins(3, 3, 3, 3),- (isPanelActive) ? m_floatActiveBorderPm : m_floatBorderPm);}if (dw->getOrientation() == TDockWidget::vertical) {@@ -591,18 +614,25 @@ void TPanelTitleBar::paintEvent(QPaintEvent *) {if (dw->isFloating()) {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);+ painter.drawPixmap(closeButtonPos, m_closeButtonOverPixmap);else- painter.drawPixmap(closeButtonPos, closeButtonPixmap);+ painter.drawPixmap(closeButtonPos, m_closeButtonPixmap);}+}- painter.end();+//-----------------------------------------------------------------------------++void TPanelTitleBar::setOverColor(const QColor &color) {+ if (m_overColor != color) {+ m_overColor = color;+ generateCloseButtonPixmaps();+ }}+QColor TPanelTitleBar::getOverColor() const { return m_overColor; }+//-----------------------------------------------------------------------------void TPanelTitleBar::leaveEvent(QEvent *) {diff --git a/toonz/sources/toonz/pane.h b/toonz/sources/toonz/pane.hindex e690ef805..b8754b04d 100644--- a/toonz/sources/toonz/pane.h+++ b/toonz/sources/toonz/pane.h@@ -15,10 +15,14 @@ class Room;class TPanelTitleBarButton : public QWidget {Q_OBJECT- // Pixmaps+ // FilepathQString m_standardPixmapName;++ // PixmapsQPixmap m_standardPixmap;- QMap<QString, QPixmap> m_pixmaps;+ QPixmap m_onPixmap;+ QPixmap m_offPixmap;+ QPixmap m_overPixmap;// ColorsQColor m_overColor;@@ -27,7 +31,7 @@ class TPanelTitleBarButton : public QWidget {QColor m_previewColor;// Methods- void computePixmaps(const QString &standardPixmapName);+ void TPanelTitleBarButton::updatePixmaps();// StylesheetQ_PROPERTY(QColor OverColor READ getOverColor WRITE setOverColor);@@ -51,14 +55,17 @@ public: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; }- QColor getPressedColor() const { return m_pressedColor; }- void setFreezeColor(const QColor &color) { m_freezeColor = color; }- QColor getFreezeColor() const { return m_freezeColor; }- void setPreviewColor(const QColor &color) { m_previewColor = color; }- QColor getPreviewColor() const { return m_previewColor; }+ void setOverColor(const QColor &color);+ QColor getOverColor() const;++ void setPressedColor(const QColor &color);+ QColor getPressedColor() const;++ void setFreezeColor(const QColor &color);+ QColor getFreezeColor() const;++ void setPreviewColor(const QColor &color);+ QColor getPreviewColor() const;public slots:void setPressed(bool pressed); // n.b. doesn't emit signals. calls update()@@ -145,10 +152,8 @@ class TPanelTitleBar final : public QFrame {bool m_closeButtonHighlighted;std::vector<std::pair<QPoint, QWidget *>> m_buttons;- QPixmap m_borderPm, m_activeBorderPm, m_floatBorderPm, m_floatActiveBorderPm;QColor m_titleColor, m_activeTitleColor, m_overColor;-- QMap<QString, QPixmap> m_pixmaps; // cache+ QPixmap m_closeButtonPixmap, m_closeButtonOverPixmap;public:TPanelTitleBar(QWidget *parent = 0,@@ -157,27 +162,18 @@ public:QSize sizeHint() const override { return minimumSizeHint(); }QSize minimumSizeHint() const override;+ void generateCloseButtonPixmaps();+// pos = widget position. n.b. if pos.x()<0 then origin is topright cornervoid add(const QPoint &pos, QWidget *widget);-- QPixmap getBorderPixmap() const { return m_borderPm; }- void setBorderPixmap(const QPixmap &pixmap) { m_borderPm = pixmap; }- QPixmap getActiveBorderPixmap() const { return m_activeBorderPm; }- void setActiveBorderPixmap(const QPixmap &pixmap) {- m_activeBorderPm = pixmap;- }- QPixmap getFloatBorderPixmap() const { return m_floatBorderPm; }- void setFloatBorderPixmap(const QPixmap &pixmap) { m_floatBorderPm = pixmap; }- QPixmap getFloatActiveBorderPixmap() const { return m_floatActiveBorderPm; }- void setFloatActiveBorderPixmap(const QPixmap &pixmap) {- m_floatActiveBorderPm = pixmap;- }+QColor getTitleColor() const { return m_titleColor; }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; }++ QColor getOverColor() const;+ void setOverColor(const QColor &color);protected:void resizeEvent(QResizeEvent *e) override;@@ -193,13 +189,6 @@ protected:QPixmap getPixmap(const QString &iconSVGName, bool rollover);- Q_PROPERTY(QPixmap BorderPixmap READ getBorderPixmap WRITE setBorderPixmap);- Q_PROPERTY(QPixmap ActiveBorderPixmap READ getActiveBorderPixmap WRITE- setActiveBorderPixmap);- Q_PROPERTY(QPixmap FloatBorderPixmap READ getFloatBorderPixmap WRITE- setFloatBorderPixmap);- Q_PROPERTY(QPixmap FloatActiveBorderPixmap READ getFloatActiveBorderPixmap- WRITE setFloatActiveBorderPixmap);Q_PROPERTY(QColor TitleColor READ getTitleColor WRITE setTitleColor);Q_PROPERTY(QColor ActiveTitleColor READ getActiveTitleColor WRITEsetActiveTitleColor);