Files
qt-migration-copilot-demo/qt6-after/qt6-migrated-benchmark/MainWindow.cpp
T
torsten fc70e757bd style: Apply clang-format to all C++ files
- Format MainWindow.cpp, MainWindow.h, main.cpp
- Format test files (test_main.cpp, test_mainwindow.cpp)
- Fixes Jenkins clang-format policy check

Entire-Checkpoint: ea47c089bf3a
Signed-off-by: twi-devel <torsten.wierschin@life-maps.com>
2026-10-22 18:42:43 +02:00

64 lines
1.5 KiB
C++

#include "MainWindow.h"
#include "ui_MainWindow.h"
#include <QApplication>
#include <QPixmap>
#include <QRect>
#include <QScreen>
#include <QString>
MainWindow::MainWindow(QWidget* parent)
: QMainWindow(parent), ui(new Ui::MainWindow), m_pattern(QRegularExpression(R"(^[A-Za-z]+\d+$)"))
{
ui->setupUi(this);
setWindowTitle(u"Qt6 Legacy Migration Benchmark"_s);
ui->label->setText(u"Bitte Text wie Test123 eingeben."_s);
ui->iconLabel->setPixmap(QPixmap(u":/icons/app.png"_s).scaled(48, 48));
connect(ui->validateButton, &QPushButton::clicked, this, &MainWindow::onValidateClicked);
connect(ui->screenButton, &QPushButton::clicked, this, &MainWindow::onScreenInfoClicked);
}
MainWindow::~MainWindow()
{
delete ui;
}
bool MainWindow::validateInput(const QString& text) const
{
return m_pattern.match(text).hasMatch();
}
QString MainWindow::getScreenInfo() const
{
const QScreen* screen = QApplication::primaryScreen();
if (!screen)
{
return u"Screen: unavailable"_s;
}
const QRect geometry = screen->geometry();
return u"Screen: %1x%2"_s.arg(geometry.width()).arg(geometry.height());
}
void MainWindow::onValidateClicked()
{
const QString text = ui->lineEdit->text();
if (validateInput(text))
{
ui->resultLabel->setText(u"Match"_s);
}
else
{
ui->resultLabel->setText(u"No match"_s);
}
}
void MainWindow::onScreenInfoClicked()
{
const QString info = getScreenInfo();
ui->resultLabel->setText(info);
}