mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-07-15 06:45:48 +00:00
add support of smartctl (TODO remove qdbus calls)
end work on awesome-widget (prerelease state)
This commit is contained in:
@ -17,6 +17,7 @@
|
||||
|
||||
import QtQuick 2.4
|
||||
import QtQuick.Controls 1.3 as QtControls
|
||||
import QtQuick.Layouts 1.1
|
||||
import org.kde.plasma.plasmoid 2.0
|
||||
import org.kde.plasma.core 2.0 as PlasmaCore
|
||||
import org.kde.plasma.components 2.0 as PlasmaComponents
|
||||
@ -39,7 +40,7 @@ Item {
|
||||
property variant tooltipSettings: {
|
||||
"tooltipNumber": plasmoid.configuration.tooltipNumber,
|
||||
"useTooltipBackground": plasmoid.configuration.useTooltipBackground,
|
||||
"tooltipBackgroung": plasmoid.configuration.tooltipBackgroung,
|
||||
"tooltipBackground": plasmoid.configuration.tooltipBackground,
|
||||
"cpuTooltip": plasmoid.configuration.cpuTooltip,
|
||||
"cpuclTooltip": plasmoid.configuration.cpuclTooltip,
|
||||
"memTooltip": plasmoid.configuration.memTooltip,
|
||||
@ -61,6 +62,14 @@ Item {
|
||||
|
||||
|
||||
// init
|
||||
Plasmoid.preferredRepresentation: Plasmoid.fullRepresentation
|
||||
Plasmoid.compactRepresentation: Plasmoid.fullRepresentation
|
||||
|
||||
Layout.fillWidth: plasmoid.formFactor != PlasmaCore.Planar
|
||||
Layout.fillHeight: plasmoid.formFactor != PlasmaCore.Planar
|
||||
Layout.minimumHeight: text.height
|
||||
Layout.minimumWidth: text.width
|
||||
|
||||
Plasmoid.icon: "utilities-system-monitor"
|
||||
Plasmoid.backgroundHints: plasmoid.configuration.background ? "DefaultBackground" : "NoBackground"
|
||||
Plasmoid.associatedApplication: "ksysguard"
|
||||
@ -68,18 +77,19 @@ Item {
|
||||
PlasmaCore.DataSource {
|
||||
id: systemmonitorDE
|
||||
engine: "systemmonitor"
|
||||
connectedSources: systemmonitorDE.sources
|
||||
interval: plasmoid.configuration.interval
|
||||
|
||||
onNewData: {
|
||||
if (debug) console.log("[main::onNewData] : Update source " + sourceName)
|
||||
|
||||
AWKeys.setDataBySource(sourceName, data, settings)
|
||||
if (AWKeys.setDataBySource(sourceName, data, settings)) disconnectSource(sourceName)
|
||||
}
|
||||
|
||||
onSourceAdded: {
|
||||
if (debug) console.log("[main::onSourceAdded] : Source " + source)
|
||||
|
||||
if (AWKeys.addDevice(source)) systemmonitorDE.connectSource(source)
|
||||
AWKeys.addDevice(source)
|
||||
}
|
||||
}
|
||||
|
||||
@ -110,27 +120,35 @@ Item {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ui
|
||||
Grid {
|
||||
id: mainGrid
|
||||
columns: 1
|
||||
|
||||
Text {
|
||||
id: text
|
||||
height: contentHeight
|
||||
width: contentWidth
|
||||
textFormat: Text.RichText
|
||||
wrapMode: Text.NoWrap
|
||||
|
||||
horizontalAlignment: general.align[plasmoid.configuration.textAlign]
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
|
||||
color: plasmoid.configuration.fontColor
|
||||
font.family: plasmoid.configuration.fontFamily
|
||||
font.italic: plasmoid.configuration.fontStyle == "italic" ? true : false
|
||||
font.pointSize: plasmoid.configuration.fontSize
|
||||
font.weight: general.fontWeight[plasmoid.configuration.fontWeight]
|
||||
horizontalAlignment: general.align[plasmoid.configuration.textAlign]
|
||||
textFormat: Text.RichText
|
||||
|
||||
text: plasmoid.configuration.text
|
||||
|
||||
PlasmaCore.ToolTipArea {
|
||||
id: rootTooltip
|
||||
mainItem: Text {
|
||||
id: tooltip
|
||||
height: 100
|
||||
width: 500
|
||||
mainText: "Awesome Widget"
|
||||
textFormat: Text.RichText
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -138,25 +156,32 @@ Item {
|
||||
Component.onCompleted: {
|
||||
if (debug) console.log("[main::onCompleted]")
|
||||
|
||||
// init submodule
|
||||
AWKeys.initKeys(plasmoid.configuration.text, tooltipSettings)
|
||||
// actions
|
||||
plasmoid.setAction("requestKey", i18n("Request key"), "utilities-system-monitor")
|
||||
plasmoid.setAction("showReadme", i18n("Show README"), "text-x-readme")
|
||||
plasmoid.setAction("checkUpdates", i18n("Check updates"), "system-software-update")
|
||||
// plasmoid.setAction("report", i18n("Mail to developers"), "email")
|
||||
// init submodule
|
||||
Plasmoid.userConfiguringChanged(true)
|
||||
}
|
||||
|
||||
onNeedUpdate: {
|
||||
if (debug) console.log("[main::onNeedUpdate]")
|
||||
|
||||
text.text = AWKeys.parsePattern(plasmoid.configuration.text)
|
||||
// FIXME change to pixmap/image/etc
|
||||
tooltip.image = AWKeys.toolTipImage()
|
||||
tooltip.text = AWKeys.toolTipImage()
|
||||
// update geometry
|
||||
text.update()
|
||||
height = text.contentHeight
|
||||
width = text.contentWidth
|
||||
height = text.height
|
||||
width = text.width
|
||||
update()
|
||||
rootTooltip.height = AWKeys.toolTipSize().height
|
||||
rootTooltip.width = AWKeys.toolTipSize().width
|
||||
}
|
||||
|
||||
Plasmoid.onUserConfiguringChanged: {
|
||||
// init submodule
|
||||
AWKeys.initKeys(plasmoid.configuration.text, tooltipSettings)
|
||||
}
|
||||
|
||||
function action_checkUpdates() {
|
||||
@ -171,6 +196,12 @@ Item {
|
||||
AWActions.showReadme()
|
||||
}
|
||||
|
||||
function action_report() {
|
||||
if (debug) console.log("[main::action_report]")
|
||||
|
||||
AWActions.sendEmail()
|
||||
}
|
||||
|
||||
function action_requestKey() {
|
||||
if (debug) console.log("[main::action_requestKey]")
|
||||
|
||||
|
@ -64,7 +64,7 @@ Item {
|
||||
|
||||
Column {
|
||||
id: pageColumn
|
||||
width: units.gridUnit * 50
|
||||
width: units.gridUnit * 25
|
||||
QtControls.Label {
|
||||
width: parent.width
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
@ -78,6 +78,7 @@ Item {
|
||||
width: parent.width
|
||||
QtControls.Button {
|
||||
text: i18n("Font")
|
||||
iconName: "font"
|
||||
|
||||
onClicked: {
|
||||
if (debug) console.log("[widget::onClicked] : Font button")
|
||||
@ -207,12 +208,17 @@ Item {
|
||||
textPattern.insert(pos, "<p align=\"justify\">" + selected + "</p")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Row {
|
||||
height: implicitHeight
|
||||
width: parent.width
|
||||
QtControls.ComboBox {
|
||||
id: tags
|
||||
model: AWKeys.dictKeys()
|
||||
width: parent.width - addTagButton.width - showValueButton.width
|
||||
}
|
||||
QtControls.Button {
|
||||
id: addTagButton
|
||||
text: i18n("Add")
|
||||
|
||||
onClicked: {
|
||||
@ -225,6 +231,7 @@ Item {
|
||||
}
|
||||
}
|
||||
QtControls.Button {
|
||||
id: showValueButton
|
||||
text: i18n("Show value")
|
||||
|
||||
onClicked: {
|
||||
@ -293,5 +300,6 @@ Item {
|
||||
|
||||
// init submodule
|
||||
AWKeys.initKeys(plasmoid.configuration.text, tooltipSettings)
|
||||
tags.model = AWKeys.dictKeys()
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user