Skip to content

Commit

Permalink
Address Mattheiu's last comment
Browse files Browse the repository at this point in the history
Signed-off-by: Claudio Cambra <claudio.cambra@gmail.com>
  • Loading branch information
claucambra committed Mar 12, 2022
1 parent ff5ec21 commit febf5f6
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
7 changes: 4 additions & 3 deletions src/libsync/account.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,16 +168,17 @@ QColor Account::headerColor() const

QColor Account::headerTextColor() const
{
return capabilities().serverTextColor();
const auto headerTextColor = capabilities().serverTextColor();
return headerTextColor.isValid() ? headerTextColor : QColor(255,255,255);
}

QColor Account::accentColor() const
{
// This will need adjusting when dark theme is a thing
const auto serverColor = capabilities().serverColor();
auto serverColor = capabilities().serverColor();

if(!serverColor.isValid()) {
return {};
serverColor = Theme::defaultColor();
}

const auto effectMultiplier = 8;
Expand Down
18 changes: 10 additions & 8 deletions src/libsync/capabilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,25 +241,27 @@ bool Capabilities::userStatusSupportsEmoji() const

QColor Capabilities::serverColor() const
{
if (!_capabilities.contains("theming")) {
return {};
}

const auto themingMap = _capabilities["theming"].toMap();
return QColor(themingMap["color"].toString());
const auto themingMap = serverThemingMap();
return themingMap.contains("color") ? QColor(themingMap["color"].toString()) : QColor();
}

QColor Capabilities::serverTextColor() const
{
const auto themingMap = serverThemingMap();
return themingMap.contains("color-text") ? QColor(themingMap["color-text"].toString()) : QColor();
}

QMap<QString, QVariant> Capabilities::serverThemingMap() const
{
if (!_capabilities.contains("theming")) {
return {};
}

const auto themingMap = _capabilities["theming"].toMap();
return QColor(themingMap["color-text"].toString());
return _capabilities["theming"].toMap();
}



PushNotificationTypes Capabilities::availablePushNotifications() const
{
if (!_capabilities.contains("notify_push")) {
Expand Down
2 changes: 2 additions & 0 deletions src/libsync/capabilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ class OWNCLOUDSYNC_EXPORT Capabilities
DirectEditor* getDirectEditorForOptionalMimetype(const QMimeType &mimeType);

private:
QMap<QString, QVariant> serverThemingMap() const;

QVariantMap _capabilities;

QList<DirectEditor*> _directEditors;
Expand Down

0 comments on commit febf5f6

Please sign in to comment.