Skip to content

Conversation

@hardWorker254
Copy link
Contributor

@hardWorker254 hardWorker254 commented Sep 24, 2025

linuxdeepin/developer-center#12262

Summary by Sourcery

Prevent UI text truncation in power and bluetooth plugins by dynamically sizing tip labels to fit rendered text

Bug Fixes:

  • Prevent power plugin tips from being truncated by setting the label's minimum width to the rendered text width
  • Prevent bluetooth plugin tips from being truncated by setting the label's minimum width to the rendered text width

@deepin-ci-robot
Copy link

Hi @hardWorker254. Thanks for your PR. 😃

@deepin-ci-robot
Copy link

Hi @hardWorker254. Thanks for your PR.

I'm waiting for a linuxdeepin member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@github-actions
Copy link

github-actions bot commented Sep 24, 2025

CLA Assistant Lite bot:

如果你是以企业贡献者的身份进行提交,请联系我们签署企业贡献者许可协议
If you submit as corporate contributor, please contact us to sign our Corporate Contributor License Agreement

感谢您的提交,我们非常感谢。 像许多开源项目一样,在接受您的贡献之前,我们要求您签署我们的个人贡献者许可协议。 您只需发布与以下格式相同的评论即可签署个人贡献者许可协议
Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Individual Contributor License Agreement before we can accept your contribution. You can sign the Individual Contributor License Agreement by just posting a Pull Request Comment same as the below format.


I have read the CLA Document and I hereby sign the CLA.

You can retrigger this bot by commenting recheck in this Pull Request

@sourcery-ai
Copy link

sourcery-ai bot commented Sep 24, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This PR ensures that power and Bluetooth tip labels fully display localized text by using QFontMetrics to calculate the rendered text width and setting the label’s minimum width accordingly, alongside minor formatting tweaks in the loadPlugin function.

Sequence diagram for BluetoothItem tips label width adjustment

sequenceDiagram
    participant BluetoothItem
    participant QLabel as "m_tipsLabel"
    participant QFontMetrics
    BluetoothItem->>QLabel: setText(tipsText)
    BluetoothItem->>QFontMetrics: QFontMetrics(m_tipsLabel.font())
    BluetoothItem->>QFontMetrics: boundingRect(m_tipsLabel.text())
    QFontMetrics-->>BluetoothItem: QRect (width)
    BluetoothItem->>QLabel: setMinimumWidth(textWidth)
Loading

File-Level Changes

Change Details Files
Add dynamic width adjustment for power tips label
  • Compute tip text width via QFontMetrics after setting label text
  • Apply setMinimumWidth(textWidth) to m_tipsLabel
plugins/dde-dock/power/powerplugin.cpp
Add dynamic width adjustment for Bluetooth tips label
  • Compute tip text width via QFontMetrics after setting label text
  • Apply setMinimumWidth(textWidth) to m_tipsLabel
plugins/dde-dock/bluetooth/bluetoothitem.cpp
Minor formatting tweaks in loadPlugin
  • Inserted blank lines to improve code readability in loadPlugin
plugins/dde-dock/power/powerplugin.cpp

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey there - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: 18202781743, hardWorker254

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@18202781743 18202781743 requested a review from Copilot September 25, 2025 05:35
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Fixes text truncation issues in Russian language UI for power and bluetooth dock plugins by dynamically calculating and setting minimum label widths based on rendered text dimensions.

  • Adds dynamic width calculation for tip labels in both power and bluetooth plugins
  • Prevents UI text truncation by ensuring labels are sized to accommodate their content
  • Addresses localization issues where longer translated text was being cut off

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
plugins/dde-dock/power/powerplugin.cpp Adds font metrics calculation and minimum width setting for power plugin tip labels
plugins/dde-dock/bluetooth/bluetoothitem.cpp Adds font metrics calculation and minimum width setting for bluetooth plugin tip labels

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

m_tipsLabel->setText(tips);
QFontMetrics metrics(m_tipsLabel->font());
int textWidth = metrics.boundingRect(m_tipsLabel->text()).width();
m_tipsLabel->setMinimumWidth(textWidth);
Copy link

Copilot AI Sep 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider adding padding to the calculated width to ensure proper visual spacing. The current implementation sets the minimum width exactly to the text width, which may result in text appearing cramped against the label edges.

Suggested change
m_tipsLabel->setMinimumWidth(textWidth);
const int horizontalPadding = 8; // pixels
m_tipsLabel->setMinimumWidth(textWidth + horizontalPadding);

Copilot uses AI. Check for mistakes.
m_tipsLabel->setText(tipsText);
QFontMetrics metrics(m_tipsLabel->font());
int textWidth = metrics.boundingRect(m_tipsLabel->text()).width();
m_tipsLabel->setMinimumWidth(textWidth);
Copy link

Copilot AI Sep 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider adding padding to the calculated width to ensure proper visual spacing. The current implementation sets the minimum width exactly to the text width, which may result in text appearing cramped against the label edges.

Suggested change
m_tipsLabel->setMinimumWidth(textWidth);
const int horizontalPadding = 12; // Add 12px padding for better visual spacing
m_tipsLabel->setMinimumWidth(textWidth + horizontalPadding);

Copilot uses AI. Check for mistakes.
@deepin-bot
Copy link

deepin-bot bot commented Sep 25, 2025

TAG Bot

New tag: 2.0.12
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #372

@BLumia BLumia merged commit 66a98ee into linuxdeepin:master Sep 26, 2025
4 of 6 checks passed
@BLumia
Copy link
Member

BLumia commented Sep 26, 2025

Thanks for your contribution! ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants