Fix label borking and wrong icon colours in the share dialog

Signed-off-by: Claudio Cambra <claudio.cambra@gmail.com>
This commit is contained in:
Claudio Cambra 2022-05-16 15:46:06 +02:00
parent 6bd99f59d1
commit 2d74a5752e
6 changed files with 73 additions and 58 deletions

View 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);
connect(this, &ShareDialog::toggleShareLinkAnimation, _emptyShareLinkWidget, &ShareLinkWidget::slotToggleShareLinkAnimation);
connect(_emptyShareLinkWidget, &ShareLinkWidget::createLinkShare, this, &ShareDialog::slotCreateLinkShare);
_emptyShareLinkWidget->slotStyleChanged(); // Get the initial customizeStyle() to happen
connect(this, &ShareDialog::toggleShareLinkAnimation, _emptyShareLinkWidget, &ShareLinkWidget::slotToggleShareLinkAnimation);
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());
}

View 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>
@ -49,33 +49,8 @@
<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">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" 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>
</size>
</property>
<property name="text">
<string>Icon</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="label_name">
<property name="sizePolicy">
@ -101,7 +76,32 @@
</property>
</widget>
</item>
<item row="2" column="1">
<item row="3" column="1">
<widget class="QLabel" name="label_lockinfo">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>315</width>
<height>0</height>
</size>
</property>
<property name="text">
<string notr="true">TextLabel</string>
</property>
<property name="textFormat">
<enum>Qt::PlainText</enum>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="label_sharePath">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Maximum">
@ -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="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string notr="true">TextLabel</string>
</property>
<property name="textFormat">
<enum>Qt::PlainText</enum>
</property>
<property name="wordWrap">
<bool>true</bool>
<string>Icon</string>
</property>
</widget>
</item>

View 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"));

View 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{};

View 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));

View File

@ -113,6 +113,7 @@ private:
void activateShareeLineEdit();
Ui::ShareUserGroupWidget *_ui;
QScopedPointer<QAction> _searchGloballyAction;
QScrollArea *_parentScrollArea;
QVBoxLayout *_shareUserGroup;
AccountPtr _account;