qtui: Hide "fallback" and "Override" if no system theme is configured
[quassel.git] / src / qtui / coreinfodlg.cpp
index e5eb7f4..299a94f 100644 (file)
@@ -18,6 +18,8 @@
  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
  ***************************************************************************/
 
+#include <QMessageBox>
+
 #include "coreinfodlg.h"
 
 #include "client.h"
@@ -30,6 +32,9 @@ CoreInfoDlg::CoreInfoDlg(QWidget *parent) : QDialog(parent) {
 
     coreInfoChanged(coreInfo->coreData());
 
+    // Warning icon
+    ui.coreUnsupportedIcon->setPixmap(QIcon::fromTheme("dialog-warning").pixmap(16));
+
     updateUptime();
     startTimer(1000);
 }
@@ -59,7 +64,10 @@ void CoreInfoDlg::coreInfoChanged(const QVariantMap &coreInfo) {
         coreSessionWidget->setData(peerMap);
         if (isNew) {
             _widgets[peerId] = coreSessionWidget;
-            ui.coreSessionContainer->addWidget(coreSessionWidget);
+            // Add this to the end of the session list, but before the default layout stretch item.
+            // The layout stretch item should never be removed, so count should always be >= 1.
+            ui.coreSessionContainer->insertWidget(ui.coreSessionContainer->count() - 1,
+                                                  coreSessionWidget, 0, Qt::AlignTop);
             connect(coreSessionWidget, SIGNAL(disconnectClicked(int)), this, SLOT(disconnectClicked(int)));
         }
     }
@@ -70,7 +78,9 @@ void CoreInfoDlg::coreInfoChanged(const QVariantMap &coreInfo) {
     }
 
     ui.coreSessionScrollArea->setVisible(coreSessionSupported);
-    ui.coreSessionContainer->addStretch(1);
+
+    // Hide the information bar when core sessions are supported
+    ui.coreUnsupportedWidget->setVisible(!coreSessionSupported);
 }
 
 
@@ -100,3 +110,13 @@ void CoreInfoDlg::updateUptime() {
 void CoreInfoDlg::disconnectClicked(int peerId) {
     Client::kickClient(peerId);
 }
+
+void CoreInfoDlg::on_coreUnsupportedDetails_clicked()
+{
+    QMessageBox::warning(this,
+                         tr("Active sessions unsupported"),
+                         QString("<p><b>%1</b></p></br><p>%2</p>"
+                                 ).arg(tr("Your Quassel core is too old to show active sessions"),
+                                       tr("You need a Quassel core v0.13.0 or newer to view and "
+                                          "disconnect other connected clients.")));
+}