feat: implement MainWindow label update on valueReceived

This commit is contained in:
unai_71 2026-03-10 18:36:08 +00:00
parent 040cf974f4
commit 32426b3028
2 changed files with 53 additions and 0 deletions

33
src/app/MainWindow.cxx Normal file
View File

@ -0,0 +1,33 @@
// MainWindow.cxx
// SPDX-License-Identifier: GPL-3.0-or-later
// Author: Unai Blazquez <unaibg2000@gmail.com>
#include "MainWindow.hpp"
MainWindow::MainWindow(QWidget* parent) : QWidget(parent)
{
setWindowTitle("Azkoyen IPC Monitor");
setMinimumSize(320, 120);
auto* layout = new QVBoxLayout(this);
m_title_label = new QLabel("Last received value:", this);
m_value_label = new QLabel("(waiting...)", this);
// Make the value label stand out a bit
QFont font = m_value_label->font();
font.setPointSize(24);
font.setBold(true);
m_value_label->setFont(font);
m_value_label->setAlignment(Qt::AlignCenter);
layout->addWidget(m_title_label);
layout->addWidget(m_value_label);
}
QString MainWindow::lastDisplayedText() const { return m_value_label->text(); }
void MainWindow::onValueReceived(int value)
{
m_value_label->setText(QString::number(value));
}

View File

@ -53,3 +53,23 @@ target_link_libraries(test_consumer
) )
add_test(NAME test_consumer COMMAND test_consumer) add_test(NAME test_consumer COMMAND test_consumer)
add_executable(test_main_window
test_main_window.cxx
${CMAKE_SOURCE_DIR}/src/app/MainWindow.cxx
${CMAKE_SOURCE_DIR}/include/MainWindow.hpp
)
target_include_directories(test_main_window PRIVATE ${CMAKE_SOURCE_DIR}/include)
target_link_libraries(test_main_window
PRIVATE
core
gtest
gtest_main
Qt5::Core
Qt5::Widgets
Qt5::Test
)
add_test(NAME test_main_window COMMAND test_main_window)