Skip to content

Commit

Permalink
Merge pull request #4550 from nextcloud/backport/4540/stable-3.5
Browse files Browse the repository at this point in the history
[stable-3.5] Fix visual borking in the share dialog
  • Loading branch information
mgallien authored May 17, 2022
2 parents 77ffc3c + b9bbb84 commit 05f08a6
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 47 deletions.
12 changes: 10 additions & 2 deletions src/gui/sharedialog.cpp
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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());
}
Expand Down
60 changes: 30 additions & 30 deletions src/gui/sharedialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -49,35 +49,35 @@
<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>
Expand All @@ -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>
Expand All @@ -101,7 +101,7 @@
</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">
Expand Down Expand Up @@ -132,28 +132,28 @@
</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>
Expand Down
20 changes: 12 additions & 8 deletions src/gui/sharelinkwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand All @@ -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();
}
}
Expand All @@ -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"));

Expand Down
4 changes: 2 additions & 2 deletions src/gui/sharelinkwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ private slots:
QAction *_allowUploadLinkAction;
QAction *_passwordProtectLinkAction;
QAction *_expirationDateLinkAction;
QAction *_unshareLinkAction;
QAction *_addAnotherLinkAction;
QScopedPointer<QAction> _unshareLinkAction;
QScopedPointer<QAction> _addAnotherLinkAction;
QAction *_noteLinkAction;
QHBoxLayout *_shareLinkLayout{};
QLabel *_shareLinkLabel{};
Expand Down
12 changes: 7 additions & 5 deletions src/gui/shareusergroupwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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));
Expand Down
1 change: 1 addition & 0 deletions src/gui/shareusergroupwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ private slots:
void activateShareeLineEdit();

Ui::ShareUserGroupWidget *_ui;
QScopedPointer<QAction> _searchGloballyAction;
QScrollArea *_parentScrollArea;
QVBoxLayout *_shareUserGroup;
AccountPtr _account;
Expand Down

0 comments on commit 05f08a6

Please sign in to comment.