-
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.
add executable source, add new monitor types, ...
- Loading branch information
Showing
14 changed files
with
1,066 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
* Copyright (C) 2017 Michal Bukovský <[email protected]> | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public License as | ||
* published by the Free Software Foundation; either version 2 of | ||
* the License or (at your option) version 3 or any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/> | ||
*/ | ||
|
||
function to_string(value) { | ||
return Number(value).toLocaleString(Qt.locale(), "f") | ||
} | ||
|
||
function format_number(conf, value) { | ||
var value_units = [ | ||
{"unit": "Y", "exp": Math.pow(10, 24)}, | ||
{"unit": "Z", "exp": Math.pow(10, 21)}, | ||
{"unit": "E", "exp": Math.pow(10, 18)}, | ||
{"unit": "P", "exp": Math.pow(10, 15)}, | ||
{"unit": "T", "exp": Math.pow(10, 12)}, | ||
{"unit": "G", "exp": Math.pow(10, 9)}, | ||
{"unit": "M", "exp": Math.pow(10, 6)}, | ||
{"unit": "k", "exp": Math.pow(10, 3)}, | ||
{"unit": "", "exp": Math.pow(10, 0)}, | ||
{"unit": "m", "exp": Math.pow(10, -3)}, | ||
{"unit": "u", "exp": Math.pow(10, -6)}, | ||
{"unit": "n", "exp": Math.pow(10, -9)}, | ||
{"unit": "p", "exp": Math.pow(10, -12)}, | ||
{"unit": "f", "exp": Math.pow(10, -15)}, | ||
{"unit": "a", "exp": Math.pow(10, -18)}, | ||
] | ||
|
||
for (var i = 0; i < value_units.length; ++i) { | ||
var value_unit = value_units[i] | ||
var fixed_value = value * conf.multiplier | ||
if (fixed_value > value_unit.exp) | ||
return to_string(fixed_value / value_unit.exp) + value_unit.unit | ||
} | ||
return "0" | ||
} | ||
|
||
function get_label(conf, orig_values) { | ||
if (!conf.use_value_as_label) | ||
return conf.label | ||
var label = 0.0 | ||
for (var i = 0; i < orig_values.length; ++i) | ||
label += orig_values[i] | ||
return format_number(conf, label) | ||
} | ||
|
||
function is_label_visible(conf) { | ||
return conf.use_value_as_label | ||
|| (conf.label && conf.label.length) | ||
} | ||
|
||
function get_height(conf, base) { | ||
return base.height - theme.mSize(theme.defaultFont).height * (is_label_visible(conf)? 1: 0) | ||
} | ||
|
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,103 @@ | ||
/* | ||
* Copyright (C) 2014 Martin Yrjölä <[email protected]> | ||
* Copyright (C) 2017 Michal Bukovský <[email protected]> | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public License as | ||
* published by the Free Software Foundation; either version 2 of | ||
* the License or (at your option) version 3 or any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/> | ||
*/ | ||
|
||
import QtQuick 2.2 | ||
import QtQuick.Layouts 1.1 | ||
import org.kde.plasma.components 2.0 as PlasmaComponents | ||
|
||
import "../code/utils.js" as Utils | ||
|
||
Item { | ||
id: bar_monitor | ||
|
||
anchors.fill: parent | ||
height: childrenRect.height | ||
|
||
property var orig_values | ||
property var values | ||
|
||
ColumnLayout { | ||
width: parent.width | ||
|
||
Item { | ||
id: bar_row | ||
|
||
height: Utils.get_height(plasmoid.configuration, bar_monitor) | ||
|
||
Rectangle { | ||
id: bar_border | ||
|
||
height: Utils.get_height(plasmoid.configuration, bar_monitor) | ||
width: bar_monitor.width | ||
|
||
color: "transparent" | ||
|
||
radius: 3 | ||
opacity: .4 | ||
|
||
border { | ||
color: theme.textColor | ||
width: 1 | ||
} | ||
} | ||
|
||
Repeater { | ||
id: bar_repeater | ||
model: values.length | ||
|
||
Rectangle { | ||
color: plasmoid.configuration.colors[index] | ||
height: (bar_border.height - (bar_border.border.width * 2)) * bar_monitor.values[index] | ||
width: bar_border.width - (bar_border.border.width * 2) | ||
z: -1 | ||
anchors { | ||
bottom: index == 0 | ||
? bar_border.bottom | ||
: bar_repeater.itemAt(index - 1).top | ||
bottomMargin: index == 0 | ||
? bar_border.border.width | ||
: 0 | ||
} | ||
} | ||
} | ||
} | ||
|
||
PlasmaComponents.Label { | ||
id: bar_label | ||
|
||
width: bar_border.width | ||
Layout.maximumWidth: bar_border.width | ||
visible: Utils.is_label_visible(plasmoid.configuration) | ||
elide: Text.ElideRight | ||
horizontalAlignment: Text.AlignHCenter | ||
|
||
onVisibleChanged: { | ||
bar_row.height = Utils.get_height(plasmoid.configuration, bar_monitor) | ||
bar_monitor.height = Utils.get_height(plasmoid.configuration, bar_monitor) | ||
} | ||
|
||
anchors { | ||
top: bar_row.bottom | ||
horizontalCenter: parent.horizontalCenter | ||
} | ||
|
||
text: Utils.get_label(plasmoid.configuration, orig_values) | ||
} | ||
} | ||
} | ||
|
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,60 @@ | ||
/* | ||
* Copyright (C) 2014 Martin Yrjölä <[email protected]> | ||
* Copyright (C) 2015 Joshua Worth <[email protected]> | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public License as | ||
* published by the Free Software Foundation; either version 2 of | ||
* the License or (at your option) version 3 or any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/> | ||
*/ | ||
|
||
import QtQuick 2.2 | ||
import QtQuick.Layouts 1.1 | ||
import QtGraphicalEffects 1.0 | ||
|
||
Item { | ||
id: barMonitor | ||
|
||
property var colors | ||
property var proportions: [] | ||
|
||
Layout.fillHeight: true | ||
Layout.fillWidth: true | ||
|
||
Rectangle { | ||
id: barBorder | ||
anchors.fill: parent | ||
opacity: 0 | ||
} | ||
|
||
Repeater { | ||
id: barRepeater | ||
model: proportions.length | ||
Rectangle { | ||
color: barMonitor.colors[index] | ||
height: barBorder.height * barMonitor.proportions[index] | ||
width: barBorder.width | ||
anchors { | ||
bottom: index == 0 ? barBorder.bottom : barRepeater.itemAt(index-1).top | ||
bottomMargin: index == 0 ? barBorder.border.width : 0 | ||
} | ||
|
||
LinearGradient { | ||
anchors.fill: parent | ||
end: Qt.point(width, 0) | ||
gradient: Gradient { | ||
GradientStop { position: 0.0; color: "#60ffffff" } | ||
GradientStop { position: 1.0; color: "transparent" } | ||
} | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.