mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-04-25 07:57:19 +00:00
more correct widget resizing. Create width and height options (#47)
This commit is contained in:
parent
104bb52557
commit
15d88ee3ba
@ -14,6 +14,12 @@
|
|||||||
|
|
||||||
<group name="Advanced">
|
<group name="Advanced">
|
||||||
<!-- advanced -->
|
<!-- advanced -->
|
||||||
|
<entry name="height" type="int">
|
||||||
|
<default>0</default>
|
||||||
|
</entry>
|
||||||
|
<entry name="width" type="int">
|
||||||
|
<default>0</default>
|
||||||
|
</entry>
|
||||||
<entry name="notify" type="bool">
|
<entry name="notify" type="bool">
|
||||||
<default>true</default>
|
<default>true</default>
|
||||||
</entry>
|
</entry>
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
|
|
||||||
import QtQuick 2.0
|
import QtQuick 2.0
|
||||||
import QtQuick.Controls 1.3 as QtControls
|
import QtQuick.Controls 1.3 as QtControls
|
||||||
import org.kde.plasma.core 2.0 as PlasmaCore
|
|
||||||
|
|
||||||
import org.kde.plasma.private.awesomewidget 1.0
|
import org.kde.plasma.private.awesomewidget 1.0
|
||||||
|
|
||||||
@ -30,34 +29,9 @@ Item {
|
|||||||
implicitHeight: pageColumn.implicitHeight
|
implicitHeight: pageColumn.implicitHeight
|
||||||
|
|
||||||
property bool debug: AWKeys.isDebugEnabled()
|
property bool debug: AWKeys.isDebugEnabled()
|
||||||
property variant settings: {
|
|
||||||
"customTime": plasmoid.configuration.customTime,
|
|
||||||
"customUptime": plasmoid.configuration.customUptime,
|
|
||||||
"tempUnits": plasmoid.configuration.tempUnits,
|
|
||||||
"acOnline": plasmoid.configuration.acOnline,
|
|
||||||
"acOffline": plasmoid.configuration.acOffline
|
|
||||||
}
|
|
||||||
property variant tooltipSettings: {
|
|
||||||
"tooltipNumber": plasmoid.configuration.tooltipNumber,
|
|
||||||
"useTooltipBackground": plasmoid.configuration.useTooltipBackground,
|
|
||||||
"tooltipBackgroung": plasmoid.configuration.tooltipBackgroung,
|
|
||||||
"cpuTooltip": plasmoid.configuration.cpuTooltip,
|
|
||||||
"cpuclTooltip": plasmoid.configuration.cpuclTooltip,
|
|
||||||
"memTooltip": plasmoid.configuration.memTooltip,
|
|
||||||
"swapTooltip": plasmoid.configuration.swapTooltip,
|
|
||||||
"downTooltip": plasmoid.configuration.downTooltip,
|
|
||||||
"upTooltip": plasmoid.configuration.downTooltip,
|
|
||||||
"batTooltip": plasmoid.configuration.batTooltip,
|
|
||||||
"cpuTooltipColor": plasmoid.configuration.cpuTooltipColor,
|
|
||||||
"cpuclTooltipColor": plasmoid.configuration.cpuclTooltipColor,
|
|
||||||
"memTooltipColor": plasmoid.configuration.memTooltipColor,
|
|
||||||
"swapTooltipColor": plasmoid.configuration.swapTooltipColor,
|
|
||||||
"downTooltipColor": plasmoid.configuration.downTooltipColor,
|
|
||||||
"upTooltipColor": plasmoid.configuration.upTooltipColor,
|
|
||||||
"batTooltipColor": plasmoid.configuration.batTooltipColor,
|
|
||||||
"batInTooltipColor": plasmoid.configuration.batInTooltipColor
|
|
||||||
}
|
|
||||||
|
|
||||||
|
property alias cfg_height: widgetHeight.value
|
||||||
|
property alias cfg_width: widgetWidth.value
|
||||||
property alias cfg_notify: notify.checked
|
property alias cfg_notify: notify.checked
|
||||||
property alias cfg_background: background.checked
|
property alias cfg_background: background.checked
|
||||||
property alias cfg_customTime: customTime.text
|
property alias cfg_customTime: customTime.text
|
||||||
@ -70,6 +44,46 @@ Item {
|
|||||||
Column {
|
Column {
|
||||||
id: pageColumn
|
id: pageColumn
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
Row {
|
||||||
|
height: implicitHeight
|
||||||
|
width: parent.width
|
||||||
|
QtControls.Label {
|
||||||
|
height: parent.height
|
||||||
|
width: parent.width / 3
|
||||||
|
horizontalAlignment: Text.AlignRight
|
||||||
|
verticalAlignment: Text.AlignVCenter
|
||||||
|
text: i18n("Widget height, px")
|
||||||
|
}
|
||||||
|
QtControls.SpinBox {
|
||||||
|
id: widgetHeight
|
||||||
|
width: parent.width * 2 / 3
|
||||||
|
minimumValue: 0
|
||||||
|
maximumValue: 4096
|
||||||
|
stepSize: 50
|
||||||
|
value: plasmoid.configuration.height
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Row {
|
||||||
|
height: implicitHeight
|
||||||
|
width: parent.width
|
||||||
|
QtControls.Label {
|
||||||
|
height: parent.height
|
||||||
|
width: parent.width / 3
|
||||||
|
horizontalAlignment: Text.AlignRight
|
||||||
|
verticalAlignment: Text.AlignVCenter
|
||||||
|
text: i18n("Widget width, px")
|
||||||
|
}
|
||||||
|
QtControls.SpinBox {
|
||||||
|
id: widgetWidth
|
||||||
|
width: parent.width * 2 / 3
|
||||||
|
minimumValue: 0
|
||||||
|
maximumValue: 4096
|
||||||
|
stepSize: 50
|
||||||
|
value: plasmoid.configuration.width
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Row {
|
Row {
|
||||||
height: implicitHeight
|
height: implicitHeight
|
||||||
width: parent.width
|
width: parent.width
|
||||||
@ -220,71 +234,9 @@ Item {
|
|||||||
text: plasmoid.configuration.acOffline
|
text: plasmoid.configuration.acOffline
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Row {
|
|
||||||
height: implicitHeight
|
|
||||||
width: parent.width
|
|
||||||
QtControls.Label {
|
|
||||||
height: parent.height
|
|
||||||
width: parent.width * 2 / 5
|
|
||||||
horizontalAlignment: Text.AlignRight
|
|
||||||
verticalAlignment: Text.AlignVCenter
|
|
||||||
text: i18n("Bars")
|
|
||||||
}
|
|
||||||
QtControls.Button {
|
|
||||||
width: parent.width * 3 / 5
|
|
||||||
text: i18n("Edit bars")
|
|
||||||
onClicked: AWKeys.editItem("graphicalitem")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// we need to initializate DataEngines here too
|
|
||||||
// because we need to get keys and values
|
|
||||||
PlasmaCore.DataSource {
|
|
||||||
id: systemmonitorDE
|
|
||||||
engine: "systemmonitor"
|
|
||||||
connectedSources: systemmonitorDE.sources
|
|
||||||
interval: 5000
|
|
||||||
|
|
||||||
onNewData: {
|
|
||||||
if (debug) console.log("[advanced::onNewData] : Update source " + sourceName)
|
|
||||||
|
|
||||||
AWKeys.setDataBySource(sourceName, data, settings)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
PlasmaCore.DataSource {
|
|
||||||
id: extsysmonDE
|
|
||||||
engine: "extsysmon"
|
|
||||||
connectedSources: ["battery", "custom", "desktop", "netdev", "gpu",
|
|
||||||
"gputemp", "hddtemp", "pkg", "player", "ps", "update"]
|
|
||||||
interval: 5000
|
|
||||||
|
|
||||||
onNewData: {
|
|
||||||
if (debug) console.log("[advanced::onNewData] : Update source " + sourceName)
|
|
||||||
|
|
||||||
AWKeys.setDataBySource(sourceName, data, settings)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
PlasmaCore.DataSource {
|
|
||||||
id: timeDE
|
|
||||||
engine: "time"
|
|
||||||
connectedSources: ["Local"]
|
|
||||||
interval: 5000
|
|
||||||
|
|
||||||
onNewData: {
|
|
||||||
if (debug) console.log("[advanced::onNewData] : Update source " + sourceName)
|
|
||||||
|
|
||||||
AWKeys.setDataBySource(sourceName, data, settings)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
if (debug) console.log("[advanced::onCompleted]")
|
if (debug) console.log("[advanced::onCompleted]")
|
||||||
|
|
||||||
// init submodule
|
|
||||||
AWKeys.initKeys(plasmoid.configuration.text, tooltipSettings)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -67,8 +67,8 @@ Item {
|
|||||||
|
|
||||||
Layout.fillWidth: plasmoid.formFactor != PlasmaCore.Planar
|
Layout.fillWidth: plasmoid.formFactor != PlasmaCore.Planar
|
||||||
Layout.fillHeight: plasmoid.formFactor != PlasmaCore.Planar
|
Layout.fillHeight: plasmoid.formFactor != PlasmaCore.Planar
|
||||||
Layout.minimumHeight: text.contentHeight
|
Layout.minimumHeight: plasmoid.configuration.height == 0 ? text.contentHeight : plasmoid.configuration.height
|
||||||
Layout.minimumWidth: text.contentWidth
|
Layout.minimumWidth: plasmoid.configuration.width == 0 ? text.contentWidth : plasmoid.configuration.width
|
||||||
|
|
||||||
Plasmoid.icon: "utilities-system-monitor"
|
Plasmoid.icon: "utilities-system-monitor"
|
||||||
Plasmoid.backgroundHints: plasmoid.configuration.background ? "DefaultBackground" : "NoBackground"
|
Plasmoid.backgroundHints: plasmoid.configuration.background ? "DefaultBackground" : "NoBackground"
|
||||||
@ -124,11 +124,11 @@ Item {
|
|||||||
// ui
|
// ui
|
||||||
Grid {
|
Grid {
|
||||||
columns: 1
|
columns: 1
|
||||||
|
anchors.fill: parent
|
||||||
|
|
||||||
Text {
|
Text {
|
||||||
id: text
|
id: text
|
||||||
height: contentHeight
|
anchors.fill: parent
|
||||||
width: contentWidth
|
|
||||||
textFormat: Text.RichText
|
textFormat: Text.RichText
|
||||||
wrapMode: Text.NoWrap
|
wrapMode: Text.NoWrap
|
||||||
|
|
||||||
|
@ -246,6 +246,16 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Row {
|
||||||
|
height: implicitHeight
|
||||||
|
width: parent.width
|
||||||
|
QtControls.Button {
|
||||||
|
width: parent.width
|
||||||
|
text: i18n("Edit bars")
|
||||||
|
onClicked: AWKeys.editItem("graphicalitem")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QtControls.TextArea {
|
QtControls.TextArea {
|
||||||
id: textPattern
|
id: textPattern
|
||||||
width: parent.width
|
width: parent.width
|
||||||
|
@ -1188,7 +1188,7 @@ void AWKeys::addKeyToCache(const QString type, const QString key)
|
|||||||
QStringList devices = allDevices.filter(QRegExp(QString("^[hms]d[a-z]$")));
|
QStringList devices = allDevices.filter(QRegExp(QString("^[hms]d[a-z]$")));
|
||||||
for (int i=0; i<devices.count(); i++) {
|
for (int i=0; i<devices.count(); i++) {
|
||||||
QString device = QString("/dev/%1").arg(devices[i]);
|
QString device = QString("/dev/%1").arg(devices[i]);
|
||||||
if (cachedValues.contains(devices[i])) continue;
|
if (cachedValues.contains(device)) continue;
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Found new key" << device << "for type" << type;
|
if (debug) qDebug() << PDEBUG << ":" << "Found new key" << device << "for type" << type;
|
||||||
cache.setValue(QString("%1").arg(cache.allKeys().count(), 3, 10, QChar('0')), device);
|
cache.setValue(QString("%1").arg(cache.allKeys().count(), 3, 10, QChar('0')), device);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user