macOS speed badge display is "wrong" by mac UI conventions #14312

Closed
opened 2026-02-22 00:55:27 -05:00 by deekerman · 15 comments
Owner

Originally created by @Artoria2e5 on GitHub (Feb 7, 2023).

qBittorrent & operating system versions

qBittorrent: 4.5.0 x64
Operating system: macOS 12.6.1

What is the problem?

badge speed display in #6952 results in:

  • a big red thing: this is not where it should be as it's on the top and barely centered (even though it's long enough to make you think it should)
  • that needs notification permissions to work: this is not obvious when you see "needs notification perms"

It's more conventional to draw stuff in the style of Transmission and (sighs) Thunder. The code to do so in Transmission is in github.com/transmission/transmission@db802afc4f/macosx/BadgeView.mm (L31). There's the added bonus of having space to do both speeds, maybe even an ETA.

Steps to reproduce

No response

Additional context

No response

Log(s) & preferences file(s)

No response

Originally created by @Artoria2e5 on GitHub (Feb 7, 2023). ### qBittorrent & operating system versions qBittorrent: 4.5.0 x64 Operating system: macOS 12.6.1 ### What is the problem? badge speed display in #6952 results in: * a big red thing: this is not where it should be as it's on the top and barely centered (even though it's long enough to make you think it should) * that needs notification permissions to work: this is not obvious when you see "needs notification perms" It's more conventional to draw stuff in the style of Transmission and (sighs) Thunder. The code to do so in Transmission is in https://github.com/transmission/transmission/blob/db802afc4f7f05c28d6e3bfb43e60c3230a26d18/macosx/BadgeView.mm#L31. There's the added bonus of having space to do both speeds, maybe even an ETA. ### Steps to reproduce _No response_ ### Additional context _No response_ ### Log(s) & preferences file(s) _No response_
deekerman 2026-02-22 00:55:27 -05:00
Author
Owner

@luzpaz commented on GitHub (Aug 31, 2023):

@Artoria2e5 can you provide a screenshot for reference (and a mockup of what is expected as well?)

@luzpaz commented on GitHub (Aug 31, 2023): @Artoria2e5 can you provide a screenshot for reference (and a mockup of what is expected as well?)
Author
Owner

@Artoria2e5 commented on GitHub (Sep 3, 2023):

@luzpaz
qbt uses the notification banner, which is aligned top-right:
image
transmission draws its own thing, which is centered:
IMAGE 2023-09-03 21:30:01

@Artoria2e5 commented on GitHub (Sep 3, 2023): @luzpaz qbt uses the notification banner, which is aligned top-right: ![image](https://github.com/qbittorrent/qBittorrent/assets/6459309/b62409ee-a65a-4a5f-8186-f0148972b425) transmission draws its own thing, which is centered: ![IMAGE 2023-09-03 21:30:01](https://github.com/qbittorrent/qBittorrent/assets/6459309/6bf5019f-1e07-4c19-aaa1-4f2fed16fd96)
Author
Owner

@luzpaz commented on GitHub (Sep 4, 2023):

Thanks, @Artoria2e5
Can you help locate the code in Qbit source ?

Edit: linking to https://github.com/qbittorrent/qBittorrent/issues/2761

@luzpaz commented on GitHub (Sep 4, 2023): Thanks, @Artoria2e5 Can you help locate the code in Qbit source ? Edit: linking to https://github.com/qbittorrent/qBittorrent/issues/2761
Author
Owner
@Artoria2e5 commented on GitHub (Sep 4, 2023): https://github.com/qbittorrent/qBittorrent/blob/39efd0e9ffa58be1f709775cf81baa544ce1fc64/src/gui/macutilities.mm#L126
Author
Owner

@luzpaz commented on GitHub (Sep 5, 2023):

Thanks. The badge is aligned top-right, is that just by default? Because, looking at the code it doesn't look like alignment was specified at all. Or am I just missing it?

@luzpaz commented on GitHub (Sep 5, 2023): Thanks. The badge is aligned top-right, is that just by default? Because, looking at the code it doesn't look like alignment was specified at all. Or am I just missing it?
Author
Owner

@luzpaz commented on GitHub (Sep 5, 2023):

CC @Kolcha (sorry for the ping. Since you've committed in the past to macOS efforts, could you help weigh-in here?)

@luzpaz commented on GitHub (Sep 5, 2023): CC @Kolcha (sorry for the ping. Since you've committed in the past to macOS efforts, could you help weigh-in here?)
Author
Owner

@Kolcha commented on GitHub (Sep 5, 2023):

I can look, even I don't know Objective-C and macOS APIs, I can at least find how Transmission does it and implement the same for qBittorrent if this is acceptable (I'm not aware of any Apple' style guides and so on).

@Kolcha commented on GitHub (Sep 5, 2023): I can look, even I don't know Objective-C and macOS APIs, I can at least find how Transmission does it and implement the same for qBittorrent if this is acceptable (I'm not aware of any Apple' style guides and so on).
Author
Owner

@Artoria2e5 commented on GitHub (Sep 5, 2023):

The alignment cannot be changed, ever. It is originally designed to display the red bubble with a number we all know and hate...

@Artoria2e5 commented on GitHub (Sep 5, 2023): The alignment cannot be changed, ever. It is originally designed to display the red bubble with a number we all know and hate...
Author
Owner

@Kolcha commented on GitHub (Sep 6, 2023):

Transmission implemented "own component/widget" for this purpose. only need to understand when and how it is created. Will try to integrate it into qBittorrent this weekend.
the hardest part is the dependence on 4 images, need to find the way how to create Apple-specific structures from Qt-specific structures. this may require some undocumented Qt API usage or tricks used in Qt internally.
in any case, it seems not so complex.

@Kolcha commented on GitHub (Sep 6, 2023): Transmission implemented "[own component/widget](https://github.com/transmission/transmission/blob/main/macosx/BadgeView.mm)" for this purpose. only need to understand when and how it is created. Will try to integrate it into qBittorrent this weekend. the hardest part is the dependence on 4 images, need to find the way how to create Apple-specific structures from Qt-specific structures. this may require some undocumented Qt API usage or tricks used in Qt internally. in any case, it seems not so complex.
Author
Owner

@Kolcha commented on GitHub (Sep 10, 2023):

so, I spent some time working on it... unfortunately, I have bad news: I see no way at all to re-use (or port) that component implemented by Transmission devs to qBittorrent. some technical details are below.

as I mentioned above, component relies on 4 images (actually even 8, but it doesn't matter), these images are used in platform-specific code written in Objective-C. qBittorrent is written in C++ using Qt framework, so some "bridge" between C++/Qt and Objective-C is required. fortunately, Objective-C++ perfectly suits these needs.
Qt has its own resource system, so Qt classes should be used to access any images (or whatever) stored as app resources. few image-specific classes can be used to load image from resources. then this Qt-specific object must be "converted" into something that fits macOS frameworks API (as so as platform-specific code is required). QImage class provides suitable function for that, but unfortunately it returns null pointer for any valid image for unknown reasons.

this is slightly surprising for me, but not completely unexpected, unfortunately. about year ago I already faced similar issues with passing "C pointer" to some Objective-C functions on macOS. things which perfectly worked on macOS 12.4 has stopped working (and lead to crash due to null pointer dereference) after upgrade to macOS 12.5. I have some thoughts what can lead to this, but no idea how to deal with it. I'm not macOS (or whatever Apple product) developer and don't want to be it, especially nowadays (I hate everything made by Apple now, sorry).

so, sorry... I can't help. maybe some experienced Apple developer will help with it, but not me.

P.S> you may ask why Transmission doesn't experience such issues. answer is simple: Transmission has several almost self-contained platform-specific UI implementations which just use C/C++ torrent implementation library, I even not sure that they need to share some string values between C/C++ core and whatever platform-specific UI, let alone some "raw data".

@Kolcha commented on GitHub (Sep 10, 2023): so, I spent some time working on it... unfortunately, I have bad news: I see no way at all to re-use (or port) that component implemented by Transmission devs to qBittorrent. some technical details are below. as I mentioned above, component relies on 4 images (actually even 8, but it doesn't matter), these images are used in platform-specific code written in Objective-C. qBittorrent is written in C++ using Qt framework, so some "bridge" between C++/Qt and Objective-C is required. fortunately, Objective-C++ perfectly suits these needs. Qt has its own resource system, so Qt classes should be used to access any images (or whatever) stored as app resources. few image-specific classes can be used to load image from resources. then this Qt-specific object must be "converted" into something that fits macOS frameworks API (as so as platform-specific code is required). `QImage` class provides suitable function for that, but unfortunately it returns null pointer for any valid image for unknown reasons. this is slightly surprising for me, but not completely unexpected, unfortunately. about year ago I already faced similar issues with passing "C pointer" to some Objective-C functions on macOS. things which perfectly worked on macOS 12.4 has stopped working (and lead to crash due to null pointer dereference) after upgrade to macOS 12.5. I have some thoughts what can lead to this, but no idea how to deal with it. I'm not macOS (or whatever Apple product) developer and don't want to be it, especially nowadays (I hate everything made by Apple now, sorry). so, sorry... I can't help. maybe some experienced Apple developer will help with it, but not me. P.S> you may ask why Transmission doesn't experience such issues. answer is simple: Transmission has several almost self-contained platform-specific UI implementations which just use C/C++ torrent implementation library, I even not sure that they need to share some string values between C/C++ core and whatever platform-specific UI, let alone some "raw data".
Author
Owner

@glassez commented on GitHub (Sep 10, 2023):

@Kolcha
Could you create draft Pull request? Maybe someone can help with it.

@glassez commented on GitHub (Sep 10, 2023): @Kolcha Could you create draft Pull request? Maybe someone can help with it.
Author
Owner

@glassez commented on GitHub (Sep 10, 2023):

And how about text only implementation?

@glassez commented on GitHub (Sep 10, 2023): And how about text only implementation?
Author
Owner

@Kolcha commented on GitHub (Sep 10, 2023):

Could you create draft Pull request? Maybe someone can help with it.

sorry, there is nothing to publish... I tried that on "hello world" application first, as so as qBittorrent is pretty complex app with at least few dependencies and it is pretty inconvenient to setup IDE / dev environment to work on it rather than just build it.

And how about text only implementation?

very good idea! I didn't thought about it... should work, as so as QString to NSString coversion definitely works. Will try on my test app and will post anything working (even somehow) as PR. but this will happen very likely only on next weekend, it is very unlikely that I'll work on it during the week (usually I don't want to work on something personal in the evening after work)

@Kolcha commented on GitHub (Sep 10, 2023): > Could you create draft Pull request? Maybe someone can help with it. sorry, there is nothing to publish... I tried that on "hello world" application first, as so as qBittorrent is pretty complex app with at least few dependencies and it is pretty inconvenient to setup IDE / dev environment to work on it rather than just build it. > And how about text only implementation? very good idea! I didn't thought about it... should work, as so as `QString` to `NSString` coversion definitely works. Will try on my test app and will post anything working (even somehow) as PR. but this will happen very likely only on next weekend, it is very unlikely that I'll work on it during the week (usually I don't want to work on something personal in the evening after work)
Author
Owner

@Kolcha commented on GitHub (Sep 11, 2023):

text-only implementation concept (just a test app to demonstrate the possibilities)
Screenshot 2023-09-11 at 8 09 39 AM

P.S> have some ideas on how to avoid images usage at all. just need to Google for some Apple APIs similar to what QPainter provides.

wait for PR :)

@Kolcha commented on GitHub (Sep 11, 2023): text-only implementation concept (just a test app to demonstrate the possibilities) <img width="70" alt="Screenshot 2023-09-11 at 8 09 39 AM" src="https://github.com/qbittorrent/qBittorrent/assets/947647/78ca818e-54b3-4944-bcc0-48eedec7e7bb"> P.S> have some ideas on how to avoid images usage at all. just need to Google for some Apple APIs similar to what `QPainter` provides. wait for PR :)
Author
Owner

@Kolcha commented on GitHub (Sep 11, 2023):

almost replicated Transmission' look :) (without arrows and with)
no images are required, everything is painted programmatically
Screenshot 2023-09-11 at 9 25 40 AM Screenshot 2023-09-11 at 10 20 06 AM

again, still demo app with random image used as app icon

@Kolcha commented on GitHub (Sep 11, 2023): almost replicated Transmission' look :) (without arrows and with) no images are required, everything is painted programmatically <img width="70" alt="Screenshot 2023-09-11 at 9 25 40 AM" src="https://github.com/qbittorrent/qBittorrent/assets/947647/2fc9f256-1f69-4f05-ba5c-445079c895eb"> <img width="70" alt="Screenshot 2023-09-11 at 10 20 06 AM" src="https://github.com/qbittorrent/qBittorrent/assets/947647/4b92daf2-3b63-4f3c-8d29-927708f11551"> again, still demo app with random image used as app icon
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/qBittorrent#14312
No description provided.