Skip to content

Commit

Permalink
feat(config): add font scale option
Browse files Browse the repository at this point in the history
  • Loading branch information
orblazer committed May 23, 2021
1 parent 5a253c5 commit 5238bc2
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 15 deletions.
9 changes: 7 additions & 2 deletions package/contents/config/main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<entry name="updateInterval" type="Double">
<default>1.0</default>
</entry>

<entry name="showCpuMonitor" type="Bool">
<default>true</default>
</entry>
Expand All @@ -21,6 +22,7 @@
<entry name="showClock" type="Bool">
<default>true</default>
</entry>

<entry name="verticalLayout" type="Bool">
<default>false</default>
</entry>
Expand All @@ -30,6 +32,9 @@
<entry name="enableShadows" type="Bool">
<default>true</default>
</entry>
<entry name="fontScale" type="int">
<default>26</default>
</entry>
</group>
</kcfg>

</kcfg>
41 changes: 29 additions & 12 deletions package/contents/ui/config/ConfigGeneral.qml
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,23 @@ import QtQuick.Controls 1.3
import QtQuick.Layouts 1.1

Item {

property alias cfg_updateInterval: updateIntervalSpinBox.value

property alias cfg_showCpuMonitor: showCpuMonitor.checked
property alias cfg_showClock: showClock.checked
property alias cfg_showRamMonitor: showRamMonitor.checked
property alias cfg_memoryInPercent: memoryInPercent.checked

property alias cfg_verticalLayout: verticalLayout.checked
property alias cfg_enableHints: enableHints.checked
property alias cfg_enableShadows: enableShadows.checked
property alias cfg_fontScale: fontScale.value

GridLayout {
Layout.fillWidth: true
columns: 2

Label {
text: i18n('Update interval:')
Layout.alignment: Qt.AlignRight
Expand All @@ -28,50 +31,65 @@ Item {
minimumValue: 0.1
suffix: i18nc('Abbreviation for seconds', 's')
}


Label {
text: i18n('Font scale:')
Layout.alignment: Qt.AlignRight
}
SpinBox {
id: fontScale
minimumValue: 1
maximumValue: 100
suffix: i18nc('Percent', '%')
}

// Charts

Item {
width: 2
height: 10
Layout.columnSpan: 2
}

CheckBox {
id: showCpuMonitor
Layout.columnSpan: 2
text: i18n('Show CPU monitor')
}

CheckBox {
id: showClock
Layout.columnSpan: 2
text: i18n('Show clock')
enabled: showCpuMonitor.checked
}

CheckBox {
id: showRamMonitor
Layout.columnSpan: 2
text: i18n('Show RAM monitor')
}

CheckBox {
id: memoryInPercent
Layout.columnSpan: 2
text: i18n('Memory in percentage')
}


// Layout

Item {
width: 2
height: 10
Layout.columnSpan: 2
}

CheckBox {
id: verticalLayout
Layout.columnSpan: 2
text: i18n('Vertical layout')
}

CheckBox {
id: enableHints
Layout.columnSpan: 2
Expand All @@ -83,7 +101,6 @@ Item {
Layout.columnSpan: 2
text: i18n('Drop shadows')
}

}

}
3 changes: 2 additions & 1 deletion package/contents/ui/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ Item {
property bool showRamMonitor: plasmoid.configuration.showRamMonitor
property bool memoryInPercent: plasmoid.configuration.memoryInPercent
property bool showMemoryInPercent: memoryInPercent
property double fontScale: (plasmoid.configuration.fontScale / 100)

property color warningColor: theme.neutralTextColor
property int graphGranularity: 20
Expand All @@ -47,7 +48,7 @@ Item {
property double parentHeight: parent === null ? 0 : parent.height
property double itemWidth: vertical ? ( verticalLayout ? parentWidth : (parentWidth - itemMargin) / 2 ) : ( verticalLayout ? (parentHeight - itemMargin) / 2 : parentHeight )
property double itemHeight: itemWidth
property double fontPixelSize: itemHeight * 0.26
property double fontPixelSize: itemHeight * fontScale
property double widgetWidth: showCpuMonitor && showRamMonitor && !verticalLayout ? itemWidth*2 + itemMargin : itemWidth
property double widgetHeight: showCpuMonitor && showRamMonitor && verticalLayout ? itemWidth*2 + itemMargin : itemWidth

Expand Down

0 comments on commit 5238bc2

Please sign in to comment.