Files
qt-migration-legatus/qt6-after/qt6-migrated-legatus/Lts/Tools/LoginTest/login_window.cpp
T
torsten d5c13033e2 Session 022: Migrate Lts/Tools (72 submodules) to Qt6
- Copied complete Lts/Tools directory from qt5-before to qt6-after
- Updated 32 CMakeLists.txt files (Qt5:: → Qt6::)
- Tools subdirectory already included in parent Lts/CMakeLists.txt
- All 72 tool submodules now present in qt6-migrated-legatus
- Includes: Adler, ArAssets, ConfigX, DBAdministration, DBUpdate,
  DdsView, InfrastructureManagement, and 67 more tools
- C++17 standard (RTI 7.7.0 compatibility maintained)
- Tests deferred until final validation phase

Migration progress:
✅ Lts/Application (68 files)
✅ Lts/DDS (verified Qt6-ready)
✅ Lts/Plugins (60 submodules, verified)
✅ Lts/Projects (5 submodules, verified)
✅ Lts/Proxies (13 submodules, verified)
✅ Lts/Services (47 submodules, verified)
✅ Lts/Tools (72 submodules, copied + CMake updated)
✅ Lts/Viewer (LtsFileDialog, LtsReportDisplay, SituationMap)
🟡 TetraIF (partial)
🟡 Z (partial: nglwidgets, QtSingleApplication, qsql_informix, WMS_Interface)
2026-08-25 14:07:20 +02:00

187 lines
4.8 KiB
C++
Executable File

#include "login_window.h"
#include "ui_login_window.h"
#include <QtCore/QSettings>
#include <QApplication>
#include <QScreen>
#include <QStyle>
#include <QtCore/QDebug>
#include <QMessageBox>
#include <QGraphicsDropShadowEffect>
LoginWindow::LoginWindow()
: QDialog(nullptr)
, m_ui(new Ui::LoginWindow)
, m_settings(new NGL::Settings(QLatin1String("gfs_ws.ini")))
, m_hiddenWidget(new QWidget())
{
ScreenList screenList = QApplication::screens();
QString projectLogoFilename = m_settings->bitmapPath()
+ QLatin1String("/logo_Project.jpg");
for (ScreenListConstIterator i = screenList.constBegin(); i != screenList.constEnd(); ++i)
{
BackgroundWidget* bgw = new BackgroundWidget(projectLogoFilename, m_hiddenWidget);
connect(bgw, SIGNAL(signalUserAction()), this, SLOT(slotUserAction()));
bgw->setGeometry((*i)->availableGeometry());
bgw->showFullScreen();
m_bgwl.append(bgw);
}
setWindowTitle(tr("Login"));
setWindowFlags(windowFlags() | Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint); // hints..
setMouseTracking(true); // register mouse movement
setAttribute(Qt::WA_TranslucentBackground);
m_hideTimer.setInterval(10000);
connect(&m_hideTimer, SIGNAL(timeout()), this, SLOT(slotHide()));
m_ui->setupUi(this);
m_ui->lbLoginText->setText(tr("<b>Login</b><br>%1<br><i>%2</i>").arg(QLatin1String("ProjectName"),
QLatin1String("WorkstationName")));
QList<QLabel*> labels = findChildren<QLabel*>();
for (QList<QLabel*>::const_iterator i = labels.constBegin(); i != labels.constEnd(); ++i)
{
QGraphicsDropShadowEffect *shadow = new QGraphicsDropShadowEffect(this); // cannot copy this..
shadow->setOffset(0,0);
shadow->setBlurRadius(22);
shadow->setColor(QColor("white"));
(*i)->setGraphicsEffect(shadow);
}
setGeometry(QStyle::alignedRect(
Qt::LeftToRight,
Qt::AlignHCenter | Qt::AlignBottom,
size(),
QApplication::primaryScreen()->geometry()));
QString rdeLogoFilename = m_settings->bitmapPath() + QLatin1String("logo_RDE.svg");
QPixmap rdeLogoPixmap(rdeLogoFilename);
if (rdeLogoPixmap.isNull())
{
qWarning() << "LoginWindow::c_tor: file missing or is not an valid image '" << rdeLogoFilename << "'";
}
else
{
rdeLogoPixmap = rdeLogoPixmap.scaled(m_ui->lbRDELogo->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
m_ui->lbRDELogo->setPixmap(rdeLogoPixmap);
}
connect(m_ui->leUsername, SIGNAL(returnPressed()), this, SLOT(slotUsernameEnter())); //m_ui->lePassword, SLOT(setFocus()));
connect(m_ui->lePassword, SIGNAL(returnPressed()), this, SLOT(slotLogin()));
connect(m_ui->pbLogin, SIGNAL(clicked(bool)), this, SLOT(slotLogin()));
connect(m_ui->pbCancel, SIGNAL(clicked(bool)), this, SLOT(slotCancel()));
m_hideTimer.start();
}
LoginWindow::~LoginWindow()
{
delete m_ui;
qDeleteAll(m_bgwl);
}
void LoginWindow::slotUsernameEnter()
{
if (!m_ui->leUsername->text().isEmpty()) // only go next if username is not empty
{
m_ui->lePassword->setFocus();
}
}
void LoginWindow::slotUserAction()
{
raise();
m_hideTimer.start(); // restarts timer (hides window on timeout)
if (!isVisible())
{
setGeometry(QStyle::alignedRect(
Qt::LeftToRight,
Qt::AlignHCenter | Qt::AlignBottom,
size(),
QApplication::primaryScreen()->geometry()));
m_ui->leUsername->setFocus();
show();
}
}
bool LoginWindow::event(QEvent *event)
{
if (event->type() == QEvent::KeyPress || // respect typing into textfields
event->type() == QEvent::MouseButtonPress ||
event->type() == QEvent::MouseButtonRelease ||
event->type() == QEvent::MouseMove)
{
slotUserAction();
}
return QWidget::event(event);
}
void LoginWindow::moveEvent(QMoveEvent *event)
{
//move(event->oldPos()); // HACK!
}
void LoginWindow::slotHide()
{
m_hideTimer.stop(); // window hidden, no need to hide it by timeout
hide();
}
void LoginWindow::closeEvent(QCloseEvent * event) // TODO: override reject()
{
(void)event;
#ifdef DEVEL
deleteLater();
#else
event->ignore();
hide();
#endif
}
void LoginWindow::wrongUsername()
{
QMessageBox::warning(this, tr("Login Failed"), tr("User '%1' does not exist!").arg(m_ui->leUsername->text()));
m_ui->leUsername->clear();
m_ui->lePassword->clear();
m_ui->leUsername->setFocus();
}
void LoginWindow::wrongPassword()
{
QMessageBox::warning(this, tr("Login Failed"), tr("Invalid password!"));
m_ui->lePassword->clear();
m_ui->lePassword->setFocus();
}
void LoginWindow::slotLogin()
{
// some login logic
}
void LoginWindow::slotCancel() // TODO: override reject()
{
#ifdef DEVEL
deleteLater();
#else
slotHide();
#endif
}