Compare commits

...

471 Commits

Author SHA1 Message Date
fe2f147d45 update requiremets 2015-08-16 15:52:31 +03:00
6c42b3dc7e update requirements 2015-08-16 15:35:42 +03:00
000708b6a2 renaming 2015-08-16 15:29:51 +03:00
4300e1d18a add files to build packages 2015-08-16 15:27:19 +03:00
c244166016 add note to readme 2015-05-22 01:03:49 +03:00
e3cb503b2e bump readme 2015-05-22 01:02:56 +03:00
fba0a91eb9 rename package to *-git 2015-05-22 00:53:18 +03:00
a098c9d2c4 rebuild package to git version 2015-05-22 00:48:28 +03:00
4a6ec00b20 drop kf5, create branch for 2.2.1 2015-05-19 21:53:19 +03:00
7ae90bf82d release 2.2.1 2015-02-24 00:14:04 +03:00
bcf26156d1 * implement interval to extupgrade (ApiVer = 1) (fix #45)
* improve extscript logic
* add cache values to both of them
2015-02-24 00:02:59 +03:00
4cee2535ee add desktop files reconfiguring
fix target on cmake builds
improve cmake version check logic
2015-02-17 03:37:06 +03:00
e1ebd87871 update pkg logic 2015-02-16 13:12:38 +03:00
4cef889fd4 implement is-active properties 2015-02-16 03:45:49 +03:00
d785839d1d remote sensors from deplist 2015-02-16 02:20:22 +03:00
cf6ccc293b update readme 2015-02-16 02:13:37 +03:00
e9ee6150c1 release 2.2.0 (KF5 developer preview) 2015-02-15 19:14:19 +03:00
30577e91ec changes in notifications 2015-02-14 21:25:18 +03:00
e5006ed2d6 fix update pkg
add notify flag
2015-02-13 08:11:56 +03:00
3bd73d0458 fix cppcheck warnings
improvements of interaction with items
2015-02-12 02:57:05 +03:00
4dbf5150fc update supporting files 2015-02-11 07:38:30 +03:00
061244b1d0 update translations
add notifications
edit resizing
fix reading ps
some fixes
2015-02-11 05:04:56 +03:00
8055647f34 * remove panel hidding functions (comment in)
* remove ps calls from DE. Now processes are reading from /proc
* remove qdbus calls from DE. Now mpris information is reading using
  native DBus functions
* update graphicalitem in KDE4

TODO:
* widgets resizing
* tests and optimizations
* update DE configuration for KDE4 package
2015-02-10 18:50:36 +03:00
d74c7cb030 add forgotten freeing 2015-02-09 14:09:18 +03:00
f5006af977 add remove button 2015-02-09 14:08:51 +03:00
16d7d2bc20 update DP
update aw-kde4
2015-02-08 12:57:25 +03:00
6e27717dc8 rollback gi 2015-02-07 01:29:22 +03:00
d1f1d79752 Merge branch 'master' of github.com:arcan1s/awesome-widgets
Conflicts:
	sources/awesome-widget-kde4/graphicalitem.cpp
2015-02-07 01:28:14 +03:00
862d14dc0e udpate aw-kde4 2015-02-06 16:22:31 +03:00
685c0390b4 end porting core part
todo: panels control, windows preview
2015-02-05 12:31:34 +03:00
35a5aa6a6c fix memory leak 2015-02-05 05:32:38 +03:00
681fec4cac start work on desktop panel 2015-02-05 04:26:19 +03:00
bb88892125 add notifications
edit widget.qml
fix bug in monitor
2015-02-04 05:20:00 +03:00
f01fd96cf6 add support of smartctl (TODO remove qdbus calls)
end work on awesome-widget (prerelease state)
2015-02-04 04:17:40 +03:00
eac1319889 some work on tooltip 2015-02-03 08:33:46 +03:00
86d4bd76ea some fixes 2015-02-03 02:01:43 +03:00
27fd4e8f1e end work on awesomewidget
edit setdatabysource method
2015-02-02 08:21:56 +03:00
9611677254 some updates 2015-02-01 03:34:16 +03:00
a61cff7caa remove fucking connector 2015-01-31 07:20:22 +03:00
4966a0a5bf some work on configuration interface
correct file locations
create configuration slots
TODO сделать этот ебаный коннектор или выкинуть его нахуй
2015-01-31 06:10:21 +03:00
b1abf74e89 work on interface 2015-01-30 08:35:22 +03:00
16170c72b0 move back desktop files
add widget configuration
append plugin slots
rewrite KF5 and DE to use ExtUpgrade class
some fixes
2015-01-30 02:43:31 +03:00
c5a0ba3796 end work on core part. Now widget works normally
(except for configuration and appearance)
2015-01-28 07:53:31 +03:00
cce37d66e5 dataengine fixes 2015-01-25 17:26:54 +03:00
c850aaf2a3 some work on porting 2015-01-24 19:16:00 +03:00
43efbbba72 minor changes 2015-01-23 08:36:27 +03:00
3a0cbee39f realize keys methods 2015-01-21 08:06:48 +03:00
213595b3c1 split plugin to classes
rewrite extscripts
fix building
implement several methods
2015-01-20 01:08:21 +03:00
f5fbb80d91 work on plugin 2015-01-19 08:31:48 +03:00
0288e6e1eb edit translations build 2015-01-18 04:16:40 +03:00
6667b45919 edit translations 2015-01-17 23:24:14 +03:00
9ff07241b1 implement general methods to plugin 2015-01-17 02:30:16 +03:00
cc7b7b5659 create skel for aw 2015-01-16 05:27:41 +03:00
3e709f549d port dataengine to kf5 2015-01-16 04:09:39 +03:00
adcf6c942f start work on porting 2015-01-15 18:46:56 +03:00
7415a6830f release 2.1.0 2014-12-31 01:04:50 +03:00
c23846f7b4 update readme 2014-12-28 16:49:43 +03:00
e957a2723b Merge branch 'master' of github.com:arcan1s/awesome-widgets 2014-12-26 02:31:29 +03:00
5369bbda65 remove script 2014-12-26 02:31:13 +03:00
6a8842163e update text in version.h 2014-12-25 00:14:03 +03:00
56e7ee3d11 approve translation 2014-12-24 00:05:40 +03:00
ce72c46cd9 Merge pull request #40 from underr/master
pt_BR translation
2014-12-24 00:00:59 +03:00
78ab09c1da pt_BR translation 2014-12-23 14:21:32 -02:00
498a965488 add skel to create rpm and debs 2014-12-23 10:32:18 +03:00
d1d4a97fa4 apply fix to extscripts 2014-12-22 06:19:25 +03:00
8f1e8606d4 update Ukrainian transaltion 2014-12-18 01:37:06 +03:00
b682c6dbd6 update Spanish translation 2014-12-16 09:36:02 +03:00
c8bf047e76 implement #36
fix (?) initialization
update translations
2014-12-15 02:41:39 +03:00
a336d9aa04 fix #37 2014-12-12 01:04:31 +03:00
2272b0c2c0 auto commit 2014-12-12 00:02:48 +03:00
0533ee8cd5 add #38 2014-12-07 03:04:35 +03:00
be792a4c5a add graphical settings 2014-12-03 04:33:13 +00:00
997e13706b add comments to template 2014-11-29 22:48:52 +03:00
6bcb6798a2 fix #37 2014-11-28 21:02:45 +03:00
4e3593a2a9 fix build 2014-11-25 04:00:01 +03:00
4b471593c7 update changelogs 2014-11-24 09:36:17 +03:00
695a85be29 update translations, implement copy method 2014-11-21 05:13:01 +03:00
bae34ba898 update translations, version and readme 2014-11-21 03:28:11 +03:00
93db63b16c * fix naming
* fix notification
2014-11-20 06:13:09 +03:00
0cd2ff6813 rewrite all ui interfaces t oKDE standards 2014-11-20 06:01:56 +03:00
222db43dc1 update extscripts and dp ui files to kde standards 2014-11-20 04:21:24 +03:00
e4be3b2e02 simplify custom script class
remove QGraphicsView border
2014-11-20 04:07:14 +03:00
543e39a7ac Merge branch 'master' of github.com:arcan1s/awesome-widgets 2014-11-20 03:18:53 +03:00
ca60a85241 update graphicalitem 2014-11-19 16:19:23 +03:00
2c3c575493 * add .desktop suffix to files if they have not
* remove frameshape
2014-11-19 15:04:10 +03:00
5f37a9d8c7 fix direction 2014-11-19 12:28:43 +03:00
c3420a8393 some simplification of graphicalitem 2014-11-19 12:08:54 +03:00
5ce3a5c213 fix configuration 2014-11-19 11:14:55 +03:00
179a97b01b implement tooltip to configuration interface 2014-11-18 12:58:56 +03:00
f0c79a4dab implement contextual menu to listWidgets 2014-11-18 11:54:23 +03:00
f56f319075 some update on graphical items 2014-11-18 06:56:22 +03:00
f7b7d5b6b4 fix run 2014-11-17 17:38:02 +03:00
3193de1a85 implement ExtScripts configuration 2014-11-17 17:04:31 +03:00
8cdfdd4e81 start work on porting extscripts to *.desktop configuration 2014-11-17 10:29:09 +03:00
16d7ca2005 update extscript to inherit from QDialog 2014-11-17 10:01:57 +03:00
e54ab7e1a5 small update 2014-11-16 22:37:55 +03:00
a335979830 implement grapicalitem settings 2014-11-16 13:33:09 +03:00
8460d07875 implement tryDelete() method 2014-11-16 11:40:16 +03:00
5ec26c7747 implement graphical item to aw (except for configuration) 2014-11-14 07:16:55 +03:00
8aafdb6fc4 update gi to use desktop conf files 2014-11-14 04:19:53 +03:00
9eedaf246f rename ring to circle 2014-11-13 12:03:48 +03:00
e7714042bb yet another fix margin 2014-11-13 11:21:51 +03:00
0f4bbbfba1 some intermediate commit 2014-11-12 05:16:05 +03:00
7069758b73 add colorsettings to DP tooltip
remove deprecated settings from AW
2014-11-10 01:53:27 +03:00
bbc9d72606 fix margin 2014-11-10 00:51:43 +03:00
b53b1111f9 fix tooltip to DP 2014-11-09 08:22:05 +03:00
64fdc4bebe move tooltip to proxydiwget 2014-11-09 04:50:22 +03:00
583046e195 update translations 2014-11-08 18:41:33 +03:00
71b3a4e6ab implement #35 2014-11-07 05:36:36 +03:00
4b90fac0c4 implement #28 2014-11-07 04:56:32 +03:00
2fa0acf13d some intermediate commit 2014-11-06 20:42:53 +03:00
0f9d2e52ab fix #24 2014-11-04 00:06:22 +03:00
373bab14db some edit of external scripts 2014-11-04 00:04:13 +03:00
7e095c4349 implement script function 2014-11-03 06:33:39 +03:00
a4af7ffc07 some improvemance of external scripts 2014-11-03 05:03:14 +03:00
0ab4878b22 update translations 2014-11-01 23:26:47 +03:00
1748829901 implement script feature to the widget 2014-10-31 07:20:14 +03:00
6a41fa2b8a implement script feature to dataengine 2014-10-31 06:13:49 +03:00
2cd04e1f7f end work on extscript class 2014-10-31 04:43:17 +03:00
0a61d926f8 create properties 2014-10-31 01:54:35 +03:00
45c248b101 some intermediate commit 2014-10-30 01:05:09 +03:00
6a784d2e28 remove install script from git pkgbuild 2014-10-27 04:33:16 +03:00
13023a4985 add workaround for #34 to AW 2014-10-27 04:20:13 +03:00
6463ed3bf7 add pkgbuild-git 2014-10-26 17:06:39 +03:00
5bf3847bc9 add checkupdates function 2014-10-15 16:41:31 +04:00
4fc2e238bd fix regexp matching 2014-10-14 05:15:13 +04:00
c18bb61521 implement about window 2014-10-12 15:01:07 +04:00
9e82210463 implement autoupdate function to aw (see #32) 2014-10-11 03:38:19 +04:00
171d545562 add skel for #32 2014-10-10 23:36:11 +04:00
c6fa1f2a79 update tasks 2014-10-08 22:39:39 +04:00
14cee9dbc7 release 2.0.5 2014-10-05 00:20:09 +04:00
5759273e4c add workaroud for resizing 2014-10-04 01:17:34 +04:00
4387bb1e76 some fixes which was introduced with the latest patches 2014-10-02 06:13:10 +04:00
03af5f0e49 upd task, add ability to use $ symbol over $$ 2014-10-02 05:10:02 +04:00
7f6afbcb4d add resizing 2014-10-01 03:15:28 +04:00
4a320bc5d6 more correct destuction 2014-10-01 02:59:47 +04:00
29d34525a3 fix plasma crash caused by label destruction 2014-10-01 02:57:06 +04:00
0ab74b493c fix #31, update submodules 2014-10-01 02:33:10 +04:00
952fa97fcc Merge branch 'master' of github.com:arcan1s/awesome-widgets 2014-10-01 02:02:13 +04:00
677ed1ab5e fix update netdev 2014-10-01 02:01:18 +04:00
deb0b3bdbb chenge forceupdate logic 2014-09-29 00:59:19 +04:00
20c85f0d42 fix number of issue 2014-09-28 23:12:33 +04:00
f9a37f0cb2 edit echange log, fix #20 2014-09-26 01:43:22 +04:00
0c8013c26b add tooltip bottom 2014-09-26 01:41:27 +04:00
6b9e19ed58 Merge branch 'master' of github.com:arcan1s/awesome-widgets 2014-09-25 23:25:08 +04:00
432ab694fd update changelog 2014-09-25 23:24:33 +04:00
c506183247 fix battery tooltip 2014-09-24 09:51:46 +04:00
fe822518d5 release 2014-09-21 21:50:03 +04:00
1f9e8221f0 release 2.0.4
battery fixes
2014-09-21 21:49:02 +04:00
d7e93e83a3 release 2.0.3 2014-09-21 21:23:26 +04:00
17c3383616 fix aw geometry 2014-09-21 20:43:27 +04:00
830bab7cb6 add support of several $bat tags. Update translations 2014-09-21 20:19:57 +04:00
0b3832cc32 some work 2014-09-18 21:57:59 +04:00
e64ca5ec08 update TODO 2014-09-16 08:54:08 +04:00
84b93098f2 release 2.0.2 2014-09-16 00:04:31 +04:00
17bef06c98 some fixes, prepare to release 2.0.2 2014-09-15 20:28:09 +04:00
db7573de80 update DP translations 2014-09-15 10:04:57 +04:00
4907496a2e fix text edit dp configuration interface 2014-09-14 00:01:23 +04:00
43daae5529 edit temp conversion 2014-09-13 03:06:00 +04:00
1d1fe469f8 rewrite DP configuration interface 2014-09-12 19:29:31 +04:00
99049164be fix cpu* tags
fix notifiations
2014-09-12 00:03:18 +04:00
f61948d9b3 fix (?) notifications 2014-09-11 00:00:08 +04:00
ea54c54d42 add fan tags 2014-09-10 23:51:14 +04:00
c843c5260d Merge pull request #23 from Lemueler/master
Add Chinese translation for awesome-widgets
2014-09-10 21:52:44 +04:00
a8912074dd Modify Chinese translations 2014-09-10 22:56:21 +08:00
2be0edcb40 Add Chinese translations 2014-09-10 22:40:32 +08:00
fcf7ca233f release 2.0.1 2014-09-10 11:18:36 +04:00
aa127574c4 fix label edge's shading 2014-09-09 03:12:20 +04:00
d72f827984 fix empty values 2014-09-09 02:29:59 +04:00
b7d607bfcc add support of custom interfaces 2014-09-09 02:09:58 +04:00
c727947557 update install script 2014-09-09 00:39:02 +04:00
6864e5bda0 update screenshots and link 2014-09-09 00:34:20 +04:00
4babb3ba04 release 2.0.0 2014-09-09 00:19:20 +04:00
e0aadc48c4 fix acoffline variable 2014-09-09 00:00:57 +04:00
18b6fc6eef update changelog 2014-09-08 02:22:50 +04:00
5406f6f66f update readme 2014-09-08 01:57:18 +04:00
ab966504cc update translations, fix layout, some edit of formating
prepare to release 2.0.0
(I plan to update all translations with next releases)
2014-09-08 01:52:40 +04:00
ce761db924 change layout to gridlayout
remove deprecated functions
2014-09-08 00:36:55 +04:00
f91c80b5b1 rollback taging 2014-09-08 00:09:41 +04:00
97fbb4acc1 update install scripts 2014-09-07 19:40:12 +04:00
554354ce36 update trasnaltions 2014-09-06 16:06:47 +04:00
c007fabe12 some fixes 2014-09-06 15:43:53 +04:00
3b11e39e99 change color 2014-09-05 19:43:04 +04:00
653cc4fd84 add button to insert tag 2014-09-05 11:47:05 +04:00
eae742c559 update translations 2014-09-05 11:22:56 +04:00
e339f5aa1a start porting translations 2014-09-05 11:16:56 +04:00
21a1d8cd1b update to upstream changes 2014-09-04 21:20:44 +04:00
0ea17555b1 update to use cfontdialog 2014-09-04 21:04:44 +04:00
eec87be7a2 add html text interaction 2014-09-04 03:32:37 +04:00
0cd293c4c3 add support of battery tooltip 2014-09-03 22:14:50 +04:00
e5c70b9535 more correct interaction with DataEngines 2014-09-03 15:08:33 +04:00
3ef68f7a43 fix tooltip adding processing 2014-09-03 14:58:01 +04:00
1fbc9e315e update formating 2014-09-03 14:52:52 +04:00
28dafcb721 add ex name 2014-09-02 22:52:17 +04:00
4164c7fe04 commit before renaming 2014-09-02 22:49:17 +04:00
bc8aadc17b fix temperature 2014-09-02 22:20:43 +04:00
cd48ac8245 fix cpu reading 2014-09-02 22:16:13 +04:00
0751d080eb move back layout settings 2014-09-02 22:06:01 +04:00
6c6cfe9a04 fix time and uptime 2014-09-02 21:55:23 +04:00
b61d514cb2 add notification module
fix definition of network deivce
2014-09-02 04:30:43 +04:00
a5c352bc06 add contextual actions
fix icons
2014-09-02 03:56:34 +04:00
54174974b1 edit supported information
update desktop panel to tag changes
2014-09-02 03:29:17 +04:00
fd81fda9a1 fix tooltip
fix memory
remove layout settings
more correct parsing
2014-09-02 02:42:34 +04:00
c69957e905 add configuration interface slots 2014-09-02 01:10:27 +04:00
a65f4cb02f commit before tests 2014-09-01 20:58:47 +04:00
3b89b30a98 fix formating 2014-09-01 12:57:10 +04:00
5921bd4c1d add tooltip 2014-09-01 12:35:43 +04:00
5b26d835df end work on deinteraction module 2014-09-01 03:49:00 +04:00
38c4d3bfaf work on data update 2014-08-31 20:21:06 +04:00
eac50a8799 plasmoid fixes 2014-08-31 18:45:43 +04:00
6e5a068ad2 add battery dataengine 2014-08-31 18:35:35 +04:00
7f639805e6 add connectToEngine() function 2014-08-31 18:07:18 +04:00
8a6650f833 add findKeys() function
it's time to drink!
2014-08-30 18:17:37 +04:00
96cfeb520d add keys 2014-08-30 18:14:56 +04:00
7cd80e14a7 create initialization skeleton 2014-08-30 17:40:25 +04:00
b55d453aeb add checkboxes to tooltip window 2014-08-30 16:30:58 +04:00
7eb5197318 add configChanged() function 2014-08-30 16:17:42 +04:00
e603ad9977 add configAccepted() function 2014-08-30 15:56:05 +04:00
068a976499 add createConfigurationInterface() function 2014-08-30 15:24:19 +04:00
5b44fa5c75 starting of porting ptm to C++ 2014-08-29 10:50:37 +04:00
87614084ab more pretty deconfig page 2014-08-29 10:22:47 +04:00
8ccad0b86c more temperature units: Reaumur, cm^-1, kJ/mol, kcal/mol (really, I use
cm^-1)
2014-08-29 02:19:34 +04:00
0240dee6ea rewrite advanced config to better view 2014-08-29 01:59:14 +04:00
81105fb12d remove dublicates 2014-08-28 23:00:08 +04:00
93abb86340 update to use submodules 2014-08-28 15:35:57 +04:00
5584ba0e9f update to use submodules 2014-08-28 15:21:41 +04:00
2c35031549 add toggle panel configuration 2014-08-28 12:28:52 +04:00
d28d7156ce add raw support to hide panels 2014-08-28 03:06:48 +04:00
123cfcb475 fix according to netctl#9 2014-08-09 20:21:30 +04:00
7fa541bc06 rewrite dataengine to use task 2014-08-07 19:44:29 +04:00
03574461a9 update notifications 2014-08-02 18:36:12 +04:00
f588c9af8d update files 2014-08-02 18:21:39 +04:00
ee39ac9203 add background settings to the tooltip 2014-08-02 17:49:25 +04:00
5ea8c97094 add mpris support 2014-08-02 11:54:57 +04:00
edf3a72564 edited todo list 2014-07-30 19:57:23 +04:00
b9c9aac686 fix twinkle of desktop panel 2014-07-23 17:58:01 +04:00
7dd7251a45 fixes in desktop-panel 2014-07-22 09:49:55 +04:00
1ccbc264ed fix naming 2014-07-21 22:45:22 +04:00
334189b8a1 prerelease 1.11.0 2014-07-21 22:02:54 +04:00
6c7d6a5443 update russian readme 2014-07-09 18:54:54 +04:00
e37f2a7190 add support of tags to cmd 2014-07-09 13:50:46 +04:00
baf21549d5 update eng readme and changlelog 2014-07-09 13:32:33 +04:00
07c2abd5bc update translations 2014-07-09 13:14:48 +04:00
2ea73b2261 add support of desktop label to ptm 2014-07-09 13:12:52 +04:00
7c3b47693e update translations 2014-07-09 10:53:54 +04:00
0fe67ce323 initialization of translation files 2014-07-09 10:34:38 +04:00
bfb7d72faf change lineedit to combobox 2014-07-09 09:59:04 +04:00
662b952961 ended work on ptm-desktop-panel 2014-07-09 09:42:58 +04:00
a81cbe3d9c add interaction with craphical interface 2014-07-09 08:55:33 +04:00
0462bb186e Started work on ptm-desktop-panel widget 2014-07-09 01:00:24 +04:00
9985fe6260 add desktop section to the sysmon 2014-07-08 19:08:08 +04:00
11a6f01ae3 prepare to release 1.10.3
+ added ability to set transparent background
2014-07-08 10:12:20 +04:00
43ee40a65d release 1.10.2 2014-06-11 04:23:46 +04:00
f9eb27964f release 1.10.1 2014-06-10 10:44:34 +04:00
bab9f58b35 try again fix of initialization 2014-06-10 10:42:15 +04:00
608908fd02 fix checking of qmmp 2014-06-10 09:57:30 +04:00
178bbd0bc0 fix first initialization 2014-06-10 09:42:21 +04:00
f8a02a48ac fix 2014-06-10 09:30:31 +04:00
cf39fba9c2 fix error in ps dataengine 2014-06-10 09:27:26 +04:00
6643852822 edit desktop files 2014-06-10 07:59:05 +04:00
7145a1d33e release 1.10.0 2014-06-09 16:57:25 +04:00
a3c1f4ea66 fix force update function 2014-06-09 16:55:51 +04:00
a6ddd53308 small fix 2014-06-09 15:58:04 +04:00
744f3bc04b add setKeys() function 2014-06-09 15:57:15 +04:00
afdf86f03a update archives 2014-06-09 15:41:30 +04:00
8f2784d2a2 prepare to release 1.10.0 2014-06-09 15:41:01 +04:00
926da88c10 fix ps 2014-06-09 15:39:55 +04:00
ea287c21b1 fix player 2014-06-09 15:34:11 +04:00
c0561a95e0 fix hddtemp 2014-06-09 15:20:22 +04:00
b7d1802ca8 fix gpu and gputemp 2014-06-09 15:17:31 +04:00
c659f16d7e fix custom command 2014-06-09 15:10:51 +04:00
79cbfc4b32 fix pkg 2014-06-09 15:04:40 +04:00
61e2a380b9 add support of multithreading to all functions of dataengine 2014-06-09 13:35:52 +04:00
64bc89ba75 edit changelog (prerelease 1.10.0?) 2014-06-09 03:35:58 +04:00
926d112d22 add support of multithreading to dataengine (only for custom command
now)
2014-06-09 03:23:14 +04:00
e205664fec small fix pt_BR files 2014-06-09 01:48:45 +04:00
5d13c8289f Merge branch 'master' of https://github.com/underr/pytextmonitor into underr-master
Conflicts:
	README.md
	sources/ptm/po/pt_BR.po
2014-06-09 01:37:44 +04:00
7ac5d68b02 Fixed 'u's problem 2014-06-08 14:53:13 -03:00
69b5bdec66 Updated Brazillian Portuguese translation and README 2014-06-08 14:51:24 -03:00
5ce7aac9dd edit header of uk.po 2014-06-06 11:48:52 +04:00
80eb7983fc update Ukrainian translation 2014-06-06 01:24:44 +04:00
7e2b1384ae edited script 2014-06-05 19:30:23 +04:00
d573cc7491 update fr translation 2014-06-05 19:25:09 +04:00
b380000d2f Merge pull request #18 from Mermouy/master
fr-translation update
2014-06-05 19:06:09 +04:00
50d96574f5 fr-translation update 2014-06-05 16:19:09 +02:00
d6819e3771 update spanish translation 2014-06-05 10:25:20 +04:00
a54b3064fe add debug information 2014-06-04 22:55:29 +04:00
a0288bcf96 edited readme and changelog 2014-06-04 22:53:51 +04:00
f1e22f122e add support of stretch 2014-06-04 22:49:47 +04:00
52f85836a2 edit size of fields in configuration interface 2014-06-04 16:32:54 +04:00
2ad638c158 edit changelog 2014-06-02 16:00:55 +04:00
cebf3b9aea add support of debug to widget 2014-06-02 15:59:11 +04:00
e32a37043a debug settings for dataengine is read now from environment 2014-06-02 14:44:48 +04:00
246430dc28 small edit of PKGBUILD 2014-06-02 14:29:35 +04:00
dd4471a0d2 fix typo 2014-06-02 14:18:48 +04:00
31c612cfd2 add debug support in DataEngine 2014-06-02 14:16:18 +04:00
2201f4d4a2 remove runtime libraries from dep list, since they aren't needed 2014-06-02 12:16:29 +04:00
886e24d4af add double quotes 2014-06-01 23:34:53 +04:00
fbf5f649ee update Ukrainian translation
fix typo and errors in Russian texts (thanks to Viktor Slobodyan)
2014-06-01 23:29:28 +04:00
7fc7b68358 added support of $hddtotmb and $hddtotgb tags 2014-05-31 14:12:04 +04:00
9904e5d6c6 fix typo 2014-05-29 18:17:15 +04:00
e10f3396b9 added ability to use vertical layout 2014-05-29 18:13:32 +04:00
25ff5a9189 fix charset 2014-05-29 00:54:43 +04:00
41b1282488 edited readme 2014-05-29 00:42:38 +04:00
5d46988745 small fix 2014-05-29 00:33:23 +04:00
71823471cc fix bug with saving settings
added 'enable popup message'
2014-05-29 00:30:23 +04:00
fe580ef806 removed util.py
removed createNotifyrc function
2014-05-28 23:27:05 +04:00
b1f8340774 fix version 2014-05-28 22:43:19 +04:00
e868b03454 fix icons 2014-05-28 22:23:49 +04:00
632adfa54c refactoring of configuration interface 2014-05-28 21:52:55 +04:00
4476ec8e45 fix default tab in configuration interface 2014-05-28 20:27:17 +04:00
b4f7b6e65a updated readme 2014-05-28 18:07:11 +04:00
77349e797f small changes in supporting scripts 2014-05-28 10:24:26 +04:00
e7b6e4a3bf added support of disable ooption to dataengine 2014-05-27 16:15:49 +04:00
3d8f88d935 added support of disable option to dataengine 2014-05-27 15:52:08 +04:00
1eed0f458c update notification for clementine 2014-05-27 12:09:41 +04:00
9b581a882f updated gui translations 2014-05-27 12:07:03 +04:00
6ba1288c50 moved player settings from plasmoid to dataengine
try to fix creating a lot of zombies
2014-05-27 09:11:53 +04:00
926c283338 updated changlelog 2014-05-27 01:31:32 +04:00
8519eb51bd added create_diff
+added tags $*tot*
2014-05-27 01:30:20 +04:00
f05b256306 updated changelog 2014-05-26 12:22:00 +04:00
6fd7bad8f9 changed from md readme to html 2014-05-26 12:18:39 +04:00
6f4ecbd107 fix typo 2014-05-24 20:27:07 +04:00
9f392c3a19 edited update netdevice 2014-05-24 18:08:03 +04:00
e04430e36c added Ukrainian readme 2014-05-24 17:09:08 +04:00
68759513a9 added Ukrainian translation. Thanks to Виктор Слободян 2014-05-24 16:27:24 +04:00
62164f8229 added support of text update contextual action 2014-05-24 16:06:45 +04:00
7c5e02217b prepare to add updateText function 2014-05-24 14:15:48 +04:00
23cd74132a set pkgcmd combobox untranslatable 2014-05-23 12:08:38 +04:00
5dfb02bf9d removed checking playerName in getPlayerInfo() 2014-05-23 12:04:24 +04:00
2d0a92eec1 fix reading clementine 2014-05-23 11:52:04 +04:00
359e81ff93 yaf of pt_BR translation 2014-05-23 11:48:15 +04:00
1bd80ba786 updated changelog 2014-05-22 11:51:18 +04:00
2a04414600 update readme 2014-05-22 11:49:46 +04:00
fe51e67ba4 added support of clementine to plasmoid 2014-05-22 11:45:20 +04:00
e208be7894 added support of clementine to dataengine 2014-05-22 11:41:39 +04:00
26bf118d50 remove message from install 2014-05-22 03:07:11 +04:00
86da48bbca update readme 2014-05-22 03:06:43 +04:00
d081a64889 edited supporting materials 2014-05-22 02:49:28 +04:00
3d2c09647a update pt_BR translation and fix small typos 2014-05-22 02:46:27 +04:00
c7a99a6d0d Merge pull request #16 from underr/master
Brazillian Portuguese translation
2014-05-22 02:45:35 +04:00
c0a273f9f7 added support of hddtempcmd to GUI
edited readme call
2014-05-22 02:43:54 +04:00
5d724ac688 Brazillian Portuguese translation 2014-05-21 19:18:44 -03:00
8e318a99d0 added support of cmd to dataengine 2014-05-22 01:27:50 +04:00
5c861b3814 release 1.9.0 2014-05-21 19:56:59 +04:00
5cf068875c Merge pull request #15 from Mermouy/master
update fr translation
2014-05-21 19:47:00 +04:00
80366e59bb fr translation 2014-05-21 17:01:15 +02:00
a6a94f0e49 update 2014-05-20 11:13:02 +04:00
6a74802261 fix typo 2014-05-20 11:08:21 +04:00
c44e98d8a1 fix 2014-05-20 11:07:24 +04:00
b872a66088 added status of translation 2014-05-20 11:06:50 +04:00
74d54d6268 fix typo 2014-05-20 10:48:52 +04:00
2ad6d76d4e updated readme (added link) 2014-05-20 10:47:15 +04:00
878dac158e added TRANSLATORS.md 2014-05-20 10:44:51 +04:00
2de09cec32 prepare to release 1.9.0
+ added support of several custom commands
* fix parsing pkg label
2014-05-20 10:07:01 +04:00
90ca8c89f5 added support of several custom commands to dataengine 2014-05-20 09:48:07 +04:00
757d7b703f update Spain translations 2014-05-19 23:05:32 +04:00
5d3e377ffb yet another update readme (hope actual for 1.9.0) 2014-05-19 21:29:10 +04:00
9b5a6908d7 fix typo 2014-05-19 21:23:22 +04:00
f54ba7a6cf updated en readme 2014-05-19 21:22:11 +04:00
7427183981 fix typo 2014-05-19 11:57:06 +04:00
109328e33b rollback fr translation 2014-05-19 11:55:28 +04:00
ec62e93e4e prepare to add support of several custom command 2014-05-19 03:06:29 +04:00
1a6d97800c added hdd speed label 2014-05-19 02:48:00 +04:00
b09e90a0e5 added context menu 2014-05-19 00:59:48 +04:00
c1f18a31bf release 1.8.3 2014-05-12 23:56:52 +04:00
962478a27a release 1.8.2 2014-05-08 00:31:06 +04:00
4857c6658f fix =) 2014-05-03 04:39:44 +04:00
4416298e88 removed unneeded lines in ptm/CMakeLists.txt 2014-05-03 04:38:20 +04:00
a3576275cc Release 1.8.1 2014-04-10 12:20:30 +04:00
9c8be61855 Release 1.8.0 2014-04-09 13:07:58 +04:00
3fece265f4 yae translations 2014-04-09 12:36:10 +04:00
cc26873200 updated translations 2014-04-09 12:34:07 +04:00
2ee6949a59 edited dataengine 2014-04-09 12:22:27 +04:00
1a99c0cb3d small refactoring of de 2014-04-09 11:43:33 +04:00
a0e8f373c0 prerelease (w\o translations)
* hope release 1.8.0 will be tomorrow *
2014-04-09 01:22:15 +04:00
f53179330b edited readme 2014-04-09 00:39:58 +04:00
d1a0597b5f fixed ps 2014-04-09 00:26:22 +04:00
1c58b23fa2 added support of package managers and ps 2014-04-09 00:24:06 +04:00
4c442a7e73 at the end of work on ext-sysmon-1.8.0 2014-04-08 22:47:03 +04:00
3bfeabe537 refactoring of de 2014-04-08 21:25:40 +04:00
cd99f059ff added tags $hddmb, $hddgb 2014-04-07 21:19:32 +04:00
45de9145fb added todo list 2014-04-07 16:34:40 +04:00
21418cdd18 edited changelog 2014-04-07 12:15:16 +04:00
cc1d062fd9 added scrollbar
added AC configuration
2014-04-07 12:13:36 +04:00
c9fd746cd0 fix f*cking formats again 2014-04-07 03:53:31 +04:00
1555b22a3b edited changelog =) 2014-04-07 03:33:04 +04:00
1c772f288a release 1.7.4 2014-04-07 03:31:46 +04:00
16f4f4a8ff set correct choose of devices 2014-04-06 17:44:25 +04:00
c09da99e06 fix bug with reverse() 2014-04-06 17:40:17 +04:00
14fab265cd changes in formatLine variable 2014-04-06 12:02:13 +04:00
9ba7a2b0d5 added support of more than 10 tags 2014-04-05 22:40:38 +04:00
2c4515eb66 edited authors 2014-04-05 19:32:52 +04:00
2e7fa3689b fix typo 2014-04-05 19:24:19 +04:00
831b98f836 release 1.7.3 2014-04-05 19:21:22 +04:00
2295e80b67 commit before merging 2014-04-05 19:17:56 +04:00
f21fea1393 fix bug with none type value 2014-04-05 18:53:22 +04:00
2675beb106 fixed bugs 2014-04-05 18:44:05 +04:00
329457955d edited notifications 2014-04-05 18:11:51 +04:00
614e15d336 configuration window refactoring
type "player_name" is str now
2014-04-05 17:15:21 +04:00
2e93325601 fixed types of variables 2014-04-05 16:30:09 +04:00
6f6af548ef edited main.py 2014-04-05 15:56:03 +04:00
5dc3d4e212 Merge branch 'master' into refactoring
(fr translation)
2014-04-05 13:16:51 +04:00
d8ae9a4c2a Added french .po 2014-04-05 02:34:29 +02:00
ce74cdb2d5 intermediate commit 2014-04-05 02:17:59 +04:00
0fdb7317cc refactoring dataengine 2014-04-04 13:23:21 +04:00
c1d55962a7 start 2014-04-04 05:09:09 +04:00
7353fdfe0f created 'refactoring' branch 2014-04-03 18:48:17 +04:00
032953eac2 edited readme 2014-04-03 14:29:20 +04:00
4766ef5675 added readme directory 2014-04-03 14:28:31 +04:00
1b6c8faf49 edited readme 2014-04-03 13:27:09 +04:00
fc104b4549 change PKGBUILD 2014-04-03 13:19:45 +04:00
975b575db5 edited tooltip in configuration window 2014-04-03 13:17:08 +04:00
4547815549 added russian changelog 2014-04-03 12:58:07 +04:00
73e921a8f5 release 1.7.2
edited readme, changelog
2014-04-03 12:05:07 +04:00
7ee4a5dc9d added tooltip screenshot 2014-04-03 12:02:08 +04:00
89efe6c846 edited screenshots 2014-04-03 11:58:49 +04:00
4218a4da08 added scalling to tooltip 2014-04-03 11:46:51 +04:00
0db909d914 Prerelease 1.7.2 2014-04-03 02:32:56 +04:00
d7cc354432 edited changelog. Release 1.7.1 2014-04-02 23:50:09 +04:00
aab456924f update archives 2014-04-02 23:49:22 +04:00
20c2a4eb6b release 1.7.1
* fix bug with zero values in tooltip
- removed error label
2014-04-02 23:48:44 +04:00
d63b33903a fix configuration window size 2014-04-02 23:30:55 +04:00
fe77fcb2fd small fix 2014-04-02 23:10:07 +04:00
d226629b45 prepare to release 1.7.0
Commit before merging
2014-04-02 23:00:54 +04:00
413dbb2134 removed net-tools from dep list 2014-04-02 01:47:41 +04:00
b11b4d2462 yae 2014-04-02 00:39:52 +04:00
62dd94a294 edited readme 2014-04-02 00:38:54 +04:00
12d506a16d Merge pull request #11 from arcan1s/experimental
Experimental
2014-04-02 00:37:49 +04:00
363c4327ee commit before merging 2014-04-02 00:35:47 +04:00
a716269e79 edited translations 2014-04-01 23:48:53 +04:00
c66b255e8b fix bugs that were found 2014-04-01 23:35:31 +04:00
decf714e74 commit before testing 2014-04-01 22:39:32 +04:00
405dda5144 start work on V.1.7.0
edited ui
2014-04-01 09:59:44 +04:00
0f8b9dc627 updated screenshots 2014-04-01 08:07:40 +04:00
6cf7792f9a release 1.6.1 2014-03-31 20:45:27 +04:00
1df3cf0def added support of several device in hddtemp 2014-03-31 20:41:00 +04:00
59ffe456de try to fix #6 again 2014-03-31 20:00:43 +04:00
9b981cb3f0 added changelog, edited archive 2014-03-31 08:28:32 +04:00
f640eb58d7 edited install 2014-03-31 07:48:55 +04:00
e5648babfc updated archive 2014-03-31 07:45:28 +04:00
c34e569603 updated readme
release 1.6.0
2014-03-31 07:45:06 +04:00
f42fc1e97d changes license, small fixes 2014-03-31 07:35:33 +04:00
b8fd9cd51f fixes 2014-03-31 07:17:15 +04:00
05b65679d9 fixed #6 2014-03-31 02:28:55 +04:00
284243f810 edited russian translation 2014-03-31 01:22:42 +04:00
c0e1f9c094 fixed translations 2014-03-31 01:20:13 +04:00
3545b9c1f1 edited 2014-03-31 01:05:05 +04:00
d66bafa816 added cmake build 2014-03-30 14:18:56 +04:00
e6bbea9c07 fixes 2014-03-30 02:33:42 +04:00
2ddf9082f2 added custom schemes 2014-03-30 02:26:29 +04:00
65a60de9a5 added support alternative time schemes (#8) 2014-03-30 01:36:11 +04:00
1b5e2c7fea edited readme 2014-03-27 20:10:59 +04:00
a3a5ebf2af release 1.5.3 2014-03-27 20:09:46 +04:00
0d3aacdec7 Fixed zero swap and memory 2013-11-19 18:17:59 +04:00
5bcf76a136 Fixed pkgrel 2013-11-18 21:20:40 +04:00
29da9b43f3 Edited README 2013-11-18 21:09:03 +04:00
e2e511f083 Release pytextmonitor 1.5.2
+ added time formats
* fixed definition of conf file for dataengine
2013-11-18 21:02:55 +04:00
ccaca2a725 Edited for 1.5 ext-sysmon 2013-11-18 19:51:57 +04:00
916c32589f Release ext-sysmon 1.5
+ added configuration file
2013-11-18 19:16:38 +04:00
24325e2d3a Edited archives 2013-11-11 09:50:23 +04:00
9569400757 Edited for #6 2013-11-11 09:47:48 +04:00
4d4317150a Edited pkgbuild 2013-11-07 01:45:55 +04:00
946c0ea874 Release ext-sysmon 1.4
* fix #4
2013-11-07 01:38:32 +04:00
ebb828dd4c Edited readme 2013-11-06 04:48:28 +04:00
f5fa6af1bc Release 1.5.1
+ added date andtime support
2013-11-06 04:45:58 +04:00
ddf1de6f8e Yes another edit readme 2013-11-06 01:54:35 +04:00
4689a9054d Edited README 2013-11-06 01:39:33 +04:00
4a841766e8 Release 1.5.0
+ added music player support
+ added copyright
* edited README
2013-11-06 01:33:21 +04:00
7d5803fec8 Release ext-sysmon-1.3
+ added music players support: amarok, mpd and qmmp
2013-11-05 23:01:34 +04:00
60f1cd8c58 Fixed bug with notifyrc 2013-10-22 16:53:49 +04:00
134 changed files with 24642 additions and 2980 deletions

7
.gitignore vendored Normal file
View File

@ -0,0 +1,7 @@
sources/build
sources/usr
*src.tar.[gx]z
*pkg.tar.[gx]z
build
src
pkg

12
.gitmodules vendored Normal file
View File

@ -0,0 +1,12 @@
[submodule "sources/3rdparty/pdebug"]
path = sources/3rdparty/pdebug
url = https://github.com/arcan1s/qtadds-pdebug.git
[submodule "sources/3rdparty/task"]
path = sources/3rdparty/task
url = https://github.com/arcan1s/qtadds-taskadds-qprocess.git
[submodule "sources/3rdparty/tasks"]
path = sources/3rdparty/tasks
url = https://github.com/mhogomchungu/tasks.git
[submodule "sources/3rdparty/fontdialog"]
path = sources/3rdparty/fontdialog
url = https://github.com/arcan1s/qtadds-fontdialog.git

9
AUTHORS Normal file
View File

@ -0,0 +1,9 @@
Current developers:
Evgeniy Alekseev aka arcanis <esalexeev (at) gmail (dot) com>
Translators:
@Mermouy (French translation)
Ernesto Avilés Vzqz (Spanish translation)
@underr (Brazillian Portuguese translation)
Виктор Слободян (Ukrainian translation)
Steve Lemuel (Chinese translation)

274
CHANGELOG Normal file
View File

@ -0,0 +1,274 @@
Ver.2.2.1:
+ add key X-AW-Interval to ExtUpgrade (ApiVer = 1, default = 3600)
+ add values cache to ExtScript and ExtUpgrade
+ add support isActive to ExtUpgrade
* change cmake version check
* improve logic of ExtScript and ExtUpgrade
Ver.2.2.0:
* port to Plasma 5
+ add support of windows list in tooltip
+ add notifications on system events
+ add ability to show selected tag
+ add tags $downN, $upN
+ add new engine netdev
+ add support of smartctl
- remove ability to hide panel on hotkey
* small changes in widget logic
* edit window preview painting
* KDE4 code upgrade to new ABI
* dataengine optimization
* PKGCMD was replaced by ExtUpgrade
Ver.2.1.0:
+ add support of custom scripts
+ add support of desktop preview to DP
+ add bar support
+ add autoupdate function
- remove custom command
- fix #34
* fix notifications
* rewrite UI to KDE standards
* fix margins on graphical objects
* rewrite DP abd DE to use library calls
* edit GPU properties definition
* edit regexp matching
Ver.2.0.5:
+ add tooltip bottom (#30)
* fix network interface update
* fix battery tooltip bug
* edit DP layout (#31)
Ver.2.0.4:
* more correct work with batteries
Ver.2.0.3:
+ add support of several $bat tags
* edit layout
Ver.2.0.2:
+ add $fan* tags
+ add Chinese translation (thanks to @Lemueler)
+ add net devices checking is it p2p device
- remove ps stats from notification
* yet another fix cpu* and cpucl*
* rewrite DP configuration interface
* fix non-standard temp units
Ver.2.0.1:
+ add support of custom interfaces
* fix label edge's shading
* fix cpu*, cpucl*, gpu*, ps* tags
Ver.2.0.0:
+ add new widget - awesome widget
+ add new tags $hddfreemb, $hddfreegb, $memusedmb, $memusedgb, $memfreemb $memfreegb, $swapfreemb, $swapfreegb
+ add new DataEngine - battery
+ add new tooltip - battery
+ add new temperature units cm^-1, kcal/mol, kJ/mol, Reamur
+ add ability to hide panels by hotkey pressing
- remove widget pytextmonitor
- remove separate fields
- remove README
* project has been renamed to Awesome Widgets
* rename tag $custom (time) to $ctime
* rename tag $custom (uptime) to $cuptime
* rename tag $time (player) to $duration
* rename tag $number to $ndesktop
* rename tag $name to $desktop
* rename tag $total to $tdesktops
* debug flag is DEBUG now
* rewrite project to C++
* tooltip doesn't depend on widget now
* text align now can be configured only by using HTML tags
* move battery and AC settings to DataEngine
* changes in configuration interface
Ver.1.11.0:
+ add ability to disable background image
+ add desktop DataEngine
+ add PTM desktop panel
+ add desktop label (tags $name, $number, $total)
+ add ability to interact with players using mpris
* rewrite to use submodules
* rewrite dataengine to use tasks
* fix nvidia temperature definition
Ver.1.10.2:
- fix error with tempUnits in hddtemp label
Ver.1.10.1:
- fix error with number formats in ps label
- fix first initialization of DataEngine
- fix checking of qmmp
Ver.1.10.0:
+ add tags $hddtotmb, $hddtotgb
+ add tags $memtotmb, $memtotgb, $swaptotmb, $swaptotgb
+ add ability for force update text
+ add support of clementine
+ add support of hddtemp cmd
+ add support of disable option for HDDDEV and GPUDEV
+ add error checking of DataEngine variables
+ add multithreading to DataEngine
+ add ability to disable popup messages
+ add ability to use vertical layout
+ add ability to add stretch
+ add ability to show debug information (set environment variable 'PTM_DEBUG' to 'yes')
+ add Brazillian Portuguese translation (@underr)
+ add Ukrainian translation (Виктор Слободян)
- remove util.py
- remove createNotifyrc since it isn't needed
* refactoring of configuration interface
* player settings was moved from plasmoid to dataengine
* edit readme call
* change readme from md to html
Ver.1.9.0:
+ add support of several custom commands ($customN)
+ add hdd speed label ($hddrN, $hddwN)
+ add actions to context menu (open readme and run ksysguard)
- remove doubleclick event
* fix parsing pkg label
Ver.1.8.3:
+ add Spanish translation (thanks to Ernesto Avilés Vzqz)
+ add readme to the package
Ver.1.8.2:
+ add different temperature units (Farenheit and Kelvin)
Ver.1.8.1:
* change pkg update time to hour
Ver.1.8.0:
+ add scrollbar to configuration interface
+ add AC lines configuration
+ add $hddmbN, $hddgbN tags
+ add support of ps ($ps, $pscount, $pstotal tags)
+ add support of package managers ($pkgcountN tags)
* refactoring of DataEngine
Ver.1.7.4:
+ add support more than 10 tags in cpu, cpuclock, hdd, hddtemp, temp labels
- format bug fixes
* changes in custom uptime format
Ver.1.7.3:
+ add tags $memgb, $swapgb
+ add readme directory
+ add french translation (@Mermouy)
- fix tooltip for custom uptime format
- fix #12
* more refactoring to the god of refactoring
* network device update interval now is 30*interval
* $swap, $swapmb and $swapgb tags now work simultaneously ($mem* tags too)
* player_name now has str type
Ver.1.7.2:
+ add tags $dd, $d, $hh, $h, $mm, $m to custom uptime format
+ add scalling to tooltips
+ add dataengine configuration from ptm
+ add custom command to dataengine
- remove custom command from ptm
- remove tags $ds, $hs, $ms
Ver.1.7.1:
- remove error label
* fix bug with zero values in tooltip
Ver.1.7.0:
+ add support of several tags in temperature label
+ add tags $cpuN, $cpuclN, $hddN, $tempN, $hddtempN, $up, $down
+ add label with custom command
+ add tooltips for CPU, CPU clock, memory, swap and network labels
- remove tags @@...@@, $temp, $ccpu, $ccpucl, $net
* changes in settings
* ptm now does not require net-tools
* refactoring
Ver.1.6.1:
+ add support of several devices in hddtemp label
- fixed #6
Ver.1.6.0:
+ add $custom tag to time and uptime labels (#8)
+ russian translation
- fix #6, #10
* change license to GPLv3
* change project build
Ver.1.5.3:
+ add $album, $progress and $time tags to player label (#7)
- fix zero swap
Ver.1.5.2:
+ add $isotime, $shorttime and $longtime tags to time label
Ver.1.5.1:
+ add time label
Ver.1.5.0:
+ add player label
Ver.1.4.0:
+ add notifications
Ver.1.3.6:
- fix #1, #2
Ver.1.3.5:
- fix bug with definition network device
Ver.1.3.4:
+ add double click event
+ add auto selection of network device
- fix yet another plasma crash
Ver.1.3.3:
* edit reading temperature device
Ver.1.3.2b:
- fix plasma crash
Ver.1.3.2:
+ add GPU, GPU temperature, HDD and HDD temperature labels
+ add $ccpu and $ccpucl tags
- bug fixes
* optimization and refactoring
Ver.1.2.2:
+ add tooltip to lineEdit
Ver.1.2.1:
* if battery doesn't exist return 'off'
* if AC doesn't exist return '(?)'
Ver.1.2.0:
+ add $ac tag to battery label
+ add battery and ac device configurations
+ add error cheking
* $bat tag now reading from /sys/*
Ver.1.1.4:
* change parsing acpi output (battery label)
Ver.1.1.3:
+ add font weight
* edit font setup line. Now setup for font family works normaly
* small bug fix
Ver.1.1.2:
+ add CPU clock lable
+ add function to update network device (100*time_interval)
+ change update sliders
Ver.1.1.1:
+ add $swapmb, $memmb, $netdev, @@netdev=...@@ tags
- some bug fixes
* widget consists of several labels
* edit configuration interface
Ver.1.0:
First release

274
CHANGELOG-RU Normal file
View File

@ -0,0 +1,274 @@
Вер.2.2.1:
+ добавлен ключ X-AW-Interval в ExtUpgrade (ApiVer = 1, default = 3600)
+ добавлено кеширование значений в ExtScript и ExtUpgrade
+ добавлена поддержка isActive в ExtUpgrade
* изменена проверка версий cmake
* улучшена логика работы ExtScript и ExtUpgrade
Вер.2.2.0:
* портирование на Plasma 5
+ добавлена поддержка списка окон в тултипе
+ добавлены уведомления на системные события
+ добавлена возможность показать выбранный тег
+ добавлены теги $downN, $upN
+ добавлен инструмент netdev
+ добавлена поддержка smartctl
- убрана возможность сокрытия панелей
* незначительно изменена логика работы виджета
* исправлена отрисовка превью окон
* обновление кодовой базы KDE4 под новый ABI
* оптимизация работы dataengine
* PKGCMD были заменены на ExtUpgrade
Вер.2.1.0:
+ добавлена функция автообновления
+ добавлена поддерка кастомных скриптов
+ добавлена поддержка превью рабочего стола для DP
+ добавлена поддержка баров
- удалена поддержка кастомных команд
- фикс #34
* исправлены уведомления
* переписан UI в соответствии со стандартами KDE
* исправлены границы для графических объектов
* переписан DP и DE на использование библиотечных функций
* изменено определение свойств GPU
* изменен поиск регулярных выражений
Вер.2.0.5:
+ добавлен нижний край к тултипу (#30)
* исправлен баг с обновлением сетевого интерфейса
* исправлен баг с тултипом батареи
* отредактирована разметка DP (#31)
Вер.2.0.4:
* более корректная работа с батареями
Вер.2.0.3:
+ добавлена поддержка нескольких тегов $bat
* отредактирована разметка
Вер.2.0.2:
+ добавлены теги $fan*
+ добавлен китайский перевод (спасибо @Lemueler)
+ добавлена проверка сетевых устройств на p2p
- удалено ps stats из уведомлений
* еще один фикс тегов cpu* и cpucl
* переписан конфигурационный интерфейс DP
* исправлены нестандартные единицы температуры
Вер.2.0.1:
+ добавлена поддержка кастомных интерфейсов
* фикс затенения краев поля
* фикс тегов cpu*, cpucl*, gpu*, ps*
Вер.2.0.0:
+ добавлен виджет awesome widget
+ новые теги $hddfreemb, $hddfreegb, $memusedmb, $memusedgb, $memfreemb $memfreegb, $swapfreemb, $swapfreegb
+ новый DataEngine - battery
+ новый тултип - battery
+ новые температурные единицы см^-1, ккал/моль, кДж/моль, Реамюр
+ добавлена возможность скрывать панели по хоткею
- удален виджет pytextmonitor
- убраны отдельные поля
- удалены README
* проект переименован в Awesome Widgets
* тег $custom (время) переименован в $ctime
* тег $custom (время работы) переименован в $cuptime
* тег $time (плеер) переименован в $duration
* тег $number переименован в $ndesktop
* тег $name переименован в $desktop
* тег $total переименован в $tdesktops
* дебаг флаг теперь DEBUG
* проект полностью переписан на C++
* тултип независит теперь от самого виджета
* настройка выравнивания текста теперь осуществляется только HTML тегами
* настройки батареи и адаптора питания вынесены в DataEngine
* изменения в конфигурационном интерфейсе
Вер.1.11.0:
+ добавлена возможность отключения фона
+ добавлен desktop DataEngine
+ добавлен виджет PTM desktop panel
+ добавлено поле текущий рабочий стол (теги $name, $number, $total)
+ добавлена возможность взаимодействия с плеерами через mpris
* добавлено использование сабмодулей
* dataengine переписан с использованием tasks
* фикс чтения температуры nvidia
Вер.1.10.2:
- фикс ошибки с tempUnits в поле hddtemp
Вер.1.10.1:
- пофикшена ошибка с форматами чисел в поле ps
- пофикшена инициализация значений в DataEngine
- пофикшена проверка qmmp
Вер.1.10.0:
+ добавлены теги $hddtotmb, $hddtotgb
+ добавлены теги $memtotmb, $memtotgb, $swaptotmb, $swaptotgb
+ добавлена возможность форсированного обновления
+ добавлена поддержка clementine
+ добавлена поддержка команды hddtemp
+ добавлены поддержка disable для HDDDEV и GPUDEV
+ добавлена многопоточность в DataEngine
+ добавлена проверка ошибок для переменных DataEngine
+ добавлена возможность отключения всплывающих сообщений
+ добавлена возможность использовать вертикальную разметку
+ добавлена возможность добавить пустое пространство
+ добавлена возможность вывода отладочной информации (установите переменную окружения 'PTM_DEBUG' в 'yes')
+ добавлен перевод Brazillian Portuguese (@underr)
+ добавлена украинская локализация (Виктор Слободян)
- удален util.py
- удалены функции createNotifyrc, поскольку они больше не нужны
* рефакторинг конфигурационного интерфейса
* настройки плеера были перенесены из виджета в dataengine
* исправлен вызов readme под четырехсимвольное обозначение
* перенос readme с md на html
Вер.1.9.0:
+ добавлена поддержка нескольких кастомных команд ($customN)
+ добавлено поле скорости hdd ($hddrN, $hddwN)
+ добавлены действия в контекстное меню (открыть readme и запустить ksysguard)
* исправлен парсинг поля pkg
- убрано событие по двойному клику
Вер.1.8.3:
+ добавлен испанский перевод (Ernesto Avilés Vzqz)
+ добавлены файлы readme
Вер.1.8.2:
+ добавлены различные температурные единицы (Farenheit и Kelvin)
Вер.1.8.1:
* поле pkg теперь обновляется раз в час
Вер.1.8.0:
+ добавлены скроллбары в конфигурационный интерфейс
+ добавлена настройка значений AC
+ добавлены теги $hddmbN, $hddgbN
+ добавлена поддержка ps (теги $ps, $pscount, $pstotal)
+ добавлена поддержка пакетных менеджеров (теги $pkgcountN)
* рефакторинг DataEngine
Вер.1.7.4:
+ добавлена поддержка более чем 10 тэгов в полях cpu, cpuclock, hdd, hddtemp, temp
- фиксы в форматах
* изменения в кастомном формате аптайма
Вер.1.7.3:
+ добавлены тэги $memgb, $swapgb
+ добавлена директория readme
+ добавлен французский перевод (@Mermouy)
- фикс подсказки для кастомного формата аптайма
- фикс #12
* больше рефакторинга богу рефакторинга
* интервал обновления сетевого интерфейса теперь 30*interval
* тэги $swap, $swapmb и $swapgb теперь работают одновременно (тэги $mem* тоже)
* player_name теперь имеет тип str
Вер.1.7.2:
+ добавлены тэги $dd, $d, $hh, $h, $mm, $m в кастомный формат аптайма
+ добавлено масштабирование в тултипы
+ добавлена конфигурация DE из виджета
+ добавлена кастомная команда в DE
- удалена кастомная команда из виджета
- удалены тэги $ds, $hs, $ms
Вер.1.7.1:
- удалено поле с ошибкой
* пофикшен баг с нулевым значением в тултипе
Вер.1.7.0:
+ добавлена поддержка нескольких тэгов в поле температуры
+ добавлены тэги $cpuN, $cpuclN, $hddN, $tempN, $hddtempN, $up, $down
+ добавлено поле с кастомной командой
+ добавлены тултипы для полей CPU, частоты CPU, памяти, swap и сеть
- удалены тэги @@...@@, $temp, $ccpu, $ccpucl, $net
* изменения в настройках
* виджет не требует больше net-tools
* рефакторинг
Вер.1.6.1:
+ добавлена поддержка нескольких девайсов в поле hddtemp
- фикс #6
Вер.1.6.0:
+ добавлен тэг $custom в поля time и uptime (#8)
+ русский перевод
- фикс #6, #10
* лицензия изменена на GPLv3
* изменения в сборке проекта
Вер.1.5.3:
+ добавлены тэги $album, $progress и $time tags в поле плеера (#7)
- фикс бага с нулевым свопом
Вер.1.5.2:
+ добавлены тэги $isotime, $shorttime и $longtime в поле time
Вер.1.5.1:
+ добавлено поле time
Вер.1.5.0:
+ добавлено поле player
Вер.1.4.0:
+ добавлены уведомления
Вер.1.3.6:
- фикс #1, #2
Вер.1.3.5:
- фикс бага с определением сетевого устройства
Вер.1.3.4:
+ добавлено событие по двойному щелчку
+ добавлен автовыбор сетевого устройства
- фикс еще одного падения Плазмы
Вер.1.3.3:
* редактирование чтения температурного устройства
Вер.1.3.2b:
- фикс падения Плазмы
Вер.1.3.2:
+ добавлены поля GPU, GPU temp, HDD и HDD temp
+ добавлены тэги $ccpu и $ccpucl
- фикс некоторых багов
* оптимизация и рефакторинг
Вер.1.2.2:
+ добавлен тултип в строки
Вер.1.2.1:
* если батарея не существует, возвращает off
* если AC не существует, возвращает '(?)'
Вер.1.2.0:
+ добавлен тэг $ac в поле battery
+ добавлена настройка устройств батареи и AC
+ добавлена проверка ошибок
* тэг $bat теперь читается из /sys/*
Вер.1.1.4:
* изменения в парсинге acpi (поле battery)
Вер.1.1.3:
+ добавлена настройка ширины шрифта
- небольшие фиксы
* отредактирована настройка шрифта. Теперь настройки для шрифта работают нормально
Вер.1.1.2:
+ добавлено поле CPU clock
+ добавлена функция для обновления сетевого интерфейса (100*time_interval)
* изменено обновление слайдеров
Вер.1.1.1:
+ добавлены тэги $swapmb, $memmb, $netdev, @@netdev=...@@
- небольшие фиксы
* виджет теперь состоит из нескольких полей
* отредактирован конфигурационный интерфейс
Вер.1.0:
Первый релиз

674
COPYING Normal file
View File

@ -0,0 +1,674 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
awesome-widgets
Copyright (C) 2013-2014 Evgeniy Alekseev
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
awesome-widgets Copyright (C) 2013 Evgeniy Alekseev
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<http://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<http://www.gnu.org/philosophy/why-not-lgpl.html>.

View File

@ -1,56 +0,0 @@
# Author: Evgeniy "arcanis" Alexeev <esalexeev@gmail.com>
# Maintainer: Evgeniy "arcanis" Alexeev <esalexeev@gmail.com>
pkgname=kdeplasma-applets-pytextmonitor
_pkgname=py-text-monitor
pkgver=1.4.0
pkgrel=1
_dtengine=ext-sysmon
_dtver=1.2
pkgdesc="Minimalistic Plasmoid script written on Python2. It looks like widgets in awesome-wm"
arch=('i686' 'x86_64')
url="https://github.com/arcan1s/pytextmonitor"
license=('GPL')
depends=('kdebase-workspace' 'kdebindings-python2' 'lm_sensors' 'net-tools')
optdepends=("hddtemp: for HDD temperature monitor"
"catalyst: for GPU monitor"
"nvidia-utils: for GPU monitor")
makedepends=('automoc4' 'cmake')
source=(https://github.com/arcan1s/pytextmonitor/releases/download/V.${pkgver}/${_pkgname}-${pkgver}.plasmoid
https://github.com/arcan1s/pytextmonitor/releases/download/V.${pkgver}/${_dtengine}-${_dtver}.zip)
install=${pkgname}.install
md5sums=('988704016573b215bb36b62762075fee'
'3182acdadb3b498be929b3cadad92206')
build ()
{
# build dataengine
if [[ -d ${srcdir}/${_dtengine}/build ]]; then
rm -rf "${srcdir}/${_dtengine}/build"
fi
mkdir "${srcdir}/${_dtengine}/build"; cd "${srcdir}/${_dtengine}/build"
cmake -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=`kde4-config --prefix` \
../
make
}
package()
{
# install dataengine
cd "${srcdir}/${_dtengine}/build"
make DESTDIR="${pkgdir}" install
# install plasmoid
install -D -m644 "${srcdir}/contents/code/plasma_applet_pytextmonitor.notifyrc" \
"${pkgdir}/`kde4-config --prefix`/share/apps/plasma_applet_pytextmonitor/plasma_applet_pytextmonitor.notifyrc"
install -D -m644 "${srcdir}/metadata.desktop" \
"${pkgdir}/`kde4-config --prefix`/share/kde4/services/${_pkgname}.desktop"
install -D -m644 "${srcdir}/metadata.desktop" \
"${pkgdir}/`kde4-config --prefix`/share/apps/plasma/plasmoids/${_pkgname}/metadata.desktop"
mkdir -p "${pkgdir}/`kde4-config --prefix`/share/apps/plasma/plasmoids/${_pkgname}/contents/"{code,ui}
install -m644 "${srcdir}/contents/code/"* \
-t "${pkgdir}/`kde4-config --prefix`/share/apps/plasma/plasmoids/${_pkgname}/contents/code"
install -m644 "${srcdir}/contents/ui/"* \
-t "${pkgdir}/`kde4-config --prefix`/share/apps/plasma/plasmoids/${_pkgname}/contents/ui"
}

36
README
View File

@ -1,36 +0,0 @@
py-text-monitor
=============
PyTextMonitor is a minimalistic Plasmoid script written on Python2. It looks like widgets in awesome-wm.
HOWTO
For edited output you must open Settings window and setup output format in lines:
label "$uptime" means uptime, ---d--h--m
label "$cpu" means total load cpu, %
label "$ccpu" means load CPU for each core, %
label "$cpucl" - average cpu clock, MHz
label "$ccpucl" - cpu clock for each core, MHz
label "$temp" - average temperature in system
label "$gpu" - GPU usage, %. `aticonfig` or `nvidia-smi` must be installed
label "$gputemp" - GPU temperature. `aticonfig` or `nvidia-smi` must be installed
label "$mem" - usage memory, %
label "$memmb" - usage memory, MB
label "$swap" - swap, %
label "$swapmb" - swap, MB
label "@@/@@" (in hdd label) - mount point ('/' in example) usage, %. Separator for mount points list is ';', for example "@@/;/home;/mnt/global@@". `hddtemp` must be installed
label "@@/dev/sda@@" (in hddtemp label) - HDD ('/dev/sda' in example) temperature
label "$net" - download and upload speed, KB/s. You may specify network device: something like @@eth0@@
label "$netdev" - current network device
label "$bat" - battery charge, %. Battery device may be set below. File ("/sys/class/power_supply/BAT0/capacity" by default) must contain only battery charge in percent
label "$ac" - status AC device. Return (*) if AC device is online or ( ) if offline. AC device may be set below. FIle ("/sys/class/power_supply/AC/online" by default) must contain '1' if AC is online
Label order will changed if you change slider position. HTML tags in label work normally.
Attention: you don't may set to show $cpu in swap label for example. $cpu will work only in cpu label.
Dependencies:
kdebindings-python2
ext-sysmon (for GPU, GPU temp and HDD temp labels)
lm_sensors (for definition temperature device)
net-tools (for definition network device)

77
README.md Normal file
View File

@ -0,0 +1,77 @@
awesome-widgets (ex-pytextmonitor)
==================================
**NOTE** KDE4 version is dropped from development since 2.2.1. Only critical bug
fixes will be applied.
Information
-----------
A collection of minimalistic widgets which looks like Awesome Window Manager widgets.
**NOTE** [LOOKING FOR TRANSLATORS!](https://github.com/arcan1s/awesome-widgets/issues/14)
Features
========
* easy and fully configurable native Plasma widget which may be used as Conky widget or as Awesome-like information panel
* panel which shows active desktop status
* clear Conky-like configuration with html tags support
* custom command support (it may be simple action as well as special custom tag)
* graphical item support - tooltips, bars
See [links](#Links) for more details.
**Didn't find required feature?** [Just ask for it!](https://github.com/arcan1s/awesome-widgets/issues)
Instruction
===========
Dependencies
------------
* kdebase-workspace
* lm_sensors (*for definition temperature device*)
Optional dependencies
---------------------
* proprietary video driver
* hddtemp
* smartmontools
* music player (mpd or supported MPRIS)
Make dependencies
-----------------
* cmake
* automoc4
Installation
------------
* download sources
* install
mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr ../
make && sudo make install
Additional information
======================
TODO (wish list)
----------------
See [milestones](https://github.com/arcan1s/awesome-widgets/milestones) for more details.
Links
-----
* [Homepage](http://arcanis.name/projects/awesome-widgets/)
* [Migration to 2.*](http://arcanis.name/en/2014/09/04/migration-to-v2/)
* [Scripts and bars](http://arcanis.name/en/2014/12/19/aw-v21-bells-and-whistles/)
* Plasmoid on [kde-look](http://kde-look.org/content/show.php/Awesome+Widgets?content=157124)
* DataEngine on [kde-look](http://kde-look.org/content/show.php/Extended+Systemmonitor+DataEngine?content=158773)
* Archlinux [AUR](https://aur.archlinux.org/packages/kdeplasma-applets-awesome-widgets-git/) package
* [OpenSuse](http://software.opensuse.org/package/awesome-widgets) package

6
TODO
View File

@ -1,6 +0,0 @@
1. Tooltip (graphical information):
a) cpu, %
b) cpuclock, mhz
c) memory, %
d) swap, %
e) network, %

View File

@ -1,30 +0,0 @@
#!/bin/bash
# build dataengine
ARCHIVE="ext-sysmon"
VERSION=`grep Version ext-sysmon/plasma-engine-extsysmon.desktop | awk -F "=" '{print $2}'`
# create archive
if [ -e ${ARCHIVE}-${VERSION}.zip ]; then
rm -f ${ARCHIVE}-${VERSION}.zip
fi
zip -9 -y -r -q ${ARCHIVE}-${VERSION}.zip ${ARCHIVE}
# update md5sum
MD5SUMS=`md5sum ${ARCHIVE}-${VERSION}.zip | awk '{print $1}'`
sed -i "/ '[0-9A-Fa-f]*/s/[^'][^)]*/ '${MD5SUMS}'/" PKGBUILD
sed -i "s/_dtver=[0-9.]*/_dtver=${VERSION}/" PKGBUILD
# build widget
cd sources
FILES="contents metadata.desktop plasma_applet_pytextmonitor"
ARCHIVE="py-text-monitor"
VERSION=`grep Version metadata.desktop | awk -F "=" '{print $2}'`
# create archive
if [ -e ${ARCHIVE}-${VERSION}.plasmoid ]; then
rm -f ${ARCHIVE}-${VERSION}.plasmoid
fi
zip -9 -y -r -q ../${ARCHIVE}-${VERSION}.plasmoid ${FILES}
cd ..
# update md5sum
MD5SUMS=`md5sum ${ARCHIVE}-${VERSION}.plasmoid | awk '{print $1}'`
sed -i "/md5sums=('[0-9A-Fa-f]*/s/[^'][^)]*/md5sums=('${MD5SUMS}'/" PKGBUILD
sed -i "s/pkgver=[0-9.]*/pkgver=${VERSION}/" PKGBUILD

Binary file not shown.

View File

@ -1,24 +0,0 @@
# set project name
project (plasma_engine_extsysmon)
# find required libaries
find_package (KDE4 REQUIRED)
include (KDE4Defaults)
add_definitions (${QT_DEFINITIONS}
${KDE4_DEFINITIONS})
include_directories (${CMAKE_SOURCE_DIR}
${CMAKE_BINARY_DIR}
${KDE4_INCLUDES})
set (PLUGIN_NAME ${PROJECT_NAME})
file (GLOB PROJECT_DESKTOP *.desktop)
file (GLOB PROJECT_SRCS *.cpp)
# make
kde4_add_plugin (${PLUGIN_NAME} ${PROJECT_SRCS})
target_link_libraries (${PLUGIN_NAME} ${KDE4_KDECORE_LIBS} ${KDE4_PLASMA_LIBS})
# install
install(TARGETS ${PLUGIN_NAME} DESTINATION ${PLUGIN_INSTALL_DIR})
install(FILES ${PROJECT_DESKTOP} DESTINATION ${SERVICES_INSTALL_DIR})

View File

@ -1,175 +0,0 @@
#include "extsysmon.h"
#include <Plasma/DataContainer>
#include <stdio.h>
ExtendedSysMon::ExtendedSysMon(QObject* parent, const QVariantList& args)
: Plasma::DataEngine(parent, args)
{
Q_UNUSED(args)
setMinimumPollingInterval(333);
FILE *f_out;
f_out = popen("lspci 2>&1", "r");
char device[256];
QString dev;
while (fgets(device, 256, f_out) != NULL)
{
dev = QString(device);
if (dev.toLower().contains("nvidia"))
gpudev = QString("nvidia");
else if (dev.toLower().contains("radeon"))
gpudev = QString("ati");
}
pclose(f_out);
f_out = popen("ls -1 /dev/sd[a-z] && ls -1 /dev/hd[a-z] 2>&1", "r");
while (fgets(device, 256, f_out) != NULL)
{
dev = QString(device);
if (dev[0] == '/')
hdddev.append(dev);
}
pclose(f_out);
}
QStringList ExtendedSysMon::sources() const
{
QStringList source;
source.append(QString("gpu"));
source.append(QString("gputemp"));
source.append(QString("hddtemp"));
return source;
}
bool ExtendedSysMon::sourceRequestEvent(const QString &name)
{
return updateSourceEvent(name);
}
bool ExtendedSysMon::updateSourceEvent(const QString &source)
{
FILE *f_out;
QString key, out, tmp_out, value;
bool ok = false;
char output[256], val[5];
if (source == QString("gpu"))
{
key = QString("GPU");
if (gpudev == QString("nvidia"))
{
f_out = popen("nvidia-smi -q -d UTILIZATION | grep Gpu | tail -n1 2>&1", "r");
fgets (output, 256, f_out);
if ((output[0] == '\0') ||
(QString(output).split(QString(" "), QString::SkipEmptyParts).count() < 2))
value = QString(" N\\A");
else
{
out = QString(output).split(QString(" "), QString::SkipEmptyParts)[2];
sprintf (val, "%5.1f", out.left(out.count()-2).toFloat(&ok));
value = QString(val);
}
pclose(f_out);
}
else if (gpudev == QString("ati"))
{
f_out = popen("aticonfig --od-getclocks | grep load | tail -n1 2>&1", "r");
fgets (output, 256, f_out);
if ((output[0] == '\0') ||
(QString(output).split(QString(" "), QString::SkipEmptyParts).count() < 3))
value = QString(" N\\A");
else
{
out = QString(output).split(QString(" "), QString::SkipEmptyParts)[3];
sprintf (val, "%5.1f", out.left(out.count()-2).toFloat(&ok));
value = QString(val);
}
pclose(f_out);
}
else
{
value = QString(" N\\A");
}
if (ok == false)
value = QString(" N\\A");
value = value.split(QString(","), QString::SkipEmptyParts).join(QString("."));
setData(source, key, value);
}
else if (source == QString("gputemp"))
{
key = QString("GPUTemp");
if (gpudev == QString("nvidia"))
{
f_out = popen("nvidia-smi -q -d TEMPERATURE | grep Gpu | tail -n1 2>&1", "r");
fgets (output, 256, f_out);
if ((output[0] == '\0') ||
(QString(output).split(QString(" "), QString::SkipEmptyParts).count() < 2))
value = QString(" N\\A");
else
{
out = QString(output).split(QString(" "), QString::SkipEmptyParts)[2];
sprintf (val, "%4.1f", out.toFloat(&ok));
value = QString(val);
}
pclose(f_out);
}
else if (gpudev == QString("ati"))
{
f_out = popen("aticonfig --od-gettemperature | grep Temperature | tail -n1 2>&1", "r");
fgets (output, 256, f_out);
if ((output[0] == '\0') ||
(QString(output).split(QString(" "), QString::SkipEmptyParts).count() < 4))
value = QString(" N\\A");
else
{
out = QString(output).split(QString(" "), QString::SkipEmptyParts)[4];
sprintf (val, "%4.1f", out.toFloat(&ok));
value = QString(val);
}
pclose(f_out);
}
else
{
value = QString(" N\\A");
}
if (ok == false)
value = QString(" N\\A");
value = value.split(QString(","), QString::SkipEmptyParts).join(QString("."));
setData(source, key, value);
}
else if (source == QString("hddtemp"))
{
char command[256], *dev;
QByteArray qb;
for (int i=0; i<hdddev.count(); i++)
{
qb = hdddev[i].toUtf8();
dev = qb.data();
sprintf(command, "hddtemp %s", dev);
f_out = popen(command, "r");
fgets(output, 256, f_out);
if ((output[0] == '\0') ||
(QString(output).split(QString(":"), QString::SkipEmptyParts).count() < 3))
value = QString(" N\\A");
else
{
out = QString(output).split(QString(":"), QString::SkipEmptyParts)[2];
sprintf (val, "%4.1f", out.left(out.count()-4).toFloat(&ok));
value = QString(val);
}
pclose(f_out);
if (ok == false)
value = QString(" N\\A");
value = value.split(QString(","), QString::SkipEmptyParts).join(QString("."));
setData(source, hdddev[i], value);
}
}
return true;
}
K_EXPORT_PLASMA_DATAENGINE(extsysmon, ExtendedSysMon)
#include "extsysmon.moc"

View File

@ -1,21 +0,0 @@
#ifndef EXTSYSMON_H
#define EXTSYSMON_H
#include <Plasma/DataEngine>
class ExtendedSysMon : public Plasma::DataEngine
{
Q_OBJECT
public:
ExtendedSysMon(QObject *parent, const QVariantList &args);
protected:
bool sourceRequestEvent(const QString &name);
bool updateSourceEvent(const QString &source);
QStringList hdddev;
QString gpudev;
QStringList sources() const;
};
#endif // EXTSYSMON_H

View File

@ -1,25 +0,0 @@
func_update()
{
cat << EOF
Update plasmoids...
EOF
kbuildsycoca4 > /dev/null 2>&1
}
post_install()
{
func_update
cat << EOF
Make sure that \`hddtemp\` can be run as non-root
EOF
}
post_upgrade()
{
func_update
}
post_remove()
{
func_update
}

Binary file not shown.

View File

@ -1,3 +0,0 @@
#!/bin/sh
plasmapkg -t dataengine -i ext-sysmon-1.0.zip

56
packages/PKGBUILD Normal file
View File

@ -0,0 +1,56 @@
# Maintainer: Evgeniy Alekseev <arcanis at archlinux dot org>
pkgname=kdeplasma-applets-awesome-widgets-git
_pkgname=awesome-widgets
pkgver=2.2.1.r2.ga098c9d
pkgrel=1
pkgdesc="Collection of minimalistic Plasmoids which look like Awesome WM widgets (ex-PyTextMonitor)"
arch=('i686' 'x86_64')
url="http://arcanis.name/projects/awesome-widgets"
license=('GPL3')
depends=('kdebase-workspace' 'lm_sensors')
optdepends=("amarok: for music player monitor"
"clementine: for music player monitor"
"catalyst: for GPU monitor"
"hddtemp: for HDD temperature monitor"
"smartmontools: for HDD temperature monitor"
"mpd: for music player monitor"
"nvidia-utils: for GPU monitor"
"qmmp: for music player monitor")
makedepends=('automoc4' 'cmake' 'git')
source=(${_pkgname}::git+https://github.com/arcan1s/awesome-widgets.git#branch=release-2.2.1)
install=${pkgname}.install
md5sums=('SKIP')
backup=('usr/share/config/plasma-dataengine-extsysmon.conf')
pkgver() {
cd "${srcdir}/${_pkgname}"
git describe --tags --long | sed 's/V\.//' | sed 's/\([^-]*-g\)/r\1/;s/-/./g'
}
prepare() {
rm -rf "${srcdir}/${_pkgname}/build"
mkdir "${srcdir}/${_pkgname}/build"
# update submobules
cd "${srcdir}/${_pkgname}"
git submodule init
git submodule update --recursive
}
build () {
cd "${srcdir}/${_pkgname}/build"
cmake -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=$(kde4-config --prefix) \
"../sources"
make
}
package() {
cd "${srcdir}/${_pkgname}/build"
make DESTDIR="${pkgdir}" install
}

View File

@ -0,0 +1,4 @@
cmake
g++
git
kdelibs5-dev

View File

View File

@ -0,0 +1,11 @@
post_install() {
kbuildsycoca4 > /dev/null 2>&1
}
post_upgrade() {
post_install "$1"
}
post_remove() {
post_install "$1"
}

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 205 KiB

BIN
screenshots/config_01.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

BIN
screenshots/config_02.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 75 KiB

BIN
screenshots/config_03.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 59 KiB

BIN
screenshots/config_04.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

BIN
screenshots/config_05.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

BIN
screenshots/dataengine.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.4 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

BIN
screenshots/panel_01.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.5 KiB

BIN
screenshots/panel_02.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.4 KiB

BIN
screenshots/panel_03.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

BIN
screenshots/tooltips.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.1 KiB

View File

@ -0,0 +1,23 @@
[Buildset]
BuildItems=@Variant(\x00\x00\x00\t\x00\x00\x00\x00\x01\x00\x00\x00\x0b\x00\x00\x00\x00\x01\x00\x00\x00\x1e\x00a\x00w\x00e\x00s\x00o\x00m\x00e\x00-\x00w\x00i\x00d\x00g\x00e\x00t\x00s)
[CMake]
Build Directory Count=1
Current Build Directory Index=0
ProjectRootRelative=./
[CMake][CMake Build Directory 0]
Build Directory Path=file:///home/arcanis/Documents/github/awesome-widgets/build
Build Type=Debug
CMake Binary=file:///usr/bin/cmake
Environment Profile=
Extra Arguments=
Install Directory=file:///usr
[Defines And Includes][Compiler]
Name=GCC
Path=gcc
Type=GCC
[Project]
VersionControlSupport=kdevgit

218
sources/3rdparty/about/about.ui vendored Normal file
View File

@ -0,0 +1,218 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>About</class>
<widget class="QWidget" name="About">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>450</width>
<height>359</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tab_About">
<attribute name="title">
<string>About</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QScrollArea" name="scrollArea_about">
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents_about">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>418</width>
<height>284</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLabel" name="label_name">
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="textInteractionFlags">
<set>Qt::TextBrowserInteraction</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_version">
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="textInteractionFlags">
<set>Qt::TextBrowserInteraction</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_description">
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignJustify|Qt::AlignVCenter</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="textInteractionFlags">
<set>Qt::TextBrowserInteraction</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_links">
<property name="text">
<string/>
</property>
<property name="textFormat">
<enum>Qt::RichText</enum>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
<property name="textInteractionFlags">
<set>Qt::TextBrowserInteraction</set>
</property>
</widget>
</item>
<item>
<spacer name="spacer_about">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_ackn">
<attribute name="title">
<string>Acknowledgement</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QScrollArea" name="scrollArea_ackn">
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents_ackn">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>418</width>
<height>284</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<widget class="QLabel" name="label_translators">
<property name="text">
<string/>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="textInteractionFlags">
<set>Qt::TextBrowserInteraction</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_trdparty">
<property name="text">
<string/>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="textInteractionFlags">
<set>Qt::TextBrowserInteraction</set>
</property>
</widget>
</item>
<item>
<spacer name="spacer_ackn">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>229</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<widget class="QLabel" name="label_license">
<property name="text">
<string/>
</property>
<property name="textFormat">
<enum>Qt::RichText</enum>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
<property name="textInteractionFlags">
<set>Qt::TextBrowserInteraction</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

1
sources/3rdparty/fontdialog vendored Submodule

1
sources/3rdparty/pdebug vendored Submodule

Submodule sources/3rdparty/pdebug added at 75e4a0df83

1
sources/3rdparty/task vendored Submodule

Submodule sources/3rdparty/task added at d2798204a1

1
sources/3rdparty/tasks vendored Submodule

Submodule sources/3rdparty/tasks added at 230bdecd2c

48
sources/CMakeLists.txt Normal file
View File

@ -0,0 +1,48 @@
cmake_minimum_required (VERSION 2.8)
cmake_policy (SET CMP0003 OLD)
cmake_policy (SET CMP0002 OLD)
cmake_policy (SET CMP0011 NEW)
cmake_policy (SET CMP0015 NEW)
project (awesomewidgets)
set (PROJECT_AUTHOR "Evgeniy Alekseev")
set (PROJECT_CONTACT "esalexeev@gmail.com")
set (PROJECT_LICENSE "GPLv3")
set (PROJECT_VERSION_MAJOR 2)
set (PROJECT_VERSION_MINOR 2)
set (PROJECT_VERSION_PATCH 1)
set (PROJECT_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH})
string (TIMESTAMP CURRENT_DATE "%Y-%m-%d %H:%M" UTC)
string (TIMESTAMP CURRENT_YEAR "%Y")
message (STATUS "Project: ${PROJECT_NAME}")
message (STATUS "Version: ${PROJECT_VERSION}")
message (STATUS "Build date: ${CURRENT_DATE}")
option(BUILD_DEB_PACKAGE "Build deb package" OFF)
option(BUILD_RPM_PACKAGE "Build rpm package" OFF)
# flags
if (CMAKE_COMPILER_IS_GNUCXX)
set (CMAKE_CXX_FLAGS "-Wall -Wno-cpp -std=c++11")
set (CMAKE_CXX_FLAGS_DEBUG "-g -O0")
set (CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG")
# avoid newer gcc warnings
add_definitions (-D_DEFAULT_SOURCE)
else ()
message (STATUS "Unknown compiler")
endif ()
configure_file (${CMAKE_SOURCE_DIR}/version.h.in ${CMAKE_CURRENT_BINARY_DIR}/version.h)
set (PROJECT_TRDPARTY_DIR ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty)
add_subdirectory (extsysmon)
add_subdirectory (awesome-widget)
add_subdirectory (desktop-panel)
# translations
add_subdirectory (translations)
include(packages-recipe.cmake)

View File

@ -0,0 +1,45 @@
# set project name
set (SUBPROJECT plasma_applet_awesome-widget)
set (PLUGIN_NAME ${SUBPROJECT})
message (STATUS "Subproject ${SUBPROJECT}")
# find required libaries
find_package (KDE4 REQUIRED)
add_definitions (${QT_DEFINITIONS} ${KDE4_DEFINITIONS})
include (KDE4Defaults)
include_directories (${CMAKE_SOURCE_DIR}
${CMAKE_BINARY_DIR}
${KDE4_INCLUDES}
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_BINARY_DIR}/../
${PROJECT_TRDPARTY_DIR}
../extsysmon
${CMAKE_CURRENT_BINARY_DIR}/../extsysmon)
# set sources
file (GLOB SUBPROJECT_DESKTOP_IN *.desktop)
file (RELATIVE_PATH SUBPROJECT_DESKTOP ${CMAKE_SOURCE_DIR} ${SUBPROJECT_DESKTOP_IN})
file (GLOB_RECURSE SUBPROJECT_SOURCE *.cpp ${PROJECT_TRDPARTY_DIR}/task/*.cpp
${PROJECT_TRDPARTY_DIR}/fontdialog/*.cpp
../extsysmon/extscript.cpp
../extsysmon/extupgrade.cpp)
set (TASK_HEADER ${PROJECT_TRDPARTY_DIR}/task/task.h)
file (GLOB SUBPROJECT_UI *.ui ${PROJECT_TRDPARTY_DIR}/about/*.ui)
file (GLOB SUBPROJECT_NOTIFY *.notifyrc)
set (SUBPROJECT_DESKTOPS ${CMAKE_CURRENT_SOURCE_DIR}/desktops)
# prepare
configure_file (${SUBPROJECT_DESKTOP_IN} ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT_DESKTOP})
# make
qt4_wrap_cpp (TASK_MOC_SOURCE ${TASK_HEADER})
kde4_add_ui_files (SUBPROJECT_SOURCE ${SUBPROJECT_UI})
kde4_add_plugin (${PLUGIN_NAME} ${SUBPROJECT_SOURCE} ${TASK_MOC_SOURCE})
target_link_libraries (${PLUGIN_NAME} ${KDE4_PLASMA_LIBS} ${KDE4_KDEUI_LIBS} ${KDE4_KIO_LIBS})
# install
install (TARGETS ${PLUGIN_NAME} DESTINATION ${PLUGIN_INSTALL_DIR})
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT_DESKTOP} DESTINATION ${SERVICES_INSTALL_DIR})
install (FILES ${SUBPROJECT_NOTIFY} DESTINATION ${DATA_INSTALL_DIR}/${PLUGIN_NAME})
install (DIRECTORY ${SUBPROJECT_DESKTOPS} DESTINATION ${DATA_INSTALL_DIR}/${PLUGIN_NAME})

View File

@ -0,0 +1,534 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>AdvancedWindow</class>
<widget class="QWidget" name="AdvancedWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>700</width>
<height>588</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>700</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="windowTitle">
<string notr="true">Advanced</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QScrollArea" name="scrollArea_advanced">
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="contents_advanced">
<property name="geometry">
<rect>
<x>0</x>
<y>-250</y>
<width>675</width>
<height>822</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_8">
<item>
<layout class="QHBoxLayout" name="layout_popup">
<item>
<spacer name="spacer_popup">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QCheckBox" name="checkBox_popup">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Enable popup on mouse click</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_background">
<item>
<spacer name="spacer_background">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QCheckBox" name="checkBox_background">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Enable background</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_timeFormat">
<item>
<widget class="QLabel" name="label_timeFormat">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Custom time format</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_timeFormat">
<property name="toolTip">
<string>$dddd - long weekday
$ddd - short weekday
$dd - day
$d - day w\o zero
$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
$ss - seconds
$s - seconds w\o zero</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_uptimeFormat">
<item>
<widget class="QLabel" name="label_uptimeFormat">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Custom uptime format</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_uptimeFormat">
<property name="toolTip">
<string>$dd - uptime days
$d - uptime days without zero
$hh - uptime hours
$h - uptime hours without zero
$mm - uptime minutes
$m - uptime minutes without zero</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_tempUnits">
<item>
<widget class="QLabel" name="label_tempUnits">
<property name="text">
<string>Temperature units</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox_tempUnits">
<item>
<property name="text">
<string notr="true">Celsius</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">Fahrenheit</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">Kelvin</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">Reaumur</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">cm^-1</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">kJ/mol</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">kcal/mol</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="layout_tempDevice">
<item>
<widget class="QLabel" name="label_tempDevice">
<property name="minimumSize">
<size>
<width>200</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Temperature devices</string>
</property>
</widget>
</item>
<item>
<widget class="QListWidget" name="listWidget_tempDevice">
<property name="toolTip">
<string>Editable</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="layout_fanDevice">
<item>
<widget class="QLabel" name="label_fanDevice">
<property name="minimumSize">
<size>
<width>200</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Fan devices</string>
</property>
</widget>
</item>
<item>
<widget class="QListWidget" name="listWidget_fanDevice">
<property name="toolTip">
<string>Editable</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="layout_mount">
<item>
<widget class="QLabel" name="label_mount">
<property name="minimumSize">
<size>
<width>200</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Mount points</string>
</property>
</widget>
</item>
<item>
<widget class="QListWidget" name="listWidget_mount">
<property name="toolTip">
<string>Editable</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="layout_hddSpeedDevice">
<item>
<widget class="QLabel" name="label_hddSpeedDevice">
<property name="minimumSize">
<size>
<width>200</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>HDD devices (speed)</string>
</property>
</widget>
</item>
<item>
<widget class="QListWidget" name="listWidget_hddSpeedDevice">
<property name="toolTip">
<string>Editable</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="layout_hddDevice">
<item>
<widget class="QLabel" name="label_hddDevice">
<property name="minimumSize">
<size>
<width>200</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>HDD devices (temp)</string>
</property>
</widget>
</item>
<item>
<widget class="QListWidget" name="listWidget_hddDevice">
<property name="toolTip">
<string>Editable</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_netdev">
<item>
<widget class="QCheckBox" name="checkBox_netdev">
<property name="toolTip">
<string>Disable auto select device and set specified device</string>
</property>
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
</property>
<property name="text">
<string>Set network device</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox_netdev">
<property name="editable">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_acOnline">
<item>
<widget class="QLabel" name="label_acOnline">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>AC online tag</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_acOnline">
<property name="toolTip">
<string>Line, which returns when AC is online</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_acOffline">
<item>
<widget class="QLabel" name="label_acOffline">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>AC offline tag</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_acOffline">
<property name="toolTip">
<string>Line, which returns when AC is offline</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="layout_bars">
<item>
<layout class="QHBoxLayout" name="layout_barsAdd">
<item>
<widget class="QLabel" name="label_bars">
<property name="text">
<string>Bars</string>
</property>
</widget>
</item>
<item>
<spacer name="spacer_bars">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pushButton_bars">
<property name="text">
<string>Add</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QListWidget" name="listWidget_bars">
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_updates">
<item>
<spacer name="spacer_updates">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QCheckBox" name="checkBox_updates">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Check for updates</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="spacer_advanced">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,237 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>AppearanceWindow</class>
<widget class="QWidget" name="AppearanceWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>700</width>
<height>594</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>700</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="windowTitle">
<string notr="true">Appearance</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QScrollArea" name="scrollArea_appearance">
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="contents_appearance">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>684</width>
<height>578</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_10">
<item>
<layout class="QHBoxLayout" name="layout_interval">
<item>
<widget class="QLabel" name="label_interval">
<property name="text">
<string>Time interval</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinBox_interval">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>10000</number>
</property>
<property name="singleStep">
<number>500</number>
</property>
<property name="value">
<number>2000</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_font">
<item>
<widget class="QLabel" name="label_font">
<property name="text">
<string>Font</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QFontComboBox" name="fontComboBox">
<property name="minimumSize">
<size>
<width>180</width>
<height>0</height>
</size>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_size">
<item>
<widget class="QLabel" name="label_size">
<property name="text">
<string>Font size</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinBox_size">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>99</number>
</property>
<property name="singleStep">
<number>1</number>
</property>
<property name="value">
<number>12</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_color">
<item>
<widget class="QLabel" name="label_color">
<property name="text">
<string>Font color</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="KColorCombo" name="kcolorcombo"/>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_style">
<item>
<widget class="QLabel" name="label_style">
<property name="text">
<string>Font style</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox_style">
<item>
<property name="text">
<string notr="true">normal</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">italic</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_weight">
<item>
<widget class="QLabel" name="label_weight">
<property name="text">
<string>Font weight</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinBox_weight">
<property name="minimum">
<number>100</number>
</property>
<property name="maximum">
<number>900</number>
</property>
<property name="singleStep">
<number>100</number>
</property>
<property name="value">
<number>400</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="spacer_text">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>KColorCombo</class>
<extends>QComboBox</extends>
<header>kcolorcombo.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,503 @@
/***************************************************************************
* This file is part of awesome-widgets *
* *
* awesome-widgets is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* awesome-widgets is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#include "awesome-widget.h"
#include <KStandardDirs>
#include <Plasma/ToolTipManager>
#include <QDesktopServices>
#include <QDir>
#include <QGraphicsGridLayout>
#include <QGraphicsProxyWidget>
#include <QGraphicsScene>
#include <QGraphicsView>
#include <QMessageBox>
#include <QNetworkAccessManager>
#include <QNetworkInterface>
#include <QNetworkRequest>
#include <QNetworkReply>
#include <QProcessEnvironment>
#include <QTextCodec>
#include <QTimer>
#include "customlabel.h"
#include "graphicalitem.h"
#include <pdebug/pdebug.h>
#include <task/taskadds.h>
#include "version.h"
AwesomeWidget::AwesomeWidget(QObject *parent, const QVariantList &args)
: Plasma::Applet(parent, args)
{
// debug
QProcessEnvironment environment = QProcessEnvironment::systemEnvironment();
QString debugEnv = environment.value(QString("DEBUG"), QString("no"));
if (debugEnv == QString("yes"))
debug = true;
else
debug = false;
setBackgroundHints(DefaultBackground);
setAspectRatioMode(Plasma::IgnoreAspectRatio);
setHasConfigurationInterface(true);
setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
// text format init
formatLine.append(QString(""));
formatLine.append(QString(""));
}
AwesomeWidget::~AwesomeWidget()
{
if (debug) qDebug() << PDEBUG;
}
void AwesomeWidget::checkUpdates()
{
if (debug) qDebug() << PDEBUG;
QNetworkAccessManager *manager = new QNetworkAccessManager(this);
connect(manager, SIGNAL(finished(QNetworkReply *)), this, SLOT(replyRecieved(QNetworkReply *)));
manager->get(QNetworkRequest(QUrl(VERSION_API)));
}
QList<QAction *> AwesomeWidget::contextualActions()
{
if (debug) qDebug() << PDEBUG;
return contextMenu;
}
void AwesomeWidget::createActions()
{
if (debug) qDebug() << PDEBUG;
contextMenu.clear();
contextMenu.append(new QAction(QIcon::fromTheme(QString("utilities-system-monitor")),
i18n("Run ksysguard"), this));
connect(contextMenu[0], SIGNAL(triggered(bool)), this, SLOT(showKsysguard()));
contextMenu.append(new QAction(QIcon::fromTheme(QString("text-x-readme")),
i18n("Show README"), this));
connect(contextMenu[1], SIGNAL(triggered(bool)), this, SLOT(showReadme()));
contextMenu.append(new QAction(QIcon::fromTheme(QString("stock-refresh")),
i18n("Update text"), this));
connect(contextMenu[2], SIGNAL(triggered(bool)), this, SLOT(updateNetworkDevice()));
connect(contextMenu[2], SIGNAL(triggered(bool)), extsysmonEngine, SLOT(updateAllSources()));
connect(contextMenu[2], SIGNAL(triggered(bool)), sysmonEngine, SLOT(updateAllSources()));
contextMenu.append(new QAction(QIcon::fromTheme(QString("system-software-update")),
i18n("Check for updates"), this));
connect(contextMenu[3], SIGNAL(triggered(bool)), this, SLOT(checkUpdates()));
}
QString AwesomeWidget::getNetworkDevice()
{
if (debug) qDebug() << PDEBUG;
QString device = QString("lo");
if (configuration[QString("useCustomNetdev")].toInt() == 2)
device = configuration[QString("customNetdev")];
else {
QList<QNetworkInterface> rawInterfaceList = QNetworkInterface::allInterfaces();
for (int i=0; i<rawInterfaceList.count(); i++)
if ((rawInterfaceList[i].flags().testFlag(QNetworkInterface::IsUp)) &&
(!rawInterfaceList[i].flags().testFlag(QNetworkInterface::IsLoopBack)) &&
(!rawInterfaceList[i].flags().testFlag(QNetworkInterface::IsPointToPoint)))
device = rawInterfaceList[i].name();
}
return device;
}
int AwesomeWidget::getNumberCpus()
{
if (debug) qDebug() << PDEBUG;
QString cmd = QString("grep -c ^processor /proc/cpuinfo");
if (debug) qDebug() << PDEBUG << ":" << "cmd" << cmd;
TaskResult process = runTask(cmd);
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
if (process.exitCode != 0)
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
return QTextCodec::codecForMib(106)->toUnicode(process.output).trimmed().toInt();
}
float AwesomeWidget::getTemp(const float temp)
{
if (debug) qDebug() << PDEBUG;
float convertedTemp = temp;
if (configuration[QString("tempUnits")] == QString("Celsius"))
;
else if (configuration[QString("tempUnits")] == QString("Fahrenheit"))
convertedTemp = temp * 9.0 / 5.0 + 32.0;
else if (configuration[QString("tempUnits")] == QString("Kelvin"))
convertedTemp = temp + 273.15;
else if (configuration[QString("tempUnits")] == QString("Reaumur"))
convertedTemp = temp * 0.8;
else if (configuration[QString("tempUnits")] == QString("cm^-1"))
convertedTemp = (temp + 273.15) * 0.695;
else if (configuration[QString("tempUnits")] == QString("kJ/mol"))
convertedTemp = (temp + 273.15) * 8.31;
else if (configuration[QString("tempUnits")] == QString("kcal/mol"))
convertedTemp = (temp + 273.15) * 1.98;
return convertedTemp;
}
QStringList AwesomeWidget::getTimeKeys()
{
if (debug) qDebug() << PDEBUG;
QStringList timeKeys;
timeKeys.append(QString("dddd"));
timeKeys.append(QString("ddd"));
timeKeys.append(QString("dd"));
timeKeys.append(QString("d"));
timeKeys.append(QString("MMMM"));
timeKeys.append(QString("MMM"));
timeKeys.append(QString("MM"));
timeKeys.append(QString("M"));
timeKeys.append(QString("yyyy"));
timeKeys.append(QString("yy"));
timeKeys.append(QString("hh"));
timeKeys.append(QString("h"));
timeKeys.append(QString("mm"));
timeKeys.append(QString("m"));
timeKeys.append(QString("ss"));
timeKeys.append(QString("s"));
return timeKeys;
}
void AwesomeWidget::init()
{
if (debug) qDebug() << PDEBUG;
// dataengines
extsysmonEngine = dataEngine(QString("extsysmon"));
sysmonEngine = dataEngine(QString("systemmonitor"));
connect(sysmonEngine, SIGNAL(sourceAdded(QString)), this, SLOT(addDiskDevice(QString)));
timeEngine = dataEngine(QString("time"));
// tooltip
toolTip = Plasma::ToolTipContent();
toolTip.setMainText(QString("Awesome Widget"));
toolTip.setSubText(QString(""));
toolTipScene = new QGraphicsScene();
toolTipView = new QGraphicsView(toolTipScene);
toolTipView->setStyleSheet(QString("background: transparent"));
toolTipView->setContentsMargins(0, 0, 0, 0);
toolTipView->setFrameShape(QFrame::NoFrame);
toolTipView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
toolTipView->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
Plasma::ToolTipManager::self()->setContent(this, toolTip);
// body
createActions();
mainLayout = new QGraphicsGridLayout();
mainLayout->setContentsMargins(1, 1, 1, 1);
setLayout(mainLayout);
textLabel = new CustomLabel(this, debug);
textLabel->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
QGraphicsProxyWidget *pw = new QGraphicsProxyWidget(this);
pw->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
textLabel->setAttribute(Qt::WA_TranslucentBackground, true);
pw->setWidget(textLabel);
mainLayout->addItem(pw, 0, 0);
// read variables
configChanged();
timer = new QTimer(this);
timer->setSingleShot(false);
timer->setInterval(configuration[QString("interval")].toInt());
connect(timer, SIGNAL(timeout()), this, SLOT(updateText()));
connect(timer, SIGNAL(timeout()), this, SLOT(updateTooltip()));
timer->start();
// check for updates
connect(this, SIGNAL(thereIsUpdates(QString)), this, SLOT(showUpdates(QString)));
if (configuration[QString("checkUpdates")].toInt() == 2)
checkUpdates();
}
void AwesomeWidget::replyRecieved(QNetworkReply *reply)
{
if (debug) qDebug() << PDEBUG;
QString answer = reply->readAll();
if (!answer.contains(QString("tag_name"))) return;
QString version = QString(VERSION);
if (debug) qDebug() << PDEBUG << answer;
for (int i=0; i<answer.split(QString("tag_name")).count(); i++) {
version = answer.split(QString("tag_name"))[1].split(QChar(','))[0];
version.remove(QChar('"'));
version.remove(QChar(':'));
version.remove(QString("V."));
break;
}
int old_major = QString(VERSION).split(QChar('.'))[0].toInt();
int old_minor = QString(VERSION).split(QChar('.'))[1].toInt();
int old_patch = QString(VERSION).split(QChar('.'))[2].toInt();
int new_major = QString(version).split(QChar('.'))[0].toInt();
int new_minor = QString(version).split(QChar('.'))[1].toInt();
int new_patch = QString(version).split(QChar('.'))[2].toInt();
if ((old_major < new_major) ||
((old_major == new_major) && (old_minor < new_minor)) ||
((old_major == new_major) && (old_minor == new_minor) && (old_patch < new_patch)))
emit(thereIsUpdates(version));
}
void AwesomeWidget::addDiskDevice(const QString source)
{
if (debug) qDebug() << PDEBUG;
QRegExp diskRegexp = QRegExp(QString("disk/(?:md|sd|hd)[a-z|0-9]_.*/Rate/(?:rblk)"));
if (diskRegexp.indexIn(source) > -1) {
QStringList splitSource = source.split(QChar('/'));
QString device = splitSource[0] + QString("/") + splitSource[1];
diskDevices.append(device);
}
}
QStringList AwesomeWidget::findKeys()
{
if (debug) qDebug() << PDEBUG;
QStringList selectedKeys;
for (int i=0; i<keys.count(); i++)
if (configuration[QString("text")].contains(QString("$") + keys[i])) {
if (debug) qDebug() << PDEBUG << ":" << "Found key" << keys[i];
selectedKeys.append(keys[i]);
}
return selectedKeys;
}
QStringList AwesomeWidget::getKeys()
{
if (debug) qDebug() << PDEBUG;
QStringList allKeys;
// time
allKeys.append(QString("time"));
allKeys.append(QString("isotime"));
allKeys.append(QString("shorttime"));
allKeys.append(QString("longtime"));
allKeys.append(QString("ctime"));
// uptime
allKeys.append(QString("uptime"));
allKeys.append(QString("cuptime"));
// cpuclock
for (int i=counts[QString("cpu")]-1; i>=0; i--)
allKeys.append(QString("cpucl") + QString::number(i));
allKeys.append(QString("cpucl"));
// cpu
for (int i=counts[QString("cpu")]-1; i>=0; i--)
allKeys.append(QString("cpu") + QString::number(i));
allKeys.append(QString("cpu"));
// temperature
for (int i=counts[QString("temp")]-1; i>=0; i--)
allKeys.append(QString("temp") + QString::number(i));
for (int i=counts[QString("fan")]-1; i>=0; i--)
allKeys.append(QString("fan") + QString::number(i));
// gputemp
allKeys.append(QString("gputemp"));
// gpu
allKeys.append(QString("gpu"));
// memory
allKeys.append(QString("memmb"));
allKeys.append(QString("memgb"));
allKeys.append(QString("memfreemb"));
allKeys.append(QString("memfreegb"));
allKeys.append(QString("memtotmb"));
allKeys.append(QString("memtotgb"));
allKeys.append(QString("memusedmb"));
allKeys.append(QString("memusedgb"));
allKeys.append(QString("mem"));
// swap
allKeys.append(QString("swapmb"));
allKeys.append(QString("swapgb"));
allKeys.append(QString("swapfreemb"));
allKeys.append(QString("swapfreegb"));
allKeys.append(QString("swaptotmb"));
allKeys.append(QString("swaptotgb"));
allKeys.append(QString("swap"));
// hdd
for (int i=counts[QString("mount")]-1; i>=0; i--) {
allKeys.append(QString("hddmb") + QString::number(i));
allKeys.append(QString("hddgb") + QString::number(i));
allKeys.append(QString("hddfreemb") + QString::number(i));
allKeys.append(QString("hddfreegb") + QString::number(i));
allKeys.append(QString("hddtotmb") + QString::number(i));
allKeys.append(QString("hddtotgb") + QString::number(i));
allKeys.append(QString("hdd") + QString::number(i));
}
// hdd speed
for (int i=counts[QString("disk")]-1; i>=0; i--) {
allKeys.append(QString("hddr") + QString::number(i));
allKeys.append(QString("hddw") + QString::number(i));
}
// hdd temp
for (int i=counts[QString("hddtemp")]-1; i>=0; i--) {
allKeys.append(QString("hddtemp") + QString::number(i));
allKeys.append(QString("hddtemp") + QString::number(i));
}
// network
allKeys.append(QString("down"));
allKeys.append(QString("up"));
allKeys.append(QString("netdev"));
// battery
allKeys.append(QString("ac"));
for (int i=counts[QString("bat")]-1; i>=0; i--)
allKeys.append(QString("bat") + QString::number(i));
allKeys.append(QString("bat"));
// player
allKeys.append(QString("album"));
allKeys.append(QString("artist"));
allKeys.append(QString("duration"));
allKeys.append(QString("progress"));
allKeys.append(QString("title"));
// ps
allKeys.append(QString("pscount"));
allKeys.append(QString("pstotal"));
allKeys.append(QString("ps"));
// package manager
for (int i=counts[QString("pkg")]-1; i>=0; i--)
allKeys.append(QString("pkgcount") + QString::number(i));
// custom
for (int i=counts[QString("custom")]-1; i>=0; i--)
allKeys.append(QString("custom") + QString::number(i));
// desktop
allKeys.append(QString("desktop"));
allKeys.append(QString("ndesktop"));
allKeys.append(QString("tdesktops"));
return allKeys;
}
QStringList AwesomeWidget::findGraphicalItems()
{
if (debug) qDebug() << PDEBUG;
QStringList orderedKeys;
for (int i=0; i<graphicalItems.count(); i++)
orderedKeys.append(graphicalItems[i]->name() + graphicalItems[i]->bar());
orderedKeys.sort();
QStringList selectedKeys;
for (int i=orderedKeys.count()-1; i>=0; i--)
if (configuration[QString("text")].contains(QString("$") + orderedKeys[i])) {
if (debug) qDebug() << PDEBUG << ":" << "Found key" << orderedKeys[i];
selectedKeys.append(orderedKeys[i]);
}
return selectedKeys;
}
void AwesomeWidget::getGraphicalItems()
{
if (debug) qDebug() << PDEBUG;
graphicalItems.clear();
// create directory at $HOME
QString localDir = KStandardDirs::locateLocal("data", "plasma_applet_awesome-widget/desktops");
if (KStandardDirs::makeDir(localDir))
if (debug) qDebug() << PDEBUG << ":" << "Created directory" << localDir;
QStringList dirs = KGlobal::dirs()->findDirs("data", "plasma_applet_awesome-widget/desktops");
QStringList names;
for (int i=0; i<dirs.count(); i++) {
QStringList files = QDir(dirs[i]).entryList(QDir::Files, QDir::Name);
for (int j=0; j<files.count(); j++) {
if (!files[j].endsWith(QString(".desktop"))) continue;
if (names.contains(files[j])) continue;
if (debug) qDebug() << PDEBUG << ":" << "Found file" << files[j] << "in" << dirs[i];
names.append(files[j]);
graphicalItems.append(new GraphicalItem(0, files[j], dirs, debug));
}
}
}
GraphicalItem *AwesomeWidget::getItemByTag(const QString tag)
{
if (debug) qDebug() << PDEBUG;
GraphicalItem *item = nullptr;
for (int i=0; i< graphicalItems.count(); i++) {
if ((graphicalItems[i]->name() + graphicalItems[i]->bar()) != tag) continue;
item = graphicalItems[i];
break;
}
return item;
}
void AwesomeWidget::showKsysguard()
{
if (debug) qDebug() << PDEBUG;
QString cmd = QString("ksysguard");
if (debug) qDebug() << PDEBUG << ":" << "cmd" << cmd;
TaskResult process = runTask(cmd);
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
if (process.exitCode != 0)
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
}
void AwesomeWidget::showReadme()
{
if (debug) qDebug() << PDEBUG;
QDesktopServices::openUrl(QString("http://arcanis.name/projects/awesome-widgets/"));
}
void AwesomeWidget::showUpdates(QString version)
{
if (debug) qDebug() << PDEBUG;
QString text;
text += i18n("Current version : %1", QString(VERSION)) + QString("\n");
text += i18n("New version : %1", version) + QString("\n\n");
text += i18n("Click \"Ok\" to download");
int select = QMessageBox::information(0, i18n("There are updates"), text, QMessageBox::Ok | QMessageBox::Cancel);
switch (select) {
case QMessageBox::Ok:
QDesktopServices::openUrl(QString(RELEASES) + version);
break;
}
}
K_EXPORT_PLASMA_APPLET(awesome-widget, AwesomeWidget)

View File

@ -0,0 +1,154 @@
/***************************************************************************
* This file is part of awesome-widgets *
* *
* awesome-widgets is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* awesome-widgets is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#ifndef AWESOME_WIDGET_H
#define AWESOME_WIDGET_H
#include <Plasma/Applet>
#include <Plasma/DataEngine>
#include <Plasma/ToolTipContent>
#include <ui_about.h>
#include <ui_advanced.h>
#include <ui_appearance.h>
#include <ui_deconfig.h>
#include <ui_tooltipconfig.h>
#include <ui_widget.h>
class CustomLabel;
class ExtScript;
class ExtUpgrade;
class GraphicalItem;
class QGraphicsGridLayout;
class QGraphicsScene;
class QNetworkReply;
class AwesomeWidget : public Plasma::Applet
{
Q_OBJECT
public:
AwesomeWidget(QObject *parent, const QVariantList &args);
~AwesomeWidget();
QString getNetworkDevice();
int getNumberCpus();
float getTemp(const float temp);
QStringList getTimeKeys();
void init();
// de configuration
QMap<QString, QString> readDataEngineConfiguration();
void writeDataEngineConfiguration(const QMap<QString, QString> settings);
public slots:
// contextual actions
void showKsysguard();
void showReadme();
void showUpdates(QString version);
// dataengine
void addDiskDevice(const QString source);
void connectToEngine();
void dataUpdated(const QString &sourceName, const Plasma::DataEngine::Data &data);
void disconnectFromEngine();
// configuration interface
void configAccepted();
void configChanged();
// update events
void sendNotification(const QString eventId, const QString message);
void updateNetworkDevice(const bool delay = true);
void updateText(const bool clear = false);
void updateTooltip();
private slots:
void checkUpdates();
void reinit();
void replyRecieved(QNetworkReply *reply);
// configuration interface
void addBar();
void addCustomScript();
void addPkgCommand();
void contextMenuBars(const QPoint pos);
void contextMenuCustomCommand(const QPoint pos);
void contextMenuPkgCommand(const QPoint pos);
void copyBar(const QString original);
void copyCustomCommand(const QString original);
void copyPkgCommand(const QString original);
void editBar(QListWidgetItem *item);
void editCustomCommand(QListWidgetItem *item);
void editPkgCommand(QListWidgetItem *item);
void editFanItem(QListWidgetItem *item);
void editHddItem(QListWidgetItem *item);
void editHddSpeedItem(QListWidgetItem *item);
void editMountItem(QListWidgetItem *item);
void editTempItem(QListWidgetItem *item);
void setFontFormating();
void setFormating();
signals:
void thereIsUpdates(QString version);
protected:
QList<QAction *> contextualActions();
void createConfigurationInterface(KConfigDialog *parent);
private:
// functions
void createActions();
QStringList findKeys();
QStringList getKeys();
QStringList findGraphicalItems();
void getGraphicalItems();
GraphicalItem *getItemByTag(const QString tag);
QList<ExtScript *> initScripts();
QList<ExtUpgrade *> initUpgrades();
// ui
QGraphicsGridLayout *mainLayout = nullptr;
CustomLabel *textLabel = nullptr;
QTimer *timer = nullptr;
QList<QAction *> contextMenu;
// tooltip
Plasma::ToolTipContent toolTip;
QGraphicsScene *toolTipScene = nullptr;
QGraphicsView *toolTipView = nullptr;
// values
int networkDeviceUpdate = 0;
QMap<QString, int> counts;
QMap<QString, QList<float>> tooltipValues;
QMap<QString, QString> values;
// debug
bool debug;
// data engine
Plasma::DataEngine *extsysmonEngine = nullptr;
Plasma::DataEngine *sysmonEngine = nullptr;
Plasma::DataEngine *timeEngine = nullptr;
// configuration interface
Ui::About uiAboutConfig;
Ui::AdvancedWindow uiAdvancedConfig;
Ui::AppearanceWindow uiAppConfig;
Ui::ConfigWindow uiWidConfig;
Ui::DEWindow uiDEConfig;
Ui::TooltipWindow uiTooltipConfig;
// configuration
QMap<QString, QString> configuration;
QStringList diskDevices, keys, formatLine, foundKeys;
QList<GraphicalItem *> graphicalItems;
QStringList foundBars;
};
#endif /* AWESOME_WIDGET_H */

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,97 @@
/***************************************************************************
* This file is part of awesome-widgets *
* *
* awesome-widgets is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* awesome-widgets is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#include "customlabel.h"
#include <QGraphicsSceneMouseEvent>
#include <QTextCodec>
#include "awesome-widget.h"
#include <pdebug/pdebug.h>
#include <task/taskadds.h>
CustomLabel::CustomLabel(AwesomeWidget *wid, const bool debugCmd)
: QLabel(0),
widget(wid),
debug(debugCmd)
{
setWordWrap(false);
}
CustomLabel::~CustomLabel()
{
if (debug) qDebug() << PDEBUG;
}
void CustomLabel::setPopupEnabled(const bool state)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "State" << state;
enablePopup = state;
}
void CustomLabel::mousePressEvent(QMouseEvent *event)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Get signal" << event->button();
if ((enablePopup) && (event->button() == Qt::LeftButton)) {
QString cmd, text;
TaskResult process;
// kernel
cmd = QString("uname -rsm");
if (debug) qDebug() << PDEBUG << ":" << "cmd" << cmd;
process = runTask(cmd);
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
if (process.exitCode != 0)
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
text += QString("Kernel: %1<br>").arg(QTextCodec::codecForMib(106)->toUnicode(process.output).trimmed());
// hostname
cmd = QString("uname -n");
if (debug) qDebug() << PDEBUG << ":" << "cmd" << cmd;
process = runTask(cmd);
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
if (process.exitCode != 0)
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
text += QString("Hostname: %1<br>").arg(QTextCodec::codecForMib(106)->toUnicode(process.output).trimmed());
// whoami
cmd = QString("whoami");
if (debug) qDebug() << PDEBUG << ":" << "cmd" << cmd;
process = runTask(cmd);
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
if (process.exitCode != 0)
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
text += QString("Whoami: %1<br>").arg(QTextCodec::codecForMib(106)->toUnicode(process.output).trimmed());
// uptime
cmd = QString("uptime");
if (debug) qDebug() << PDEBUG << ":" << "cmd" << cmd;
process = runTask(cmd);
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
if (process.exitCode != 0)
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
text += QString("Uptime: %1").arg(QTextCodec::codecForMib(106)->toUnicode(process.output).trimmed());
widget->sendNotification(QString("system"), text);
}
emit(QWidget::mousePressEvent(event));
}

View File

@ -0,0 +1,45 @@
/***************************************************************************
* This file is part of awesome-widgets *
* *
* awesome-widgets is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* awesome-widgets is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#ifndef CUSTOMLABEL_H
#define CUSTOMLABEL_H
#include <QLabel>
class AwesomeWidget;
class CustomLabel : public QLabel
{
Q_OBJECT
public:
CustomLabel(AwesomeWidget *wid, const bool debugCmd = false);
~CustomLabel();
void setPopupEnabled(const bool state);
protected:
void mousePressEvent(QMouseEvent *event);
private:
AwesomeWidget *widget;
bool debug;
bool enablePopup = true;
};
#endif /* CUSTOMLABEL_H */

View File

@ -0,0 +1,440 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DEWindow</class>
<widget class="QWidget" name="DEWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>700</width>
<height>582</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>700</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="windowTitle">
<string notr="true">DE</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QScrollArea" name="scrollArea_dattaengine">
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="contents_dattaengine">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>684</width>
<height>566</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="4" column="0">
<layout class="QHBoxLayout" name="layout_hddtempCmd">
<item>
<widget class="QLabel" name="label_hddtempCmd">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>hddtemp cmd</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_hddtempCmd"/>
</item>
</layout>
</item>
<item row="2" column="0">
<layout class="QHBoxLayout" name="layout_gpudev">
<item>
<widget class="QLabel" name="label_gpudev">
<property name="text">
<string>GPU device</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox_gpudev">
<item>
<property name="text">
<string notr="true">auto</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">disable</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">nvidia</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">ati</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item row="3" column="0">
<layout class="QHBoxLayout" name="layout_hdddev">
<item>
<widget class="QLabel" name="label_hdddev">
<property name="text">
<string>HDD</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox_hdddev"/>
</item>
</layout>
</item>
<item row="8" column="0">
<layout class="QHBoxLayout" name="layout_playerSelect">
<item>
<widget class="QLabel" name="label_playerSelect">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Music player</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox_playerSelect">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<item>
<property name="text">
<string notr="true">mpris</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">mpd</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item row="6" column="0">
<layout class="QHBoxLayout" name="layout_mpdport">
<item>
<widget class="QLabel" name="label_mpdport">
<property name="text">
<string>MPD port</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinBox_mpdport">
<property name="minimum">
<number>0</number>
</property>
<property name="maximum">
<number>50000</number>
</property>
<property name="singleStep">
<number>100</number>
</property>
<property name="value">
<number>6600</number>
</property>
</widget>
</item>
</layout>
</item>
<item row="5" column="0">
<layout class="QHBoxLayout" name="layout_mpdaddress">
<item>
<widget class="QLabel" name="label_mpdaddress">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>MPD address</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_mpdaddress"/>
</item>
</layout>
</item>
<item row="10" column="0">
<spacer name="spacer_dataengine">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="0">
<layout class="QHBoxLayout" name="layout_acpi">
<item>
<widget class="QLabel" name="label_acpi">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>ACPI path</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_acpi">
<property name="toolTip">
<string>&quot;/sys/class/power_supply/&quot; by default</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="7" column="0">
<layout class="QVBoxLayout" name="layout_mpris">
<item>
<widget class="QLabel" name="label_mprisInfo">
<property name="text">
<string>&lt;b&gt;NOTE:&lt;/b&gt; Player DBus interface should be an active</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="layout_mprisSelect">
<item>
<widget class="QLabel" name="label_mpris">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>MPRIS player name</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox_mpris">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="editable">
<bool>true</bool>
</property>
<item>
<property name="text">
<string notr="true">auto</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">amarok</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">audacious</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">clementine</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">deadbeef</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">vlc</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">qmmp</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">xmms2</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item row="1" column="0">
<layout class="QVBoxLayout" name="layout_custom">
<item>
<layout class="QHBoxLayout" name="layout_customAdd">
<item>
<widget class="QLabel" name="label_custom">
<property name="text">
<string>Custom scripts</string>
</property>
</widget>
</item>
<item>
<spacer name="spacer_custom">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pushButton_custom">
<property name="text">
<string>Add</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QListWidget" name="listWidget_custom">
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
</widget>
</item>
</layout>
</item>
<item row="9" column="0">
<layout class="QVBoxLayout" name="layout_pkgCommand">
<item>
<layout class="QHBoxLayout" name="layout_pkgCommandAdd">
<item>
<widget class="QLabel" name="label_pkgCommand">
<property name="text">
<string>Package manager</string>
</property>
</widget>
</item>
<item>
<spacer name="spacer_pkgCommand">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pushButton_pkgCommand">
<property name="text">
<string>Add</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QListWidget" name="listWidget_pkgCommand">
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,606 @@
/***************************************************************************
* This file is part of awesome-widgets *
* *
* awesome-widgets is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* awesome-widgets is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#include "awesome-widget.h"
#include <QRegExp>
#include <math.h>
#include "graphicalitem.h"
#include <pdebug/pdebug.h>
void AwesomeWidget::connectToEngine()
{
if (debug) qDebug() << PDEBUG;
QRegExp regExp;
// battery
regExp = QRegExp(QString("(^|bar[0-9].*)(ac|bat.*)"));
if ((foundKeys.indexOf(regExp) > -1) ||
(configuration[QString("batteryTooltip")].toInt() == 2) ||
(foundBars.indexOf(regExp) > -1))
extsysmonEngine->connectSource(QString("battery"),
this, configuration[QString("interval")].toInt());
// cpu
regExp = QRegExp(QString("(^|bar[0-9].*)cpu(?!cl).*"));
if ((foundKeys.indexOf(regExp) > -1) ||
(configuration[QString("cpuTooltip")].toInt() == 2) ||
(foundBars.indexOf(regExp) > -1)) {
sysmonEngine->connectSource(QString("cpu/system/TotalLoad"),
this, configuration[QString("interval")].toInt());
for (int i=0; i<counts[QString("cpu")]; i++)
sysmonEngine->connectSource(QString("cpu/cpu") + QString::number(i) + QString("/TotalLoad"),
this, configuration[QString("interval")].toInt());
}
// cpuclock
regExp = QRegExp(QString("cpucl.*"));
if ((foundKeys.indexOf(regExp) > -1) ||
(configuration[QString("cpuclTooltip")].toInt() == 2)) {
sysmonEngine->connectSource(QString("cpu/system/AverageClock"),
this, configuration[QString("interval")].toInt());
for (int i=0; i<counts[QString("cpu")]; i++)
sysmonEngine->connectSource(QString("cpu/cpu") + QString::number(i) + QString("/clock"),
this, configuration[QString("interval")].toInt());
}
// custom command
regExp = QRegExp(QString("custom.*"));
if (foundKeys.indexOf(regExp) > -1)
extsysmonEngine->connectSource(QString("custom"),
this, configuration[QString("interval")].toInt());
// desktop
regExp = QRegExp(QString(".*desktop.*"));
if (foundKeys.indexOf(regExp) > -1)
extsysmonEngine->connectSource(QString("desktop"),
this, configuration[QString("interval")].toInt());
// disk speed
regExp = QRegExp(QString("hdd[rw].*"));
if (foundKeys.indexOf(regExp) > -1)
for (int i=0; i<configuration[QString("disk")].split(QString("@@")).count(); i++) {
sysmonEngine->connectSource(configuration[QString("disk")].split(QString("@@"))[i] + QString("/Rate/rblk"),
this, configuration[QString("interval")].toInt());
sysmonEngine->connectSource(configuration[QString("disk")].split(QString("@@"))[i] + QString("/Rate/wblk"),
this, configuration[QString("interval")].toInt());
}
// fan
regExp = QRegExp(QString("fan.*"));
if (foundKeys.indexOf(regExp) > -1)
for (int i=0; i<configuration[QString("fanDevice")].split(QString("@@")).count(); i++)
sysmonEngine->connectSource(configuration[QString("fanDevice")].split(QString("@@"))[i],
this, configuration[QString("interval")].toInt());
// gpu
regExp = QRegExp(QString("(^|bar[0-9].*)gpu"));
if ((foundKeys.indexOf(regExp) > -1) ||
(foundBars.indexOf(regExp) > -1))
extsysmonEngine->connectSource(QString("gpu"),
this, configuration[QString("interval")].toInt());
// gputemp
regExp = QRegExp(QString("gputemp"));
if (foundKeys.indexOf(regExp) > -1)
extsysmonEngine->connectSource(QString("gputemp"),
this, configuration[QString("interval")].toInt());
// mount
regExp = QRegExp(QString("(^|bar[0-9].*)hdd([0-9]|mb|gb|freemb|freegb|totmb|totgb).*"));
if ((foundKeys.indexOf(regExp) > -1) ||
(foundBars.indexOf(regExp) > -1))
for (int i=0; i<configuration[QString("mount")].split(QString("@@")).count(); i++) {
sysmonEngine->connectSource(QString("partitions") + configuration[QString("mount")].split(QString("@@"))[i] + QString("/filllevel"),
this, configuration[QString("interval")].toInt());
sysmonEngine->connectSource(QString("partitions") + configuration[QString("mount")].split(QString("@@"))[i] + QString("/freespace"),
this, configuration[QString("interval")].toInt());
sysmonEngine->connectSource(QString("partitions") + configuration[QString("mount")].split(QString("@@"))[i] + QString("/usedspace"),
this, configuration[QString("interval")].toInt());
}
// hddtemp
regExp = QRegExp(QString("hddtemp.*"));
if (foundKeys.indexOf(regExp) > -1)
extsysmonEngine->connectSource(QString("hddtemp"),
this, configuration[QString("interval")].toInt());
// memory
regExp = QRegExp(QString("(^|bar[0-9].*)mem.*"));
if ((foundKeys.indexOf(regExp) > -1) ||
(configuration[QString("memTooltip")].toInt() == 2) ||
(foundBars.indexOf(regExp) > -1)) {
sysmonEngine->connectSource(QString("mem/physical/free"),
this, configuration[QString("interval")].toInt());
sysmonEngine->connectSource(QString("mem/physical/used"),
this, configuration[QString("interval")].toInt());
sysmonEngine->connectSource(QString("mem/physical/application"),
this, configuration[QString("interval")].toInt());
}
// network
networkDeviceUpdate = 0;
regExp = QRegExp(QString("(down|up|netdev)"));
if ((foundKeys.indexOf(regExp) > -1) ||
(configuration[QString("downTooltip")].toInt() == 2)) {
sysmonEngine->connectSource(QString("network/interfaces/") + values[QString("netdev")] + QString("/transmitter/data"),
this, configuration[QString("interval")].toInt());
sysmonEngine->connectSource(QString("network/interfaces/") + values[QString("netdev")] + QString("/receiver/data"),
this, configuration[QString("interval")].toInt());
}
// package manager
regExp = QRegExp(QString("pkgcount.*"));
if (foundKeys.indexOf(regExp) > -1)
extsysmonEngine->connectSource(QString("pkg"),
this, configuration[QString("interval")].toInt());
// player
regExp = QRegExp(QString("(album|artist|duration|progress|title)"));
if (foundKeys.indexOf(regExp) > -1)
extsysmonEngine->connectSource(QString("player"),
this, configuration[QString("interval")].toInt());
// ps
regExp = QRegExp(QString("ps.*"));
if (foundKeys.indexOf(regExp) > -1)
extsysmonEngine->connectSource(QString("ps"),
this, configuration[QString("interval")].toInt());
// swap
regExp = QRegExp(QString("(^|bar[0-9].*)swap.*"));
if ((foundKeys.indexOf(regExp) > -1) ||
(configuration[QString("swapTooltip")].toInt() == 2) ||
(foundBars.indexOf(regExp) > -1)) {
sysmonEngine->connectSource(QString("mem/swap/free"),
this, configuration[QString("interval")].toInt());
sysmonEngine->connectSource(QString("mem/swap/used"),
this, configuration[QString("interval")].toInt());
}
// temp
regExp = QRegExp(QString("temp.*"));
if (foundKeys.indexOf(regExp) > -1)
for (int i=0; i<configuration[QString("tempDevice")].split(QString("@@")).count(); i++)
sysmonEngine->connectSource(configuration[QString("tempDevice")].split(QString("@@"))[i],
this, configuration[QString("interval")].toInt());
// time
regExp = QRegExp(QString("(^|iso|short|long|c)time"));
if (foundKeys.indexOf(regExp) > -1)
timeEngine->connectSource(QString("Local"),
this, 1000);
// uptime
regExp = QRegExp(QString("(^|c)uptime"));
if (foundKeys.indexOf(regExp) > -1)
sysmonEngine->connectSource(QString("system/uptime"),
this, configuration[QString("interval")].toInt());
}
void AwesomeWidget::dataUpdated(const QString &sourceName, const Plasma::DataEngine::Data &data)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Source" << sourceName;
// regular expressions
QRegExp cpuRegExp = QRegExp(QString("cpu/cpu.*/TotalLoad"));
QRegExp cpuclRegExp = QRegExp(QString("cpu/cpu.*/clock"));
QRegExp hddrRegExp = QRegExp(QString("disk/.*/Rate/rblk"));
QRegExp hddwRegExp = QRegExp(QString("disk/.*/Rate/wblk"));
QRegExp mountFillRegExp = QRegExp(QString("partitions/.*/filllevel"));
QRegExp mountFreeRegExp = QRegExp(QString("partitions/.*/freespace"));
QRegExp mountUsedRegExp = QRegExp(QString("partitions/.*/usedspace"));
QRegExp netRecRegExp = QRegExp(QString("network/interfaces/.*/receiver/data"));
QRegExp netTransRegExp = QRegExp(QString("network/interfaces/.*/transmitter/data"));
QRegExp tempRegExp = QRegExp(QString("lmsensors/.*"));
if (data.keys().isEmpty()) return;
if (sourceName == QString("battery")) {
for (int i=0; i<data.keys().count(); i++) {
if (data.keys()[i] == QString("ac")) {
if (data[QString("ac")].toBool())
values[QString("ac")] = configuration[QString("acOnline")];
else
values[QString("ac")] = configuration[QString("acOffline")];
} else {
values[data.keys()[i]] = QString("%1").arg(data[data.keys()[i]].toFloat(), 3, 'f', 0);
if (foundBars.indexOf(QRegExp(QString("bar[0-9].*bat"))) > -1) {
for (int j=0; j<foundBars.count(); j++) {
if (getItemByTag(foundBars[j])->bar() != data.keys()[i]) continue;
values[foundBars[j]] = values[data.keys()[i]];
}
}
}
}
if ((configuration[QString("batteryTooltip")].toInt() == 2) &&
(!isnan(data[QString("bat")].toFloat()))) {
if (tooltipValues[QString("bat")].count() > configuration[QString("tooltipNumber")].toInt())
tooltipValues[QString("bat")].takeFirst();
if (data[QString("ac")].toBool())
tooltipValues[QString("bat")].append(data[QString("bat")].toFloat());
else
tooltipValues[QString("bat")].append(-data[QString("bat")].toFloat());
}
} else if (sourceName == QString("cpu/system/TotalLoad")) {
values[QString("cpu")] = QString("%1").arg(data[QString("value")].toFloat(), 5, 'f', 1);
if (foundBars.indexOf(QRegExp(QString("bar[0-9].*cpu(?!cl).*"))) > -1) {
for (int j=0; j<foundBars.count(); j++) {
if (getItemByTag(foundBars[j])->bar() != QString("cpu")) continue;
values[foundBars[j]] = QString("%1").arg(data[QString("value")].toFloat());
}
}
if ((configuration[QString("cpuTooltip")].toInt() == 2) &&
(!isnan(data[QString("value")].toFloat()))) {
if (tooltipValues[QString("cpu")].count() > configuration[QString("tooltipNumber")].toInt())
tooltipValues[QString("cpu")].takeFirst();
tooltipValues[QString("cpu")].append(data[QString("value")].toFloat());
}
} else if (sourceName.contains(cpuRegExp)) {
QString number = sourceName;
number.remove(QString("cpu/cpu"));
number.remove(QString("/TotalLoad"));
values[QString("cpu") + number] = QString("%1").arg(data[QString("value")].toFloat(), 5, 'f', 1);
if (foundBars.indexOf(QRegExp(QString("bar[0-9].*cpu(?!cl).*"))) > -1) {
for (int j=0; j<foundBars.count(); j++) {
if (getItemByTag(foundBars[j])->bar() != (QString("cpu") + number)) continue;
values[foundBars[j]] = values[QString("cpu") + number];
}
}
} else if (sourceName == QString("cpu/system/AverageClock")) {
values[QString("cpucl")] = QString("%1").arg(data[QString("value")].toFloat(), 4, 'f', 0);
if ((configuration[QString("cpuclTooltip")].toInt() == 2) &&
(!isnan(data[QString("value")].toFloat()))) {
if (tooltipValues[QString("cpucl")].count() > configuration[QString("tooltipNumber")].toInt())
tooltipValues[QString("cpucl")].takeFirst();
tooltipValues[QString("cpucl")].append(data[QString("value")].toFloat());
}
} else if (sourceName.contains(cpuclRegExp)) {
QString number = sourceName;
number.remove(QString("cpu/cpu"));
number.remove(QString("/clock"));
values[QString("cpucl") + number] = QString("%1").arg(data[QString("value")].toFloat(), 4, 'f', 0);
} else if (sourceName == QString("custom")) {
for (int i=0; i<data.keys().count(); i++)
values[data.keys()[i]] = data[data.keys()[i]].toString();
} else if (sourceName == QString("desktop")) {
values[QString("desktop")] = data[QString("currentName")].toString();
values[QString("ndesktop")] = QString("%1").arg(data[QString("currentNumber")].toInt());
values[QString("tdesktops")] = QString("%1").arg(data[QString("number")].toInt());
} else if (sourceName.contains(hddrRegExp)) {
QString device = sourceName;
device.remove(QString("/Rate/rblk"));
for (int i=0; i<counts[QString("disk")]; i++)
if (configuration[QString("disk")].split(QString("@@"))[i] == device) {
values[QString("hddr") + QString::number(i)] = QString("%1").arg(data[QString("value")].toFloat(), 5, 'f', 0);
break;
}
} else if (sourceName.contains(hddwRegExp)) {
QString device = sourceName;
device.remove(QString("/Rate/wblk"));
for (int i=0; i<counts[QString("disk")]; i++)
if (configuration[QString("disk")].split(QString("@@"))[i] == device) {
values[QString("hddw") + QString::number(i)] = QString("%1").arg(data[QString("value")].toFloat(), 5, 'f', 0);
break;
}
} else if (sourceName == QString("gpu")) {
values[QString("gpu")] = QString("%1").arg(data[QString("value")].toFloat(), 5, 'f', 1);
if (foundBars.indexOf(QRegExp(QString("bar[0-9].*gpu"))) > -1) {
for (int j=0; j<foundBars.count(); j++) {
if (getItemByTag(foundBars[j])->bar() != QString("gpu")) continue;
values[foundBars[j]] = values[QString("gpu")];
}
}
} else if (sourceName == QString("gputemp")) {
values[QString("gputemp")] = QString("%1").arg(getTemp(data[QString("value")].toFloat()), 4, 'f', 1);
} else if (sourceName.contains(mountFillRegExp)) {
QString mount = sourceName;
mount.remove(QString("partitions"));
mount.remove(QString("/filllevel"));
for (int i=0; i<counts[QString("mount")]; i++)
if (configuration[QString("mount")].split(QString("@@"))[i] == mount) {
values[QString("hdd") + QString::number(i)] = QString("%1").arg(data[QString("value")].toFloat(), 5, 'f', 1);
if (foundBars.indexOf(QRegExp(QString("bar[0-9].*hdd([0-9].*"))) > -1) {
for (int j=0; j<foundBars.count(); j++) {
if (getItemByTag(foundBars[j])->bar() != (QString("hdd") + QString::number(i))) continue;
values[foundBars[j]] = values[QString("hdd") + QString::number(i)];
}
}
}
} else if (sourceName.contains(mountFreeRegExp)) {
QString mount = sourceName;
mount.remove(QString("partitions"));
mount.remove(QString("/freespace"));
for (int i=0; i<counts[QString("mount")]; i++)
if (configuration[QString("mount")].split(QString("@@"))[i] == mount) {
values[QString("hddfreemb") + QString::number(i)] = QString("%1").arg(
data[QString("value")].toFloat() / 1024.0, 5, 'f', 0);
values[QString("hddfreegb") + QString::number(i)] = QString("%1").arg(
data[QString("value")].toFloat() / (1024.0 * 1024.0), 5, 'f', 1);
break;
}
} else if (sourceName.contains(mountUsedRegExp)) {
QString mount = sourceName;
mount.remove(QString("partitions"));
mount.remove(QString("/usedspace"));
for (int i=0; i<counts[QString("mount")]; i++)
if (configuration[QString("mount")].split(QString("@@"))[i] == mount) {
values[QString("hddmb") + QString::number(i)] = QString("%1").arg(
data[QString("value")].toFloat() / 1024.0, 5, 'f', 0);
values[QString("hddgb") + QString::number(i)] = QString("%1").arg(
data[QString("value")].toFloat() / (1024.0 * 1024.0), 5, 'f', 1);
// total
values[QString("hddtotmb") + QString::number(i)] = QString("%1").arg(
values[QString("hddfreemb") + QString::number(i)].toInt() +
values[QString("hddmb") + QString::number(i)].toInt());
values[QString("hddtotgb") + QString::number(i)] = QString("%1").arg(
values[QString("hddfreegb") + QString::number(i)].toFloat() +
values[QString("hddgb") + QString::number(i)].toFloat(),
5, 'f', 1);
break;
}
} else if (sourceName == QString("hddtemp")) {
for (int i=0; i<data.keys().count(); i++)
for (int j=0; j<counts[QString("hddtemp")]; j++)
if (data.keys()[i] == configuration[QString("hdd")].split(QString("@@"))[j]) {
values[QString("hddtemp") + QString::number(j)] = QString("%1").arg(getTemp(data[data.keys()[i]].toFloat()), 4, 'f', 1);
break;
}
} else if (sourceName == QString("mem/physical/application")) {
values[QString("memmb")] = QString("%1").arg(data[QString("value")].toFloat() / 1024.0, 5, 'f', 0);
values[QString("memgb")] = QString("%1").arg(data[QString("value")].toFloat() / (1024.0 * 1024.0), 5, 'f', 1);
} else if (sourceName == QString("mem/physical/free")) {
values[QString("memfreemb")] = QString("%1").arg(data[QString("value")].toFloat() / 1024.0, 5, 'f', 0);
values[QString("memfreegb")] = QString("%1").arg(data[QString("value")].toFloat() / (1024.0 * 1024.0), 4, 'f', 1);
} else if (sourceName == QString("mem/physical/used")) {
values[QString("memusedmb")] = QString("%1").arg(data[QString("value")].toFloat() / 1024.0, 0, 'f', 0);
values[QString("memusedgb")] = QString("%1").arg(data[QString("value")].toFloat() / (1024.0 * 1024.0), 4, 'f', 1);
// total
values[QString("memtotmb")] = QString("%1").arg(
values[QString("memusedmb")].toInt() + values[QString("memfreemb")].toInt(), 5);
values[QString("memtotgb")] = QString("%1").arg(
values[QString("memusedgb")].toFloat() + values[QString("memfreegb")].toFloat(),
4, 'f', 1);
// percentage
values[QString("mem")] = QString("%1").arg(100.0 * values[QString("memmb")].toFloat() / values[QString("memtotmb")].toFloat(),
5, 'f', 1);
if ((configuration[QString("memTooltip")].toInt() == 2) &&
(!isnan(values[QString("mem")].toFloat()))) {
if (tooltipValues[QString("mem")].count() > configuration[QString("tooltipNumber")].toInt())
tooltipValues[QString("mem")].takeFirst();
tooltipValues[QString("mem")].append(values[QString("mem")].toFloat());
}
if (foundBars.indexOf(QRegExp(QString("bar[0-9].*mem"))) > -1) {
for (int j=0; j<foundBars.count(); j++) {
if (getItemByTag(foundBars[j])->bar() != QString("mem")) continue;
values[foundBars[j]] = values[QString("mem")];
}
}
} else if (sourceName.contains(netRecRegExp)) {
values[QString("down")] = QString("%1").arg(data[QString("value")].toFloat(), 4, 'f', 0);
if ((configuration[QString("downTooltip")].toInt() == 2) &&
(!isnan(data[QString("value")].toFloat()))) {
if (tooltipValues[QString("down")].count() > configuration[QString("tooltipNumber")].toInt())
tooltipValues[QString("down")].takeFirst();
tooltipValues[QString("down")].append(data[QString("value")].toFloat());
}
networkDeviceUpdate++;
if (networkDeviceUpdate >= 30) {
networkDeviceUpdate = 0;
if (configuration[QString("useCustomNetdev")].toInt() == 0) {
sysmonEngine->disconnectSource(QString("network/interfaces/") + values[QString("netdev")] + QString("/transmitter/data"), this);
sysmonEngine->disconnectSource(QString("network/interfaces/") + values[QString("netdev")] + QString("/receiver/data"), this);
updateNetworkDevice(false);
sysmonEngine->connectSource(QString("network/interfaces/") + values[QString("netdev")] + QString("/transmitter/data"),
this, configuration[QString("interval")].toInt());
sysmonEngine->connectSource(QString("network/interfaces/") + values[QString("netdev")] + QString("/receiver/data"),
this, configuration[QString("interval")].toInt());
}
}
} else if (sourceName.contains(netTransRegExp)) {
values[QString("up")] = QString("%1").arg(data[QString("value")].toFloat(), 4, 'f', 0);
if ((configuration[QString("downTooltip")].toInt() == 2) &&
(!isnan(data[QString("value")].toFloat()))) {
if (tooltipValues[QString("up")].count() > configuration[QString("tooltipNumber")].toInt())
tooltipValues[QString("up")].takeFirst();
tooltipValues[QString("up")].append(data[QString("value")].toFloat());
}
} else if (sourceName == QString("pkg")) {
for (int i=0; i<data.keys().count(); i++)
values[data.keys()[i].toLower()] = QString("%1").arg(data[data.keys()[i]].toInt(), 2);
} else if (sourceName == QString("player")) {
values[QString("album")] = data[QString("album")].toString();
values[QString("artist")] = data[QString("artist")].toString();
values[QString("duration")] = data[QString("duration")].toString();
values[QString("progress")] = data[QString("progress")].toString();
values[QString("title")] = data[QString("title")].toString();
} else if (sourceName == QString("ps")) {
values[QString("ps")] = data[QString("ps")].toString();
values[QString("pscount")] = QString("%1").arg(data[QString("psCount")].toInt(), 2);
values[QString("pstotal")] = QString("%1").arg(data[QString("psTotal")].toInt(), 3);
} else if (sourceName == QString("mem/swap/free")) {
values[QString("swapfreemb")] = QString("%1").arg(data[QString("value")].toFloat() / 1024.0, 5, 'f', 0);
values[QString("swapfreegb")] = QString("%1").arg(data[QString("value")].toFloat() / (1024.0 * 1024.0), 4, 'f', 1);
} else if (sourceName == QString("mem/swap/used")) {
values[QString("swapmb")] = QString("%1").arg(data[QString("value")].toFloat() / 1024.0, 5, 'f', 0);
values[QString("swapgb")] = QString("%1").arg(data[QString("value")].toFloat() / (1024.0 * 1024.0), 4, 'f', 1);
// total
values[QString("swaptotmb")] = QString("%1").arg(
values[QString("swapmb")].toInt() + values[QString("swapfreemb")].toInt(), 5);
values[QString("swaptotgb")] = QString("%1").arg(
values[QString("swapgb")].toFloat() + values[QString("swapfreegb")].toFloat(), 4, 'f', 1);
// percentage
values[QString("swap")] = QString("%1").arg(100.0 * values[QString("swapmb")].toFloat() / values[QString("swaptotmb")].toFloat(),
5, 'f', 1);
if ((configuration[QString("swapTooltip")].toInt() == 2) &&
(!isnan(values[QString("swap")].toFloat()))) {
if (tooltipValues[QString("swap")].count() > configuration[QString("tooltipNumber")].toInt())
tooltipValues[QString("swap")].takeFirst();
tooltipValues[QString("swap")].append(values[QString("swap")].toFloat());
}
if (foundBars.indexOf(QRegExp(QString("bar[0-9].*swap"))) > -1) {
for (int j=0; j<foundBars.count(); j++) {
if (getItemByTag(foundBars[j])->bar() != QString("swap")) continue;
values[foundBars[j]] = values[QString("swap")];
}
}
} else if (sourceName.contains(tempRegExp)) {
if (data[QString("units")].toString() == QString("rpm")) {
for (int i=0; i<counts[QString("fan")]; i++)
if (sourceName == configuration[QString("fanDevice")].split(QString("@@"))[i]) {
values[QString("fan") + QString::number(i)] = QString("%1").arg(data[QString("value")].toFloat(), 4, 'f', 1);
break;
}
} else {
for (int i=0; i<counts[QString("temp")]; i++)
if (sourceName == configuration[QString("tempDevice")].split(QString("@@"))[i]) {
values[QString("temp") + QString::number(i)] = QString("%1").arg(getTemp(data[QString("value")].toFloat()), 4, 'f', 1);
break;
}
}
} else if (sourceName == QString("Local")) {
values[QString("time")] = data[QString("DateTime")].toDateTime().toString(Qt::TextDate);
values[QString("isotime")] = data[QString("DateTime")].toDateTime().toString(Qt::ISODate);
values[QString("shorttime")] = data[QString("DateTime")].toDateTime().toString(Qt::SystemLocaleShortDate);
values[QString("longtime")] = data[QString("DateTime")].toDateTime().toString(Qt::SystemLocaleLongDate);
QStringList timeKeys = getTimeKeys();
values[QString("ctime")] = configuration[QString("customTime")];
for (int i=0; i<timeKeys.count(); i++)
values[QString("ctime")].replace(QString("$") + timeKeys[i],
data[QString("DateTime")].toDateTime().toString(timeKeys[i]));
} else if (sourceName == QString("system/uptime")) {
int uptime = data[QString("value")].toFloat();
int seconds = uptime - uptime % 60;
int minutes = seconds / 60 % 60;
int hours = ((seconds / 60) - minutes) / 60 % 24;
int days = (((seconds / 60) - minutes) / 60 - hours) / 24;
values[QString("uptime")] = QString("%1d%2h%3m").arg(days, 3).arg(hours, 2).arg(minutes, 2);
values[QString("cuptime")] = configuration[QString("customUptime")];
values[QString("cuptime")].replace(QString("$dd"), QString("%1").arg(days, 3, 10, QChar('0')));
values[QString("cuptime")].replace(QString("$d"), QString("%1").arg(days));
values[QString("cuptime")].replace(QString("$hh"), QString("%1").arg(hours, 2, 10, QChar('0')));
values[QString("cuptime")].replace(QString("$h"), QString("%1").arg(hours));
values[QString("cuptime")].replace(QString("$mm"), QString("%1").arg(minutes, 2, 10, QChar('0')));
values[QString("cuptime")].replace(QString("$m"), QString("%1").arg(minutes));
}
}
void AwesomeWidget::disconnectFromEngine()
{
if (debug) qDebug() << PDEBUG;
QRegExp regExp;
// battery
regExp = QRegExp(QString("(^|bar[0-9].*)(ac|bat.*)"));
if ((foundKeys.indexOf(regExp) > -1) ||
(configuration[QString("batteryTooltip")].toInt() == 2) ||
(foundBars.indexOf(regExp) > -1))
extsysmonEngine->disconnectSource(QString("battery"), this);
// cpu
regExp = QRegExp(QString("(^|bar[0-9].*)cpu(?!cl).*"));
if ((foundKeys.indexOf(regExp) > -1) ||
(configuration[QString("cpuTooltip")].toInt() == 2) ||
(foundBars.indexOf(regExp) > -1)) {
sysmonEngine->disconnectSource(QString("cpu/system/TotalLoad"), this);
for (int i=0; i<counts[QString("cpu")]; i++)
sysmonEngine->disconnectSource(QString("cpu/cpu") + QString::number(i) + QString("/TotalLoad"), this);
}
// cpuclock
regExp = QRegExp(QString("cpucl.*"));
if ((foundKeys.indexOf(regExp) > -1) ||
(configuration[QString("cpuclTooltip")].toInt() == 2)) {
sysmonEngine->disconnectSource(QString("cpu/system/AverageClock"), this);
for (int i=0; i<counts[QString("cpu")]; i++)
sysmonEngine->disconnectSource(QString("cpu/cpu") + QString::number(i) + QString("/clock"), this);
}
// custom command
regExp = QRegExp(QString("custom.*"));
if (foundKeys.indexOf(regExp) > -1)
extsysmonEngine->disconnectSource(QString("custom"), this);
// desktop
regExp = QRegExp(QString(".*desktop.*"));
if (foundKeys.indexOf(regExp) > -1)
extsysmonEngine->disconnectSource(QString("desktop"), this);
// disk speed
regExp = QRegExp(QString("hdd[rw].*"));
if (foundKeys.indexOf(regExp) > -1)
for (int i=0; i<configuration[QString("disk")].split(QString("@@")).count(); i++) {
sysmonEngine->disconnectSource(configuration[QString("disk")].split(QString("@@"))[i] + QString("/Rate/rblk"), this);
sysmonEngine->disconnectSource(configuration[QString("disk")].split(QString("@@"))[i] + QString("/Rate/wblk"), this);
}
// fan
regExp = QRegExp(QString("fan.*"));
if (foundKeys.indexOf(regExp) > -1)
for (int i=0; i<configuration[QString("fanDevice")].split(QString("@@")).count(); i++)
sysmonEngine->disconnectSource(configuration[QString("fanDevice")].split(QString("@@"))[i], this);
// gpu
regExp = QRegExp(QString("(^|bar[0-9].*)gpu"));
if ((foundKeys.indexOf(regExp) > -1) ||
(foundBars.indexOf(regExp) > -1))
extsysmonEngine->disconnectSource(QString("gpu"), this);
// gputemp
regExp = QRegExp(QString("gputemp"));
if (foundKeys.indexOf(regExp) > -1)
extsysmonEngine->disconnectSource(QString("gputemp"), this);
// mount
regExp = QRegExp(QString("(^|bar[0-9].*)hdd([0-9]|mb|gb|freemb|freegb|totmb|totgb).*"));
if ((foundKeys.indexOf(regExp) > -1) ||
(foundBars.indexOf(regExp) > -1))
for (int i=0; i<configuration[QString("mount")].split(QString("@@")).count(); i++) {
sysmonEngine->disconnectSource(QString("partitions") + configuration[QString("mount")].split(QString("@@"))[i] + QString("/filllevel"), this);
sysmonEngine->disconnectSource(QString("partitions") + configuration[QString("mount")].split(QString("@@"))[i] + QString("/freespace"), this);
sysmonEngine->disconnectSource(QString("partitions") + configuration[QString("mount")].split(QString("@@"))[i] + QString("/usedspace"), this);
}
// hddtemp
regExp = QRegExp(QString("hddtemp.*"));
if (foundKeys.indexOf(regExp) > -1)
extsysmonEngine->disconnectSource(QString("hddtemp"), this);
// memory
regExp = QRegExp(QString("(^|bar[0-9].*)mem.*"));
if ((foundKeys.indexOf(regExp) > -1) ||
(configuration[QString("memTooltip")].toInt() == 2) ||
(foundBars.indexOf(regExp) > -1)) {
sysmonEngine->disconnectSource(QString("mem/physical/free"), this);
sysmonEngine->disconnectSource(QString("mem/physical/used"), this);
sysmonEngine->disconnectSource(QString("mem/physical/application"), this);
}
// network
regExp = QRegExp(QString("(down|up|netdev)"));
if ((foundKeys.indexOf(regExp) > -1) ||
(configuration[QString("downTooltip")].toInt() == 2)) {
sysmonEngine->disconnectSource(QString("network/interfaces/") + values[QString("netdev")] + QString("/transmitter/data"), this);
sysmonEngine->disconnectSource(QString("network/interfaces/") + values[QString("netdev")] + QString("/receiver/data"), this);
}
// package manager
regExp = QRegExp(QString("pkgcount.*"));
if (foundKeys.indexOf(regExp) > -1)
extsysmonEngine->disconnectSource(QString("pkg"), this);
// player
regExp = QRegExp(QString("(album|artist|duration|progress|title)"));
if (foundKeys.indexOf(regExp) > -1)
extsysmonEngine->disconnectSource(QString("player"), this);
// ps
regExp = QRegExp(QString("ps.*"));
if (foundKeys.indexOf(regExp) > -1)
extsysmonEngine->disconnectSource(QString("ps"), this);
// swap
regExp = QRegExp(QString("(^|bar[0-9].*)swap.*"));
if ((foundKeys.indexOf(regExp) > -1) ||
(configuration[QString("swapTooltip")].toInt() == 2) ||
(foundBars.indexOf(regExp) > -1)) {
sysmonEngine->disconnectSource(QString("mem/swap/free"), this);
sysmonEngine->disconnectSource(QString("mem/swap/used"), this);
}
// temp
regExp = QRegExp(QString("temp.*"));
if (foundKeys.indexOf(regExp) > -1)
for (int i=0; i<configuration[QString("tempDevice")].split(QString("@@")).count(); i++)
sysmonEngine->disconnectSource(configuration[QString("tempDevice")].split(QString("@@"))[i], this);
// time
regExp = QRegExp(QString("(^|iso|short|long|c)time"));
if (foundKeys.indexOf(regExp) > -1)
timeEngine->disconnectSource(QString("Local"), this);
// uptime
regExp = QRegExp(QString("(^|c)uptime"));
if (foundKeys.indexOf(regExp) > -1)
sysmonEngine->disconnectSource(QString("system/uptime"), this);
}

View File

@ -0,0 +1,12 @@
[Desktop Entry]
Encoding=UTF-8
Name=bar3
Comment=Simple bat bar
X-AW-Value=bat
X-AW-ActiveColor="0,0,0,255"
X-AW-InactiveColor="255,255,255,255"
X-AW-Type=Horizontal
X-AW-Direction=LeftToRight
X-AW-Height=25
X-AW-Width=100
X-AW-ApiVersion=1

View File

@ -0,0 +1,12 @@
[Desktop Entry]
Encoding=UTF-8
Name=bar0
Comment=Simple cpu bar
X-AW-Value=cpu
X-AW-ActiveColor="0,0,0,255"
X-AW-InactiveColor="255,255,255,255"
X-AW-Type=Horizontal
X-AW-Direction=LeftToRight
X-AW-Height=25
X-AW-Width=100
X-AW-ApiVersion=1

View File

@ -0,0 +1,12 @@
[Desktop Entry]
Encoding=UTF-8
Name=bar1
Comment=Simple mem bar
X-AW-Value=mem
X-AW-ActiveColor="0,0,0,255"
X-AW-InactiveColor="255,255,255,255"
X-AW-Type=Horizontal
X-AW-Direction=LeftToRight
X-AW-Height=25
X-AW-Width=100
X-AW-ApiVersion=1

View File

@ -0,0 +1,12 @@
[Desktop Entry]
Encoding=UTF-8
Name=bar2
Comment=Simple swap bar
X-AW-Value=swap
X-AW-ActiveColor="0,0,0,255"
X-AW-InactiveColor="255,255,255,255"
X-AW-Type=Horizontal
X-AW-Direction=LeftToRight
X-AW-Height=25
X-AW-Width=100
X-AW-ApiVersion=1

View File

@ -0,0 +1,25 @@
[Desktop Entry]
Encoding=UTF-8
# name should be barN and uniq
Name=bar100500
Comment=Template for the AW bars
# value to show. Supported types are
# cpu, cpu[0-9], mem, swap, bat
X-AW-Value=cpu
# active color, RGBA
# you should use double quotes
X-AW-ActiveColor="0,0,0,255"
# inactive color, RGBA
# you should use double quotes
X-AW-InactiveColor="255,255,255,255"
# bar type. Supported types are
# Horizontal, Vertical, Circle
X-AW-Type=Horizontal
# direction. LeftToRight or RightToLeft
X-AW-Direction=LeftToRight
# height in pixels
X-AW-Height=25
# width in pixels
X-AW-Width=100
# API version
X-AW-ApiVersion=1

View File

@ -0,0 +1,523 @@
/***************************************************************************
* This file is part of awesome-widgets *
* *
* awesome-widgets is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* awesome-widgets is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#include "graphicalitem.h"
#include "ui_graphicalitem.h"
#include <QBuffer>
#include <QColorDialog>
#include <QDebug>
#include <QDir>
#include <QGraphicsEllipseItem>
#include <QGraphicsScene>
#include <QGraphicsView>
#include <QSettings>
#include <pdebug/pdebug.h>
#include "version.h"
GraphicalItem::GraphicalItem(QWidget *parent, const QString desktopName, const QStringList directories, const bool debugCmd)
: QDialog(parent),
m_fileName(desktopName),
m_dirs(directories),
debug(debugCmd),
ui(new Ui::GraphicalItem)
{
readConfiguration();
ui->setupUi(this);
connect(ui->pushButton_activeColor, SIGNAL(clicked()), this, SLOT(changeColor()));
connect(ui->pushButton_inactiveColor, SIGNAL(clicked()), this, SLOT(changeColor()));
}
GraphicalItem::~GraphicalItem()
{
if (debug) qDebug() << PDEBUG;
delete ui;
}
QString GraphicalItem::image(const float value)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Value" << value;
if (m_bar == QString("none")) return QString("");
QColor active = stringToColor(m_activeColor);
QColor inactive = stringToColor(m_inactiveColor);
float percent = value / 100.0;
int scale[2] = {1, 1};
QPen pen = QPen();
QGraphicsScene *scene = new QGraphicsScene();
scene->setBackgroundBrush(QBrush(Qt::NoBrush));
QGraphicsView *view = new QGraphicsView(scene);
view->setStyleSheet(QString("background: transparent"));
view->setContentsMargins(0, 0, 0, 0);
view->setFrameShape(QFrame::NoFrame);
view->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
view->resize(m_width + 5.0, m_height + 5.0);
// paint
switch(m_type) {
case Vertical:
pen.setWidth(m_width);
// inactive
pen.setColor(inactive);
scene->addLine(0.5 * m_width, -0.5 * m_width, 0.5 * m_width,
(1.0 - percent) * m_height - 0.5 * m_width, pen);
// active
pen.setColor(active);
scene->addLine(0.5 * m_width, (1.0 - percent) * m_height + 0.5 * m_width,
0.5 * m_width, m_height + 0.5 * m_width, pen);
// scale
scale[1] = -2 * static_cast<int>(m_direction) + 1;
break;
case Circle:
QGraphicsEllipseItem *circle;
pen.setWidth(1.0);
// inactive
pen.setColor(inactive);
circle = scene->addEllipse(0.0, 0.0, m_width, m_height, pen, QBrush(inactive, Qt::SolidPattern));
circle->setSpanAngle(- (1.0 - percent) * 360.0 * 16.0);
circle->setStartAngle(90.0 * 16.0 - percent * 360.0 * 16.0);
// active
pen.setColor(active);
circle = scene->addEllipse(0.0, 0.0, m_width, m_height, pen, QBrush(active, Qt::SolidPattern));
circle->setSpanAngle(- percent * 360.0 * 16.0);
circle->setStartAngle(90.0 * 16.0);
// scale
scale[0] = -2 * static_cast<int>(m_direction) + 1;
break;
default:
pen.setWidth(m_height);
// inactive
pen.setColor(inactive);
scene->addLine(percent * m_width + 0.5 * m_height, 0.5 * m_height,
m_width + 0.5 * m_height, 0.5 * m_height, pen);
// active
pen.setColor(active);
scene->addLine(-0.5 * m_height, 0.5 * m_height,
percent * m_width - 0.5 * m_height, 0.5 * m_height, pen);
// scale
scale[0] = -2 * static_cast<int>(m_direction) + 1;
break;
}
// convert
QPixmap pixmap = QPixmap::grabWidget(view).transformed(QTransform().scale(scale[0], scale[1]));
QByteArray byteArray;
QBuffer buffer(&byteArray);
pixmap.save(&buffer, "PNG");
QString url = QString("<img src=\"data:image/png;base64,%1\"/>").arg(QString(byteArray.toBase64()));
delete view;
delete scene;
return url;
}
QString GraphicalItem::fileName()
{
if (debug) qDebug() << PDEBUG;
return m_fileName;
}
int GraphicalItem::apiVersion()
{
if (debug) qDebug() << PDEBUG;
return m_apiVersion;
}
QString GraphicalItem::name()
{
if (debug) qDebug() << PDEBUG;
return m_name;
}
QString GraphicalItem::comment()
{
if (debug) qDebug() << PDEBUG;
return m_comment;
}
QString GraphicalItem::bar()
{
if (debug) qDebug() << PDEBUG;
return m_bar;
}
QString GraphicalItem::activeColor()
{
if (debug) qDebug() << PDEBUG;
return m_activeColor;
}
QString GraphicalItem::inactiveColor()
{
if (debug) qDebug() << PDEBUG;
return m_inactiveColor;
}
GraphicalItem::Type GraphicalItem::type()
{
if (debug) qDebug() << PDEBUG;
return m_type;
}
QString GraphicalItem::strType()
{
if (debug) qDebug() << PDEBUG;
QString value;
switch(m_type) {
case Vertical:
value = QString("Vertical");
break;
case Circle:
value = QString("Circle");
break;
default:
value = QString("Horizontal");
break;
}
return value;
}
GraphicalItem::Direction GraphicalItem::direction()
{
if (debug) qDebug() << PDEBUG;
return m_direction;
}
QString GraphicalItem::strDirection()
{
if (debug) qDebug() << PDEBUG;
QString value;
switch (m_direction) {
case RightToLeft:
value = QString("RightToLeft");
break;
default:
value = QString("LeftToRight");
break;
}
return value;
}
int GraphicalItem::height()
{
if (debug) qDebug() << PDEBUG;
return m_height;
}
int GraphicalItem::width()
{
if (debug) qDebug() << PDEBUG;
return m_width;
}
void GraphicalItem::setApiVersion(const int _apiVersion)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Version" << _apiVersion;
m_apiVersion = _apiVersion;
}
void GraphicalItem::setName(const QString _name)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Name" << _name;
m_name = _name;
}
void GraphicalItem::setComment(const QString _comment)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Comment" << _comment;
m_comment = _comment;
}
void GraphicalItem::setBar(const QString _bar)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Bar" << _bar;
if ((!_bar.contains(QRegExp(QString("cpu(?!cl).*")))) &&
(!_bar.contains(QRegExp(QString("gpu")))) &&
(!_bar.contains(QRegExp(QString("mem")))) &&
(!_bar.contains(QRegExp(QString("swap")))) &&
(!_bar.contains(QRegExp(QString("hdd[0-9].*")))) &&
(!_bar.contains(QRegExp(QString("bat.*")))))
m_bar = QString("none");
else
m_bar = _bar;
}
void GraphicalItem::setActiveColor(const QString _color)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Color" << _color;
m_activeColor = _color;
}
void GraphicalItem::setInactiveColor(const QString _color)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Color" << _color;
m_inactiveColor = _color;
}
void GraphicalItem::setType(const Type _type)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Type" << _type;
m_type = _type;
}
void GraphicalItem::setStrType(const QString _type)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Type" << _type;
if (_type == QString("Vertical"))
setType(Vertical);
else if (_type == QString("Circle"))
setType(Circle);
else
setType(Horizontal);
}
void GraphicalItem::setDirection(const Direction _direction)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Direction" << _direction;
m_direction = _direction;
}
void GraphicalItem::setStrDirection(const QString _direction)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Direction" << _direction;
if (_direction == QString("RightToLeft"))
setDirection(RightToLeft);
else
setDirection(LeftToRight);
}
void GraphicalItem::setHeight(const int _height)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Height" << _height;
if (_height <= 0) return;
m_height = _height;
}
void GraphicalItem::setWidth(const int _width)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Width" << _width;
if (_width <= 0) return;
m_width = _width;
}
void GraphicalItem::readConfiguration()
{
if (debug) qDebug() << PDEBUG;
for (int i=m_dirs.count()-1; i>=0; i--) {
if (!QDir(m_dirs[i]).entryList(QDir::Files).contains(m_fileName)) continue;
QSettings settings(m_dirs[i] + QDir::separator() + m_fileName, QSettings::IniFormat);
settings.beginGroup(QString("Desktop Entry"));
setName(settings.value(QString("Name"), m_name).toString());
setComment(settings.value(QString("Comment"), m_comment).toString());
setApiVersion(settings.value(QString("X-AW-ApiVersion"), AWGIAPI).toInt());
setBar(settings.value(QString("X-AW-Value"), m_bar).toString());
setActiveColor(settings.value(QString("X-AW-ActiveColor"), m_activeColor).toString());
setInactiveColor(settings.value(QString("X-AW-InactiveColor"), m_inactiveColor).toString());
setStrType(settings.value(QString("X-AW-Type"), strType()).toString());
setStrDirection(settings.value(QString("X-AW-Direction"), strDirection()).toString());
setHeight(settings.value(QString("X-AW-Height"), m_height).toInt());
setWidth(settings.value(QString("X-AW-Width"), m_width).toInt());
settings.endGroup();
}
}
int GraphicalItem::showConfiguration(const QStringList tags)
{
if (debug) qDebug() << PDEBUG;
ui->label_nameValue->setText(m_name);
ui->lineEdit_comment->setText(m_comment);
ui->comboBox_value->addItems(tags);
ui->comboBox_value->addItem(m_bar);
ui->comboBox_value->setCurrentIndex(ui->comboBox_value->count() - 1);
ui->pushButton_activeColor->setText(m_activeColor);
ui->pushButton_inactiveColor->setText(m_inactiveColor);
ui->comboBox_type->setCurrentIndex(static_cast<int>(m_type));
ui->comboBox_direction->setCurrentIndex(static_cast<int>(m_direction));
ui->spinBox_height->setValue(m_height);
ui->spinBox_width->setValue(m_width);
int ret = exec();
if (ret != 1) return ret;
setName(ui->label_nameValue->text());
setComment(ui->lineEdit_comment->text());
setApiVersion(AWGIAPI);
setBar(ui->comboBox_value->currentText());
setActiveColor(ui->pushButton_activeColor->text().remove(QChar('&')));
setInactiveColor(ui->pushButton_inactiveColor->text().remove(QChar('&')));
setStrType(ui->comboBox_type->currentText());
setStrDirection(ui->comboBox_direction->currentText());
setHeight(ui->spinBox_height->value());
setWidth(ui->spinBox_width->value());
writeConfiguration();
return ret;
}
int GraphicalItem::tryDelete()
{
if (debug) qDebug() << PDEBUG;
for (int i=0; i<m_dirs.count(); i++)
if (debug) qDebug() << PDEBUG << ":" << "Remove file" << m_dirs[i] + QDir::separator() + m_fileName <<
QFile::remove(m_dirs[i] + QDir::separator() + m_fileName);
// check if exists
for (int i=0; i<m_dirs.count(); i++)
if (QFile::exists(m_dirs[i] + QDir::separator() + m_fileName)) return 0;
return 1;
}
void GraphicalItem::writeConfiguration()
{
if (debug) qDebug() << PDEBUG;
QSettings settings(m_dirs[0] + QDir::separator() + m_fileName, QSettings::IniFormat);
if (debug) qDebug() << PDEBUG << ":" << "Configuration file" << settings.fileName();
settings.beginGroup(QString("Desktop Entry"));
settings.setValue(QString("Encoding"), QString("UTF-8"));
settings.setValue(QString("Name"), m_name);
settings.setValue(QString("Comment"), m_comment);
settings.setValue(QString("X-AW-ApiVersion"), m_apiVersion);
settings.setValue(QString("X-AW-Value"), m_bar);
settings.setValue(QString("X-AW-ActiveColor"), m_activeColor);
settings.setValue(QString("X-AW-InactiveColor"), m_inactiveColor);
settings.setValue(QString("X-AW-Type"), strType());
settings.setValue(QString("X-AW-Direction"), strDirection());
settings.setValue(QString("X-AW-Height"), m_height);
settings.setValue(QString("X-AW-Width"), m_width);
settings.endGroup();
settings.sync();
}
void GraphicalItem::changeColor()
{
if (debug) qDebug() << PDEBUG;
QColor color = stringToColor(((QPushButton *)sender())->text());
QColor newColor = QColorDialog::getColor(color, 0, i18n("Select color"),
QColorDialog::ShowAlphaChannel);
if (!newColor.isValid()) return;
QStringList colorText;
colorText.append(QString("%1").arg(newColor.red()));
colorText.append(QString("%1").arg(newColor.green()));
colorText.append(QString("%1").arg(newColor.blue()));
colorText.append(QString("%1").arg(newColor.alpha()));
dynamic_cast<QPushButton *>(sender())->setText(colorText.join(QChar(',')));
}
QColor GraphicalItem::stringToColor(const QString _color)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Color" << _color;
QColor qcolor;
QStringList listColor = _color.split(QChar(','));
while (listColor.count() < 4)
listColor.append(QString("0"));
qcolor.setRed(listColor[0].toInt());
qcolor.setGreen(listColor[1].toInt());
qcolor.setBlue(listColor[2].toInt());
qcolor.setAlpha(listColor[3].toInt());
return qcolor;
}

View File

@ -0,0 +1,115 @@
/***************************************************************************
* This file is part of awesome-widgets *
* *
* awesome-widgets is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* awesome-widgets is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#ifndef GRAPHICALITEM_H
#define GRAPHICALITEM_H
#include <QColor>
#include <QDialog>
namespace Ui {
class GraphicalItem;
}
class GraphicalItem : public QDialog
{
Q_OBJECT
Q_PROPERTY(int apiVersion READ apiVersion WRITE setApiVersion)
Q_PROPERTY(QString name READ name WRITE setName)
Q_PROPERTY(QString comment READ comment WRITE setComment)
Q_PROPERTY(QString bar READ bar WRITE setBar)
Q_PROPERTY(QString activeColor READ activeColor WRITE setActiveColor)
Q_PROPERTY(QString inactiveColor READ inactiveColor WRITE setInactiveColor)
Q_PROPERTY(Type type READ type WRITE setType)
Q_PROPERTY(Direction direction READ direction WRITE setDirection)
Q_PROPERTY(int height READ height WRITE setHeight)
Q_PROPERTY(int width READ width WRITE setWidth)
public:
enum Direction {
LeftToRight = 0,
RightToLeft
};
enum Type {
Horizontal = 0,
Vertical,
Circle
};
explicit GraphicalItem(QWidget *parent = 0, const QString desktopName = QString(),
const QStringList directories = QStringList(), const bool debugCmd = false);
~GraphicalItem();
QString fileName();
QString image(const float value);
// get methods
int apiVersion();
QString name();
QString comment();
QString bar();
QString activeColor();
QString inactiveColor();
Type type();
QString strType();
Direction direction();
QString strDirection();
int height();
int width();
// set methods
void setApiVersion(const int _apiVersion = 0);
void setName(const QString _name = QString("none"));
void setComment(const QString _comment = QString("empty"));
void setBar(const QString _bar = QString("cpu"));
void setActiveColor(const QString _color = QString("0,0,0,130"));
void setInactiveColor(const QString _color = QString("255,255,255,130"));
void setType(const Type _type = Horizontal);
void setStrType(const QString _type = QString("Horizontal"));
void setDirection(const Direction _direction = LeftToRight);
void setStrDirection(const QString _direction = QString("LeftToRight"));
void setHeight(const int _height = 100);
void setWidth(const int _width = 100);
public slots:
void readConfiguration();
int showConfiguration(const QStringList tags = QStringList());
int tryDelete();
void writeConfiguration();
private slots:
void changeColor();
private:
QColor stringToColor(const QString _color);
QString m_fileName;
QStringList m_dirs;
bool debug;
Ui::GraphicalItem *ui;
// properties
int m_apiVersion = 0;
QString m_name = QString("none");
QString m_comment = QString("empty");
QString m_bar = QString("cpu");
QString m_activeColor = QString("0,0,0,130");
QString m_inactiveColor = QString("255,255,255,130");
Type m_type = Horizontal;
Direction m_direction = LeftToRight;
int m_height = 100;
int m_width = 100;
};
#endif /* GRAPHICALITEM_H */

View File

@ -0,0 +1,293 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>GraphicalItem</class>
<widget class="QDialog" name="GraphicalItem">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>416</width>
<height>325</height>
</rect>
</property>
<property name="windowTitle">
<string>Configuration</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="layout_name">
<item>
<widget class="QLabel" name="label_name">
<property name="text">
<string>Name</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_nameValue">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_comment">
<item>
<widget class="QLabel" name="label_comment">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Comment</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_comment"/>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_value">
<item>
<widget class="QLabel" name="label_value">
<property name="text">
<string>Value</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox_value">
<property name="editable">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_activeColor">
<item>
<widget class="QLabel" name="label_activeColor">
<property name="text">
<string>Active color</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_activeColor">
<property name="text">
<string notr="true"/>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_inactiveColor">
<item>
<widget class="QLabel" name="label_inactiveColor">
<property name="text">
<string>Inactive color</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_inactiveColor">
<property name="text">
<string notr="true"/>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_type">
<item>
<widget class="QLabel" name="label_type">
<property name="text">
<string>Type</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox_type">
<item>
<property name="text">
<string notr="true">Horizontal</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">Vertical</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">Circle</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_direction">
<item>
<widget class="QLabel" name="label_direction">
<property name="text">
<string>Direction</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox_direction">
<item>
<property name="text">
<string notr="true">LeftToRight</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">RightToLeft</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_height">
<item>
<widget class="QLabel" name="label_height">
<property name="text">
<string>Height</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinBox_height">
<property name="maximum">
<number>2000</number>
</property>
<property name="singleStep">
<number>25</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_width">
<item>
<widget class="QLabel" name="label_width">
<property name="text">
<string>Width</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinBox_width">
<property name="maximum">
<number>2000</number>
</property>
<property name="singleStep">
<number>25</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>GraphicalItem</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>GraphicalItem</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -0,0 +1,25 @@
[Desktop Entry]
Encoding=UTF-8
Name=Awesome Widget
Comment=A minimalistic Plasmoid
Comment[en]=A minimalistic Plasmoid
Comment[es]=Un plasmoide minimalista
Comment[es]=Un script Plasmoïde minimaliste
Comment[pt_BR]=Um script Plasmoid
Comment[ru]=Минималистичный плазмоид
Comment[uk]=Мінімалістичний плазмоїд
X-KDE-ServiceTypes=Plasma/Applet
Type=Service
Icon=utilities-system-monitor
X-KDE-Library=plasma_applet_awesome-widget
X-KDE-PluginInfo-Author=Evgeniy Alekseev aka arcanis
X-KDE-PluginInfo-Email=esalexeev@gmail.com
X-KDE-PluginInfo-Name=awesome-widget
X-KDE-PluginInfo-Version=@PROJECT_VERSION@
X-KDE-PluginInfo-Website=http://arcanis.name/projects/awesome-widgets/
X-KDE-PluginInfo-Category=System Information
X-KDE-PluginInfo-Depends=
X-KDE-PluginInfo-License=GPLv3
X-KDE-PluginInfo-EnabledByDefault=true

View File

@ -0,0 +1,14 @@
[Global]
IconName=system
Name=Awesome Widget
Comment=Awesome widget information
[Event/system]
Name=System information
Comment=System information
Action=Popup
[Event/tag]
Name=Tag information
Comment=Tag information
Action=Popup

View File

@ -0,0 +1,166 @@
/***************************************************************************
* This file is part of awesome-widgets *
* *
* awesome-widgets is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* awesome-widgets is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#include "awesome-widget.h"
#include <KNotification>
#include <Plasma/ToolTipManager>
#include <QGraphicsGridLayout>
#include <QGraphicsView>
#include <math.h>
#include "customlabel.h"
#include "graphicalitem.h"
#include <pdebug/pdebug.h>
void AwesomeWidget::reinit()
{
if (debug) qDebug() << PDEBUG;
if (configuration[QString("background")].toInt() == 0)
setBackgroundHints(NoBackground);
if (configuration[QString("popup")].toInt() == 0)
textLabel->setPopupEnabled(false);
else
textLabel->setPopupEnabled(true);
updateText(true);
keys = getKeys();
foundKeys = findKeys();
getGraphicalItems();
foundBars = findGraphicalItems();
updateNetworkDevice(false);
connectToEngine();
}
void AwesomeWidget::sendNotification(const QString eventId, const QString message)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Event" << eventId;
if (debug) qDebug() << PDEBUG << ":" << "Message" << message;
KNotification *notification = new KNotification(eventId);
notification->setComponentData(KComponentData("plasma_applet_awesome-widget"));
notification->setTitle(QString("Awesome Widget ::: ") + eventId);
notification->setText(message);
notification->sendEvent();
delete notification;
}
void AwesomeWidget::updateNetworkDevice(const bool delay)
{
if (debug) qDebug() << PDEBUG;
if (delay)
networkDeviceUpdate = 30;
else
values[QString("netdev")] = getNetworkDevice();
}
void AwesomeWidget::updateText(const bool clear)
{
if (debug) qDebug() << PDEBUG;
QString text = configuration[QString("text")];
if (!clear) {
text.replace(QString("$$"), QString("$\\$\\"));
for (int i=0; i<foundKeys.count(); i++)
text.replace(QString("$") + foundKeys[i], values[foundKeys[i]]);
for (int i=0; i<foundBars.count(); i++)
text.replace(QString("$") + foundBars[i], getItemByTag(foundBars[i])->image(values[foundBars[i]].toFloat()));
text.replace(QString("$\\$\\"), QString("$$"));
}
textLabel->setText(formatLine[0] + text + formatLine[1]);
mainLayout->itemAt(0, 0)->updateGeometry();
updateGeometry();
}
void AwesomeWidget::updateTooltip()
{
if (debug) qDebug() << PDEBUG;
toolTipView->resize(100.0 * counts[QString("tooltip")], 105.0);
// boundaries
QMap<QString, float> boundaries;
boundaries[QString("cpu")] = 100.0;
boundaries[QString("cpucl")] = 4000.0;
boundaries[QString("mem")] = 100.0;
boundaries[QString("swap")] = 100.0;
boundaries[QString("down")] = 1.0;
if (configuration[QString("downTooltip")].toInt() == 2) {
for (int i=0; i<tooltipValues[QString("down")].count(); i++)
if (boundaries[QString("down")] < tooltipValues[QString("down")][i])
boundaries[QString("down")] = tooltipValues[QString("down")][i];
for (int i=0; i<tooltipValues[QString("up")].count(); i++)
if (boundaries[QString("down")] < tooltipValues[QString("up")][i])
boundaries[QString("down")] = tooltipValues[QString("up")][i];
boundaries[QString("down")] *= 1.2;
}
boundaries[QString("up")] = boundaries[QString("down")];
boundaries[QString("bat")] = 100.0;
// create image
toolTipScene->clear();
QPen pen = QPen();
if (configuration[QString("useTooltipBackground")].toInt() == 2)
toolTipScene->setBackgroundBrush(QColor(configuration[QString("tooltipBackground")]));
else
toolTipScene->setBackgroundBrush(QBrush(Qt::NoBrush));
bool down = false;
bool isBattery = false;
QStringList trueKeys;
if (tooltipValues.contains(QString("cpu"))) trueKeys.append(QString("cpu"));
if (tooltipValues.contains(QString("cpucl"))) trueKeys.append(QString("cpucl"));
if (tooltipValues.contains(QString("mem"))) trueKeys.append(QString("mem"));
if (tooltipValues.contains(QString("swap"))) trueKeys.append(QString("swap"));
if (tooltipValues.contains(QString("down"))) trueKeys.append(QString("down"));
if (tooltipValues.contains(QString("up"))) trueKeys.append(QString("up"));
if (tooltipValues.contains(QString("bat"))) trueKeys.append(QString("bat"));
for (int i=0; i<trueKeys.count(); i++) {
float normX = 100.0 / (float)tooltipValues[trueKeys[i]].count();
float normY = 100.0 / (1.5 * boundaries[trueKeys[i]]);
if (trueKeys[i] == QString("bat"))
isBattery = true;
else
isBattery = false;
if (!isBattery) pen.setColor(QColor(configuration[trueKeys[i] + QString("Color")]));
float shift = i * 100.0;
if (down) shift -= 100.0;
for (int j=0; j<tooltipValues[trueKeys[i]].count()-1; j++) {
float x1 = j * normX + shift;
float y1 = - fabs(tooltipValues[trueKeys[i]][j]) * normY + 5.0;
float x2 = (j + 1) * normX + shift;
float y2 = - fabs(tooltipValues[trueKeys[i]][j+1]) * normY + 5.0;
if (isBattery) {
if (tooltipValues[trueKeys[i]][j+1] > 0)
pen.setColor(QColor(configuration[QString("batteryColor")]));
else
pen.setColor(QColor(configuration[QString("batteryInColor")]));
}
toolTipScene->addLine(x1, y1, x2, y2, pen);
}
if (trueKeys[i] == QString("down")) down = true;
}
toolTip.setImage(QPixmap::grabWidget(toolTipView));
Plasma::ToolTipManager::self()->setContent(this, toolTip);
}

View File

@ -0,0 +1,295 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>TooltipWindow</class>
<widget class="QWidget" name="TooltipWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>700</width>
<height>594</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>700</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="windowTitle">
<string notr="true">Tooltip</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<widget class="QLabel" name="label_tooltip">
<property name="text">
<string>CPU, CPU clock, memory, swap and network labels support graphical tooltip. To enable them just make needed checkbox fully checked.</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QScrollArea" name="scrollArea_tooltip">
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="contents_tooltip">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>684</width>
<height>542</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_9">
<item>
<layout class="QHBoxLayout" name="layout_tooltipNum">
<item>
<widget class="QLabel" name="label_tooltipNum">
<property name="text">
<string>Number of values for tooltips</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinBox_tooltipNum">
<property name="minimum">
<number>50</number>
</property>
<property name="maximum">
<number>1000</number>
</property>
<property name="singleStep">
<number>25</number>
</property>
<property name="value">
<number>100</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_background">
<item>
<widget class="QCheckBox" name="checkBox_background">
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
</property>
<property name="text">
<string>Background</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="KColorCombo" name="kcolorcombo_background"/>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_cpuColor">
<item>
<widget class="QCheckBox" name="checkBox_cpu">
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
</property>
<property name="text">
<string>CPU color</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="KColorCombo" name="kcolorcombo_cpu"/>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_cpuclockColor">
<item>
<widget class="QCheckBox" name="checkBox_cpuclock">
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
</property>
<property name="text">
<string>CPU clock color</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="KColorCombo" name="kcolorcombo_cpuclock"/>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_memColor">
<item>
<widget class="QCheckBox" name="checkBox_mem">
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
</property>
<property name="text">
<string>Memory color</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="KColorCombo" name="kcolorcombo_mem"/>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_swapColor">
<item>
<widget class="QCheckBox" name="checkBox_swap">
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
</property>
<property name="text">
<string>Swap color</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="KColorCombo" name="kcolorcombo_swap"/>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_downColor">
<item>
<widget class="QCheckBox" name="checkBox_down">
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
</property>
<property name="text">
<string>Download speed color</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="KColorCombo" name="kcolorcombo_down"/>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_upColor">
<item>
<widget class="QLabel" name="label_up">
<property name="text">
<string>Upload speed color</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="KColorCombo" name="kcolorcombo_up"/>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_batteryColor">
<item>
<widget class="QCheckBox" name="checkBox_battery">
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
</property>
<property name="text">
<string>Battery active color</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="KColorCombo" name="kcolorcombo_battery"/>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_batteryInColor">
<item>
<widget class="QLabel" name="label_batteryIn">
<property name="text">
<string>Battery inactive color</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="KColorCombo" name="kcolorcombo_batteryIn"/>
</item>
</layout>
</item>
<item>
<spacer name="spacer_tooltip">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>289</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>KColorCombo</class>
<extends>QComboBox</extends>
<header>kcolorcombo.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,228 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ConfigWindow</class>
<widget class="QWidget" name="ConfigWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>700</width>
<height>600</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>700</width>
<height>600</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="windowTitle">
<string notr="true">Widget</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Detailed information may be found on &lt;a href=&quot;http://arcanis.name/projects/awesome-widgets/&quot;&gt;project homepage&lt;/a&gt;</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="layput_mainFormating">
<item>
<widget class="QPushButton" name="pushButton_font">
<property name="text">
<string>Font</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_br">
<property name="icon">
<iconset theme="stock_text_indent">
<normaloff/>
</iconset>
</property>
</widget>
</item>
<item>
<spacer name="spacer_mainFormatingCenter1">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pushButton_bold">
<property name="icon">
<iconset theme="format-text-bold">
<normaloff/>
</iconset>
</property>
<property name="shortcut">
<string>Ctrl+B</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_italic">
<property name="icon">
<iconset theme="format-text-italic">
<normaloff/>
</iconset>
</property>
<property name="shortcut">
<string>Ctrl+I</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_underline">
<property name="icon">
<iconset theme="format-text-underline">
<normaloff/>
</iconset>
</property>
<property name="shortcut">
<string>Ctrl+U</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_strike">
<property name="icon">
<iconset theme="format-text-strikethrough">
<normaloff/>
</iconset>
</property>
</widget>
</item>
<item>
<spacer name="spacer_mainFormatingCenter2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pushButton_left">
<property name="icon">
<iconset theme="format-justify-left">
<normaloff/>
</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_center">
<property name="icon">
<iconset theme="format-justify-center">
<normaloff/>
</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_right">
<property name="icon">
<iconset theme="format-justify-right">
<normaloff/>
</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_fill">
<property name="icon">
<iconset theme="format-justify-fill">
<normaloff/>
</iconset>
</property>
</widget>
</item>
<item>
<spacer name="spacer_mainFormatingCenter3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QComboBox" name="comboBox_tags">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_tags">
<property name="text">
<string>Add</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QTextEdit" name="textEdit_elements">
<property name="lineWrapMode">
<enum>QTextEdit::NoWrap</enum>
</property>
<property name="acceptRichText">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -1,16 +0,0 @@
# -*- coding: utf-8 -*-
from util import *
class Config():
def __init__(self, applet):
self.applet = applet
self.config = self.applet.config()
def get(self, key, default = ''):
return self.config.readEntry(key, default).toString()
def set(self, key, value):
self.config.writeEntry(key, value)

View File

@ -1,194 +0,0 @@
# -*- coding: utf-8 -*-
from PyQt4.QtGui import *
from PyKDE4.kdecore import *
from PyKDE4.kdeui import *
import commands
import config
class ConfigDefinition:
def __init__(self, parent, configpage):
"""class definition"""
self.parent = parent
self.configpage = configpage
def configAccepted(self):
"""function to accept settings"""
settings = config.Config(self.parent)
# update local variables
self.parent.interval = self.configpage.ui.spinBox_interval.value()
settings.set('interval', self.parent.interval)
self.parent.font_family = str(self.configpage.ui.fontComboBox.currentFont().family())
settings.set('font_family', self.parent.font_family)
self.parent.font_size = self.configpage.ui.spinBox_fontSize.value()
settings.set('font_size', self.parent.font_size)
self.parent.font_color = str(self.configpage.ui.kcolorcombo.color().name())
settings.set('font_color', self.parent.font_color)
if (self.configpage.ui.comboBox_style.currentIndex() == 0):
self.parent.font_style = 'normal'
else:
self.parent.font_style = 'italic'
settings.set('font_style', self.parent.font_style)
self.parent.font_weight = self.configpage.ui.spinBox_weight.value()
settings.set('font_weight', self.parent.font_weight)
# disconnecting from source and clear layout
if (self.parent.uptimeBool > 0):
self.parent.systemmonitor.disconnectSource("system/uptime", self.parent)
self.parent.label_uptime.setText('')
self.parent.layout.removeItem(self.parent.label_uptime)
if (self.parent.cpuBool > 0):
self.parent.systemmonitor.disconnectSource("cpu/system/TotalLoad", self.parent)
if (self.parent.cpuFormat.split('$ccpu')[0] != self.parent.cpuFormat):
self.parent.label_cpu.setText('')
self.parent.layout.removeItem(self.parent.label_cpu)
self.parent.label_cpu1.setText('')
self.parent.layout.removeItem(self.parent.label_cpu1)
for core in range(self.parent.numCores):
self.parent.systemmonitor.disconnectSource("cpu/cpu"+str(core)+"/TotalLoad", self.parent)
exec ("self.parent.label_coreCpu" + str(core) + ".setText('')")
exec ("self.parent.layout.removeItem(self.parent.label_coreCpu" + str(core) + ")")
else:
self.parent.label_cpu.setText('')
self.parent.layout.removeItem(self.parent.label_cpu)
if (self.parent.cpuclockBool > 0):
self.parent.systemmonitor.disconnectSource("cpu/system/AverageClock", self.parent)
if (self.parent.cpuclockFormat.split('$ccpu')[0] != self.parent.cpuclockFormat):
self.parent.label_cpuclock.setText('')
self.parent.layout.removeItem(self.parent.label_cpuclock)
self.parent.label_cpuclock1.setText('')
self.parent.layout.removeItem(self.parent.label_cpuclock1)
for core in range(self.parent.numCores):
self.parent.systemmonitor.disconnectSource("cpu/cpu"+str(core)+"/clock", self.parent)
exec ("self.parent.label_coreCpuclock" + str(core) + ".setText('')")
exec ("self.parent.layout.removeItem(self.parent.label_coreCpuclock" + str(core) + ")")
else:
self.parent.label_cpuclock.setText('')
self.parent.layout.removeItem(self.parent.label_cpuclock)
if (self.parent.tempBool > 0):
self.parent.systemmonitor.disconnectSource(self.parent.tempdev, self.parent)
self.parent.label_temp.setText('')
self.parent.layout.removeItem(self.parent.label_temp)
if (self.parent.gpuBool > 0):
self.parent.extsysmon.disconnectSource("gpu", self.parent)
self.parent.label_gpu.setText('')
self.parent.layout.removeItem(self.parent.label_gpu)
if (self.parent.gputempBool > 0):
self.parent.extsysmon.disconnectSource("gputemp", self.parent)
self.parent.label_gputemp.setText('')
self.parent.layout.removeItem(self.parent.label_gputemp)
if (self.parent.memBool > 0):
self.parent.systemmonitor.disconnectSource("mem/physical/application", self.parent)
if (self.parent.memInMb == False):
self.parent.systemmonitor.disconnectSource("mem/physical/free", self.parent)
self.parent.systemmonitor.disconnectSource("mem/physical/used", self.parent)
self.parent.label_mem.setText('')
self.parent.layout.removeItem(self.parent.label_mem)
if (self.parent.swapBool > 0):
self.parent.systemmonitor.disconnectSource("mem/swap/used", self.parent)
if (self.parent.swapInMb == False):
self.parent.systemmonitor.disconnectSource("mem/swap/free", self.parent)
self.parent.label_swap.setText('')
self.parent.layout.removeItem(self.parent.label_swap)
if (self.parent.hddBool > 0):
for mount in self.parent.mountPoints:
self.parent.systemmonitor.disconnectSource("partitions" + mount + "/filllevel", self.parent)
exec ('self.parent.label_hdd_' + ''.join(mount.split('/')) + '.setText("")')
exec ("self.parent.layout.removeItem(self.parent.label_hdd_" + ''.join(mount.split('/')) + ")")
self.parent.label_hdd0.setText('')
self.parent.label_hdd1.setText('')
self.parent.layout.removeItem(self.parent.label_hdd0)
self.parent.layout.removeItem(self.parent.label_hdd1)
if (self.parent.hddtempBool > 0):
self.parent.extsysmon.disconnectSource("hddtemp", self.parent)
self.parent.label_hddtemp.setText('')
self.parent.layout.removeItem(self.parent.label_hddtemp)
if (self.parent.netBool > 0):
self.parent.systemmonitor.disconnectSource("network/interfaces/"+self.parent.netdev+"/transmitter/data", self.parent)
self.parent.systemmonitor.disconnectSource("network/interfaces/"+self.parent.netdev+"/receiver/data", self.parent)
self.parent.label_netDown.setText('')
self.parent.label_netUp.setText('')
self.parent.layout.removeItem(self.parent.label_netUp)
self.parent.layout.removeItem(self.parent.label_netDown)
if (self.parent.batBool > 0):
self.parent.label_bat.setText('')
self.parent.layout.removeItem(self.parent.label_bat)
self.parent.label_order = "------------"
for label in self.parent.dict_orders.keys():
exec ('self.parent.' + self.parent.dict_orders[label] + 'Bool = ' + str(self.configpage.checkboxes[self.parent.dict_orders[label]].checkState()))
if (self.configpage.checkboxes[self.parent.dict_orders[label]].checkState() > 0):
pos = self.configpage.sliders[self.parent.dict_orders[label]].value() - 1
self.parent.label_order = self.parent.label_order[:pos] + label + self.parent.label_order[pos+1:]
if (self.parent.dict_orders[label] == 'net'):
exec ('self.parent.' + self.parent.dict_orders[label] + 'NonFormat = str(self.configpage.lineedits[self.parent.dict_orders[label]].text())')
exec ('settings.set("' + self.parent.dict_orders[label] + 'NonFormat", self.parent.' + self.parent.dict_orders[label] + 'NonFormat)')
else:
exec ('self.parent.' + self.parent.dict_orders[label] + 'Format = str(self.configpage.lineedits[self.parent.dict_orders[label]].text())')
exec ('settings.set("' + self.parent.dict_orders[label] + 'Format", self.parent.' + self.parent.dict_orders[label] + 'Format)')
exec ('settings.set("' + self.parent.dict_orders[label] + 'Bool", self.parent.' + self.parent.dict_orders[label] + 'Bool)')
if (self.parent.dict_orders[label] == 'bat'):
self.parent.battery_device = str(self.configpage.ui.lineEdit_batdev.text())
self.parent.ac_device = str(self.configpage.ui.lineEdit_acdev.text())
settings.set('battery_device', self.parent.battery_device)
settings.set('ac_device', self.parent.ac_device)
elif (self.parent.dict_orders[label] == 'temp'):
self.parent.tempdev = str(self.configpage.ui.comboBox_temp.currentText())
settings.set('temp_device', self.parent.tempdev)
self.parent.label_order = ''.join(self.parent.label_order.split('-'))
settings.set('label_order', self.parent.label_order)
# reinitializate
self.parent.reinit.reinit(confAccept=True)
def createConfigurationInterface(self, parent):
"""function to setup configuration window"""
settings = config.Config(self.parent)
font = QFont(str(settings.get('font_family', 'Terminus')), settings.get('font_size', 12).toInt()[0], 400, False)
self.configpage.ui.spinBox_interval.setValue(settings.get('interval', 2000).toInt()[0])
self.configpage.ui.fontComboBox.setCurrentFont(font)
self.configpage.ui.spinBox_fontSize.setValue(settings.get('font_size', 12).toInt()[0])
self.configpage.ui.kcolorcombo.setColor(QColor(str(settings.get('font_color', '#000000'))))
font = str(settings.get('font_style', 'normal'))
if (font == 'normal'):
self.configpage.ui.comboBox_style.setCurrentIndex(0)
else:
self.configpage.ui.comboBox_style.setCurrentIndex(1)
self.configpage.ui.spinBox_weight.setValue(settings.get('font_weight', 400).toInt()[0])
for label in self.parent.dict_orders.keys():
exec ('bool = self.parent.' + self.parent.dict_orders[label] + 'Bool')
self.configpage.checkboxes[self.parent.dict_orders[label]].setCheckState(bool)
if (bool > 0):
self.configpage.sliders[self.parent.dict_orders[label]].setValue(self.parent.label_order.find(label)+1)
if (self.parent.dict_orders[label] == 'net'):
self.configpage.lineedits[self.parent.dict_orders[label]].setText(str(settings.get(self.parent.dict_orders[label] + 'NonFormat', self.parent.dict_defFormat[self.parent.dict_orders[label]])))
else:
self.configpage.lineedits[self.parent.dict_orders[label]].setText(str(settings.get(self.parent.dict_orders[label] + 'Format', self.parent.dict_defFormat[self.parent.dict_orders[label]])))
if (self.parent.dict_orders[label] == 'bat'):
self.configpage.ui.lineEdit_batdev.setText(str(settings.get('battery_device', '/sys/class/power_supply/BAT0/capacity')))
self.configpage.ui.lineEdit_acdev.setText(str(settings.get('ac_device', '/sys/class/power_supply/AC/online')))
elif (self.parent.dict_orders[label] == 'temp'):
self.configpage.ui.comboBox_temp.addItem(str(settings.get('temp_device', '<select device>')))
commandOut = commands.getoutput("sensors")
for adapter in commandOut.split("\n\n"):
for device in adapter.split("\n"):
if (device.find('\xc2\xb0C') > -1):
try:
tempdev = 'lmsensors/' + adapter.split('\n')[0] + '/' + '_'.join(device.split(":")[0].split())
self.configpage.ui.comboBox_temp.addItem(tempdev)
except:
pass
# add config page
page = parent.addPage(self.configpage, i18n(self.parent.name()))
page.setIcon(KIcon(self.parent.icon()))
parent.okClicked.connect(self.configAccepted)

View File

@ -1,104 +0,0 @@
# -*- coding: utf-8 -*-
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyKDE4.plasma import *
from PyQt4 import uic
from PyKDE4 import plasmascript
class ConfigWindow(QWidget):
def __init__(self, parent):
"""settings window definition"""
QWidget.__init__(self)
self.ui = uic.loadUi(parent.package().filePath('ui', 'configwindow.ui'), self)
self.parent = parent
self.checkboxes = {'bat':self.ui.checkBox_bat, 'cpu':self.ui.checkBox_cpu,
'cpuclock':self.ui.checkBox_cpuclock, 'gpu':self.ui.checkBox_gpu,
'gputemp':self.ui.checkBox_gpuTemp, 'hdd':self.ui.checkBox_hdd,
'hddtemp':self.ui.checkBox_hddTemp, 'mem':self.ui.checkBox_mem,
'net':self.ui.checkBox_net, 'swap':self.ui.checkBox_swap,
'temp':self.ui.checkBox_temp, 'uptime':self.ui.checkBox_uptime}
self.sliders = {'bat':self.ui.slider_bat, 'cpu':self.ui.slider_cpu,
'cpuclock':self.ui.slider_cpuclock, 'gpu':self.ui.slider_gpu,
'gputemp':self.ui.slider_gpuTemp, 'hdd':self.ui.slider_hdd,
'hddtemp':self.ui.slider_hddTemp, 'mem':self.ui.slider_mem,
'net':self.ui.slider_net, 'swap':self.ui.slider_swap,
'temp':self.ui.slider_temp, 'uptime':self.ui.slider_uptime}
self.lineedits = {'bat':self.ui.lineEdit_bat, 'cpu':self.ui.lineEdit_cpu,
'cpuclock':self.ui.lineEdit_cpuclock, 'gpu':self.ui.lineEdit_gpu,
'gputemp':self.ui.lineEdit_gpuTemp, 'hdd':self.ui.lineEdit_hdd,
'hddtemp':self.ui.lineEdit_hddTemp, 'mem':self.ui.lineEdit_mem,
'net':self.ui.lineEdit_net, 'swap':self.ui.lineEdit_swap,
'temp':self.ui.lineEdit_temp, 'uptime':self.ui.lineEdit_uptime}
for item in self.checkboxes.values():
QObject.connect(item, SIGNAL("stateChanged(int)"), self.setStatus)
for item in self.sliders.values():
QObject.connect(item, SIGNAL("valueChanged(int)"), self.setSlider)
def setStatus(self):
"""function to enable label"""
count = self.sliders['bat'].maximum()
for label in self.checkboxes.keys():
if ((self.checkboxes[label].checkState() > 0) and (self.sliders[label].isEnabled() == False)):
self.lineedits[label].setEnabled(True)
self.sliders[label].setEnabled(True)
if (label == 'bat'):
self.ui.lineEdit_acdev.setEnabled(True)
self.ui.lineEdit_batdev.setEnabled(True)
elif (label == 'temp'):
self.ui.comboBox_temp.setEnabled(True)
slider_label = 0
for slider in self.sliders.values():
if (slider.isEnabled() == True):
slider_label += 1
for slider in self.sliders.values():
if (slider_label > 1):
slider.setMaximum(slider.maximum()+1)
elif (slider_label == 1):
slider.setMaximum(1)
self.sliders[label].setValue(self.sliders[label].maximum())
elif ((self.checkboxes[label].checkState() == 0) and (self.sliders[label].isEnabled() == True)):
self.lineedits[label].setDisabled(True)
self.sliders[label].setDisabled(True)
if (label == 'bat'):
self.ui.lineEdit_acdev.setDisabled(True)
self.ui.lineEdit_batdev.setDisabled(True)
elif (label == 'temp'):
self.ui.comboBox_temp.setDisabled(True)
for slider in self.sliders.values():
if ((slider.value() == slider.maximum()) and (slider != self.sliders[label])):
slider.setValue(self.sliders[label].value())
slider_label = 0
for slider in self.sliders.values():
if (slider.isEnabled() == True):
slider_label += 1
for slider in self.sliders.values():
if (slider_label > 0):
slider.setMaximum(slider.maximum()-1)
else:
slider.setMaximum(1)
self.sliders[label].setValue(1)
def setSlider(self):
"""function to set sliders"""
if (self.sender().isEnabled() == True):
second_slider = self.sender()
order = []
for slider in self.sliders.values():
if (slider.isEnabled() == True):
order.append(slider.value())
if ((slider.value() == self.sender().value()) and (slider != self.sender())):
second_slider = slider
if (second_slider == self.sender()):
return
for value in range(len(order)):
if (order.count(value+1) == 0):
new_value = value + 1
second_slider.setValue(new_value)

View File

@ -1,237 +0,0 @@
# -*- coding: utf-8 -*-
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyKDE4.plasma import Plasma
from PyKDE4 import plasmascript
class DataEngine:
def __init__(self, parent):
"""class definition"""
self.parent = parent
def connectToEngine(self):
"""function to initializate engine"""
self.parent.systemmonitor = self.parent.dataEngine("systemmonitor")
if ((self.parent.gputempBool > 0) or (self.parent.gpuBool > 0) or (self.parent.hddtempBool > 0)):
self.parent.extsysmon = self.parent.dataEngine("ext-sysmon")
if (self.parent.uptimeBool > 0):
self.parent.systemmonitor.connectSource("system/uptime", self.parent, self.parent.interval)
if (self.parent.cpuBool > 0):
self.parent.systemmonitor.connectSource("cpu/system/TotalLoad", self.parent, self.parent.interval)
if (self.parent.cpuFormat.split('$ccpu')[0] != self.parent.cpuFormat):
for core in range(self.parent.numCores):
self.parent.systemmonitor.connectSource("cpu/cpu"+str(core)+"/TotalLoad", self.parent, self.parent.interval)
if (self.parent.cpuclockBool > 0):
self.parent.systemmonitor.connectSource("cpu/system/AverageClock", self.parent, self.parent.interval)
if (self.parent.cpuclockFormat.split('$ccpucl')[0] != self.parent.cpuclockFormat):
for core in range(self.parent.numCores):
self.parent.systemmonitor.connectSource("cpu/cpu"+str(core)+"/clock", self.parent, self.parent.interval)
if (self.parent.tempBool > 0):
self.parent.systemmonitor.connectSource(self.parent.tempdev, self.parent, self.parent.interval)
if (self.parent.gpuBool > 0):
self.parent.extsysmon.connectSource("gpu", self.parent, self.parent.interval)
if (self.parent.gputempBool > 0):
self.parent.extsysmon.connectSource("gputemp", self.parent, self.parent.interval)
if (self.parent.memBool > 0):
if (self.parent.memInMb):
self.parent.systemmonitor.connectSource("mem/physical/application", self.parent, self.parent.interval)
else:
self.parent.systemmonitor.connectSource("mem/physical/free", self.parent, int(self.parent.interval*0.5))
self.parent.systemmonitor.connectSource("mem/physical/used", self.parent, int(self.parent.interval*0.5))
self.parent.systemmonitor.connectSource("mem/physical/application", self.parent, int(self.parent.interval*0.5))
if (self.parent.swapBool > 0):
if (self.parent.swapInMb):
self.parent.systemmonitor.connectSource("mem/swap/used", self.parent, self.parent.interval)
else:
self.parent.systemmonitor.connectSource("mem/swap/free", self.parent, int(self.parent.interval*0.5))
self.parent.systemmonitor.connectSource("mem/swap/used", self.parent, int(self.parent.interval*0.5))
if (self.parent.hddBool > 0):
for mount in self.parent.mountPoints:
self.parent.systemmonitor.connectSource("partitions" + mount + "/filllevel", self.parent, self.parent.interval)
if (self.parent.hddtempBool > 0):
self.parent.extsysmon.connectSource("hddtemp", self.parent, self.parent.interval)
if (self.parent.netBool > 0):
self.parent.updateNetdev = 0
self.parent.systemmonitor.connectSource("network/interfaces/"+self.parent.netdev+"/transmitter/data", self.parent, self.parent.interval)
self.parent.systemmonitor.connectSource("network/interfaces/"+self.parent.netdev+"/receiver/data", self.parent, self.parent.interval)
def dataUpdated(self, sourceName, data):
"""function to update data"""
try:
if (sourceName == "system/uptime"):
value = 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)
if (self.parent.uptimeFormat.split('$uptime')[0] != self.parent.uptimeFormat):
line = self.parent.uptimeFormat.split('$uptime')[0] + uptimeText + self.parent.uptimeFormat.split('$uptime')[1]
else:
line = self.parent.uptimeFormat
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
self.parent.label_uptime.setText(text)
elif (sourceName == "cpu/system/TotalLoad"):
value = str(round(float(data[QString(u'value')]), 1))
cpuText = "%5s" % (value)
if (self.parent.cpuFormat.split('$ccpu')[0] != self.parent.cpuFormat):
if (self.parent.cpuFormat.split('$ccpu')[0].split('$cpu')[0] != self.parent.cpuFormat.split('$ccpu')[0]):
line = self.parent.cpuFormat.split('$ccpu')[0].split('$cpu')[0] + cpuText + self.parent.cpuFormat.split('$ccpu')[0].split('$cpu')[1]
else:
line = self.parent.cpuFormat.split('$ccpu')[0]
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
self.parent.label_cpu.setText(text)
if (self.parent.cpuFormat.split('$ccpu')[1].split('$cpu')[0] != self.parent.cpuFormat.split('$ccpu')[1]):
line = self.parent.cpuFormat.split('$ccpu')[1].split('$cpu')[0] + cpuText + self.parent.cpuFormat.split('$ccpu')[1].split('$cpu')[1]
else:
line = self.parent.cpuFormat.split('$ccpu')[1]
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
self.parent.label_cpu1.setText(text)
else:
if (self.parent.cpuFormat.split('$cpu')[0] != self.parent.cpuFormat):
line = self.parent.cpuFormat.split('$cpu')[0] + cpuText + self.parent.cpuFormat.split('$cpu')[1]
else:
line = self.parent.cpuFormat
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
self.parent.label_cpu.setText(text)
elif ((str(sourceName)[:7] == "cpu/cpu") and (str(sourceName).split('/')[2] == "TotalLoad")):
value = str(round(float(data[QString(u'value')]), 1))
cpuText = "%5s" % (value)
text = self.parent.formatLine.split('$LINE')[0] + cpuText + self.parent.formatLine.split('$LINE')[1]
exec ('self.parent.label_coreCpu' + str(sourceName)[7] + '.setText(text)')
elif (sourceName == "cpu/system/AverageClock"):
value = str(data[QString(u'value')]).split('.')[0]
cpuclockText = "%4s" % (value)
if (self.parent.cpuclockFormat.split('$ccpucl')[0] != self.parent.cpuclockFormat):
if (self.parent.cpuclockFormat.split('$ccpucl')[0].split('$cpucl')[0] != self.parent.cpuclockFormat.split('$ccpucl')[0]):
line = self.parent.cpuclockFormat.split('$ccpucl')[0].split('$cpucl')[0] + cpuclockText + self.parent.cpuclockFormat.split('$ccpucl')[0].split('$cpucl')[1]
else:
line = self.parent.cpuclockFormat.split('$ccpucl')[0]
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
self.parent.label_cpuclock.setText(text)
if (self.parent.cpuclockFormat.split('$ccpucl')[1].split('$cpucl')[0] != self.parent.cpuclockFormat.split('$ccpucl')[1]):
line = self.parent.cpuclockFormat.split('$ccpucl')[1].split('$cpucl')[0] + cpuclockText + self.parent.cpuclockFormat.split('$ccpucl')[1].split('$cpucl')[1]
else:
line = self.parent.cpuclockFormat.split('$ccpucl')[1]
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
self.parent.label_cpuclock1.setText(text)
else:
if (self.parent.cpuclockFormat.split('$cpucl')[0] != self.parent.cpuclockFormat):
line = self.parent.cpuclockFormat.split('$cpucl')[0] + cpuclockText + self.parent.cpuclockFormat.split('$cpucl')[1]
else:
line = self.parent.cpuclockFormat
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
self.parent.label_cpuclock.setText(text)
elif ((str(sourceName)[:7] == "cpu/cpu") and (str(sourceName).split('/')[2] == "clock")):
value = str(data[QString(u'value')]).split('.')[0]
cpuclockText = "%4s" % (value)
text = self.parent.formatLine.split('$LINE')[0] + cpuclockText + self.parent.formatLine.split('$LINE')[1]
exec ('self.parent.label_coreCpuclock' + str(sourceName)[7] + '.setText(text)')
elif (sourceName == "network/interfaces/"+self.parent.netdev+"/transmitter/data"):
value = str(data[QString(u'value')]).split('.')[0]
up_speed = "%4s" % (value)
if (self.parent.netFormat.split('$net')[0] != self.parent.netFormat):
line = '/' + up_speed + self.parent.netFormat.split('$net')[1]
else:
line = ''
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
self.parent.label_netUp.setText(text)
elif (sourceName == "network/interfaces/"+self.parent.netdev+"/receiver/data"):
value = str(data[QString(u'value')]).split('.')[0]
down_speed = "%4s" % (value)
if (self.parent.netFormat.split('$net')[0] != self.parent.netFormat):
line = self.parent.netFormat.split('$net')[0] + down_speed
else:
line = self.parent.netFormat
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
self.parent.label_netDown.setText(text)
# update network device
self.parent.updateNetdev = self.parent.updateNetdev + 1
if (self.parent.updateNetdev == 100):
self.parent.updateNetdev = 0
if (self.parent.netNonFormat.split('@@')[0] == self.parent.netNonFormat):
self.parent.systemmonitor.disconnectSource("network/interfaces/"+self.parent.netdev+"/transmitter/data", self.parent)
self.parent.systemmonitor.disconnectSource("network/interfaces/"+self.parent.netdev+"/receiver/data", self.parent)
self.parent.netdev = self.parent.setupNetdev()
self.parent.systemmonitor.connectSource("network/interfaces/"+self.parent.netdev+"/transmitter/data", self.parent, self.parent.interval)
self.parent.systemmonitor.connectSource("network/interfaces/"+self.parent.netdev+"/receiver/data", self.parent, self.parent.interval)
if (self.parent.netNonFormat.split('$netdev')[0] != self.parent.netNonFormat):
self.parent.netFormat = self.parent.netNonFormat.split('$netdev')[0] + self.parent.netdev + self.parent.netNonFormat.split('$netdev')[1]
else:
self.parent.netFormat = self.parent.netNonFormat
elif (sourceName == self.parent.tempdev):
value = str(round(float(data[QString(u'value')]), 1))
tempText = "%4s" % (value)
if (self.parent.tempFormat.split('$temp')[0] != self.parent.tempFormat):
line = self.parent.tempFormat.split('$temp')[0] + tempText + self.parent.tempFormat.split('$temp')[1]
else:
line = self.parent.tempFormat
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
self.parent.label_temp.setText(text)
elif (str(sourceName).split('/')[0] == "partitions"):
value = str(round(float(data[QString(u'value')]), 1))
hddText = "%5s" % (value)
text = self.parent.formatLine.split('$LINE')[0] + hddText + self.parent.formatLine.split('$LINE')[1]
exec ('self.parent.label_hdd_' + ''.join(str(sourceName).split('/')[1:-1]) + '.setText(text)')
elif (sourceName == "mem/physical/free"):
self.parent.mem_free = float(data[QString(u'value')])
elif (sourceName == "mem/physical/used"):
self.parent.mem_uf = float(data[QString(u'value')])
elif (sourceName == "mem/physical/application"):
if (self.parent.memInMb):
mem = str(round(float(data[QString(u'value')]) / 1024, 0)).split('.')[0]
mem = "%5s" % (mem)
if (self.parent.memFormat.split('$memmb')[0] != self.parent.memFormat):
line = self.parent.memFormat.split('$memmb')[0] + mem + self.parent.memFormat.split('$memmb')[1]
else:
line = self.parent.memFormat
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
self.parent.label_mem.setText(text)
else:
self.parent.mem_used = float(data[QString(u'value')])
elif (sourceName == "mem/swap/free"):
self.parent.swap_free = float(data[QString(u'value')])
elif (sourceName == "mem/swap/used"):
if (self.parent.swapInMb):
mem = str(round(float(data[QString(u'value')]) / 1024, 0)).split('.')[0]
mem = "%5s" % (mem)
if (self.parent.swapFormat.split('$swapmb')[0] != self.parent.swapFormat):
line = self.parent.swapFormat.split('$swapmb')[0] + mem + self.parent.swapFormat.split('$swapmb')[1]
else:
line = self.parent.swapFormat
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
self.parent.label_swap.setText(text)
else:
self.parent.swap_used = float(data[QString(u'value')])
elif (sourceName == "gpu"):
value = str(data[QString(u'GPU')])
gpuText = "%4s" % (value)
if (self.parent.gpuFormat.split('$gpu')[0] != self.parent.gpuFormat):
line = self.parent.gpuFormat.split('$gpu')[0] + gpuText + self.parent.gpuFormat.split('$gpu')[1]
else:
line = self.parent.gpuFormat
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
self.parent.label_gpu.setText(text)
elif (sourceName == "gputemp"):
value = str(data[QString(u'GPUTemp')])
gputempText = "%4s" % (value)
if (self.parent.gputempFormat.split('$gputemp')[0] != self.parent.gputempFormat):
line = self.parent.gputempFormat.split('$gputemp')[0] + gputempText + self.parent.gputempFormat.split('$gputemp')[1]
else:
line = self.parent.gputempFormat
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
self.parent.label_gputemp.setText(text)
elif (sourceName == "hddtemp"):
value = str(data[QString(self.parent.hddtempFormat.split('@@')[1])])
hddtempText = "%4s" % (value)
if (self.parent.hddtempFormat.split('@@')[0] != self.parent.hddtempFormat):
line = self.parent.hddtempFormat.split('@@')[0] + hddtempText + self.parent.hddtempFormat.split('@@')[2]
else:
line = self.parent.hddtempFormat
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
self.parent.label_hddtemp.setText(text)
self.parent.update()
except:
pass

View File

@ -1,202 +0,0 @@
# -*- coding: utf-8 -*-
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyKDE4.kdecore import *
from PyKDE4.kdeui import *
from PyKDE4.kio import *
from PyKDE4 import plasmascript
from PyKDE4.plasma import Plasma
import commands, os, shutil, time
import configdef
import configwindow
import dataengine
import reinit
from util import *
class pyTextWidget(plasmascript.Applet):
def __init__(self, parent, args=None):
"""widget definition"""
plasmascript.Applet.__init__(self, parent)
def init(self):
"""function to initializate widget"""
self._name = str(self.package().metadata().pluginName())
self.initTooltip()
self.layout = QGraphicsLinearLayout(Qt.Horizontal, self.applet)
self.dataengine = dataengine.DataEngine(self)
self.reinit = reinit.Reinit(self)
self.timer = QTimer()
QObject.connect(self.timer, SIGNAL("timeout()"), self.updateLabel)
self.setupVar()
self.reinit.reinit(confAccept=False)
self.setHasConfigurationInterface(True)
# Create notifyrc file if required
kdehome = unicode(KGlobal.dirs().localkdedir())
if ((not os.path.exists(kdehome + "/share/apps/plasma_applet_pytextmonitor/plasma_applet_pytextmonitor.notifyrc")) or
(not os.path.exists("/usr" + "/share/apps/plasma_applet_pytextmonitor/plasma_applet_pytextmonitor.notifyrc"))):
self.createNotifyrc(kdehome)
def createConfigurationInterface(self, parent):
"""function to setup configuration window"""
self.configpage = configwindow.ConfigWindow(self)
self.configdef = configdef.ConfigDefinition(self, self.configpage)
self.configdef.createConfigurationInterface(parent)
def createNotifyrc(self, kdehome):
"""function to create *.notifyrc"""
if (not os.path.isdir(kdehome + "/share/apps/plasma_applet_pytextmonitor")):
os.mkdir(kdehome + "/share/apps/plasma_applet_pytextmonitor")
shutil.copy(kdehome + "/share/apps/plasma/plasmoids/py-text-monitor/contents/code/plasma_applet_pytextmonitor.notifyrc",
kdehome + "/share/apps/plasma_applet_pytextmonitor/")
def initTooltip(self):
"""function to create tooltip"""
self.tooltip = Plasma.ToolTipContent()
self.tooltip.setMainText("PyTextMonitor")
self.tooltip.setSubText('')
Plasma.ToolTipManager.self().registerWidget(self.applet)
# show tooltip
#Plasma.ToolTipManager.self().setContent(self.applet, self.tooltip)
def mouseDoubleClickEvent(self, event):
"""function to doubleclick event"""
os.system("ksysguard &")
def setupNetdev(self):
"""function to setup network device"""
netdev = "lo"
try:
interfaces = []
for line in commands.getoutput("ifconfig -a -s").split("\n"):
if ((line.split()[0] != 'Iface') and (line.split()[0] != 'lo')):
interfaces.append(line.split()[0])
for device in interfaces:
if (commands.getoutput("ifconfig " + device + " | grep 'inet '") != ''):
netdev = device
break
except:
pass
return netdev
def setupVar(self):
"""function to setup variables"""
self.netdev = ''
# setup number of cores
commandOut = commands.getoutput("grep -c '^processor' /proc/cpuinfo")
self.numCores = int(commandOut)
# create dictionaries
self.dict_orders = {'6':'bat', '1':'cpu', '7':'cpuclock', '9':'gpu', 'a':'gputemp',
'b':'hdd', 'c':'hddtemp', '3':'mem', '5':'net', '4':'swap', '2':'temp', '8':'uptime'}
self.dict_defFormat = {'bat':'[bat: $bat%$ac]', 'cpu':'[cpu: $cpu%]',
'cpuclock':'[mhz: $cpucl]', 'gpu':'[gpu: $gpu%]',
'gputemp':'[gpu temp: $gputemp&deg;C]', 'hdd':'[hdd: @@/@@%]',
'hddtemp':'[hdd temp: @@/dev/sda@@&deg;C]', 'mem':'[mem: $mem%]',
'net':'[$netdev: $netKB/s]', 'swap':'[swap: $swap%]',
'temp':'[temp: $temp&deg;C]', 'uptime':'[uptime: $uptime]'}
def showConfigurationInterface(self):
"""function to show configuration window"""
plasmascript.Applet.showConfigurationInterface(self)
def startPolling(self):
try:
self.timer.start()
self.updateLabel()
self.tooltip.setSubText('')
except Exception as strerror:
self.tooltip.setSubText(str(strerror))
self.label_error = Plasma.Label(self.applet)
self.label_error.setText('<font color="red">ERROR</font>')
self.layout.addItem(self.label_error)
return
def updateLabel(self):
"""function to update label"""
if ((self.memBool > 0) and (self.memInMb == False)):
self.memText()
if ((self.swapBool > 0) and (self.swapInMb == False)):
self.swapText()
if (self.batBool > 0):
self.batText()
def batText(self):
"""function to set battery text"""
line = self.batFormat
if (line.split('$bat')[0] != line):
try:
with open (self.battery_device, 'r') as bat_file:
bat = bat_file.readline().split('\n')[0]
except:
bat = 'off'
bat = "%3s" % (bat)
line = line.split('$bat')[0] + bat + line.split('$bat')[1]
if (line.split('$ac')[0] != line):
try:
with open (self.ac_device, 'r') as bat_file:
bat = bat_file.readline().split('\n')[0]
if (bat == '1'):
bat = '(*)'
else:
bat = '( )'
except:
bat = '(?)'
line = line.split('$ac')[0] + bat + line.split('$ac')[1]
text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1]
self.label_bat.setText(text)
def memText(self):
"""function to set mem text"""
full = self.mem_uf + self.mem_free
mem = 100 * self.mem_used / full
mem = "%5s" % (str(round(mem, 1)))
if (self.memFormat.split('$mem')[0] != self.memFormat):
line = self.memFormat.split('$mem')[0] + mem + self.memFormat.split('$mem')[1]
else:
line = self.memFormat
text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1]
self.label_mem.setText(text)
def swapText(self):
"""function to set swap text"""
full = self.swap_used + self.swap_free
mem = 100 * self.swap_used / full
mem = "%5s" % (str(round(mem, 1)))
if (self.swapFormat.split('$swap')[0] != self.swapFormat):
line = self.swapFormat.split('$swap')[0] + mem + self.swapFormat.split('$swap')[1]
else:
line = self.swapFormat
text = self.formatLine.split('$LINE')[0] + line + self.formatLine.split('$LINE')[1]
self.label_swap.setText(text)
@pyqtSignature("dataUpdated(const QString &, const Plasma::DataEngine::Data &)")
def dataUpdated(self, sourceName, data):
"""function to update label"""
self.dataengine.dataUpdated(sourceName, data)
def CreateApplet(parent):
return pyTextWidget(parent)

View File

@ -1,44 +0,0 @@
[Global]
IconName=system
Name=PyTextMonitor
Comment=PyTextMonitor information
[Event/system]
Name=System information
Comment=System information
Action=Popup
[Event/processor]
Name=Processor information
Comment=Processor information
Action=Popup
[Event/graphical]
Name=GPU information
Comment=GPU information
Action=Popup
[Event/memory]
Name=Memory information
Comment=Memory information
Action=Popup
[Event/disk]
Name=Disk information
Comment=Disk information
Action=Popup
[Event/network]
Name=Network information
Comment=Network information
Action=Popup
[Event/battery]
Name=Battery information
Comment=Battery information
Action=Popup
[Event/graphinfo]
Name=Graphical Information
Comment=Graphical Information
Action=Popup

View File

@ -1,214 +0,0 @@
# -*- coding: utf-8 -*-
from PyKDE4.kdecore import KComponentData
from PyKDE4.kdeui import KNotification
import commands
class PTMNotify:
def __init__(self, parent):
"""class definition"""
self.parent = parent
def init(self):
"""function to init notification"""
content = self.initText(self.parent)
self.createNotify(content)
def createNotify(self, content):
"""function to create notification for label"""
notification = KNotification(content[0])
notification.setComponentData(KComponentData("plasma_applet_pytextmonitor"))
notification.setTitle("PyTextMonitor info ::: " + content[0]);
notification.setText(content[1]);
notification.sendEvent();
def createText(self, type):
"""function to create text"""
text = ""
if (type == "system"):
try:
text = text + "Kernel: %s\n" %(commands.getoutput("uname -rsm"))
text = text + "Hostname: %s\n" %(commands.getoutput("uname -n"))
text = text + "Whoami: %s\n" %(commands.getoutput("whoami"))
text = text + "Uptime: %s\n" %(commands.getoutput("uptime"))
except:
text = "Something wrong"
elif (type == "processor"):
try:
output = commands.getoutput("grep 'model name' /proc/cpuinfo | head -1")
text = text + "Model: %s\n" %(' '.join(output.split()[3:]))
output = commands.getoutput("sar -u | tail -1")
print "1"
text = text + "CPU Usage: %s%%\n" %(str(100-float(output.split()[-1])))
output = commands.getoutput("grep MHz /proc/cpuinfo | head -1")
text = text + "CPU Freq: %s MHz\n" %(str(int(float(output.split()[-1]))))
output = commands.getoutput("sensors -u")
text = text + "Temps:"
for line in output.split("\n"):
if (line.find("_input") > -1):
text = text + " %s\xb0C" %(str(round(float(line.split()[-1]), 0)))
except:
text = "Something wrong"
elif (type == "graphical"):
try:
output = commands.getoutput("lspci -m | grep 'VGA\|3D'")
if (output.lower().find('nvidia') > -1):
gpudev = "nvidia"
elif (output.lower().find('radeon') > -1):
gpudev = "ati"
for line in output.split("\n"):
text = text + "%s %s\n" %(line.split('"')[0], line.split('"')[5])
if (gpudev == 'nvidia'):
output = commands.getoutput("nvidia-smi -q -d UTILIZATION | grep Gpu | tail -n1")
try:
value = "%5s" % (str(round(float(output.split()[2][:-1]), 1)))
except:
value = " N\A"
elif (gpudev == 'ati'):
output = commands.getoutput("aticonfig --od-getclocks | grep load | tail -n1")
try:
value = "%5s" % (str(round(float(output.split()[3][:-1]), 1)))
except:
value = " N\A"
else:
value = " N\A"
text = text + "Load: %s%%\n" %(value)
if (gpudev == 'nvidia'):
output = commands.getoutput("nvidia-smi -q -d TEMPERATURE | grep Gpu | tail -n1")
try:
value = "%5s" % (str(round(float(output.split()[2][:-1]), 1)))
except:
value = " N\A"
elif (gpudev == 'ati'):
output = commands.getoutput("aticonfig --od-gettemperature | grep Temperature | tail -n1")
try:
value = "%5s" % (str(round(float(output.split()[3][:-1]), 1)))
except:
value = " N\A"
else:
value = " N\A"
text = text + "Temp: %s\xb0C\n" %(value)
except:
text = "Something wrong"
elif (type == "memory"):
try:
output = commands.getoutput("free -m -o").split("\n")
memusage = int(output[1].split()[1]) - (int(output[1].split()[3]) + int(output[1].split()[5]) + int(output[1].split()[6]))
text = text + "Memory: %s of %s (%s%%)\n" %(str(memusage), output[1].split()[1], str(int(100*memusage/int(output[1].split()[1]))))
text = text + "Swap: %s of %s (%s%%)\n" %(output[2].split()[2], output[2].split()[1], str(int(100*int(output[2].split()[2])/int(output[2].split()[1]))))
output = commands.getoutput("swapon --show").split("\n")
text = text + "Swap Device: %s (%s)" %(output[1].split()[0], output[1].split()[1])
except:
text = "Something wrong"
elif (type == "disk"):
try:
output = commands.getoutput("df -h --output='source,target,used,size,pcent' --exclude-type=fuseblk --exclude-type=tmpfs --exclude-type=devtmpfs").split("\n")[1:]
for line in output:
text = text + "%s (to %s): %s of %s (%s)\n" %(line.split()[0], line.split()[1], line.split()[2], line.split()[3], line.split()[4])
except:
text = "Something wrong"
elif (type == "network"):
try:
output = commands.getoutput("ifconfig -a -s").split("\n")[1:]
text = text + "Devices:"
for line in output:
text = text + " %s" %(line.split()[0])
output = commands.getoutput("ifconfig -a -s " + self.parent.parent.netdev + " && sleep 0.2 && ifconfig -a -s " + self.parent.parent.netdev).split("\n")
download = int((int(output[3].split()[2]) - int(output[1].split()[2])) / (0.2 * 1024))
upload = int((int(output[3].split()[6]) - int(output[1].split()[6])) / (0.2 * 1024))
text = text + "\n%s: %s/%s KB/s\n" %(self.parent.parent.netdev, download, upload)
output = commands.getoutput("ifconfig " + self.parent.parent.netdev + " | grep 'inet '").split()[1]
text = text + "IP: %s\n" %(output[:-1])
output = commands.getoutput("wget http://checkip.dyndns.org/ -q -O - | awk '{print $6}' | sed 's/<.*>//g'")
text = text + "External IP: %s" %(output[:-1])
except:
text = "Something wrong"
elif (type == "battery"):
try:
text = text + "%s" %(commands.getoutput("acpi -abi"))
except:
text = "Something wrong"
content = [type, text]
return content
def initText(self, sender):
"""function to send text"""
try:
if (sender == self.parent.parent.label_uptime):
content = self.createText("system")
return content
except:
pass
try:
if (sender == self.parent.parent.label_cpu):
content = self.createText("processor")
return content
except:
pass
try:
if (sender == self.parent.parent.label_cpuclock):
content = self.createText("processor")
return content
except:
pass
try:
if (sender == self.parent.parent.label_temp):
content = self.createText("processor")
return content
except:
pass
try:
if (sender == self.parent.parent.label_gpu):
content = self.createText("graphical")
return content
except:
pass
try:
if (sender == self.parent.parent.label_gputemp):
content = self.createText("graphical")
return content
except:
pass
try:
if (sender == self.parent.parent.label_mem):
content = self.createText("memory")
return content
except:
pass
try:
if (sender == self.parent.parent.label_swap):
content = self.createText("memory")
return content
except:
pass
try:
if (sender == self.parent.parent.label_hdd0):
content = self.createText("disk")
return content
except:
pass
try:
if (sender == self.parent.parent.label_hddtemp):
content = self.createText("disk")
return content
except:
pass
try:
if (sender == self.parent.parent.label_netDown):
content = self.createText("network")
return content
except:
pass
try:
if (sender == self.parent.parent.label_bat):
content = self.createText("battery")
return content
except:
pass

View File

@ -1,292 +0,0 @@
# -*- coding: utf-8 -*-
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyKDE4.plasma import Plasma
import config
import ptmnotify
class NewPlasmaLabel(Plasma.Label):
"""new Label with defined clicked() event"""
def __init__(self, applet, parent):
"""class definition"""
Plasma.Label.__init__(self, applet)
self.parent = parent
self.notify = ptmnotify.PTMNotify(self)
def mousePressEvent(self, event):
"""mouse click event"""
if (event.button() == Qt.LeftButton):
self.notify.init()
class Reinit():
def __init__(self, parent):
"""class definition"""
self.parent = parent
def reinit(self, confAccept=False):
"""function to reinitializate widget"""
settings = config.Config(self.parent)
self.parent.interval = settings.get('interval', 2000).toInt()[0]
self.parent.font_family = str(settings.get('font_family', 'Terminus'))
self.parent.font_size = settings.get('font_size', 12).toInt()[0]
self.parent.font_color = str(settings.get('font_color', '#000000'))
self.parent.font_style = str(settings.get('font_style', 'normal'))
self.parent.font_weight = settings.get('font_weight', 400).toInt()[0]
self.parent.formatLine = "<pre><p align=\"center\"><span style=\" font-family:'" + self.parent.font_family + "'; font-style:" + self.parent.font_style
self.parent.formatLine = self.parent.formatLine + "; font-size:" + str(self.parent.font_size) + "pt; font-weight:" + str(self.parent.font_weight)
self.parent.formatLine = self.parent.formatLine + "; color:" + self.parent.font_color + ";\">$LINE</span></p></pre>"
self.parent.label_order = str(settings.get('label_order', '1345'))
for label in self.parent.dict_orders.values():
if ((label == 'cpu') or (label == 'mem') or (label == 'swap') or (label == 'net')):
exec ('self.parent.' + label + 'Bool = int(settings.get("' + label + 'Bool", 2))')
else:
exec ('self.parent.' + label + 'Bool = int(settings.get("' + label + 'Bool", 0))')
# labels
for order in self.parent.label_order:
if (order == "1"):
if (self.parent.cpuBool > 0):
self.parent.cpuFormat = str(settings.get('cpuFormat', '[cpu: $cpu%]'))
if (self.parent.cpuFormat.split('$ccpu')[0] != self.parent.cpuFormat):
self.parent.label_cpu = NewPlasmaLabel(self.parent.applet, self.parent)
self.parent.label_cpu1 = Plasma.Label(self.parent.applet)
if (self.parent.cpuFormat.split('$ccpu')[0].split('$cpu')[0] != self.parent.cpuFormat.split('$ccpu')[0]):
line = self.parent.cpuFormat.split('$ccpu')[0].split('$cpu')[0] + '-----' + self.parent.cpuFormat.split('$ccpu')[0].split('$cpu')[1]
else:
line = self.parent.cpuFormat.split('$ccpu')[0]
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
self.parent.label_cpu.setText(text)
self.parent.layout.addItem(self.parent.label_cpu)
text = self.parent.formatLine.split('$LINE')[0] + "-----" + self.parent.formatLine.split('$LINE')[1]
for core in range(self.parent.numCores):
exec ('self.parent.label_coreCpu' + str(core) + ' = Plasma.Label(self.parent.applet)')
exec ('self.parent.label_coreCpu' + str(core) + '.setText(text)')
exec ('self.parent.layout.addItem(self.parent.label_coreCpu' + str(core) + ')')
if (self.parent.cpuFormat.split('$ccpu')[1].split('$cpu')[0] != self.parent.cpuFormat.split('$ccpu')[1]):
line = self.parent.cpuFormat.split('$ccpu')[1].split('$cpu')[0] + '-----' + self.parent.cpuFormat.split('$ccpu')[1].split('$cpu')[1]
else:
line = self.parent.cpuFormat.split('$ccpu')[1]
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
self.parent.label_cpu1.setText(text)
self.parent.layout.addItem(self.parent.label_cpu1)
else:
self.parent.label_cpu = NewPlasmaLabel(self.parent.applet, self.parent)
if (self.parent.cpuFormat.split('$cpu')[0] != self.parent.cpuFormat):
line = self.parent.cpuFormat.split('$cpu')[0] + '-----' + self.parent.cpuFormat.split('$cpu')[1]
else:
line = self.parent.cpuFormat
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
self.parent.label_cpu.setText(text)
self.parent.layout.addItem(self.parent.label_cpu)
elif (order == "2"):
if (self.parent.tempBool > 0):
self.parent.tempdev = str(settings.get('temp_device', '<select device>'))
self.parent.tempFormat = str(settings.get('tempFormat', '[temp: $temp&deg;C]'))
self.parent.label_temp = NewPlasmaLabel(self.parent.applet, self.parent)
if (self.parent.tempFormat.split('$temp')[0] != self.parent.tempFormat):
line = self.parent.tempFormat.split('$temp')[0] + '----' + self.parent.tempFormat.split('$temp')[1]
else:
line = self.parent.tempFormat
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
self.parent.label_temp.setText(text)
self.parent.layout.addItem(self.parent.label_temp)
elif (order == "3"):
if (self.parent.memBool > 0):
self.parent.memFormat = str(settings.get('memFormat', '[mem: $mem%]'))
if (self.parent.memFormat.split('$memmb')[0] != self.parent.memFormat):
self.parent.memInMb = True
line = self.parent.memFormat.split('$memmb')[0] + '-----' + self.parent.memFormat.split('$memmb')[1]
elif (self.parent.memFormat.split('$mem')[0] != self.parent.memFormat):
self.parent.memInMb = False
self.parent.mem_used = 0.0
self.parent.mem_free = 1.0
self.parent.mem_uf = 0.0
line = self.parent.memFormat.split('$mem')[0] + '-----' + self.parent.memFormat.split('$mem')[1]
else:
line = self.parent.memFormat
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
self.parent.label_mem = NewPlasmaLabel(self.parent.applet, self.parent)
self.parent.label_mem.setText(text)
self.parent.layout.addItem(self.parent.label_mem)
elif (order == "4"):
if (self.parent.swapBool > 0):
self.parent.swapFormat = str(settings.get('swapFormat', '[swap: $swap%]'))
if (self.parent.swapFormat.split('$swapmb')[0] != self.parent.swapFormat):
self.parent.swapInMb = True
line = self.parent.swapFormat.split('$swapmb')[0] + '-----' + self.parent.swapFormat.split('$swapmb')[1]
elif (self.parent.swapFormat.split('$swap')[0] != self.parent.swapFormat):
self.parent.swapInMb = False
self.parent.swap_free = 1.0
self.parent.swap_used = 0.0
line = self.parent.swapFormat.split('$swap')[0] + '-----' + self.parent.swapFormat.split('$swap')[1]
else:
line = self.parent.swapFormat
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
self.parent.label_swap = NewPlasmaLabel(self.parent.applet, self.parent)
self.parent.label_swap.setText(text)
self.parent.layout.addItem(self.parent.label_swap)
elif (order == "5"):
if (self.parent.netBool > 0):
self.parent.netNonFormat = str(settings.get('netNonFormat', '[net: $netKB/s]'))
if (self.parent.netNonFormat.split('@@')[0] != self.parent.netNonFormat):
self.parent.netdev = self.parent.netNonFormat.split('@@')[1]
self.parent.netNonFormat = self.parent.netNonFormat.split('@@')[0] + self.parent.netNonFormat.split('@@')[2]
else:
self.parent.netdev = self.parent.setupNetdev()
if (self.parent.netNonFormat.split('$netdev')[0] != self.parent.netNonFormat):
self.parent.netFormat = self.parent.netNonFormat.split('$netdev')[0] + self.parent.netdev + self.parent.netNonFormat.split('$netdev')[1]
else:
self.parent.netFormat = self.parent.netNonFormat
self.parent.label_netDown = NewPlasmaLabel(self.parent.applet, self.parent)
if (self.parent.netFormat.split('$net')[0] != self.parent.netFormat):
line = self.parent.netFormat.split('$net')[0] + '----'
else:
line = self.parent.netFormat
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
self.parent.label_netDown.setText(text)
self.parent.layout.addItem(self.parent.label_netDown)
self.parent.label_netUp = Plasma.Label(self.parent.applet)
if (self.parent.netFormat.split('$net')[0] != self.parent.netFormat):
line = '/----' + self.parent.netFormat.split('$net')[1]
else:
line = ''
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
self.parent.label_netUp.setText(text)
self.parent.layout.addItem(self.parent.label_netUp)
elif (order == "6"):
if (self.parent.batBool > 0):
self.parent.batFormat = str(settings.get('batFormat', '[bat: $bat%$ac]'))
self.parent.battery_device= str(settings.get('battery_device', '/sys/class/power_supply/BAT0/capacity'))
self.parent.ac_device = str(settings.get('ac_device', '/sys/class/power_supply/AC/online'))
self.parent.label_bat = NewPlasmaLabel(self.parent.applet, self.parent)
line = self.parent.batFormat
if (line.split('$ac')[0] != line):
line = line.split('$ac')[0] + '(-)' + line.split('$ac')[1]
if (line.split('$bat')[0] != line):
line = line.split('$bat')[0] + '---' + line.split('$bat')[1]
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
self.parent.label_bat.setText(text)
self.parent.layout.addItem(self.parent.label_bat)
elif (order == "7"):
if (self.parent.cpuclockBool > 0):
self.parent.cpuclockFormat = str(settings.get('cpuclockFormat', '[mhz: $cpucl]'))
if (self.parent.cpuclockFormat.split('$ccpucl')[0] != self.parent.cpuclockFormat):
self.parent.label_cpuclock = NewPlasmaLabel(self.parent.applet, self.parent)
self.parent.label_cpuclock1 = Plasma.Label(self.parent.applet)
if (self.parent.cpuclockFormat.split('$ccpucl')[0].split('$cpucl')[0] != self.parent.cpuclockFormat.split('$ccpucl')[0]):
line = self.parent.cpuclockFormat.split('$ccpucl')[0].split('$cpucl')[0] + '----' + self.parent.cpuclockFormat.split('$ccpucl')[0].split('$cpucl')[1]
else:
line = self.parent.cpuclockFormat.split('$ccpucl')[0]
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
self.parent.label_cpuclock.setText(text)
self.parent.layout.addItem(self.parent.label_cpuclock)
text = self.parent.formatLine.split('$LINE')[0] + "----" + self.parent.formatLine.split('$LINE')[1]
for core in range(self.parent.numCores):
exec ('self.parent.label_coreCpuclock' + str(core) + ' = Plasma.Label(self.parent.applet)')
exec ('self.parent.label_coreCpuclock' + str(core) + '.setText(text)')
exec ('self.parent.layout.addItem(self.parent.label_coreCpuclock' + str(core) + ')')
if (self.parent.cpuclockFormat.split('$ccpucl')[1].split('$cpucl')[0] != self.parent.cpuclockFormat.split('$ccpucl')[1]):
line = self.parent.cpuclockFormat.split('$ccpucl')[1].split('$cpucl')[0] + '----' + self.parent.cpuclockFormat.split('$ccpucl')[1].split('$cpucl')[1]
else:
line = self.parent.cpuclockFormat.split('$ccpucl')[1]
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
self.parent.label_cpuclock1.setText(text)
self.parent.layout.addItem(self.parent.label_cpuclock1)
else:
self.parent.label_cpuclock = NewPlasmaLabel(self.parent.applet, self.parent)
if (self.parent.cpuclockFormat.split('$cpucl')[0] != self.parent.cpuclockFormat):
line = self.parent.cpuclockFormat.split('$cpucl')[0] + '----' + self.parent.cpuclockFormat.split('$cpucl')[1]
else:
line = self.parent.cpuclockFormat
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
self.parent.label_cpuclock.setText(text)
self.parent.layout.addItem(self.parent.label_cpuclock)
elif (order == "8"):
if (self.parent.uptimeBool > 0):
self.parent.uptimeFormat = str(settings.get('uptimeFormat', '[uptime: $uptime]'))
self.parent.label_uptime = NewPlasmaLabel(self.parent.applet, self.parent)
if (self.parent.uptimeFormat.split('$uptime')[0] != self.parent.uptimeFormat):
line = self.parent.uptimeFormat.split('$uptime')[0] + '---d--h--m' + self.parent.uptimeFormat.split('$uptime')[1]
else:
line = self.parent.uptimeFormat
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
self.parent.label_uptime.setText(text)
self.parent.layout.addItem(self.parent.label_uptime)
elif (order == "9"):
if (self.parent.gpuBool > 0):
self.parent.gpuFormat = str(settings.get('gpuFormat', '[gpu: $gpu%]'))
self.parent.label_gpu = NewPlasmaLabel(self.parent.applet, self.parent)
if (self.parent.gpuFormat.split('$gpu')[0] != self.parent.gpuFormat):
line = self.parent.gpuFormat.split('$gpu')[0] + '-----' + self.parent.gpuFormat.split('$gpu')[1]
else:
line = self.parent.gpuFormat
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
self.parent.label_gpu.setText(text)
self.parent.layout.addItem(self.parent.label_gpu)
elif (order == "a"):
if (self.parent.gputempBool > 0):
self.parent.gputempFormat = str(settings.get('gputempFormat', '[gpu temp: $gputemp&deg;C]'))
self.parent.label_gputemp = NewPlasmaLabel(self.parent.applet, self.parent)
if (self.parent.gputempFormat.split('$gputemp')[0] != self.parent.gputempFormat):
line = self.parent.gputempFormat.split('$gputemp')[0] + '----' + self.parent.gputempFormat.split('$gputemp')[1]
else:
line = self.parent.gputempFormat
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
self.parent.label_gputemp.setText(text)
self.parent.layout.addItem(self.parent.label_gputemp)
elif (order == "b"):
if (self.parent.hddBool > 0):
self.parent.hddFormat = str(settings.get('hddFormat', '[hdd: @@/@@%]'))
if (self.parent.hddFormat.split('@@')[0] != self.parent.hddFormat):
self.parent.mountPoints = self.parent.hddFormat.split('@@')[1].split(';')
line = self.parent.hddFormat.split('@@')[0]
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
self.parent.label_hdd0 = NewPlasmaLabel(self.parent.applet, self.parent)
self.parent.label_hdd0.setText(text)
self.parent.layout.addItem(self.parent.label_hdd0)
text = self.parent.formatLine.split('$LINE')[0] + "-----" + self.parent.formatLine.split('$LINE')[1]
for mount in self.parent.mountPoints:
exec ('self.parent.label_hdd_' + ''.join(mount.split('/')) + ' = Plasma.Label(self.parent.applet)')
exec ('self.parent.label_hdd_' + ''.join(mount.split('/')) + '.setText(text)')
exec ('self.parent.layout.addItem(self.parent.label_hdd_' + ''.join(mount.split('/')) + ')')
line = self.parent.hddFormat.split('@@')[2]
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
self.parent.label_hdd1 = Plasma.Label(self.parent.applet)
self.parent.label_hdd1.setText(text)
self.parent.layout.addItem(self.parent.label_hdd1)
else:
line = self.parent.hddFormat
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
self.parent.label_hdd0.setText(text)
self.parent.layout.addItem(self.parent.label_hdd0)
elif (order == "c"):
if (self.parent.hddtempBool > 0):
self.parent.hddtempFormat = str(settings.get('hddtempFormat', '[hdd temp: @@/dev/sda@@&deg;C]'))
self.parent.label_hddtemp = NewPlasmaLabel(self.parent.applet, self.parent)
if (self.parent.hddtempFormat.split('@@')[0] != self.parent.hddtempFormat):
line = self.parent.hddtempFormat.split('@@')[0] + '----' + self.parent.hddtempFormat.split('@@')[2]
else:
line = self.parent.hddtempFormat
text = self.parent.formatLine.split('$LINE')[0] + line + self.parent.formatLine.split('$LINE')[1]
self.parent.label_hddtemp.setText(text)
self.parent.layout.addItem(self.parent.label_hddtemp)
if not confAccept:
self.parent.applet.setLayout(self.parent.layout)
self.parent.theme = Plasma.Svg(self.parent)
self.parent.theme.setImagePath("widgets/background")
self.parent.setBackgroundHints(Plasma.Applet.DefaultBackground)
self.parent.resize(10, 10)
# create dataengines
self.parent.thread().wait(60000)
self.parent.dataengine.connectToEngine()
self.parent.timer.setInterval(self.parent.interval)
self.parent.startPolling()

View File

@ -1,40 +0,0 @@
# -*- coding: utf-8 -*-
from shutil import copyfile
from PyKDE4.kdecore import *
import os
class Util():
def __init__(self, applet):
self.applet = applet
def createDirectory(self, name):
if not os.path.isdir(name):
try:
os.mkdir(name)
except:
print 'Failed to create directory: ' + name
def kdeHome(self):
return unicode(KGlobal.dirs().localkdedir())
def createNotifyrc(self):
print '[%s] creating notifyrc' % (self.applet._name)
self.createDirectory(self.kdeHome() + 'share/apps/%s' % self.applet._name)
source = self.applet.package().path() + 'contents/misc/%s.notifyrc' % self.applet._name
destination = self.kdeHome() + 'share/apps/%s/%s.notifyrc' % (self.applet._name, self.applet._name)
copyfile(source, destination)
def createConfig(self):
self.createDirectory(self.kdeHome() + 'share/apps/%s' % self.applet._name)
source = self.applet.package().path() + 'contents/misc/%s.ini' % self.applet._name
destination = self.kdeHome() + 'share/apps/%s/%s.ini' % (self.applet._name, self.applet._name)
copyfile(source, destination)

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,34 @@
# set project name
set (SUBPROJECT plasma_applet_desktop-panel)
message (STATUS "Subproject ${SUBPROJECT}")
# find required libaries
find_package (KDE4 REQUIRED)
add_definitions (${QT_DEFINITIONS} ${KDE4_DEFINITIONS})
include (KDE4Defaults)
include_directories (${CMAKE_SOURCE_DIR}
${CMAKE_BINARY_DIR}
${KDE4_INCLUDES}
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_BINARY_DIR}/../
${PROJECT_TRDPARTY_DIR})
# set sources
set (PLUGIN_NAME ${SUBPROJECT})
file (GLOB SUBPROJECT_DESKTOP_IN *.desktop)
file (RELATIVE_PATH SUBPROJECT_DESKTOP ${CMAKE_SOURCE_DIR} ${SUBPROJECT_DESKTOP_IN})
file (GLOB_RECURSE SUBPROJECT_SOURCE *.cpp ${PROJECT_TRDPARTY_DIR}/fontdialog/*.cpp)
file (GLOB SUBPROJECT_UI *.ui)
# prepare
configure_file (${SUBPROJECT_DESKTOP_IN} ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT_DESKTOP})
# make
kde4_add_ui_files (SUBPROJECT_SOURCE ${SUBPROJECT_UI})
kde4_add_plugin (${PLUGIN_NAME} ${SUBPROJECT_SOURCE})
target_link_libraries (${PLUGIN_NAME} ${KDE4_PLASMA_LIBS} ${KDE4_KDEUI_LIBS} ${KDE4_KIO_LIBS})
# install
install (TARGETS ${PLUGIN_NAME} DESTINATION ${PLUGIN_INSTALL_DIR})
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT_DESKTOP} DESTINATION ${SERVICES_INSTALL_DIR})

View File

@ -0,0 +1,357 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>AppearanceWidget</class>
<widget class="QWidget" name="AppearanceWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>480</width>
<height>343</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>480</width>
<height>320</height>
</size>
</property>
<property name="windowTitle">
<string notr="true">Apearance</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tab_active">
<attribute name="title">
<string>Active desktop</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QScrollArea" name="scrollArea_active">
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents_active">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>448</width>
<height>289</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="layout_fontActive">
<item>
<widget class="QLabel" name="label_fontActive">
<property name="text">
<string>Font</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QFontComboBox" name="fontComboBox_fontActive"/>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_fontSizeActive">
<item>
<widget class="QLabel" name="label_fontSizeActive">
<property name="text">
<string>Font size</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinBox_fontSizeActive">
<property name="minimum">
<number>7</number>
</property>
<property name="maximum">
<number>48</number>
</property>
<property name="value">
<number>12</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_fontColorActive">
<item>
<widget class="QLabel" name="label_fontColorActive">
<property name="text">
<string>Font color</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="KColorCombo" name="kcolorcombo_fontColorActive"/>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_fontWeightActive">
<item>
<widget class="QLabel" name="label_fontWeightActive">
<property name="text">
<string>Font weight</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinBox_fontWeightActive">
<property name="minimum">
<number>100</number>
</property>
<property name="maximum">
<number>900</number>
</property>
<property name="singleStep">
<number>100</number>
</property>
<property name="value">
<number>400</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_fontStyleActive">
<item>
<widget class="QLabel" name="label_fontStyleActive">
<property name="text">
<string>Font style</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox_fontStyleActive">
<item>
<property name="text">
<string notr="true">normal</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">italic</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer_active">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>119</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_inactive">
<attribute name="title">
<string>Inactive desktop</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="QScrollArea" name="scrollArea_inactive">
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents_inactive">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>448</width>
<height>289</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="layout_fontInactive">
<item>
<widget class="QLabel" name="label_fontInactive">
<property name="text">
<string>Font</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QFontComboBox" name="fontComboBox_fontInactive"/>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_fontSizeInactive">
<item>
<widget class="QLabel" name="label_fontSizeInactive">
<property name="text">
<string>Font size</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinBox_fontSizeInactive">
<property name="minimum">
<number>7</number>
</property>
<property name="maximum">
<number>48</number>
</property>
<property name="value">
<number>12</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_fontColorInactive">
<item>
<widget class="QLabel" name="label_fontColorInactive">
<property name="text">
<string>Font color</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="KColorCombo" name="kcolorcombo_fontColorInactive"/>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_fontWeightInactive">
<item>
<widget class="QLabel" name="label_fontWeightInactive">
<property name="text">
<string>Font weight</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinBox_fontWeightInactive">
<property name="minimum">
<number>100</number>
</property>
<property name="maximum">
<number>900</number>
</property>
<property name="singleStep">
<number>100</number>
</property>
<property name="value">
<number>400</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_fontStyleInactive">
<item>
<widget class="QLabel" name="label_fontStyleInactive">
<property name="text">
<string>Font style</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox_fontStyleInactive">
<item>
<property name="text">
<string notr="true">normal</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">italic</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer_inactive">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>119</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>KColorCombo</class>
<extends>QComboBox</extends>
<header>kcolorcombo.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,634 @@
/***************************************************************************
* This file is part of awesome-widgets *
* *
* awesome-widgets is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* awesome-widgets is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#include "desktop-panel.h"
#include <KConfigDialog>
#include <KGlobal>
#include <KStandardDirs>
#include <KWindowSystem>
#include <Plasma/Containment>
#include <Plasma/Corona>
#include <Plasma/Theme>
#include <Plasma/ToolTipManager>
#include <QDebug>
#include <QDesktopWidget>
#include <QFile>
#include <QGraphicsGridLayout>
#include <QGraphicsProxyWidget>
#include <QGraphicsView>
#include <QMouseEvent>
#include <QProcessEnvironment>
#include <QTextCodec>
#include <QTimer>
#include <fontdialog/fontdialog.h>
#include <pdebug/pdebug.h>
CustomPlasmaLabel::CustomPlasmaLabel(DesktopPanel *wid, const int num, const bool debugCmd)
: QLabel(0),
debug(debugCmd),
number(num),
widget(wid)
{
if (debug) qDebug() << PDEBUG << ":" << "Init label" << number;
}
CustomPlasmaLabel::~CustomPlasmaLabel()
{
if (debug) qDebug() << PDEBUG;
}
int CustomPlasmaLabel::getNumber()
{
if (debug) qDebug() << PDEBUG;
return number;
}
void CustomPlasmaLabel::enterEvent(QEvent *event)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Event" << event->type();
if (event->type() == QEvent::Enter)
widget->paintTooltip(number);
emit(QLabel::enterEvent(event));
}
void CustomPlasmaLabel::mousePressEvent(QMouseEvent *event)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Get signal" << event->button();
if (event->button() == Qt::LeftButton)
widget->setCurrentDesktop(number);
emit(QLabel::mousePressEvent(event));
}
DesktopPanel::DesktopPanel(QObject *parent, const QVariantList &args)
: Plasma::Applet(parent, args)
{
// debug
QProcessEnvironment environment = QProcessEnvironment::systemEnvironment();
QString debugEnv = environment.value(QString("DEBUG"), QString("no"));
if (debugEnv == QString("yes"))
debug = true;
else
debug = false;
setBackgroundHints(DefaultBackground);
setAspectRatioMode(Plasma::IgnoreAspectRatio);
setHasConfigurationInterface(true);
// text format init
currentFormatLine.append(QString(""));
currentFormatLine.append(QString(""));
formatLine.append(QString(""));
formatLine.append(QString(""));
}
DesktopPanel::~DesktopPanel()
{
if (debug) qDebug() << PDEBUG;
}
void DesktopPanel::init()
{
if (debug) qDebug() << PDEBUG;
layout = new QGraphicsGridLayout();
layout->setContentsMargins(1, 1, 1, 1);
setLayout(layout);
// tooltip
toolTip = Plasma::ToolTipContent();
toolTipScene = new QGraphicsScene();
toolTipView = new QGraphicsView(toolTipScene);
toolTipView->setStyleSheet(QString("background: transparent"));
toolTipView->setContentsMargins(0, 0, 0, 0);
toolTipView->setFrameShape(QFrame::NoFrame);
toolTipView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
toolTipView->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
Plasma::ToolTipManager::self()->setContent(this, toolTip);
// read variables
configChanged();
connect(this, SIGNAL(activate()), this, SLOT(changePanelsState()));
connect(KWindowSystem::self(), SIGNAL(currentDesktopChanged(int)), this, SLOT(updateText(int)));
}
DesktopPanel::DesktopWindowsInfo DesktopPanel::getInfoByDesktop(const int num)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Number" << num;
DesktopWindowsInfo info;
info.desktop = KWindowSystem::workArea(num);
QList<WId> windows = KWindowSystem::windows();
for (int i=0; i<windows.count(); i++) {
KWindowInfo winInfo = KWindowSystem::windowInfo(windows[i],
NET::Property::WMDesktop | NET::Property::WMGeometry |
NET::Property::WMState | NET::Property::WMWindowType);
if (!winInfo.isOnDesktop(num)) continue;
if (winInfo.windowType(NET::WindowTypeMask::NormalMask) == NET::WindowType::Normal) {
if (winInfo.isMinimized()) continue;
info.windows.append(winInfo.geometry());
info.winId.append(windows[i]);
} else if (winInfo.windowType(NET::WindowTypeMask::DesktopMask) == NET::WindowType::Desktop) {
info.desktopId.append(windows[i]);
}
}
return info;
}
QList<Plasma::Containment *> DesktopPanel::getPanels()
{
if (debug) qDebug() << PDEBUG;
QList<Plasma::Containment *> panels;
for (int i=0; i<containment()->corona()->containments().count(); i++)
if (containment()->corona()->containments()[i]->containmentType() == Plasma::Containment::PanelContainment)
panels.append(containment()->corona()->containments()[i]);
return panels;
}
QString DesktopPanel::panelLocationToStr(Plasma::Location loc)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Location" << loc;
switch (loc) {
case Plasma::TopEdge:
return i18n("Top Edge");
case Plasma::BottomEdge:
return i18n("Bottom Edge");
case Plasma::LeftEdge:
return i18n("Left Edge");
case Plasma::RightEdge:
return i18n("Right Edge");
default:
return i18n("Unknown Position (%1)", loc);
}
}
QString DesktopPanel::parsePattern(const QString rawLine, const int num)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Raw line" << rawLine;
if (debug) qDebug() << PDEBUG << ":" << "Number" << num;
QString line, fullMark, mark;
line = rawLine;
if (KWindowSystem::currentDesktop() == num + 1)
mark = configuration[QString("mark")];
else
mark = QString("");
fullMark = QString("%1").arg(mark, configuration[QString("mark")].count(), QLatin1Char(' '));
if (line.contains(QString("$fullmark")))
line.replace(QString("$fullmark"), fullMark);
if (line.contains(QString("$mark")))
line.replace(QString("$mark"), mark);
if (line.contains(QString("$name")))
line.replace(QString("$name"), desktopNames[num]);
if (line.contains(QString("$number")))
line.replace(QString("$number"), QString::number(num + 1));
if (line.contains(QString("$total")))
line.replace(QString("$total"), QString::number(desktopNames.count()));
return line;
}
void DesktopPanel::reinit()
{
if (debug) qDebug() << PDEBUG;
// clear
// labels
for (int i=0; i<proxyWidgets.count(); i++) {
layout->removeItem(proxyWidgets[i]);
proxyWidgets[i]->setWidget(0);
delete labels[i];
delete proxyWidgets[i];
}
labels.clear();
proxyWidgets.clear();
desktopNames.clear();
// add
int total = KWindowSystem::numberOfDesktops();
for (int i=1; i<total+1; i++)
desktopNames.append(KWindowSystem::desktopName(i));
// layout
if (configuration[QString("background")].toInt() == 0)
setBackgroundHints(NoBackground);
// labels
for (int i=0; i<desktopNames.count(); i++) {
proxyWidgets.append(new QGraphicsProxyWidget(this));
labels.append(new CustomPlasmaLabel(this, i, debug));
labels[i]->setWordWrap(false);
labels[i]->setAttribute(Qt::WA_TranslucentBackground, true);
proxyWidgets[i]->setWidget(labels[i]);
if (configuration[QString("layout")].toInt() == 0)
layout->addItem(proxyWidgets[i], 0, i);
else
layout->addItem(proxyWidgets[i], i, 0);
}
updateText(KWindowSystem::currentDesktop());
for (int i=0; i<proxyWidgets.count(); i++) {
labels[i]->adjustSize();
proxyWidgets[i]->setGeometry(labels[i]->geometry());
}
emit(KWindowSystem::setCurrentDesktop(KWindowSystem::currentDesktop()));
}
void DesktopPanel::changePanelsState()
{
if (debug) qDebug() << PDEBUG;
QList<Plasma::Containment *> panels = getPanels();
for (int i=0; i<panels.count(); i++) {
if ((!configuration[QString("panels")].split(QChar(','))
.contains(QString::number(i))) &&
(configuration[QString("panels")] != QString("-1")))
continue;
bool wasVisible = panels[i]->view()->isVisible();
int winId = panels[i]->view()->winId();
if (wasVisible) {
if (debug) qDebug() << PDEBUG << ":" << "Hide panel";
KWindowInfo oldInfo = KWindowSystem::windowInfo(winId, NET::WMState);
oldState = oldInfo.state();
panels[i]->view()->setVisible(false);
} else {
if (debug) qDebug() << PDEBUG << ":" << "Show panel";
panels[i]->view()->setVisible(true);
KWindowSystem::clearState(winId, NET::KeepAbove);
KWindowSystem::setState(winId, oldState | NET::StaysOnTop);
KWindowSystem::setOnAllDesktops(winId, true);
}
}
}
void DesktopPanel::paintTooltip(const int active)
{
if (debug) qDebug() << PDEBUG;
if (active == activeTooltip) return;
// prepare
// clear
toolTip.setImage(0);
toolTip.setWindowsToPreview(QList<WId>());
activeTooltip = active;
DesktopWindowsInfo info = getInfoByDesktop(active + 1);
float margin = 5.0 * info.desktop.width() / 400.0;
toolTipView->resize(info.desktop.width() + 2.0 * margin, info.desktop.height() + 2.0 * margin);
toolTipScene->clear();
toolTipScene->setBackgroundBrush(QBrush(Qt::NoBrush));
// borders
toolTipScene->addLine(0, 0, 0, info.desktop.height() + 2.0 * margin);
toolTipScene->addLine(0, info.desktop.height() + 2.0 * margin,
info.desktop.width() + 2.0 * margin, info.desktop.height() + 2.0 * margin);
toolTipScene->addLine(info.desktop.width() + 2.0 * margin, info.desktop.height() + 2.0 * margin,
info.desktop.width() + 2.0 * margin, 0);
toolTipScene->addLine(info.desktop.width() + 2.0 * margin, 0, 0, 0);
if (configuration[QString("tooltipType")].toInt() == 1) {
// only contours
QPen pen = QPen();
pen.setWidthF(2.0 * info.desktop.width() / 400.0);
pen.setColor(QColor(configuration[QString("tooltipColor")]));
for (int i=0; i<info.windows.count(); i++) {
toolTipScene->addLine(info.windows[i].left() + margin, info.windows[i].bottom() + margin,
info.windows[i].left() + margin, info.windows[i].top() + margin, pen);
toolTipScene->addLine(info.windows[i].left() + margin, info.windows[i].top() + margin,
info.windows[i].right() + margin, info.windows[i].top() + margin, pen);
toolTipScene->addLine(info.windows[i].right() + margin, info.windows[i].top() + margin,
info.windows[i].right() + margin, info.windows[i].bottom() + margin, pen);
toolTipScene->addLine(info.windows[i].right() + margin, info.windows[i].bottom() + margin,
info.windows[i].left() + margin, info.windows[i].bottom() + margin, pen);
}
toolTip.setImage(QPixmap::grabWidget(toolTipView).scaledToWidth(configuration[QString("tooltipWidth")].toInt()));
} else if (configuration[QString("tooltipType")].toInt() == 2) {
// clean desktop
toolTip.setWindowsToPreview(info.desktopId);
} else {
// desktop preview
toolTip.setWindowsToPreview(info.winId);
}
Plasma::ToolTipManager::self()->setContent(this, toolTip);
}
void DesktopPanel::setCurrentDesktop(const int number)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Set desktop" << number + 1;
KWindowSystem::setCurrentDesktop(number + 1);
}
void DesktopPanel::updateText(const int active)
{
if (debug) qDebug() << PDEBUG;
QString line, text;
for (int i=0; i<labels.count(); i++) {
if (debug) qDebug() << PDEBUG << ":" << "Label" << i;
line = parsePattern(configuration[QString("pattern")], i);
if (active == i + 1)
text = currentFormatLine[0] + line + currentFormatLine[1];
else
text = formatLine[0] + line + formatLine[1];
labels[i]->setText(text);
}
int height = 0;
int width = 0;
for (int i=0; i<proxyWidgets.count(); i++) {
labels[i]->adjustSize();
proxyWidgets[i]->setGeometry(labels[i]->geometry());
if (configuration[QString("layout")].toInt() == 0) {
width += proxyWidgets[i]->geometry().width();
if (height < proxyWidgets[i]->geometry().height())
height = proxyWidgets[i]->geometry().height();
} else {
height += proxyWidgets[i]->geometry().height();
if (width < proxyWidgets[i]->geometry().width())
width = proxyWidgets[i]->geometry().width();
}
}
layout->setMinimumSize(width, height);
}
// configuration interface
void DesktopPanel::createConfigurationInterface(KConfigDialog *parent)
{
if (debug) qDebug() << PDEBUG;
QWidget *appWidget = new QWidget;
uiAppConfig.setupUi(appWidget);
QWidget *configWidget = new QWidget;
uiWidConfig.setupUi(configWidget);
QWidget *toggleWidget = new QWidget;
uiToggleConfig.setupUi(toggleWidget);
uiWidConfig.textEdit_elements->setPlainText(configuration[QString("pattern")]);
if (configuration[QString("tooltip")].toInt() == 0)
uiWidConfig.checkBox_tooltip->setCheckState(Qt::Unchecked);
else
uiWidConfig.checkBox_tooltip->setCheckState(Qt::Checked);
uiWidConfig.comboBox_tooltipType->setCurrentIndex(configuration[QString("tooltipType")].toInt());
uiWidConfig.spinBox_tooltip->setValue(configuration[QString("tooltipWidth")].toInt());
uiWidConfig.kcolorcombo_tooltipColor->setColor(QColor(configuration[QString("tooltipColor")]));
if (configuration[QString("background")].toInt() == 0)
uiWidConfig.checkBox_background->setCheckState(Qt::Unchecked);
else
uiWidConfig.checkBox_background->setCheckState(Qt::Checked);
if (configuration[QString("layout")].toInt() == 0)
uiWidConfig.checkBox_layout->setCheckState(Qt::Unchecked);
else
uiWidConfig.checkBox_layout->setCheckState(Qt::Checked);
uiWidConfig.comboBox_mark->setItemText(uiWidConfig.comboBox_mark->count()-1, configuration[QString("mark")]);
uiWidConfig.comboBox_mark->setCurrentIndex(uiWidConfig.comboBox_mark->count()-1);
KConfigGroup cg = config();
CFont font(cg.readEntry("currentFontFamily", "Terminus"));
font.setPointSize(cg.readEntry("currentFontSize", 10));
font.setCurrentColor(QColor(cg.readEntry("currentFontColor", "#ff0000")));
font.setHtmlWeight(cg.readEntry("currentFontWeight", 400));
font.setItalic(cg.readEntry("currentFontStyle", "normal") == QString("italic"));
uiAppConfig.fontComboBox_fontActive->setCurrentFont(font.toQFont());
uiAppConfig.spinBox_fontSizeActive->setValue(font.pointSize());
uiAppConfig.kcolorcombo_fontColorActive->setColor(font.color());
if (font.italic())
uiAppConfig.comboBox_fontStyleActive->setCurrentIndex(1);
else
uiAppConfig.comboBox_fontStyleActive->setCurrentIndex(0);
uiAppConfig.spinBox_fontWeightActive->setValue(font.htmlWeight());
font = CFont(cg.readEntry("fontFamily", "Terminus"));
font.setPointSize(cg.readEntry("fontSize", 10));
font.setCurrentColor(QColor(cg.readEntry("fontColor", "#000000")));
font.setHtmlWeight(cg.readEntry("fontWeight", 400));
font.setItalic(cg.readEntry("fontStyle", "normal") == QString("italic"));
uiAppConfig.fontComboBox_fontInactive->setCurrentFont(font.toQFont());
uiAppConfig.spinBox_fontSizeInactive->setValue(font.pointSize());
uiAppConfig.kcolorcombo_fontColorInactive->setColor(font.color());
if (font.italic())
uiAppConfig.comboBox_fontStyleInactive->setCurrentIndex(1);
else
uiAppConfig.comboBox_fontStyleInactive->setCurrentIndex(0);
uiAppConfig.spinBox_fontWeightInactive->setValue(font.htmlWeight());
uiToggleConfig.listWidget_list->clear();
QList<Plasma::Containment *> panels = getPanels();
for (int i=0; i<panels.count(); i++) {
QListWidgetItem *item = new QListWidgetItem(panelLocationToStr(panels[i]->location()), uiToggleConfig.listWidget_list);
item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
if ((configuration[QString("panels")].split(QChar(','))
.contains(QString::number(i))) ||
(configuration[QString("panels")] == QString("-1")))
item->setCheckState(Qt::Checked);
else
item->setCheckState(Qt::Unchecked);
}
parent->addPage(configWidget, i18n("Widget"), Applet::icon());
parent->addPage(appWidget, i18n("Appearance"), QString("preferences-desktop-theme"));
parent->addPage(toggleWidget, i18n("Toggle panels"), QString("plasma"));
connect(uiWidConfig.pushButton_tags, SIGNAL(clicked(bool)), this, SLOT(setFormating()));
connect(uiWidConfig.pushButton_br, SIGNAL(clicked(bool)), this, SLOT(setFormating()));
connect(uiWidConfig.pushButton_font, SIGNAL(clicked(bool)), this, SLOT(setFontFormating()));
connect(uiWidConfig.pushButton_bold, SIGNAL(clicked(bool)), this, SLOT(setFormating()));
connect(uiWidConfig.pushButton_italic, SIGNAL(clicked(bool)), this, SLOT(setFormating()));
connect(uiWidConfig.pushButton_underline, SIGNAL(clicked(bool)), this, SLOT(setFormating()));
connect(uiWidConfig.pushButton_strike, SIGNAL(clicked(bool)), this, SLOT(setFormating()));
connect(uiWidConfig.pushButton_left, SIGNAL(clicked(bool)), this, SLOT(setFormating()));
connect(uiWidConfig.pushButton_center, SIGNAL(clicked(bool)), this, SLOT(setFormating()));
connect(uiWidConfig.pushButton_right, SIGNAL(clicked(bool)), this, SLOT(setFormating()));
connect(uiWidConfig.pushButton_fill, SIGNAL(clicked(bool)), this, SLOT(setFormating()));
connect(parent, SIGNAL(okClicked()), this, SLOT(configAccepted()));
connect(parent, SIGNAL(applyClicked()), this, SLOT(configAccepted()));
}
void DesktopPanel::configAccepted()
{
if (debug) qDebug() << PDEBUG;
KConfigGroup cg = config();
cg.writeEntry("pattern", uiWidConfig.textEdit_elements->toPlainText());
cg.writeEntry("tooltip", QString::number(uiWidConfig.checkBox_tooltip->checkState()));
cg.writeEntry("tooltipType", QString::number(uiWidConfig.comboBox_tooltipType->currentIndex()));
cg.writeEntry("tooltipWidth", QString::number(uiWidConfig.spinBox_tooltip->value()));
cg.writeEntry("tooltipColor", uiWidConfig.kcolorcombo_tooltipColor->color().name());
cg.writeEntry("background", QString::number(uiWidConfig.checkBox_background->checkState()));
cg.writeEntry("layout", QString::number(uiWidConfig.checkBox_layout->checkState()));
cg.writeEntry("mark", uiWidConfig.comboBox_mark->currentText());
cg.writeEntry("currentFontFamily", uiAppConfig.fontComboBox_fontActive->currentFont().family());
cg.writeEntry("currentFontSize", uiAppConfig.spinBox_fontSizeActive->value());
cg.writeEntry("currentFontColor", uiAppConfig.kcolorcombo_fontColorActive->color().name());
cg.writeEntry("currentFontWeight", uiAppConfig.spinBox_fontWeightActive->value());
cg.writeEntry("currentFontStyle", uiAppConfig.comboBox_fontStyleActive->currentText());
cg.writeEntry("fontFamily", uiAppConfig.fontComboBox_fontInactive->currentFont().family());
cg.writeEntry("fontSize", uiAppConfig.spinBox_fontSizeInactive->value());
cg.writeEntry("fontColor", uiAppConfig.kcolorcombo_fontColorInactive->color().name());
cg.writeEntry("fontWeight", uiAppConfig.spinBox_fontWeightInactive->value());
cg.writeEntry("fontStyle", uiAppConfig.comboBox_fontStyleInactive->currentText());
QStringList indexes;
for (int i=0; i<uiToggleConfig.listWidget_list->count(); i++)
if (uiToggleConfig.listWidget_list->item(i)->checkState() == Qt::Checked)
indexes.append(QString::number(i));
if (indexes.count() == uiToggleConfig.listWidget_list->count())
cg.writeEntry("panels", QString("-1"));
else
cg.writeEntry("panels", indexes.join(QChar(',')));
}
void DesktopPanel::configChanged()
{
if (debug) qDebug() << PDEBUG;
KConfigGroup cg = config();
configuration[QString("pattern")] = cg.readEntry("pattern", "[$fullmark$number/$total: $name]");
configuration[QString("tooltip")] = cg.readEntry("tooltip", "2");
configuration[QString("tooltipType")] = cg.readEntry("tooltipType", "0");
configuration[QString("tooltipWidth")] = cg.readEntry("tooltipWidth", "200");
configuration[QString("tooltipColor")] = cg.readEntry("tooltipColor", "#ffffff");
configuration[QString("background")] = cg.readEntry("background", "2");
configuration[QString("layout")] = cg.readEntry("layout", "0");
configuration[QString("mark")] = cg.readEntry("mark", "¤");
configuration[QString("panels")] = cg.readEntry("panels", "-1");
CFont font = CFont(cg.readEntry("currentFontFamily", "Terminus"));
font.setPointSize(cg.readEntry("currentFontSize", 10));
font.setCurrentColor(QColor(cg.readEntry("currentFontColor", "#ff0000")));
font.setHtmlWeight(cg.readEntry("currentFontWeight", 400));
font.setItalic(cg.readEntry("currentFontStyle", "normal") == QString("italic"));
QString fontStyle;
if (font.italic())
fontStyle = QString("italic");
else
fontStyle = QString("normal");
currentFormatLine[0] = QString("<html><head><style type=\"text/css\">p, li { white-space: pre-wrap; }</style>\
</head><body style=\"font-family:'%1'; font-size:%2pt; font-weight:%3; font-style:%4; color:%5;\">")
.arg(font.family())
.arg(font.pointSize())
.arg(font.htmlWeight())
.arg(fontStyle)
.arg(font.color().name());
currentFormatLine[1] = QString("</body></html>");
font = CFont(cg.readEntry("fontFamily", "Terminus"));
font.setPointSize(cg.readEntry("fontSize", 10));
font.setCurrentColor(QColor(cg.readEntry("fontColor", "#000000")));
font.setHtmlWeight(cg.readEntry("fontWeight", 400));
font.setItalic(cg.readEntry("fontStyle", "normal") == QString("italic"));
if (font.italic())
fontStyle = QString("italic");
else
fontStyle = QString("normal");
formatLine[0] = QString("<html><head><style type=\"text/css\">p, li { white-space: pre-wrap; }</style>\
</head><body style=\"font-family:'%1'; font-size:%2pt; font-weight:%3; font-style:%4; color:%5;\">")
.arg(font.family())
.arg(font.pointSize())
.arg(font.htmlWeight())
.arg(fontStyle)
.arg(font.color().name());
formatLine[1] = QString("</body></html>");
reinit();
}
void DesktopPanel::setFontFormating()
{
if (debug) qDebug() << PDEBUG;
CFont defaultFont = CFont(uiAppConfig.fontComboBox_fontInactive->currentFont().family(),
uiAppConfig.spinBox_fontSizeInactive->value(),
400, false, uiAppConfig.kcolorcombo_fontColorInactive->color());
CFont font = CFontDialog::getFont(i18n("Select font"), defaultFont,
false, false);
QString selectedText = uiWidConfig.textEdit_elements->textCursor().selectedText();
uiWidConfig.textEdit_elements->insertPlainText(QString("<span style=\"color:%1; font-family:'%2'; font-size:%3pt;\">")
.arg(font.color().name()).arg(font.family()).arg(font.pointSize()) +
selectedText + QString("</span>"));
}
void DesktopPanel::setFormating()
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Sender" << sender();
QString selectedText = uiWidConfig.textEdit_elements->textCursor().selectedText();
if (sender() == uiWidConfig.pushButton_tags)
uiWidConfig.textEdit_elements->insertPlainText(QString("$") + uiWidConfig.comboBox_tags->currentText());
else if (sender() == uiWidConfig.pushButton_br)
uiWidConfig.textEdit_elements->insertPlainText(QString("<br>\n"));
else if (sender() == uiWidConfig.pushButton_bold)
uiWidConfig.textEdit_elements->insertPlainText(QString("<b>") + selectedText + QString("</b>"));
else if (sender() == uiWidConfig.pushButton_italic)
uiWidConfig.textEdit_elements->insertPlainText(QString("<i>") + selectedText + QString("</i>"));
else if (sender() == uiWidConfig.pushButton_underline)
uiWidConfig.textEdit_elements->insertPlainText(QString("<u>") + selectedText + QString("</u>"));
else if (sender() == uiWidConfig.pushButton_strike)
uiWidConfig.textEdit_elements->insertPlainText(QString("<s>") + selectedText + QString("</s>"));
else if (sender() == uiWidConfig.pushButton_left)
uiWidConfig.textEdit_elements->insertPlainText(QString("<p align=\"left\">") + selectedText + QString("</p>"));
else if (sender() == uiWidConfig.pushButton_center)
uiWidConfig.textEdit_elements->insertPlainText(QString("<p align=\"center\">") + selectedText + QString("</p>"));
else if (sender() == uiWidConfig.pushButton_right)
uiWidConfig.textEdit_elements->insertPlainText(QString("<p align=\"right\">") + selectedText + QString("</p>"));
else if (sender() == uiWidConfig.pushButton_fill)
uiWidConfig.textEdit_elements->insertPlainText(QString("<p align=\"justify\">") + selectedText + QString("</p>"));
}
#include "desktop-panel.moc"

View File

@ -0,0 +1,125 @@
/***************************************************************************
* This file is part of awesome-widgets *
* *
* awesome-widgets is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* awesome-widgets is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#ifndef DESKTOP_PANEL_H
#define DESKTOP_PANEL_H
#include <Plasma/Applet>
#include <Plasma/ToolTipContent>
#include <QLabel>
#include <ui_appearance.h>
#include <ui_toggle.h>
#include <ui_widget.h>
class QGraphicsGridLayout;
class QGraphicsProxyWidget;
class QGraphicsScene;
class DesktopPanel;
class CustomPlasmaLabel : public QLabel
{
Q_OBJECT
public:
CustomPlasmaLabel(DesktopPanel *wid,
const int num,
const bool debugCmd = false);
~CustomPlasmaLabel();
int getNumber();
protected:
void enterEvent(QEvent *event);
void mousePressEvent(QMouseEvent *event);
private:
// debug
bool debug;
// variables
int number;
DesktopPanel *widget;
};
class DesktopPanel : public Plasma::Applet
{
Q_OBJECT
typedef struct {
QRect desktop;
QList<WId> desktopId;
QList<QRect> windows;
QList<WId> winId;
} DesktopWindowsInfo;
public:
DesktopPanel(QObject *parent, const QVariantList &args);
~DesktopPanel();
void init();
DesktopWindowsInfo getInfoByDesktop(const int num);
QString parsePattern(const QString rawLine, const int num);
public slots:
// configuration interface
void configAccepted();
void configChanged();
// events
void changePanelsState();
void paintTooltip(const int active);
void setCurrentDesktop(const int number);
private slots:
void reinit();
void setFontFormating();
void setFormating();
void updateText(const int active);
protected:
void createConfigurationInterface(KConfigDialog *parent);
private:
// functions
QList<Plasma::Containment *> getPanels();
QString panelLocationToStr(Plasma::Location loc);
// ui
QGraphicsGridLayout *layout = nullptr;
QList<QGraphicsProxyWidget *> proxyWidgets;
QList<CustomPlasmaLabel *> labels;
// tooltip
Plasma::ToolTipContent toolTip;
QGraphicsScene *toolTipScene = nullptr;
QGraphicsView *toolTipView = nullptr;
// debug
bool debug;
int activeTooltip = -1;
int oldState = 0;
// configuration interface
Ui::AppearanceWidget uiAppConfig;
Ui::ConfigWindow uiWidConfig;
Ui::ToggleWindow uiToggleConfig;
// configuration
QMap<QString, QString> configuration;
QStringList desktopNames, currentFormatLine, formatLine;
};
K_EXPORT_PLASMA_APPLET(desktop-panel, DesktopPanel)
#endif /* DESKTOP_PANEL_H */

View File

@ -0,0 +1,25 @@
[Desktop Entry]
Encoding=UTF-8
Name=Desktop Panel
Comment=A minimalistic Plasmoid
Comment[en]=A minimalistic Plasmoid
Comment[es]=Un plasmoide minimalista
Comment[es]=Un script Plasmoïde minimaliste
Comment[pt_BR]=Um script Plasmoid
Comment[ru]=Минималистичный плазмоид
Comment[uk]=Мінімалістичний плазмоїд
X-KDE-ServiceTypes=Plasma/Applet
Type=Service
Icon=utilities-system-monitor
X-KDE-Library=plasma_applet_desktop-panel
X-KDE-PluginInfo-Author=Evgeniy Alekseev aka arcanis
X-KDE-PluginInfo-Email=esalexeev@gmail.com
X-KDE-PluginInfo-Name=desktop-panel
X-KDE-PluginInfo-Version=@PROJECT_VERSION@
X-KDE-PluginInfo-Website=http://arcanis.name/projects/awesome-widgets/
X-KDE-PluginInfo-Category=System Information
X-KDE-PluginInfo-Depends=
X-KDE-PluginInfo-License=GPLv3
X-KDE-PluginInfo-EnabledByDefault=true

View File

@ -0,0 +1,56 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ToggleWindow</class>
<widget class="QWidget" name="ToggleWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>480</width>
<height>343</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>480</width>
<height>320</height>
</size>
</property>
<property name="windowTitle">
<string notr="true">Toggle</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QScrollArea" name="scrollArea">
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>464</width>
<height>327</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label_info">
<property name="text">
<string>To control panels please set widget shortcut.</string>
</property>
</widget>
</item>
<item>
<widget class="QListWidget" name="listWidget_list"/>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,472 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ConfigWindow</class>
<widget class="QWidget" name="ConfigWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>721</width>
<height>420</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>700</width>
<height>320</height>
</size>
</property>
<property name="windowTitle">
<string notr="true">Widget</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="9" column="0">
<layout class="QHBoxLayout" name="layout_mark">
<item>
<widget class="QLabel" name="label_mark">
<property name="text">
<string>Mark</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox_mark">
<property name="toolTip">
<string>A mark which will be shown if this desktop is active</string>
</property>
<property name="editable">
<bool>true</bool>
</property>
<item>
<property name="text">
<string notr="true">#</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">$</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">%</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">&amp;</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">*</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">@</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">¤</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">¶</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">·</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">º</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">×</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">†</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">•</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">(current)</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item row="0" column="0">
<layout class="QHBoxLayout" name="layput_mainFormating">
<item>
<widget class="QPushButton" name="pushButton_font">
<property name="text">
<string>Font</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_br">
<property name="icon">
<iconset theme="stock_text_indent">
<normaloff>../awesome-widget</normaloff>../awesome-widget</iconset>
</property>
</widget>
</item>
<item>
<spacer name="spacer_mainFormatingCenter1">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pushButton_bold">
<property name="icon">
<iconset theme="format-text-bold">
<normaloff>../awesome-widget</normaloff>../awesome-widget</iconset>
</property>
<property name="shortcut">
<string>Ctrl+B</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_italic">
<property name="icon">
<iconset theme="format-text-italic">
<normaloff>../awesome-widget</normaloff>../awesome-widget</iconset>
</property>
<property name="shortcut">
<string>Ctrl+I</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_underline">
<property name="icon">
<iconset theme="format-text-underline">
<normaloff>../awesome-widget</normaloff>../awesome-widget</iconset>
</property>
<property name="shortcut">
<string>Ctrl+U</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_strike">
<property name="icon">
<iconset theme="format-text-strikethrough">
<normaloff>../awesome-widget</normaloff>../awesome-widget</iconset>
</property>
</widget>
</item>
<item>
<spacer name="spacer_mainFormatingCenter2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pushButton_left">
<property name="icon">
<iconset theme="format-justify-left">
<normaloff>../awesome-widget</normaloff>../awesome-widget</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_center">
<property name="icon">
<iconset theme="format-justify-center">
<normaloff>../awesome-widget</normaloff>../awesome-widget</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_right">
<property name="icon">
<iconset theme="format-justify-right">
<normaloff>../awesome-widget</normaloff>../awesome-widget</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_fill">
<property name="icon">
<iconset theme="format-justify-fill">
<normaloff>../awesome-widget</normaloff>../awesome-widget</iconset>
</property>
</widget>
</item>
<item>
<spacer name="spacer_mainFormatingCenter3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QComboBox" name="comboBox_tags">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<item>
<property name="text">
<string notr="true">fullmark</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">mark</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">name</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">number</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">total</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_tags">
<property name="text">
<string>Add</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="QTextEdit" name="textEdit_elements">
<property name="lineWrapMode">
<enum>QTextEdit::NoWrap</enum>
</property>
<property name="acceptRichText">
<bool>false</bool>
</property>
</widget>
</item>
<item row="5" column="0">
<layout class="QHBoxLayout" name="layout_tooltip">
<item>
<widget class="QLabel" name="label_tooltip">
<property name="text">
<string>Tooltip width</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinBox_tooltip">
<property name="suffix">
<string>px</string>
</property>
<property name="minimum">
<number>100</number>
</property>
<property name="maximum">
<number>1000</number>
</property>
<property name="singleStep">
<number>25</number>
</property>
</widget>
</item>
</layout>
</item>
<item row="6" column="0">
<layout class="QHBoxLayout" name="layout_tooltipColor">
<item>
<widget class="QLabel" name="label_tooltipColor">
<property name="text">
<string>Window border color on tooltip</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="KColorCombo" name="kcolorcombo_tooltipColor"/>
</item>
</layout>
</item>
<item row="2" column="0">
<layout class="QHBoxLayout" name="layout_background">
<item>
<spacer name="spacer_background">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QCheckBox" name="checkBox_background">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Enable background</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="3" column="0">
<layout class="QHBoxLayout" name="layout_layout">
<item>
<spacer name="spacer_layout">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QCheckBox" name="checkBox_layout">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Vertical layout</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="4" column="0">
<layout class="QHBoxLayout" name="layout_tooltip_2">
<item>
<widget class="QCheckBox" name="checkBox_tooltip">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
</property>
<property name="text">
<string>Enable tooltip</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox_tooltipType">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<item>
<property name="text">
<string>Windows</string>
</property>
</item>
<item>
<property name="text">
<string>Contours</string>
</property>
</item>
<item>
<property name="text">
<string>Clean desktop</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>KColorCombo</class>
<extends>QComboBox</extends>
<header>kcolorcombo.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,44 @@
# set project name
set (SUBPROJECT plasma_dataengine_extsysmon)
set (PLUGIN_NAME ${SUBPROJECT})
message (STATUS "Subproject ${SUBPROJECT}")
# find required libaries
find_package (KDE4 REQUIRED)
include (KDE4Defaults)
add_definitions (${QT_DEFINITIONS} ${KDE4_DEFINITIONS})
set (KDE_INCLUDE ${KDE4_INCLUDES})
include_directories (${CMAKE_SOURCE_DIR}
${CMAKE_BINARY_DIR}
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_BINARY_DIR}/../
${PROJECT_TRDPARTY_DIR}
${Qt_INCLUDE}
${KDE_INCLUDE})
file (GLOB SUBPROJECT_DESKTOP_IN *.desktop)
file (RELATIVE_PATH SUBPROJECT_DESKTOP ${CMAKE_SOURCE_DIR} ${SUBPROJECT_DESKTOP_IN})
file (GLOB_RECURSE SUBPROJECT_SOURCE *.cpp ${PROJECT_TRDPARTY_DIR}/task/*.cpp)
set (TASK_HEADER ${PROJECT_TRDPARTY_DIR}/task/task.h)
file (GLOB SUBPROJECT_UI *.ui)
file (GLOB SUBPROJECT_CONF *.conf)
set (SUBPROJECT_SCRIPTS ${CMAKE_CURRENT_SOURCE_DIR}/scripts)
set (SUBPROJECT_UPGRADE ${CMAKE_CURRENT_SOURCE_DIR}/upgrade)
# prepare
configure_file (${SUBPROJECT_DESKTOP_IN} ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT_DESKTOP})
# make
qt4_wrap_cpp (TASK_MOC_SOURCE ${TASK_HEADER})
kde4_add_ui_files (SUBPROJECT_SOURCE ${SUBPROJECT_UI})
kde4_add_plugin (${PLUGIN_NAME} ${SUBPROJECT_SOURCE} ${TASK_MOC_SOURCE})
target_link_libraries (${PLUGIN_NAME} ${KDE4_KDECORE_LIBS} ${KDE4_PLASMA_LIBS} ${QT_QTNETWORK_LIBRARY})
# install
install (TARGETS ${PLUGIN_NAME} DESTINATION ${PLUGIN_INSTALL_DIR})
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT_DESKTOP} DESTINATION ${SERVICES_INSTALL_DIR})
install (FILES ${SUBPROJECT_CONF} DESTINATION ${CONFIG_INSTALL_DIR})
install (DIRECTORY ${SUBPROJECT_SCRIPTS} DESTINATION ${DATA_INSTALL_DIR}/${PROJECT_NAME})
install (DIRECTORY ${SUBPROJECT_UPGRADE} DESTINATION ${DATA_INSTALL_DIR}/${PROJECT_NAME})

View File

@ -0,0 +1,390 @@
/***************************************************************************
* This file is part of awesome-widgets *
* *
* awesome-widgets is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* awesome-widgets is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#include "extscript.h"
#include "ui_extscript.h"
#include <QDebug>
#include <QDir>
#include <QSettings>
#include <QTextCodec>
#include <pdebug/pdebug.h>
#include <task/taskadds.h>
#include "version.h"
ExtScript::ExtScript(QWidget *parent, const QString scriptName, const QStringList directories, const bool debugCmd)
: QDialog(parent),
m_fileName(scriptName),
m_dirs(directories),
debug(debugCmd),
ui(new Ui::ExtScript)
{
m_name = m_fileName;
readConfiguration();
ui->setupUi(this);
}
ExtScript::~ExtScript()
{
if (debug) qDebug() << PDEBUG;
delete ui;
}
int ExtScript::apiVersion()
{
if (debug) qDebug() << PDEBUG;
return m_apiVersion;
}
QString ExtScript::comment()
{
if (debug) qDebug() << PDEBUG;
return m_comment;
}
QString ExtScript::executable()
{
if (debug) qDebug() << PDEBUG;
return m_executable;
}
QString ExtScript::fileName()
{
if (debug) qDebug() << PDEBUG;
return m_fileName;
}
int ExtScript::interval()
{
if (debug) qDebug() << PDEBUG;
return m_interval;
}
QString ExtScript::name()
{
if (debug) qDebug() << PDEBUG;
return m_name;
}
QString ExtScript::prefix()
{
if (debug) qDebug() << PDEBUG;
return m_prefix;
}
ExtScript::Redirect ExtScript::redirect()
{
if (debug) qDebug() << PDEBUG;
return m_redirect;
}
QString ExtScript::strRedirect()
{
if (debug) qDebug() << PDEBUG;
QString value;
switch (m_redirect) {
case stdout2stderr:
value = QString("stdout2stderr");
break;
case stderr2stdout:
value = QString("stderr2stdout");
break;
default:
value = QString("nothing");
break;
}
return value;
}
bool ExtScript::hasOutput()
{
if (debug) qDebug() << PDEBUG;
return m_output;
}
bool ExtScript::isActive()
{
if (debug) qDebug() << PDEBUG;
return m_active;
}
void ExtScript::setApiVersion(const int _apiVersion)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Version" << _apiVersion;
m_apiVersion = _apiVersion;
}
void ExtScript::setActive(const bool state)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "State" << state;
m_active = state;
}
void ExtScript::setComment(const QString _comment)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Comment" << _comment;
m_comment = _comment;
}
void ExtScript::setExecutable(const QString _executable)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Executable" << _executable;
m_executable = _executable;
}
void ExtScript::setHasOutput(const bool state)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "State" << state;
m_output = state;
}
void ExtScript::setInterval(const int _interval)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Interval" << _interval;
if (_interval <= 0) return;
m_interval = _interval;
}
void ExtScript::setName(const QString _name)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Name" << _name;
m_name = _name;
}
void ExtScript::setPrefix(const QString _prefix)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Prefix" << _prefix;
m_prefix = _prefix;
}
void ExtScript::setRedirect(const Redirect _redirect)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Redirect" << _redirect;
m_redirect = _redirect;
}
void ExtScript::setStrRedirect(const QString _redirect)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Redirect" << _redirect;
if (_redirect == QString("stdout2sdterr"))
m_redirect = stdout2stderr;
else if (_redirect == QString("stderr2sdtout"))
m_redirect = stderr2stdout;
else
m_redirect = nothing;
}
void ExtScript::readConfiguration()
{
if (debug) qDebug() << PDEBUG;
for (int i=m_dirs.count()-1; i>=0; i--) {
if (!QDir(m_dirs[i]).entryList(QDir::Files).contains(m_fileName)) continue;
QSettings settings(m_dirs[i] + QDir::separator() + m_fileName, QSettings::IniFormat);
settings.beginGroup(QString("Desktop Entry"));
setName(settings.value(QString("Name"), m_name).toString());
setComment(settings.value(QString("Comment"), m_comment).toString());
setApiVersion(settings.value(QString("X-AW-ApiVersion"), AWESAPI).toInt());
setExecutable(settings.value(QString("Exec"), m_executable).toString());
setPrefix(settings.value(QString("X-AW-Prefix"), m_prefix).toString());
setActive(settings.value(QString("X-AW-Active"), QVariant(m_active)).toString() == QString("true"));
setHasOutput(settings.value(QString("X-AW-Output"), QVariant(m_output)).toString() == QString("true"));
setStrRedirect(settings.value(QString("X-AW-Redirect"), strRedirect()).toString());
setInterval(settings.value(QString("X-AW-Interval"), m_interval).toInt());
settings.endGroup();
}
if (!m_output)
setRedirect(stdout2stderr);
}
QString ExtScript::run()
{
if (debug) qDebug() << PDEBUG;
if (!m_active) return value;
if (times == 1) {
QStringList cmdList;
if (!m_prefix.isEmpty())
cmdList.append(m_prefix);
cmdList.append(m_executable);
if (debug) qDebug() << PDEBUG << ":" << "cmd" << cmdList.join(QChar(' '));
TaskResult process = runTask(cmdList.join(QChar(' ')));
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
if (process.exitCode != 0)
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
QString info = QString::number(process.exitCode) + QString(":") +
QTextCodec::codecForMib(106)->toUnicode(process.error).trimmed();
QString qoutput = QTextCodec::codecForMib(106)->toUnicode(process.output).trimmed();
switch (m_redirect) {
case stdout2stderr:
if (debug) qDebug() << PDEBUG << ":" << "Debug" << info;
if (debug) qDebug() << PDEBUG << ":" << "Output" << qoutput;
break;
case stderr2stdout:
value = info + QString("\t") + qoutput;
break;
default:
if (debug) qDebug() << PDEBUG << ":" << "Debug" << info;
value = qoutput;
break;
}
}
// update value
if (times >= m_interval) times = 0;
times++;
return value;
}
int ExtScript::showConfiguration()
{
if (debug) qDebug() << PDEBUG;
ui->lineEdit_name->setText(m_name);
ui->lineEdit_comment->setText(m_comment);
ui->lineEdit_command->setText(m_executable);
ui->lineEdit_prefix->setText(m_prefix);
if (m_active)
ui->checkBox_active->setCheckState(Qt::Checked);
else
ui->checkBox_active->setCheckState(Qt::Unchecked);
if (m_output)
ui->checkBox_output->setCheckState(Qt::Checked);
else
ui->checkBox_output->setCheckState(Qt::Unchecked);
ui->comboBox_redirect->setCurrentIndex(static_cast<int>(m_redirect));
ui->spinBox_interval->setValue(m_interval);
int ret = exec();
if (ret != 1) return ret;
setName(ui->lineEdit_name->text());
setComment(ui->lineEdit_comment->text());
setApiVersion(AWESAPI);
setExecutable(ui->lineEdit_command->text());
setPrefix(ui->lineEdit_prefix->text());
setActive(ui->checkBox_active->checkState() == Qt::Checked);
setHasOutput(ui->checkBox_output->checkState() == Qt::Checked);
setStrRedirect(ui->comboBox_redirect->currentText());
setInterval(ui->spinBox_interval->value());
writeConfiguration();
return ret;
}
int ExtScript::tryDelete()
{
if (debug) qDebug() << PDEBUG;
for (int i=0; i<m_dirs.count(); i++)
if (debug) qDebug() << PDEBUG << ":" << "Remove file" << m_dirs[i] + QDir::separator() + m_fileName <<
QFile::remove(m_dirs[i] + QDir::separator() + m_fileName);
// check if exists
for (int i=0; i<m_dirs.count(); i++)
if (QFile::exists(m_dirs[i] + QDir::separator() + m_fileName)) return 0;
return 1;
}
void ExtScript::writeConfiguration()
{
if (debug) qDebug() << PDEBUG;
QSettings settings(m_dirs[0] + QDir::separator() + m_fileName, QSettings::IniFormat);
if (debug) qDebug() << PDEBUG << ":" << "Configuration file" << settings.fileName();
settings.beginGroup(QString("Desktop Entry"));
settings.setValue(QString("Encoding"), QString("UTF-8"));
settings.setValue(QString("Name"), m_name);
settings.setValue(QString("Comment"), m_comment);
settings.setValue(QString("Exec"), m_executable);
settings.setValue(QString("X-AW-ApiVersion"), m_apiVersion);
settings.setValue(QString("X-AW-Prefix"), m_prefix);
settings.setValue(QString("X-AW-Active"), QVariant(m_active).toString());
settings.setValue(QString("X-AW-Output"), QVariant(m_active).toString());
settings.setValue(QString("X-AW-Redirect"), strRedirect());
settings.setValue(QString("X-AW-Interval"), m_interval);
settings.endGroup();
settings.sync();
}

View File

@ -0,0 +1,102 @@
/***************************************************************************
* This file is part of awesome-widgets *
* *
* awesome-widgets is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* awesome-widgets is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#ifndef EXTSCRIPT_H
#define EXTSCRIPT_H
#include <QDialog>
namespace Ui {
class ExtScript;
}
class ExtScript : public QDialog
{
Q_OBJECT
Q_PROPERTY(int apiVersion READ apiVersion WRITE setApiVersion)
Q_PROPERTY(QString name READ name WRITE setName)
Q_PROPERTY(QString comment READ comment WRITE setComment)
Q_PROPERTY(QString executable READ executable WRITE setExecutable)
Q_PROPERTY(QString prefix READ prefix WRITE setPrefix)
Q_PROPERTY(bool active READ isActive WRITE setActive)
Q_PROPERTY(bool output READ hasOutput WRITE setHasOutput)
Q_PROPERTY(int interval READ interval WRITE setInterval)
Q_PROPERTY(Redirect redirect READ redirect WRITE setRedirect)
public:
enum Redirect {
stdout2stderr = 0,
nothing,
stderr2stdout
};
explicit ExtScript(QWidget *parent = 0, const QString scriptName = QString(),
const QStringList directories = QStringList(), const bool debugCmd = false);
~ExtScript();
// get methods
int apiVersion();
QString comment();
QString executable();
QString fileName();
int interval();
QString name();
QString prefix();
Redirect redirect();
QString strRedirect();
bool hasOutput();
bool isActive();
// set methods
void setApiVersion(const int _apiVersion = 0);
void setActive(const bool _state = true);
void setComment(const QString _comment = QString("empty"));
void setExecutable(const QString _executable = QString("/usr/bin/true"));
void setHasOutput(const bool _state = true);
void setInterval(const int _interval = 1);
void setName(const QString _name = QString("none"));
void setPrefix(const QString _prefix = QString(""));
void setRedirect(const Redirect _redirect = nothing);
void setStrRedirect(const QString _redirect = QString("nothing"));
public slots:
void readConfiguration();
QString run();
int showConfiguration();
int tryDelete();
void writeConfiguration();
private:
QString m_fileName;
QStringList m_dirs;
bool debug;
Ui::ExtScript *ui;
// properties
int m_apiVersion = 0;
bool m_active = true;
QString m_comment = QString("empty");
QString m_executable = QString("/usr/bin/true");
int m_interval = 1;
QString m_name = QString("none");
bool m_output = true;
QString m_prefix = QString("");
Redirect m_redirect = nothing;
int times = 0;
QString value = QString();
};
#endif /* EXTSCRIPT_H */

View File

@ -0,0 +1,283 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ExtScript</class>
<widget class="QDialog" name="ExtScript">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>420</width>
<height>301</height>
</rect>
</property>
<property name="windowTitle">
<string>Configuration</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="layout_name">
<item>
<widget class="QLabel" name="label_name">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Name</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_name"/>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_comment">
<item>
<widget class="QLabel" name="label_comment">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Comment</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_comment"/>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_command">
<item>
<widget class="QLabel" name="label_command">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Command</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_command"/>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_prefix">
<item>
<widget class="QLabel" name="label_prefix">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Prefix</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_prefix"/>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_active">
<item>
<spacer name="spacer_active">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QCheckBox" name="checkBox_active">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Active</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_output">
<item>
<spacer name="spacer_output">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QCheckBox" name="checkBox_output">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Has output</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_redirect">
<item>
<widget class="QLabel" name="label_redirect">
<property name="text">
<string>Redirect</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox_redirect">
<item>
<property name="text">
<string notr="true">stdout2stderr</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">nothing</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">stderr2stdout</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_interval">
<item>
<widget class="QLabel" name="label_interval">
<property name="text">
<string>Interval</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinBox_interval">
<property name="minimum">
<number>1</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>ExtScript</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>ExtScript</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -0,0 +1,678 @@
/***************************************************************************
* This file is part of awesome-widgets *
* *
* awesome-widgets is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* awesome-widgets is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#include "extsysmon.h"
#include <KWindowSystem>
#include <Plasma/DataContainer>
#include <QDBusArgument>
#include <QDBusConnection>
#include <QDBusConnectionInterface>
#include <QDBusMessage>
#include <QDebug>
#include <QDir>
#include <QFile>
#include <QNetworkInterface>
#include <QProcessEnvironment>
#include <QRegExp>
#include <QTextCodec>
#include <QSettings>
#include <pdebug/pdebug.h>
#include <task/taskadds.h>
#include "extscript.h"
#include "extupgrade.h"
#include "version.h"
#include <KGlobal>
#include <KStandardDirs>
ExtendedSysMon::ExtendedSysMon(QObject* parent, const QVariantList &args)
: Plasma::DataEngine(parent, args)
{
Q_UNUSED(args)
// debug
QProcessEnvironment environment = QProcessEnvironment::systemEnvironment();
QString debugEnv = environment.value(QString("DEBUG"), QString("no"));
debug = (debugEnv == QString("yes"));
setMinimumPollingInterval(333);
readConfiguration();
initScripts();
initUpgrade();
}
QString ExtendedSysMon::getAllHdd()
{
if (debug) qDebug() << PDEBUG;
QStringList allDevices = QDir(QString("/dev")).entryList(QDir::System, QDir::Name);
QStringList devices = allDevices.filter(QRegExp(QString("^[hms]d[a-z]$")));
for (int i=0; i<devices.count(); i++)
devices[i] = QString("/dev/") + devices[i];
if (debug) qDebug() << PDEBUG << ":" << "Device list" << devices;
return devices.join(QChar(','));
}
QString ExtendedSysMon::getAutoGpu()
{
if (debug) qDebug() << PDEBUG;
QString gpu = QString("disable");
QFile moduleFile(QString("/proc/modules"));
if (!moduleFile.open(QIODevice::ReadOnly)) return gpu;
QString output = moduleFile.readAll();
if (output.contains(QString("fglrx")))
gpu = QString("ati");
else if (output.contains(QString("nvidia")))
gpu = QString("nvidia");
if (debug) qDebug() << PDEBUG << ":" << "Device" << gpu;
return gpu;
}
QString ExtendedSysMon::getAutoMpris()
{
if (debug) qDebug() << PDEBUG;
QDBusMessage listServices = QDBusConnection::sessionBus().interface()->call(QDBus::BlockWithGui, QString("ListNames"));
if (listServices.arguments().count() == 0) return QString();
QStringList arguments = listServices.arguments()[0].toStringList();
for (int i=0; i<arguments.count(); i++) {
if (debug) qDebug() << PDEBUG << ":" << "Service found" << arguments[i];
if (!arguments[i].startsWith(QString("org.mpris.MediaPlayer2."))) continue;
QString service = arguments[i];
service.remove(QString("org.mpris.MediaPlayer2."));
return service;
}
return QString();
}
void ExtendedSysMon::initScripts()
{
if (debug) qDebug() << PDEBUG;
// create directory at $HOME and create dirs list
QString localDir;
QStringList dirs;
localDir = KStandardDirs::locateLocal("data", "awesomewidgets/scripts");
if (KStandardDirs::makeDir(localDir))
if (debug) qDebug() << PDEBUG << ":" << "Created directory" << localDir;
dirs = KGlobal::dirs()->findDirs("data", "awesomewidgets/scripts");
QStringList names;
for (int i=0; i<dirs.count(); i++) {
QStringList files = QDir(dirs[i]).entryList(QDir::Files, QDir::Name);
for (int j=0; j<files.count(); j++) {
if (!files[j].endsWith(QString(".desktop"))) continue;
if (names.contains(files[j])) continue;
if (debug) qDebug() << PDEBUG << ":" << "Found file" << files[j] << "in" << dirs[i];
names.append(files[j]);
externalScripts.append(new ExtScript(0, files[j], dirs, debug));
}
}
}
void ExtendedSysMon::initUpgrade()
{
if (debug) qDebug() << PDEBUG;
// create directory at $HOME and create dirs list
QString localDir;
QStringList dirs;
localDir = KStandardDirs::locateLocal("data", "awesomewidgets/upgrade");
if (KStandardDirs::makeDir(localDir))
if (debug) qDebug() << PDEBUG << ":" << "Created directory" << localDir;
dirs = KGlobal::dirs()->findDirs("data", "awesomewidgets/upgrade");
QStringList names;
for (int i=0; i<dirs.count(); i++) {
QStringList files = QDir(dirs[i]).entryList(QDir::Files, QDir::Name);
for (int j=0; j<files.count(); j++) {
if (!files[j].endsWith(QString(".desktop"))) continue;
if (names.contains(files[j])) continue;
if (debug) qDebug() << PDEBUG << ":" << "Found file" << files[j] << "in" << dirs[i];
names.append(files[j]);
externalUpgrade.append(new ExtUpgrade(0, files[j], dirs, debug));
}
}
}
QStringList ExtendedSysMon::sources() const
{
if (debug) qDebug() << PDEBUG;
QStringList source;
source.append(QString("battery"));
source.append(QString("custom"));
source.append(QString("desktop"));
source.append(QString("netdev"));
source.append(QString("gpu"));
source.append(QString("gputemp"));
source.append(QString("hddtemp"));
source.append(QString("pkg"));
source.append(QString("player"));
source.append(QString("ps"));
source.append(QString("update"));
if (debug) qDebug() << PDEBUG << ":" << "Sources" << source;
return source;
}
void ExtendedSysMon::readConfiguration()
{
if (debug) qDebug() << PDEBUG;
QString fileName;
fileName = KGlobal::dirs()->findResource("config", "plasma-dataengine-extsysmon.conf");
if (debug) qDebug() << PDEBUG << ":" << "Configuration file" << fileName;
QSettings settings(fileName, QSettings::IniFormat);
QMap<QString, QString> rawConfig;
settings.beginGroup(QString("Configuration"));
rawConfig[QString("ACPIPATH")] = settings.value(QString("ACPIPATH"), QString("/sys/class/power_supply/")).toString();
rawConfig[QString("GPUDEV")] = settings.value(QString("GPUDEV"), QString("auto")).toString();
rawConfig[QString("HDDDEV")] = settings.value(QString("HDDDEV"), QString("all")).toString();
rawConfig[QString("HDDTEMPCMD")] = settings.value(QString("HDDTEMPCMD"), QString("sudo hddtemp")).toString();
rawConfig[QString("MPDADDRESS")] = settings.value(QString("MPDADDRESS"), QString("localhost")).toString();
rawConfig[QString("MPDPORT")] = settings.value(QString("MPDPORT"), QString("6600")).toString();
rawConfig[QString("MPRIS")] = settings.value(QString("MPRIS"), QString("auto")).toString();
rawConfig[QString("PLAYER")] = settings.value(QString("PLAYER"), QString("mpris")).toString();
settings.endGroup();
configuration = updateConfiguration(rawConfig);
}
QMap<QString, QString> ExtendedSysMon::updateConfiguration(QMap<QString, QString> rawConfig)
{
if (debug) qDebug() << PDEBUG;
// gpudev
if (rawConfig[QString("GPUDEV")] == QString("disable"))
rawConfig[QString("GPUDEV")] = QString("disable");
else if (rawConfig[QString("GPUDEV")] == QString("auto"))
rawConfig[QString("GPUDEV")] = getAutoGpu();
else if ((rawConfig[QString("GPUDEV")] != QString("ati")) &&
(rawConfig[QString("GPUDEV")] != QString("nvidia")))
rawConfig[QString("GPUDEV")] = getAutoGpu();
// hdddev
allHddDevices = getAllHdd().split(QChar(','), QString::SkipEmptyParts);
if (rawConfig[QString("HDDDEV")] == QString("all"))
rawConfig[QString("HDDDEV")] = allHddDevices.join(QChar(','));
else if (rawConfig[QString("HDDDEV")] == QString("disable"))
rawConfig[QString("HDDDEV")] = QString("");
else {
QStringList deviceList = rawConfig[QString("HDDDEV")].split(QChar(','), QString::SkipEmptyParts);
QStringList devices;
QRegExp diskRegexp = QRegExp("^/dev/[hms]d[a-z]$");
for (int i=0; i<deviceList.count(); i++)
if ((QFile::exists(deviceList[i])) &&
(diskRegexp.indexIn(deviceList[i]) > -1))
devices.append(deviceList[i]);
if (devices.isEmpty())
rawConfig[QString("HDDDEV")] = allHddDevices.join(QChar(','));
else
rawConfig[QString("HDDDEV")] = devices.join(QChar(','));
}
// player
if ((rawConfig[QString("PLAYER")] != QString("mpd")) &&
(rawConfig[QString("PLAYER")] != QString("mpris")))
rawConfig[QString("PLAYER")] = QString("mpris");
for (int i=0; i<rawConfig.keys().count(); i++)
if (debug) qDebug() << PDEBUG << ":" <<
rawConfig.keys()[i] + QString("=") + rawConfig[rawConfig.keys()[i]];
return rawConfig;
}
QMap<QString, QVariant> ExtendedSysMon::getBattery(const QString acpiPath)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "ACPI path" << acpiPath;
QMap<QString, QVariant> battery;
battery[QString("ac")] = false;
battery[QString("bat")] = 0;
QFile acFile(acpiPath + QString("/AC/online"));
if (acFile.open(QIODevice::ReadOnly)) {
if (QString(acFile.readLine()).trimmed().toInt() == 1)
battery[QString("ac")] = true;
}
acFile.close();
// batterites
QStringList allDevices = QDir(acpiPath).entryList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name);
QStringList batDevices;
QRegExp batRegexp = QRegExp(QString("BAT.*"));
for (int i=0; i<allDevices.count(); i++)
if (allDevices[i].contains(batRegexp))
batDevices.append(allDevices[i]);
for (int i=0; i<batDevices.count(); i++) {
QFile batFile(acpiPath + QString("/") + batDevices[i] + QString("/capacity"));
if (batFile.open(QIODevice::ReadOnly))
battery[QString("bat") + QString::number(i)] = QString(batFile.readLine()).trimmed().toInt();
batFile.close();
}
float number = 0.0;
float average = 0.0;
for (int i=0; i<battery.keys().count(); i++) {
if (battery.keys()[i] == QString("ac")) continue;
if (battery.keys()[i] == QString("bat")) continue;
average += battery[battery.keys()[i]].toInt();
number++;
}
battery[QString("bat")] = int(average / number);
return battery;
}
QMap<QString, QVariant> ExtendedSysMon::getCurrentDesktop()
{
if (debug) qDebug() << PDEBUG;
int number = KWindowSystem::currentDesktop();
int total = KWindowSystem::numberOfDesktops();
QMap<QString, QVariant> currentDesktop;
currentDesktop[QString("currentName")] = KWindowSystem::desktopName(number);
currentDesktop[QString("currentNumber")] = number;
QStringList list;
for (int i=1; i<total+1; i++)
list.append(KWindowSystem::desktopName(i));
currentDesktop[QString("list")] = list.join(QString(";;"));
currentDesktop[QString("number")] = total;
return currentDesktop;
}
float ExtendedSysMon::getGpu(const QString device)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Device" << device;
float value = 0.0;
if ((device != QString("nvidia")) && (device != QString("ati")))
return value;
QString cmd = QString("");
if (device == QString("nvidia"))
cmd = QString("nvidia-smi -q -x");
else if (device == QString("ati"))
cmd = QString("aticonfig --od-getclocks");
if (debug) qDebug() << PDEBUG << ":" << "cmd" << cmd;
TaskResult process = runTask(QString("bash -c \"") + cmd + QString("\""));
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
if (process.exitCode != 0)
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
QString qoutput = QTextCodec::codecForMib(106)->toUnicode(process.output).trimmed();
if (configuration[QString("GPUDEV")] == QString("nvidia"))
for (int i=0; i<qoutput.split(QChar('\n'), QString::SkipEmptyParts).count(); i++) {
if (qoutput.split(QChar('\n'), QString::SkipEmptyParts)[i].contains(QString("<gpu_util>"))) {
QString load = qoutput.split(QChar('\n'), QString::SkipEmptyParts)[i]
.remove(QString("<gpu_util>"))
.remove(QString("</gpu_util>"))
.remove(QChar('%'));
value = load.toFloat();
}
}
else if (configuration[QString("GPUDEV")] == QString("ati"))
for (int i=0; i<qoutput.split(QChar('\n'), QString::SkipEmptyParts).count(); i++) {
if (qoutput.split(QChar('\n'), QString::SkipEmptyParts)[i].contains(QString("load"))) {
QString load = qoutput.split(QChar('\n'), QString::SkipEmptyParts)[i]
.split(QChar(' '), QString::SkipEmptyParts)[3]
.remove(QChar('%'));
value = load.toFloat();
}
}
return value;
}
float ExtendedSysMon::getGpuTemp(const QString device)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Device" << device;
float value = 0.0;
if ((device != QString("nvidia")) && (device != QString("ati")))
return value;
QString cmd = QString("");
if (device == QString("nvidia"))
cmd = QString("nvidia-smi -q -x");
else if (device == QString("ati"))
cmd = QString("aticonfig --od-gettemperature");
if (debug) qDebug() << PDEBUG << ":" << "cmd" << cmd;
TaskResult process = runTask(QString("bash -c \"") + cmd + QString("\""));
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
if (process.exitCode != 0)
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
QString qoutput = QTextCodec::codecForMib(106)->toUnicode(process.output);
if (configuration[QString("GPUDEV")] == QString("nvidia"))
for (int i=0; i<qoutput.split(QChar('\n'), QString::SkipEmptyParts).count(); i++) {
if (qoutput.split(QChar('\n'), QString::SkipEmptyParts)[i].contains(QString("<gpu_temp>"))) {
QString temp = qoutput.split(QChar('\n'), QString::SkipEmptyParts)[i]
.remove(QString("<gpu_temp>"))
.remove(QString("C</gpu_temp>"));
value = temp.toFloat();
}
}
else if (configuration[QString("GPUDEV")] == QString("ati"))
for (int i=0; i<qoutput.split(QChar('\n'), QString::SkipEmptyParts).count(); i++) {
if (qoutput.split(QChar('\n'), QString::SkipEmptyParts)[i].contains(QString("Temperature"))) {
QString temp = qoutput.split(QChar('\n'), QString::SkipEmptyParts)[i]
.split(QChar(' '), QString::SkipEmptyParts)[4];
value = temp.toFloat();
}
}
return value;
}
float ExtendedSysMon::getHddTemp(const QString cmd, const QString device)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "cmd" << cmd;
if (debug) qDebug() << PDEBUG << ":" << "Device" << device;
float value = 0.0;
TaskResult process = runTask(cmd + QString(" ") + device);
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
if (process.exitCode != 0)
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
bool smartctl = cmd.contains(QString("smartctl"));
if (debug) qDebug() << PDEBUG << ":" << "Define smartctl" << smartctl;
QString qoutput = QTextCodec::codecForMib(106)->toUnicode(process.output).trimmed();
if (smartctl) {
for (int i=0; i<qoutput.split(QChar(':'), QString::SkipEmptyParts).count(); i++) {
if (qoutput.split(QChar(':'), QString::SkipEmptyParts)[i].split(QChar(' '))[0] != QString("194")) continue;
if (qoutput.split(QChar(':'), QString::SkipEmptyParts)[i].split(QChar(' '), QString::SkipEmptyParts).count() < 9) break;
value = qoutput.split(QChar(':'), QString::SkipEmptyParts)[i].split(QChar(' '), QString::SkipEmptyParts)[9].toFloat();
break;
}
} else {
if (qoutput.split(QChar(':'), QString::SkipEmptyParts).count() >= 3) {
QString temp = qoutput.split(QChar(':'), QString::SkipEmptyParts)[2];
temp.remove(QChar(0260)).remove(QChar('C'));
value = temp.toFloat();
}
}
return value;
}
QString ExtendedSysMon::getNetworkDevice()
{
if (debug) qDebug() << PDEBUG;
QString device = QString("lo");
QList<QNetworkInterface> rawInterfaceList = QNetworkInterface::allInterfaces();
for (int i=0; i<rawInterfaceList.count(); i++)
if ((rawInterfaceList[i].flags().testFlag(QNetworkInterface::IsUp)) &&
(!rawInterfaceList[i].flags().testFlag(QNetworkInterface::IsLoopBack)) &&
(!rawInterfaceList[i].flags().testFlag(QNetworkInterface::IsPointToPoint))) {
device = rawInterfaceList[i].name();
break;
}
return device;
}
QMap<QString, QVariant> ExtendedSysMon::getPlayerInfo(const QString playerName,
const QString mpdAddress,
const QString mpdPort,
QString mpris)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "player" << playerName;
if (debug) qDebug() << PDEBUG << ":" << "MPD" << mpdAddress + QString(":") + mpdPort;
if (debug) qDebug() << PDEBUG << ":" << "MPRIS" << mpris;
QMap<QString, QVariant> info;
info[QString("album")] = QString("unknown");
info[QString("artist")] = QString("unknown");
info[QString("duration")] = QString("0");
info[QString("progress")] = QString("0");
info[QString("title")] = QString("unknown");
if (playerName == QString("mpd"))
// mpd
return getPlayerMpdInfo(mpdAddress, mpdPort);
else if (playerName == QString("mpris")) {
// players which supports mpris
if (mpris == QString("auto")) mpris = getAutoMpris();
if (mpris.isEmpty()) return info;
return getPlayerMprisInfo(mpris);
}
return info;
}
QMap<QString, QVariant> ExtendedSysMon::getPlayerMpdInfo(const QString mpdAddress,
const QString mpdPort)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "MPD" << mpdAddress + QString(":") + mpdPort;
QMap<QString, QVariant> info;
info[QString("album")] = QString("unknown");
info[QString("artist")] = QString("unknown");
info[QString("duration")] = QString("0");
info[QString("progress")] = QString("0");
info[QString("title")] = QString("unknown");
QString cmd = QString("bash -c \"echo 'currentsong\nstatus\nclose' | curl --connect-timeout 1 -fsm 3 telnet://%1:%2\"")
.arg(mpdAddress)
.arg(mpdPort);
if (debug) qDebug() << PDEBUG << ":" << "cmd" << cmd;
TaskResult process = runTask(cmd);
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
if (process.exitCode != 0)
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
QString qoutput = QTextCodec::codecForMib(106)->toUnicode(process.output).trimmed();
QString qstr = QString("");
for (int i=0; i<qoutput.split(QChar('\n'), QString::SkipEmptyParts).count(); i++) {
qstr = qoutput.split(QChar('\n'), QString::SkipEmptyParts)[i];
if (qstr.split(QString(": "), QString::SkipEmptyParts).count() > 1) {
if (qstr.split(QString(": "), QString::SkipEmptyParts)[0] == QString("Album"))
info[QString("album")] = qstr.split(QString(": "), QString::SkipEmptyParts)[1].trimmed();
else if (qstr.split(QString(": "), QString::SkipEmptyParts)[0] == QString("Artist"))
info[QString("artist")] = qstr.split(QString(": "), QString::SkipEmptyParts)[1].trimmed();
else if (qstr.split(QString(": "), QString::SkipEmptyParts)[0] == QString("time")) {
info[QString("duration")] = qstr.split(QString(": "), QString::SkipEmptyParts)[1].trimmed().split(QString(":"))[0];
info[QString("progress")] = qstr.split(QString(": "), QString::SkipEmptyParts)[1].trimmed().split(QString(":"))[1];
} else if (qstr.split(QString(": "), QString::SkipEmptyParts)[0] == QString("Title"))
info[QString("title")] = qstr.split(QString(": "), QString::SkipEmptyParts)[1].trimmed();
}
}
return info;
}
QMap<QString, QVariant> ExtendedSysMon::getPlayerMprisInfo(const QString mpris)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << "MPRIS" << mpris;
QMap<QString, QVariant> info;
info[QString("album")] = QString("unknown");
info[QString("artist")] = QString("unknown");
info[QString("duration")] = 0;
info[QString("progress")] = 0;
info[QString("title")] = QString("unknown");
// init
QDBusArgument arg;
QDBusConnection bus = QDBusConnection::sessionBus();
QDBusMessage response, request;
QVariantMap map;
// general information
request = QDBusMessage::createMethodCall(QString("org.mpris.MediaPlayer2.%1").arg(mpris),
QString("/Player"),
QString(""),
QString("GetMetadata"));
response = bus.call(request, QDBus::BlockWithGui);
if (response.arguments().size() == 0) {
if (debug) qDebug() << PDEBUG << ":" << "Error message" << response.errorMessage();
} else {
arg = response.arguments()[0].value<QDBusArgument>();
arg >> map;
info[QString("album")] = map[QString("album")];
info[QString("artist")] = map[QString("artist")];
info[QString("duration")] = map[QString("time")];
info[QString("title")] = map[QString("title")];
}
// position
request = QDBusMessage::createMethodCall(QString("org.mpris.MediaPlayer2.%1").arg(mpris),
QString("/Player"),
QString(""),
QString("PositionGet"));
response = bus.call(request, QDBus::BlockWithGui);
if (response.arguments().size() == 0) {
if (debug) qDebug() << PDEBUG << ":" << "Error message" << response.errorMessage();
} else
info[QString("progress")] = response.arguments()[0].toInt() / 1000;
return info;
}
QMap<QString, QVariant> ExtendedSysMon::getPsStats()
{
if (debug) qDebug() << PDEBUG;
QStringList allDirectories = QDir(QString("/proc")).entryList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name);
QStringList directories = allDirectories.filter(QRegExp(QString("(\\d+)")));
QStringList running;
for (int i=0; i<directories.count(); i++) {
QFile statusFile(QString("/proc/%1/status").arg(directories[i]));
if (!statusFile.open(QIODevice::ReadOnly)) continue;
QFile cmdFile(QString("/proc/%1/cmdline").arg(directories[i]));
if (!cmdFile.open(QIODevice::ReadOnly)) continue;
QString output = statusFile.readAll();
if (output.contains(QString("running"))) running.append(cmdFile.readAll());
}
QMap<QString, QVariant> psStats;
psStats[QString("pscount")] = running.count();
psStats[QString("ps")] = running.join(QString(","));
psStats[QString("pstotal")] = directories.count();
return psStats;
}
bool ExtendedSysMon::sourceRequestEvent(const QString &source)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Source" << source;
return updateSourceEvent(source);
}
bool ExtendedSysMon::updateSourceEvent(const QString &source)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Source" << source;
if (source == QString("battery")) {
QMap<QString, QVariant> battery = getBattery(configuration[QString("ACPIPATH")]);
setData(source, QString("ac"), battery[QString("ac")].toBool());
for (int i=0; i<battery.keys().count(); i++) {
if (battery.keys()[i] == QString("ac")) continue;
setData(source, battery.keys()[i], battery[battery.keys()[i]].toInt());
}
} else if (source == QString("custom")) {
for (int i=0; i<externalScripts.count(); i++)
setData(source, QString("custom") + QString::number(i), externalScripts[i]->run());
} else if (source == QString("desktop")) {
QMap<QString, QVariant> desktop = getCurrentDesktop();
for (int i=0; i<desktop.keys().count(); i++)
setData(source, desktop.keys()[i], desktop[desktop.keys()[i]]);
} else if (source == QString("gpu")) {
setData(source, QString("value"), getGpu(configuration[QString("GPUDEV")]));
} else if (source == QString("gputemp")) {
setData(source, QString("value"), getGpuTemp(configuration[QString("GPUDEV")]));
} else if (source == QString("hddtemp")) {
// fill empty list
for (int i=0; i<allHddDevices.count(); i++)
setData(source, allHddDevices[i], 0.0);
QStringList deviceList = configuration[QString("HDDDEV")].split(QChar(','), QString::SkipEmptyParts);
for (int i=0; i<deviceList.count(); i++)
setData(source, deviceList[i],
getHddTemp(configuration[QString("HDDTEMPCMD")], deviceList[i]));
} else if (source == QString("netdev")) {
setData(source, QString("value"), getNetworkDevice());
} else if (source == QString("pkg")) {
for (int i=0; i<externalUpgrade.count(); i++)
setData(source, QString("pkgcount") + QString::number(i), externalUpgrade[i]->run());
} else if (source == QString("player")) {
QMap<QString, QVariant> player = getPlayerInfo(configuration[QString("PLAYER")],
configuration[QString("MPDADDRESS")],
configuration[QString("MPDPORT")],
configuration[QString("MPRIS")]);
for (int i=0; i<player.keys().count(); i++)
setData(source, player.keys()[i], player[player.keys()[i]]);
} else if (source == QString("ps")) {
QMap<QString, QVariant> ps = getPsStats();
for (int i=0; i<ps.keys().count(); i++)
setData(source, ps.keys()[i], ps[ps.keys()[i]]);
} else if (source == QString("update")) {
setData(source, QString("value"), true);
}
return true;
}
K_EXPORT_PLASMA_DATAENGINE(extsysmon, ExtendedSysMon)
#include "extsysmon.moc"

View File

@ -0,0 +1,73 @@
/***************************************************************************
* This file is part of awesome-widgets *
* *
* awesome-widgets is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* awesome-widgets is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#ifndef EXTSYSMON_H
#define EXTSYSMON_H
#include <Plasma/DataEngine>
#include <QProcess>
class ExtScript;
class ExtUpgrade;
class ExtendedSysMon : public Plasma::DataEngine
{
Q_OBJECT
public:
ExtendedSysMon(QObject *parent, const QVariantList &args);
// update functions
QMap<QString, QVariant> getBattery(const QString acpiPath);
QMap<QString, QVariant> getCurrentDesktop();
float getGpu(const QString device);
float getGpuTemp(const QString device);
float getHddTemp(const QString cmd, const QString device);
QString getNetworkDevice();
QMap<QString, QVariant> getPlayerInfo(const QString playerName,
const QString mpdAddress = 0,
const QString mpdPort = 0,
const QString mpris = 0);
QMap<QString, QVariant> getPlayerMpdInfo(const QString mpdAddress = 0,
const QString mpdPort = 0);
QMap<QString, QVariant> getPlayerMprisInfo(const QString mpris = 0);
QMap<QString, QVariant> getPsStats();
protected:
bool sourceRequestEvent(const QString &source);
bool updateSourceEvent(const QString &source);
QStringList sources() const;
private:
// configuration
QMap<QString, QString> configuration;
QList<ExtScript *> externalScripts;
QList<ExtUpgrade *> externalUpgrade;
bool debug;
// reread configuration
QStringList allHddDevices;
QString getAllHdd();
QString getAutoGpu();
QString getAutoMpris();
void initScripts();
void initUpgrade();
void readConfiguration();
QMap<QString, QString> updateConfiguration(QMap<QString, QString> rawConfig);
};
#endif /* EXTSYSMON_H */

View File

@ -0,0 +1,288 @@
/***************************************************************************
* This file is part of awesome-widgets *
* *
* awesome-widgets is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* awesome-widgets is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#include "extupgrade.h"
#include "ui_extupgrade.h"
#include <QDebug>
#include <QDir>
#include <QSettings>
#include <QTextCodec>
#include <pdebug/pdebug.h>
#include <task/taskadds.h>
#include "version.h"
ExtUpgrade::ExtUpgrade(QWidget *parent, const QString upgradeName, const QStringList directories, const bool debugCmd) :
QDialog(parent),
m_fileName(upgradeName),
m_dirs(directories),
debug(debugCmd),
ui(new Ui::ExtUpgrade)
{
m_name = m_fileName;
readConfiguration();
ui->setupUi(this);
}
ExtUpgrade::~ExtUpgrade()
{
if (debug) qDebug() << PDEBUG;
delete ui;
}
int ExtUpgrade::apiVersion()
{
if (debug) qDebug() << PDEBUG;
return m_apiVersion;
}
QString ExtUpgrade::comment()
{
if (debug) qDebug() << PDEBUG;
return m_comment;
}
QString ExtUpgrade::executable()
{
if (debug) qDebug() << PDEBUG;
return m_executable;
}
QString ExtUpgrade::fileName()
{
if (debug) qDebug() << PDEBUG;
return m_fileName;
}
int ExtUpgrade::interval()
{
if (debug) qDebug() << PDEBUG;
return m_interval;
}
QString ExtUpgrade::name()
{
if (debug) qDebug() << PDEBUG;
return m_name;
}
int ExtUpgrade::null()
{
if (debug) qDebug() << PDEBUG;
return m_null;
}
bool ExtUpgrade::isActive()
{
if (debug) qDebug() << PDEBUG;
return m_active;
}
void ExtUpgrade::setApiVersion(const int _apiVersion)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Version" << _apiVersion;
m_apiVersion = _apiVersion;
}
void ExtUpgrade::setActive(const bool state)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "State" << state;
m_active = state;
}
void ExtUpgrade::setComment(const QString _comment)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Comment" << _comment;
m_comment = _comment;
}
void ExtUpgrade::setExecutable(const QString _executable)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Executable" << _executable;
m_executable = _executable;
}
void ExtUpgrade::setInterval(const int _interval)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Interval" << _interval;
m_interval = _interval;
}
void ExtUpgrade::setName(const QString _name)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Name" << _name;
m_name = _name;
}
void ExtUpgrade::setNull(const int _null)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Null lines" << _null;
if (_null < 0) return;
m_null = _null;
}
void ExtUpgrade::readConfiguration()
{
if (debug) qDebug() << PDEBUG;
for (int i=m_dirs.count()-1; i>=0; i--) {
if (!QDir(m_dirs[i]).entryList(QDir::Files).contains(m_fileName)) continue;
QSettings settings(m_dirs[i] + QDir::separator() + m_fileName, QSettings::IniFormat);
settings.beginGroup(QString("Desktop Entry"));
setName(settings.value(QString("Name"), m_name).toString());
setComment(settings.value(QString("Comment"), m_comment).toString());
setApiVersion(settings.value(QString("X-AW-ApiVersion"), AWESAPI).toInt());
setExecutable(settings.value(QString("Exec"), m_executable).toString());
setActive(settings.value(QString("X-AW-Active"), QVariant(m_active)).toString() == QString("true"));
setNull(settings.value(QString("X-AW-Null"), m_null).toInt());
setInterval(settings.value(QString("X-AW-Interval"), m_interval).toInt());
settings.endGroup();
}
}
int ExtUpgrade::run()
{
if (debug) qDebug() << PDEBUG;
if (!m_active) return value;
if (times == 1) {
TaskResult process = runTask(QString("bash -c \"") + m_executable + QString("\""));
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
if (process.exitCode != 0)
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
QString qoutput = QTextCodec::codecForMib(106)->toUnicode(process.output).trimmed();
value = qoutput.split(QChar('\n'), QString::SkipEmptyParts).count() - m_null;
}
// update value
if (times >= m_interval) times = 0;
times++;
return value;
}
int ExtUpgrade::showConfiguration()
{
if (debug) qDebug() << PDEBUG;
ui->lineEdit_name->setText(m_name);
ui->lineEdit_comment->setText(m_comment);
ui->lineEdit_command->setText(m_executable);
if (m_active)
ui->checkBox_active->setCheckState(Qt::Checked);
else
ui->checkBox_active->setCheckState(Qt::Unchecked);
ui->spinBox_null->setValue(m_null);
ui->spinBox_interval->setValue(m_interval);
int ret = exec();
if (ret != 1) return ret;
setName(ui->lineEdit_name->text());
setComment(ui->lineEdit_comment->text());
setApiVersion(AWEUAPI);
setExecutable(ui->lineEdit_command->text());
setActive(ui->checkBox_active->checkState() == Qt::Checked);
setNull(ui->spinBox_null->value());
setInterval(ui->spinBox_interval->value());
writeConfiguration();
return ret;
}
int ExtUpgrade::tryDelete()
{
if (debug) qDebug() << PDEBUG;
for (int i=0; i<m_dirs.count(); i++)
if (debug) qDebug() << PDEBUG << ":" << "Remove file" << m_dirs[i] + QDir::separator() + m_fileName <<
QFile::remove(m_dirs[i] + QDir::separator() + m_fileName);
// check if exists
for (int i=0; i<m_dirs.count(); i++)
if (QFile::exists(m_dirs[i] + QDir::separator() + m_fileName)) return 0;
return 1;
}
void ExtUpgrade::writeConfiguration()
{
if (debug) qDebug() << PDEBUG;
QSettings settings(m_dirs[0] + QDir::separator() + m_fileName, QSettings::IniFormat);
if (debug) qDebug() << PDEBUG << ":" << "Configuration file" << settings.fileName();
settings.beginGroup(QString("Desktop Entry"));
settings.setValue(QString("Encoding"), QString("UTF-8"));
settings.setValue(QString("Name"), m_name);
settings.setValue(QString("Comment"), m_comment);
settings.setValue(QString("Exec"), m_executable);
settings.setValue(QString("X-AW-ApiVersion"), m_apiVersion);
settings.setValue(QString("X-AW-Active"), QVariant(m_active).toString());
settings.setValue(QString("X-AW-Null"), m_null);
settings.setValue(QString("X-AW-Interval"), m_interval);
settings.endGroup();
settings.sync();
}

View File

@ -0,0 +1,86 @@
/***************************************************************************
* This file is part of awesome-widgets *
* *
* awesome-widgets is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* awesome-widgets is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#ifndef EXTUPGRADE_H
#define EXTUPGRADE_H
#include <QDialog>
namespace Ui {
class ExtUpgrade;
}
class ExtUpgrade : public QDialog
{
Q_OBJECT
Q_PROPERTY(int apiVersion READ apiVersion WRITE setApiVersion)
Q_PROPERTY(QString name READ name WRITE setName)
Q_PROPERTY(QString comment READ comment WRITE setComment)
Q_PROPERTY(QString executable READ executable WRITE setExecutable)
Q_PROPERTY(int null READ null WRITE setNull)
Q_PROPERTY(bool active READ isActive WRITE setActive)
Q_PROPERTY(int interval READ interval WRITE setInterval)
public:
explicit ExtUpgrade(QWidget *parent = 0, const QString upgradeName = QString(),
const QStringList directories = QStringList(), const bool debugCmd = false);
~ExtUpgrade();
// get methods
int apiVersion();
QString comment();
QString executable();
QString fileName();
int interval();
QString name();
int null();
bool isActive();
// set methods
void setApiVersion(const int _apiVersion = 0);
void setActive(const bool _state = true);
void setComment(const QString _comment = QString("empty"));
void setExecutable(const QString _executable = QString("/usr/bin/true"));
void setName(const QString _name = QString("none"));
void setNull(const int _null = 0);
void setInterval(const int _interval = 0);
public slots:
void readConfiguration();
int run();
int showConfiguration();
int tryDelete();
void writeConfiguration();
private:
QString m_fileName;
QStringList m_dirs;
bool debug;
Ui::ExtUpgrade *ui;
// properties
int m_apiVersion = 0;
bool m_active = true;
QString m_comment = QString("empty");
QString m_executable = QString("/usr/bin/true");
QString m_name = QString("none");
int m_null = 0;
int m_interval = 3600;
int times = 0;
int value = 0;
};
#endif /* EXTUPGRADE_H */

View File

@ -0,0 +1,230 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ExtUpgrade</class>
<widget class="QDialog" name="ExtUpgrade">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>420</width>
<height>301</height>
</rect>
</property>
<property name="windowTitle">
<string>Configuration</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="layout_name">
<item>
<widget class="QLabel" name="label_name">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Name</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_name"/>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_comment">
<item>
<widget class="QLabel" name="label_comment">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Comment</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_comment"/>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_command">
<item>
<widget class="QLabel" name="label_command">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Command</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_command"/>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_active">
<item>
<spacer name="spacer_active">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QCheckBox" name="checkBox_active">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Active</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_null">
<item>
<widget class="QLabel" name="label_null">
<property name="text">
<string>Null</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinBox_null">
<property name="minimum">
<number>0</number>
</property>
<property name="value">
<number>0</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_interval">
<item>
<widget class="QLabel" name="label_interval">
<property name="text">
<string>Interval</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinBox_interval">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>10000</number>
</property>
<property name="singleStep">
<number>500</number>
</property>
<property name="value">
<number>3600</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>ExtUpgrade</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>ExtUpgrade</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

Some files were not shown because too many files have changed in this diff Show More