Skip to content

Instantly share code, notes, and snippets.

@sawaYch
Created January 10, 2020 15:38
Show Gist options
  • Select an option

  • Save sawaYch/5f5f2445ad00b1cff2a377bc9db0c039 to your computer and use it in GitHub Desktop.

Select an option

Save sawaYch/5f5f2445ad00b1cff2a377bc9db0c039 to your computer and use it in GitHub Desktop.
QML svg antialiasing example.
LogoImage {
id: distroLogo
Layout.minimumWidth: (implicitWidth < implicitHeight) ? 100*implicitWidth/implicitHeight : 100
Layout.minimumHeight: (implicitHeight < implicitWidth) ? 100*implicitHeight/implicitWidth : 100
Layout.preferredWidth: (Layout.fillWidth) ? Layout.minimumWidth : height * implicitWidth/implicitHeight
Layout.preferredHeight: (Layout.fillHeight) ? Layout.minimumHeight : width * implicitHeight/implicitWidth
Layout.fillWidth: (implicitWidth < implicitHeight) ? false: true
Layout.fillHeight: !Layout.fillWidth
Layout.alignment: Qt.AlignCenter
image.source: "../" + Code.getStandardLogo(logo, osInfoItem.distroId)
image.sourceSize.width: parent.width // This line is important
image.sourceSize.height: parent.height // This line is important
image.smooth:true // This line is important
image.antialiasing: true // This line is important
fillScale: plasmoid.configuration.logoScale
onFillScaleChanged: if (fillScale !== plasmoid.configuration.logoScale) plasmoid.configuration.logoScale = fillScale
MouseArea {
anchors.fill: parent
acceptedButtons: Qt.RightButton
onClicked: logoPopup.open(mouse.x, mouse.y)
}
PlasmaComponents.ContextMenu {
id: logoPopup
PlasmaComponents.MenuItem {
text: distroLogo.editMode ? i18n("Lock image scaling") : i18n("Unlock image scaling")
onClicked: distroLogo.editMode = !distroLogo.editMode
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment