diff --git a/containment/package/contents/ui/VisibilityManager.qml b/containment/package/contents/ui/VisibilityManager.qml index e11d8c8f8..e3ced3ef9 100644 --- a/containment/package/contents/ui/VisibilityManager.qml +++ b/containment/package/contents/ui/VisibilityManager.qml @@ -288,7 +288,6 @@ Item{ property: "drawEffects" when: latteView && latteView.effects value: LatteCore.WindowSystem.compositingActive - && !root.inConfigureAppletsMode && (((root.blurEnabled && root.useThemePanel) || (root.blurEnabled && root.forceSolidPanel && LatteCore.WindowSystem.compositingActive)) && (!root.inStartup || inForceHiding || inTempHiding)) diff --git a/declarativeimports/core/CMakeLists.txt b/declarativeimports/core/CMakeLists.txt index 40d326569..ad5fa0939 100644 --- a/declarativeimports/core/CMakeLists.txt +++ b/declarativeimports/core/CMakeLists.txt @@ -5,6 +5,7 @@ set(lattecoreplugin_SRCS environment.cpp iconitem.cpp quickwindowsystem.cpp + tools.cpp types.h ) diff --git a/declarativeimports/core/lattecoreplugin.cpp b/declarativeimports/core/lattecoreplugin.cpp index 78f53bcf9..82a6d02b4 100644 --- a/declarativeimports/core/lattecoreplugin.cpp +++ b/declarativeimports/core/lattecoreplugin.cpp @@ -24,6 +24,7 @@ #include "environment.h" #include "iconitem.h" #include "quickwindowsystem.h" +#include "tools.h" #include @@ -37,5 +38,6 @@ void LatteCorePlugin::registerTypes(const char *uri) qmlRegisterUncreatableType(uri, 0, 2, "Types", "Latte Types uncreatable"); qmlRegisterType(uri, 0, 2, "IconItem"); qmlRegisterSingletonType(uri, 0, 2, "Environment", &Latte::environment_qobject_singletontype_provider); + qmlRegisterSingletonType(uri, 0, 2, "Tools", &Latte::tools_qobject_singletontype_provider); qmlRegisterSingletonType(uri, 0, 2, "WindowSystem", &Latte::windowsystem_qobject_singletontype_provider); } diff --git a/declarativeimports/core/tools.cpp b/declarativeimports/core/tools.cpp new file mode 100644 index 000000000..74113ceed --- /dev/null +++ b/declarativeimports/core/tools.cpp @@ -0,0 +1,78 @@ +/* + * Copyright 2020 Michail Vourlakos + * + * This file is part of Latte-Dock + * + * Latte-Dock is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * Latte-Dock is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +#include "tools.h" + +// Qt +#include + +namespace Latte{ + +Tools::Tools(QObject *parent) + : QObject(parent) +{ +} + +float Tools::colorBrightness(QColor color) +{ + return colorBrightness(color.red(), color.green(), color.blue()); +} + +float Tools::colorBrightness(QRgb rgb) +{ + return colorBrightness(qRed(rgb), qGreen(rgb), qBlue(rgb)); +} + +float Tools::colorBrightness(float r, float g, float b) +{ + float brightness = (r * 299 + g * 587 + b * 114) / 1000; + + return brightness; +} + +float Tools::colorLumina(QRgb rgb) +{ + float r = (float)(qRed(rgb)) / 255; + float g = (float)(qGreen(rgb)) / 255; + float b = (float)(qBlue(rgb)) / 255; + + return colorLumina(r, g, b); +} + +float Tools::colorLumina(QColor color) +{ + return colorLumina(color.redF(), color.greenF(), color.blueF()); +} + +float Tools::colorLumina(float r, float g, float b) +{ + // formula for luminance according to: + // https://www.w3.org/TR/2008/REC-WCAG20-20081211/#relativeluminancedef + + float rS = (r <= 0.03928 ? r / 12.92 : qPow(((r + 0.055) / 1.055), 2.4)); + float gS = (g <= 0.03928 ? g / 12.92 : qPow(((g + 0.055) / 1.055), 2.4)); + float bS = (b <= 0.03928 ? b / 12.92 : qPow(((b + 0.055) / 1.055), 2.4)); + + float luminosity = 0.2126 * rS + 0.7152 * gS + 0.0722 * bS; + + return luminosity; +} + +} diff --git a/declarativeimports/core/tools.h b/declarativeimports/core/tools.h new file mode 100644 index 000000000..31f12f178 --- /dev/null +++ b/declarativeimports/core/tools.h @@ -0,0 +1,63 @@ +/* + * Copyright 2020 Michail Vourlakos + * + * This file is part of Latte-Dock + * + * Latte-Dock is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * Latte-Dock is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +#ifndef LATTECORETOOLS_H +#define LATTECORETOOLS_H + +// Qt +#include +#include +#include +#include + + +namespace Latte{ + +class Tools final: public QObject +{ + Q_OBJECT + +public: + explicit Tools(QObject *parent = nullptr); + +public slots: + Q_INVOKABLE float colorBrightness(QColor color); + Q_INVOKABLE float colorLumina(QColor color); + +private: + float colorBrightness(QRgb rgb); + float colorBrightness(float r, float g, float b); + + float colorLumina(QRgb rgb); + float colorLumina(float r, float g, float b); +}; + +static QObject *tools_qobject_singletontype_provider(QQmlEngine *engine, QJSEngine *scriptEngine) +{ + Q_UNUSED(engine) + Q_UNUSED(scriptEngine) + +// NOTE: QML engine is the owner of this resource + return new Tools; +} + +} + +#endif diff --git a/shell/package/contents/configuration/canvas/SettingsOverlay.qml b/shell/package/contents/configuration/canvas/SettingsOverlay.qml index 71287e085..d7ad6eb62 100644 --- a/shell/package/contents/configuration/canvas/SettingsOverlay.qml +++ b/shell/package/contents/configuration/canvas/SettingsOverlay.qml @@ -24,6 +24,8 @@ import QtQuick.Layouts 1.1 import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.components 2.0 as PlasmaComponents +import org.kde.latte.core 0.2 as LatteCore + import "controls" as SettingsControls import "maxlength" as MaximumLength @@ -46,7 +48,7 @@ Item{ property string tooltip: "" - readonly property real textColorBrightness: 150// ColorizerTools.colorBrightness(textColor) + readonly property real textColorBrightness: LatteCore.Tools.colorBrightness(textColor) readonly property bool textColorIsDark: textColorBrightness < 127.5 readonly property color bestContrastedTextColor: {