Warning, /plasma/latte-dock/containment/package/contents/ui/colorizer/Manager.qml is written in an unsupported language. File is not indexed.
0001 /*
0002 * Copyright 2018 Michail Vourlakos <mvourlakos@gmail.com>
0003 *
0004 * This file is part of Latte-Dock
0005 *
0006 * Latte-Dock is free software; you can redistribute it and/or
0007 * modify it under the terms of the GNU General Public License as
0008 * published by the Free Software Foundation; either version 2 of
0009 * the License, or (at your option) any later version.
0010 *
0011 * Latte-Dock is distributed in the hope that it will be useful,
0012 * but WITHOUT ANY WARRANTY; without even the implied warranty of
0013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0014 * GNU General Public License for more details.
0015 *
0016 * You should have received a copy of the GNU General Public License
0017 * along with this program. If not, see <http://www.gnu.org/licenses/>.
0018 */
0019
0020 import QtQuick 2.7
0021
0022 import org.kde.plasma.plasmoid 2.0
0023 import org.kde.plasma.core 2.0 as PlasmaCore
0024
0025 import org.kde.latte 0.2 as Latte
0026
0027 import "../../code/ColorizerTools.js" as ColorizerTools
0028
0029 Loader{
0030 id: manager
0031
0032 //! the loader loads the backgroundTracker component
0033 active: root.themeColors === Latte.Types.SmartThemeColors
0034
0035 readonly property bool backgroundIsBusy: item ? item.isBusy : false
0036
0037 readonly property real originalThemeTextColorBrightness: ColorizerTools.colorBrightness(theme.textColor)
0038 readonly property color originalLightTextColor: originalThemeTextColorBrightness > 127.5 ? theme.textColor : theme.backgroundColor
0039
0040 readonly property real themeTextColorBrightness: ColorizerTools.colorBrightness(textColor)
0041 readonly property real backgroundColorBrightness: ColorizerTools.colorBrightness(backgroundColor)
0042 readonly property color minimizedDotColor: themeTextColorBrightness > 127.5 ? Qt.darker(textColor, 1.7) : Qt.lighter(textColor, 8)
0043
0044 readonly property color focusGlowColor: Qt.hsva(buttonFocusColor.h, buttonFocusColor.s, 1.0, 1.0)
0045
0046 readonly property color outlineColorBase: backgroundColor
0047 readonly property real outlineColorBaseBrightness: ColorizerTools.colorBrightness(outlineColorBase)
0048 readonly property color outlineColor: {
0049 if (!root.panelOutline) {
0050 return backgroundColor;
0051 }
0052
0053 if (outlineColorBaseBrightness > 127.5) {
0054 return Qt.darker(outlineColorBase, 1.5);
0055 } else {
0056 return Qt.lighter(outlineColorBase, 2.2);
0057 }
0058 }
0059
0060 readonly property bool editModeTextColorIsBright: ColorizerTools.colorBrightness(editModeTextColor) > 127.5
0061 readonly property color editModeTextColor: latteView && latteView.layout ? latteView.layout.textColor : "white"
0062
0063 readonly property bool mustBeShown: (applyTheme && applyTheme !== theme)
0064 || (root.inConfigureAppletsMode && (root.themeColors === Latte.Types.SmartThemeColors))
0065
0066 readonly property real currentBackgroundBrightness: item ? item.currentBrightness : -1000
0067
0068 readonly property bool applyingWindowColors: (root.windowColors === Latte.Types.ActiveWindowColors && latteView && latteView.windowsTracker
0069 && selectedWindowsTracker.activeWindowScheme)
0070 || (root.windowColors === Latte.Types.TouchingWindowColors && latteView && latteView.windowsTracker
0071 && latteView.windowsTracker.currentScreen.touchingWindowScheme)
0072
0073 property QtObject applyTheme: {
0074 if (!graphicsSystem.isAccelerated) {
0075 return theme;
0076 }
0077
0078 if (latteView && latteView.windowsTracker && !root.hasExpandedApplet) {
0079 if (root.windowColors === Latte.Types.ActiveWindowColors && selectedWindowsTracker.activeWindowScheme) {
0080 return selectedWindowsTracker.activeWindowScheme;
0081 }
0082
0083 if (root.windowColors === Latte.Types.TouchingWindowColors && latteView.windowsTracker.currentScreen.touchingWindowScheme) {
0084 //! we must track touching windows and when they are not ative
0085 //! the active window scheme is used for convenience
0086 if (latteView.windowsTracker.currentScreen.existsWindowTouching
0087 && !latteView.windowsTracker.currentScreen.activeWindowTouching
0088 && latteView.windowsTracker.currentScreen.activeWindowScheme) {
0089 return latteView.windowsTracker.currentScreen.activeWindowScheme;
0090 }
0091
0092 return latteView.windowsTracker.currentScreen.touchingWindowScheme;
0093 }
0094 }
0095
0096 if (themeExtended) {
0097 if (root.userShowPanelBackground && root.plasmaBackgroundForPopups && root.hasExpandedApplet /*for expanded popups when it is enabled*/
0098 || root.plasmaStyleBusyForTouchingBusyVerticalView
0099 || (root.themeColors === Latte.Types.SmartThemeColors /*for Smart theming that Windows colors are not used and the user wants solidness at some cases*/
0100 && root.windowColors === Latte.Types.NoneWindowColors
0101 && root.forceSolidPanel) ) {
0102 /* plasma style*/
0103 return theme;
0104 }
0105
0106 if (root.themeColors === Latte.Types.ReverseThemeColors) {
0107 return themeExtended.isLightTheme ? themeExtended.darkTheme : themeExtended.lightTheme;
0108 }
0109
0110 if (root.themeColors === Latte.Types.SmartThemeColors) {
0111 //! Smart Colors Case
0112 if (!root.forcePanelForBusyBackground) {
0113 //! simple case that not a busy background is applied
0114 return currentBackgroundBrightness > 127.5 ? themeExtended.lightTheme : themeExtended.darkTheme;
0115 } else {
0116 //! Smart + Busy background case
0117 var themeContrastedTextColor = currentBackgroundBrightness > 127.5 ? themeExtended.lightTheme : themeExtended.darkTheme;
0118 var themeContrastedBackground = currentBackgroundBrightness > 127.5 ? themeExtended.darkTheme : themeExtended.lightTheme;
0119
0120 if (root.panelTransparency < 35) {
0121 //! textColor should be better to provide the needed contrast
0122 return themeContrastedTextColor;
0123 } else if (root.panelTransparency >= 35 && root.panelTransparency <= 70) {
0124 //! provide a dark case scenario at all cases
0125 return themeExtended.darkTheme;
0126 } else {
0127 //! default plasma theme should be better for panel transparency > 70
0128 return theme;
0129 }
0130 }
0131 }
0132 }
0133
0134 return theme;
0135 }
0136
0137 property color applyColor: textColor
0138
0139 readonly property color backgroundColor:applyTheme.backgroundColor
0140 readonly property color textColor: {
0141 if (latteView && latteView.layout
0142 && root.inConfigureAppletsMode
0143 && Latte.WindowSystem.compositingActive
0144 && root.panelTransparency<40
0145 && (root.themeColors === Latte.Types.SmartThemeColors)) {
0146 return latteView.layout.textColor;
0147 }
0148
0149 return applyTheme.textColor;
0150 }
0151
0152 readonly property color inactiveBackgroundColor: applyTheme === theme ? theme.backgroundColor : applyTheme.inactiveBackgroundColor
0153 readonly property color inactiveTextColor: applyTheme === theme ? theme.textColor : applyTheme.inactiveTextColor
0154
0155 readonly property color highlightColor: applyTheme.highlightColor
0156 readonly property color highlightedTextColor: applyTheme.highlightedTextColor
0157 readonly property color positiveTextColor: applyTheme.positiveTextColor
0158 readonly property color neutralTextColor: applyTheme.neutralTextColor
0159 readonly property color negativeTextColor: applyTheme.negativeTextColor
0160
0161 readonly property color buttonTextColor: applyTheme.buttonTextColor
0162 readonly property color buttonBackgroundColor: applyTheme.buttonBackgroundColor
0163 readonly property color buttonHoverColor: applyTheme.buttonHoverColor
0164 readonly property color buttonFocusColor: applyTheme.buttonFocusColor
0165
0166 readonly property string scheme: {
0167 if (root.inConfigureAppletsMode && (root.themeColors === Latte.Types.SmartThemeColors)) {
0168 if (!Latte.WindowSystem.compositingActive && applyTheme !== theme) {
0169 return applyTheme.schemeFile;
0170 }
0171
0172 //! in edit mode (that is shown the edit visual without opacity)
0173 //! take care the applets that need a proper color scheme to paint themselves
0174 if ((editModeTextColorIsBright && themeExtended.isLightTheme)
0175 || (!editModeTextColorIsBright && !themeExtended.isLightTheme)) {
0176 if (themeExtended.darkTheme === themeExtended.defaultTheme) {
0177 console.log("light theme..." + themeExtended.isLightTheme);
0178 return themeExtended.lightTheme.schemeFile;
0179 } else {
0180 console.log("dark theme..." + themeExtended.isLightTheme);
0181 return themeExtended.darkTheme.schemeFile;
0182 }
0183 } else {
0184 console.log("default theme... : " + themeExtended.isLightTheme);
0185 return themeExtended.defaultTheme.schemeFile;
0186 }
0187 }
0188
0189 if (applyTheme===theme || !mustBeShown) {
0190 if (themeExtended) {
0191 return themeExtended.defaultTheme.schemeFile;
0192 } else {
0193 return "kdeglobals";
0194 }
0195 }
0196
0197 return applyTheme.schemeFile;
0198 }
0199
0200 sourceComponent: Latte.BackgroundTracker {
0201 activity: viewLayout ? viewLayout.lastUsedActivity : ""
0202 location: plasmoid.location
0203 screenName: latteView && latteView.positioner ? latteView.positioner.currentScreenName : ""
0204 }
0205 }