mirror of
https://github.com/nextcloud/desktop.git
synced 2025-10-26 11:17:43 +00:00
Merge pull request #5946 from nextcloud/bugfix/remember-server-color
Display correct server colour prior to acquiring server capabilities
This commit is contained in:
commit
daba7a11e5
@ -42,6 +42,8 @@ constexpr auto caCertsKeyC = "CaCertificates";
|
||||
constexpr auto accountsC = "Accounts";
|
||||
constexpr auto versionC = "version";
|
||||
constexpr auto serverVersionC = "serverVersion";
|
||||
constexpr auto serverColorC = "serverColor";
|
||||
constexpr auto serverTextColorC = "serverTextColor";
|
||||
constexpr auto skipE2eeMetadataChecksumValidationC = "skipE2eeMetadataChecksumValidation";
|
||||
constexpr auto generalC = "General";
|
||||
|
||||
@ -306,6 +308,8 @@ void AccountManager::saveAccountHelper(Account *acc, QSettings &settings, bool s
|
||||
settings.setValue(QLatin1String(davUserC), acc->_davUser);
|
||||
settings.setValue(QLatin1String(displayNameC), acc->_displayName);
|
||||
settings.setValue(QLatin1String(serverVersionC), acc->_serverVersion);
|
||||
settings.setValue(QLatin1String(serverColorC), acc->_serverColor);
|
||||
settings.setValue(QLatin1String(serverTextColorC), acc->_serverTextColor);
|
||||
if (!acc->_skipE2eeMetadataChecksumValidation) {
|
||||
settings.remove(QLatin1String(skipE2eeMetadataChecksumValidationC));
|
||||
} else {
|
||||
@ -412,6 +416,8 @@ AccountPtr AccountManager::loadAccountHelper(QSettings &settings)
|
||||
qCInfo(lcAccountManager) << "Account for" << acc->url() << "using auth type" << authType;
|
||||
|
||||
acc->_serverVersion = settings.value(QLatin1String(serverVersionC)).toString();
|
||||
acc->_serverColor = settings.value(QLatin1String(serverColorC)).value<QColor>();
|
||||
acc->_serverTextColor = settings.value(QLatin1String(serverTextColorC)).value<QColor>();
|
||||
acc->_skipE2eeMetadataChecksumValidation = settings.value(QLatin1String(skipE2eeMetadataChecksumValidationC), {}).toBool();
|
||||
acc->_davUser = settings.value(QLatin1String(davUserC), "").toString();
|
||||
|
||||
|
||||
@ -13,16 +13,16 @@
|
||||
*/
|
||||
|
||||
#include "account.h"
|
||||
#include "accountfwd.h"
|
||||
#include "clientsideencryptionjobs.h"
|
||||
#include "cookiejar.h"
|
||||
#include "networkjobs.h"
|
||||
#include "configfile.h"
|
||||
#include "accessmanager.h"
|
||||
#include "creds/abstractcredentials.h"
|
||||
#include "accountfwd.h"
|
||||
#include "capabilities.h"
|
||||
#include "theme.h"
|
||||
#include "clientsideencryptionjobs.h"
|
||||
#include "configfile.h"
|
||||
#include "cookiejar.h"
|
||||
#include "creds/abstractcredentials.h"
|
||||
#include "networkjobs.h"
|
||||
#include "pushnotifications.h"
|
||||
#include "theme.h"
|
||||
#include "version.h"
|
||||
|
||||
#include "deletejob.h"
|
||||
@ -71,6 +71,7 @@ const char app_password[] = "_app-password";
|
||||
Account::Account(QObject *parent)
|
||||
: QObject(parent)
|
||||
, _capabilities(QVariantMap())
|
||||
, _serverColor(Theme::defaultColor())
|
||||
{
|
||||
qRegisterMetaType<AccountPtr>("AccountPtr");
|
||||
qRegisterMetaType<Account *>("Account*");
|
||||
@ -197,32 +198,30 @@ QString Account::prettyName() const
|
||||
return name;
|
||||
}
|
||||
|
||||
QColor Account::serverColor() const
|
||||
{
|
||||
return _serverColor;
|
||||
}
|
||||
|
||||
QColor Account::headerColor() const
|
||||
{
|
||||
const auto serverColor = capabilities().serverColor();
|
||||
return serverColor.isValid() ? serverColor : Theme::defaultColor();
|
||||
return serverColor();
|
||||
}
|
||||
|
||||
QColor Account::headerTextColor() const
|
||||
{
|
||||
const auto headerTextColor = capabilities().serverTextColor();
|
||||
return headerTextColor.isValid() ? headerTextColor : QColor(255,255,255);
|
||||
return _serverTextColor;
|
||||
}
|
||||
|
||||
QColor Account::accentColor() const
|
||||
{
|
||||
// This will need adjusting when dark theme is a thing
|
||||
auto serverColor = capabilities().serverColor();
|
||||
const auto accentColor = serverColor();
|
||||
constexpr auto effectMultiplier = 8;
|
||||
|
||||
if(!serverColor.isValid()) {
|
||||
serverColor = Theme::defaultColor();
|
||||
}
|
||||
|
||||
const auto effectMultiplier = 8;
|
||||
auto darknessAdjustment = static_cast<int>((1 - Theme::getColorDarkness(serverColor)) * effectMultiplier);
|
||||
auto darknessAdjustment = static_cast<int>((1 - Theme::getColorDarkness(accentColor)) * effectMultiplier);
|
||||
darknessAdjustment *= darknessAdjustment; // Square the value to pronounce the darkness more in lighter colours
|
||||
const auto baseAdjustment = 125;
|
||||
const auto adjusted = Theme::isDarkColor(serverColor) ? serverColor : serverColor.darker(baseAdjustment + darknessAdjustment);
|
||||
const auto adjusted = Theme::isDarkColor(accentColor) ? accentColor : accentColor.darker(baseAdjustment + darknessAdjustment);
|
||||
return adjusted;
|
||||
}
|
||||
|
||||
@ -649,10 +648,23 @@ const Capabilities &Account::capabilities() const
|
||||
return _capabilities;
|
||||
}
|
||||
|
||||
void Account::updateServerColors()
|
||||
{
|
||||
if (const auto capServerColor = _capabilities.serverColor(); capServerColor.isValid()) {
|
||||
_serverColor = capServerColor;
|
||||
}
|
||||
|
||||
if (const auto capServerTextColor = _capabilities.serverTextColor(); capServerTextColor.isValid()) {
|
||||
_serverTextColor = capServerTextColor;
|
||||
}
|
||||
}
|
||||
|
||||
void Account::setCapabilities(const QVariantMap &caps)
|
||||
{
|
||||
_capabilities = Capabilities(caps);
|
||||
|
||||
updateServerColors();
|
||||
|
||||
emit capabilitiesChanged();
|
||||
|
||||
setupUserStatusConnector();
|
||||
|
||||
@ -31,12 +31,13 @@
|
||||
#include <QPixmap>
|
||||
#endif
|
||||
|
||||
#include "common/utility.h"
|
||||
#include <memory>
|
||||
#include "capabilities.h"
|
||||
#include "clientsideencryption.h"
|
||||
#include "common/utility.h"
|
||||
#include "syncfileitem.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
class QSettings;
|
||||
class QNetworkReply;
|
||||
class QUrl;
|
||||
@ -375,8 +376,10 @@ protected Q_SLOTS:
|
||||
private:
|
||||
Account(QObject *parent = nullptr);
|
||||
void setSharedThis(AccountPtr sharedThis);
|
||||
void updateServerColors();
|
||||
|
||||
static QString davPathBase();
|
||||
[[nodiscard]] static QString davPathBase();
|
||||
[[nodiscard]] QColor serverColor() const;
|
||||
|
||||
bool _trustCertificates = false;
|
||||
|
||||
@ -406,6 +409,8 @@ private:
|
||||
QSslConfiguration _sslConfiguration;
|
||||
Capabilities _capabilities;
|
||||
QString _serverVersion;
|
||||
QColor _serverColor;
|
||||
QColor _serverTextColor = QColorConstants::White;
|
||||
bool _skipE2eeMetadataChecksumValidation = false;
|
||||
QScopedPointer<AbstractSslErrorHandler> _sslErrorHandler;
|
||||
QSharedPointer<QNetworkAccessManager> _am;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user