
Source (link to git-repo or to original if based on someone elses unmodified work): Add the source-code for this project on opencode.net
Plasmoid to show date and time in adjustable format using rich text.
Developed and tested on KDE 4.11 with Qt 4.8 (Kubuntu 13.10).
Source (main repository, with more frequent updates) is located at:
https://github.com/Emdek/plasmoid-adjustable-clock
Warning!
Version 4.0 (and newer) is not backwards compatible with 3.x, all custom formats need to be exported and manually converted.
QML themes support is currently considered as experimental, behavior and available API are not yet stable and most probably will be changed with next release.
Tips:
- to change tool tip text you need to set options toolTipExpressionMain and toolTipExpressionSub in applets configuration file (usually located at ~/.kde4/share/config/plasma-desktop-appletsrc), in group containing line plugin=adjustableclock;
- you can use advanced WebKit features (all of these that work with for example rekonq should work here too), for example use CSS to create reflections:
-webkit-box-reflect:below 5px -webkit-gradient(linear, left top, left bottom, from(transparent), color-stop(0.5, transparent), to(white));
And much more. ;-)
If you created interesting theme and want to share it then post in comments!
Features:
- fully custom date and time using JavaScript API to obtain date and time components;
- multiple clock themes utilizing various designs;
- possibility to use rich text editor or edit source directly (HTML and CSS or QML) to adjust theme;
- context menu with actions to copy formatted (adjustable expressions) date and time to clipboard;
- fast copy to clipboard of adjustable date and time expression after middle mouse click on the clock or activation of keyboard shortcut;
- adjustable tool tip (hidden option, toolTipExpressionMain and toolTipExpressionSub keys);
- standard clock calendar.
If you have found bugs or have suggestions you can contact me via email, message or using comments, before you will vote bad. And remember that not everybody has enough time for fast replying. ;-)
7 years ago
4.1.4 (01.11.2013):
- fixed week number not being updated;
- added missing title of "Insert Component" dialog.
4.1.3 (27.09.2013):
- ensure that component values are always up to date;
- adjust timestamp for time zone offset;
- do not allow for accidental nesting of components in editor;
- added option to hide date in Train Clock theme;
- added workaround to ensure that hands of SVG Clock have correct initial positions as soon as possible.
4.1.2 (01.06.2013):
- ensure that center of SVG Clock theme is always valid;
- improve resizing in vertical panels.
4.1.1 (25.05.2013):
- fixed WYSIWYG editor for HTML themes;
- fixed missing dialog for "Insert Component" actions.
4.1 (15.05.2013):
- added SVG Clock theme (analog clock that uses Plasma theme);
- added experimental support for QML themes (alpha state);
- added simple file templates for new themes;
- move theme editor to own dialog;
- move theme specific actions to context menu;
- added ability to install and export themes (Plasma Package ZIP);
- some other improvements and fixes.
7 years ago
4.1.4 (01.11.2013):
- fixed week number not being updated;
- added missing title of "Insert Component" dialog.
4.1.3 (27.09.2013):
- ensure that component values are always up to date;
- adjust timestamp for time zone offset;
- do not allow for accidental nesting of components in editor;
- added option to hide date in Train Clock theme;
- added workaround to ensure that hands of SVG Clock have correct initial positions as soon as possible.
4.1.2 (01.06.2013):
- ensure that center of SVG Clock theme is always valid;
- improve resizing in vertical panels.
4.1.1 (25.05.2013):
- fixed WYSIWYG editor for HTML themes;
- fixed missing dialog for "Insert Component" actions.
4.1 (15.05.2013):
- added SVG Clock theme (analog clock that uses Plasma theme);
- added experimental support for QML themes (alpha state);
- added simple file templates for new themes;
- move theme editor to own dialog;
- move theme specific actions to context menu;
- added ability to install and export themes (Plasma Package ZIP);
- some other improvements and fixes.
Emdek
8 years ago
I will try to find some free time to test it during this week, in case of no activity feel free to send me message (here, by email, on github or elsewhere).
Well, it is already scriptable, it is just not so trivial after themes become more advanced. ;-)
Report
Emdek
8 years ago
I'm unable to open that scripting console, it is application name or binary name, or there is some special command known only for KRunner (hopefully not translated...)?
And I can only tell that your approach is still wrong, here is example configuration file layout with two formats (test and test2):
http://paste.kde.org/614522/
Report
nowardev
8 years ago
http://wstaw.org/m/2012/11/26/plasma-desktopwu5011.png
or if you can't there is a shell command that works for sure , type in konsole :
qdbus org.kde.plasma-desktop /MainApplication showInteractiveConsole
there is no problem for delay cuz i have already done plasma panels collections 2 it would say i will use your widget when we will be able to script it ;)
Report
Emdek
8 years ago
There are big chances that old one doesn't react at all or does it improperly in case of configuration changes done from outside.
And if no one want to maintain this package in Debian then it should be dropped, since it makes even more harm to have so outdated one there...
Report
nowardev
8 years ago
it's faster if you do because i can't undestand your way.
i have tested this : with and without the array Configuration
you could just try it out : alt f2 >> desktop console => copy and paste the code it's not a pain it just add an empty panel and it tries to add your widget with some config
var panel = new Panel
panel.location = 'bottom' //panel.location = 'top'
var applet = panel.addWidget("adjustableclock")
applet.currentConfigGroup = new Array('Configuration')
applet.writeConfig("timeFormatNames","Default 2")
applet.writeConfig("timeFormatStrings",'<html><body><div style="text-align:center; margin:5px; white-space:pre;"><span style="color:#ffffff;"><b style="font-size: 27px; "><span style="font-size: 32px; "><span style="font-family:\'Ubuntu\';">%d %x</span><span style="font-family: Ubuntu; font-size: 40px; "> </span></span><big style="font-size: 56px; "><span style="font-family:\'Ubuntu\';">%H:%M</span></big></b></span></div>')
panel.reloadConfig()
Report
pallegro
8 years ago
Report
quinnuendo
8 years ago
html:
<div style="text-align: center; font-family:Droid Sans">
<span class="gen shadowed clock">%h</span><br>
<span class="gen shadowed clock" style="font-size:12px">o o<br></span>
<span class="gen shadowed clock">%m<br></span>
<span class="gen shadowed" style="font-size: 40px;">%!$w</span><br>
<span class="gen shadowed" style="font-size: 30px;">%d/%M</span>
</div>
css:
.shadowed {text-shadow:black 0.04em 0.04em 0em, #bbf 0em 0.0em 0.3em}
.clock {font-size: 60px; font-weight:bold}
.gen {color:#ccc}
Could be a bit more elegant with the font sizes not hard coded, but it works. The important part anyway are the relative sizes, since the plasmoid gets resized to fit in the sidebar.
Report
gldvorak
8 years ago
<div style="text-align: center; color:#FFFF00;">
<span style="font-size: 20px;"> %h:%m:%s %p </span>
<span style="font-size: 14px;"><br>%!$w, %!$M %!d, %Y</span>
<span style="font-size: 12px;"><br>%!$z UTC %!z</span><br>
</div>
This displays on three lines and shows only the time zone city.
Report
gldvorak
8 years ago
Report
gldvorak
8 years ago
<span style="font-size: 20px;"> %h:%m:%s %p </span>
<span style="font-size: 14px;"><br>%$w,</span>
<span style="font-size: 14px;"><br>%$M %!d, %Y</span>
<span style="font-size: 12px;"><br>%$z UTC %!z</span><br>
</div>
Note that I use nonbreaking spaces to keep from having line wraps where I do not want them. I use a rather tall panel where this clock is located.
Report
gldvorak
8 years ago
Returns the letter—Size changes as time zones are changed!
%a b B c C e f F g G i I j J k K l L n N o O P q Q r u v V x X y
%$a b B c C e f F g G i I j J k K l L n N o O P q Q r u v V x X y
%!a b B c C e f F g G i I j J k K l L n N o O P q Q r u v V x X y
Useful codes—Size changes as time zones are changed, except where noted!
%A or %$A Fri, Sep 14, 12 09:44 PM
%!A Fri, 09/14/12 09:44 PM
%D or %$D or %!D—258 Days into the year
%d or %$d or %!d—14 Day number, two digits
%E or %$E or %!E—returns nothing!
%H or %$H or %!H returns nothing!
%h or %$h—09 Hour
%!h—9 Hour
%M—09 Month number, two digits—Size does not change
%$M—Month name—Size does not change
%!M—9 Month number, one digit—Size does not change
%$m or %m—05 Minute, two digits—Size does not change
%!m—5 Minute—Size does not change,
%$p or %p—am/pm
%$R or %R or %!R—09:44 AM/PM
%$S or %S or %!S —nn:nn AM/PM,
The values change with the time zones but do not correspond with anything! The size does not change.
%$s or %s or %-S or %~s or %+s—15 Seconds, two digits
%!s—9 Seconds, 0ne digit
%$T or %T—Fri, Sep 14, 12; Short weekday, short Month name day number, two digit year
%!T—Fri, 09/14/12; Short weekday, Month number/Day number/Two digit year
%$t or %t—09:34:47 PM; HH:MM:SS AM/PM
%!t—09:34 pm; HH:MM AM/PM
%$U or %U or %!U—Seconds since the epoch—Size does not change.hm,,
%$W or %W or %!W—week number—Size does not change.
%$w—Tuesday; Long weekday name—Size does not change.
%w or %!w—6 Day of weeknumber, Sunday=0—Size does not change.
%$Y or %Y—Year number, four digits
%!Y—12 Two digit year.
%$Z or %Z—Country/City: HH:MM AM Fri, Sep 14, 12;
List of country name/city name: Hour:Minute AM/PM Short day name, Short Day name, Short Month name Day num, two digit year
%!Z—City: HH:MM AM Fri, Sep 14, 12;
List of city name: hour:minute AM/PM Short day name, Short Day name, Short Month name Day num, two digit year
%z or %!z— -7;UTC offset
%$z—America/Los Angeles; Country name/city name
Report
Emdek
8 years ago
Clock always tries to first calculate maximum results width for placeholders with variable lengths (like month name) but that is not always feasible.
Report
timonoj
8 years ago
Report
Emdek
8 years ago
I can only reproduce such behavior using plasmoidviewer, when each instance has own process... Moreover, I can reproduce that also using standard digital clock.
This seems to be limitation of data engine which has no option to align to a second (http://api.kde.org/4.9-api/kdelibs-apidocs/plasma/html/namespacePlasma.html#aab29f15efa645a5f644650f2f7f44857) but uses milliseconds internally - this could lead to such slight differences (depending when clock instance was connected to data engine).
And since kdelibs are frozen (so it will not be fixed in proper way before KDE 5.x) I can only think about some workaround, like checking milliseconds delay and connecting to data engine in slot called after computed time.
But it is still weird that one is delayed so much inside single process, maybe it was added a bit later and there is some applet(s) that consume that 0.8 second for own initialization? Then removing all clocks and adding them again could help.
Report
cmlr
8 years ago
https://aur.archlinux.org/packages.php?ID=60809
Report
woodsdog
9 years ago
Also, can you help us understand why you went away from the Unix standard strftime placeholders? Those are pretty much universally standard, and referenced everywhere. I'm sure there are good reasons, just curious to what they are.
Report
Emdek
9 years ago
2. There is not enough symbols for all combinations (short and long forms, leading zeros, alternative forms etc.) to make it compatible and fully logical.
Report
woodsdog
9 years ago
I see the menu where I can choose "seconds" or "days" or whatever. However, when coding in HTML, I don't know what they are. I have to generate one with the menu, look at the code details, then put it in my html. It's quite the process.
As a suggestion, it would be very helpful to have a list of these placeholders documented.
Also, how do I do a 3 letter Month? In the drop down, I see month, but it spells it out all the way. I want just a three letter Month.
Thanks again for this widget!
Report
Emdek
9 years ago
Partial documentation (modifiers syntax) is available in README file, currently there is no separate list of placeholders, but you can get them from comments in src/Applet.cpp, in body of method QString Applet::evaluatePlaceholder(ushort placeholder, QDateTime dateTime, int alternativeForm, bool shortForm, bool textualForm).
Report
5er
9 years ago
Other than that, keep up the great work.
Report
Emdek
9 years ago
You can disable substitution for individual placeholders by placing ~ just after %.
I'm also planning to allow to disable current substitution in editor, for advanced users (as it was added to do not scary beginners).
You can also follow changes in git repository, as some nice features should be there soon (currently most interesting change is removal of requirement that repainted can be done only on time change, so use of CSS transitions, animations and such is now possible). ;-)
Report
Emdek
9 years ago
of animations and other stuff that requires more often repainting etc.
I've initially checked how it works in QtWebKit (using rekonq) and I see some bugs (maybe wrong transformations order?) however 3D transforms itself are possible.
http://www.webkit.org/blog/386/3d-transforms/
Those who want to experiment with it can start testing it using QtWebKit based browsers (rekonq, Arora) to test it first, it could be good idea to announce attempt first, so we don't end with duplicate efforts (my plans are train clock and rotating rings based one).
Report
5er
9 years ago
Report
Emdek
9 years ago
More important thing is probably second entry in TODO, possibility to create really scripted themes, with API to get data (easier to use than placeholders) and to decide when repaint by the script itself. This is planned for next release.
Report
5er
9 years ago
Report