forked from Shinonome/dots-hyprland
Merge branch 'main' into hefty-hype
This commit is contained in:
+4
-4
@@ -5,13 +5,13 @@ import qs.modules.common.functions
|
||||
import qs.modules.common.widgets
|
||||
|
||||
QuickToggleModel {
|
||||
name: Translation.tr("Anti-flashbang")
|
||||
tooltipText: Translation.tr("Anti-flashbang")
|
||||
icon: "flash_off"
|
||||
name: HyprlandAntiFlashbangShader.enabled ? (HyprlandAntiFlashbangShader.weak ? Translation.tr("Anti-flash: Weak") : Translation.tr("Anti-flash: Strong")) : Translation.tr("Anti-flashbang")
|
||||
tooltipText: `${Translation.tr("Anti-flashbang")}: ${HyprlandAntiFlashbangShader.enabled ? (HyprlandAntiFlashbangShader.weak ? Translation.tr("Weak") : Translation.tr("Strong")) : Translation.tr("Off")}`
|
||||
icon: HyprlandAntiFlashbangShader.enabled ? (!HyprlandAntiFlashbangShader.weak ? "flash_off" : "sunny_snowing") : "flash_on"
|
||||
toggled: HyprlandAntiFlashbangShader.enabled
|
||||
|
||||
mainAction: () => {
|
||||
HyprlandAntiFlashbangShader.toggle()
|
||||
HyprlandAntiFlashbangShader.cycle()
|
||||
}
|
||||
hasMenu: true
|
||||
}
|
||||
|
||||
@@ -153,7 +153,7 @@ Item { // Notification item area
|
||||
implicitHeight: summaryText.implicitHeight
|
||||
StyledText {
|
||||
id: summaryText
|
||||
Layout.fillWidth: summaryTextMetrics.width >= summaryRow.implicitWidth * root.summaryElideRatio
|
||||
Layout.fillWidth: summaryTextMetrics.width >= root.width * root.summaryElideRatio
|
||||
visible: !root.onlyNotification
|
||||
font.pixelSize: root.fontSize
|
||||
color: Appearance.colors.colOnLayer3
|
||||
|
||||
@@ -16,6 +16,7 @@ Item {
|
||||
|
||||
StyledFlickable {
|
||||
id: flickable
|
||||
clip: true
|
||||
anchors.fill: parent
|
||||
anchors.margins: Appearance.rounding.small
|
||||
contentHeight: height
|
||||
@@ -34,4 +35,10 @@ Item {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ScrollEdgeFade {
|
||||
target: flickable
|
||||
vertical: false
|
||||
color: Appearance.colors.colLayer0Base
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,8 @@ import QtQuick
|
||||
import QtQuick.Layouts
|
||||
import Quickshell
|
||||
|
||||
// Notes:
|
||||
// We deal with keybinds being numbered 1, 2, etc by discarding 2+, keeping 1 and replacing it with a generic "<Number>"
|
||||
Column {
|
||||
id: root
|
||||
required property string categoryName
|
||||
@@ -61,11 +63,11 @@ Column {
|
||||
property var keyBlacklist: ["SUPER_L", "SUPER_R"]
|
||||
property var keySubstitutions: Object.assign({
|
||||
"Super": "",
|
||||
"Mouse_up": "Scroll ↓", // ikr, weird
|
||||
"Mouse_down": "Scroll ↑", // trust me bro
|
||||
"Mouse:272": "LMB",
|
||||
"Mouse:273": "RMB",
|
||||
"Mouse:275": "MouseBack",
|
||||
"mouse_up": "Scroll ↓", // ikr, weird
|
||||
"mouse_down": "Scroll ↑", // trust me bro
|
||||
"mouse:272": "LMB",
|
||||
"mouse:273": "RMB",
|
||||
"mouse:275": "MouseBack",
|
||||
"Slash": "/",
|
||||
"Hash": "#",
|
||||
"Return": "Enter",
|
||||
@@ -93,6 +95,7 @@ Column {
|
||||
return list;
|
||||
}
|
||||
|
||||
visible: repeater.model.length > 0
|
||||
spacing: titleSpacing
|
||||
|
||||
StyledText {
|
||||
@@ -100,14 +103,59 @@ Column {
|
||||
font.pixelSize: Appearance.font.pixelSize.title
|
||||
}
|
||||
|
||||
function hasDescription(bind) {
|
||||
return bind.description?.length > 0;
|
||||
}
|
||||
|
||||
function isCategory(bind, categoryName) {
|
||||
return bind.description.substring(0, bind.description.indexOf(":")) === categoryName;
|
||||
}
|
||||
|
||||
function isUncategorized(bind) {
|
||||
return bind.description.indexOf(":") === -1;
|
||||
}
|
||||
|
||||
function containsNonFirstRepetitive(bind) {
|
||||
const key = bind.key;
|
||||
if (key.includes("mouse") || key.includes("page")) return false;
|
||||
// Contains non-1 number
|
||||
if (/\d/.test(key) && !key.includes("1")) return true;
|
||||
// Contains non-left direction
|
||||
if (/^(right|up|down)\b/i.test(key)) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
function containsFirstRepetitive(bind) {
|
||||
const key = bind.key;
|
||||
return key.includes("1") || /left/i.test(key);
|
||||
}
|
||||
|
||||
function transformKey(key) {
|
||||
const replaced = root.keySubstitutions[key] || key;
|
||||
const denumbered = replaced.replace("1", "<Number>");
|
||||
const dedirectioned = denumbered.replace("Left", "<Direction>");
|
||||
return dedirectioned;
|
||||
}
|
||||
|
||||
function transformDescription(bind, categoryName) {
|
||||
const description = bind.description
|
||||
const regex = new RegExp("\\s*" + categoryName + "\\s*:\\s*");
|
||||
const decategorized = description.replace(regex, "");
|
||||
if (!containsFirstRepetitive(bind)) return decategorized;
|
||||
const denumbered = decategorized.replace("1", "<Number>");
|
||||
const dedirectioned = denumbered.replace(/ \b(left|right|up|down)\b/i, " <Direction>");
|
||||
return dedirectioned;
|
||||
}
|
||||
|
||||
Column {
|
||||
spacing: 4
|
||||
Repeater {
|
||||
id: repeater
|
||||
model: {
|
||||
if (!root.isCategorized) {
|
||||
return HyprlandKeybinds.keybinds.filter(bind => bind.description?.length > 0 && bind.description.indexOf(":") === -1);
|
||||
return HyprlandKeybinds.keybinds.filter(bind => root.hasDescription(bind) && root.isUncategorized(bind) && !root.containsNonFirstRepetitive(bind));
|
||||
}
|
||||
return HyprlandKeybinds.keybinds.filter(bind => bind.description?.length > 0 && bind.description.substring(0, bind.description.indexOf(":")) === root.categoryName);
|
||||
return HyprlandKeybinds.keybinds.filter(bind => root.hasDescription(bind) && root.isCategory(bind, root.categoryName) && !root.containsNonFirstRepetitive(bind));
|
||||
}
|
||||
delegate: BindLine {
|
||||
required property var modelData
|
||||
@@ -138,7 +186,7 @@ Column {
|
||||
}
|
||||
delegate: KeyboardKey {
|
||||
required property var modelData
|
||||
key: modelData
|
||||
key: root.transformKey(modelData)
|
||||
pixelSize: Config.options.cheatsheet.fontSize.key
|
||||
}
|
||||
}
|
||||
@@ -152,10 +200,7 @@ Column {
|
||||
id: keybindKey
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
visible: !keyBlacklist.includes(bindLine.keyData.key)
|
||||
key: {
|
||||
const k = StringUtils.toTitleCase(bindLine.keyData.key)
|
||||
return root.keySubstitutions[k] || k
|
||||
}
|
||||
key: root.transformKey(bindLine.keyData.key)
|
||||
pixelSize: Config.options.cheatsheet.fontSize.key
|
||||
color: Appearance.colors.colOnLayer0
|
||||
}
|
||||
@@ -169,10 +214,7 @@ Column {
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
anchors.left: parent.left
|
||||
font.pixelSize: Config.options.cheatsheet.fontSize.comment || Appearance.font.pixelSize.smaller
|
||||
text: {
|
||||
const regex = new RegExp("\\s*" + bindLine.categoryName + "\\s*:\\s*");
|
||||
return bindLine.keyData.description.replace(regex, "");
|
||||
}
|
||||
text: root.transformDescription(bindLine.keyData, bindLine.categoryName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -226,7 +226,7 @@ RippleButton {
|
||||
color: root.colForeground
|
||||
horizontalAlignment: Text.AlignLeft
|
||||
elide: Text.ElideRight
|
||||
text: root.selected ? root.itemName : root.displayContent
|
||||
text: root.selected ? StringUtils.escapeHtml(root.itemName) : root.displayContent
|
||||
}
|
||||
}
|
||||
Loader { // Clipboard image preview
|
||||
|
||||
@@ -21,7 +21,6 @@ Scope {
|
||||
|
||||
component CornerPanelWindow: PanelWindow {
|
||||
id: cornerPanelWindow
|
||||
property var screen: QsWindow.window?.screen
|
||||
property var brightnessMonitor: Brightness.getMonitorForScreen(screen)
|
||||
property bool fullscreen
|
||||
visible: (Config.options.appearance.fakeScreenRounding === 1 || (Config.options.appearance.fakeScreenRounding === 2 && !fullscreen))
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ GroupButton {
|
||||
// Declared in specific toggles
|
||||
property QuickToggleModel toggleModel
|
||||
property string name: toggleModel?.name ?? ""
|
||||
property string statusText: (toggleModel?.hasStatusText) ? (toggleModel?.statusText || (toggled ? Translation.tr("Active") : Translation.tr("Inactive"))) : ""
|
||||
property string statusText: (toggleModel?.hasStatusText) ? (toggleModel?.statusText || (toggled ? Translation.tr("On") : Translation.tr("Off"))) : ""
|
||||
property string tooltipText: toggleModel?.tooltipText ?? ""
|
||||
property string buttonIcon: toggleModel?.icon ?? "close"
|
||||
property bool available: toggleModel?.available ?? true
|
||||
|
||||
@@ -10,7 +10,9 @@ Singleton {
|
||||
id: root
|
||||
|
||||
readonly property string shaderPath: Quickshell.shellPath("services/hyprlandAntiFlashbangShader/anti-flashbang.glsl")
|
||||
property bool enabled: confOpt.value == shaderPath
|
||||
readonly property string weakShaderPath: Quickshell.shellPath("services/hyprlandAntiFlashbangShader/anti-flashbang-weak.glsl")
|
||||
property bool enabled: confOpt.value == shaderPath || weak
|
||||
property bool weak: confOpt.value == weakShaderPath
|
||||
|
||||
function enable() {
|
||||
HyprlandConfig.setMany({
|
||||
@@ -19,6 +21,13 @@ Singleton {
|
||||
});
|
||||
}
|
||||
|
||||
function enableWeak() {
|
||||
HyprlandConfig.setMany({
|
||||
"decoration:screen_shader": root.weakShaderPath,
|
||||
"debug:damage_tracking": 1,
|
||||
});
|
||||
}
|
||||
|
||||
function disable() {
|
||||
HyprlandConfig.resetMany([
|
||||
"decoration:screen_shader",
|
||||
@@ -30,6 +39,16 @@ Singleton {
|
||||
if (root.enabled) disable()
|
||||
else enable()
|
||||
}
|
||||
|
||||
function cycle() {
|
||||
if (!enabled) {
|
||||
enableWeak();
|
||||
} else if (weak) {
|
||||
enable();
|
||||
} else {
|
||||
disable();
|
||||
}
|
||||
}
|
||||
|
||||
HyprlandConfigOption {
|
||||
id: confOpt
|
||||
|
||||
@@ -166,7 +166,6 @@ Singleton {
|
||||
target: Config.options.light.night
|
||||
function onColorTemperatureChanged() {
|
||||
if (!root.temperatureActive) return;
|
||||
Hyprland.dispatch(`hyprctl hyprsunset temperature ${Config.options.light.night.colorTemperature}`);
|
||||
Quickshell.execDetached(["hyprctl", "hyprsunset", "temperature", `${Config.options.light.night.colorTemperature}`]);
|
||||
}
|
||||
}
|
||||
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
#version 300 es
|
||||
precision highp float;
|
||||
|
||||
in vec2 v_texcoord;
|
||||
uniform sampler2D tex;
|
||||
out vec4 fragColor;
|
||||
|
||||
float overlayOpacityForBrightness(float x) {
|
||||
// Note: range 0 to 1
|
||||
|
||||
// Will a fancy curve help?... I'll have to experiment more at night
|
||||
// float y = pow(x, 2.0) * 0.75;
|
||||
// float y = (1.0 - exp(-x))*1.19;
|
||||
// float y = (1.0 - exp(-pow((x-0.15), 0.6)))*1.18;
|
||||
|
||||
float y = x*0.42;
|
||||
return min(max(y, 0.001), 1.0);
|
||||
}
|
||||
|
||||
void main() {
|
||||
// 1. Get the current pixel color
|
||||
vec4 pixColor = texture(tex, v_texcoord);
|
||||
|
||||
// 2. Calculate average screen brightness
|
||||
vec3 totalRGB = vec3(0.0);
|
||||
float samples = 0.0;
|
||||
|
||||
// We use a nested loop to create a 10x10 grid (100 samples)
|
||||
// This is dense enough to catch small icons/text but light enough to run fast.
|
||||
for(float x = 0.05; x < 1.0; x += 0.1) {
|
||||
for(float y = 0.05; y < 1.0; y += 0.1) {
|
||||
totalRGB += texture(tex, vec2(x, y)).rgb;
|
||||
samples++;
|
||||
}
|
||||
}
|
||||
|
||||
vec3 avgColor = totalRGB / samples;
|
||||
float globalBrightness = dot(avgColor, vec3(0.2126, 0.7152, 0.0722));
|
||||
|
||||
// 3. Get the specific opacity for this brightness level
|
||||
float opacity = overlayOpacityForBrightness(globalBrightness);
|
||||
|
||||
// 4. Apply the "black overlay" effect
|
||||
vec3 outColor = mix(pixColor.rgb, vec3(0.0), opacity);
|
||||
|
||||
fragColor = vec4(outColor, pixColor.a);
|
||||
}
|
||||
Reference in New Issue
Block a user