Fix label borking and wrong icon colours in the share dialog
authorClaudio Cambra <claudio.cambra@gmail.com>
Mon, 16 May 2022 13:46:06 +0000 (15:46 +0200)
committerClaudio Cambra <claudio.cambra@gmail.com>
Mon, 16 May 2022 20:59:00 +0000 (22:59 +0200)
Signed-off-by: Claudio Cambra <claudio.cambra@gmail.com>
src/gui/sharedialog.cpp
src/gui/sharedialog.ui
src/gui/sharelinkwidget.cpp
src/gui/sharelinkwidget.h
src/gui/shareusergroupwidget.cpp
src/gui/shareusergroupwidget.h

index 95fca99e65be02cc82775cbd43ee2377a8a998c5..2220a46166f2810bd5dc732e800b23e9d14bf47f 100644 (file)
@@ -1,4 +1,4 @@
-/*
+/*
  * Copyright (C) by Roeland Jago Douma <roeland@famdouma.nl>
  *
  * This program is free software; you can redistribute it and/or modify
@@ -103,6 +103,8 @@ ShareDialog::ShareDialog(QPointer<AccountState> accountState,
         const auto remainingTime = QDateTime::currentDateTime().secsTo(QDateTime::fromSecsSinceEpoch(lockExpirationTime));
         const auto remainingTimeInMinute = static_cast<int>(remainingTime > 0 ? remainingTime / SECONDS_PER_MINUTE : 0);
         _ui->label_lockinfo->setText(tr("Locked by %1 - Expire in %2 minutes", "remaining time before lock expire", remainingTimeInMinute).arg(_filelockState._lockOwnerDisplayName).arg(remainingTimeInMinute));
+    } else {
+        _ui->label_lockinfo->setVisible(false);
     }
 
     QString ocDir(_sharePath);
@@ -196,9 +198,13 @@ void ShareDialog::initLinkShareWidget()
     if(_linkWidgetList.size() == 0) {
         _emptyShareLinkWidget = new ShareLinkWidget(_accountState->account(), _sharePath, _localPath, _maxSharingPermissions, _ui->scrollArea);
         _linkWidgetList.append(_emptyShareLinkWidget);
+
+        _emptyShareLinkWidget->slotStyleChanged(); // Get the initial customizeStyle() to happen
+
         connect(this, &ShareDialog::toggleShareLinkAnimation, _emptyShareLinkWidget, &ShareLinkWidget::slotToggleShareLinkAnimation);
-        connect(_emptyShareLinkWidget, &ShareLinkWidget::createLinkShare, this, &ShareDialog::slotCreateLinkShare);
+        connect(this, &ShareDialog::styleChanged, _emptyShareLinkWidget, &ShareLinkWidget::slotStyleChanged);
 
+        connect(_emptyShareLinkWidget, &ShareLinkWidget::createLinkShare, this, &ShareDialog::slotCreateLinkShare);
         connect(_emptyShareLinkWidget, &ShareLinkWidget::createPassword, this, &ShareDialog::slotCreatePasswordForLinkShare);
 
         _ui->verticalLayout->insertWidget(_linkWidgetList.size()+1, _emptyShareLinkWidget);
@@ -322,6 +328,8 @@ void ShareDialog::showSharingUi()
         // Connect styleChanged events to our widget, so it can adapt (Dark-/Light-Mode switching)
         connect(this, &ShareDialog::styleChanged, _userGroupWidget, &ShareUserGroupWidget::slotStyleChanged);
 
+        _userGroupWidget->slotStyleChanged();
+
         _ui->verticalLayout->insertWidget(1, _userGroupWidget);
         _scrollAreaLayout->addLayout(_userGroupWidget->shareUserGroupLayout());
     }
index accfc2b5cf651426dd89c65a162159db52421b46..cd207fbb2586390cca27f6132953ce3e5bb24643 100644 (file)
@@ -38,7 +38,7 @@
       <enum>QLayout::SetDefaultConstraint</enum>
      </property>
      <item>
-      <layout class="QGridLayout" name="gridLayout" rowstretch="0,0" columnstretch="0,0">
+      <layout class="QGridLayout" name="gridLayout" rowstretch="0,0,0,0" columnstretch="0,0">
        <property name="leftMargin">
         <number>0</number>
        </property>
         <number>0</number>
        </property>
        <property name="spacing">
-        <number>10</number>
+       <number>2</number>
        </property>
-       <item row="0" column="0" rowspan="2">
-        <widget class="QLabel" name="label_icon">
+       <item row="0" column="1">
+        <widget class="QLabel" name="label_name">
          <property name="sizePolicy">
-          <sizepolicy hsizetype="Maximum" vsizetype="Maximum">
+          <sizepolicy hsizetype="Minimum" vsizetype="Maximum">
            <horstretch>0</horstretch>
            <verstretch>0</verstretch>
           </sizepolicy>
          </property>
          <property name="minimumSize">
           <size>
-           <width>40</width>
-           <height>40</height>
-          </size>
-         </property>
-         <property name="maximumSize">
-          <size>
-           <width>16777215</width>
-           <height>16777215</height>
+           <width>315</width>
+           <height>0</height>
           </size>
          </property>
          <property name="text">
-          <string>Icon</string>
+          <string>share label</string>
+         </property>
+         <property name="textFormat">
+          <enum>Qt::PlainText</enum>
+         </property>
+         <property name="wordWrap">
+          <bool>true</bool>
          </property>
         </widget>
        </item>
-       <item row="0" column="1">
-        <widget class="QLabel" name="label_name">
+       <item row="3" column="1">
+        <widget class="QLabel" name="label_lockinfo">
          <property name="sizePolicy">
           <sizepolicy hsizetype="Minimum" vsizetype="Maximum">
            <horstretch>0</horstretch>
@@ -91,7 +91,7 @@
           </size>
          </property>
          <property name="text">
-          <string>share label</string>
+          <string notr="true">TextLabel</string>
          </property>
          <property name="textFormat">
           <enum>Qt::PlainText</enum>
          </property>
         </widget>
        </item>
-       <item row="2" column="1">
+       <item row="1" column="1">
         <widget class="QLabel" name="label_sharePath">
          <property name="sizePolicy">
           <sizepolicy hsizetype="Minimum" vsizetype="Maximum">
          </property>
         </widget>
        </item>
-       <item row="1" column="1">
-        <widget class="QLabel" name="label_lockinfo">
+       <item row="0" column="0" rowspan="3">
+        <widget class="QLabel" name="label_icon">
          <property name="sizePolicy">
-          <sizepolicy hsizetype="Minimum" vsizetype="Maximum">
+          <sizepolicy hsizetype="Maximum" vsizetype="Maximum">
            <horstretch>0</horstretch>
            <verstretch>0</verstretch>
           </sizepolicy>
          </property>
          <property name="minimumSize">
           <size>
-           <width>315</width>
-           <height>0</height>
+           <width>40</width>
+           <height>40</height>
           </size>
          </property>
-         <property name="text">
-          <string notr="true">TextLabel</string>
-         </property>
-         <property name="textFormat">
-          <enum>Qt::PlainText</enum>
+         <property name="maximumSize">
+          <size>
+           <width>16777215</width>
+           <height>16777215</height>
+          </size>
          </property>
-         <property name="wordWrap">
-          <bool>true</bool>
+         <property name="text">
+          <string>Icon</string>
          </property>
         </widget>
        </item>
index 8c77c29683976ec6f5b6f396d0127d4c43d4b3f0..09186e9723d9ce53c4408d441953fbed69aa36aa 100644 (file)
@@ -301,13 +301,13 @@ void ShareLinkWidget::setupUiOptions()
     }
 
     // Adds action to unshare widget (check box)
-    _unshareLinkAction = _linkContextMenu->addAction(QIcon(":/client/theme/delete.svg"),
-        tr("Delete link"));
+    _unshareLinkAction.reset(_linkContextMenu->addAction(QIcon(":/client/theme/delete.svg"),
+        tr("Delete link")));
 
     _linkContextMenu->addSeparator();
 
-    _addAnotherLinkAction = _linkContextMenu->addAction(QIcon(":/client/theme/add.svg"),
-        tr("Add another link"));
+    _addAnotherLinkAction.reset(_linkContextMenu->addAction(QIcon(":/client/theme/add.svg"),
+        tr("Add another link")));
 
     _ui->enableShareLink->setIcon(QIcon(":/client/theme/copy.svg"));
     disconnect(_ui->enableShareLink, &QPushButton::clicked, this, &ShareLinkWidget::slotCreateShareLink);
@@ -543,7 +543,7 @@ void ShareLinkWidget::slotLinkContextMenuActionTriggered(QAction *action)
     const auto state = action->isChecked();
     SharePermissions perm = SharePermissionRead;
 
-    if (action == _addAnotherLinkAction) {
+    if (action == _addAnotherLinkAction.data()) {
         emit createLinkShare();
 
     } else if (action == _readOnlyLinkAction && state) {
@@ -570,7 +570,7 @@ void ShareLinkWidget::slotLinkContextMenuActionTriggered(QAction *action)
     } else if (action == _noteLinkAction) {
         toggleNoteOptions(state);
 
-    } else if (action == _unshareLinkAction) {
+    } else if (action == _unshareLinkAction.data()) {
         confirmAndDeleteShare();
     }
 }
@@ -596,9 +596,13 @@ void ShareLinkWidget::slotStyleChanged()
 
 void ShareLinkWidget::customizeStyle()
 {
-    _unshareLinkAction->setIcon(Theme::createColorAwareIcon(":/client/theme/delete.svg"));
+    if(_unshareLinkAction) {
+        _unshareLinkAction->setIcon(Theme::createColorAwareIcon(":/client/theme/delete.svg"));
+    }
 
-    _addAnotherLinkAction->setIcon(Theme::createColorAwareIcon(":/client/theme/add.svg"));
+    if(_addAnotherLinkAction) {
+        _addAnotherLinkAction->setIcon(Theme::createColorAwareIcon(":/client/theme/add.svg"));
+    }
 
     _ui->enableShareLink->setIcon(Theme::createColorAwareIcon(":/client/theme/copy.svg"));
 
index f80aeb52cac1a421fa96a4dcbb4ddc011084c2d3..186b6fe2b4e3a3c0e3ee3d4231abe79bb3a80399 100644 (file)
@@ -140,8 +140,8 @@ private:
     QAction *_allowUploadLinkAction;
     QAction *_passwordProtectLinkAction;
     QAction *_expirationDateLinkAction;
-    QAction *_unshareLinkAction;
-    QAction *_addAnotherLinkAction;
+    QScopedPointer<QAction> _unshareLinkAction;
+    QScopedPointer<QAction> _addAnotherLinkAction;
     QAction *_noteLinkAction;
     QHBoxLayout *_shareLinkLayout{};
     QLabel *_shareLinkLabel{};
index 3c24925770ef80a1661ce55ce98b1063b604e732..024e1266e482d4964b57df6ecc8ffa64aa3d7ae5 100644 (file)
@@ -118,15 +118,15 @@ ShareUserGroupWidget::ShareUserGroupWidget(AccountPtr account,
     _completer->setCompletionMode(QCompleter::UnfilteredPopupCompletion);
     _ui->shareeLineEdit->setCompleter(_completer);
 
-    auto searchGloballyAction = new QAction(_ui->shareeLineEdit);
-    searchGloballyAction->setIcon(QIcon(":/client/theme/magnifying-glass.svg"));
-    searchGloballyAction->setToolTip(tr("Search globally"));
+    _searchGloballyAction.reset(new QAction(_ui->shareeLineEdit));
+    _searchGloballyAction->setIcon(Theme::createColorAwareIcon(":/client/theme/magnifying-glass.svg"));
+    _searchGloballyAction->setToolTip(tr("Search globally"));
 
-    connect(searchGloballyAction, &QAction::triggered, this, [this]() {
+    connect(_searchGloballyAction.data(), &QAction::triggered, this, [this]() {
         searchForSharees(ShareeModel::GlobalSearch);
     });
 
-    _ui->shareeLineEdit->addAction(searchGloballyAction, QLineEdit::LeadingPosition);
+    _ui->shareeLineEdit->addAction(_searchGloballyAction.data(), QLineEdit::LeadingPosition);
 
     _manager = new ShareManager(_account, this);
     connect(_manager, &ShareManager::sharesFetched, this, &ShareUserGroupWidget::slotSharesFetched);
@@ -433,6 +433,8 @@ void ShareUserGroupWidget::slotStyleChanged()
 
 void ShareUserGroupWidget::customizeStyle()
 {
+    _searchGloballyAction->setIcon(Theme::createColorAwareIcon(":/client/theme/magnifying-glass.svg"));
+
     _ui->confirmShare->setIcon(Theme::createColorAwareIcon(":/client/theme/confirm.svg"));
 
     _pi_sharee.setColor(QGuiApplication::palette().color(QPalette::Text));
index d8122a4897a3b23974b073bb6b5763d4a4347a43..512c5f7cab9bf899404da57e7ae8c384cf00ac3a 100644 (file)
@@ -113,6 +113,7 @@ private:
     void activateShareeLineEdit();
 
     Ui::ShareUserGroupWidget *_ui;
+    QScopedPointer<QAction> _searchGloballyAction;
     QScrollArea *_parentScrollArea;
     QVBoxLayout *_shareUserGroup;
     AccountPtr _account;