X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fqtui%2Fcoresessionwidget.cpp;h=fbbb39b86590d11546f9934b06c895182f74d3de;hb=d1aa795013aaebe5ca57353d6077b0007b489832;hp=68adfe5afea20fa3403ea5a41f8cb021ae3a96ab;hpb=68878dc8366f2f4a0afe132847aad9a51a80cdbf;p=quassel.git diff --git a/src/qtui/coresessionwidget.cpp b/src/qtui/coresessionwidget.cpp index 68adfe5a..fbbb39b8 100644 --- a/src/qtui/coresessionwidget.cpp +++ b/src/qtui/coresessionwidget.cpp @@ -22,6 +22,7 @@ #include "client.h" #include "coresessionwidget.h" +#include "util.h" CoreSessionWidget::CoreSessionWidget(QWidget *parent) @@ -36,7 +37,12 @@ void CoreSessionWidget::setData(QMap map) ui.sessionGroup->setTitle(map["remoteAddress"].toString()); ui.labelLocation->setText(map["location"].toString()); ui.labelClient->setText(map["clientVersion"].toString()); - ui.labelVersionDate->setText(map["clientVersionDate"].toString()); + if (map["clientVersionDate"].toString().isEmpty()) { + ui.labelVersionDate->setText(QString("%1").arg(tr("Unknown date"))); + } + else { + ui.labelVersionDate->setText(tryFormatUnixEpoch(map["clientVersionDate"].toString())); + } ui.labelUptime->setText(map["connectedSince"].toDateTime().toLocalTime().toString(Qt::DateFormat::SystemLocaleShortDate)); if (map["location"].toString().isEmpty()) { ui.labelLocation->hide(); @@ -45,7 +51,25 @@ void CoreSessionWidget::setData(QMap map) ui.labelSecure->setText(map["secure"].toBool() ? tr("Yes") : tr("No")); auto features = Quassel::Features{map["featureList"].toStringList(), static_cast(map["features"].toUInt())}; - ui.disconnectButton->setVisible(features.isEnabled(Quassel::Feature::RemoteDisconnect)); + if (features.isEnabled(Quassel::Feature::RemoteDisconnect)) { + // Both client and core support it, enable the button + ui.disconnectButton->setEnabled(true); + ui.disconnectButton->setToolTip(tr("End the client's session, disconnecting it")); + } else { + // For any active sessions to be displayed, the core must support this feature. We can + // assume the client doesn't support being remotely disconnected. + // + // (During the development of 0.13, there was a period of time where active sessions existed + // but did not provide the disconnect option. We can overlook this.) + + // Either core or client doesn't support it, disable the option + ui.disconnectButton->setEnabled(false); + // Assuming the client lacks support, set the tooltip accordingly + ui.disconnectButton->setToolTip( + QString("

%1

%2

").arg( + tr("End the client's session, disconnecting it"), + tr("This client does not support being remotely disconnected"))); + } bool success = false; _peerId = map["id"].toInt(&success); @@ -54,5 +78,10 @@ void CoreSessionWidget::setData(QMap map) void CoreSessionWidget::disconnectClicked() { + // Don't allow the End Session button to be spammed; Quassel's protocol isn't lossy and it + // should reach the destination eventually... + ui.disconnectButton->setEnabled(false); + ui.disconnectButton->setText(tr("Ending session...")); + emit disconnectClicked(_peerId); }