Skip to content

Conversation

@18202781743
Copy link
Contributor

@18202781743 18202781743 commented May 14, 2025

  1. Changed icon names from 'osd_display_' to 'osd_multi_screen_' for
    better consistency
  2. Modified display mode logic to support more than 2 screens by:
    • Always sorting output names (not just for 2 screens)
    • Using 'osd_multi_screen_only_more' icon when more than 2 screens
      exist
  3. Removed old icon files and added new ones with updated naming scheme

refactor: 更新显示模式图标和逻辑

  1. 将图标名称从'osd_display_'改为'osd_multi_screen_'以提高一致性
  2. 修改显示模式逻辑以支持超过2个屏幕:
    • 始终排序输出名称(不仅限于2个屏幕时)
    • 当存在超过2个屏幕时使用'osd_multi_screen_only_more'图标
  3. 删除旧图标文件并添加具有更新命名方案的新图标

pms: BUG-315934

Summary by Sourcery

Refactor display mode icons and logic to standardize naming and support more than two screens.

Enhancements:

  • Standardize icon names from 'osd_display_' to 'osd_multi_screen_'.
  • Always sort display outputs to ensure consistent ordering.
  • Use a generic 'osd_multi_screen_only_more' icon for third and subsequent screens.

Chores:

  • Remove deprecated icon files and add new assets with updated naming.

@sourcery-ai
Copy link

sourcery-ai bot commented May 14, 2025

Reviewer's Guide

Refactors display mode components by renaming icon identifiers and assets for consistency, and updates selection logic to support more than two screens with proper sorting and dynamic icon selection.

File-Level Changes

Change Details Files
Refactor icon naming scheme for consistency
  • Updated DPItem constructors to use osd_multi_screen_* identifiers
  • Removed legacy osd_display_* icon files
  • Added new osd_multi_screen_* icons matching the updated naming convention
panels/notification/osd/displaymode/displaymodeapplet.cpp
icons/osd_display_* (removed)
icons/osd_multi_screen_* (added)
Enhance display mode logic for multi-screen support
  • Always sort outputNames regardless of count
  • Update conditional from size==2 to size>1
  • Select 'only on' icon dynamically, using osd_multi_screen_only_more when more than two outputs
panels/notification/osd/displaymode/displaymodeapplet.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 @18202781743 - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

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.

mhduiy
mhduiy previously approved these changes May 14, 2025
@deepin-ci-robot
Copy link

deepin pr auto review

代码审查意见:

  1. 代码可读性

    • fetchPlanItems函数中,将std::sort(outputNames.begin(), outputNames.end(), std::greater<QString>());移到了if (outputNames.size() >= 2)之前,这可能会影响代码的逻辑顺序。建议保留原有的排序逻辑,并在if语句中处理特定的逻辑。
  2. 资源管理

    • fetchPlanItems函数中,使用new关键字创建DPItem对象,但没有看到相应的delete操作。建议使用智能指针(如std::unique_ptr)来管理动态分配的对象,以避免内存泄漏。
  3. 错误处理

    • fetchPlanItems函数中没有错误处理逻辑。如果outputNames为空或包含无效数据,可能会导致未定义行为。建议添加适当的错误检查和处理逻辑。
  4. 代码重复

    • fetchPlanItems函数中,DPItem对象的创建逻辑存在重复。可以考虑将这部分逻辑提取到一个单独的函数中,以提高代码的可维护性。
  5. 图标命名

    • 新增的图标文件命名(如osd_multi_screen_only_more.dci)可能不够直观,建议使用更具描述性的命名,以便于理解和维护。
  6. 代码风格

    • fetchPlanItems函数中,if (outputNames.size() >= 2)的判断条件可以简化为if (!outputNames.isEmpty()),以提高代码的可读性。

综合以上意见,建议对代码进行如下修改:

void DisPlayModeApplet::fetchPlanItems()
{
    m_planItems.clear();
    m_currentPlanItem = nullptr;

    m_planItems << new DPItem(tr("Duplicate"), "osd_multi_screen_copy", DPItem::Merge, this);
    m_planItems << new DPItem(tr("Extend"), "osd_multi_screen_extension", DPItem::Extend, this);

    std::sort(outputNames.begin(), outputNames.end(), std::greater<QString>());

    if (!outputNames.isEmpty()) {
        for (int i = 0; i < outputNames.size(); i++) {
            const auto item = outputNames[i];
            const QString iconName = i < 2 ? QString("osd_multi_screen_only%1").arg(i + 1) : "osd_multi_screen_only_more";
            m_planItems << new DPItem(tr("Only on %1").arg(item), item, iconName, DPItem::Single, this);
        }
    }
}

同时,建议使用智能指针来管理动态分配的对象,例如:

#include <memory>

void DisPlayModeApplet::fetchPlanItems()
{
    m_planItems.clear();
    m_currentPlanItem = nullptr;

    m_planItems << std::make_unique<DPItem>(tr("Duplicate"), "osd_multi_screen_copy", DPItem::Merge, this);
    m_planItems << std::make_unique<DPItem>(tr("Extend"), "osd_multi_screen_extension", DPItem::Extend, this);

    std::sort(outputNames.begin(), outputNames.end(), std::greater<QString>());

    if (!outputNames.isEmpty()) {
        for (int i = 0; i < outputNames.size(); i++) {
            const auto item = outputNames[i];
            const QString iconName = i < 2 ? QString("osd_multi_screen_only%1").arg(i + 1) : "osd_multi_screen_only_more";
            m_planItems << std::make_unique<DPItem>(tr("Only on %1").arg(item), item, iconName, DPItem::Single, this);
        }
    }
}

这样可以避免内存泄漏,并提高代码的可读性和可维护性。

1. Changed icon names from 'osd_display_*' to 'osd_multi_screen_*' for
better consistency
2. Modified display mode logic to support more than 2 screens by:
   - Always sorting output names (not just for 2 screens)
   - Using 'osd_multi_screen_only_more' icon when more than 2 screens
exist
3. Removed old icon files and added new ones with updated naming scheme

refactor: 更新显示模式图标和逻辑

1. 将图标名称从'osd_display_*'改为'osd_multi_screen_*'以提高一致性
2. 修改显示模式逻辑以支持超过2个屏幕:
   - 始终排序输出名称(不仅限于2个屏幕时)
   - 当存在超过2个屏幕时使用'osd_multi_screen_only_more'图标
3. 删除旧图标文件并添加具有更新命名方案的新图标

pms: BUG-315934
@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

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

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
Copy link
Contributor Author

/forcemerge

@deepin-bot
Copy link

deepin-bot bot commented May 15, 2025

This pr force merged! (status: blocked)

@deepin-bot deepin-bot bot merged commit 2df60b4 into linuxdeepin:master May 15, 2025
7 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants