Skip to content

Commit

Permalink
feat(config): add customizable graph sizes
Browse files Browse the repository at this point in the history
fix #4
  • Loading branch information
orblazer committed Oct 20, 2021
1 parent 7d4d215 commit 5257e1d
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 4 deletions.
13 changes: 13 additions & 0 deletions package/contents/config/main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,19 @@
<entry name="fontScale" type="int">
<default>26</default>
</entry>
<entry name="customGraphWidth" type="Bool">
<default>false</default>
</entry>
<entry name="graphWidth" type="int">
</entry>
<entry name="customGraphHeight" type="Bool">
<default>false</default>
</entry>
<entry name="graphHeight" type="int">
</entry>
<entry name="graphMargin" type="int">
<default>15</default>
</entry>
<entry name="displayment" type="string">
<default>hover-hints</default>
</entry>
Expand Down
39 changes: 39 additions & 0 deletions package/contents/ui/components/CustomizableSize.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import QtQuick 2.2
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.1
import QtQuick.Dialogs 1.0

import "./"

RowLayout {
id: customizableSize

// Aliases
property alias value: spinBox.value
property alias checked: customized.checked

property alias from: spinBox.from
property alias to: spinBox.to
property alias stepSize: spinBox.stepSize

// Properties
property string label
property string dialogTitle

// Components
CheckBox {
id: customized

Accessible.name: ToolTip.text
ToolTip {
text: i18n("Check for use customized graph width")
}
}
SpinBox {
id: spinBox

enabled: customized.checked
suffix: i18nc('Pixels', 'px')
Layout.fillWidth: true
}
}
28 changes: 28 additions & 0 deletions package/contents/ui/config/ConfigAppearance.qml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ Kirigami.FormLayout {
property alias cfg_verticalLayout: verticalLayout.checked
property alias cfg_enableShadows: enableShadows.checked
property alias cfg_fontScale: fontScale.value
property alias cfg_customGraphWidth: graphWidth.checked
property alias cfg_graphWidth: graphWidth.value
property alias cfg_customGraphHeight: graphHeight.checked
property alias cfg_graphHeight: graphHeight.value
property alias cfg_graphMargin: graphMargin.value
property string cfg_placement: ''
property string cfg_displayment: ''

Expand Down Expand Up @@ -57,6 +62,29 @@ Kirigami.FormLayout {
suffix: i18nc('Percent', '%')
}

CustomizableSize {
id: graphWidth
Kirigami.FormData.label: i18n('Graph width:')
QtLayouts.Layout.fillWidth: true
from: 1
to: 1000
}
CustomizableSize {
id: graphHeight
Kirigami.FormData.label: i18n('Graph height:')
QtLayouts.Layout.fillWidth: true
from: 1
to: 1000
}
SpinBox {
id: graphMargin
Kirigami.FormData.label: i18n('Graph margin:')
QtLayouts.Layout.fillWidth: true
suffix: i18nc('Pixels', 'px')
from: 1
to: 1000
}

QtControls.ComboBox {
id: displayment
Kirigami.FormData.label: i18n('Text displayment:')
Expand Down
9 changes: 5 additions & 4 deletions package/contents/ui/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,15 @@ Item {

// Component properties
property int containerCount: (showCpuMonitor?1:0) + (showRamMonitor?1:0) + (showNetMonitor?1:0)
property int itemMargin: 10
property int itemMargin: plasmoid.configuration.graphMargin
property double parentWidth: parent === null ? 0 : parent.width
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 initWidth: vertical ? ( verticalLayout ? parentWidth : (parentWidth - itemMargin) / 2 ) : ( verticalLayout ? (parentHeight - itemMargin) / 2 : parentHeight )
property double itemWidth: plasmoid.configuration.customGraphWidth ? plasmoid.configuration.graphWidth : initWidth
property double itemHeight: plasmoid.configuration.customGraphHeight ? plasmoid.configuration.graphHeight : initWidth
property double fontPixelSize: itemHeight * fontScale
property double widgetWidth: !verticalLayout ? (itemWidth*containerCount + itemMargin*containerCount) : itemWidth
property double widgetHeight: verticalLayout ? (itemWidth*containerCount + itemMargin*containerCount) : itemWidth
property double widgetHeight: verticalLayout ? (itemHeight*containerCount + itemMargin*containerCount) : itemHeight

Layout.preferredWidth: widgetWidth
Layout.maximumWidth: widgetWidth
Expand Down

0 comments on commit 5257e1d

Please sign in to comment.