X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Fcoresessionwidget.cpp;h=97993f4f5c18701be0355257a18bf0307f6e9f36;hp=fa6d17608478ef14b91e657d680724cb03dff1b2;hb=911f181e0e179eb51279c0880eb701a43163b8b5;hpb=28cee4568aeb1ce3014d11234e40f19e7aeae5bd diff --git a/src/qtui/coresessionwidget.cpp b/src/qtui/coresessionwidget.cpp index fa6d1760..97993f4f 100644 --- a/src/qtui/coresessionwidget.cpp +++ b/src/qtui/coresessionwidget.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-2016 by the Quassel Project * + * Copyright (C) 2005-2018 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -28,27 +28,42 @@ CoreSessionWidget::CoreSessionWidget(QWidget *parent) : QWidget(parent) { ui.setupUi(this); - layout()->setContentsMargins(0, 0, 0, 0); - layout()->setSpacing(0); connect(ui.disconnectButton, SIGNAL(released()), this, SLOT(disconnectClicked())); } void CoreSessionWidget::setData(QMap map) { - QLabel *iconSecure = ui.iconSecure; - // TODO: Implement "secure" icon - Q_UNUSED(iconSecure); - - ui.labelRemoteAddress->setText(map["remoteAddress"].toString()); + ui.sessionGroup->setTitle(map["remoteAddress"].toString()); ui.labelLocation->setText(map["location"].toString()); ui.labelClient->setText(map["clientVersion"].toString()); ui.labelVersionDate->setText(map["clientVersionDate"].toString()); - ui.labelUptime - ->setText(map["connectedSince"].toDateTime().toLocalTime().toString(Qt::DateFormat::SystemLocaleShortDate)); + ui.labelUptime->setText(map["connectedSince"].toDateTime().toLocalTime().toString(Qt::DateFormat::SystemLocaleShortDate)); if (map["location"].toString().isEmpty()) { ui.labelLocation->hide(); ui.labelLocationTitle->hide(); } + ui.labelSecure->setText(map["secure"].toBool() ? tr("Yes") : tr("No")); + + auto features = Quassel::Features{map["featureList"].toStringList(), static_cast(map["features"].toUInt())}; + 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); @@ -57,5 +72,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); }