54 lines
1.3 KiB
C++
54 lines
1.3 KiB
C++
#include "MainWindow.h"
|
|
#include "ui_MainWindow.h"
|
|
|
|
#include <QApplication>
|
|
#include <QDesktopWidget>
|
|
#include <QTextCodec>
|
|
#include <QPixmap>
|
|
#include <QString>
|
|
#include <QRect>
|
|
|
|
MainWindow::MainWindow(QWidget *parent)
|
|
: QMainWindow(parent)
|
|
, ui(new Ui::MainWindow)
|
|
, legacyPattern("^[A-Za-z]+\\d+$")
|
|
{
|
|
ui->setupUi(this);
|
|
|
|
QTextCodec *codec = QTextCodec::codecForName("UTF-8");
|
|
QString title = codec->toUnicode("Qt5 Legacy Migration Benchmark");
|
|
setWindowTitle(title);
|
|
|
|
ui->label->setText(codec->toUnicode("Bitte Text wie Test123 eingeben."));
|
|
ui->iconLabel->setPixmap(QPixmap(":/icons/app.png").scaled(48, 48));
|
|
|
|
connect(ui->validateButton, SIGNAL(clicked()), this, SLOT(onValidateClicked()));
|
|
connect(ui->screenButton, SIGNAL(clicked()), this, SLOT(onScreenInfoClicked()));
|
|
}
|
|
|
|
MainWindow::~MainWindow()
|
|
{
|
|
delete ui;
|
|
}
|
|
|
|
void MainWindow::onValidateClicked()
|
|
{
|
|
QString text = ui->lineEdit->text();
|
|
|
|
if (legacyPattern.exactMatch(text)) {
|
|
ui->resultLabel->setText("Match");
|
|
} else {
|
|
ui->resultLabel->setText("No match");
|
|
}
|
|
}
|
|
|
|
void MainWindow::onScreenInfoClicked()
|
|
{
|
|
QRect screenGeometry = QApplication::desktop()->screenGeometry();
|
|
QString info = QString("Screen: %1x%2")
|
|
.arg(screenGeometry.width())
|
|
.arg(screenGeometry.height());
|
|
|
|
ui->resultLabel->setText(info);
|
|
}
|