Commit 5ac5cf99 authored by Nate Graham's avatar Nate Graham
Browse files

Port to singleton Theme

We ported units to use the PlasmaCore.Units singleton earlier; now it's
time to do the same thing for PlasmaCore.Theme.

There are no UI changes or regressions detected.
parent 293b79cc
......@@ -46,7 +46,7 @@ Kicker.DashboardWindow {
property bool smallScreen: ((Math.floor(width / PlasmaCore.Units.iconSizes.huge) <= 22) || (Math.floor(height / PlasmaCore.Units.iconSizes.huge) <= 14))
property int iconSize: smallScreen ? PlasmaCore.Units.iconSizes.large : PlasmaCore.Units.iconSizes.huge
property int cellSize: iconSize + theme.mSize(theme.defaultFont).height
property int cellSize: iconSize + PlasmaCore.Theme.mSize(PlasmaCore.Theme.defaultFont).height
+ (2 * PlasmaCore.Units.smallSpacing)
+ (2 * Math.max(highlightItemSvg.margins.top + highlightItemSvg.margins.bottom,
highlightItemSvg.margins.left + highlightItemSvg.margins.right))
......
......@@ -38,7 +38,7 @@ Item {
Rectangle {
anchors.fill: parent
color: tab.parent.focus ? theme.highlightColor : "black"
color: tab.parent.focus ? PlasmaCore.Theme.highlightColor : "black"
opacity: tab.active ? 0.4 : 0.15
Behavior on opacity { SmoothedAnimation { duration: PlasmaCore.Units.shortDuration; velocity: 0.01 } }
......@@ -54,7 +54,7 @@ Item {
opacity: tab.active ? 1.0 : 0.6
Behavior on opacity { SmoothedAnimation { duration: PlasmaCore.Units.shortDuration; velocity: 0.01 } }
color: tab.parent.focus ? theme.highlightedTextColor : "white"
color: tab.parent.focus ? PlasmaCore.Theme.highlightedTextColor : "white"
level: 1
}
......
......@@ -274,7 +274,7 @@ Item {
}
updateSvgMetrics();
theme.themeChanged.connect(updateSvgMetrics);
PlasmaCore.Theme.themeChanged.connect(updateSvgMetrics);
rootModel.refreshed.connect(reset);
......
......@@ -169,7 +169,7 @@ FocusScope {
property int iconSize: PlasmaCore.Units.iconSizes.large
property bool animating: false
cellWidth: gridView.iconSize + theme.mSize(theme.defaultFont).height
cellWidth: gridView.iconSize + PlasmaCore.Theme.mSize(PlasmaCore.Theme.defaultFont).height
+ (4 * PlasmaCore.Units.smallSpacing + Math.round(PlasmaCore.Units.smallSpacing * 1.5)) //item margins + spacing
+ (2 * gridView.cellMargin) //highlight padding
+ cellMargin * 2 //actual margins
......
......@@ -158,7 +158,7 @@ Item {
text: isManagerMode ? "" : model.description || ""
opacity: isCurrent ? 0.8 : 0.6
font: theme.smallestFont
font: PlasmaCore.Theme.smallestFont
elide: Text.ElideMiddle
horizontalAlignment: Text.AlignRight
}
......
......@@ -88,7 +88,7 @@ Kirigami.FormLayout {
id: fontDialog
title: i18nc("@title:window", "Select Font")
font: !cfg_font || cfg_font.family === "" ? theme.defaultFont : cfg_font
font: !cfg_font || cfg_font.family === "" ? PlasmaCore.Theme.defaultFont : cfg_font
onAccepted: {
cfg_font = font
......
......@@ -33,8 +33,8 @@ PlasmaCore.Dialog {
readonly property bool verticalLayout: (helper.lookupTableLayout === 1) || (helper.lookupTableLayout === 0 && plasmoid.configuration.vertical_lookup_table);
property int highlightCandidate: helper.lookupTableCursor
property int hoveredCandidate: -1
property font preferredFont: plasmoid.configuration.use_default_font ? theme.defaultFont : plasmoid.configuration.font
property int baseSize: theme.mSize(preferredFont).height
property font preferredFont: plasmoid.configuration.use_default_font ? PlasmaCore.Theme.defaultFont : plasmoid.configuration.font
property int baseSize: PlasmaCore.Theme.mSize(preferredFont).height
property rect position: helper.spotRect
onPositionChanged : updatePosition();
......@@ -71,7 +71,7 @@ PlasmaCore.Dialog {
font: preferredFont
}
Rectangle {
color: theme.textColor
color: PlasmaCore.Theme.textColor
height: baseSize
width: 2
opacity: 0.8
......@@ -122,13 +122,13 @@ PlasmaCore.Dialog {
text: model.label
font: preferredFont
opacity: 0.8
color: selected ? theme.highlightedTextColor : theme.textColor
color: selected ? PlasmaCore.Theme.highlightedTextColor : PlasmaCore.Theme.textColor
}
PlasmaComponents.Label {
id: textLabel
text: model.text
font: preferredFont
color: selected ? theme.highlightedTextColor : theme.textColor
color: selected ? PlasmaCore.Theme.highlightedTextColor : PlasmaCore.Theme.textColor
}
}
MouseArea {
......
......@@ -66,12 +66,12 @@ MouseArea {
return Qt.rgba(color.r, color.g, color.b, alpha)
}
readonly property color windowActiveOnActiveDesktopColor: colorWithAlpha(theme.textColor, 0.6)
readonly property color windowInactiveOnActiveDesktopColor: colorWithAlpha(theme.textColor, 0.35)
readonly property color windowActiveOnActiveDesktopColor: colorWithAlpha(PlasmaCore.Theme.textColor, 0.6)
readonly property color windowInactiveOnActiveDesktopColor: colorWithAlpha(PlasmaCore.Theme.textColor, 0.35)
readonly property color windowActiveColor: colorWithAlpha(theme.textColor, 0.5)
readonly property color windowActiveBorderColor: theme.textColor
readonly property color windowInactiveColor: colorWithAlpha(theme.textColor, 0.17)
readonly property color windowInactiveBorderColor: colorWithAlpha(theme.textColor, 0.5)
readonly property color windowActiveBorderColor: PlasmaCore.Theme.textColor
readonly property color windowInactiveColor: colorWithAlpha(PlasmaCore.Theme.textColor, 0.17)
readonly property color windowInactiveBorderColor: colorWithAlpha(PlasmaCore.Theme.textColor, 0.5)
function action_addDesktop() {
pagerModel.addDesktop();
......@@ -187,7 +187,7 @@ MouseArea {
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
font.pixelSize: Math.min(height, theme.defaultFont.pixelSize)
font.pixelSize: Math.min(height, PlasmaCore.Theme.defaultFont.pixelSize)
// unset pointSize set by PlasmaComponents.Label to avoid "Both point size and pixel size set." warning
font.pointSize: -1
......
......@@ -30,7 +30,7 @@ Rectangle {
property int number: 0
implicitWidth: Math.max(height, Math.round(label.contentWidth + radius / 2)) // Add some padding around.
color: theme.highlightColor
color: PlasmaCore.Theme.highlightColor
radius: height / 2
PlasmaComponents.Label {
......@@ -43,7 +43,7 @@ Rectangle {
fontSizeMode: Text.VerticalFit
font.pointSize: 1024
minimumPointSize: 5
color: theme.highlightedTextColor
color: PlasmaCore.Theme.highlightedTextColor
text: {
if (badgeRect.number < 0) {
return i18nc("Invalid number of new messages, overlay, keep short", "");
......
......@@ -70,7 +70,7 @@ PlasmaComponents3.ScrollView {
LayoutMirroring.enabled: Qt.application.layoutDirection === Qt.RightToLeft
LayoutMirroring.childrenInherit: true
property int textWidth: theme.mSize(theme.defaultFont).width * 20
property int textWidth: PlasmaCore.Theme.mSize(PlasmaCore.Theme.defaultFont).width * 20
Component.onCompleted: {
flickableItem.interactive = Qt.binding(function() {
......
......@@ -296,7 +296,7 @@ ColumnLayout {
lineHeight: 1
elide: parent.state ? Text.ElideNone : Text.ElideRight
text: artist || ""
font: theme.smallestFont
font: PlasmaCore.Theme.smallestFont
}
}
}
......
......@@ -17,6 +17,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
***************************************************************************/
.import org.kde.plasma.core 2.0 as PlasmaCore
var iconSizes = ["small", "smallMedium", "medium", "large", "huge", "enormous"];
function horizontalMargins() {
......@@ -111,7 +113,9 @@ function preferredMinWidth() {
var width = launcherWidth();
if (!tasks.vertical && !tasks.iconsOnly) {
width += (PlasmaCore.Units.smallSpacing * 2) + (theme.mSize(theme.defaultFont).width * 12);
width +=
(PlasmaCore.Units.smallSpacing * 2) +
(PlasmaCore.Theme.mSize(PlasmaCore.Theme.defaultFont).width * 12);
}
return width;
......@@ -135,30 +139,38 @@ function preferredMaxWidth() {
function preferredMinHeight() {
// TODO FIXME UPSTREAM: Port to proper font metrics for descenders once we have access to them.
return theme.mSize(theme.defaultFont).height + 4;
return PlasmaCore.Theme.mSize(PlasmaCore.Theme.defaultFont).height + 4;
}
function preferredMaxHeight() {
if (tasks.vertical) {
return verticalMargins()
+ Math.min(
// Do not allow the preferred icon size to exceed the width of the vertical task manager.
tasks.width,
Math.max(
// This assumes that we show some text and that we need some minimal vertical space for it.
// In reality, we do not always show the text. We show the text only if there
// is enough horizontal space for some hard coded amount of 'm' characters
// - see minimumMColumns() below.
// Hence in case the user prefers icons smaller than the height of his font,
// the font height will win even if the text will stay invisible.
// We leave it for the future developers to improve this expresssion if the
// named corner case turns out to be important.
PlasmaCore.Units.iconSizes[iconSizes[plasmoid.configuration.iconSize]],
theme.mSize(theme.defaultFont).height
)
);
return verticalMargins() +
Math.min(
// Do not allow the preferred icon size to exceed the width of
// the vertical task manager.
tasks.width,
Math.max(
// This assumes that we show some text and that we need
// some minimal vertical space for it. In reality, we do
// not always show the text. We show the text only if there
// is enough horizontal space for some hard coded amount of
// 'm' characters
// - see minimumMColumns() below.
// Hence in case the user prefers icons smaller than the
// height of his font, the font height will win even if the
// text will stay invisible. We leave it for the future
// developers to improve this expresssion if the named
// corner case turns out to be important.
PlasmaCore.Units
.iconSizes[iconSizes[plasmoid.configuration.iconSize]],
PlasmaCore.Theme.mSize(PlasmaCore.Theme.defaultFont)
.height));
} else {
return verticalMargins() + Math.min(PlasmaCore.Units.iconSizes.small * 3, theme.mSize(theme.defaultFont).height * 3);
return verticalMargins() +
Math.min(
PlasmaCore.Units.iconSizes.small * 3,
PlasmaCore.Theme.mSize(PlasmaCore.Theme.defaultFont).height *
3);
}
}
......@@ -200,7 +212,7 @@ function launcherWidth() {
}
function maximumContextMenuTextWidth() {
return (theme.mSize(theme.defaultFont).width * 28);
return (PlasmaCore.Theme.mSize(PlasmaCore.Theme.defaultFont).width * 28);
}
function layout(container) {
......
......@@ -79,7 +79,7 @@ PlasmaComponents.ToolButton {
wrapMode: Text.WordWrap
elide: Text.ElideRight
// The handle uses always the main global theme
color: theme.textColor
color: PlasmaCore.Theme.textColor
visible: text.length > 0
}
}
......
......@@ -30,7 +30,7 @@ DragDrop.DropArea {
|| plasmoid.location === PlasmaCore.Types.LeftEdge)
Layout.minimumWidth: plasmoid.formFactor === PlasmaCore.Types.Horizontal ? height : PlasmaCore.Units.iconSizes.small
Layout.minimumHeight: plasmoid.formFactor === PlasmaCore.Types.Vertical ? width : (PlasmaCore.Units.iconSizes.small + 2 * theme.mSize(theme.defaultFont).height)
Layout.minimumHeight: plasmoid.formFactor === PlasmaCore.Types.Vertical ? width : (PlasmaCore.Units.iconSizes.small + 2 * PlasmaCore.Theme.mSize(PlasmaCore.Theme.defaultFont).height)
Layout.maximumWidth: inPanel && plasmoid.formFactor !== PlasmaCore.Types.Vertical ? PlasmaCore.Units.iconSizeHints.panel : -1
Layout.maximumHeight: inPanel && plasmoid.formFactor !== PlasmaCore.Types.Vertical ? PlasmaCore.Units.iconSizeHints.panel : -1
......
......@@ -248,7 +248,7 @@ Item {
return (PlasmaCore.Units.smallSpacing // icon.anchors.topMargin (acts as top padding)
+ icon.height
+ PlasmaCore.Units.smallSpacing // label.anchors.topMargin (acts as spacing between icon and label)
+ (label.lineCount * theme.mSize(theme.defaultFont).height)
+ (label.lineCount * PlasmaCore.Theme.mSize(PlasmaCore.Theme.defaultFont).height)
+ PlasmaCore.Units.smallSpacing); // leftover (acts as bottom padding)
}
......
......@@ -702,11 +702,11 @@ FocusScope {
cellHeight: {
if (root.useListViewMode) {
return Math.ceil((Math.max(theme.mSize(theme.defaultFont).height, iconSize)
return Math.ceil((Math.max(PlasmaCore.Theme.mSize(PlasmaCore.Theme.defaultFont).height, iconSize)
+ Math.max(highlightItemSvg.margins.top + highlightItemSvg.margins.bottom,
listItemSvg.margins.top + listItemSvg.margins.bottom)) / 2) * 2;
} else {
var iconHeight = iconSize + (theme.mSize(theme.defaultFont).height * plasmoid.configuration.textLines) + (4 * PlasmaCore.Units.smallSpacing);
var iconHeight = iconSize + (PlasmaCore.Theme.mSize(PlasmaCore.Theme.defaultFont).height * plasmoid.configuration.textLines) + (4 * PlasmaCore.Units.smallSpacing);
if (root.isContainment && isRootView && scrollArea.viewportHeight > 0) {
var extraHeight = calcExtraSpacing(iconHeight, scrollArea.viewportHeight);
return iconHeight + extraHeight;
......@@ -1427,7 +1427,7 @@ FocusScope {
_height = targetItem.labelArea.height + __style.padding.top + __style.padding.bottom;
} else {
var realHeight = contentHeight + __style.padding.top + __style.padding.bottom;
var maxHeight = theme.mSize(theme.defaultFont).height * (plasmoid.configuration.textLines + 1) + __style.padding.top + __style.padding.bottom;
var maxHeight = PlasmaCore.Theme.mSize(PlasmaCore.Theme.defaultFont).height * (plasmoid.configuration.textLines + 1) + __style.padding.top + __style.padding.bottom;
_height = Math.min(realHeight, maxHeight);
}
return(_height + (addWidthHoriozontalScroller ? __horizontalScrollBar.parent.horizontalScrollbarOffset : 0));
......
......@@ -35,7 +35,7 @@ FocusScope {
property Item view: folderView
property Item label: null
property int labelHeight: theme.mSize(theme.defaultFont).height
property int labelHeight: PlasmaCore.Theme.mSize(PlasmaCore.Theme.defaultFont).height
+ (root.isPopup ? (PlasmaCore.Units.smallSpacing * 2) : 0)
property alias model: folderView.model
......
......@@ -267,7 +267,7 @@ MouseArea {
Rectangle {
id: handle
visible: configurationArea.containsMouse
color: theme.backgroundColor
color: PlasmaCore.Theme.backgroundColor
radius: 3
opacity: currentApplet ? 0.5 : 0
PlasmaCore.IconItem {
......@@ -287,7 +287,7 @@ MouseArea {
opacity: visible && !xAnim.running && !yAnim.running ? 1.0 : 0
width: configurationArea.spacerHandleSize
height: configurationArea.spacerHandleSize
color: theme.textColor
color: PlasmaCore.Theme.textColor
Behavior on opacity {
NumberAnimation {
duration: PlasmaCore.Units.longDuration
......@@ -306,7 +306,7 @@ MouseArea {
opacity: visible && !xAnim.running && !yAnim.running ? 1.0 : 0
width: configurationArea.spacerHandleSize
height: configurationArea.spacerHandleSize
color: theme.textColor
color: PlasmaCore.Theme.textColor
Behavior on opacity {
NumberAnimation {
duration: PlasmaCore.Units.longDuration
......
......@@ -475,8 +475,8 @@ function checkLastSpacer() {
id: dndSpacer
Layout.preferredWidth: width
Layout.preferredHeight: height
width: (plasmoid.formFactor === PlasmaCore.Types.Vertical) ? currentLayout.width : theme.mSize(theme.defaultFont).width * 10
height: (plasmoid.formFactor === PlasmaCore.Types.Vertical) ? theme.mSize(theme.defaultFont).width * 10 : currentLayout.height
width: (plasmoid.formFactor === PlasmaCore.Types.Vertical) ? currentLayout.width : PlasmaCore.Theme.mSize(PlasmaCore.Theme.defaultFont).width * 10
height: (plasmoid.formFactor === PlasmaCore.Types.Vertical) ? PlasmaCore.Theme.mSize(PlasmaCore.Theme.defaultFont).width * 10 : currentLayout.height
}
// while the user is moving the applet when configuring the panel, the applet is reparented
......
......@@ -121,7 +121,7 @@ Item {
visible: root.current
border.width: root.current ? PlasmaCore.Units.smallSpacing : 0
border.color: theme.highlightColor
border.color: PlasmaCore.Theme.highlightColor
z: 10
......@@ -246,7 +246,7 @@ Item {
}
opacity: .75
color: theme.backgroundColor
color: PlasmaCore.Theme.backgroundColor
}
TaskDropArea {
......@@ -345,7 +345,7 @@ Item {
}
opacity: .75
color: theme.backgroundColor
color: PlasmaCore.Theme.backgroundColor
}
PlasmaComponents.Button {
......
Supports Markdown
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