From 90eb088d34ce625f1af9986170f45274738c4832 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Mon, 16 May 2022 15:46:06 +0200 Subject: [PATCH] Fix label borking and wrong icon colours in the share dialog Signed-off-by: Claudio Cambra --- src/gui/sharedialog.cpp | 12 +++++-- src/gui/sharedialog.ui | 60 ++++++++++++++++---------------- src/gui/sharelinkwidget.cpp | 20 ++++++----- src/gui/sharelinkwidget.h | 4 +-- src/gui/shareusergroupwidget.cpp | 12 ++++--- src/gui/shareusergroupwidget.h | 1 + 6 files changed, 62 insertions(+), 47 deletions(-) diff --git a/src/gui/sharedialog.cpp b/src/gui/sharedialog.cpp index 95fca99e65be0..2220a46166f28 100644 --- a/src/gui/sharedialog.cpp +++ b/src/gui/sharedialog.cpp @@ -1,4 +1,4 @@ -/* +/* * Copyright (C) by Roeland Jago Douma * * This program is free software; you can redistribute it and/or modify @@ -103,6 +103,8 @@ ShareDialog::ShareDialog(QPointer accountState, const auto remainingTime = QDateTime::currentDateTime().secsTo(QDateTime::fromSecsSinceEpoch(lockExpirationTime)); const auto remainingTimeInMinute = static_cast(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()); } diff --git a/src/gui/sharedialog.ui b/src/gui/sharedialog.ui index accfc2b5cf651..cd207fbb25863 100644 --- a/src/gui/sharedialog.ui +++ b/src/gui/sharedialog.ui @@ -38,7 +38,7 @@ QLayout::SetDefaultConstraint - + 0 @@ -49,35 +49,35 @@ 0 - 10 + 2 - - + + - + 0 0 - 40 - 40 - - - - - 16777215 - 16777215 + 315 + 0 - Icon + share label + + + Qt::PlainText + + + true - - + + 0 @@ -91,7 +91,7 @@ - share label + TextLabel Qt::PlainText @@ -101,7 +101,7 @@ - + @@ -132,28 +132,28 @@ - - + + - + 0 0 - 315 - 0 + 40 + 40 - - TextLabel - - - Qt::PlainText + + + 16777215 + 16777215 + - - true + + Icon diff --git a/src/gui/sharelinkwidget.cpp b/src/gui/sharelinkwidget.cpp index 8c77c29683976..09186e9723d9c 100644 --- a/src/gui/sharelinkwidget.cpp +++ b/src/gui/sharelinkwidget.cpp @@ -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")); diff --git a/src/gui/sharelinkwidget.h b/src/gui/sharelinkwidget.h index f80aeb52cac1a..186b6fe2b4e3a 100644 --- a/src/gui/sharelinkwidget.h +++ b/src/gui/sharelinkwidget.h @@ -140,8 +140,8 @@ private slots: QAction *_allowUploadLinkAction; QAction *_passwordProtectLinkAction; QAction *_expirationDateLinkAction; - QAction *_unshareLinkAction; - QAction *_addAnotherLinkAction; + QScopedPointer _unshareLinkAction; + QScopedPointer _addAnotherLinkAction; QAction *_noteLinkAction; QHBoxLayout *_shareLinkLayout{}; QLabel *_shareLinkLabel{}; diff --git a/src/gui/shareusergroupwidget.cpp b/src/gui/shareusergroupwidget.cpp index 3c24925770ef8..024e1266e482d 100644 --- a/src/gui/shareusergroupwidget.cpp +++ b/src/gui/shareusergroupwidget.cpp @@ -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)); diff --git a/src/gui/shareusergroupwidget.h b/src/gui/shareusergroupwidget.h index d8122a4897a3b..512c5f7cab9bf 100644 --- a/src/gui/shareusergroupwidget.h +++ b/src/gui/shareusergroupwidget.h @@ -113,6 +113,7 @@ private slots: void activateShareeLineEdit(); Ui::ShareUserGroupWidget *_ui; + QScopedPointer _searchGloballyAction; QScrollArea *_parentScrollArea; QVBoxLayout *_shareUserGroup; AccountPtr _account;