From dc03b7e7d689156c14a036283702944a8ca4d767 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Sun, 1 Dec 2013 17:55:09 -0800 Subject: We need the correct context to translate event names Qt assumes that all strings are in the context of the class in which you use them. So when we want to display the translated event names from within the ProfileGraphicsView we need to make it explicit that these are strings that come from the C part of the code. Doing that showed another bug in the code where we foolishly compared the translated text to a fixed string. Not smart. Fixes #312 Signed-off-by: Dirk Hohndel --- qt-ui/profilegraphics.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/qt-ui/profilegraphics.cpp b/qt-ui/profilegraphics.cpp index 7645cba88..b1798f750 100644 --- a/qt-ui/profilegraphics.cpp +++ b/qt-ui/profilegraphics.cpp @@ -27,6 +27,7 @@ #include "../device.h" #include "../helpers.h" #include "../planner.h" +#include "../gettextfromc.h" #include #include @@ -969,10 +970,10 @@ void ProfileGraphicsView::plot_one_event(struct event *ev) item->setPos(x, y); scene()->addItem(item); - /* we display the event on screen - so translate */ - QString name = tr(ev->name); + /* we display the event on screen - so translate (with the correct context for events) */ + QString name = gettextFromC::instance()->tr(ev->name); if (ev->value) { - if (ev->name && name == "gaschange") { + if (ev->name && strcmp(ev->name, "gaschange") == 0) { int he = get_he(&dive->cylinder[entry->cylinderindex].gasmix); int o2 = get_o2(&dive->cylinder[entry->cylinderindex].gasmix); -- cgit v1.2.3-70-g09d2