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
|
||||
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
import Quickshell
|
||||
import qs.Commons
|
||||
|
||||
Singleton {
|
||||
id: root
|
||||
|
||||
// FontLoader for Bootstrap Icons
|
||||
FontLoader {
|
||||
id: bootstrapIconsFont
|
||||
source: Quickshell.shellDir + "/Assets/Bootstrap/bootstrap-icons.woff2"
|
||||
}
|
||||
readonly property string defaultIcon: "balloon"
|
||||
|
||||
// Expose the font family name for easy access
|
||||
readonly property string fontFamily: bootstrapIconsFont.name
|
||||
|
||||
// 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 aliases: {
|
||||
"close": "x-lg"
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
Text {
|
||||
readonly property string defaultIcon: "balloon"
|
||||
property string icon: defaultIcon
|
||||
property string icon: Icons.defaultIcon
|
||||
property string family: Icons.fontFamily
|
||||
|
||||
visible: (icon !== undefined) && (icon !== "")
|
||||
text: {
|
||||
if ((icon === undefined) || (icon === "")) {
|
||||
return ""
|
||||
}
|
||||
if (Bootstrap.icons[icon] === undefined) {
|
||||
Logger.warn("Icon", `"${icon}"`, "doesn't exist in the bootstrap font")
|
||||
if (Icons.get(icon) === undefined) {
|
||||
Logger.warn("Icon", `"${icon}"`, "doesn't exist in the icons font")
|
||||
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
|
||||
color: Color.mOnSurface
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue