Skip to content

Commit

Permalink
feat(config): allow differents text displayment
Browse files Browse the repository at this point in the history
  • Loading branch information
orblazer committed May 31, 2021
1 parent 58875e3 commit 3a7e73e
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 25 deletions.
6 changes: 3 additions & 3 deletions package/contents/config/main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@
<entry name="verticalLayout" type="Bool">
<default>false</default>
</entry>
<entry name="enableHints" type="Bool">
<default>true</default>
</entry>
<entry name="enableShadows" type="Bool">
<default>true</default>
</entry>
<entry name="fontScale" type="int">
<default>26</default>
</entry>
<entry name="displayment" type="string">
<default>hover-hints</default>
</entry>
<entry name="placement" type="string">
<default>top-right</default>
</entry>
Expand Down
59 changes: 48 additions & 11 deletions package/contents/ui/components/GraphItem.qml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Item {
property string secondLineValue: ''
property bool enableShadows: plasmoid.configuration.enableShadows
property string placement: plasmoid.configuration.placement // Values: top-right, top-left, bottom-right, bottom-left
property string displayment: plasmoid.configuration.displayment // Values: always, hover, hover-hints

// Graph properties
property var firstGraphModel
Expand Down Expand Up @@ -208,27 +209,63 @@ Item {
source: textContainer
}

// Action

onDisplaymentChanged: {
switch (displayment) {
case 'always':
firstLineInfoLabel.visible = secondLineInfoLabel.visible = false
break

case 'hover':
firstLineInfoLabel.visible = secondLineInfoLabel.visible = false
firstLineValueLabel.visible = secondLineValueLabel.visible = false
break

case 'always':
case 'hover-hints':
firstLineValueLabel.visible = true
secondLineValueLabel.visible = secondLineInfoText != ''
break
}
}

MouseArea {
anchors.fill: parent
hoverEnabled: enableHints
hoverEnabled: displayment !== 'always'

onEntered: {
firstLineInfoLabel.visible = true
firstLineValueLabel.visible = false
switch (displayment) {
case 'hover':
firstLineValueLabel.visible = true
secondLineValueLabel.visible = secondLineInfoText != ''
break
case 'hover-hints':
firstLineInfoLabel.visible = true
firstLineValueLabel.visible = false

if(secondLineInfoText != '') {
secondLineInfoLabel.visible = true
secondLineValueLabel.visible = false
if(secondLineInfoText != '') {
secondLineInfoLabel.visible = true
secondLineValueLabel.visible = false
}
break
}
}

onExited: {
firstLineInfoLabel.visible = false
firstLineValueLabel.visible = true
switch (displayment) {
case 'hover':
firstLineValueLabel.visible = secondLineValueLabel.visible = false
break
case 'hover-hints':
firstLineInfoLabel.visible = false
firstLineValueLabel.visible = true

if(secondLineInfoText != '') {
secondLineInfoLabel.visible = false
secondLineValueLabel.visible = true
if(secondLineInfoText != '') {
secondLineInfoLabel.visible = false
secondLineValueLabel.visible = true
}
break
}
}
}
Expand Down
39 changes: 28 additions & 11 deletions package/contents/ui/config/ConfigAppearance.qml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import "../components"

Kirigami.FormLayout {
property alias cfg_verticalLayout: verticalLayout.checked
property alias cfg_enableHints: enableHints.checked
property alias cfg_enableShadows: enableShadows.checked
property alias cfg_fontScale: fontScale.value
property string cfg_placement: ''
property string cfg_displayment: ''

property alias cfg_customWarningColor: warningColor.checked
property alias cfg_warningColor: warningColor.value
Expand Down Expand Up @@ -43,6 +43,11 @@ Kirigami.FormLayout {
Kirigami.FormData.label: i18n('Text')
}

QtControls.CheckBox {
id: enableShadows
text: i18n('Drop shadows')
}

SpinBox {
id: fontScale
Kirigami.FormData.label: i18n('Font scale:')
Expand All @@ -51,17 +56,29 @@ Kirigami.FormLayout {
suffix: i18nc('Percent', '%')
}

Item {}

QtControls.CheckBox {
id: enableHints
Kirigami.FormData.label: i18n('Info text:')
text: i18n('Enable hints')
}
QtControls.ComboBox {
id: displayment
Kirigami.FormData.label: i18n('Text displayment:')
textRole: 'label'
model: [{
'label': i18n('Always'),
'name': 'always'
}, {
'label': i18n('On hover'),
'name': 'hover'
}, {
'label': i18n('Hints when hover'),
'name': 'hover-hints'
}]
onCurrentIndexChanged: cfg_displayment = model[currentIndex]['name']

QtControls.CheckBox {
id: enableShadows
text: i18n('Drop shadows')
Component.onCompleted: {
for (var i = 0; i < model.length; i++) {
if (model[i]['name'] === plasmoid.configuration.displayment) {
displayment.currentIndex = i;
}
}
}
}

QtControls.ComboBox {
Expand Down

0 comments on commit 3a7e73e

Please sign in to comment.