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

[Manager] Gray out projects in project wizard that are already attached #5862

Merged
merged 4 commits into from
Dec 24, 2024

Conversation

Vulpine05
Copy link
Contributor

Fixes #1552

Description of the Change
This PR adds a feature to the Add Project wizard that will change the text of a project to gray if the project is already added. This is accomplished by storing a string array of all projects that are available in the wizard, another string array of all projects currently attached. Each array is then canonicalized, then trimmed of "http", etc. Arrays are then compared and if any match, the text is set to gray. The ability to make the text gray was enabled by adding the property "wxLB_OWNERDRAW" to the wxListBox.

For a "simple" change, this is actually a bit more complicated. A few design notes:

  1. Adding the Ownerdraw property did more than provide the ability to change the text color. The background color of the wxListBox, wherenever there is text, also changed to grey. I discovered this was a bug and not a feature in wxWidgets, and have reported it here. It is being fixed with this pull request. I haven't tested the fix yet (I'm not sure I have the skill set to change BOINC's wxWidgets dependency). Therefore, if you were to built with this PR, it looks like this:
    image

    I had hard coded a white background before I noticed it was a bug with wxWidgets, and with that it looks like this:
    image
    Of course, that white background would be redundant once the wxWidgets PR is merged, so that hard coding is not in this PR.

  2. I have not tested this in Linux nor MacOS. I also have not reviewed the code for anything dark mode settings. I will need someone to check on those platforms to see if I broke anything. FWIW, I run Windows in dark mode.

  3. I am not an expert in accessibility, but a 4.6:1 contrast ratio looked good to me. I tried to get a 7:1 ratio, but the gray looked too close to black to me and was hard to notice the distinction.

From what I have worked on, I think this PR is ready, but I kindly request others to test this on other platforms, especially with dark mode, before merging.

Alternate Designs
Hiding the projects that are attached didn't seem like a good idea to me. If someone wanted to find out the information of the project in this wizard, they would not be able to unless they removed the project. By graying out the projects that are attached, the users is able to see which projects that are still active and they are attached to.

Release Notes
[Manager] Projects listed in Add a Project wizard that are already added are changed to grey.

The code in this commit is repeated, additionally it will be used in the same PR.
Copy link

codecov bot commented Oct 28, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 10.70%. Comparing base (0707685) to head (18d9638).
Report is 583 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #5862      +/-   ##
============================================
+ Coverage     10.53%   10.70%   +0.16%     
  Complexity     1068     1068              
============================================
  Files           279      280       +1     
  Lines         35867    36710     +843     
  Branches       8409     8515     +106     
============================================
+ Hits           3779     3930     +151     
- Misses        31694    32391     +697     
+ Partials        394      389       -5     

see 144 files with indirect coverage changes

@computezrmle
Copy link
Contributor

There should be a hint explaining the meaning of the different color, like:
"To choose a project, click its name or type its URL below.
Greyed projects are already attached."

As an option or in addition something like this could be at the top of the "Project details" page:
"This project is already attached to your computer.
---"

There may also be a new entry in the "Categories" drop-down list like:
"attached"

@AenBleidd
Copy link
Member

@Vulpine05, please fix linux build

@Vulpine05
Copy link
Contributor Author

Hmm...I may have to go back to the drawing board on this one. Apparently Owner Drawn is a feature in wxWidgets for Windows build, but not for mac nor Linux. I suppose I could add precompiler code to use this feature only for Windows, but that kindof defeats the purpose of the PR if it can only work on one platform.

@Vulpine05
Copy link
Contributor Author

There should be a hint explaining the meaning of the different color, like: "To choose a project, click its name or type its URL below. Greyed projects are already attached."

As an option or in addition something like this could be at the top of the "Project details" page: "This project is already attached to your computer. ---"

When you click on the Next button a message does pop up stating that the project is added. I am assuming the user has some knowledge of what project(s) they are attached to, so I am hoping that is obvious enough. Your idea isn't bad, but in my opinion I would rather keep the window cleaner.

There may also be a new entry in the "Categories" drop-down list like: "attached"

Neat idea, but may be not as easy to add to the code. Again, just my opinion, so if there is strong support for this, I'd be willing to work on it.

Using wxLB_OWNERDRAW is not compatible with Linux.  Changing the class from wxListBox to wxListCtrl provides a differnt way of changing the text color for each row and still provide functionality across platforms.
@Vulpine05 Vulpine05 marked this pull request as ready for review December 22, 2024 22:32
@Vulpine05
Copy link
Contributor Author

Okay, this should be ready for review. I only tested this on Windows, so if someone can test on Mac and Linux it would be appreciated.

@CharlieFenton, I have one concern with running this on Mac. Per the wxWidgets manual here, it says that report mode for a wxListCtrl is generic for all modes. I'm not sure exactly what that means. Could you see how it looks?

Here is how it looks to me in Windows:
Test of wxListCtrl - 2024-12-22

@AenBleidd AenBleidd requested a review from Copilot December 23, 2024 01:20

Choose a reason for hiding this comment

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

Copilot wasn't able to review any files in this pull request.

Files not reviewed (2)
  • clientgui/ProjectInfoPage.cpp: Language not supported
  • clientgui/ProjectInfoPage.h: Language not supported
Copy link
Member

@AenBleidd AenBleidd left a comment

Choose a reason for hiding this comment

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

Code itself looks good to me, but it still need to be tested.
Will try to test it on Windows and Linux during the next few days

@CharlieFenton
Copy link
Contributor

Per the wxWidgets manual here, it says that report mode for a wxListCtrl is generic for all modes. I'm not sure exactly what that means

The implementation on Windows uses a built-in API in the Windows OS. There is no such API on the Mac (and perhaps other platforms), so wxWidgets provides a generic implementation in code to be used on those platforms, simulating what the Widow API does.

II tested it, and it works on the Mac, more or less. while the projects to which you are already attached are shown in a lighter gray color, they are not disabled. You can still select them and click on the Next button, which then tells you you are already attached to the project. Here aer 3 screen shots.

Screenshot 2024-12-22 at 6 52 22 PM Screenshot 2024-12-22 at 6 53 02 PM Screenshot 2024-12-22 at 6 53 14 PM

@CharlieFenton
Copy link
Contributor

I assume the title of this PR "Gray out projects in project wizard that are already attached" means that the intent is to disable those projects in the list so that attempted clicks on the are ignored, which is what a gray item in a list normally means. This does not accomplish that goal, but only changes the appearance ofthose projects in the list.

However, it probably works well enough since clicking on the item brings up the "already attached" alert.

@Vulpine05
Copy link
Contributor Author

I assume the title of this PR "Gray out projects in project wizard that are already attached" means that the intent is to disable those projects in the list so that attempted clicks on the are ignored, which is what a gray item in a list normally means. This does not accomplish that goal, but only changes the appearance ofthose projects in the list.

However, it probably works well enough since clicking on the item brings up the "already attached" alert.

Thanks for testing this and sharing screen shots, @CharlieFenton. I'm glad to see that it functions the same as in Windows. I understand how you and others assume that with the grayed out text then the next button should be disabled. However, the way the project wizard currently operates is that it checks the project URL field, which is editable. Although you can select a project and have the information filled out in the project details, the user can still modify the URL so they can add a custom project not on the list, such as SETI's former beta test project.

Does this work well enough? I think so. Is there a better way? Probably, but there are enough guardrails to prevent the user from doing something that causes an error.

@CharlieFenton
Copy link
Contributor

Does this work well enough? I think so

I think so too.

@AenBleidd AenBleidd merged commit e33ffbd into BOINC:master Dec 24, 2024
153 checks passed
@Vulpine05 Vulpine05 deleted the Vulpine05_1552 branch December 24, 2024 13:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Merged
Development

Successfully merging this pull request may close these issues.

Hide or gray out projects already added from the BOINC Manager Add Project wizard
4 participants