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

Fix Deskbar icon and tooltip #101

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dospuntos
Copy link

This pull request enables the Deskbar Replicant menu item. The replicant will show an icon with the curren weather, and a tooltip with details about the condition, temperature and location.

The tooltip is translatable, new en.catkeys generated but not added to Polyglot.

I also removed a few header files that didn't seem necessary, please correct me if I'm wrong.


BView*
extern "C" _EXPORT BView*
instantiate_deskbar_item()
Copy link
Member

Choose a reason for hiding this comment

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

There's a instantiate_deskbar_item(float maxWidth, float maxHeight) that avoids hard-coding the icon size. The Deskbar tray and its icons are resized with the set system font size. Compare with, e.g. https://cgit.haiku-os.org/haiku/tree/src/apps/powerstatus/PowerStatusView.cpp#n929

Copy link
Author

Choose a reason for hiding this comment

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

That makes sense, I'm trying to adapt the code but I'm struggling with this part:

BArchivable*
ForecastDeskbarView::Instantiate(BMessage* archive)
{
	if (!validate_instantiation(archive, "ForecastDeskbarView"))
		return NULL;

	return reinterpret_cast<BArchivable*>(instantiate_deskbar_item());
}

How can I include maxWidth and maxHeight in instantiate_deskbar_item()?

Copy link
Member

Choose a reason for hiding this comment

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

Keep in mind that I don't really know what I'm doing, esp. when it comes to replicants...
The Instantiate() should return a ForecastDeskbarView*, not a BArchivable*.

Copy link
Author

Choose a reason for hiding this comment

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

Keep in mind that I don't really know what I'm doing, esp. when it comes to replicants...

Hard to believe...

The Instantiate() should return a ForecastDeskbarView*, not a BArchivable*.

I noticed that from the examples, however with the current code this caused the app to crash. As it is now (with my latest update), the code works and the icon will resize according to the system font size.

BString weatherDetailsText;
weatherDetailsText << "Temperature: "
weatherDetailsText << B_TRANSLATE("Temperature: ")
Copy link
Member

Choose a reason for hiding this comment

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

Here, and for rhe strings below, I suggest to remove the space at the end of the string and append it separately. A space at the end can easily be overlooked by the translators, so:

Suggested change
weatherDetailsText << B_TRANSLATE("Temperature: ")
weatherDetailsText << B_TRANSLATE("Temperature:") << " "

Or go with one long translatable string that contains variables ("%temperature%" etc.) that get replaced using BString's SetToFormat() etc.

Copy link
Author

Choose a reason for hiding this comment

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

Added a single, translatable string that inserts the variables with SetToFormat() as suggested.

Source/MainWindow.cpp Outdated Show resolved Hide resolved
@dospuntos dospuntos marked this pull request as draft November 10, 2023 16:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants