Fix the secure lock label aspect
authorKevin Ottens <kevin.ottens@nextcloud.com>
Thu, 8 Oct 2020 15:39:24 +0000 (17:39 +0200)
committerKevin Ottens <kevin.ottens@nextcloud.com>
Tue, 13 Oct 2020 05:28:32 +0000 (07:28 +0200)
Make sure we got a fixed size for that label. Also ensure that the
pixmap we display there is properly scaled to fit while maintaining the
aspect ratio.

Signed-off-by: Kevin Ottens <kevin.ottens@nextcloud.com>
src/gui/wizard/owncloudsetupnocredspage.ui
src/gui/wizard/owncloudsetuppage.cpp

index bad3323d3e1f731a59378e2a5dd1d5e1e654c84b..e158cc19c71a108bb2180d512b2cd8e0848de34e 100644 (file)
             <item>
              <widget class="QLabel" name="urlLabel">
               <property name="sizePolicy">
-               <sizepolicy hsizetype="Preferred" vsizetype="Expanding">
+               <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
                 <horstretch>0</horstretch>
                 <verstretch>0</verstretch>
                </sizepolicy>
               </property>
+              <property name="minimumSize">
+               <size>
+                <width>24</width>
+                <height>24</height>
+               </size>
+              </property>
               <property name="text">
                <string/>
               </property>
index 428f18a032002c6121a7c03082e7beba4be14784..f286eebc1d18ed69847831a70bbdf0b8e306dce3 100644 (file)
@@ -175,14 +175,15 @@ void OwncloudSetupPage::slotUrlChanged(const QString &url)
         _ui.leUrl->setText(newUrl);
     }
 
-    if (!url.startsWith(QLatin1String("https://"))) {
-        _ui.urlLabel->setPixmap(QPixmap(Theme::hidpiFileName(":/client/theme/lock-http.svg")));
-        _ui.urlLabel->setToolTip(tr("This URL is NOT secure as it is not encrypted.\n"
-                                    "It is not advisable to use it."));
-    } else {
-        _ui.urlLabel->setPixmap(QPixmap(Theme::hidpiFileName(":/client/theme/lock-https.svg")));
-        _ui.urlLabel->setToolTip(tr("This URL is secure. You can use it."));
-    }
+    const auto isSecure = url.startsWith(QLatin1String("https://"));
+    const auto toolTip = isSecure ? tr("This URL is secure. You can use it.")
+                                  : tr("This URL is NOT secure as it is not encrypted.\n"
+                                       "It is not advisable to use it.");
+    const auto pixmap = isSecure ? QPixmap(Theme::hidpiFileName(":/client/theme/lock-https.svg"))
+                                 : QPixmap(Theme::hidpiFileName(":/client/theme/lock-http.svg"));
+
+    _ui.urlLabel->setToolTip(toolTip);
+    _ui.urlLabel->setPixmap(pixmap.scaled(_ui.urlLabel->size(), Qt::KeepAspectRatio));
 }
 
 void OwncloudSetupPage::slotUrlEditFinished()