This forum has been archived. All content is frozen. Please use KDE Discuss instead.

QML plasma button and dynamic content

Tags: None
(comma "," separated)
mous16
Registered Member
Posts
12
Karma
0
OS
I'm writing a plasmoid to menage Caps Lock and Num Lock.
I would like to add some checkable buttons, with no text inside, and a my personal Item as icon. I'm developing on KDE-4.8.3

My first issue was with the Button apparence when checked: I could hardly understand visually if a button was checked or not. I worked around it by using a ToolButton, that looks as I supposed. Any contraindications?

Next the real problem; my approach to have my Item inside the button is to declare it as child of ToolButton. I would like fill the ToolButton but without overlaping the borders. Here an example:
Code: Select all
//////////////////
//  MyItem.qml  //
//////////////////
import QtQuick 1.1

Item {
  Rectangle {
    anchors.fill: parent
    color: "red"
  }
}
//////////////////

//////////////////
//  plasmo.qml  //
//////////////////
import QtQuick 1.1
import org.kde.plasma.components 0.1 as PlasmaComponents

Item {
    Grid {
      anchors.fill: parent
      rows: 1
      columns:3
      spacing:5
     
      // This make MyItem cover ToolButton borders
      PlasmaComponents.ToolButton {
        width:48
        height: 48
        checkable: true
        flat: false
        MyItem {
          anchors.fill: parent
        }
      }
         
      // This is ok, if I could determine ToolButton borders width and height.
      // I couldn't access ToolButton.surface so doesn't work
      PlasmaComponents.ToolButton {
        width:48
        height: 48
        checkable: true
        flat: false
//      property alias ownLeftBorder: surface.margins.left
//      property alias ownRightBorder: surface.margins.right
//      property alias ownTopBorder: surface.margins.top
//      property alias ownBottomBorder: surface.margins.bottom
        MyItem {
          anchors.fill: parent
//        anchors.leftMargin: parent.ownLeftBorder
//        anchors.rightMargin: parent.ownRightBorder
//        anchors.topMargin: parent.ownTopBorder
//        anchors.bottomMargin: parent.ownBottomBorder
        }
      }
     
      // This work but hardcoded value, so I don't like it
      PlasmaComponents.ToolButton {
        width:48
        height: 48
        checkable: true
        flat: false
        MyItem {
          anchors.fill: parent
          anchors.margins: 5
        }
      }
     
    }
}
//////////////////

What I have to do to make MyItem fit thr button?
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
I would recommend asking this on plasma-devel@kde.org, a mailing list which should have people on it who can help you with this Plasma/QML problem.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]


Bookmarks



Who is online

Registered users: bartoloni, Bing [Bot], Evergrowing, Google [Bot], ourcraft