--- a/ui/qt/label.cpp Tue Feb 25 21:11:00 2025 +0100 +++ b/ui/qt/label.cpp Sat Apr 05 16:46:11 2025 +0200 @@ -1,7 +1,7 @@ /* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * - * Copyright 2015 Olaf Wintermann. All rights reserved. + * Copyright 2025 Olaf Wintermann. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -29,23 +29,35 @@ #include "label.h" #include "container.h" #include "toolkit.h" +#include "ui/display.h" -UIWIDGET ui_label(UiObject *obj, char *label) { - QString str = QString::fromUtf8(label); + +UIWIDGET ui_label_create(UiObject* obj, UiLabelArgs args) { + UiContainerPrivate *ctn = ui_obj_container(obj); + UI_APPLY_LAYOUT(ctn->layout, args); + + QString str = QString::fromUtf8(args.label); QLabel *widget = new QLabel(str); - UiContainer *ct = uic_get_current_container(obj); - ct->add(widget, false); + Qt::AlignmentFlag align = Qt::AlignCenter; + if(args.align == UI_ALIGN_LEFT) { + align = Qt::AlignLeft; + } else if(args.align == UI_ALIGN_RIGHT) { + align = Qt::AlignRight; + } + widget->setAlignment(align); + + ctn->add(widget, false); return widget; } -UIWIDGET ui_space(UiObject *obj) { - // TODO: maybe there is a better widget for this purpose - QLabel *widget = new QLabel(); - - UiContainer *ct = uic_get_current_container(obj); - ct->add(widget, true); - - return widget; +UIWIDGET ui_llabel_create(UiObject* obj, UiLabelArgs args) { + args.align = UI_ALIGN_LEFT; + return ui_label_create(obj, args); } + +UIWIDGET ui_rlabel_create(UiObject* obj, UiLabelArgs args) { + args.align = UI_ALIGN_RIGHT; + return ui_label_create(obj, args); +}