Skip to content

Commit

Permalink
fix(example/image): update logo.svg size (#22)
Browse files Browse the repository at this point in the history
* feat(example): add window icon and set graphics api to vulkan

* fix(example/image): update logo.svg

* feat(src): added LingmoFilledIconButton and example
  • Loading branch information
elysia-best authored Jan 23, 2025
1 parent b42d1d6 commit f2464e6
Show file tree
Hide file tree
Showing 4 changed files with 164 additions and 27 deletions.
54 changes: 28 additions & 26 deletions example/image/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion example/qml/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ LingmoObject {
id: root
Component.onCompleted: {
LingmoApp.init(root, Qt.locale("zh_CN"));
LingmoApp.windowIcon = "qrc:/image/logo.ico"
LingmoApp.windowIcon = "qrc:/image/logo.svg"
LingmoTheme.animationEnabled = true;
LingmoTheme.blurBehindWindowEnabled = true;
LingmoTheme.darkMode = LingmoThemeType.Dark;
Expand Down
10 changes: 10 additions & 0 deletions example/qml/windows/MainPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -91,5 +91,15 @@ LingmoWindow {
Layout.alignment: Qt.AlignHCenter
text: "I'm an Button"
}

LingmoFilledIconButton {
id: iconBtn
Layout.alignment: Qt.AlignHCenter
iconSource: LingmoIcons.AddBold
iconSize: 32
implicitWidth: 64
implicitHeight: 64
radius: iconBtn.implicitWidth / 2
}
}
}
125 changes: 125 additions & 0 deletions src/Controls/LingmoFilledIconButton.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import QtQuick.Controls.Basic
import LingmoUI

LingmoFilledButton {
id: control
display: Button.IconOnly
property int iconSize: 20
property int iconSource
property bool disabled: false
property int radius: LingmoUnits.smallRadiuss
property string contentDescription: ""
property Component iconDelegate: com_icon

property color iconColor: {
if (!enabled) {
return Qt.rgba(130 / 255, 130 / 255, 130 / 255, 1);
}
return Qt.rgba(1, 1, 1, 1);
}

Accessible.role: Accessible.Button
Accessible.name: control.text
Accessible.description: contentDescription
Accessible.onPressAction: control.clicked()
focusPolicy: Qt.TabFocus
padding: 0
verticalPadding: 8
horizontalPadding: 8
enabled: !disabled
font: LingmoTextStyle.Caption

background: LingmoControlBackground {
implicitWidth: 30
implicitHeight: 30
radius: control.radius
bottomMargin: enabled ? 2 : 0
border.width: enabled ? 1 : 0
border.color: enabled ? Qt.darker(control.normalColor, 1.2) : disableColor
color: {
if (!enabled) {
return disableColor;
}
if (pressed) {
return pressedColor;
}
return hovered ? hoverColor : normalColor;
}
LingmoFocusRectangle {
visible: control.visualFocus
radius: 4
}
}

Component {
id: com_icon
LingmoIcon {
id: text_icon
font.pixelSize: iconSize
iconSize: control.iconSize
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
iconColor: control.iconColor
iconSource: control.iconSource
}
}
Component {
id: com_row
RowLayout {
LingmoLoader {
sourceComponent: iconDelegate
Layout.alignment: Qt.AlignVCenter | Qt.AlignHCenter
visible: display !== Button.TextOnly
}
LingmoText {
text: control.text
Layout.alignment: Qt.AlignVCenter | Qt.AlignHCenter
visible: display !== Button.IconOnly
color: control.textColor
font: control.font
}
}
}
Component {
id: com_column
ColumnLayout {
LingmoLoader {
sourceComponent: iconDelegate
Layout.alignment: Qt.AlignVCenter | Qt.AlignHCenter
visible: display !== Button.TextOnly
}
LingmoText {
text: control.text
Layout.alignment: Qt.AlignVCenter | Qt.AlignHCenter
visible: display !== Button.IconOnly
color: control.textColor
font: control.font
}
}
}
contentItem: LingmoLoader {
sourceComponent: {
if (display === Button.TextUnderIcon) {
return com_column;
}
return com_row;
}
}
LingmoTooltip {
id: tool_tip
visible: {
if (control.text === "") {
return false;
}
if (control.display !== Button.IconOnly) {
return false;
}
return hovered;
}
text: control.text
delay: 1000
}
}

0 comments on commit f2464e6

Please sign in to comment.