-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[foilnotes] Made font sizes configurable
- Loading branch information
Showing
16 changed files
with
406 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
.pragma library | ||
.import Sailfish.Silica 1.0 as Silica | ||
|
||
var _fontPixesSizes = { | ||
"tiny": Silica.Theme.fontSizeTiny, | ||
"extraSmall": Silica.Theme.fontSizeExtraSmall, | ||
"small": Silica.Theme.fontSizeSmall, | ||
"medium": Silica.Theme.fontSizeMedium, | ||
"large": Silica.Theme.fontSizeLarge, | ||
"extraLarge": Silica.Theme.fontSizeExtraLarge, | ||
"huge": Silica.Theme.fontSizeHuge | ||
} | ||
|
||
function fontPixelSize(config, defaultSize) { | ||
var size = _fontPixesSizes[config] | ||
return !!size ? size : defaultSize | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
import QtQuick 2.0 | ||
import Sailfish.Silica 1.0 | ||
import org.nemomobile.configuration 1.0 | ||
|
||
Item { | ||
property alias label: slider.label | ||
property alias configKey: config.key | ||
property alias defaultValue: config.defaultValue | ||
|
||
height: slider.height | ||
width: parent.width | ||
|
||
readonly property var _fontSizeConfigValues: [ | ||
"tiny", | ||
"extraSmall", | ||
"small", | ||
"medium", | ||
"large", | ||
"extraLarge", | ||
"huge" | ||
] | ||
|
||
readonly property var _fontPixesSizes: [ | ||
Theme.fontSizeTiny, | ||
Theme.fontSizeExtraSmall, | ||
Theme.fontSizeSmall, | ||
Theme.fontSizeMedium, | ||
Theme.fontSizeLarge, | ||
Theme.fontSizeExtraLarge, | ||
Theme.fontSizeHuge | ||
] | ||
|
||
readonly property int _defaultIndex: _fontSizeConfigValues.indexOf(defaultValue) | ||
|
||
Slider { | ||
id: slider | ||
|
||
readonly property real _sliderBarVerticalCenter: Math.round(height - Theme.fontSizeSmall - Theme.paddingSmall - Theme.itemSizeExtraSmall*3/8) | ||
readonly property color _highlightColor: highlighted ? Theme.secondaryHighlightColor : Theme.secondaryColor | ||
|
||
function fontSizeIndex(value) { | ||
var i = _fontSizeConfigValues.indexOf(value) | ||
return i >= 0 ? i : _defaultIndex | ||
} | ||
|
||
rightMargin: Theme.paddingLarge | ||
anchors { | ||
left: parent.left | ||
right: sample.left | ||
} | ||
stepSize: 1 | ||
minimumValue: 0 | ||
maximumValue: _fontSizeConfigValues.length - 1 | ||
value: fontSizeIndex(config.value) | ||
valueText: "" | ||
onSliderValueChanged: config.value = _fontSizeConfigValues[sliderValue] | ||
} | ||
|
||
MouseArea { | ||
id: sample | ||
|
||
property bool _highlighted: pressed && containsMouse | ||
readonly property bool _showPress: _highlighted || pressTimer.running | ||
|
||
width: Theme.itemSizeLarge + Theme.horizontalPageMargin | ||
height: slider.height | ||
anchors.right: parent.right | ||
|
||
onPressedChanged: { | ||
if (pressed) { | ||
pressTimer.start() | ||
} | ||
} | ||
|
||
onCanceled: pressTimer.stop() | ||
|
||
onClicked: slider.value = _defaultIndex | ||
|
||
Text { | ||
y: slider._sliderBarVerticalCenter - Math.round(height/2) | ||
anchors { | ||
right: parent.right | ||
rightMargin: Theme.horizontalPageMargin | ||
} | ||
color: parent._showPress ? Theme.highlightColor : Theme.primaryColor | ||
font.pixelSize: _fontPixesSizes[slider.sliderValue] | ||
text: "abc" | ||
} | ||
|
||
Timer { | ||
id: pressTimer | ||
|
||
interval: ('minimumPressHighlightTime' in Theme) ? Theme.minimumPressHighlightTime : 64 | ||
} | ||
} | ||
|
||
ConfigurationValue { | ||
id: config | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.