mirror of
https://github.com/mudita/MuditaOS.git
synced 2026-04-20 23:17:35 -04:00
Due to vfs deprecation there is need to remove all vfs calls from code. This PR covers module gui. There are some modifications in other modules included which are necessary because of build system issues.
104 lines
3.9 KiB
C++
104 lines
3.9 KiB
C++
// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
|
|
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
|
|
|
|
#include "OutputLinesTextWithLabelWidget.hpp"
|
|
|
|
#include <Span.hpp>
|
|
#include "application-phonebook/data/PhonebookStyle.hpp"
|
|
|
|
#include <ContactRecord.hpp>
|
|
#include <i18n/i18n.hpp>
|
|
|
|
namespace gui
|
|
{
|
|
OutputLinesTextWithLabelWidget::OutputLinesTextWithLabelWidget(phonebookInternals::ListItemName listItemName)
|
|
: listItemName(listItemName)
|
|
{
|
|
setMinimumSize(phonebookStyle::outputLinesTextWithLabelWidget::w,
|
|
phonebookStyle::outputLinesTextWithLabelWidget::title_label_h);
|
|
setMargins(gui::Margins(0, style::margins::huge, 0, 0));
|
|
|
|
vBox = new VBox(this, 0, 0, 0, 0);
|
|
vBox->setEdges(RectangleEdge::None);
|
|
|
|
titleLabel = new Label(vBox);
|
|
titleLabel->setMinimumSize(phonebookStyle::outputLinesTextWithLabelWidget::w,
|
|
phonebookStyle::outputLinesTextWithLabelWidget::title_label_h);
|
|
titleLabel->setEdges(RectangleEdge::None);
|
|
titleLabel->setAlignment(Alignment(gui::Alignment::Horizontal::Left, gui::Alignment::Vertical::Center));
|
|
titleLabel->setFont(style::window::font::verysmall);
|
|
titleLabel->setLineMode(true);
|
|
titleLabel->activeItem = false;
|
|
|
|
multilineText = new Text(vBox, 0, 0, 0, 0);
|
|
multilineText->setMaximumSize(phonebookStyle::outputLinesTextWithLabelWidget::w,
|
|
phonebookStyle::outputLinesTextWithLabelWidget::input_text_h * 10);
|
|
multilineText->setMargins(Margins(0, phonebookStyle::outputLinesTextWithLabelWidget::span_size, 0, 0));
|
|
multilineText->setEdges(RectangleEdge::None);
|
|
multilineText->setAlignment(Alignment(gui::Alignment::Horizontal::Left, gui::Alignment::Vertical::Bottom));
|
|
multilineText->setFont(style::window::font::medium);
|
|
multilineText->setEditMode(EditMode::Browse);
|
|
|
|
applyItemNameSpecificSettings();
|
|
|
|
focusChangedCallback = [&](Item &item) {
|
|
setFocusItem(focus ? vBox : nullptr);
|
|
return true;
|
|
};
|
|
|
|
this->activeItem = false;
|
|
setEdges(RectangleEdge::All);
|
|
}
|
|
|
|
auto OutputLinesTextWithLabelWidget::onDimensionChanged(const BoundingBox &oldDim, const BoundingBox &newDim)
|
|
-> bool
|
|
{
|
|
vBox->setPosition(0, 0);
|
|
vBox->setSize(newDim.w, newDim.h);
|
|
|
|
return true;
|
|
}
|
|
|
|
void OutputLinesTextWithLabelWidget::applyItemNameSpecificSettings()
|
|
{
|
|
switch (listItemName) {
|
|
case phonebookInternals::ListItemName::Address:
|
|
addressHandler();
|
|
break;
|
|
|
|
case phonebookInternals::ListItemName::Note:
|
|
noteHandler();
|
|
break;
|
|
|
|
default:
|
|
LOG_ERROR("Incorrect List Item Name!");
|
|
break;
|
|
}
|
|
}
|
|
|
|
void OutputLinesTextWithLabelWidget::addressHandler()
|
|
{
|
|
titleLabel->setText(utils::localize.get("app_phonebook_new_contact_address"));
|
|
|
|
onLoadCallback = [&](std::shared_ptr<ContactRecord> contact) { multilineText->setText(contact->address); };
|
|
}
|
|
|
|
void OutputLinesTextWithLabelWidget::noteHandler()
|
|
{
|
|
titleLabel->setText(utils::localize.get("app_phonebook_new_contact_note"));
|
|
|
|
onLoadCallback = [&](std::shared_ptr<ContactRecord> contact) { multilineText->setText(contact->note); };
|
|
}
|
|
|
|
auto OutputLinesTextWithLabelWidget::handleRequestResize(const Item *child,
|
|
unsigned short request_w,
|
|
unsigned short request_h) -> Size
|
|
{
|
|
setMinimumHeight(phonebookStyle::outputLinesTextWithLabelWidget::title_label_h +
|
|
phonebookStyle::outputLinesTextWithLabelWidget::span_size + request_h);
|
|
|
|
return Size(request_w, request_h);
|
|
}
|
|
|
|
} /* namespace gui */
|