Commit 90b45706 authored by Arjen Hiemstra's avatar Arjen Hiemstra

Use "raised" style for non-flat toolbuttons

Rather than switching to "button" elementType. This makes tool buttons
behave the same way regardless of whether they are flat or not. Most
importantly, this means that non-flat tool buttons now respect the
"display" property.

Also includes a small test file to compare the two.
parent 1525c205
......@@ -38,12 +38,13 @@ T.ToolButton {
id: styleitem
anchors.fill:parent
control: controlRoot
elementType: controlRoot.flat ? "toolbutton" : "button"
elementType: "toolbutton"
on: controlRoot.pressed || (controlRoot.checkable && controlRoot.checked)
hover: controlRoot.hovered
text: controlRoot.Kirigami.MnemonicData.mnemonicLabel
hasFocus: false
activeControl: controlRoot.isDefault ? "default" : "f"
raised: !controlRoot.flat
properties: {
"icon": controlRoot.icon ? (controlRoot.icon.name || controlRoot.icon.source) : "",
"iconColor": controlRoot.icon && controlRoot.icon.color.a > 0? controlRoot.icon.color : Kirigami.Theme.textColor,
......
......@@ -295,7 +295,11 @@ void KQuickStyleItem::initStyleOption()
QStyleOptionToolButton *opt =
qstyleoption_cast<QStyleOptionToolButton*>(m_styleoption);
opt->subControls = QStyle::SC_ToolButton;
opt->state |= QStyle::State_AutoRaise;
if (!m_raised || m_on) {
opt->state |= QStyle::State_AutoRaise;
}
opt->activeSubControls = QStyle::SC_ToolButton;
opt->text = text();
const QVariant icon = m_properties[QStringLiteral("icon")];
......
import QtQuick 2.3
import QtQuick.Layouts 1.3
import QtQuick.Controls 2.3
ApplicationWindow
{
visible: true
width: 800
height: 600
GridLayout {
anchors.fill: parent
anchors.margins: 10
rows: 6
flow: GridLayout.TopToBottom
Label {
text: "Flat"
}
ToolButton {
icon.name: "documentinfo"
text: "Tool Button Default"
flat: true
}
ToolButton {
icon.name: "documentinfo"
text: "Tool Button Icon Only"
display: ToolButton.IconOnly
flat: true
}
ToolButton {
icon.name: "documentinfo"
text: "Tool Button Text Only"
display: ToolButton.TextOnly
flat: true
}
ToolButton {
icon.name: "documentinfo"
text: "Tool Button Text Beside Icon"
display: ToolButton.TextBesideIcon
flat: true
}
ToolButton {
icon.name: "documentinfo"
text: "Tool Button Text Below Icon"
display: ToolButton.TextUnderIcon
flat: true
}
Label {
text: "Non-Flat"
}
ToolButton {
icon.name: "documentinfo"
text: "Tool Button Default"
flat: false
}
ToolButton {
icon.name: "documentinfo"
text: "Tool Button Icon Only"
display: ToolButton.IconOnly
flat: false
}
ToolButton {
icon.name: "documentinfo"
text: "Tool Button Text Only"
display: ToolButton.TextOnly
flat: false
}
ToolButton {
icon.name: "documentinfo"
text: "Tool Button Text Beside Icon"
display: ToolButton.TextBesideIcon
flat: false
}
ToolButton {
icon.name: "documentinfo"
text: "Tool Button Text Below Icon"
display: ToolButton.TextUnderIcon
flat: false
}
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment