Refactor icons font wip
This commit is contained in:
parent
b1f9609cd3
commit
43eec0e387
6 changed files with 4954 additions and 39 deletions
40
Commons/Icons.qml
Normal file
40
Commons/Icons.qml
Normal file
|
|
@ -0,0 +1,40 @@
|
||||||
|
pragma Singleton
|
||||||
|
|
||||||
|
import QtQuick
|
||||||
|
import QtQuick.Controls
|
||||||
|
import Quickshell
|
||||||
|
import qs.Commons
|
||||||
|
import qs.Commons.IconsSets
|
||||||
|
|
||||||
|
Singleton {
|
||||||
|
id: root
|
||||||
|
|
||||||
|
// Expose the font family name for easy access
|
||||||
|
readonly property string fontFamily: fontLoader.name
|
||||||
|
readonly property string defaultIcon: Bootstrap.defaultIcon
|
||||||
|
|
||||||
|
Component.onCompleted: {
|
||||||
|
Logger.log("Icons", "Service started")
|
||||||
|
}
|
||||||
|
|
||||||
|
function get(iconName) {
|
||||||
|
return Bootstrap.icons[iconName]
|
||||||
|
}
|
||||||
|
|
||||||
|
FontLoader {
|
||||||
|
id: fontLoader
|
||||||
|
source: Quickshell.shellDir + "/Assets/Fonts/bootstrap/bootstrap-icons.woff2"
|
||||||
|
}
|
||||||
|
|
||||||
|
// Monitor font loading status
|
||||||
|
Connections {
|
||||||
|
target: fontLoader
|
||||||
|
function onStatusChanged() {
|
||||||
|
if (fontLoader.status === FontLoader.Ready) {
|
||||||
|
Logger.log("Bootstrap", "Font loaded successfully:", fontFamily)
|
||||||
|
} else if (fontLoader.status === FontLoader.Error) {
|
||||||
|
Logger.error("Bootstrap", "Font failed to load")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,44 +1,15 @@
|
||||||
pragma Singleton
|
pragma Singleton
|
||||||
|
|
||||||
import QtQuick
|
import QtQuick
|
||||||
import QtQuick.Controls
|
|
||||||
import Quickshell
|
import Quickshell
|
||||||
import qs.Commons
|
|
||||||
|
|
||||||
Singleton {
|
Singleton {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
// FontLoader for Bootstrap Icons
|
readonly property string defaultIcon: "balloon"
|
||||||
FontLoader {
|
|
||||||
id: bootstrapIconsFont
|
|
||||||
source: Quickshell.shellDir + "/Assets/Bootstrap/bootstrap-icons.woff2"
|
|
||||||
}
|
|
||||||
|
|
||||||
// Expose the font family name for easy access
|
readonly property var aliases: {
|
||||||
readonly property string fontFamily: bootstrapIconsFont.name
|
"close": "x-lg"
|
||||||
|
|
||||||
// Check if font is loaded
|
|
||||||
readonly property bool fontLoaded: bootstrapIconsFont.status === FontLoader.Ready
|
|
||||||
|
|
||||||
Component.onCompleted: {
|
|
||||||
Logger.log("Bootstrap", "Service started")
|
|
||||||
if (fontLoaded) {
|
|
||||||
Logger.log("Bootstrap", "Font loaded successfully:", fontFamily)
|
|
||||||
} else {
|
|
||||||
Logger.warn("Bootstrap", "Font failed to load")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Monitor font loading status
|
|
||||||
Connections {
|
|
||||||
target: bootstrapIconsFont
|
|
||||||
function onStatusChanged() {
|
|
||||||
if (bootstrapIconsFont.status === FontLoader.Ready) {
|
|
||||||
Logger.log("Bootstrap", "Font loaded successfully:", fontFamily)
|
|
||||||
} else if (bootstrapIconsFont.status === FontLoader.Error) {
|
|
||||||
Logger.error("Bootstrap", "Font failed to load")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
readonly property var icons: {
|
readonly property var icons: {
|
||||||
4904
Commons/IconsSets/Tabler.qml
Normal file
4904
Commons/IconsSets/Tabler.qml
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -4,22 +4,22 @@ import qs.Commons
|
||||||
import qs.Widgets
|
import qs.Widgets
|
||||||
|
|
||||||
Text {
|
Text {
|
||||||
readonly property string defaultIcon: "balloon"
|
property string icon: Icons.defaultIcon
|
||||||
property string icon: defaultIcon
|
property string family: Icons.fontFamily
|
||||||
|
|
||||||
visible: (icon !== undefined) && (icon !== "")
|
visible: (icon !== undefined) && (icon !== "")
|
||||||
text: {
|
text: {
|
||||||
if ((icon === undefined) || (icon === "")) {
|
if ((icon === undefined) || (icon === "")) {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
if (Bootstrap.icons[icon] === undefined) {
|
if (Icons.get(icon) === undefined) {
|
||||||
Logger.warn("Icon", `"${icon}"`, "doesn't exist in the bootstrap font")
|
Logger.warn("Icon", `"${icon}"`, "doesn't exist in the icons font")
|
||||||
Logger.callStack()
|
Logger.callStack()
|
||||||
return Bootstrap.icons[defaultIcon]
|
return Icons.get(defaultIcon)
|
||||||
}
|
}
|
||||||
return Bootstrap.icons[icon]
|
return Icons.get(icon)
|
||||||
}
|
}
|
||||||
font.family: Bootstrap.fontFamily
|
font.family: family
|
||||||
font.pointSize: Style.fontSizeL * scaling
|
font.pointSize: Style.fontSizeL * scaling
|
||||||
color: Color.mOnSurface
|
color: Color.mOnSurface
|
||||||
verticalAlignment: Text.AlignVCenter
|
verticalAlignment: Text.AlignVCenter
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue