diff options
author | Michael Schuster <michael@schuster.ms> | 2019-12-09 22:59:10 +0300 |
---|---|---|
committer | Michael Schuster <48932272+misch7@users.noreply.github.com> | 2019-12-09 23:37:21 +0300 |
commit | 7ce8a6a201adbd81a514e815e0a064bf1e89f96b (patch) | |
tree | 72742402b37c1a2ac0bfc99c4563e3824844409b /src/gui/sharedialog.cpp | |
parent | 789a2a7ae39f04fc1ad7b16ee28e5744a7dcec40 (diff) |
Make the ShareDialog background-aware (Dark-/Light-Mode switching)
Use customizeStyle() to change link colours, icons and pixmaps in the ShareDialog and notify
it's widgets via slots.
TODO - known issue (macOS):
- The background and font colours in the ShareUserLine widget still stay the same.
Signed-off-by: Michael Schuster <michael@schuster.ms>
Diffstat (limited to 'src/gui/sharedialog.cpp')
-rw-r--r-- | src/gui/sharedialog.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/gui/sharedialog.cpp b/src/gui/sharedialog.cpp index 435de4a0c..544e0e723 100644 --- a/src/gui/sharedialog.cpp +++ b/src/gui/sharedialog.cpp @@ -156,6 +156,9 @@ void ShareDialog::addLinkShareWidget(const QSharedPointer<LinkShare> &linkShare) connect(_linkWidgetList.at(index), &ShareLinkWidget::deleteLinkShare, this, &ShareDialog::slotDeleteShare); //connect(_linkWidgetList.at(index), &ShareLinkWidget::resizeRequested, this, &ShareDialog::slotAdjustScrollWidgetSize); + // Connect styleChanged events to our widget, so it can adapt (Dark-/Light-Mode switching) + connect(this, &ShareDialog::styleChanged, _linkWidgetList.at(index), &ShareLinkWidget::slotStyleChanged); + _ui->verticalLayout->insertWidget(_linkWidgetList.size()+1, _linkWidgetList.at(index)); _linkWidgetList.at(index)->setupUiOptions(); } @@ -281,6 +284,10 @@ void ShareDialog::showSharingUi() if (userGroupSharing) { _userGroupWidget = new ShareUserGroupWidget(_accountState->account(), _sharePath, _localPath, _maxSharingPermissions, _privateLinkUrl, this); + + // Connect styleChanged events to our widget, so it can adapt (Dark-/Light-Mode switching) + connect(this, &ShareDialog::styleChanged, _userGroupWidget, &ShareUserGroupWidget::slotStyleChanged); + _ui->verticalLayout->insertWidget(1, _userGroupWidget); _userGroupWidget->getShares(); } @@ -334,4 +341,21 @@ void ShareDialog::slotAccountStateChanged(int state) } } } + +void ShareDialog::changeEvent(QEvent *e) +{ + switch (e->type()) { + case QEvent::StyleChange: + case QEvent::PaletteChange: + case QEvent::ThemeChange: + // Notify the other widgets (Dark-/Light-Mode switching) + emit styleChanged(); + break; + default: + break; + } + + QDialog::changeEvent(e); +} + } |