From a9e8e88879db24f9410a78c0a178fbfca2e02db4 Mon Sep 17 00:00:00 2001 From: mhduiy <73688594+mhduiy@users.noreply.github.com> Date: Mon, 14 Sep 2026 12:08:32 +0800 Subject: [PATCH] fix(dde-license-dialog): distinguish disabled button visual state The OK button in the license disclaimer dialog uses a custom LicenseDialogButton with a custom initStyleOption. Two issues made disabled and enabled-normal states visually identical: 1. backgroundOpacity defaulted to 0.15 for both disabled and enabled-normal (only sunken/hover were overridden), so users could not tell whether the button was clickable from the background. 2. The highlighted text color was applied unconditionally when m_highlighted was true, ignoring State_Enabled, so the disabled OK button still showed the highlight text color. Fix: set backgroundOpacity to 0.05 for disabled state, and only apply the highlight text color when State_Enabled is set; use the disabledButtonText color otherwise. Log: yes Bug: https://pms.uniontech.com/bug-view-360973.html --- dde-license-dialog/src/content.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/dde-license-dialog/src/content.cpp b/dde-license-dialog/src/content.cpp index 634d60aa..754ad524 100644 --- a/dde-license-dialog/src/content.cpp +++ b/dde-license-dialog/src/content.cpp @@ -57,6 +57,8 @@ class LicenseDialogButton : public DPushButton } else if (option->state.testFlag(QStyle::State_MouseOver)) { backgroundOpacity = 0.2; } + } else { + backgroundOpacity = 0.05; } QColor backgroundColor(Qt::black); @@ -64,8 +66,13 @@ class LicenseDialogButton : public DPushButton option->palette.setColor(QPalette::Button, backgroundColor); if (m_highlighted) { - QColor textColor = option->palette.highlight().color(); - option->palette.setColor(QPalette::ButtonText, textColor); + if (option->state.testFlag(QStyle::State_Enabled)) { + QColor textColor = option->palette.highlight().color(); + option->palette.setColor(QPalette::ButtonText, textColor); + } else { + QColor textColor = option->palette.color(QPalette::Disabled, QPalette::ButtonText); + option->palette.setColor(QPalette::ButtonText, textColor); + } } option->state.setFlag(QStyle::State_MouseOver, false);