mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-07-24 19:19:55 +00:00
Add additional column to configuraion ui to better tag selection
This commit is contained in:
@ -231,15 +231,78 @@ Item {
|
||||
Row {
|
||||
height: implicitHeight
|
||||
width: parent.width
|
||||
QtControls.ComboBox {
|
||||
width: (parent.width - addTagButton.width - showValueButton.width - addLambdaButton.width) / 2
|
||||
textRole: "label"
|
||||
model: [
|
||||
{
|
||||
'label': i18n("AC"),
|
||||
'regexp': "^(ac|bat).*"
|
||||
},
|
||||
{
|
||||
'label': i18n("Bars"),
|
||||
'regexp': "^bar.*"
|
||||
},
|
||||
{
|
||||
'label': i18n("CPU"),
|
||||
'regexp': "^(cpu|gpu|la|ps|temp(?!erature)).*"
|
||||
},
|
||||
{
|
||||
'label': i18n("Desktops"),
|
||||
'regexp': "^(n|t)?desktop(s)?"
|
||||
},
|
||||
{
|
||||
'label': i18n("HDD"),
|
||||
'regexp': "^hdd.*"
|
||||
},
|
||||
{
|
||||
'label': i18n("Memory"),
|
||||
'regexp': "^(mem|swap).*"
|
||||
},
|
||||
{
|
||||
'label': i18n("Network"),
|
||||
'regexp': "^(netdev|(down|up(?!time)).*)"
|
||||
},
|
||||
{
|
||||
'label': i18n("Music player"),
|
||||
'regexp': "^(album|artist|duration|progress|title)"
|
||||
},
|
||||
{
|
||||
'label': i18n("Scripts"),
|
||||
'regexp': "^custom.*"
|
||||
},
|
||||
{
|
||||
'label': i18n("Time"),
|
||||
'regexp': ".*time$"
|
||||
},
|
||||
{
|
||||
'label': i18n("Quotes"),
|
||||
'regexp': "^(perc)?(ask|bid|price)(chg)?.*"
|
||||
},
|
||||
{
|
||||
'label': i18n("Upgrades"),
|
||||
'regexp': "^pkgcount.*"
|
||||
},
|
||||
{
|
||||
'label': i18n("Weathers"),
|
||||
'regexp': "^(weather(Id)?|humidity|pressure|temperature|timestamp)"
|
||||
}
|
||||
]
|
||||
onCurrentIndexChanged: {
|
||||
tags.model = awKeys.dictKeys(true, model[currentIndex]["regexp"])
|
||||
tags.currentIndex = -1
|
||||
}
|
||||
}
|
||||
QtControls.ComboBox {
|
||||
id: tags
|
||||
width: parent.width - addTagButton.width - showValueButton.width - addLambdaButton.width
|
||||
width: (parent.width - addTagButton.width - showValueButton.width - addLambdaButton.width) / 2
|
||||
}
|
||||
QtControls.Button {
|
||||
id: addTagButton
|
||||
text: i18n("Add")
|
||||
|
||||
onClicked: {
|
||||
if (!tags.currentText) return
|
||||
if (debug) console.log("[widget::onClicked] : Add tag button")
|
||||
|
||||
var pos = textPattern.cursorPosition
|
||||
@ -253,6 +316,7 @@ Item {
|
||||
text: i18n("Show value")
|
||||
|
||||
onClicked: {
|
||||
if (!tags.currentText) return
|
||||
if (debug) console.log("[widget::onClicked] : Show tag button")
|
||||
|
||||
var message = i18n("Tag: %1", tags.currentText)
|
||||
@ -273,7 +337,7 @@ Item {
|
||||
var pos = textPattern.cursorPosition
|
||||
var selected = textPattern.selectedText
|
||||
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
||||
textPattern.insert(pos, selected + "${{}}")
|
||||
textPattern.insert(pos, selected + "${{\n\n}}")
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -343,6 +407,5 @@ Item {
|
||||
|
||||
// init submodule
|
||||
awKeys.initKeys(plasmoid.configuration.text)
|
||||
tags.model = awKeys.dictKeys(true)
|
||||
}
|
||||
}
|
||||
|
@ -171,25 +171,26 @@ void AWKeys::addDevice(const QString source)
|
||||
|
||||
QRegExp diskRegexp = QRegExp(QString("disk/(?:md|sd|hd)[a-z|0-9]_.*/Rate/(?:rblk)"));
|
||||
QRegExp mountRegexp = QRegExp(QString("partitions/.*/filllevel"));
|
||||
QRegExp tempRegexp = QRegExp(QString("lmsensors/.*"));
|
||||
|
||||
if (diskRegexp.indexIn(source) > -1) {
|
||||
if (source.contains(diskRegexp)) {
|
||||
QString device = source;
|
||||
device.remove(QString("/Rate/rblk"));
|
||||
addKeyToCache(QString("Disk"), device);
|
||||
} else if (mountRegexp.indexIn(source) > -1) {
|
||||
} else if (source.contains(mountRegexp)) {
|
||||
QString device = source;
|
||||
device.remove(QString("partitions")).remove(QString("/filllevel"));
|
||||
addKeyToCache(QString("Mount"), device);
|
||||
} else if (tempRegexp.indexIn(source) > -1) {
|
||||
} else if (source.startsWith(QString("lmsensors"))) {
|
||||
addKeyToCache(QString("Temp"), source);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QStringList AWKeys::dictKeys(const bool sorted) const
|
||||
QStringList AWKeys::dictKeys(const bool sorted, const QString regexp) const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Should be sorted" << sorted;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Filter" << regexp;
|
||||
|
||||
QStringList allKeys;
|
||||
// time
|
||||
@ -339,7 +340,7 @@ QStringList AWKeys::dictKeys(const bool sorted) const
|
||||
// sort if required
|
||||
if (sorted) allKeys.sort();
|
||||
|
||||
return allKeys;
|
||||
return allKeys.filter(QRegExp(regexp));
|
||||
}
|
||||
|
||||
|
||||
@ -377,7 +378,6 @@ void AWKeys::setDataBySource(const QString sourceName, const QVariantMap data,
|
||||
QRegExp mountFreeRegExp = QRegExp(QString("partitions/.*/freespace"));
|
||||
QRegExp mountUsedRegExp = QRegExp(QString("partitions/.*/usedspace"));
|
||||
QRegExp netRegExp = QRegExp(QString("network/interfaces/.*/(receiver|transmitter)/data$"));
|
||||
QRegExp tempRegExp = QRegExp(QString("lmsensors/.*"));
|
||||
|
||||
if (sourceName == QString("battery")) {
|
||||
// battery
|
||||
@ -611,7 +611,7 @@ void AWKeys::setDataBySource(const QString sourceName, const QVariantMap data,
|
||||
AWActions::sendNotification(QString("event"), i18n("Swap is used"), enablePopup);
|
||||
// value
|
||||
values[QString("swap")] = QString("%1").arg(value, 5, 'f', 1);
|
||||
} else if (sourceName.contains(tempRegExp)) {
|
||||
} else if (sourceName.startsWith(QString("lmsensors/"))) {
|
||||
// temperature devices
|
||||
for (int i=0; i<tempDevices.count(); i++) {
|
||||
if (sourceName != tempDevices.at(i)) continue;
|
||||
|
@ -52,7 +52,8 @@ public:
|
||||
Q_INVOKABLE QSize toolTipSize() const;
|
||||
// keys
|
||||
Q_INVOKABLE void addDevice(const QString source);
|
||||
Q_INVOKABLE QStringList dictKeys(const bool sorted = false) const;
|
||||
Q_INVOKABLE QStringList dictKeys(const bool sorted = false,
|
||||
const QString regexp = QString()) const;
|
||||
Q_INVOKABLE QStringList getHddDevices() const;
|
||||
Q_INVOKABLE void setDataBySource(const QString sourceName, const QVariantMap data,
|
||||
const QVariantMap params);
|
||||
|
Reference in New Issue
Block a user