mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-04-25 07:57:19 +00:00
added custom schemes
This commit is contained in:
parent
65a60de9a5
commit
2ddf9082f2
@ -23,6 +23,9 @@ from PyKDE4 import plasmascript
|
|||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
|
timeLetters = ['dddd', 'ddd', 'dd', 'd', 'MMMM', 'MMM', 'MM', 'M', 'yyyy', 'yy', \
|
||||||
|
'hh', 'h', 'mm', 'm', 'ss', 's']
|
||||||
|
|
||||||
|
|
||||||
class DataEngine:
|
class DataEngine:
|
||||||
def __init__(self, parent):
|
def __init__(self, parent):
|
||||||
@ -85,14 +88,25 @@ class DataEngine:
|
|||||||
|
|
||||||
def dataUpdated(self, sourceName, data):
|
def dataUpdated(self, sourceName, data):
|
||||||
"""function to update data"""
|
"""function to update data"""
|
||||||
try:
|
#try:
|
||||||
|
if True:
|
||||||
if (sourceName == "system/uptime"):
|
if (sourceName == "system/uptime"):
|
||||||
value = int(round(float(data[QString(u'value')]), 1))
|
value = datetime.timedelta(0, int(round(float(data[QString(u'value')]), 1)))
|
||||||
uptimeText = '%3sd%2sh%2sm' % (str(int(value/(24*60*60))), int(value/60/60)-int(value/24/60/60)*24, (value-value%60)/60%60)
|
days = value.days
|
||||||
if (self.parent.uptimeFormat.split('$uptime')[0] != self.parent.uptimeFormat):
|
hours = int(value.seconds / 60 / 60)
|
||||||
line = self.parent.uptimeFormat.split('$uptime')[0] + uptimeText + self.parent.uptimeFormat.split('$uptime')[1]
|
minutes = int(value.seconds / 60 % 60)
|
||||||
else:
|
|
||||||
line = self.parent.uptimeFormat
|
line = self.parent.uptimeFormat
|
||||||
|
if (line.split('$uptime')[0] != line):
|
||||||
|
uptimeText = "%3id%2ih%2im" % (days, hours, minutes)
|
||||||
|
line = line.split('$uptime')[0] + uptimeText + line.split('$uptime')[1]
|
||||||
|
elif (line.split('$custom')[0] != line):
|
||||||
|
line = ''.join(line.split('$custom'))
|
||||||
|
if (line.split('$ds')[0] != line):
|
||||||
|
line = line.split('$ds')[0] + str(days) + line.split('$ds')[1]
|
||||||
|
if (line.split('$hs')[0] != line):
|
||||||
|
line = line.split('$hs')[0] + str(hours) + line.split('$hs')[1]
|
||||||
|
if (line.split('$ms')[0] != line):
|
||||||
|
line = line.split('$ms')[0] + str(minutes) + line.split('$ms')[1]
|
||||||
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
|
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
|
||||||
self.parent.label_uptime.setText(text)
|
self.parent.label_uptime.setText(text)
|
||||||
elif (sourceName == "cpu/system/TotalLoad"):
|
elif (sourceName == "cpu/system/TotalLoad"):
|
||||||
@ -284,7 +298,7 @@ class DataEngine:
|
|||||||
if (line.split('$time')[0] != line):
|
if (line.split('$time')[0] != line):
|
||||||
timeText = '%02i:%02i' % (int(time)/60, int(time)%60)
|
timeText = '%02i:%02i' % (int(time)/60, int(time)%60)
|
||||||
line = line.split('$time')[0] + timeText + line.split('$time')[1]
|
line = line.split('$time')[0] + timeText + line.split('$time')[1]
|
||||||
if (line.split('$title') != line):
|
if (line.split('$title')[0] != line):
|
||||||
line = line.split('$title')[0] + title + line.split('$title')[1]
|
line = line.split('$title')[0] + title + line.split('$title')[1]
|
||||||
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
|
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
|
||||||
self.parent.label_player.setText(text)
|
self.parent.label_player.setText(text)
|
||||||
@ -311,11 +325,19 @@ class DataEngine:
|
|||||||
value = ':'.join(rawDate.split()[3].split(':')[0:2]) + " " + rawDate.split()[0] + " " + \
|
value = ':'.join(rawDate.split()[3].split(':')[0:2]) + " " + rawDate.split()[0] + " " + \
|
||||||
rawDate.split()[2] + " " + rawDate.split()[1]
|
rawDate.split()[2] + " " + rawDate.split()[1]
|
||||||
line = self.parent.timeFormat.split('$nsnstime')[0] + value.decode("utf-8") + self.parent.timeFormat.split('$nsnstime')[1]
|
line = self.parent.timeFormat.split('$nsnstime')[0] + value.decode("utf-8") + self.parent.timeFormat.split('$nsnstime')[1]
|
||||||
|
elif (self.parent.timeFormat.split('$custom')[0] != self.parent.timeFormat):
|
||||||
|
rawDate = data[QString(u'DateTime')]
|
||||||
|
line = ''.join(self.parent.timeFormat.split('$custom'))
|
||||||
|
for letters in timeLetters:
|
||||||
|
if (line.split('$'+letters)[0] != line):
|
||||||
|
line = line.split('$'+letters)[0] + \
|
||||||
|
str(data[QString(u'DateTime')].toString(letters).toUtf8()).decode("utf-8") + \
|
||||||
|
line.split('$'+letters)[1]
|
||||||
else:
|
else:
|
||||||
line = self.parent.timeFormat
|
line = self.parent.timeFormat
|
||||||
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
|
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
|
||||||
self.parent.label_time.setText(text)
|
self.parent.label_time.setText(text)
|
||||||
|
|
||||||
self.parent.update()
|
self.parent.update()
|
||||||
except:
|
#except:
|
||||||
pass
|
#pass
|
||||||
|
@ -67,8 +67,12 @@
|
|||||||
$isotime - time in ISO format
|
$isotime - time in ISO format
|
||||||
$shorttime - time in short format
|
$shorttime - time in short format
|
||||||
$longtime - time in log format
|
$longtime - time in log format
|
||||||
$snsntime - time in format 'string number string number'
|
$custom: $dddd - long weekday; $ddd - short weekday; $dd - day; $d day w\o zero;
|
||||||
$nsnstime - time in format 'number string number string'</string>
|
$MMMM - long month; $MMM - short month; $MM - month; $M - month w\o zero;
|
||||||
|
$yyyy - year; $yy short year;
|
||||||
|
$hh - hours (24 only); $h - hours w\o zero (24 only);
|
||||||
|
$mm - minutes; $m - minutes w\o zero;
|
||||||
|
s$ss - seconds; $s - seconds w\o zero</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="alignment">
|
<property name="alignment">
|
||||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
@ -123,7 +127,8 @@ $nsnstime - time in format 'number string number string'</string>
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QLineEdit" name="lineEdit_uptime">
|
<widget class="QLineEdit" name="lineEdit_uptime">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string notr="true">$uptime - uptime</string>
|
<string notr="true">$uptime - system uptime
|
||||||
|
$custom: $ds - uptime days; $hs - uptime hours; $ms - uptime minutes</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="alignment">
|
<property name="alignment">
|
||||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
|
Loading…
Reference in New Issue
Block a user