Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

check exist preference dialog before open a new one (fix #644) #645

Merged
merged 1 commit into from
Dec 27, 2024

Conversation

lidaobing
Copy link
Member

@lidaobing lidaobing commented Dec 27, 2024

/close #644

Summary by Sourcery

Bug Fixes:

  • Fixed an issue where multiple preference dialogs could be opened at the same time.

Copy link

sourcery-ai bot commented Dec 27, 2024

Reviewer's Guide by Sourcery

This pull request fixes a bug where the preference dialog could be opened multiple times. It modifies the DataSettings::ResetDataEntry function to check if the preference dialog is already open, and if so, it brings the existing dialog to the front instead of creating a new one. It also adds a preference_dialog_ member variable to the Application class to store a pointer to the currently open preference dialog, along with getter and setter methods.

Sequence diagram for preference dialog handling

sequenceDiagram
    participant User as User
    participant App as Application
    participant DS as DataSettings

    User->>DS: Open Preferences
    DS->>App: getPreferenceDialog()
    alt Dialog already exists
        App-->>DS: Return existing dialog
        DS->>DS: Present existing dialog
    else No existing dialog
        App-->>DS: Return null
        DS->>DS: Create new dialog
        DS->>App: setPreferenceDialog(dialog)
        DS->>DS: Show dialog
        Note over DS: User interacts with dialog
        DS->>App: setPreferenceDialog(null)
    end
Loading

Class diagram showing Application and DataSettings changes

classDiagram
    class Application {
        -GtkWidget* preference_dialog_
        +GtkWidget* getPreferenceDialog()
        +void setPreferenceDialog(GtkWidget* dialog)
    }
    class DataSettings {
        +void ResetDataEntry(Application* app, GtkWidget* parent)
    }
    DataSettings ..> Application: uses
Loading

State diagram for preference dialog lifecycle

stateDiagram-v2
    [*] --> Closed: Initial State
    Closed --> Open: Open Dialog
    Open --> Open: Try to Open Again
    note right of Open: Present existing dialog
    Open --> Closed: Close Dialog
    Closed --> [*]
Loading

File-Level Changes

Change Details Files
Prevent multiple preference dialogs from being opened simultaneously.
  • Added a check to DataSettings::ResetDataEntry to see if the preference dialog is already open.
  • If the preference dialog is already open, bring the existing dialog to the front.
  • Added a preference_dialog_ member variable to the Application class to track the currently open preference dialog.
  • Added getter and setter methods for the preference_dialog_ member variable in the Application class.
src/iptux/DataSettings.cpp
src/iptux/Application.h

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.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a 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. You can also use
    this command to specify where the summary should be inserted.

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 @lidaobing - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider using a more descriptive commit message that explains the fix (preventing multiple preference dialogs) rather than just referencing the issue number.
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.

@@ -98,6 +104,7 @@ void DataSettings::ResetDataEntry(Application* app, GtkWidget* parent) {
break;
}
}
app->setPreferenceDialog(NULL);
Copy link

Choose a reason for hiding this comment

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

suggestion: Consider connecting to the dialog's 'destroy' signal to handle cases where the dialog is closed externally

This would ensure the preference_dialog_ pointer is properly nulled even if the dialog is destroyed by the window manager or through other means.

Copy link

Test Results

66 tests  ±0   66 ✅ ±0   3s ⏱️ -1s
32 suites ±0    0 💤 ±0 
 1 files   ±0    0 ❌ ±0 

Results for commit be71176. ± Comparison against base commit 75f8f0d.

Copy link

codecov bot commented Dec 27, 2024

Codecov Report

Attention: Patch coverage is 0% with 7 lines in your changes missing coverage. Please review.

Project coverage is 52.47%. Comparing base (75f8f0d) to head (be71176).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
src/iptux/DataSettings.cpp 0.00% 5 Missing ⚠️
src/iptux/Application.h 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #645      +/-   ##
==========================================
- Coverage   52.51%   52.47%   -0.05%     
==========================================
  Files          64       64              
  Lines        8550     8557       +7     
==========================================
  Hits         4490     4490              
- Misses       4060     4067       +7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@lidaobing lidaobing changed the title fix #644 check exist preference dialog before open a new one (fix #644) Dec 27, 2024
@lidaobing lidaobing merged commit f0224d4 into master Dec 27, 2024
15 of 17 checks passed
@lidaobing lidaobing deleted the bf_644_multiple_preference branch December 27, 2024 05:43
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.

There will be mutiple preference dialog if active from appindicator
1 participant