cmake: avoid de-duplication of user's CXXFLAGS
[quassel.git] / src / qtui / coresessionwidget.cpp
index d31122d..a4c5465 100644 (file)
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2005-2018 by the Quassel Project                        *
+ *   Copyright (C) 2005-2022 by the Quassel Project                        *
  *   devel@quassel-irc.org                                                 *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
  ***************************************************************************/
 
+#include "coresessionwidget.h"
+
 #include <QDateTime>
 
 #include "client.h"
-#include "coresessionwidget.h"
+#include "util.h"
 
-
-CoreSessionWidget::CoreSessionWidget(QWidget *parent)
+CoreSessionWidget::CoreSessionWidget(QWidget* parent)
     : QWidget(parent)
 {
     ui.setupUi(this);
-    connect(ui.disconnectButton, SIGNAL(released()), this, SLOT(disconnectClicked()));
+    connect(ui.disconnectButton, &QPushButton::released, this, &CoreSessionWidget::onDisconnectClicked);
 }
 
 void CoreSessionWidget::setData(QMap<QString, QVariant> map)
@@ -36,8 +37,13 @@ void CoreSessionWidget::setData(QMap<QString, QVariant> 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());
-    ui.labelUptime->setText(map["connectedSince"].toDateTime().toLocalTime().toString(Qt::DateFormat::SystemLocaleShortDate));
+    if (map["clientVersionDate"].toString().isEmpty()) {
+        ui.labelVersionDate->setText(QString("<i>%1</i>").arg(tr("Unknown date")));
+    }
+    else {
+        ui.labelVersionDate->setText(tryFormatUnixEpoch(map["clientVersionDate"].toString(), Qt::DateFormat::DefaultLocaleShortDate));
+    }
+    ui.labelUptime->setText(map["connectedSince"].toDateTime().toLocalTime().toString(Qt::DateFormat::DefaultLocaleShortDate));
     if (map["location"].toString().isEmpty()) {
         ui.labelLocation->hide();
         ui.labelLocationTitle->hide();
@@ -49,37 +55,29 @@ void CoreSessionWidget::setData(QMap<QString, QVariant> map)
         // 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 {
+    }
+    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);
-        if (!Client::isCoreFeatureEnabled(Quassel::Feature::RemoteDisconnect)) {
-            // Until RemoteDisconnect was implemented, the Quassel core didn't forward client
-            // features.  A client might support features and we'll never hear about it.
-            // This check shouldn't be necessary for later features if the core supports at least
-            // RemoteDisconnect.
-
-            // Core doesn't support this feature (we don't know about the client)
-            ui.disconnectButton->setToolTip(
-                        QString("<p>%1</p><p><b>%2</b><br/>%3</p>").arg(
-                            tr("End the client's session, disconnecting it"),
-                            tr("Your Quassel core does not support this feature"),
-                            tr("You need a Quassel core v0.13.0 or newer in order to end connected "
-                               "sessions.")));
-        } else {
-            // Client doesn't support this feature
-            ui.disconnectButton->setToolTip(
-                        QString("<p>%1</p><p><b>%2</b></p>").arg(
-                            tr("End the client's session, disconnecting it"),
-                            tr("This client does not support being remotely disconnected")));
-        }
+        // Assuming the client lacks support, set the tooltip accordingly
+        ui.disconnectButton->setToolTip(
+            QString("<p>%1</p><p><b>%2</b></p>")
+                .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);
-    if (!success) _peerId = -1;
+    if (!success)
+        _peerId = -1;
 }
 
-void CoreSessionWidget::disconnectClicked()
+void CoreSessionWidget::onDisconnectClicked()
 {
     // Don't allow the End Session button to be spammed; Quassel's protocol isn't lossy and it
     // should reach the destination eventually...