Milestone 5: deliver embedded RDP sessions and lifecycle hardening
This commit is contained in:
@@ -4,8 +4,6 @@
|
||||
#include "profile_repository.h"
|
||||
#include "session_window.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include <QAbstractItemView>
|
||||
#include <QHBoxLayout>
|
||||
#include <QLabel>
|
||||
@@ -119,13 +117,29 @@ void ProfilesWindow::loadProfiles(const QString& query)
|
||||
for (const Profile& profile : profiles) {
|
||||
auto* item = new QListWidgetItem(formatProfileListItem(profile), m_profilesList);
|
||||
item->setData(Qt::UserRole, QVariant::fromValue(profile.id));
|
||||
item->setToolTip(QStringLiteral("%1://%2@%3:%4\nAuth: %5\nKnown Hosts: %6")
|
||||
.arg(profile.protocol,
|
||||
profile.username.isEmpty() ? QStringLiteral("<none>") : profile.username,
|
||||
profile.host,
|
||||
QString::number(profile.port),
|
||||
profile.authMode,
|
||||
profile.knownHostsPolicy));
|
||||
const QString identity = [&profile]() {
|
||||
if (profile.protocol.compare(QStringLiteral("RDP"), Qt::CaseInsensitive) == 0
|
||||
&& !profile.domain.trimmed().isEmpty()) {
|
||||
return QStringLiteral("%1\\%2").arg(profile.domain.trimmed(),
|
||||
profile.username.trimmed().isEmpty()
|
||||
? QStringLiteral("<none>")
|
||||
: profile.username.trimmed());
|
||||
}
|
||||
return profile.username.isEmpty() ? QStringLiteral("<none>") : profile.username;
|
||||
}();
|
||||
QString tooltip = QStringLiteral("%1://%2@%3:%4\nAuth: %5")
|
||||
.arg(profile.protocol,
|
||||
identity,
|
||||
profile.host,
|
||||
QString::number(profile.port),
|
||||
profile.authMode);
|
||||
if (profile.protocol.compare(QStringLiteral("SSH"), Qt::CaseInsensitive) == 0) {
|
||||
tooltip += QStringLiteral("\nKnown Hosts: %1").arg(profile.knownHostsPolicy);
|
||||
} else if (profile.protocol.compare(QStringLiteral("RDP"), Qt::CaseInsensitive) == 0) {
|
||||
tooltip += QStringLiteral("\nRDP Security: %1\nRDP Performance: %2")
|
||||
.arg(profile.rdpSecurityMode, profile.rdpPerformanceProfile);
|
||||
}
|
||||
item->setToolTip(tooltip);
|
||||
m_profileCache.insert_or_assign(profile.id, profile);
|
||||
}
|
||||
}
|
||||
@@ -264,22 +278,16 @@ void ProfilesWindow::openSessionForItem(QListWidgetItem* item)
|
||||
return;
|
||||
}
|
||||
|
||||
auto* session = new SessionWindow(profile.value());
|
||||
session->setAttribute(Qt::WA_DeleteOnClose);
|
||||
if (m_sessionWindow.isNull()) {
|
||||
m_sessionWindow = new SessionWindow(profile.value());
|
||||
m_sessionWindow->setAttribute(Qt::WA_DeleteOnClose);
|
||||
connect(m_sessionWindow, &QObject::destroyed, this, [this]() { m_sessionWindow = nullptr; });
|
||||
} else {
|
||||
m_sessionWindow->openProfile(profile.value());
|
||||
}
|
||||
|
||||
m_sessionWindows.emplace_back(session);
|
||||
connect(session,
|
||||
&QObject::destroyed,
|
||||
this,
|
||||
[this](QObject* object) {
|
||||
m_sessionWindows.erase(
|
||||
std::remove_if(m_sessionWindows.begin(),
|
||||
m_sessionWindows.end(),
|
||||
[object](const QPointer<SessionWindow>& candidate) {
|
||||
return candidate.isNull() || candidate.data() == object;
|
||||
}),
|
||||
m_sessionWindows.end());
|
||||
});
|
||||
|
||||
session->show();
|
||||
m_sessionWindow->setWindowState(m_sessionWindow->windowState() & ~Qt::WindowMinimized);
|
||||
m_sessionWindow->show();
|
||||
m_sessionWindow->raise();
|
||||
m_sessionWindow->activateWindow();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user