Compare commits

...

152 Commits

Author SHA1 Message Date
ae4e7deddd create pkgbuild for the last stable archive in 2.4.0 branch 2015-09-09 06:57:49 +03:00
be26033ff7 edit log format line 2015-09-04 00:18:46 +03:00
70020d0aef Merge branch 'master' of github.com:arcan1s/awesome-widgets 2015-09-03 00:31:07 +03:00
7218defe19 add '$this' feature to lambda functions
fix large size on startup
fix invalid key parsing
2015-09-03 00:30:10 +03:00
200ecc7196 translation update 2015-09-02 00:19:28 +03:00
6689bea9a7 implement dynamic tags 2015-09-02 00:05:11 +03:00
5940ec4531 update awdebug 2015-09-01 01:45:25 +03:00
2716f77eb2 revert 2015-09-01 01:40:48 +03:00
cfdcaae036 drop script from deps 2015-09-01 01:40:15 +03:00
82c1839634 drop hidding method 2015-09-01 01:12:10 +03:00
08dae3b02b small patch to avoid notifications on nan 2015-08-31 01:43:39 +03:00
cc2b1b7b8a add images feature to extweather (apiver == 2) 2015-08-31 00:16:04 +03:00
4c27382467 more correct logging, use qt logging for qml as well 2015-08-30 16:24:00 +03:00
aacb50c946 start moving to qt5 style logging 2015-08-29 00:58:39 +03:00
466faf53fa some refactoring, prepare to moving to qt5 style logging 2015-08-28 00:15:25 +03:00
8228d1d06b Add filter feature to ExtUpgrade (ApiVer = 3) 2015-08-26 00:24:55 +03:00
37726370ee Add additional column to configuraion ui to better tag selection 2015-08-25 00:07:23 +03:00
07305d7578 no kf5 on ubuntu 12.04 2015-08-23 02:26:12 +03:00
b97c821c8f try to upgrade ubuntu first 2015-08-23 02:16:22 +03:00
b50c1d2363 add ability to do not translate strings 2015-08-23 02:14:55 +03:00
713aa611d9 drop travis since it uses ubuntu-12.04 2015-08-22 23:11:09 +03:00
319755179f #2 2015-08-22 22:30:52 +03:00
9509d87962 try to get it working 2015-08-22 22:27:27 +03:00
6d58a3f05c add repo 2015-08-22 14:59:44 +03:00
2cca290630 try add travis-ci 2015-08-22 14:55:50 +03:00
29b75e2b12 update additional files
update translations
add "Add lambda" button to ui
2015-08-22 00:40:14 +03:00
835eb00f0d add lambda support 2015-08-21 00:05:15 +03:00
a5e9b32b28 implement support of network speed units tags
fix warning for empty tooltip image
2015-08-18 01:17:51 +03:00
fbdc9112aa update archive generator 2015-08-16 15:48:43 +03:00
b3fc0501ba unify build, allow cross build 2015-08-16 03:24:44 +03:00
a74c65a2a3 fix typo 2015-08-16 02:41:26 +03:00
4858c9dbcd add rpm recipe 2015-08-16 02:38:24 +03:00
3601b4246d add build requirements for deb packages 2015-08-16 01:54:49 +03:00
241e13ffd8 add experimental debian build 2015-08-16 01:22:28 +03:00
7a5d2d5dd4 add forgoten line to CHANGELOG
drop default active script
2015-08-11 00:05:23 +03:00
24b143f43a release 2.4.0 2015-08-10 00:09:31 +03:00
df473c53b5 move plugins to iterators 2015-08-08 00:22:25 +03:00
3122c2fa8c rewrite to iterators library part 2015-08-07 07:21:55 +03:00
08cb7d9abe fix #60
some hash improvements
2015-08-06 01:23:43 +03:00
e38863ebc2 add disable key to player monitor 2015-08-05 01:14:09 +03:00
1cddf6f14d some map replacing 2015-08-04 00:15:19 +03:00
7405b2ba1d work with extendedsysmon
* fix mpris info getting
* replace qmap to qhash if possible
* some at()/[] repalcements
* add time logging
2015-08-03 00:01:14 +03:00
6fbe897b27 fix CMake policy setup 2015-08-02 14:24:49 +03:00
5f7c35a37c edit translations build
translation update
2015-08-02 00:40:23 +03:00
6173b60806 edit cmake files
edit font dialog
2015-08-01 00:10:18 +03:00
4c9e39ec9b translation update 2015-07-31 00:48:01 +03:00
429393998c update translations cmakelists as well 2015-07-30 00:01:13 +03:00
c9acb0bdcd edit build, create a separate cmake include file 2015-07-29 23:59:42 +03:00
16305a91c4 rewrite tooltip class 2015-07-29 00:03:12 +03:00
bbb9aa0747 fix library translations 2015-07-28 00:22:34 +03:00
983b808247 move aw plugin to template-based system
bump graphicalitems to ApiVer 2 (add number property)
2015-07-27 00:05:15 +03:00
c61a5ac092 create a static library for backend items
move backend items to template-based mechanism
2015-07-26 12:58:59 +03:00
3b6df44489 more correct methods naming, prepare to move to templates 2015-07-25 00:03:45 +03:00
4742617e3e * fix building
* add clang build
* more correct method types
2015-07-24 00:18:21 +03:00
880a986782 add abstactextitem class (building is broken atm) 2015-07-23 00:07:21 +03:00
b699095f38 initial support of weather 2015-07-22 00:44:39 +03:00
a065e96bc3 * move isDebugEnabled method to AWActions
* add "Drop key cache" button
2015-07-21 00:24:50 +03:00
1110929b14 improve update events 2015-07-20 00:21:39 +03:00
c7d998eb12 more correct fix for #57 2015-07-19 00:14:49 +03:00
eb63ef5e96 Merge branch 'key-filtering-feature' 2015-07-18 00:51:21 +03:00
327d5a7ff9 more correct fix for #57 2015-07-17 09:44:44 +03:00
2b9505207c Merge branch 'memory-load-fix' 2015-07-16 00:34:18 +03:00
cd36c4ed68 drop key definition on startup since it blocks several plasmoid
instances (refer to #57)
2015-07-15 19:50:12 +03:00
903a1a454d move plugin back to private 2015-07-15 19:49:54 +03:00
cf5d713d2e Revert "drop key definition on startup since it blocks several plasmoid"
This reverts commit 4e78e0e1dd.
2015-07-15 19:34:19 +03:00
467a3bf508 fix network speed calculation for $down and $up tags 2015-07-14 00:18:29 +03:00
4e78e0e1dd drop key definition on startup since it blocks several plasmoid
instances (refer to #57)
2015-07-11 15:04:53 +03:00
d01fb91e36 bump to 2.3.2 2015-07-09 00:28:47 +03:00
61ed3a444f change text rendering 2015-07-08 12:20:01 +03:00
494590475a release 2.3.2 2015-07-04 02:35:09 +03:00
27ab7d9cd7 fix cast int as float 2015-07-03 00:05:47 +03:00
1869a68122 fix bug with no actions
set network speed units as MB/s if the value more than 1k KB/s
2015-07-03 00:04:03 +03:00
aa0a4b417d improve battery support 2015-07-01 01:14:04 +03:00
41deb8ef72 fix plasma crash with extquotes
rewrite main widget to use signal-slot model
2015-06-30 07:13:58 +03:00
aa15e13713 update fr translations 2015-06-14 17:19:38 +03:00
ad63f78929 update links to opensuse packages 2015-06-12 15:05:56 +03:00
224e558a98 release 2.3.1 2015-06-11 01:49:22 +03:00
a391df2804 - fix bug with invalid values updates from configuration UI
* merge fan tags to temp ones for better handling
2015-06-10 10:31:41 +03:00
755d0b39f8 Merge pull request #56 from underr/master
Update PT-BR translations
2015-06-06 13:18:40 +03:00
fcd612880f Update PT-BR translations 2015-06-05 21:54:24 -03:00
5aff2d2e4e update Spain translations 2015-06-05 00:19:02 +03:00
5a52c056a7 update Ukrainian translation 2015-06-04 01:54:26 +03:00
42615a6fdc update translation, fix #53 2015-06-02 01:21:03 +03:00
b431d2c6cf Release 2.3.0 2015-06-01 01:40:06 +03:00
f96b3fcb07 implement \r to default json of ExtScripts
some refactoring
bump ApiVer of ExtQuotes
update changelog
2015-05-31 02:57:43 +03:00
f534a6854a try to implement timeouts support to quotes (ref to #54) 2015-05-29 18:29:13 +03:00
b51c97abbb drop qxml, port quotes from xml to json (xml has been used for qt4
branch)
2015-05-28 09:16:27 +03:00
8dc3510a30 more pretty configuration interface
implement quotes changes
2015-05-25 02:28:09 +03:00
fce098cb5c improve work with filters for custom scripts
implement new line filters for widget text
fix bug with html parsing
implement key sorting in combo boxes
2015-05-24 00:03:54 +03:00
5f4bf9ec29 edit readme.md
implement initial support of filters (dep #53)
2015-05-23 02:07:16 +03:00
8c73b2560b Release 2.2.2
* update screenshots
+ add error logging to extquotes
- fix paragraph bug
- fix bug with DP settings
2015-05-22 00:18:14 +03:00
78931b3ae0 fix CMake 2015-05-20 00:39:07 +03:00
a53c5ec38c drop kde4 from master 2015-05-20 00:36:48 +03:00
3bac9ac09f * fix hddtemp definition (create workaround)
* create git pkgbuild
* fix plugin build
* replace hddtemp to smartctl by default
2015-05-19 09:41:15 +03:00
b82d78bcbe implement #51 for upgrade and scripts 2015-05-18 00:57:47 +03:00
396fa95ec3 some refactoring
update resizing
2015-05-17 14:09:08 +03:00
c6cadba4b6 some part of refactoring
move plugin from private
fix translation issue (#50)
2015-05-12 00:19:08 +03:00
daa362fc16 Merge branch 'master' of github.com:arcan1s/awesome-widgets 2015-05-11 01:29:57 +03:00
26c51007e0 some fixes in ui 2015-05-11 01:29:42 +03:00
7919e6d250 update DP paint 2015-05-08 16:49:13 +03:00
88c3e780cf implement tag number support to widget
bump api ver to 2
2015-05-07 00:17:35 +03:00
7f4dfe1060 * more correct sizes in the configuration interface
* remove additional debug information
* increase limits for extscripts intervals to 10000 (fix #48)
2015-05-06 00:31:37 +03:00
15d88ee3ba more correct widget resizing. Create width and height options (#47) 2015-05-05 02:18:39 +03:00
104bb52557 add work with key cache
fix bug with invalid dataengine settings in UI
2015-05-03 03:49:39 +03:00
9a6b883905 fixed bugs with dataengine settings saving 2015-05-02 01:40:20 +03:00
fd8f2127d9 initial support of quotes 2015-04-28 16:43:34 +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
187 changed files with 17266 additions and 12800 deletions

3
.gitmodules vendored
View File

@ -1,6 +1,3 @@
[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

11
.travis.yml.bckp Normal file
View File

@ -0,0 +1,11 @@
install:
- sudo apt-get update -qq
- sudo apt-get install -y cmake extra-cmake-modules g++ git libkf5i18n-dev libkf5notifications-dev libkf5service-dev libkf5windowsystem-dev plasma-framework-dev qtbase5-dev qtdeclarative5-dev
- git submobule update --init
- rm -rf build
- mkdir build
script:
- cd build
- cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release -DKDE_INSTALL_USE_QT_SYS_PATHS=ON ../sources
- make

101
CHANGELOG
View File

@ -1,3 +1,96 @@
+ add tags upunits, downunits
- fix warning for empty tooltip image
Ver.2.4.0:
+ add support of weather items
+ add support of load average (la1, la5, la15 tags)
+ add "drop key cache" button
+ add support of clang building
+ create ExtItems aggregator
+ add time to debug information
+ add ability to disable player monitor
- fix bug with invalid network data calculation
- fix warning with fond dialog init
- fix bug with no object deletions (#60)
* rewrite ExtItems to use own abstract class
* improve work with data updating (#57)
* move to signal-slot interface painting
* move plugin part back to private
* cast plugin as type, not signleton (#57)
* change logic in data building inside DataEngine
* edit build and drop different DataEngine packaging
* rewrite QMap to QHash if possible
* rewrite to use iterators if possible
* list of desktops is now represented as QStringList
* refactoring
Ver.2.3.3:
* change text rendering from Qt to native
Ver.2.3.2:
+ change network speed units from KB/s to MB/s if value is more than 1000 KB/s (metrics are the same)
- fix bug with no actions on link activation (thanks to infans)
* improve quotes support, e.g. fix plasma crash
* rewrite main widget to signal-slot update model
* improve battery calculation for system which has several batteries
Ver.2.3.1:
- fix bug with no updates from configuration UI
- fix invalid vertical tab parsing
* translation update
* merge fan tags to temp ones, improve lmsensors tags handling
Ver.2.3.0:
+ implement fitlers support to ExtScripts (ApiVer = 3) (#53)
+ implement ability to wrap `\n` as new lines (#53)
+ implement key sorting in comboboxes
+ implement (perc)(bid|ask|price)chg tag support (ApiVer = 2)
+ implement timeouts to quotes (#54)
- fix bug with invalid html parsing
* move from XML to JSON in ExtQuotes (ApiVer = 2)
* more pretty configuration UI
* some part of refactoring
Ver.2.2.2:
+ add quotes support (#46)
+ add support of properties height and width (#47)
+ add transtaltion support to the plugins (#50)
+ add support of key caching
+ add support of X-AW-Number to ExtScript and ExtUpgrade (ApiVer = 2)
+ add reconnection to DataEngine (in some cases some values are not updated)
+ add widgets width and height update
- fix bug with Ext* items update (#49)
- fix bug with GPUDEV, HDDDEV settings saving from UI
- fix Desktop Panel settings
- fix bug with adding paragraph settings
* drop support of KDE4 support, created a separated branch
* increase intervals limits (#48)
* hddtemp was replaced to smartctl by default
* plugins were moved from private
* more correct interface painting
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
@ -70,7 +163,7 @@ Ver.1.11.0:
+ add desktop label (tags $name, $number, $total)
+ add ability to interact with players using mpris
* rewrite to use submodules
* rewrite dataengine to use tasks
* rewrite DataEngine to use tasks
* fix nvidia temperature definition
Ver.1.10.2:
@ -99,7 +192,7 @@ Ver.1.10.0:
- remove util.py
- remove createNotifyrc since it isn't needed
* refactoring of configuration interface
* player settings was moved from plasmoid to dataengine
* player settings was moved from plasmoid to DataEngine
* edit readme call
* change readme from md to html
@ -147,8 +240,8 @@ Ver.1.7.3:
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
+ add DataEngine configuration from ptm
+ add custom command to DataEngine
- remove custom command from ptm
- remove tags $ds, $hs, $ms

View File

@ -1,3 +1,93 @@
Вер.2.4.0:
+ добавлена поддержка погоды
+ добавлена поддержка LA (теги la1, la5, la15)
+ добавлена кнопка "Сбросить кеш"
+ добавлена поддержка сборки с clang
+ добавлен ExtItem агрегатор
+ добавлено время в дебаг вывод
+ добавлена возможность отключить монитор плеера
- исправлен баг с неправильным расчетам скорости сети
- исправлен баг с неправильной инициализацией диалога шрифтов
- исправлен баг с отсутствием удаления объектов (#60)
* переписаны ExtItems для использования собственного абстрактного класса
* улучшена работа с обновлениями виджета (#57)
* рисование интерфейса переписано на модель сигнал-слот
* плагин опять стал приватным
* исправлен каст плагина с синглтона (#57)
* изменена логика показа данных в DataEngine
* изменена сборка пакета и прекращена поддержка отдельного пакета с DataEngine
* замена QMap на QHash, если возможно
* замена циклов на итераторы, если возможно
* список рабочий столов сейчас представлен, как QStringList
* рефакторинг
Вер.2.3.3:
* изменен рендеринг с Qt на нативный
Вер.2.3.2:
+ добавлено изменение скорости интернета с KB/s на MB/s, если величина более 1000 KB/s
- пофикшен баг с отсутствием действия при активации ссылки (спасибо infans)
* улучшена поддержка котировок, например пофикшен возможный сегфолт плазмы
* переписать основной виджет к модели сигнал-слот
* улучшена поддержка расчета заряда батареи для нескольких батарей
Вер.2.3.1:
- пофикшен баг с отсутствием обновлений значений из настроек
- убрана поддержка фильтра `\t`
* обновлены переводы
* теги fan были объединены с temp, улучшена поддержка тегов lmsensors
Вер.2.3.0:
+ добавлена поддержка фильтров в ExtScript (ApiVer = 3) (#53)
+ добавлена возможность отображать `\n`, как перенос строки (#53)
+ добавлена сортировка ключей в комбобоксах
+ добавлена поддержка тегов (perc)(bid|ask|price)chg (ApiVer = 2)
+ добавлены таймауты запросов котировок (#54)
- исправлен баг с неправильным парсингом html
* ExtQuotes теперь использует JSON вместо XML (ApiVer = 2)
* более красивый UI настроек
* некоторый рефакторинг
Вер.2.2.2:
+ добавлена поддержка котировок (#46)
+ добавлена поддержка свойств height и width (#47)
+ добавлена поддержка перевода в плагины (#50)
+ добавлено кеширование ключей
+ добавлена поддержка X-AW-Number в ExtScript, ExtUpgrade (ApiVer=2)
+ добавлено переподключение DataEngine (в некоторых случаях отдельные значения не обновляются)
+ добавлено обновление ширины и высоты виджета
- исправлен баг при обновлении Ext* (#49)
- исправлен баг с сохранением настроек GPUDEV, HDDDEV из графического интерфейса
- исправлены настройки Desktop Panel
- исправлен баг с добавлением настроек параграфа
* дропнута поддержка KDE4 версии (отдельная ветка разработки)
* увеличены лимиты для интервалов (#48)
* hddtemp был заменен на smartctl по умолчанию
* плагины были перемещены из private
* более корректное рисование интерфейса
Вер.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:
+ добавлена функция автообновления
+ добавлена поддерка кастомных скриптов
@ -70,7 +160,7 @@
+ добавлено поле текущий рабочий стол (теги $name, $number, $total)
+ добавлена возможность взаимодействия с плеерами через mpris
* добавлено использование сабмодулей
* dataengine переписан с использованием tasks
* DataEngine переписан с использованием tasks
* фикс чтения температуры nvidia
Вер.1.10.2:
@ -99,7 +189,7 @@
- удален util.py
- удалены функции createNotifyrc, поскольку они больше не нужны
* рефакторинг конфигурационного интерфейса
* настройки плеера были перенесены из виджета в dataengine
* настройки плеера были перенесены из виджета в DataEngine
* исправлен вызов readme под четырехсимвольное обозначение
* перенос readme с md на html

View File

@ -1,41 +0,0 @@
# Maintainer: Evgeniy Alekseev <arcanis at archlinux dot org>
pkgname=kdeplasma-applets-awesome-widgets
_pkgname=awesome-widgets
pkgver=2.1.0
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"
"mpd: for music player monitor"
"nvidia-utils: for GPU monitor"
"qmmp: for music player monitor")
makedepends=('automoc4' 'cmake')
source=(https://github.com/arcan1s/awesome-widgets/releases/download/V.${pkgver}/${_pkgname}-${pkgver}-src.tar.xz)
install=${pkgname}.install
md5sums=('37d9ad08b2b4623d2ab9089facf4b5ff')
backup=('usr/share/config/extsysmon.conf')
prepare() {
rm -rf "${srcdir}/build"
mkdir "${srcdir}/build"
}
build () {
cd "${srcdir}/build"
cmake -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=$(kde4-config --prefix) \
"../${_pkgname}"
make
}
package() {
cd "${srcdir}/build"
make DESTDIR="${pkgdir}" install
}

View File

@ -1,40 +0,0 @@
# Maintainer: Evgeniy Alekseev <arcanis at archlinux dot org>
pkgname=kdeplasma-applets-awesome-widgets
_pkgname=awesome-widgets
pkgver=2.0.5
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"
"mpd: for music player monitor"
"nvidia-utils: for GPU monitor"
"qmmp: for music player monitor")
makedepends=('automoc4' 'cmake')
source=(${_pkgname}::git+https://github.com/arcan1s/awesome-widgets/)
md5sums=('SKIP')
backup=('usr/share/config/extsysmon.conf')
prepare() {
rm -rf "${srcdir}/build"
mkdir "${srcdir}/build"
}
build () {
cd "${srcdir}/build"
cmake -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=$(kde4-config --prefix) \
"../${_pkgname}/sources"
make
}
package() {
cd "${srcdir}/build"
make DESTDIR="${pkgdir}" install
}

View File

@ -27,21 +27,21 @@ Instruction
Dependencies
------------
* kdebase-workspace
* lm_sensors (*for definition temperature device*)
* plasma-framework
Optional dependencies
---------------------
* proprietary video driver
* hddtemp
* music player (mpd or supported MPRIS)
* smartmontools
* music player (mpd or MPRIS supported)
Make dependencies
-----------------
* automoc4
* cmake
* extra-cmake-modules
Installation
------------
@ -50,15 +50,11 @@ Installation
* install
mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=`kde4-config --localprefix` ../
make && make install
Also you may install it to `/`:
mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=`kde4-config --prefix` ../
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr ../
make && sudo make install
**NOTE** on Plasma 5 it very likely requires `-DKDE_INSTALL_USE_QT_SYS_PATHS=ON` flag
Additional information
======================
@ -75,4 +71,5 @@ Links
* [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/) package
* Archlinux [AUR](https://aur.archlinux.org/packages/plasma5-applet-awesome-widgets/) package
* [OpenSuse](http://software.opensuse.org/search?q=awesome-widgets) packages, [KF5 OpenSuse](http://software.opensuse.org/package/plasma5-awesome-widgets) package

View File

@ -1,24 +1,18 @@
#!/bin/bash
SRCDIR="sources"
MAJOR=$(grep -m1 PROJECT_VERSION_MAJOR sources/CMakeLists.txt | awk '{print $3}' | sed 's/.$//g')
MINOR=$(grep -m1 PROJECT_VERSION_MINOR sources/CMakeLists.txt | awk '{print $3}' | sed 's/.$//g')
PATCH=$(grep -m1 PROJECT_VERSION_PATCH sources/CMakeLists.txt | awk '{print $3}' | sed 's/.$//g')
MAJOR=$(grep -m1 PROJECT_VERSION_MAJOR sources/CMakeLists.txt | awk '{print $2}' | sed 's/^.\(.*\)..$/\1/')
MINOR=$(grep -m1 PROJECT_VERSION_MINOR sources/CMakeLists.txt | awk '{print $2}' | sed 's/^.\(.*\)..$/\1/')
PATCH=$(grep -m1 PROJECT_VERSION_PATCH sources/CMakeLists.txt | awk '{print $2}' | sed 's/^.\(.*\)..$/\1/')
VERSION="${MAJOR}.${MINOR}.${PATCH}"
# build dataengine
ARCHIVE="ext-sysmon"
# create archive
[[ -e ${ARCHIVE}-${VERSION}-src.tar.xz ]] && rm -f ${ARCHIVE}-${VERSION}-src.tar.xz
[[ -d ${ARCHIVE} ]] && rm -rf "${ARCHIVE}"
cp -r "${SRCDIR}/${ARCHIVE}" "${ARCHIVE}"
tar cJf "${ARCHIVE}-${VERSION}-src.tar.xz" "${ARCHIVE}"
rm -rf "${ARCHIVE}"
# update submodules
git submodule update --init --recursive
# build widget
ARCHIVE="awesome-widgets"
FILES="AUTHORS CHANGELOG CHANGELOG-RU COPYING"
IGNORELIST="build usr"
IGNORELIST="build usr .kdev4 *.kdev4"
# create archive
[[ -e ${ARCHIVE}-${VERSION}-src.tar.xz ]] && rm -f "${ARCHIVE}-${VERSION}-src.tar.xz"
[[ -d ${ARCHIVE} ]] && rm -rf "${ARCHIVE}"
@ -26,9 +20,13 @@ cp -r "${SRCDIR}" "${ARCHIVE}"
for FILE in ${FILES[*]}; do cp -r "$FILE" "${ARCHIVE}"; done
for FILE in ${IGNORELIST[*]}; do rm -rf "${ARCHIVE}/${FILE}"; done
tar cJf "${ARCHIVE}-${VERSION}-src.tar.xz" "${ARCHIVE}"
ln -sf "../${ARCHIVE}-${VERSION}-src.tar.xz" packages
rm -rf "${ARCHIVE}"
# update md5sum
MD5SUMS=$(md5sum ${ARCHIVE}-${VERSION}-src.tar.xz | awk '{print $1}')
sed -i "/md5sums=('[0-9A-Fa-f]*/s/[^'][^)]*/md5sums=('${MD5SUMS}'/" PKGBUILD
sed -i "s/pkgver=[0-9.]*/pkgver=${VERSION}/" PKGBUILD
sed -i "/md5sums=('[0-9A-Fa-f]*/s/[^'][^)]*/md5sums=('${MD5SUMS}'/" packages/PKGBUILD
sed -i "s/pkgver=[0-9.]*/pkgver=${VERSION}/" packages/PKGBUILD
# clear
find . -type f -name '*src.tar.xz' -not -name "*${VERSION}-src.tar.xz" -exec rm -rf {} \;
find packages -type l -xtype l -exec rm -rf {} \;

54
packages/PKGBUILD Normal file
View File

@ -0,0 +1,54 @@
# Maintainer: Evgeniy Alekseev <arcanis at archlinux dot org>
pkgname=plasma5-applet-awesome-widgets
_pkgname=awesome-widgets
pkgver=2.4.0.r34.gbe26033
pkgrel=1
pkgdesc="Collection of minimalistic Plasmoids which look like Awesome WM widgets (ex-PyTextMonitor). Git version"
arch=('i686' 'x86_64')
url="http://arcanis.name/projects/awesome-widgets"
license=('GPL3')
depends=('plasma-framework')
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=('cmake' 'extra-cmake-modules' 'git')
source=(${_pkgname}::git+https://github.com/arcan1s/awesome-widgets.git#branch=release-2.4.0)
install=${pkgname}.install
md5sums=('SKIP')
backup=('etc/xdg/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
echo "$pkgver"
}
build () {
cd "${srcdir}/${_pkgname}/build"
cmake -DKDE_INSTALL_USE_QT_SYS_PATHS=ON \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/usr \
"../sources"
make
}
package() {
cd "${srcdir}/${_pkgname}/build"
make DESTDIR="${pkgdir}" install
}

View File

@ -0,0 +1,11 @@
cmake
extra-cmake-modules
g++
git
libkf5i18n-dev
libkf5notifications-dev
libkf5service-dev
libkf5windowsystem-dev
plasma-framework-dev
qtbase5-dev
qtdeclarative5-dev

View File

View File

@ -1,5 +1,5 @@
post_install() {
kbuildsycoca4 > /dev/null 2>&1
kbuildsycoca5 > /dev/null 2>&1
}
post_upgrade() {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 42 KiB

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 75 KiB

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 59 KiB

After

Width:  |  Height:  |  Size: 55 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 44 KiB

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 83 KiB

After

Width:  |  Height:  |  Size: 53 KiB

BIN
screenshots/config_06.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

View File

@ -0,0 +1,26 @@
[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=Release
CMake Binary=file:///usr/bin/cmake
Environment Profile=
Extra Arguments=
Install Directory=file:///usr
[Defines And Includes][Compiler]
Name=GCC
Path=gcc
Type=GCC
[Launch]
Launch Configurations=
[Project]
VersionControlSupport=kdevgit

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=Release
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

Submodule sources/3rdparty/pdebug deleted from 294a590bb9

View File

@ -0,0 +1,18 @@
#include "qreplytimeout.h"
#include <QTimer>
QReplyTimeout::QReplyTimeout(QNetworkReply *reply, const int timeout)
: QObject(reply)
{
QTimer::singleShot(timeout, this, SLOT(timeout()));
}
void QReplyTimeout::timeout()
{
QNetworkReply *reply = static_cast<QNetworkReply *>(parent());
if (reply->isRunning())
reply->close();
}

View File

@ -0,0 +1,17 @@
// from here http://codereview.stackexchange.com/questions/30031/qnetworkreply-network-reply-timeout-helper
// no license provided
#include <QNetworkReply>
#include <QObject>
class QReplyTimeout : public QObject
{
Q_OBJECT
public:
explicit QReplyTimeout(QNetworkReply *reply, const int timeout);
public slots:
void timeout();
};

View File

@ -1,38 +1,67 @@
cmake_minimum_required (VERSION 2.8)
cmake_minimum_required(VERSION 2.8.12)
cmake_policy (SET CMP0003 OLD)
cmake_policy (SET CMP0002 OLD)
cmake_policy (SET CMP0011 NEW)
cmake_policy (SET CMP0015 NEW)
# some fucking magic
cmake_policy(SET CMP0003 OLD)
cmake_policy(SET CMP0002 OLD)
cmake_policy(SET CMP0011 NEW)
cmake_policy(SET CMP0015 NEW)
if (POLICY CMP0063)
cmake_policy(SET CMP0063 OLD)
endif()
project (awesome-widgets)
set (PROJECT_AUTHOR "Evgeniy Alekseev")
set (PROJECT_CONTACT "esalexeev@gmail.com")
set (PROJECT_LICENSE "GPLv3")
set (PROJECT_VERSION_MAJOR 2)
set (PROJECT_VERSION_MINOR 1)
set (PROJECT_VERSION_PATCH 0)
set (PROJECT_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH})
project(awesomewidgets)
set(PROJECT_AUTHOR "Evgeniy Alekseev")
set(PROJECT_CONTACT "esalexeev@gmail.com")
set(PROJECT_LICENSE "GPL3")
set(PROJECT_VERSION_MAJOR "2")
set(PROJECT_VERSION_MINOR "4")
set(PROJECT_VERSION_PATCH "0")
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")
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}")
message(STATUS "Project: ${PROJECT_NAME}")
message(STATUS "Version: ${PROJECT_VERSION}")
message(STATUS "Build date: ${CURRENT_DATE}")
option(BUILD_PLASMOIDS "Build plasmoids" ON)
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")
else ()
message (STATUS "Unknown compiler")
endif ()
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)
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(CMAKE_CXX_FLAGS "-Wall -std=c++11 -stdlib=libc++")
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0")
set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG")
# linker flags
set(CMAKE_EXE_LINKER_FLAGS "-lc++abi")
set(CMAKE_MODULE_LINKER_FLAGS "-lc++abi")
set(CMAKE_SHARED_LINKER_FLAGS "-lc++abi")
else()
message(FATAL_ERROR "Unknown compiler")
endif()
if(CMAKE_BUILD_TYPE MATCHES Debug)
set(CMAKE_VERBOSE_MAKEFILE ON)
endif()
configure_file (${CMAKE_SOURCE_DIR}/version.h.in ${CMAKE_CURRENT_BINARY_DIR}/version.h)
set (PROJECT_TRDPARTY_DIR ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty)
configure_file(${CMAKE_SOURCE_DIR}/version.h.in ${CMAKE_CURRENT_BINARY_DIR}/version.h)
set(PROJECT_TRDPARTY_DIR ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty)
set(PROJECT_LIBRARY awesomewidgets)
include(libraries.cmake)
add_subdirectory (ext-sysmon)
add_subdirectory (awesome-widget)
add_subdirectory (desktop-panel)
add_subdirectory(awesomewidgets)
add_subdirectory(extsysmon)
if(BUILD_PLASMOIDS)
add_subdirectory(awesome-widget)
add_subdirectory(desktop-panel)
add_subdirectory(translations)
endif()
include(packages-recipe.cmake)

25
sources/awdebug.cpp Normal file
View File

@ -0,0 +1,25 @@
/***************************************************************************
* 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 "awdebug.h"
Q_LOGGING_CATEGORY(LOG_AW, "org.kde.plasma.awesomewidget", QtMsgType::QtWarningMsg)
Q_LOGGING_CATEGORY(LOG_DP, "org.kde.plasma.desktoppanel", QtMsgType::QtWarningMsg)
Q_LOGGING_CATEGORY(LOG_ESM, "org.kde.plasma.extsysmon", QtMsgType::QtWarningMsg)
Q_LOGGING_CATEGORY(LOG_LIB, "org.kde.plasma.awesomewidgets", QtMsgType::QtWarningMsg)

45
sources/awdebug.h Normal file
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 AWDEBUG_H
#define AWDEBUG_H
#include <QLoggingCategory>
#ifndef LOG_FORMAT
#define LOG_FORMAT "[%{time yyyy-MM-ddTHH:mm:ss.zzz}][%{if-debug}DD%{endif}%{if-info}II%{endif}%{if-warning}WW%{endif}%{if-critical}CC%{endif}%{if-fatal}FF%{endif}][%{category}][%{function}] %{message}"
#endif /* LOG_FORMAT */
// define info log level
// #if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
// #ifndef qCInfo
// redefine info because it doesn't log properly
#ifdef qCInfo
#undef qCInfo
#endif /* qCInfo */
#define qCInfo qCDebug
// #endif /* QT_VERSION */
Q_DECLARE_LOGGING_CATEGORY(LOG_AW)
Q_DECLARE_LOGGING_CATEGORY(LOG_DP)
Q_DECLARE_LOGGING_CATEGORY(LOG_ESM)
Q_DECLARE_LOGGING_CATEGORY(LOG_LIB)
#endif /* AWDEBUG_H */

View File

@ -1,46 +1,7 @@
# set project name
set (SUBPROJECT plasma_applet_awesome-widget)
set (PLUGIN_NAME ${SUBPROJECT})
message (STATUS "Subproject ${SUBPROJECT}")
set(SUBPROJECT plasma_applet_awesome-widget)
message(STATUS "Subproject ${SUBPROJECT}")
# find required libaries
find_package (KDE4 REQUIRED)
add_definitions (${QT_DEFINITIONS} ${KDE4_DEFINITIONS})
configure_file(metadata.desktop ${CMAKE_CURRENT_SOURCE_DIR}/package/metadata.desktop)
add_subdirectory (po)
include (KDE4Defaults)
include_directories (${CMAKE_SOURCE_DIR}
${CMAKE_BINARY_DIR}
${KDE4_INCLUDES}
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_BINARY_DIR}/../
${PROJECT_TRDPARTY_DIR}
../ext-sysmon
${CMAKE_CURRENT_BINARY_DIR}/../ext-sysmon)
# 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
../ext-sysmon/extscript.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})
add_subdirectory(plugin)
plasma_install_package(package org.kde.plasma.awesomewidget)

View File

@ -1,534 +0,0 @@
<?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

@ -1,237 +0,0 @@
<?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

@ -1,503 +0,0 @@
/***************************************************************************
* 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("ext-sysmon"));
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]->getName() + graphicalItems[i]->getBar());
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]->getName() + graphicalItems[i]->getBar()) != 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

@ -1,151 +0,0 @@
/***************************************************************************
* 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 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);
QMap<QString, QString> updateDataEngineConfiguration(const QMap<QString, QString> rawConfig);
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 addNewPkgCommand(QTableWidgetItem *item);
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 editBar(QListWidgetItem *item);
void editCustomCommand(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();
// 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;
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

@ -1,97 +0,0 @@
/***************************************************************************
* 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

@ -1,432 +0,0 @@
<?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="9" column="0">
<layout class="QVBoxLayout" name="layout_pkgCommand">
<item>
<widget class="QTableWidget" name="tableWidget_pkgCommand">
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="toolTip">
<string>Editable
del - remove item</string>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::SingleSelection</enum>
</property>
<attribute name="horizontalHeaderStretchLastSection">
<bool>true</bool>
</attribute>
<attribute name="verticalHeaderVisible">
<bool>false</bool>
</attribute>
<column>
<property name="text">
<string>Package manager</string>
</property>
</column>
<column>
<property name="text">
<string>Null lines</string>
</property>
</column>
</widget>
</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>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -1,606 +0,0 @@
/***************************************************************************
* 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, 60*60*1000, Plasma::AlignToHour);
// 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])->getBar() != 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])->getBar() != 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])->getBar() != (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("GPU")].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])->getBar() != QString("gpu")) continue;
values[foundBars[j]] = values[QString("gpu")];
}
}
} else if (sourceName == QString("gputemp")) {
values[QString("gputemp")] = QString("%1").arg(getTemp(data[QString("GPUTemp")].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])->getBar() != (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])->getBar() != 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])->getBar() != 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

@ -1,23 +0,0 @@
[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

View File

@ -1,470 +0,0 @@
/***************************************************************************
* 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>
GraphicalItem::GraphicalItem(QWidget *parent, const QString desktopName, const QStringList directories, const bool debugCmd)
: QDialog(parent),
fileName(desktopName),
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::getImage(const float value)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Value" << value;
if (_bar == QString("none")) return QString("");
QColor active = stringToColor(_activeColor);
QColor inactive = stringToColor(_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(_width + 5.0, _height + 5.0);
// paint
switch(_type) {
case Vertical:
pen.setWidth(_width);
// inactive
pen.setColor(inactive);
scene->addLine(0.5 * _width, -0.5 * _width, 0.5 * _width, (1.0 - percent) * _height - 0.5 * _width, pen);
// active
pen.setColor(active);
scene->addLine(0.5 * _width, (1.0 - percent) * _height + 0.5 * _width, 0.5 * _width, _height + 0.5 * _width, pen);
// scale
scale[1] = -2 * (int)_direction + 1;
break;
case Circle:
QGraphicsEllipseItem *circle;
pen.setWidth(1.0);
// inactive
pen.setColor(inactive);
circle = scene->addEllipse(0.0, 0.0, _width, _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, _width, _height, pen, QBrush(active, Qt::SolidPattern));
circle->setSpanAngle(- percent * 360.0 * 16.0);
circle->setStartAngle(90.0 * 16.0);
// scale
scale[0] = -2 *(int)_direction + 1;
break;
default:
pen.setWidth(_height);
// inactive
pen.setColor(inactive);
scene->addLine(percent * _width + 0.5 * _height, 0.5 * _height, _width + 0.5 * _height, 0.5 * _height, pen);
// active
pen.setColor(active);
scene->addLine(-0.5 * _height, 0.5 * _height, percent * _width - 0.5 * _height, 0.5 * _height, pen);
// scale
scale[0] = -2 * (int)_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::getFileName()
{
if (debug) qDebug() << PDEBUG;
return fileName;
}
QString GraphicalItem::getName()
{
if (debug) qDebug() << PDEBUG;
return _name;
}
QString GraphicalItem::getComment()
{
if (debug) qDebug() << PDEBUG;
return _comment;
}
QString GraphicalItem::getBar()
{
if (debug) qDebug() << PDEBUG;
return _bar;
}
QString GraphicalItem::getActiveColor()
{
if (debug) qDebug() << PDEBUG;
return _activeColor;
}
QString GraphicalItem::getInactiveColor()
{
if (debug) qDebug() << PDEBUG;
return _inactiveColor;
}
GraphicalItem::Type GraphicalItem::getType()
{
if (debug) qDebug() << PDEBUG;
return _type;
}
QString GraphicalItem::getStrType()
{
if (debug) qDebug() << PDEBUG;
QString value;
switch(_type) {
case Vertical:
value = QString("Vertical");
break;
case Circle:
value = QString("Circle");
break;
default:
value = QString("Horizontal");
break;
}\
return value;
}
GraphicalItem::Direction GraphicalItem::getDirection()
{
if (debug) qDebug() << PDEBUG;
return _direction;
}
QString GraphicalItem::getStrDirection()
{
if (debug) qDebug() << PDEBUG;
QString value;
switch (_direction) {
case RightToLeft:
value = QString("RightToLeft");
break;
default:
value = QString("LeftToRight");
break;
}
return value;
}
int GraphicalItem::getHeight()
{
if (debug) qDebug() << PDEBUG;
return _height;
}
int GraphicalItem::getWidth()
{
if (debug) qDebug() << PDEBUG;
return _width;
}
void GraphicalItem::setName(const QString name)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Name" << name;
_name = name;
}
void GraphicalItem::setComment(const QString comment)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Comment" << comment;
_comment = comment;
}
void GraphicalItem::setBar(const QString bar)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Bar" << bar;
_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.*")))))
_bar = QString("none");
}
void GraphicalItem::setActiveColor(const QString color)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Color" << color;
_activeColor = color;
}
void GraphicalItem::setInactiveColor(const QString color)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Color" << color;
_inactiveColor = color;
}
void GraphicalItem::setType(const QString type)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Type" << type;
if (type == QString("Vertical"))
_type = Vertical;
else if (type == QString("Circle"))
_type = Circle;
else
_type = Horizontal;
}
void GraphicalItem::setDirection(const QString direction)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Direction" << direction;
if (direction == QString("RightToLeft"))
_direction = RightToLeft;
else
_direction = LeftToRight;
}
void GraphicalItem::setHeight(const int height)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Height" << height;
if (height <= 0) return;
_height = height;
}
void GraphicalItem::setWidth(const int width)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Width" << width;
if (width <= 0) return;
_width = width;
}
void GraphicalItem::readConfiguration()
{
if (debug) qDebug() << PDEBUG;
for (int i=dirs.count()-1; i>=0; i--) {
if (!QDir(dirs[i]).entryList(QDir::Files).contains(fileName)) continue;
QSettings settings(dirs[i] + QDir::separator() + fileName, QSettings::IniFormat);
settings.beginGroup(QString("Desktop Entry"));
setName(settings.value(QString("Name"), _name).toString());
setComment(settings.value(QString("Comment"), _comment).toString());
setBar(settings.value(QString("X-AW-Value"), _bar).toString());
setActiveColor(settings.value(QString("X-AW-ActiveColor"), _activeColor).toString());
setInactiveColor(settings.value(QString("X-AW-InactiveColor"), _inactiveColor).toString());
setType(settings.value(QString("X-AW-Type"), getStrType()).toString());
setDirection(settings.value(QString("X-AW-Direction"), getStrDirection()).toString());
setHeight(settings.value(QString("X-AW-Height"), QString::number(_height)).toInt());
setWidth(settings.value(QString("X-AW-Width"), QString::number(_width)).toInt());
settings.endGroup();
}
}
void GraphicalItem::showConfiguration(const QStringList tags)
{
if (debug) qDebug() << PDEBUG;
ui->label_nameValue->setText(_name);
ui->lineEdit_comment->setText(_comment);
ui->comboBox_value->addItems(tags);
ui->comboBox_value->addItem(_bar);
ui->comboBox_value->setCurrentIndex(ui->comboBox_value->count() - 1);
ui->pushButton_activeColor->setText(_activeColor);
ui->pushButton_inactiveColor->setText(_inactiveColor);
ui->comboBox_type->setCurrentIndex((int)_type);
ui->comboBox_direction->setCurrentIndex((int)_direction);
ui->spinBox_height->setValue(_height);
ui->spinBox_width->setValue(_width);
int ret = exec();
if (ret != 1) return;
setName(ui->label_nameValue->text());
setComment(ui->lineEdit_comment->text());
setBar(ui->comboBox_value->currentText());
setActiveColor(ui->pushButton_activeColor->text().remove(QChar('&')));
setInactiveColor(ui->pushButton_inactiveColor->text().remove(QChar('&')));
setType(ui->comboBox_type->currentText());
setDirection(ui->comboBox_direction->currentText());
setHeight(ui->spinBox_height->value());
setWidth(ui->spinBox_width->value());
writeConfiguration();
}
void GraphicalItem::tryDelete()
{
if (debug) qDebug() << PDEBUG;
for (int i=0; i<dirs.count(); i++)
if (debug) qDebug() << PDEBUG << ":" << "Remove file" << dirs[i] + QDir::separator() + fileName <<
QFile::remove(dirs[i] + QDir::separator() + fileName);
}
void GraphicalItem::writeConfiguration()
{
if (debug) qDebug() << PDEBUG;
QSettings settings(dirs[0] + QDir::separator() + 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"), _name);
settings.setValue(QString("Comment"), _comment);
settings.setValue(QString("X-AW-Value"), _bar);
settings.setValue(QString("X-AW-ActiveColor"), _activeColor);
settings.setValue(QString("X-AW-InactiveColor"), _inactiveColor);
settings.setValue(QString("X-AW-Type"), getStrType());
settings.setValue(QString("X-AW-Direction"), getStrDirection());
settings.setValue(QString("X-AW-Height"), _height);
settings.setValue(QString("X-AW-Width"), _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()));
((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

@ -1,98 +0,0 @@
/***************************************************************************
* 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
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 getImage(const float value);
// get methods
QString getFileName();
QString getName();
QString getComment();
QString getBar();
QString getActiveColor();
QString getInactiveColor();
Type getType();
QString getStrType();
Direction getDirection();
QString getStrDirection();
int getHeight();
int getWidth();
// set methods
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 QString type = QString("Horizontal"));
void setDirection(const QString direction = QString("LeftToRight"));
void setHeight(const int height = 100);
void setWidth(const int width = 100);
public slots:
void readConfiguration();
void showConfiguration(const QStringList tags = QStringList());
void tryDelete();
void writeConfiguration();
private slots:
void changeColor();
private:
QColor stringToColor(const QString color);
QString fileName;
QStringList dirs;
bool debug;
Ui::GraphicalItem *ui;
// properties
QString _name = QString("none");
QString _comment = QString("empty");
QString _bar = QString("cpu");
QString _activeColor = QString("0,0,0,130");
QString _inactiveColor = QString("255,255,255,130");
Type _type = Horizontal;
Direction _direction = LeftToRight;
int _height = 100;
int _width = 100;
};
#endif /* GRAPHICALITEM_H */

View File

@ -12,11 +12,14 @@ X-KDE-ServiceTypes=Plasma/Applet
Type=Service
Icon=utilities-system-monitor
X-KDE-Library=plasma_applet_awesome-widget
X-KDE-ServiceTypes=Plasma/Applet
X-Plasma-API=declarativeappletscript
X-Plasma-MainScript=ui/main.qml
X-Plasma-RemoteLocation=
X-KDE-PluginInfo-Author=Evgeniy Alekseev aka arcanis
X-KDE-PluginInfo-Email=esalexeev@gmail.com
X-KDE-PluginInfo-Name=awesome-widget
X-KDE-PluginInfo-Name=org.kde.plasma.awesomewidget
X-KDE-PluginInfo-Version=@PROJECT_VERSION@
X-KDE-PluginInfo-Website=http://arcanis.name/projects/awesome-widgets/
X-KDE-PluginInfo-Category=System Information

View File

@ -0,0 +1,59 @@
/***************************************************************************
* 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/ *
***************************************************************************/
import QtQuick 2.0
import org.kde.plasma.configuration 2.0
ConfigModel {
ConfigCategory {
name: i18n("Widget")
icon: "utilities-system-monitor"
source: "widget.qml"
}
ConfigCategory {
name: i18n("Advanced")
icon: "system-run"
source: "advanced.qml"
}
ConfigCategory {
name: i18n("Tooltip")
icon: "preferences-desktop-color"
source: "tooltip.qml"
}
ConfigCategory {
name: i18n("Appearance")
icon: "preferences-desktop-theme"
source: "appearance.qml"
}
ConfigCategory {
name: i18n("DataEngine")
icon: "utilities-system-monitor"
source: "dataengine.qml"
}
ConfigCategory {
name: i18n("About")
icon: "help-about"
source: "about.qml"
}
}

View File

@ -0,0 +1,134 @@
<?xml version="1.0" encoding="UTF-8"?>
<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
<kcfgfile name=""/>
<group name="Widget">
<!-- widget -->
<entry name="text" type="string">
<default>[cpu: $cpu%] [mem: $mem%] [swap: $swap%] [$netdev: $down/$upKB/s]</default>
</entry>
</group>
<group name="Advanced">
<!-- advanced -->
<entry name="height" type="int">
<default>0</default>
</entry>
<entry name="width" type="int">
<default>0</default>
</entry>
<entry name="notify" type="bool">
<default>true</default>
</entry>
<entry name="wrapNewLines" type="bool">
<default>false</default>
</entry>
<entry name="background" type="bool">
<default>true</default>
</entry>
<entry name="customTime" type="string">
<default>$hh:$mm</default>
</entry>
<entry name="customUptime" type="string">
<default>$dd,$hh,$mm</default>
</entry>
<entry name="tempUnits" type="string">
<default>Celsius</default>
</entry>
<entry name="acOnline" type="string">
<default>(*)</default>
</entry>
<entry name="acOffline" type="string">
<default>( )</default>
</entry>
<entry name="checkUpdates" type="bool">
<default>true</default>
</entry>
<entry name="translateStrings" type="bool">
<default>true</default>
</entry>
</group>
<group name="Tooltip">
<entry name="tooltipNumber" type="int">
<default>100</default>
</entry>
<entry name="useTooltipBackground" type="bool">
<default>true</default>
</entry>
<entry name="tooltipBackground" type="string">
<default>#ffffff</default>
</entry>
<entry name="cpuTooltip" type="bool">
<default>true</default>
</entry>
<entry name="cpuTooltipColor" type="string">
<default>#ff0000</default>
</entry>
<entry name="cpuclTooltip" type="bool">
<default>true</default>
</entry>
<entry name="cpuclTooltipColor" type="string">
<default>#00ff00</default>
</entry>
<entry name="memTooltip" type="bool">
<default>true</default>
</entry>
<entry name="memTooltipColor" type="string">
<default>#0000ff</default>
</entry>
<entry name="swapTooltip" type="bool">
<default>true</default>
</entry>
<entry name="swapTooltipColor" type="string">
<default>#ffff00</default>
</entry>
<entry name="downTooltip" type="bool">
<default>true</default>
</entry>
<entry name="downTooltipColor" type="string">
<default>#00ffff</default>
</entry>
<entry name="upTooltipColor" type="string">
<default>#ff00ff</default>
</entry>
<entry name="batTooltip" type="bool">
<default>true</default>
</entry>
<entry name="batTooltipColor" type="string">
<default>#008800</default>
</entry>
<entry name="batInTooltipColor" type="string">
<default>#880000</default>
</entry>
</group>
<group name="Appearance">
<!-- appearance -->
<entry name="interval" type="int">
<default>1000</default>
</entry>
<entry name="textAlign" type="string">
<default>center</default>
</entry>
<entry name="fontFamily" type="string">
<default>Terminus</default>
</entry>
<entry name="fontSize" type="int">
<default>12</default>
</entry>
<entry name="fontColor" type="string">
<default>#000000</default>
</entry>
<entry name="fontWeight" type="string">
<default>normal</default>
</entry>
<entry name="fontStyle" type="string">
<default>normal</default>
</entry>
</group>
</kcfg>

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/ *
***************************************************************************/
import QtQuick 2.0
import QtQuick.Controls 1.3 as QtControls
import QtQuick.Layouts 1.0 as QtLayouts
import org.kde.plasma.private.awesomewidget 1.0
Item {
id: aboutPage
AWActions {
id: awActions;
}
width: childrenRect.width
height: childrenRect.height
implicitWidth: pageColumn.implicitWidth
implicitHeight: pageColumn.implicitHeight
property bool debug: awActions.isDebugEnabled()
Column {
id: pageColumn
anchors.fill: parent
QtControls.TabView {
height: parent.height
width: parent.width
QtControls.Tab {
title: i18n("About")
QtLayouts.ColumnLayout {
QtControls.Label {
QtLayouts.Layout.fillWidth: true
horizontalAlignment: Text.AlignHCenter
text: awActions.getAboutText("header")
}
QtControls.Label {
QtLayouts.Layout.fillWidth: true
horizontalAlignment: Text.AlignHCenter
text: awActions.getAboutText("version")
}
QtControls.Label {
QtLayouts.Layout.fillWidth: true
horizontalAlignment: Text.AlignJustify
text: awActions.getAboutText("description")
}
QtControls.Label {
QtLayouts.Layout.fillWidth: true
horizontalAlignment: Text.AlignLeft
textFormat: Text.RichText
text: awActions.getAboutText("links")
onLinkActivated: Qt.openUrlExternally(link);
}
QtControls.Label {
QtLayouts.Layout.fillHeight: true
QtLayouts.Layout.fillWidth: true
font.capitalization: Font.SmallCaps
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignBottom
textFormat: Text.RichText
text: awActions.getAboutText("copy")
}
}
}
QtControls.Tab {
title: i18n("Acknowledgment")
QtLayouts.ColumnLayout {
QtControls.Label {
QtLayouts.Layout.fillWidth: true
wrapMode: Text.WordWrap
horizontalAlignment: Text.AlignJustify
text: awActions.getAboutText("translators")
}
QtControls.Label {
QtLayouts.Layout.fillHeight: true
QtLayouts.Layout.fillWidth: true
horizontalAlignment: Text.AlignJustify
verticalAlignment: Text.AlignTop
textFormat: Text.RichText
text: awActions.getAboutText("3rdparty")
onLinkActivated: Qt.openUrlExternally(link);
}
}
}
}
}
Component.onCompleted: {
if (debug) console.debug()
}
}

View File

@ -0,0 +1,309 @@
/***************************************************************************
* 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/ *
***************************************************************************/
import QtQuick 2.0
import QtQuick.Controls 1.3 as QtControls
import org.kde.plasma.private.awesomewidget 1.0
Item {
id: advancedPage
// backend
AWActions {
id: awActions;
}
width: childrenRect.width
height: childrenRect.height
implicitWidth: pageColumn.implicitWidth
implicitHeight: pageColumn.implicitHeight
property bool debug: awActions.isDebugEnabled()
property alias cfg_height: widgetHeight.value
property alias cfg_width: widgetWidth.value
property alias cfg_notify: notify.checked
property alias cfg_wrapNewLines: wrapNewLines.checked
property alias cfg_background: background.checked
property alias cfg_customTime: customTime.text
property alias cfg_customUptime: customUptime.text
property string cfg_tempUnits: tempUnits.currentText
property alias cfg_acOnline: acOnline.text
property alias cfg_acOffline: acOffline.text
property alias cfg_checkUpdates: updates.checked
property alias cfg_translateStrings: translate.checked
Column {
id: pageColumn
anchors.fill: parent
Row {
height: implicitHeight
width: parent.width
QtControls.Label {
height: parent.height
width: parent.width * 2 / 5
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
text: i18n("Widget height, px")
}
QtControls.SpinBox {
id: widgetHeight
width: parent.width * 3 / 5
minimumValue: 0
maximumValue: 4096
stepSize: 50
value: plasmoid.configuration.height
}
}
Row {
height: implicitHeight
width: parent.width
QtControls.Label {
height: parent.height
width: parent.width * 2 / 5
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
text: i18n("Widget width, px")
}
QtControls.SpinBox {
id: widgetWidth
width: parent.width * 3 / 5
minimumValue: 0
maximumValue: 4096
stepSize: 50
value: plasmoid.configuration.width
}
}
Row {
height: implicitHeight
width: parent.width
QtControls.Label {
height: parent.heigth
width: parent.width * 2 / 5
}
QtControls.CheckBox {
id: notify
width: parent.width * 3 / 5
text: i18n("Enable notifications")
}
}
Row {
height: implicitHeight
width: parent.width
QtControls.Label {
height: parent.heigth
width: parent.width * 2 / 5
}
QtControls.CheckBox {
id: wrapNewLines
width: parent.width * 3 / 5
text: i18n("Wrap new lines")
}
}
Row {
height: implicitHeight
width: parent.width
QtControls.Label {
height: parent.heigth
width: parent.width * 2 / 5
}
QtControls.CheckBox {
id: background
width: parent.width * 3 / 5
text: i18n("Enable background")
}
}
Row {
height: implicitHeight
width: parent.width
QtControls.Label {
height: parent.height
width: parent.width * 2 / 5
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
text: i18n("Custom time format")
}
QtControls.TextField {
id: customTime
width: parent.width * 3 / 5
text: plasmoid.configuration.customTime
}
}
Row {
height: implicitHeight
width: parent.width
QtControls.Label {
height: parent.height
width: parent.width * 2 / 5
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
text: i18n("Custom uptime format")
}
QtControls.TextField {
id: customUptime
width: parent.width * 3 / 5
text: plasmoid.configuration.customUptime
}
}
Row {
height: implicitHeight
width: parent.width
QtControls.Label {
height: parent.height
width: parent.width * 2 / 5
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
text: i18n("Temperature units")
}
QtControls.ComboBox {
id: tempUnits
width: parent.width * 3 / 5
textRole: "label"
model: [
{
'label': i18n("Celsius"),
'name': "Celsius"
},
{
'label': i18n("Fahrenheit"),
'name': "Fahrenheit"
},
{
'label': i18n("Kelvin"),
'name': "Kelvin"
},
{
'label': i18n("Reaumur"),
'name': "Reaumur"
},
{
'label': i18n("cm^-1"),
'name': "cm^-1"
},
{
'label': i18n("kJ/mol"),
'name': "kJ/mol"
},
{
'label': i18n("kcal/mol"),
'name': "kcal/mol"
}
]
onCurrentIndexChanged: cfg_tempUnits = model[currentIndex]["name"]
Component.onCompleted: {
if (debug) console.debug()
for (var i = 0; i < model.length; i++) {
if (model[i]["name"] == plasmoid.configuration.tempUnits) {
if (debug) console.info("Found", model[i]["name"], "on", i)
tempUnits.currentIndex = i;
}
}
}
}
}
Row {
height: implicitHeight
width: parent.width
QtControls.Label {
height: parent.height
width: parent.width * 2 / 5
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
text: i18n("AC online tag")
}
QtControls.TextField {
id: acOnline
width: parent.width * 3 / 5
text: plasmoid.configuration.acOnline
}
}
Row {
height: implicitHeight
width: parent.width
QtControls.Label {
height: parent.height
width: parent.width * 2 / 5
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
text: i18n("AC offline tag")
}
QtControls.TextField {
id: acOffline
width: parent.width * 3 / 5
text: plasmoid.configuration.acOffline
}
}
Row {
height: implicitHeight
width: parent.width
QtControls.Label {
height: parent.heigth
width: parent.width * 2 / 5
}
QtControls.CheckBox {
id: updates
width: parent.width * 3 / 5
text: i18n("Check updates on startup")
}
}
Row {
height: implicitHeight
width: parent.width
QtControls.Label {
height: parent.heigth
width: parent.width * 2 / 5
}
QtControls.CheckBox {
id: translate
width: parent.width * 3 / 5
text: i18n("Translate strings")
}
}
Row {
height: implicitHeight
width: parent.width
QtControls.Label {
height: parent.height
width: parent.width * 2 / 5
}
QtControls.Button {
id: selectFont
width: parent.width * 3 / 5
text: i18n("Drop key cache")
onClicked: awActions.dropCache()
}
}
}
Component.onCompleted: {
if (debug) console.debug()
}
}

View File

@ -0,0 +1,263 @@
/***************************************************************************
* 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/ *
***************************************************************************/
import QtQuick 2.0
import QtQuick.Controls 1.3 as QtControls
import QtQuick.Controls.Styles 1.3 as QtStyles
import QtQuick.Dialogs 1.1 as QtDialogs
import org.kde.plasma.private.awesomewidget 1.0
Item {
id: appearancePage
// backend
AWActions {
id: awActions;
}
width: childrenRect.width
height: childrenRect.height
implicitWidth: pageColumn.implicitWidth
implicitHeight: pageColumn.implicitHeight
property bool debug: awActions.isDebugEnabled()
property variant weight: {
25: 0,
50: 1,
63: 3,
75: 4,
87: 5
}
property alias cfg_interval: update.value
property alias cfg_fontFamily: selectFont.text
property alias cfg_fontSize: fontSize.value
property string cfg_fontWeight: fontWeight.currentText
property string cfg_fontStyle: fontStyle.currentText
property alias cfg_fontColor: selectColor.text
Column {
id: pageColumn
anchors.fill: parent
Row {
height: implicitHeight
width: parent.width
QtControls.Label {
height: parent.height
width: parent.width / 3
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
text: i18n("Time interval")
}
QtControls.SpinBox {
id: update
width: parent.width * 2 / 3
minimumValue: 1000
maximumValue: 10000
stepSize: 500
value: plasmoid.configuration.interval
}
}
Row {
height: implicitHeight
width: parent.width
QtControls.Label {
height: parent.height
width: parent.width / 3
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
text: i18n("Font")
}
QtControls.Button {
id: selectFont
width: parent.width * 2 / 3
text: plasmoid.configuration.fontFamily
onClicked: {
if (debug) console.debug()
fontDialog.setFont()
fontDialog.visible = true
}
}
}
Row {
height: implicitHeight
width: parent.width
QtControls.Label {
height: parent.height
width: parent.width / 3
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
text: i18n("Font size")
}
QtControls.SpinBox {
id: fontSize
width: parent.width * 2 / 3
minimumValue: 8
maximumValue: 32
stepSize: 1
value: plasmoid.configuration.fontSize
}
}
Row {
height: implicitHeight
width: parent.width
QtControls.Label {
height: parent.height
width: parent.width / 3
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
text: i18n("Font weight")
}
QtControls.ComboBox {
id: fontWeight
width: parent.width * 2 / 3
textRole: "label"
model: [
{
'label': i18n("light"),
'name': "light"
},
{
'label': i18n("normal"),
'name': "normal"
},
{
'label': i18n("demi bold"),
'name': "demibold"
},
{
'label': i18n("bold"),
'name': "bold"
},
{
'label': i18n("black"),
'name': "black"
}
]
onCurrentIndexChanged: cfg_fontWeight = model[currentIndex]["name"]
Component.onCompleted: {
if (debug) console.debug()
for (var i = 0; i < model.length; i++) {
if (model[i]["name"] == plasmoid.configuration.fontWeight) {
if (debug) console.info("Found", model[i]["name"], "on", i)
fontWeight.currentIndex = i;
}
}
}
}
}
Row {
height: implicitHeight
width: parent.width
QtControls.Label {
height: parent.height
width: parent.width / 3
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
text: i18n("Font style")
}
QtControls.ComboBox {
id: fontStyle
width: parent.width * 2 / 3
textRole: "label"
model: [
{
'label': i18n("normal"),
'name': "normal"
},
{
'label': i18n("italic"),
'name': "italic"
}
]
onCurrentIndexChanged: cfg_fontStyle = model[currentIndex]["name"]
Component.onCompleted: {
if (debug) console.debug()
for (var i = 0; i < model.length; i++) {
if (model[i]["name"] == plasmoid.configuration.fontStyle) {
if (debug) console.info("Found", model[i]["name"], "on", i)
fontStyle.currentIndex = i;
}
}
}
}
}
Row {
height: implicitHeight
width: parent.width
QtControls.Label {
height: parent.height
width: parent.width / 3
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
text: i18n("Font color")
}
QtControls.Button {
id: selectColor
width: parent.width * 2 / 3
style: QtStyles.ButtonStyle {
background: Rectangle {
color: plasmoid.configuration.fontColor
}
}
text: plasmoid.configuration.fontColor
onClicked: colorDialog.visible = true
}
}
}
QtDialogs.ColorDialog {
id: colorDialog
title: i18n("Select a color")
color: selectColor.text
onAccepted: selectColor.text = colorDialog.color
}
QtDialogs.FontDialog {
id: fontDialog
title: i18n("Select a font")
signal setFont
onAccepted: {
if (debug) console.debug()
selectFont.text = fontDialog.font.family
fontSize.value = fontDialog.font.pointSize
fontStyle.currentIndex = fontDialog.font.italic ? 1 : 0
fontWeight.currentIndex = weight[fontDialog.font.weight]
}
onSetFont: {
if (debug) console.debug()
fontDialog.font = Qt.font({
family: selectFont.text,
pointSize: fontSize.value > 0 ? fontSize.value : 12,
italic: fontStyle.currentIndex == 1,
weight: Font.Normal,
})
}
}
Component.onCompleted: {
if (debug) console.debug()
}
}

View File

@ -0,0 +1,323 @@
/***************************************************************************
* 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/ *
***************************************************************************/
import QtQuick 2.0
import QtQuick.Controls 1.0 as QtControls
import QtQuick.Dialogs 1.1 as QtDialogs
import QtQuick.Layouts 1.0 as QtLayouts
import QtQuick.Controls.Styles 1.3 as QtStyles
import org.kde.plasma.private.awesomewidget 1.0
Item {
id: dataenginePage
// backend
AWKeys {
id: awKeys;
}
AWActions {
id: awActions;
}
width: childrenRect.width
height: childrenRect.height
implicitWidth: pageColumn.implicitWidth
implicitHeight: pageColumn.implicitHeight
property bool debug: awActions.isDebugEnabled()
property variant cfg_dataengine: awActions.readDataEngineConfiguration()
Column {
id: pageColumn
anchors.fill: parent
Row {
height: implicitHeight
width: parent.width
QtControls.Label {
height: parent.height
width: parent.width * 2 / 5
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
text: i18n("ACPI path")
}
QtControls.TextField {
width: parent.width * 3 / 5
text: cfg_dataengine["ACPIPATH"]
onEditingFinished: cfg_dataengine["ACPIPATH"] = text
}
}
Row {
height: implicitHeight
width: parent.width
QtControls.Label {
height: parent.height
width: parent.width * 2 / 5
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
text: i18n("GPU device")
}
QtControls.ComboBox {
id: gpuDev
width: parent.width * 3 / 5
model: ["auto", "disable", "ati", "nvidia"]
Component.onCompleted: {
if (debug) console.debug()
for (var i=0; i<model.length; i++) {
if (model[i] == cfg_dataengine["GPUDEV"]) {
if (debug) console.info("Found", model[i], "on", i)
currentIndex = i;
}
}
}
}
}
Row {
height: implicitHeight
width: parent.width
QtControls.Label {
height: parent.height
width: parent.width * 2 / 5
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
text: i18n("HDD")
}
QtControls.ComboBox {
id: hdd
width: parent.width * 3 / 5
model: awKeys.getHddDevices(true)
Component.onCompleted: {
if (debug) console.debug()
for (var i=0; i<model.length; i++) {
if (model[i] == cfg_dataengine["HDDDEV"]) {
if (debug) console.info("Found", model[i], "on", i)
hdd.currentIndex = i;
}
}
}
}
}
Row {
height: implicitHeight
width: parent.width
QtControls.Label {
height: parent.height
width: parent.width * 2 / 5
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
text: i18n("hddtemp cmd")
}
QtControls.TextField {
width: parent.width * 3 / 5
text: cfg_dataengine["HDDTEMPCMD"]
onEditingFinished: cfg_dataengine["HDDTEMPCMD"] = text
}
}
Row {
height: implicitHeight
width: parent.width
QtControls.Label {
height: parent.height
width: parent.width * 2 / 5
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
text: i18n("MPD address")
}
QtControls.TextField {
width: parent.width * 3 / 5
text: cfg_dataengine["MPDADDRESS"]
onEditingFinished: cfg_dataengine["MPDADDRESS"] = text
}
}
Row {
height: implicitHeight
width: parent.width
QtControls.Label {
height: parent.height
width: parent.width * 2 / 5
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
text: i18n("MPD port")
}
QtControls.SpinBox {
width: parent.width * 3 / 5
minimumValue: 1000
maximumValue: 65535
stepSize: 1
value: cfg_dataengine["MPDPORT"]
onEditingFinished: cfg_dataengine["MPDPORT"] = value
}
}
Row {
height: implicitHeight
width: parent.width
QtControls.Label {
height: parent.height
width: parent.width * 2 / 5
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
text: i18n("MPRIS player name")
}
QtControls.ComboBox {
id: mpris
width: parent.width * 3 / 5
editable: true
model: ["auto", "amarok", "audacious", "clementine", "deadbeef",
"vlc", "qmmp", "xmms2", cfg_dataengine["MPRIS"]]
currentIndex: model.length - 1
}
}
Row {
height: implicitHeight
width: parent.width
QtControls.Label {
height: parent.height
width: parent.width * 2 / 5
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
text: i18n("Music player")
}
QtControls.ComboBox {
id: player
width: parent.width * 3 / 5
model: ["disable", "mpris", "mpd"]
Component.onCompleted: {
if (debug) console.debug()
for (var i=0; i<model.length; i++) {
if (model[i] == cfg_dataengine["PLAYER"]) {
if (debug) console.info("Found", model[i], "on", i)
player.currentIndex = i;
}
}
}
}
}
Row {
height: implicitHeight
width: parent.width
QtControls.Label {
height: parent.height
width: parent.width * 2 / 5
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
text: i18n("Player data symbols")
}
QtControls.SpinBox {
width: parent.width * 3 / 5
minimumValue: 1
maximumValue: 100
stepSize: 1
value: cfg_dataengine["PLAYERSYMBOLS"]
onEditingFinished: cfg_dataengine["PLAYERSYMBOLS"] = value
}
}
Row {
height: implicitHeight
width: parent.width
QtControls.Label {
height: parent.height
width: parent.width * 2 / 5
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
text: i18n("Custom scripts")
}
QtControls.Button {
width: parent.width * 3 / 5
text: i18n("Edit scripts")
onClicked: awKeys.editItem("extscript")
}
}
Row {
height: implicitHeight
width: parent.width
QtControls.Label {
height: parent.height
width: parent.width * 2 / 5
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
text: i18n("Quotes monitor")
}
QtControls.Button {
width: parent.width * 3 / 5
text: i18n("Edit tickers")
onClicked: awKeys.editItem("extquotes")
}
}
Row {
height: implicitHeight
width: parent.width
QtControls.Label {
height: parent.height
width: parent.width * 2 / 5
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
text: i18n("Package manager")
}
QtControls.Button {
width: parent.width * 3 / 5
text: i18n("Edit command")
onClicked: awKeys.editItem("extupgrade")
}
}
Row {
height: implicitHeight
width: parent.width
QtControls.Label {
height: parent.height
width: parent.width * 2 / 5
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
text: i18n("Weather")
}
QtControls.Button {
width: parent.width * 3 / 5
text: i18n("Edit weather")
onClicked: awKeys.editItem("extweather")
}
}
}
Component.onCompleted: {
if (debug) console.debug()
// init submodule
awKeys.initKeys(plasmoid.configuration.text)
}
Component.onDestruction: {
if (debug) console.debug()
cfg_dataengine["GPUDEV"] = gpuDev.currentText
cfg_dataengine["HDDDEV"] = hdd.currentText
cfg_dataengine["PLAYER"] = player.currentText
cfg_dataengine["MPRIS"] = mpris.currentText
awActions.writeDataEngineConfiguration(cfg_dataengine)
}
}

View File

@ -0,0 +1,36 @@
/***************************************************************************
* 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/ *
***************************************************************************/
pragma Singleton
import QtQuick 2.0
QtObject {
property variant fontWeight: {
"light": Font.Light,
"normal": Font.Normal,
"demibold": Font.DemiBold,
"bold": Font.Bold,
"black": Font.Black
}
property variant align: {
"left": Text.AlignLeft,
"center": Text.AlignHCenter,
"right": Text.AlignRight,
"justify": Text.AlignJustify
}
}

View File

@ -0,0 +1,259 @@
/***************************************************************************
* 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/ *
***************************************************************************/
import QtQuick 2.4
import QtQuick.Controls 1.3 as QtControls
import QtQuick.Layouts 1.1
import org.kde.plasma.plasmoid 2.0
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 2.0 as PlasmaComponents
import org.kde.plasma.private.awesomewidget 1.0
import "."
Item {
id: main
// backend
AWKeys {
id: awKeys;
}
AWActions {
id: awActions;
}
property bool debug: awActions.isDebugEnabled()
property variant settings: {
"customTime": plasmoid.configuration.customTime,
"customUptime": plasmoid.configuration.customUptime,
"tempUnits": plasmoid.configuration.tempUnits,
"acOnline": plasmoid.configuration.acOnline,
"acOffline": plasmoid.configuration.acOffline
}
property variant tooltipSettings: {
"tooltipNumber": plasmoid.configuration.tooltipNumber,
"useTooltipBackground": plasmoid.configuration.useTooltipBackground,
"tooltipBackground": plasmoid.configuration.tooltipBackground,
"cpuTooltip": plasmoid.configuration.cpuTooltip,
"cpuclTooltip": plasmoid.configuration.cpuclTooltip,
"memTooltip": plasmoid.configuration.memTooltip,
"swapTooltip": plasmoid.configuration.swapTooltip,
"downTooltip": plasmoid.configuration.downTooltip,
"upTooltip": plasmoid.configuration.downTooltip,
"batTooltip": plasmoid.configuration.batTooltip,
"cpuTooltipColor": plasmoid.configuration.cpuTooltipColor,
"cpuclTooltipColor": plasmoid.configuration.cpuclTooltipColor,
"memTooltipColor": plasmoid.configuration.memTooltipColor,
"swapTooltipColor": plasmoid.configuration.swapTooltipColor,
"downTooltipColor": plasmoid.configuration.downTooltipColor,
"upTooltipColor": plasmoid.configuration.upTooltipColor,
"batTooltipColor": plasmoid.configuration.batTooltipColor,
"batInTooltipColor": plasmoid.configuration.batInTooltipColor,
// additinal field to parse AC status
"acOnline": plasmoid.configuration.acOnline
}
signal dropSource(string sourceName)
signal needTextUpdate(string newText)
signal needToolTipUpdate(string newText)
signal sizeUpdate
// init
Plasmoid.preferredRepresentation: Plasmoid.fullRepresentation
Plasmoid.compactRepresentation: Plasmoid.fullRepresentation
Layout.fillWidth: plasmoid.formFactor != PlasmaCore.Planar
Layout.fillHeight: plasmoid.formFactor != PlasmaCore.Planar
Layout.alignment: Qt.AlignVCenter | Qt.AlignHCenter
Plasmoid.icon: "utilities-system-monitor"
Plasmoid.backgroundHints: plasmoid.configuration.background ? "DefaultBackground" : "NoBackground"
Plasmoid.associatedApplication: "ksysguard"
PlasmaCore.DataSource {
id: systemmonitorDE
engine: "systemmonitor"
connectedSources: systemmonitorDE.sources
interval: plasmoid.configuration.interval
onNewData: {
if (debug) console.debug("Update source", sourceName)
systemmonitorDE.interval = plasmoid.configuration.interval
awKeys.setDataBySource(sourceName, data, settings)
}
onSourceAdded: {
if (debug) console.debug("Source", source)
awKeys.addDevice(source)
}
}
PlasmaCore.DataSource {
id: extsysmonDE
engine: "extsysmon"
connectedSources: extsysmonDE.sources
interval: plasmoid.configuration.interval
onNewData: {
if (debug) console.debug("Update source", sourceName)
extsysmonDE.interval = plasmoid.configuration.interval
awKeys.setDataBySource(sourceName, data, settings)
}
}
PlasmaCore.DataSource {
id: timeDE
engine: "time"
connectedSources: ["Local"]
interval: 1000
onNewData: {
if (debug) console.debug("Update source", sourceName)
awKeys.setDataBySource(sourceName, data, settings)
}
}
// ui
Text {
id: text
anchors.fill: parent
renderType: Text.NativeRendering
textFormat: Text.RichText
wrapMode: Text.NoWrap
horizontalAlignment: general.align[plasmoid.configuration.textAlign]
verticalAlignment: Text.AlignVCenter
color: plasmoid.configuration.fontColor
font.family: plasmoid.configuration.fontFamily
font.italic: plasmoid.configuration.fontStyle == "italic" ? true : false
font.pointSize: plasmoid.configuration.fontSize
font.weight: general.fontWeight[plasmoid.configuration.fontWeight]
PlasmaCore.ToolTipArea {
height: tooltip.height
width: tooltip.width
mainItem: Text {
id: tooltip
height: contentHeight
width: contentWidth
textFormat: Text.RichText
}
}
}
Component.onCompleted: {
if (debug) console.debug()
// actions
plasmoid.setAction("requestKey", i18n("Request key"), "utilities-system-monitor")
plasmoid.setAction("showReadme", i18n("Show README"), "text-x-readme")
plasmoid.setAction("checkUpdates", i18n("Check updates"), "system-software-update")
// plasmoid.setAction("report", i18n("Mail to developers"), "email")
// init submodule
Plasmoid.userConfiguringChanged(false)
// connect data
awKeys.dropSourceFromDataengine.connect(dropSource)
awKeys.needTextToBeUpdated.connect(needTextUpdate)
awKeys.needToolTipToBeUpdated.connect(needToolTipUpdate)
// check updates if required
if (plasmoid.configuration.checkUpdates) return action_checkUpdates()
}
onDropSource: {
if (debug) console.debug()
if (debug) console.debug("Source", sourceName)
systemmonitorDE.disconnectSource(sourceName)
}
onNeedTextUpdate: {
if (debug) console.debug()
text.text = newText
sizeUpdate()
}
onNeedToolTipUpdate: {
if (debug) console.debug()
tooltip.text = newText
}
onSizeUpdate: {
if (debug) console.debug()
// 16 is a magic number
// in other case plasmoid will increase own size on each update
if (plasmoid.configuration.height == 0) {
Layout.minimumHeight = text.contentHeight - 16
Layout.maximumHeight = -1
} else {
Layout.minimumHeight = plasmoid.configuration.height
Layout.maximumHeight = plasmoid.configuration.height
}
if (plasmoid.configuration.width == 0) {
Layout.minimumWidth = text.contentWidth - 16
Layout.maximumWidth = -1
} else {
Layout.minimumWidth = plasmoid.configuration.width
Layout.maximumWidth = plasmoid.configuration.width
}
}
Plasmoid.onUserConfiguringChanged: {
if (plasmoid.userConfiguring) return
if (debug) console.debug()
// init submodule
awKeys.initKeys(plasmoid.configuration.text)
awKeys.initTooltip(tooltipSettings)
awKeys.setPopupEnabled(plasmoid.configuration.notify)
awKeys.setTranslateStrings(plasmoid.configuration.translateStrings)
awKeys.setWrapNewLines(plasmoid.configuration.wrapNewLines)
}
function action_checkUpdates() {
if (debug) console.debug()
return awActions.checkUpdates()
}
function action_showReadme() {
if (debug) console.debug()
return awActions.showReadme()
}
function action_report() {
if (debug) console.debug()
return awActions.sendEmail()
}
function action_requestKey() {
if (debug) console.debug()
return awKeys.graphicalValueByKey()
}
}

View File

@ -0,0 +1 @@
singleton general 1.0 general.qml

View File

@ -0,0 +1,518 @@
/***************************************************************************
* 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/ *
***************************************************************************/
import QtQuick 2.0
import QtQuick.Controls 1.3 as QtControls
import QtQuick.Controls.Styles 1.3 as QtStyles
import QtQuick.Dialogs 1.1 as QtDialogs
import org.kde.plasma.private.awesomewidget 1.0
Item {
id: tooltipPage
// backend
AWActions {
id: awActions;
}
width: childrenRect.width
height: childrenRect.height
implicitWidth: pageColumn.implicitWidth
implicitHeight: pageColumn.implicitHeight
property bool debug: awActions.isDebugEnabled()
property alias cfg_tooltipNumber: tooltipNumber.value
property alias cfg_useTooltipBackground: useTooltipBackground.checked
property alias cfg_tooltipBackground: tooltipBackground.text
property alias cfg_cpuTooltip: cpuTooltip.checked
property alias cfg_cpuTooltipColor: cpuTooltipColor.text
property alias cfg_cpuclTooltip: cpuclTooltip.checked
property alias cfg_cpuclTooltipColor: cpuclTooltipColor.text
property alias cfg_memTooltip: memTooltip.checked
property alias cfg_memTooltipColor: memTooltipColor.text
property alias cfg_swapTooltip: swapTooltip.checked
property alias cfg_swapTooltipColor: swapTooltipColor.text
property alias cfg_downTooltip: downTooltip.checked
property alias cfg_downTooltipColor: downTooltipColor.text
property alias cfg_upTooltipColor: upTooltipColor.text
property alias cfg_batTooltip: batTooltip.checked
property alias cfg_batTooltipColor: batTooltipColor.text
property alias cfg_batInTooltipColor: batInTooltipColor.text
Column {
id: pageColumn
anchors.fill: parent
QtControls.Label {
width: parent.width
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
wrapMode: Text.WordWrap
text: i18n("CPU, CPU clock, memory, swap and network labels support graphical tooltip. To enable them just make needed checkbox fully checked.")
}
Row {
height: implicitHeight
width: parent.width
QtControls.Label {
height: parent.height
width: parent.width * 2 / 5
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
text: i18n("Number of values for tooltips")
}
QtControls.SpinBox {
id: tooltipNumber
width: parent.width * 3 / 5
minimumValue: 50
maximumValue: 1000
stepSize: 25
value: plasmoid.configuration.tooltipNumber
}
}
Row {
height: implicitHeight
width: parent.width
QtControls.Label {
height: parent.height
width: parent.width * 2 / 5 - useTooltipBackground.width
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
text: i18n("Background")
}
QtControls.CheckBox {
id: useTooltipBackground
height: parent.height
width: implicitWidth
style: QtStyles.CheckBoxStyle {
indicator: Rectangle {
implicitWidth: 16
implicitHeight: 16
radius: 3
border.width: 1
border.color: control.activeFocus ? "darkblue" : "gray"
Rectangle {
visible: control.checked
radius: 1
anchors.fill: parent
anchors.margins: 4
color: "#555555"
border.color: "#333333"
}
}
}
}
QtControls.Button {
id: tooltipBackground
width: parent.width * 3 / 5
style: QtStyles.ButtonStyle {
background: Rectangle {
color: plasmoid.configuration.tooltipBackground
}
}
text: plasmoid.configuration.tooltipBackground
onClicked: tooltipBackgroundDialog.visible = true
}
QtDialogs.ColorDialog {
id: tooltipBackgroundDialog
title: i18n("Select a color")
color: tooltipBackground.text
onAccepted: tooltipBackground.text = tooltipBackgroundDialog.color
}
}
Row {
height: implicitHeight
width: parent.width
QtControls.Label {
height: parent.height
width: parent.width * 2 / 5 - cpuTooltip.width
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
text: i18n("CPU color")
}
QtControls.CheckBox {
id: cpuTooltip
height: parent.height
width: implicitWidth
style: QtStyles.CheckBoxStyle {
indicator: Rectangle {
implicitWidth: 16
implicitHeight: 16
radius: 3
border.width: 1
border.color: control.activeFocus ? "darkblue" : "gray"
Rectangle {
visible: control.checked
radius: 1
anchors.fill: parent
anchors.margins: 4
color: "#555555"
border.color: "#333333"
}
}
}
}
QtControls.Button {
id: cpuTooltipColor
width: parent.width * 3 / 5
style: QtStyles.ButtonStyle {
background: Rectangle {
color: plasmoid.configuration.cpuTooltipColor
}
}
text: plasmoid.configuration.cpuTooltipColor
onClicked: cpuTooltipColorDialog.visible = true
}
QtDialogs.ColorDialog {
id: cpuTooltipColorDialog
title: i18n("Select a color")
color: cpuTooltipColor.text
onAccepted: cpuTooltipColor.text = cpuTooltipColorDialog.color
}
}
Row {
height: implicitHeight
width: parent.width
QtControls.Label {
height: parent.height
width: parent.width * 2 / 5 - cpuclTooltip.width
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
text: i18n("CPU clock color")
}
QtControls.CheckBox {
id: cpuclTooltip
height: parent.height
width: implicitWidth
style: QtStyles.CheckBoxStyle {
indicator: Rectangle {
implicitWidth: 16
implicitHeight: 16
radius: 3
border.width: 1
border.color: control.activeFocus ? "darkblue" : "gray"
Rectangle {
visible: control.checked
radius: 1
anchors.fill: parent
anchors.margins: 4
color: "#555555"
border.color: "#333333"
}
}
}
}
QtControls.Button {
id: cpuclTooltipColor
width: parent.width * 3 / 5
style: QtStyles.ButtonStyle {
background: Rectangle {
color: plasmoid.configuration.cpuclTooltipColor
}
}
text: plasmoid.configuration.cpuclTooltipColor
onClicked: cpuclTooltipColorDialog.visible = true
}
QtDialogs.ColorDialog {
id: cpuclTooltipColorDialog
title: i18n("Select a color")
color: cpuclTooltipColor.text
onAccepted: cpuclTooltipColor.text = cpuclTooltipColorDialog.color
}
}
Row {
height: implicitHeight
width: parent.width
QtControls.Label {
height: parent.height
width: parent.width * 2 / 5 - memTooltip.width
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
text: i18n("Memory color")
}
QtControls.CheckBox {
id: memTooltip
height: parent.height
width: implicitWidth
style: QtStyles.CheckBoxStyle {
indicator: Rectangle {
implicitWidth: 16
implicitHeight: 16
radius: 3
border.width: 1
border.color: control.activeFocus ? "darkblue" : "gray"
Rectangle {
visible: control.checked
radius: 1
anchors.fill: parent
anchors.margins: 4
color: "#555555"
border.color: "#333333"
}
}
}
}
QtControls.Button {
id: memTooltipColor
width: parent.width * 3 / 5
style: QtStyles.ButtonStyle {
background: Rectangle {
color: plasmoid.configuration.memTooltipColor
}
}
text: plasmoid.configuration.memTooltipColor
onClicked: memTooltipColorDialog.visible = true
}
QtDialogs.ColorDialog {
id: memTooltipColorDialog
title: i18n("Select a color")
color: memTooltipColor.text
onAccepted: memTooltipColor.text = memTooltipColorDialog.color
}
}
Row {
height: implicitHeight
width: parent.width
QtControls.Label {
height: parent.height
width: parent.width * 2 / 5 - swapTooltip.width
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
text: i18n("Swap color")
}
QtControls.CheckBox {
id: swapTooltip
height: parent.height
width: implicitWidth
style: QtStyles.CheckBoxStyle {
indicator: Rectangle {
implicitWidth: 16
implicitHeight: 16
radius: 3
border.width: 1
border.color: control.activeFocus ? "darkblue" : "gray"
Rectangle {
visible: control.checked
radius: 1
anchors.fill: parent
anchors.margins: 4
color: "#555555"
border.color: "#333333"
}
}
}
}
QtControls.Button {
id: swapTooltipColor
width: parent.width * 3 / 5
style: QtStyles.ButtonStyle {
background: Rectangle {
color: plasmoid.configuration.swapTooltipColor
}
}
text: plasmoid.configuration.swapTooltipColor
onClicked: swapTooltipColorDialog.visible = true
}
QtDialogs.ColorDialog {
id: swapTooltipColorDialog
title: i18n("Select a color")
color: swapTooltipColor.text
onAccepted: swapTooltipColor.text = swapTooltipColorDialog.color
}
}
Row {
height: implicitHeight
width: parent.width
QtControls.Label {
height: parent.height
width: parent.width * 2 / 5 - downTooltip.width
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
text: i18n("Download speed color")
}
QtControls.CheckBox {
id: downTooltip
height: parent.height
width: implicitWidth
style: QtStyles.CheckBoxStyle {
indicator: Rectangle {
implicitWidth: 16
implicitHeight: 16
radius: 3
border.width: 1
border.color: control.activeFocus ? "darkblue" : "gray"
Rectangle {
visible: control.checked
radius: 1
anchors.fill: parent
anchors.margins: 4
color: "#555555"
border.color: "#333333"
}
}
}
}
QtControls.Button {
id: downTooltipColor
width: parent.width * 3 / 5
style: QtStyles.ButtonStyle {
background: Rectangle {
color: plasmoid.configuration.downTooltipColor
}
}
text: plasmoid.configuration.downTooltipColor
onClicked: downTooltipColorDialog.visible = true
}
QtDialogs.ColorDialog {
id: downTooltipColorDialog
title: i18n("Select a color")
color: downTooltipColor.text
onAccepted: downTooltipColor.text = downTooltipColorDialog.color
}
}
Row {
height: implicitHeight
width: parent.width
QtControls.Label {
height: parent.height
width: parent.width * 2 / 5
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
text: i18n("Upload speed color")
}
QtControls.Button {
id: upTooltipColor
width: parent.width * 3 / 5
style: QtStyles.ButtonStyle {
background: Rectangle {
color: plasmoid.configuration.upTooltipColor
}
}
text: plasmoid.configuration.upTooltipColor
onClicked: upTooltipColorDialog.visible = true
}
QtDialogs.ColorDialog {
id: upTooltipColorDialog
title: i18n("Select a color")
color: upTooltipColor.text
onAccepted: upTooltipColor.text = upTooltipColorDialog.color
}
}
Row {
height: implicitHeight
width: parent.width
QtControls.Label {
height: parent.height
width: parent.width * 2 / 5 - batTooltip.width
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
text: i18n("Battery active color")
}
QtControls.CheckBox {
id: batTooltip
height: parent.height
width: implicitWidth
style: QtStyles.CheckBoxStyle {
indicator: Rectangle {
implicitWidth: 16
implicitHeight: 16
radius: 3
border.width: 1
border.color: control.activeFocus ? "darkblue" : "gray"
Rectangle {
visible: control.checked
radius: 1
anchors.fill: parent
anchors.margins: 4
color: "#555555"
border.color: "#333333"
}
}
}
}
QtControls.Button {
id: batTooltipColor
width: parent.width * 3 / 5
style: QtStyles.ButtonStyle {
background: Rectangle {
color: plasmoid.configuration.batTooltipColor
}
}
text: plasmoid.configuration.batTooltipColor
onClicked: batTooltipColorDialog.visible = true
}
QtDialogs.ColorDialog {
id: batTooltipColorDialog
title: i18n("Select a color")
color: batTooltipColor.text
onAccepted: batTooltipColor.text = batTooltipColorDialog.color
}
}
Row {
height: implicitHeight
width: parent.width
QtControls.Label {
height: parent.height
width: parent.width * 2 / 5
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
text: i18n("Battery inactive color")
}
QtControls.Button {
id: batInTooltipColor
width: parent.width * 3 / 5
style: QtStyles.ButtonStyle {
background: Rectangle {
color: plasmoid.configuration.batInTooltipColor
}
}
text: plasmoid.configuration.batInTooltipColor
onClicked: batInTooltipColorDialog.visible = true
}
QtDialogs.ColorDialog {
id: batInTooltipColorDialog
title: i18n("Select a color")
color: batInTooltipColor.text
onAccepted: batInTooltipColor.text = batInTooltipColorDialog.color
}
}
}
Component.onCompleted: {
if (debug) console.debug()
}
}

View File

@ -0,0 +1,397 @@
/***************************************************************************
* 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/ *
***************************************************************************/
import QtQuick 2.0
import QtQuick.Controls 1.3 as QtControls
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.private.awesomewidget 1.0
Item {
id: widgetPage
// backend
AWKeys {
id: awKeys;
}
AWActions {
id: awActions;
}
width: childrenRect.width
height: childrenRect.height
implicitWidth: pageColumn.implicitWidth
implicitHeight: pageColumn.implicitHeight
property bool debug: awActions.isDebugEnabled()
property variant settings: {
"customTime": plasmoid.configuration.customTime,
"customUptime": plasmoid.configuration.customUptime,
"tempUnits": plasmoid.configuration.tempUnits,
"acOnline": plasmoid.configuration.acOnline,
"acOffline": plasmoid.configuration.acOffline
}
property variant tooltipSettings: {
"tooltipNumber": plasmoid.configuration.tooltipNumber,
"useTooltipBackground": plasmoid.configuration.useTooltipBackground,
"tooltipBackgroung": plasmoid.configuration.tooltipBackgroung,
"cpuTooltip": plasmoid.configuration.cpuTooltip,
"cpuclTooltip": plasmoid.configuration.cpuclTooltip,
"memTooltip": plasmoid.configuration.memTooltip,
"swapTooltip": plasmoid.configuration.swapTooltip,
"downTooltip": plasmoid.configuration.downTooltip,
"upTooltip": plasmoid.configuration.downTooltip,
"batTooltip": plasmoid.configuration.batTooltip,
"cpuTooltipColor": plasmoid.configuration.cpuTooltipColor,
"cpuclTooltipColor": plasmoid.configuration.cpuclTooltipColor,
"memTooltipColor": plasmoid.configuration.memTooltipColor,
"swapTooltipColor": plasmoid.configuration.swapTooltipColor,
"downTooltipColor": plasmoid.configuration.downTooltipColor,
"upTooltipColor": plasmoid.configuration.upTooltipColor,
"batTooltipColor": plasmoid.configuration.batTooltipColor,
"batInTooltipColor": plasmoid.configuration.batInTooltipColor
}
property alias cfg_text: textPattern.text
Column {
id: pageColumn
anchors.fill: parent
QtControls.Label {
width: parent.width
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
wrapMode: Text.WordWrap
text: i18n("Detailed information may be found on <a href=\"http://arcanis.name/projects/awesome-widgets/\">project homepage</a>")
onLinkActivated: Qt.openUrlExternally(link);
}
Row {
height: implicitHeight
width: parent.width
QtControls.Button {
width: parent.width * 3 / 12
text: i18n("Font")
iconName: "font"
onClicked: {
if (debug) console.debug("Font button")
var defaultFont = {
"color": plasmoid.configuration.fontColor,
"family": plasmoid.configuration.fontFamily,
"size": plasmoid.configuration.fontSize
}
var font = awActions.getFont(defaultFont)
var pos = textPattern.cursorPosition
var selected = textPattern.selectedText
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
textPattern.insert(pos, "<span style=\"color:" + font.color +
"; font-family:'" + font.family +
"'; font-size:" + font.size + "pt;\">" +
selected + "</span>")
}
}
QtControls.Button {
width: parent.width / 12
iconName: "format-indent-more"
onClicked: {
if (debug) console.debug("Indent button")
var pos = textPattern.cursorPosition
var selected = textPattern.selectedText
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
textPattern.insert(pos, selected + "<br>\n")
}
}
QtControls.Button {
width: parent.width / 12
iconName: "format-text-bold"
onClicked: {
if (debug) console.debug("Bold button")
var pos = textPattern.cursorPosition
var selected = textPattern.selectedText
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
textPattern.insert(pos, "<b>" + selected + "</b>")
}
}
QtControls.Button {
width: parent.width / 12
iconName: "format-text-italic"
onClicked: {
if (debug) console.debug("Italic button")
var pos = textPattern.cursorPosition
var selected = textPattern.selectedText
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
textPattern.insert(pos, "<i>" + selected + "</i>")
}
}
QtControls.Button {
width: parent.width / 12
iconName: "format-text-underline"
onClicked: {
if (debug) console.debug("Underline button")
var pos = textPattern.cursorPosition
var selected = textPattern.selectedText
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
textPattern.insert(pos, "<u>" + selected + "</u>")
}
}
QtControls.Button {
width: parent.width / 12
iconName: "format-text-strikethrough"
onClicked: {
if (debug) console.debug("Strike button")
var pos = textPattern.cursorPosition
var selected = textPattern.selectedText
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
textPattern.insert(pos, "<s>" + selected + "</s>")
}
}
QtControls.Button {
width: parent.width / 12
iconName: "format-justify-left"
onClicked: {
if (debug) console.debug("Left button")
var pos = textPattern.cursorPosition
var selected = textPattern.selectedText
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
textPattern.insert(pos, "<p align=\"left\">" + selected + "</p>")
}
}
QtControls.Button {
width: parent.width / 12
iconName: "format-justify-center"
onClicked: {
if (debug) console.debug("Center button")
var pos = textPattern.cursorPosition
var selected = textPattern.selectedText
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
textPattern.insert(pos, "<p align=\"center\">" + selected + "</p>")
}
}
QtControls.Button {
width: parent.width / 12
iconName: "format-justify-right"
onClicked: {
if (debug) console.debug("Right button")
var pos = textPattern.cursorPosition
var selected = textPattern.selectedText
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
textPattern.insert(pos, "<p align=\"right\">" + selected + "</p>")
}
}
QtControls.Button {
width: parent.width / 12
iconName: "format-justify-fill"
onClicked: {
if (debug) console.debug("Justify button")
var pos = textPattern.cursorPosition
var selected = textPattern.selectedText
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
textPattern.insert(pos, "<p align=\"justify\">" + selected + "</p>")
}
}
}
Row {
height: implicitHeight
width: parent.width
QtControls.ComboBox {
width: (parent.width - addTagButton.width - showValueButton.width - addLambdaButton.width) / 2
textRole: "label"
model: [
{
'label': i18n("AC"),
'regexp': "^(ac|bat).*"
},
{
'label': i18n("Bars"),
'regexp': "^bar.*"
},
{
'label': i18n("CPU"),
'regexp': "^(cpu|gpu|la|ps|temp(?!erature)).*"
},
{
'label': i18n("Desktops"),
'regexp': "^(n|t)?desktop(s)?"
},
{
'label': i18n("HDD"),
'regexp': "^hdd.*"
},
{
'label': i18n("Memory"),
'regexp': "^(mem|swap).*"
},
{
'label': i18n("Network"),
'regexp': "^(netdev|(down|up(?!time)).*)"
},
{
'label': i18n("Music player"),
'regexp': "(^|d|s)(album|artist|duration|progress|title)"
},
{
'label': i18n("Scripts"),
'regexp': "^custom.*"
},
{
'label': i18n("Time"),
'regexp': ".*time$"
},
{
'label': i18n("Quotes"),
'regexp': "^(perc)?(ask|bid|price)(chg)?.*"
},
{
'label': i18n("Upgrades"),
'regexp': "^pkgcount.*"
},
{
'label': i18n("Weathers"),
'regexp': "^(weather(Id)?|humidity|pressure|temperature|timestamp)"
}
]
onCurrentIndexChanged: {
if (debug) console.debug()
tags.model = awKeys.dictKeys(true, model[currentIndex]["regexp"])
if (debug) console.info("Init model", tags.model, "for", model[currentIndex]["label"])
tags.currentIndex = -1
}
}
QtControls.ComboBox {
id: tags
width: (parent.width - addTagButton.width - showValueButton.width - addLambdaButton.width) / 2
}
QtControls.Button {
id: addTagButton
text: i18n("Add")
onClicked: {
if (!tags.currentText) return
if (debug) console.debug("Add tag button")
var pos = textPattern.cursorPosition
var selected = textPattern.selectedText
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
textPattern.insert(pos, selected + "$" + tags.currentText)
}
}
QtControls.Button {
id: showValueButton
text: i18n("Show value")
onClicked: {
if (!tags.currentText) return
if (debug) console.debug("Show tag button")
var message = i18n("Tag: %1", tags.currentText)
message += "<br>"
message += i18n("Value: %1", awKeys.valueByKey(tags.currentText))
message += "<br>"
message += i18n("Info: %1", awKeys.infoByKey(tags.currentText))
awActions.sendNotification("tag", message)
}
}
QtControls.Button {
id: addLambdaButton
text: i18n("Add lambda")
onClicked: {
if (debug) console.debug("Lambda button")
var pos = textPattern.cursorPosition
var selected = textPattern.selectedText
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
textPattern.insert(pos, selected + "${{\n\n}}")
}
}
}
Row {
height: implicitHeight
width: parent.width
QtControls.Button {
width: parent.width
text: i18n("Edit bars")
onClicked: awKeys.editItem("graphicalitem")
}
}
QtControls.TextArea {
id: textPattern
width: parent.width
height: parent.height * 4 / 5
textFormat: TextEdit.PlainText
text: plasmoid.configuration.text
}
}
// we need to initializate DataEngines here too
// because we need to get keys and values
PlasmaCore.DataSource {
id: systemmonitorDE
engine: "systemmonitor"
connectedSources: systemmonitorDE.sources
interval: 5000
onNewData: {
if (debug) console.debug("Update source", sourceName)
awKeys.setDataBySource(sourceName, data, settings)
}
}
PlasmaCore.DataSource {
id: extsysmonDE
engine: "extsysmon"
connectedSources: extsysmonDE.sources
interval: 5000
onNewData: {
if (debug) console.debug("Update source", sourceName)
awKeys.setDataBySource(sourceName, data, settings)
}
}
PlasmaCore.DataSource {
id: timeDE
engine: "time"
connectedSources: ["Local"]
interval: 5000
onNewData: {
if (debug) console.debug("Update source", sourceName)
awKeys.setDataBySource(sourceName, data, settings)
}
}
Component.onCompleted: {
if (debug) console.debug()
// init submodule
awKeys.initKeys(plasmoid.configuration.text)
}
}

View File

@ -0,0 +1,28 @@
[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-ServiceTypes=Plasma/Applet
X-Plasma-API=declarativeappletscript
X-Plasma-MainScript=ui/main.qml
X-Plasma-RemoteLocation=
X-KDE-PluginInfo-Author=Evgeniy Alekseev aka arcanis
X-KDE-PluginInfo-Email=esalexeev@gmail.com
X-KDE-PluginInfo-Name=org.kde.plasma.awesomewidget
X-KDE-PluginInfo-Version=2.4.0
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,25 @@
set(PLUGIN_NAME awplugin)
add_definitions(-DTRANSLATION_DOMAIN=\"plasma_applet_org.kde.plasma.awesomewidget\")
include_directories(
${CMAKE_SOURCE_DIR}
${CMAKE_BINARY_DIR}
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_BINARY_DIR}/../
${CMAKE_CURRENT_SOURCE_DIR}/../../${PROJECT_LIBRARY}/
${PROJECT_TRDPARTY_DIR}
${Qt_INCLUDE}
${Kf5_INCLUDE}
)
file(GLOB SUBPROJECT_SOURCE *.cpp ${PROJECT_TRDPARTY_DIR}/fontdialog/*.cpp ${CMAKE_SOURCE_DIR}/*.cpp)
file(GLOB SUBPROJECT_UI *.ui)
file(GLOB SUBPROJECT_NOTIFY *.notifyrc)
qt5_wrap_ui(SUBPROJECT_UI_HEADER ${SUBPROJECT_UI})
add_library(${PLUGIN_NAME} SHARED ${SUBPROJECT_SOURCE} ${SUBPROJECT_UI_HEADER})
target_link_libraries(${PLUGIN_NAME} ${PROJECT_LIBRARY} ${Qt_LIBRARIES} ${Kf5_LIBRARIES})
install(TARGETS ${PLUGIN_NAME} DESTINATION ${QML_INSTALL_DIR}/org/kde/plasma/private/awesomewidget)
install(FILES qmldir DESTINATION ${QML_INSTALL_DIR}/org/kde/plasma/private/awesomewidget)
install(FILES ${SUBPROJECT_NOTIFY} DESTINATION ${KNOTIFYRC_INSTALL_DIR})

View File

@ -0,0 +1,281 @@
/***************************************************************************
* 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 "awactions.h"
#include <KI18n/KLocalizedString>
#include <KNotifications/KNotification>
#include <QDesktopServices>
#include <QDir>
#include <QJsonDocument>
#include <QJsonParseError>
#include <QMessageBox>
#include <QNetworkAccessManager>
#include <QNetworkRequest>
#include <QNetworkReply>
#include <QProcess>
#include <QProcessEnvironment>
#include <QSettings>
#include <QStandardPaths>
#include <fontdialog/fontdialog.h>
#include "awdebug.h"
#include "version.h"
AWActions::AWActions(QObject *parent)
: QObject(parent)
{
qCDebug(LOG_AW);
}
AWActions::~AWActions()
{
qCDebug(LOG_AW);
}
void AWActions::checkUpdates()
{
qCDebug(LOG_AW);
QNetworkAccessManager *manager = new QNetworkAccessManager(this);
connect(manager, SIGNAL(finished(QNetworkReply *)), this, SLOT(versionReplyRecieved(QNetworkReply *)));
manager->get(QNetworkRequest(QUrl(VERSION_API)));
}
bool AWActions::dropCache() const
{
qCDebug(LOG_AW);
QString fileName = QString("%1/awesomewidgets.ndx")
.arg(QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation));
return QFile(fileName).remove();
}
bool AWActions::isDebugEnabled() const
{
qCDebug(LOG_AW);
return LOG_AW().isDebugEnabled();
}
void AWActions::runCmd(const QString cmd) const
{
qCDebug(LOG_AW);
qCDebug(LOG_AW) << "Cmd" << cmd;
QProcess command;
sendNotification(QString("Info"), i18n("Run %1", cmd));
command.startDetached(cmd);
}
void AWActions::sendEmail() const
{
qCDebug(LOG_AW);
}
void AWActions::showReadme() const
{
qCDebug(LOG_AW);
QDesktopServices::openUrl(QString(HOMEPAGE));
}
QString AWActions::getAboutText(const QString type) const
{
qCDebug(LOG_AW);
qCDebug(LOG_AW) << "Type" << type;
QString text;
if (type == QString("header"))
text = QString(NAME);
else if (type == QString("version"))
text = i18n("Version %1 (build date %2)", QString(VERSION), QString(BUILD_DATE));
else if (type == QString("description"))
text = i18n("A set of minimalistic plasmoid widgets");
else if (type == QString("links"))
text = i18n("Links:") + QString("<br>") +
QString("<a href=\"%1\">%2</a><br>").arg(QString(HOMEPAGE)).arg(i18n("Homepage")) +
QString("<a href=\"%1\">%2</a><br>").arg(QString(REPOSITORY)).arg(i18n("Repository")) +
QString("<a href=\"%1\">%2</a><br>").arg(QString(BUGTRACKER)).arg(i18n("Bugtracker")) +
QString("<a href=\"%1\">%2</a><br>").arg(QString(TRANSLATION)).arg(i18n("Translation issue")) +
QString("<a href=\"%1\">%2</a><br>").arg(QString(AUR_PACKAGES)).arg(i18n("AUR packages")) +
QString("<a href=\"%1\">%2</a>").arg(QString(OPENSUSE_PACKAGES)).arg(i18n("openSUSE packages"));
else if (type == QString("copy"))
text = QString("<small>&copy; %1 <a href=\"mailto:%2\">%3</a><br>").arg(QString(DATE)).arg(QString(EMAIL)).arg(QString(AUTHOR)) +
i18n("This software is licensed under %1", QString(LICENSE)) + QString("</small>");
else if (type == QString("translators"))
text = i18n("Translators: %1", QString(TRANSLATORS));
else if (type == QString("3rdparty")) {
QStringList trdPartyList = QString(TRDPARTY_LICENSE).split(QChar(';'), QString::SkipEmptyParts);
for (int i=0; i<trdPartyList.count(); i++)
trdPartyList[i] = QString("<a href=\"%3\">%1</a> (%2 license)")
.arg(trdPartyList.at(i).split(QChar(','))[0])
.arg(trdPartyList.at(i).split(QChar(','))[1])
.arg(trdPartyList.at(i).split(QChar(','))[2]);
text = i18n("This software uses: %1", trdPartyList.join(QString(", ")));
}
return text;
}
QVariantMap AWActions::getFont(const QVariantMap defaultFont) const
{
qCDebug(LOG_AW);
qCDebug(LOG_AW) << "Default font is" << defaultFont;
QVariantMap fontMap;
CFont defaultCFont = CFont(defaultFont[QString("family")].toString(),
defaultFont[QString("size")].toInt(),
400, false, defaultFont[QString("color")].toString());
CFont font = CFontDialog::getFont(i18n("Select font"), defaultCFont,
false, false);
fontMap[QString("color")] = font.color().name();
fontMap[QString("family")] = font.family();
fontMap[QString("size")] = font.pointSize();
return fontMap;
}
QVariantMap AWActions::readDataEngineConfiguration() const
{
qCDebug(LOG_AW);
QString fileName = QStandardPaths::locate(QStandardPaths::ConfigLocation, QString("plasma-dataengine-extsysmon.conf"));
qCInfo(LOG_AW) << "Configuration file" << fileName;
QSettings settings(fileName, QSettings::IniFormat);
QVariantMap configuration;
settings.beginGroup(QString("Configuration"));
configuration[QString("ACPIPATH")] = settings.value(QString("ACPIPATH"), QString("/sys/class/power_supply/"));
configuration[QString("GPUDEV")] = settings.value(QString("GPUDEV"), QString("auto"));
configuration[QString("HDDDEV")] = settings.value(QString("HDDDEV"), QString("all"));
configuration[QString("HDDTEMPCMD")] = settings.value(QString("HDDTEMPCMD"), QString("sudo smartctl -a"));
configuration[QString("MPDADDRESS")] = settings.value(QString("MPDADDRESS"), QString("localhost"));
configuration[QString("MPDPORT")] = settings.value(QString("MPDPORT"), QString("6600"));
configuration[QString("MPRIS")] = settings.value(QString("MPRIS"), QString("auto"));
configuration[QString("PLAYER")] = settings.value(QString("PLAYER"), QString("mpris"));
configuration[QString("PLAYERSYMBOLS")] = settings.value(QString("PLAYERSYMBOLS"), QString("10"));
settings.endGroup();
return configuration;
}
void AWActions::writeDataEngineConfiguration(const QVariantMap configuration) const
{
qCDebug(LOG_AW);
QString fileName = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) + QString("/plasma-dataengine-extsysmon.conf");
QSettings settings(fileName, QSettings::IniFormat);
qCInfo(LOG_AW) << "Configuration file" << settings.fileName();
settings.beginGroup(QString("Configuration"));
settings.setValue(QString("ACPIPATH"), configuration[QString("ACPIPATH")]);
settings.setValue(QString("GPUDEV"), configuration[QString("GPUDEV")]);
settings.setValue(QString("HDDDEV"), configuration[QString("HDDDEV")]);
settings.setValue(QString("HDDTEMPCMD"), configuration[QString("HDDTEMPCMD")]);
settings.setValue(QString("MPDADDRESS"), configuration[QString("MPDADDRESS")]);
settings.setValue(QString("MPDPORT"), configuration[QString("MPDPORT")]);
settings.setValue(QString("MPRIS"), configuration[QString("MPRIS")]);
settings.setValue(QString("PLAYER"), configuration[QString("PLAYER")]);
settings.setValue(QString("PLAYERSYMBOLS"), configuration[QString("PLAYERSYMBOLS")]);
settings.endGroup();
settings.sync();
}
void AWActions::sendNotification(const QString eventId, const QString message,
const bool enablePopup)
{
qCDebug(LOG_AW);
qCDebug(LOG_AW) << "Event" << eventId;
qCDebug(LOG_AW) << "Message" << message;
if ((eventId == QString("event")) && (!enablePopup)) return;
KNotification *notification = KNotification::event(eventId, QString("Awesome Widget ::: %1").arg(eventId), message);
notification->setComponentName(QString("plasma-applet-org.kde.plasma.awesome-widget"));
}
void AWActions::showUpdates(QString version) const
{
qCDebug(LOG_AW);
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(nullptr, i18n("There are updates"), text,
QMessageBox::Ok | QMessageBox::Cancel);
switch (select) {
case QMessageBox::Ok:
QDesktopServices::openUrl(QString(RELEASES) + version);
break;
}
}
void AWActions::versionReplyRecieved(QNetworkReply *reply) const
{
qCDebug(LOG_AW);
qCDebug(LOG_AW) << "Return code" << reply->error();
qCDebug(LOG_AW) << "Reply error message" << reply->errorString();
QJsonParseError error;
QJsonDocument jsonDoc = QJsonDocument::fromJson(reply->readAll(), &error);
reply->deleteLater();
if ((reply->error() != QNetworkReply::NoError) ||
(error.error != QJsonParseError::NoError)) {
qCWarning(LOG_AW) << "Parse error" << error.errorString();
return;
}
// convert to map
QVariantMap firstRelease = jsonDoc.toVariant().toList().first().toMap();
QString version = firstRelease[QString("tag_name")].toString();
version.remove(QString("V."));
qCInfo(LOG_AW) << "Found version" << version;
int old_major = QString(VERSION).split(QChar('.')).at(0).toInt();
int old_minor = QString(VERSION).split(QChar('.')).at(1).toInt();
int old_patch = QString(VERSION).split(QChar('.')).at(2).toInt();
int new_major = QString(version).split(QChar('.')).at(0).toInt();
int new_minor = QString(version).split(QChar('.')).at(1).toInt();
int new_patch = QString(version).split(QChar('.')).at(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)))
return showUpdates(version);
}

View File

@ -0,0 +1,61 @@
/***************************************************************************
* 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 AWACTIONS_H
#define AWACTIONS_H
#include <QObject>
#include <QVariant>
class QNetworkReply;
class AWActions : public QObject
{
Q_OBJECT
public:
explicit AWActions(QObject *parent = nullptr);
virtual ~AWActions();
Q_INVOKABLE void checkUpdates();
Q_INVOKABLE bool dropCache() const;
Q_INVOKABLE bool isDebugEnabled() const;
Q_INVOKABLE void runCmd(const QString cmd = QString("/usr/bin/true")) const;
Q_INVOKABLE void sendEmail() const;
Q_INVOKABLE void showReadme() const;
// configuration slots
Q_INVOKABLE QString getAboutText(const QString type = QString("header")) const;
Q_INVOKABLE QVariantMap getFont(const QVariantMap defaultFont) const;
// dataengine
Q_INVOKABLE QVariantMap readDataEngineConfiguration() const;
Q_INVOKABLE void writeDataEngineConfiguration(const QVariantMap configuration) const;
public slots:
Q_INVOKABLE static void sendNotification(const QString eventId, const QString message,
const bool enablePopup = false);
private slots:
void showUpdates(QString version) const;
void versionReplyRecieved(QNetworkReply *reply) const;
private:
};
#endif /* AWACTIONS_H */

View File

@ -0,0 +1,32 @@
/***************************************************************************
* 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 "awesomewidget.h"
#include <QtQml>
#include "awactions.h"
#include "awkeys.h"
void AWPlugin::registerTypes(const char *uri)
{
Q_ASSERT(uri == QLatin1String("org.kde.plasma.private.awesomewidget"));
qmlRegisterType<AWActions>(uri, 1, 0, "AWActions");
qmlRegisterType<AWKeys>(uri, 1, 0, "AWKeys");
}

View File

@ -15,31 +15,21 @@
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#ifndef CUSTOMLABEL_H
#define CUSTOMLABEL_H
#include <QLabel>
#ifndef AWPLUGIN_H
#define AWPLUGIN_H
#include <QQmlExtensionPlugin>
class AwesomeWidget;
class CustomLabel : public QLabel
class AWPlugin : public QQmlExtensionPlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
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;
void registerTypes(const char *uri);
};
#endif /* CUSTOMLABEL_H */
#endif /* AWPLUGIN_H */

View File

@ -0,0 +1,960 @@
/***************************************************************************
* 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 "awkeys.h"
#include <KI18n/KLocalizedString>
#include <QDateTime>
#include <QDir>
#include <QInputDialog>
#include <QLocale>
#include <QNetworkInterface>
#include <QRegExp>
#include <QScriptEngine>
#include <QSettings>
#include <QStandardPaths>
#include <QThread>
#include "awactions.h"
#include "awdebug.h"
#include "awtooltip.h"
#include "extquotes.h"
#include "extscript.h"
#include "extupgrade.h"
#include "extweather.h"
#include "graphicalitem.h"
AWKeys::AWKeys(QObject *parent)
: QObject(parent)
{
qCDebug(LOG_AW);
// logging
qSetMessagePattern(LOG_FORMAT);
// backend
graphicalItems = new ExtItemAggregator<GraphicalItem>(nullptr, QString("desktops"));
extQuotes = new ExtItemAggregator<ExtQuotes>(nullptr, QString("quotes"));
extScripts = new ExtItemAggregator<ExtScript>(nullptr, QString("scripts"));
extUpgrade = new ExtItemAggregator<ExtUpgrade>(nullptr, QString("upgrade"));
extWeather = new ExtItemAggregator<ExtWeather>(nullptr, QString("weather"));
connect(this, SIGNAL(needToBeUpdated()), this, SLOT(dataUpdate()));
}
AWKeys::~AWKeys()
{
qCDebug(LOG_AW);
if (toolTip != nullptr) delete toolTip;
delete graphicalItems;
delete extQuotes;
delete extScripts;
delete extUpgrade;
delete extWeather;
}
void AWKeys::initKeys(const QString currentPattern)
{
qCDebug(LOG_AW);
qCDebug(LOG_AW) << "Pattern" << currentPattern;
// init
pattern = currentPattern;
// update network and hdd list
addKeyToCache(QString("Hdd"));
addKeyToCache(QString("Network"));
loadKeysFromCache();
reinitKeys();
}
void AWKeys::initTooltip(const QVariantMap tooltipParams)
{
qCDebug(LOG_AW);
qCDebug(LOG_AW) << "Tooltip parameters" << tooltipParams;
if (toolTip != nullptr) {
disconnect(toolTip, SIGNAL(toolTipPainted(QString)), this, SIGNAL(needToolTipToBeUpdated(QString)));
delete toolTip;
}
toolTip = new AWToolTip(this, tooltipParams);
// transfer signal from AWToolTip object to QML ui
connect(toolTip, SIGNAL(toolTipPainted(QString)), this, SIGNAL(needToolTipToBeUpdated(QString)));
}
void AWKeys::setPopupEnabled(const bool popup)
{
qCDebug(LOG_AW);
qCDebug(LOG_AW) << "Is popup enabled" << popup;
enablePopup = popup;
}
void AWKeys::setTranslateStrings(const bool translate)
{
qCDebug(LOG_AW);
qCDebug(LOG_AW) << "Is translation enabled" << translate;
translateStrings = translate;
}
void AWKeys::setWrapNewLines(const bool wrap)
{
qCDebug(LOG_AW);
qCDebug(LOG_AW) << "Is wrapping enabled" << wrap;
wrapNewLines = wrap;
}
QSize AWKeys::toolTipSize() const
{
qCDebug(LOG_AW);
if (toolTip == nullptr) return QSize();
return toolTip->getSize();
}
void AWKeys::addDevice(const QString source)
{
qCDebug(LOG_AW);
qCDebug(LOG_AW) << "Source" << source;
QRegExp diskRegexp = QRegExp(QString("disk/(?:md|sd|hd)[a-z|0-9]_.*/Rate/(?:rblk)"));
QRegExp mountRegexp = QRegExp(QString("partitions/.*/filllevel"));
if (source.contains(diskRegexp)) {
QString device = source;
device.remove(QString("/Rate/rblk"));
addKeyToCache(QString("Disk"), device);
} else if (source.contains(mountRegexp)) {
QString device = source;
device.remove(QString("partitions")).remove(QString("/filllevel"));
addKeyToCache(QString("Mount"), device);
} else if (source.startsWith(QString("lmsensors"))) {
addKeyToCache(QString("Temp"), source);
}
}
QStringList AWKeys::dictKeys(const bool sorted, const QString regexp) const
{
qCDebug(LOG_AW);
qCDebug(LOG_AW) << "Should be sorted" << sorted;
qCDebug(LOG_AW) << "Filter" << regexp;
QStringList allKeys;
// weather
for (int i=extWeather->items().count()-1; i>=0; i--) {
if (!extWeather->items().at(i)->isActive()) continue;
allKeys.append(extWeather->items().at(i)->tag(QString("weatherId")));
allKeys.append(extWeather->items().at(i)->tag(QString("weather")));
allKeys.append(extWeather->items().at(i)->tag(QString("humidity")));
allKeys.append(extWeather->items().at(i)->tag(QString("pressure")));
allKeys.append(extWeather->items().at(i)->tag(QString("temperature")));
allKeys.append(extWeather->items().at(i)->tag(QString("timestamp")));
}
// 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 & cpu
for (int i=QThread::idealThreadCount()-1; i>=0; i--) {
allKeys.append(QString("cpucl%1").arg(i));
allKeys.append(QString("cpu%1").arg(i));
}
allKeys.append(QString("cpucl"));
allKeys.append(QString("cpu"));
// temperature
for (int i=tempDevices.count()-1; i>=0; i--)
allKeys.append(QString("temp%1").arg(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=mountDevices.count()-1; i>=0; i--) {
allKeys.append(QString("hddmb%1").arg(i));
allKeys.append(QString("hddgb%1").arg(i));
allKeys.append(QString("hddfreemb%1").arg(i));
allKeys.append(QString("hddfreegb%1").arg(i));
allKeys.append(QString("hddtotmb%1").arg(i));
allKeys.append(QString("hddtotgb%1").arg(i));
allKeys.append(QString("hdd%1").arg(i));
}
// hdd speed
for (int i=diskDevices.count()-1; i>=0; i--) {
allKeys.append(QString("hddr%1").arg(i));
allKeys.append(QString("hddw%1").arg(i));
}
// hdd temp
for (int i=hddDevices.count()-1; i>=0; i--)
allKeys.append(QString("hddtemp%1").arg(i));
// network
for (int i=networkDevices.count()-1; i>=0; i--) {
allKeys.append(QString("downunits%1").arg(i));
allKeys.append(QString("upunits%1").arg(i));
allKeys.append(QString("downkb%1").arg(i));
allKeys.append(QString("down%1").arg(i));
allKeys.append(QString("upkb%1").arg(i));
allKeys.append(QString("up%1").arg(i));
}
allKeys.append(QString("downunits"));
allKeys.append(QString("upunits"));
allKeys.append(QString("downkb"));
allKeys.append(QString("down"));
allKeys.append(QString("upkb"));
allKeys.append(QString("up"));
allKeys.append(QString("netdev"));
// battery
allKeys.append(QString("ac"));
QStringList allBatteryDevices = QDir(QString("/sys/class/power_supply"))
.entryList(QStringList() << QString("BAT*"),
QDir::Dirs | QDir::NoDotAndDotDot,
QDir::Name);
for (int i=allBatteryDevices.count()-1; i>=0; i--)
allKeys.append(QString("bat%1").arg(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"));
allKeys.append(QString("dalbum"));
allKeys.append(QString("dartist"));
allKeys.append(QString("dtitle"));
allKeys.append(QString("salbum"));
allKeys.append(QString("sartist"));
allKeys.append(QString("stitle"));
// ps
allKeys.append(QString("pscount"));
allKeys.append(QString("pstotal"));
allKeys.append(QString("ps"));
// package manager
for (int i=extUpgrade->items().count()-1; i>=0; i--) {
if (!extUpgrade->items().at(i)->isActive()) continue;
allKeys.append(extUpgrade->items().at(i)->tag(QString("pkgcount")));
}
// quotes
for (int i=extQuotes->items().count()-1; i>=0; i--) {
if (!extQuotes->items().at(i)->isActive()) continue;
allKeys.append(extQuotes->items().at(i)->tag(QString("ask")));
allKeys.append(extQuotes->items().at(i)->tag(QString("askchg")));
allKeys.append(extQuotes->items().at(i)->tag(QString("percaskchg")));
allKeys.append(extQuotes->items().at(i)->tag(QString("bid")));
allKeys.append(extQuotes->items().at(i)->tag(QString("bidchg")));
allKeys.append(extQuotes->items().at(i)->tag(QString("percbidchg")));
allKeys.append(extQuotes->items().at(i)->tag(QString("price")));
allKeys.append(extQuotes->items().at(i)->tag(QString("pricechg")));
allKeys.append(extQuotes->items().at(i)->tag(QString("percpricechg")));
}
// custom
for (int i=extScripts->items().count()-1; i>=0; i--) {
if (!extScripts->items().at(i)->isActive()) continue;
allKeys.append(extScripts->items().at(i)->tag(QString("custom")));
}
// desktop
allKeys.append(QString("desktop"));
allKeys.append(QString("ndesktop"));
allKeys.append(QString("tdesktops"));
// load average
allKeys.append(QString("la15"));
allKeys.append(QString("la5"));
allKeys.append(QString("la1"));
// bars
QStringList graphicalItemsKeys;
foreach(GraphicalItem *item, graphicalItems->items())
graphicalItemsKeys.append(QString("%1%2").arg(item->name()).arg(item->bar()));
graphicalItemsKeys.sort();
for (int i=graphicalItemsKeys.count()-1; i>=0; i--)
allKeys.append(graphicalItemsKeys.at(i));
// sort if required
if (sorted) allKeys.sort();
return allKeys.filter(QRegExp(regexp));
}
QStringList AWKeys::getHddDevices() const
{
qCDebug(LOG_AW);
QStringList devices = hddDevices;
// required by ui interface
devices.insert(0, QString("disable"));
devices.insert(0, QString("auto"));
return devices;
}
void AWKeys::setDataBySource(const QString sourceName, const QVariantMap data,
const QVariantMap params)
{
qCDebug(LOG_AW);
qCDebug(LOG_AW) << "Source" << sourceName;
qCDebug(LOG_AW) << "Data" << data;
if (sourceName == QString("update")) return emit(needToBeUpdated());
// 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 netRegExp = QRegExp(QString("network/interfaces/.*/(receiver|transmitter)/data$"));
if (sourceName == QString("battery")) {
// battery
foreach(QString key, data.keys()) {
if (key == QString("ac")) {
// notification
if ((values[QString("ac")] == params[QString("acOnline")].toString()) != data[QString("ac")].toBool()) {
if (data[QString("ac")].toBool())
AWActions::sendNotification(QString("event"), i18n("AC online"), enablePopup);
else
AWActions::sendNotification(QString("event"), i18n("AC offline"), enablePopup);
}
// value
if (data[QString("ac")].toBool())
values[QString("ac")] = params[QString("acOnline")].toString();
else
values[QString("ac")] = params[QString("acOffline")].toString();
} else
values[key] = QString("%1").arg(data[key].toFloat(), 3, 'f', 0);
}
} else if (sourceName == QString("cpu/system/TotalLoad")) {
// cpu
// notification
if ((data[QString("value")].toFloat() >= 90.0) && (values[QString("cpu")].toFloat() < 90.0))
AWActions::sendNotification(QString("event"), i18n("High CPU load"), enablePopup);
// value
values[QString("cpu")] = QString("%1").arg(data[QString("value")].toFloat(), 5, 'f', 1);
} else if (sourceName.contains(cpuRegExp)) {
// cpus
QString number = sourceName;
number.remove(QString("cpu/cpu")).remove(QString("/TotalLoad"));
values[QString("cpu") + number] = QString("%1").arg(data[QString("value")].toFloat(), 5, 'f', 1);
} else if (sourceName == QString("cpu/system/AverageClock")) {
// cpucl
values[QString("cpucl")] = QString("%1").arg(data[QString("value")].toFloat(), 4, 'f', 0);
} else if (sourceName.contains(cpuclRegExp)) {
// cpucls
QString number = sourceName;
number.remove(QString("cpu/cpu")).remove(QString("/clock"));
values[QString("cpucl") + number] = QString("%1").arg(data[QString("value")].toFloat(), 4, 'f', 0);
} else if (sourceName == QString("custom")) {
// custom
foreach(QString key, data.keys()) values[key] = data[key].toString();
} else if (sourceName == QString("desktop")) {
// desktops
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)) {
// read speed
QString device = sourceName;
device.remove(QString("/Rate/rblk"));
for (int i=0; i<diskDevices.count(); i++) {
if (diskDevices.at(i) != device) continue;
values[QString("hddr%1").arg(i)] = QString("%1").arg(data[QString("value")].toFloat(), 5, 'f', 0);
break;
}
} else if (sourceName.contains(hddwRegExp)) {
// write speed
QString device = sourceName;
device.remove(QString("/Rate/wblk"));
for (int i=0; i<diskDevices.count(); i++) {
if (diskDevices.at(i) != device) continue;
values[QString("hddw%1").arg(i)] = QString("%1").arg(data[QString("value")].toFloat(), 5, 'f', 0);
break;
}
} else if (sourceName == QString("gpu")) {
// gpu load
// notification
if ((data[QString("value")].toFloat() >= 75.0) && (values[QString("gpu")].toFloat() < 75.0))
AWActions::sendNotification(QString("event"), i18n("High GPU load"), enablePopup);
// value
values[QString("gpu")] = QString("%1").arg(data[QString("value")].toFloat(), 5, 'f', 1);
} else if (sourceName == QString("gputemp")) {
// gpu temperature
values[QString("gputemp")] = QString("%1").arg(
temperature(data[QString("value")].toFloat(), params[QString("tempUnits")].toString()), 4, 'f', 1);
} else if (sourceName.contains(mountFillRegExp)) {
// fill level
QString mount = sourceName;
mount.remove(QString("partitions")).remove(QString("/filllevel"));
for (int i=0; i<mountDevices.count(); i++) {
if (mountDevices.at(i) != mount) continue;
if ((data[QString("value")].toFloat() >= 90.0) && (values[QString("hdd%1").arg(i)].toFloat() < 90.0))
AWActions::sendNotification(QString("event"), i18n("Free space on %1 less than 10%", mount), enablePopup);
values[QString("hdd%1").arg(i)] = QString("%1").arg(data[QString("value")].toFloat(), 5, 'f', 1);
break;
}
} else if (sourceName.contains(mountFreeRegExp)) {
// free space
QString mount = sourceName;
mount.remove(QString("partitions")).remove(QString("/freespace"));
for (int i=0; i<mountDevices.count(); i++) {
if (mountDevices.at(i) != mount) continue;
values[QString("hddfreemb%1").arg(i)] = QString("%1").arg(
data[QString("value")].toFloat() / 1024.0, 5, 'f', 0);
values[QString("hddfreegb%1").arg(i)] = QString("%1").arg(
data[QString("value")].toFloat() / (1024.0 * 1024.0), 5, 'f', 1);
break;
}
} else if (sourceName.contains(mountUsedRegExp)) {
// used
QString mount = sourceName;
mount.remove(QString("partitions")).remove(QString("/usedspace"));
for (int i=0; i<mountDevices.count(); i++) {
if (mountDevices.at(i) != mount) continue;
values[QString("hddmb%1").arg(i)] = QString("%1").arg(
data[QString("value")].toFloat() / 1024.0, 5, 'f', 0);
values[QString("hddgb%1").arg(i)] = QString("%1").arg(
data[QString("value")].toFloat() / (1024.0 * 1024.0), 5, 'f', 1);
// total
values[QString("hddtotmb%1").arg(i)] = QString("%1").arg(
values[QString("hddfreemb%1").arg(i)].toInt() +
values[QString("hddmb%1").arg(i)].toInt());
values[QString("hddtotgb%1").arg(i)] = QString("%1").arg(
values[QString("hddfreegb%1").arg(i)].toFloat() +
values[QString("hddgb%1").arg(i)].toFloat(), 5, 'f', 1);
break;
}
} else if (sourceName == QString("hddtemp")) {
// hdd temperature
foreach(QString key, data.keys())
for (int i=0; i<hddDevices.count(); i++) {
if (hddDevices.at(i) != key) continue;
values[QString("hddtemp%1").arg(i)] = QString("%1").arg(
temperature(data[key].toFloat(), params[QString("tempUnits")].toString()), 4, 'f', 1);
break;
}
} else if (sourceName.startsWith(QString("cpu/system/loadavg"))) {
// load average
QString time = sourceName;
time.remove(QString("cpu/system/loadavg"));
values[QString("la%1").arg(time)] = QString("%1").arg(data[QString("value")].toFloat(), 5, 'f', 2);
} else if (sourceName == QString("mem/physical/application")) {
// app memory
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")) {
// free memory
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")) {
// used memory
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
float value = 100.0 * values[QString("memmb")].toFloat() / values[QString("memtotmb")].toFloat();
// notification
if ((!isnan(value)) && (value >= 90.0) && (values[QString("mem")].toFloat() < 90.0))
AWActions::sendNotification(QString("event"), i18n("High memory usage"), enablePopup);
// value
values[QString("mem")] = QString("%1").arg(value, 5, 'f', 1);
} else if (sourceName == QString("netdev")) {
// network device
// notification
if (values[QString("netdev")] != data[QString("value")].toString())
AWActions::sendNotification(QString("event"), i18n("Network device has been changed to %1",
data[QString("value")].toString()),
enablePopup);
// value
values[QString("netdev")] = data[QString("value")].toString();
} else if (sourceName.contains(netRegExp)) {
// network speed
QString type = sourceName.contains(QString("receiver")) ? QString("down") : QString("up");
// device name
QString device = sourceName.split(QChar('/'))[2];
// values
float value = data[QString("value")].toFloat();
QString simplifiedValue = value > 1000.0 ?
QString("%1").arg(value / 1024.0, 4, 'f', 1) :
QString("%1").arg(value, 4, 'f', 0);
// units
QString units;
if (translateStrings)
units = value > 1000.0 ? i18n("MB/s") : i18n("KB/s");
else
units = value > 1000.0 ? QString("MB/s") : QString("KB/s");
// update
for (int i=0; i<networkDevices.count(); i++) {
if (networkDevices.at(i) != device) continue;
values[QString("%1kb%2").arg(type).arg(i)] = QString("%1").arg(value, 4, 'f', 0);
values[QString("%1%2").arg(type).arg(i)] = simplifiedValue;
values[QString("%1units%2").arg(type).arg(i)] = units;
break;
}
if (device == values[QString("netdev")]) {
values[QString("%1kb").arg(type)] = QString("%1").arg(value, 4, 'f', 0);
values[type] = simplifiedValue;
values[QString("%1units").arg(type)] = units;
}
} else if (sourceName == QString("pkg")) {
// package manager
foreach(QString key, data.keys()) values[key] = QString("%1").arg(data[key].toInt(), 2);
} else if (sourceName == QString("player")) {
// player
foreach(QString key, data.keys()) values[key] = data[key].toString();
} else if (sourceName == QString("ps")) {
// 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("quotes")) {
// quotes
foreach(QString key, data.keys()) values[key] = QString("%1").arg(data[key].toFloat(), 7, 'f');
} else if (sourceName == QString("mem/swap/free")) {
// free swap
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")) {
// used swap
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
float value = 100.0 * values[QString("swapmb")].toFloat() / values[QString("swaptotmb")].toFloat();
// notification
if ((!isnan(value)) && (value > 0.0) && (values[QString("swap")].toFloat() == 0.0))
AWActions::sendNotification(QString("event"), i18n("Swap is used"), enablePopup);
// value
values[QString("swap")] = QString("%1").arg(value, 5, 'f', 1);
} else if (sourceName.startsWith(QString("lmsensors/"))) {
// temperature devices
for (int i=0; i<tempDevices.count(); i++) {
if (sourceName != tempDevices.at(i)) continue;
float temp = data[QString("units")].toString() == QString("°C") ?
temperature(data[QString("value")].toFloat(), params[QString("tempUnits")].toString()) :
data[QString("value")].toFloat();
values[QString("temp%1").arg(i)] = QString("%1").arg(temp, 4, 'f', 1);
break;
}
} else if (sourceName == QString("Local")) {
// init locale
QLocale loc = translateStrings ? QLocale::system() : QLocale::c();
QDateTime dt = data[QString("DateTime")].toDateTime();
// time
values[QString("time")] = dt.toString(Qt::TextDate);
values[QString("isotime")] = dt.toString(Qt::ISODate);
values[QString("shorttime")] = loc.toString(dt, QLocale::ShortFormat);
values[QString("longtime")] = loc.toString(dt, QLocale::LongFormat);
values[QString("ctime")] = params[QString("customTime")].toString();
foreach(QString key, timeKeys)
values[QString("ctime")].replace(QString("$%1").arg(key), loc.toString(dt, key));
} else if (sourceName == QString("system/uptime")) {
// 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")] = params[QString("customUptime")].toString();
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));
} else if (sourceName == QString("weather")) {
foreach(QString key, data.keys()) {
if (key.startsWith(QString("weatherId")))
values[key] = QString("%1").arg(data[key].toInt(), 3);
else if (key.startsWith(QString("weather")))
values[key] = data[key].toString();
else if (key.startsWith(QString("humidity")))
values[key] = QString("%1").arg(data[key].toInt(), 3);
else if (key.startsWith(QString("pressure")))
values[key] = QString("%1").arg(data[key].toInt(), 4);
else if (key.startsWith(QString("temperature")))
values[key] = QString("%1").arg(
temperature(data[key].toFloat(), params[QString("tempUnits")].toString()), 4, 'f', 1);
}
} else {
qCDebug(LOG_AW) << "Source" << sourceName << "not found";
emit(dropSourceFromDataengine(sourceName));
}
}
void AWKeys::graphicalValueByKey() const
{
qCDebug(LOG_AW);
bool ok;
QString tag = QInputDialog::getItem(nullptr, i18n("Select tag"), i18n("Tag"),
dictKeys(true), 0, true, &ok);
if ((!ok) || (tag.isEmpty())) return;
QString message = i18n("Tag: %1", tag);
message += QString("<br>");
message += i18n("Value: %1", valueByKey(tag));
return AWActions::sendNotification(QString("tag"), message);
}
QString AWKeys::infoByKey(QString key) const
{
qCDebug(LOG_AW);
qCDebug(LOG_AW) << "Requested key" << key;
key.remove(QRegExp(QString("^bar[0-9]{1,}")));
if (key.startsWith(QString("custom")))
foreach(ExtScript *item, extScripts->items()) {
if (item->tag(QString("custom")) != key) continue;
return item->executable();
}
else if (key.contains(QRegExp(QString("^hdd[rw]"))))
return QString("%1").arg(diskDevices[key.remove(QRegExp(QString("hdd[rw]"))).toInt()]);
else if (key.contains(QRegExp(QString("^hdd([0-9]|mb|gb|freemb|freegb|totmb|totgb)"))))
return QString("%1").arg(mountDevices[key.remove(QRegExp(QString("^hdd([0-9]|mb|gb|freemb|freegb|totmb|totgb)"))).toInt()]);
else if (key.startsWith(QString("hddtemp")))
return QString("%1").arg(hddDevices[key.remove(QString("hddtemp")).toInt()]);
else if (key.contains(QRegExp(QString("^(down|up)[0-9]"))))
return QString("%1").arg(networkDevices[key.remove(QRegExp(QString("^(down|up)"))).toInt()]);
else if (key.startsWith(QString("pkgcount")))
foreach(ExtUpgrade *item, extUpgrade->items()) {
if (item->tag(QString("pkgcount")) != key) continue;
return item->executable();
}
else if (key.contains(QRegExp(QString("(^|perc)(ask|bid|price)(chg|)"))))
foreach(ExtQuotes *item, extQuotes->items()) {
if (item->number() != key.remove(QRegExp(QString("(^|perc)(ask|bid|price)(chg|)"))).toInt()) continue;
return item->ticker();
}
else if (key.startsWith(QString("temp")))
return QString("%1").arg(tempDevices[key.remove(QString("temp")).toInt()]);
return QString("(none)");
}
QString AWKeys::valueByKey(QString key) const
{
qCDebug(LOG_AW);
qCDebug(LOG_AW) << "Requested key" << key;
return values[key.remove(QRegExp(QString("^bar[0-9]{1,}")))];
}
void AWKeys::editItem(const QString type)
{
qCDebug(LOG_AW);
qCDebug(LOG_AW) << "Item type" << type;
if (type == QString("graphicalitem")) {
graphicalItems->setConfigArgs(dictKeys(true, QString("^(cpu(?!cl).*|gpu$|mem$|swap$|hdd[0-9].*|bat.*)")));
return graphicalItems->editItems();
} else if (type == QString("extquotes")) {
return extQuotes->editItems();
} else if (type == QString("extscript")) {
return extScripts->editItems();
} else if (type == QString("extupgrade")) {
return extUpgrade->editItems();
} else if (type == QString("extweather")) {
return extWeather->editItems();
}
}
void AWKeys::dataUpdate()
{
qCDebug(LOG_AW);
calculateLambdas();
emit(needTextToBeUpdated(parsePattern()));
if (toolTip != nullptr) emit(toolTip->updateData(values));
}
void AWKeys::loadKeysFromCache()
{
qCDebug(LOG_AW);
QString fileName = QString("%1/awesomewidgets.ndx")
.arg(QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation));
qCInfo(LOG_AW) << "Cache file" << fileName;
QSettings cache(fileName, QSettings::IniFormat);
cache.beginGroup(QString("Disk"));
diskDevices.clear();
foreach(QString key, cache.allKeys())
diskDevices.append(cache.value(key).toString());
cache.endGroup();
cache.beginGroup(QString("Hdd"));
hddDevices.clear();
foreach(QString key, cache.allKeys())
hddDevices.append(cache.value(key).toString());
cache.endGroup();
cache.beginGroup(QString("Mount"));
mountDevices.clear();
foreach(QString key, cache.allKeys())
mountDevices.append(cache.value(key).toString());
cache.endGroup();
cache.beginGroup(QString("Network"));
networkDevices.clear();
foreach(QString key, cache.allKeys())
networkDevices.append(cache.value(key).toString());
cache.endGroup();
cache.beginGroup(QString("Temp"));
tempDevices.clear();
foreach(QString key, cache.allKeys())
tempDevices.append(cache.value(key).toString());
cache.endGroup();
}
void AWKeys::reinitKeys()
{
qCDebug(LOG_AW);
// init
QStringList allKeys = dictKeys();
// append lists
// bars
foundBars = [allKeys](QString pattern) {
QStringList selectedKeys;
foreach(QString key, allKeys)
if ((key.startsWith(QString("bar"))) &&
(pattern.contains(QString("$%1").arg(key)))) {
qCInfo(LOG_AW) << "Found bar" << key;
selectedKeys.append(key);
}
if (selectedKeys.isEmpty()) qCWarning(LOG_AW) << "No bars found";
return selectedKeys;
}(pattern);
// main key list
foundKeys = [allKeys](QString pattern) {
QStringList selectedKeys;
foreach(QString key, allKeys)
if ((!key.startsWith(QString("bar"))) &&
(pattern.contains(QString("$%1").arg(key)))) {
qCInfo(LOG_AW) << "Found key" << key;
selectedKeys.append(key);
}
if (selectedKeys.isEmpty()) qCWarning(LOG_AW) << "No keys found";
return selectedKeys;
}(pattern);
// lambdas
foundLambdas = [](QString pattern) {
QStringList selectedKeys;
// substring inside ${{ }} (with brackets) which should not contain ${{
QRegularExpression lambdaRegexp(QString("\\$\\{\\{((?!\\$\\{\\{).)*?\\}\\}"));
lambdaRegexp.setPatternOptions(QRegularExpression::DotMatchesEverythingOption);
QRegularExpressionMatchIterator it = lambdaRegexp.globalMatch(pattern);
while (it.hasNext()) {
QRegularExpressionMatch match = it.next();
QString lambda = match.captured();
// drop brakets
lambda.remove(QRegExp(QString("^\\$\\{\\{")));
lambda.remove(QRegExp(QString("\\}\\}$")));
// append
qCInfo(LOG_AW) << "Found lambda" << lambda;
selectedKeys.append(lambda);
}
if (selectedKeys.isEmpty()) qCWarning(LOG_AW) << "No lambdas found";
return selectedKeys;
}(pattern);
}
void AWKeys::addKeyToCache(const QString type, const QString key)
{
qCDebug(LOG_AW);
qCDebug(LOG_AW) << "Key type" << type;
qCDebug(LOG_AW) << "Key" << key;
QString fileName = QString("%1/awesomewidgets.ndx").arg(QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation));
qCInfo(LOG_AW) << "Cache file" << fileName;
QSettings cache(fileName, QSettings::IniFormat);
cache.beginGroup(type);
QStringList cachedValues;
foreach(QString key, cache.allKeys())
cachedValues.append(cache.value(key).toString());
if (type == QString("Hdd")) {
QStringList allDevices = QDir(QString("/dev")).entryList(QDir::System, QDir::Name);
QStringList devices = allDevices.filter(QRegExp(QString("^[hms]d[a-z]$")));
foreach(QString dev, devices) {
QString device = QString("/dev/%1").arg(dev);
if (cachedValues.contains(device)) continue;
qCInfo(LOG_AW) << "Found new key" << device << "for type" << type;
cache.setValue(QString("%1").arg(cache.allKeys().count(), 3, 10, QChar('0')), device);
}
} else if (type == QString("Network")) {
QList<QNetworkInterface> rawInterfaceList = QNetworkInterface::allInterfaces();
foreach(QNetworkInterface interface, rawInterfaceList) {
QString device = interface.name();
if (cachedValues.contains(device)) continue;
qCInfo(LOG_AW) << "Found new key" << device << "for type" << type;
cache.setValue(QString("%1").arg(cache.allKeys().count(), 3, 10, QChar('0')), device);
}
} else {
if (cachedValues.contains(key)) return;
qCInfo(LOG_AW) << "Found new key" << key << "for type" << type;
cache.setValue(QString("%1").arg(cache.allKeys().count(), 3, 10, QChar('0')), key);
}
cache.endGroup();
cache.sync();
loadKeysFromCache();
return reinitKeys();
}
void AWKeys::calculateLambdas()
{
qCDebug(LOG_AW);
foreach(QString key, foundLambdas)
values[key] = [this](QString key) {
QScriptEngine engine;
// apply $this values
key.replace(QString("$this"), values[key]);
foreach(QString lambdaKey, foundKeys)
key.replace(QString("$%1").arg(lambdaKey), values[lambdaKey]);
qCInfo(LOG_AW) << "Expression" << key;
QScriptValue result = engine.evaluate(key);
if (engine.hasUncaughtException()) {
int line = engine.uncaughtExceptionLineNumber();
qCWarning(LOG_AW) << "Uncaught exception at line" << line << ":" << result.toString();
return QString();
} else
return result.toString();
}(key);
}
QString AWKeys::parsePattern() const
{
qCDebug(LOG_AW);
QString parsed = pattern;
parsed.replace(QString("$$"), QString("$\\$\\"));
// lambdas
foreach(QString key, foundLambdas)
parsed.replace(QString("${{%1}}").arg(key), values[key]);
// main keys
foreach(QString key, foundKeys)
parsed.replace(QString("$%1").arg(key), [](QString key, QString value) {
if ((!key.startsWith(QString("custom"))) &&
(!key.startsWith(QString("weather"))))
value.replace(QString(" "), QString("&nbsp;"));
return value;
}(key, values[key]));
// bars
foreach(QString bar, foundBars)
parsed.replace(QString("$%1").arg(bar),
graphicalItems->itemByTag(bar)->image(valueByKey(bar).toFloat()));
// prepare strings
parsed.replace(QString("$\\$\\"), QString("$$"));
if (wrapNewLines) parsed.replace(QString("\n"), QString("<br>"));
return parsed;
}
float AWKeys::temperature(const float temp, const QString units) const
{
qCDebug(LOG_AW);
qCDebug(LOG_AW) << "Temperature value" << temp;
qCDebug(LOG_AW) << "Temperature units" << units;
float converted = temp;
if (units == QString("Celsius"))
;
else if (units == QString("Fahrenheit"))
converted = temp * 9.0 / 5.0 + 32.0;
else if (units == QString("Kelvin"))
converted = temp + 273.15;
else if (units == QString("Reaumur"))
converted = temp * 0.8;
else if (units == QString("cm^-1"))
converted = (temp + 273.15) * 0.695;
else if (units == QString("kJ/mol"))
converted = (temp + 273.15) * 8.31;
else if (units == QString("kcal/mol"))
converted = (temp + 273.15) * 1.98;
return converted;
}

View File

@ -0,0 +1,101 @@
/***************************************************************************
* 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 AWKEYS_H
#define AWKEYS_H
#include <QHash>
#include <QObject>
#include <QStringList>
#include <QVariant>
#include "extitemaggregator.h"
#include "version.h"
class AWToolTip;
class ExtQuotes;
class ExtScript;
class ExtUpgrade;
class ExtWeather;
class GraphicalItem;
class AWKeys : public QObject
{
Q_OBJECT
public:
explicit AWKeys(QObject *parent = nullptr);
virtual ~AWKeys();
Q_INVOKABLE void initKeys(const QString currentPattern);
Q_INVOKABLE void initTooltip(const QVariantMap tooltipParams);
Q_INVOKABLE void setPopupEnabled(const bool popup = false);
Q_INVOKABLE void setTranslateStrings(const bool translate = false);
Q_INVOKABLE void setWrapNewLines(const bool wrap = false);
Q_INVOKABLE QSize toolTipSize() const;
// keys
Q_INVOKABLE void addDevice(const QString source);
Q_INVOKABLE QStringList dictKeys(const bool sorted = false,
const QString regexp = QString()) const;
Q_INVOKABLE QStringList getHddDevices() const;
Q_INVOKABLE void setDataBySource(const QString sourceName, const QVariantMap data,
const QVariantMap params);
// values
Q_INVOKABLE void graphicalValueByKey() const;
Q_INVOKABLE QString infoByKey(QString key) const;
Q_INVOKABLE QString valueByKey(QString key) const;
// configuration
Q_INVOKABLE void editItem(const QString type);
signals:
void dropSourceFromDataengine(const QString source);
void needTextToBeUpdated(const QString newText) const;
void needToolTipToBeUpdated(const QString newText) const;
void needToBeUpdated();
private slots:
void dataUpdate();
void loadKeysFromCache();
void reinitKeys();
private:
// methods
void addKeyToCache(const QString type, const QString key = QString(""));
void calculateLambdas();
QString parsePattern() const;
float temperature(const float temp, const QString units) const;
// get methods
AWToolTip *toolTip = nullptr;
bool enablePopup = false;
bool translateStrings = false;
bool wrapNewLines = false;
ExtItemAggregator<GraphicalItem> *graphicalItems;
ExtItemAggregator<ExtQuotes> *extQuotes;
ExtItemAggregator<ExtScript> *extScripts;
ExtItemAggregator<ExtUpgrade> *extUpgrade;
ExtItemAggregator<ExtWeather> *extWeather;
QString pattern;
QStringList foundBars, foundKeys, foundLambdas;
QStringList timeKeys = QString(TIME_KEYS).split(QChar(','));
QHash<QString, QString> values;
QStringList diskDevices, hddDevices, mountDevices, networkDevices, tempDevices;
};
#endif /* AWKEYS_H */

View File

@ -0,0 +1,181 @@
/***************************************************************************
* 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 "awtooltip.h"
#include <QBuffer>
#include <math.h>
#include "awdebug.h"
AWToolTip::AWToolTip(QObject *parent, QVariantMap settings)
: QObject(parent),
configuration(qvariant_cast<QVariantHash>(settings))
{
qCDebug(LOG_AW);
toolTipScene = new QGraphicsScene(nullptr);
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);
counts += configuration[QString("cpuTooltip")].toInt();
counts += configuration[QString("cpuclTooltip")].toInt();
counts += configuration[QString("memTooltip")].toInt();
counts += configuration[QString("swapTooltip")].toInt();
counts += configuration[QString("downTooltip")].toInt();
counts += configuration[QString("batTooltip")].toInt();
boundaries[QString("cpuTooltip")] = 100.0;
boundaries[QString("cpuclTooltip")] = 4000.0;
boundaries[QString("memTooltip")] = 100.0;
boundaries[QString("swapTooltip")] = 100.0;
boundaries[QString("downTooltip")] = 1.0;
boundaries[QString("upTooltip")] = 1.0;
boundaries[QString("batTooltip")] = 100.0;
size.setHeight(105.0);
size.setWidth(100.0 * counts);
if (configuration[QString("cpuTooltip")].toBool()) requiredKeys.append(QString("cpuTooltip"));
if (configuration[QString("cpuclTooltip")].toBool()) requiredKeys.append(QString("cpuclTooltip"));
if (configuration[QString("memTooltip")].toBool()) requiredKeys.append(QString("memTooltip"));
if (configuration[QString("swapTooltip")].toBool()) requiredKeys.append(QString("swapTooltip"));
if (configuration[QString("downTooltip")].toBool()) requiredKeys.append(QString("downTooltip"));
if (configuration[QString("upTooltip")].toBool()) requiredKeys.append(QString("upTooltip"));
if (configuration[QString("batTooltip")].toBool()) requiredKeys.append(QString("batTooltip"));
connect(this, SIGNAL(updateData(QHash<QString, QString>)),
this, SLOT(dataUpdate(QHash<QString, QString>)));
}
AWToolTip::~AWToolTip()
{
qCDebug(LOG_AW);
delete toolTipScene;
}
void AWToolTip::dataUpdate(QHash<QString, QString> values)
{
qCDebug(LOG_AW);
// battery update requires info is AC online or not
setData(QString("batTooltip"), values[QString("bat")].toFloat(),
values[QString("ac")] == configuration[QString("acOnline")]);
// usual case
setData(QString("cpuTooltip"), values[QString("cpu")].toFloat());
setData(QString("cpuclTooltip"), values[QString("cpucl")].toFloat());
setData(QString("memTooltip"), values[QString("mem")].toFloat());
setData(QString("swapTooltip"), values[QString("swap")].toFloat());
setData(QString("downTooltip"), values[QString("downkb")].toFloat());
setData(QString("upTooltip"), values[QString("upkb")].toFloat());
emit(toolTipPainted(htmlImage()));
}
QSize AWToolTip::getSize() const
{
qCDebug(LOG_AW);
return size;
}
QString AWToolTip::htmlImage()
{
qCDebug(LOG_AW);
QPixmap rawImage = image();
QByteArray byteArray;
QBuffer buffer(&byteArray);
rawImage.save(&buffer, "PNG");
return byteArray.isEmpty() ? QString() :
QString("<img src=\"data:image/png;base64,%1\"/>").arg(QString(byteArray.toBase64()));
}
QPixmap AWToolTip::image()
{
qCDebug(LOG_AW);
toolTipView->resize(size);
// create image
toolTipScene->clear();
QPen pen = QPen();
// background
toolTipScene->setBackgroundBrush(configuration[QString("useTooltipBackground")].toBool() ?
QBrush(QColor(configuration[QString("tooltipBackground")].toString())) :
QBrush(Qt::NoBrush));
bool down = false;
for (int i=0; i<requiredKeys.count(); i++) {
float normX = 100.0 / static_cast<float>(data[requiredKeys.at(i)].count());
float normY = 100.0 / (1.5 * boundaries[requiredKeys.at(i)]);
if (requiredKeys.at(i) != QString("batTooltip"))
pen.setColor(QColor(configuration[QString("%1Color").arg(requiredKeys.at(i))].toString()));
float shift = i * 100.0;
if (down) shift -= 100.0;
for (int j=0; j<data[requiredKeys.at(i)].count()-1; j++) {
// some magic here
float x1 = j * normX + shift;
float y1 = - fabs(data[requiredKeys.at(i)].at(j)) * normY + 5.0;
float x2 = (j + 1) * normX + shift;
float y2 = - fabs(data[requiredKeys.at(i)].at(j+1)) * normY + 5.0;
if (requiredKeys.at(i) == QString("batTooltip")) {
if (data[requiredKeys.at(i)].at(j+1) > 0)
pen.setColor(QColor(configuration[QString("batTooltipColor")].toString()));
else
pen.setColor(QColor(configuration[QString("batInTooltipColor")].toString()));
}
toolTipScene->addLine(x1, y1, x2, y2, pen);
}
if (requiredKeys.at(i) == QString("downTooltip")) down = true;
}
return toolTipView->grab();
}
void AWToolTip::setData(const QString source, float value, const bool dontInvert)
{
qCDebug(LOG_AW);
qCDebug(LOG_AW) << "Source" << source;
qCDebug(LOG_AW) << "Value" << value;
qCDebug(LOG_AW) << "Do not invert value" << dontInvert;
if (data[source].count() == 0)
data[source].append(0.0);
else if (data[source].count() > configuration[QString("tooltipNumber")].toInt())
data[source].takeFirst();
if (isnan(value)) value = 0.0;
// invert values for different battery colours
data[source].append(dontInvert ? value : -value);
if (source == QString("downTooltip")) {
QList<float> netValues = data[QString("downTooltip")] + data[QString("upTooltip")];
boundaries[QString("downTooltip")] = 1.2 * *std::max_element(netValues.cbegin(), netValues.cend());
boundaries[QString("upTooltip")] = boundaries[QString("downTooltip")];
}
}

View File

@ -0,0 +1,64 @@
/***************************************************************************
* 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 AWTOOLTIP_H
#define AWTOOLTIP_H
#include <QGraphicsScene>
#include <QGraphicsView>
#include <QHash>
#include <QObject>
#include <QPixmap>
#include <QVariant>
class AWToolTip : public QObject
{
Q_OBJECT
public:
explicit AWToolTip(QObject *parent = nullptr, QVariantMap settings = QVariantMap());
virtual ~AWToolTip();
QSize getSize() const;
QString htmlImage();
QPixmap image();
signals:
void updateData(QHash<QString, QString> values);
void toolTipPainted(QString image);
private slots:
void dataUpdate(QHash<QString, QString> values);
private:
// ui
QGraphicsScene *toolTipScene = nullptr;
QGraphicsView *toolTipView = nullptr;
void setData(const QString source, float value,
const bool dontInvert = true);
// variables
int counts = 0;
QVariantHash configuration;
QHash<QString, float> boundaries;
QHash<QString, QList<float>> data;
QStringList requiredKeys;
QSize size;
};
#endif /* AWTOOLTIP_H */

View File

@ -1,7 +1,17 @@
[Global]
IconName=system
Name=Awesome Widget
Comment=Awesome widget information
Comment=Awesome widget notifications
[info]
Name=Information
Comment=Information
Action=Popup
[Event/event]
Name=Event
Comment=Some event occurs
Action=Popup
[Event/system]
Name=System information

View File

@ -0,0 +1,2 @@
module org.kde.plasma.private.awesomewidget
plugin awplugin

View File

@ -1,25 +0,0 @@
find_package(KDE4 REQUIRED)
find_package(Gettext REQUIRED)
if (NOT GETTEXT_MSGFMT_EXECUTABLE)
message(FATAL_ERROR "Please install the msgfmt binary")
endif (NOT GETTEXT_MSGFMT_EXECUTABLE)
file (GLOB _po_files *.po)
set (_gmoFiles)
foreach (_current_PO_FILE ${_po_files})
get_filename_component (_lang ${_current_PO_FILE} NAME_WE)
set (_gmoFile ${CMAKE_CURRENT_BINARY_DIR}/${_lang}.gmo)
add_custom_command (OUTPUT ${_gmoFile}
COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} -o ${_gmoFile} ${_current_PO_FILE}
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
DEPENDS ${_current_PO_FILE}
)
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/${_lang}.gmo DESTINATION ${LOCALE_INSTALL_DIR}/${_lang}/LC_MESSAGES/
RENAME plasma_applet_awesome-widget.mo)
list (APPEND _gmoFiles ${_gmoFile})
endforeach (_current_PO_FILE)
add_custom_target (pofiles ALL DEPENDS ${_gmoFiles})

View File

@ -1,41 +0,0 @@
#!/bin/sh
BASEDIR="../" # root of translatable sources
PROJECT="plasma_applet_awesome-widget" # project name
BUGADDR="https://github.com/arcan1s/awesome-widgets/issues" # MSGID-Bugs
WDIR=$(pwd) # working dir
echo "Preparing rc files"
cd "${BASEDIR}"
find . -name '*.rc' -o -name '*.ui' -o -name '*.kcfg' -o -name '*.py' | sort > "${WDIR}/rcfiles.list"
xargs --arg-file=${WDIR}/rcfiles.list extractrc > "${WDIR}/rc.cpp"
echo 'i18nc("NAME OF TRANSLATORS","Your names");' >> "${WDIR}/rc.cpp"
echo 'i18nc("EMAIL OF TRANSLATORS","Your emails");' >> "${WDIR}/rc.cpp"
echo "Done preparing rc files"
echo "Extracting messages"
cd "${WDIR}"
cd "${BASEDIR}"
find . -name '*.cpp' -o -name '*.h' -o -name '*.c' -o -name '*.py' | sort > "${WDIR}/infiles.list"
echo "rc.cpp" >> "${WDIR}/infiles.list"
cd "${WDIR}"
xgettext --from-code=UTF-8 -C -kde -ci18n -ki18n:1 -ki18nc:1c,2 -ki18np:1,2 -ki18ncp:1c,2,3 -ktr2i18n:1 \
-kI18N_NOOP:1 -kI18N_NOOP2:1c,2 -kaliasLocale -kki18n:1 -kki18nc:1c,2 -kki18np:1,2 -kki18ncp:1c,2,3 \
--msgid-bugs-address="${BUGADDR}" --language=Python \
--files-from=infiles.list -D "${BASEDIR}" -D "${WDIR}" -o "${PROJECT}.pot" || { echo "error while calling xgettext. aborting."; exit 1; }
echo "Done extracting messages"
echo "Merging translations"
catalogs=$(find . -name '*.po')
for cat in $catalogs; do
echo $cat
msgmerge -o "$cat.new" "$cat" "${PROJECT}.pot"
mv "$cat.new" "$cat"
done
echo "Done merging translations"
echo "Cleaning up"
cd "${WDIR}"
rm -f rcfiles.list infiles.list rc.cpp
echo "Done"

View File

@ -1,469 +0,0 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: https://github.com/arcan1s/awesome-widgets/issues\n"
"POT-Creation-Date: 2014-12-15 02:40+0300\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"
#: awesome-widget.cpp:95
msgid "Run ksysguard"
msgstr ""
#: awesome-widget.cpp:98
msgid "Show README"
msgstr ""
#: awesome-widget.cpp:101
msgid "Update text"
msgstr ""
#: awesome-widget.cpp:106 po/rc.cpp:98 rc.cpp:98
msgid "Check for updates"
msgstr ""
#: awesome-widget.cpp:491
msgid "Current version : %1"
msgstr ""
#: awesome-widget.cpp:492
msgid "New version : %1"
msgstr ""
#: awesome-widget.cpp:493
msgid "Click \"Ok\" to download"
msgstr ""
#: awesome-widget.cpp:494
msgid "There are updates"
msgstr ""
#: configuration.cpp:307
msgid "Tag: %1"
msgstr ""
#: configuration.cpp:308 configuration.cpp:383
msgid "Comment: %1"
msgstr ""
#: configuration.cpp:382
msgid "Name: %1"
msgstr ""
#: configuration.cpp:384
msgid "Exec: %1"
msgstr ""
#: configuration.cpp:413 po/rc.cpp:153 rc.cpp:153
msgid "Package manager"
msgstr ""
#: configuration.cpp:414 po/rc.cpp:156 rc.cpp:156
msgid "Null lines"
msgstr ""
#: configuration.cpp:428
msgid ""
"Version %1\n"
"(build date %2)"
msgstr ""
#: configuration.cpp:429
msgid "A set of minimalistic plasmoid widgets"
msgstr ""
#: configuration.cpp:430
msgid "Links:"
msgstr ""
#: configuration.cpp:431
msgid "Homepage"
msgstr ""
#: configuration.cpp:432
msgid "Repository"
msgstr ""
#: configuration.cpp:433
msgid "Bugtracker"
msgstr ""
#: configuration.cpp:434
msgid "Translation issue"
msgstr ""
#: configuration.cpp:435
msgid "AUR packages"
msgstr ""
#: configuration.cpp:437
msgid "This software is licensed under %1"
msgstr ""
#: configuration.cpp:445
msgid "Translators: %1"
msgstr ""
#: configuration.cpp:446
msgid "This software uses: %1"
msgstr ""
#: configuration.cpp:448
msgid "Widget"
msgstr ""
#: configuration.cpp:449
msgid "Advanced"
msgstr ""
#: configuration.cpp:450
msgid "Tooltip"
msgstr ""
#: configuration.cpp:451
msgid "Appearance"
msgstr ""
#: configuration.cpp:452
msgid "DataEngine"
msgstr ""
#: configuration.cpp:453
msgid "About"
msgstr ""
#: configuration.cpp:734 configuration.cpp:760 configuration.cpp:868
#: configuration.cpp:910
msgid "Enter file name"
msgstr ""
#: configuration.cpp:735 configuration.cpp:761 configuration.cpp:869
#: configuration.cpp:911
msgid "File name"
msgstr ""
#: configuration.cpp:793 configuration.cpp:819
msgid "Edit"
msgstr ""
#: configuration.cpp:794 configuration.cpp:820
msgid "Copy"
msgstr ""
#: configuration.cpp:795 configuration.cpp:821 configuration.cpp:843
msgid "Remove"
msgstr ""
#: configuration.cpp:1037
msgid "Select font"
msgstr ""
#: graphicalitem.cpp:442
msgid "Select color"
msgstr ""
#: po/rc.cpp:3 rc.cpp:3
msgid "Enable popup on mouse click"
msgstr ""
#: po/rc.cpp:6 rc.cpp:6
msgid "Enable background"
msgstr ""
#: po/rc.cpp:9 rc.cpp:9
msgid "Custom time format"
msgstr ""
#: po/rc.cpp:12 rc.cpp:12
msgid ""
"$dddd - long weekday\n"
"$ddd - short weekday\n"
"$dd - day\n"
"$d - day w\\o zero\n"
"$MMMM - long month\n"
"$MMM - short month\n"
"$MM - month\n"
"$M - month w\\o zero\n"
"$yyyy - year\n"
"$yy - short year\n"
"$hh - hours (24 only)\n"
"$h - hours w\\o zero (24 only)\n"
"$mm - minutes\n"
"$m - minutes w\\o zero\n"
"$ss - seconds\n"
"$s - seconds w\\o zero"
msgstr ""
#: po/rc.cpp:30 rc.cpp:30
msgid "Custom uptime format"
msgstr ""
#: po/rc.cpp:33 rc.cpp:33
msgid ""
"$dd - uptime days\n"
"$d - uptime days without zero\n"
"$hh - uptime hours\n"
"$h - uptime hours without zero\n"
"$mm - uptime minutes\n"
"$m - uptime minutes without zero"
msgstr ""
#: po/rc.cpp:41 rc.cpp:41
msgid "Temperature units"
msgstr ""
#: po/rc.cpp:44 rc.cpp:44
msgid "Temperature devices"
msgstr ""
#: po/rc.cpp:47 po/rc.cpp:53 po/rc.cpp:59 po/rc.cpp:65 po/rc.cpp:71 rc.cpp:47
#: rc.cpp:53 rc.cpp:59 rc.cpp:65 rc.cpp:71
msgid "Editable"
msgstr ""
#: po/rc.cpp:50 rc.cpp:50
msgid "Fan devices"
msgstr ""
#: po/rc.cpp:56 rc.cpp:56
msgid "Mount points"
msgstr ""
#: po/rc.cpp:62 rc.cpp:62
msgid "HDD devices (speed)"
msgstr ""
#: po/rc.cpp:68 rc.cpp:68
msgid "HDD devices (temp)"
msgstr ""
#: po/rc.cpp:74 rc.cpp:74
msgid "Disable auto select device and set specified device"
msgstr ""
#: po/rc.cpp:77 rc.cpp:77
msgid "Set network device"
msgstr ""
#: po/rc.cpp:80 rc.cpp:80
msgid "AC online tag"
msgstr ""
#: po/rc.cpp:83 rc.cpp:83
msgid "Line, which returns when AC is online"
msgstr ""
#: po/rc.cpp:86 rc.cpp:86
msgid "AC offline tag"
msgstr ""
#: po/rc.cpp:89 rc.cpp:89
msgid "Line, which returns when AC is offline"
msgstr ""
#: po/rc.cpp:92 rc.cpp:92
msgid "Bars"
msgstr ""
#: po/rc.cpp:95 po/rc.cpp:162 po/rc.cpp:243 rc.cpp:95 rc.cpp:162 rc.cpp:243
msgid "Add"
msgstr ""
#: po/rc.cpp:101 rc.cpp:101
msgid "Time interval"
msgstr ""
#: po/rc.cpp:104 po/rc.cpp:231 rc.cpp:104 rc.cpp:231
msgid "Font"
msgstr ""
#: po/rc.cpp:107 rc.cpp:107
msgid "Font size"
msgstr ""
#: po/rc.cpp:110 rc.cpp:110
msgid "Font color"
msgstr ""
#: po/rc.cpp:113 rc.cpp:113
msgid "Font style"
msgstr ""
#: po/rc.cpp:116 rc.cpp:116
msgid "Font weight"
msgstr ""
#: po/rc.cpp:119 rc.cpp:119
msgid "hddtemp cmd"
msgstr ""
#: po/rc.cpp:122 rc.cpp:122
msgid "GPU device"
msgstr ""
#: po/rc.cpp:125 rc.cpp:125
msgid "HDD"
msgstr ""
#: po/rc.cpp:128 rc.cpp:128
msgid "Music player"
msgstr ""
#: po/rc.cpp:131 rc.cpp:131
msgid "MPD port"
msgstr ""
#: po/rc.cpp:134 rc.cpp:134
msgid "MPD address"
msgstr ""
#: po/rc.cpp:137 rc.cpp:137
msgid "ACPI path"
msgstr ""
#: po/rc.cpp:140 rc.cpp:140
msgid "\"/sys/class/power_supply/\" by default"
msgstr ""
#: po/rc.cpp:143 rc.cpp:143
msgid "<b>NOTE:</b> Player DBus interface should be an active"
msgstr ""
#: po/rc.cpp:146 rc.cpp:146
msgid "MPRIS player name"
msgstr ""
#: po/rc.cpp:149 rc.cpp:149
msgid ""
"Editable\n"
"del - remove item"
msgstr ""
#: po/rc.cpp:159 rc.cpp:159
msgid "Custom scripts"
msgstr ""
#: po/rc.cpp:165 rc.cpp:165
msgid "Configuration"
msgstr ""
#: po/rc.cpp:168 rc.cpp:168
msgid "Name"
msgstr ""
#: po/rc.cpp:171 rc.cpp:171
msgid "Comment"
msgstr ""
#: po/rc.cpp:174 rc.cpp:174
msgid "Value"
msgstr ""
#: po/rc.cpp:177 rc.cpp:177
msgid "Active color"
msgstr ""
#: po/rc.cpp:180 rc.cpp:180
msgid "Inactive color"
msgstr ""
#: po/rc.cpp:183 rc.cpp:183
msgid "Type"
msgstr ""
#: po/rc.cpp:186 rc.cpp:186
msgid "Direction"
msgstr ""
#: po/rc.cpp:189 rc.cpp:189
msgid "Height"
msgstr ""
#: po/rc.cpp:192 rc.cpp:192
msgid "Width"
msgstr ""
#: po/rc.cpp:195 rc.cpp:195
msgid ""
"CPU, CPU clock, memory, swap and network labels support graphical tooltip. "
"To enable them just make needed checkbox fully checked."
msgstr ""
#: po/rc.cpp:198 rc.cpp:198
msgid "Number of values for tooltips"
msgstr ""
#: po/rc.cpp:201 rc.cpp:201
msgid "Background"
msgstr ""
#: po/rc.cpp:204 rc.cpp:204
msgid "CPU color"
msgstr ""
#: po/rc.cpp:207 rc.cpp:207
msgid "CPU clock color"
msgstr ""
#: po/rc.cpp:210 rc.cpp:210
msgid "Memory color"
msgstr ""
#: po/rc.cpp:213 rc.cpp:213
msgid "Swap color"
msgstr ""
#: po/rc.cpp:216 rc.cpp:216
msgid "Download speed color"
msgstr ""
#: po/rc.cpp:219 rc.cpp:219
msgid "Upload speed color"
msgstr ""
#: po/rc.cpp:222 rc.cpp:222
msgid "Battery active color"
msgstr ""
#: po/rc.cpp:225 rc.cpp:225
msgid "Battery inactive color"
msgstr ""
#: po/rc.cpp:228 rc.cpp:228
msgid ""
"Detailed information may be found on <a href=\"http://arcanis.name/projects/"
"awesome-widgets/\">project homepage</a>"
msgstr ""
#: po/rc.cpp:234 rc.cpp:234
msgid "Ctrl+B"
msgstr ""
#: po/rc.cpp:237 rc.cpp:237
msgid "Ctrl+I"
msgstr ""
#: po/rc.cpp:240 rc.cpp:240
msgid "Ctrl+U"
msgstr ""
#: po/rc.cpp:244 rc.cpp:244
msgctxt "NAME OF TRANSLATORS"
msgid "Your names"
msgstr ""
#: po/rc.cpp:245 rc.cpp:245
msgctxt "EMAIL OF TRANSLATORS"
msgid "Your emails"
msgstr ""

View File

@ -1,519 +0,0 @@
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
#
# Steve Lemuel <wlemuel@hotmail.com>, 2014.
msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: https://github.com/arcan1s/awesome-widgets/issues\n"
"POT-Creation-Date: 2014-12-15 02:40+0300\n"
"PO-Revision-Date: 2014-09-10 22:50+0800\n"
"Last-Translator: Steve Lemuel <wlemuel@hotmail.com>\n"
"Language-Team: American English <kde-i18n-doc@kde.org>\n"
"Language: en_US\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Generator: Lokalize 1.5\n"
#: awesome-widget.cpp:95
msgid "Run ksysguard"
msgstr "运行任务管理器"
#: awesome-widget.cpp:98
msgid "Show README"
msgstr "显示帮助文档"
#: awesome-widget.cpp:101
msgid "Update text"
msgstr "刷新文本"
#: awesome-widget.cpp:106 po/rc.cpp:98 rc.cpp:98
msgid "Check for updates"
msgstr ""
#: awesome-widget.cpp:491
msgid "Current version : %1"
msgstr ""
#: awesome-widget.cpp:492
msgid "New version : %1"
msgstr ""
#: awesome-widget.cpp:493
msgid "Click \"Ok\" to download"
msgstr ""
#: awesome-widget.cpp:494
msgid "There are updates"
msgstr ""
#: configuration.cpp:307
msgid "Tag: %1"
msgstr ""
#: configuration.cpp:308 configuration.cpp:383
msgid "Comment: %1"
msgstr ""
#: configuration.cpp:382
msgid "Name: %1"
msgstr ""
#: configuration.cpp:384
msgid "Exec: %1"
msgstr ""
#: configuration.cpp:413 po/rc.cpp:153 rc.cpp:153
msgid "Package manager"
msgstr "包管理器"
#: configuration.cpp:414 po/rc.cpp:156 rc.cpp:156
msgid "Null lines"
msgstr "空行"
#: configuration.cpp:428
msgid ""
"Version %1\n"
"(build date %2)"
msgstr ""
#: configuration.cpp:429
msgid "A set of minimalistic plasmoid widgets"
msgstr ""
#: configuration.cpp:430
msgid "Links:"
msgstr ""
#: configuration.cpp:431
msgid "Homepage"
msgstr ""
#: configuration.cpp:432
msgid "Repository"
msgstr ""
#: configuration.cpp:433
msgid "Bugtracker"
msgstr ""
#: configuration.cpp:434
msgid "Translation issue"
msgstr ""
#: configuration.cpp:435
msgid "AUR packages"
msgstr ""
#: configuration.cpp:437
msgid "This software is licensed under %1"
msgstr ""
#: configuration.cpp:445
msgid "Translators: %1"
msgstr ""
#: configuration.cpp:446
msgid "This software uses: %1"
msgstr ""
#: configuration.cpp:448
msgid "Widget"
msgstr "窗口小部件"
#: configuration.cpp:449
msgid "Advanced"
msgstr "高级设置"
#: configuration.cpp:450
msgid "Tooltip"
msgstr "提示"
#: configuration.cpp:451
msgid "Appearance"
msgstr "外观"
#: configuration.cpp:452
msgid "DataEngine"
msgstr "数据引擎"
#: configuration.cpp:453
msgid "About"
msgstr ""
#: configuration.cpp:734 configuration.cpp:760 configuration.cpp:868
#: configuration.cpp:910
msgid "Enter file name"
msgstr ""
#: configuration.cpp:735 configuration.cpp:761 configuration.cpp:869
#: configuration.cpp:911
msgid "File name"
msgstr ""
#: configuration.cpp:793 configuration.cpp:819
#, fuzzy
msgid "Edit"
msgstr "可编辑的"
#: configuration.cpp:794 configuration.cpp:820
msgid "Copy"
msgstr ""
#: configuration.cpp:795 configuration.cpp:821 configuration.cpp:843
msgid "Remove"
msgstr "移除"
#: configuration.cpp:1037
msgid "Select font"
msgstr "选择字体"
#: graphicalitem.cpp:442
#, fuzzy
msgid "Select color"
msgstr "选择字体"
#: po/rc.cpp:3 rc.cpp:3
msgid "Enable popup on mouse click"
msgstr "鼠标点击时弹出对话框"
#: po/rc.cpp:6 rc.cpp:6
msgid "Enable background"
msgstr "启用背景"
#: po/rc.cpp:9 rc.cpp:9
msgid "Custom time format"
msgstr "自定义时间格式"
#: po/rc.cpp:12 rc.cpp:12
msgid ""
"$dddd - long weekday\n"
"$ddd - short weekday\n"
"$dd - day\n"
"$d - day w\\o zero\n"
"$MMMM - long month\n"
"$MMM - short month\n"
"$MM - month\n"
"$M - month w\\o zero\n"
"$yyyy - year\n"
"$yy - short year\n"
"$hh - hours (24 only)\n"
"$h - hours w\\o zero (24 only)\n"
"$mm - minutes\n"
"$m - minutes w\\o zero\n"
"$ss - seconds\n"
"$s - seconds w\\o zero"
msgstr ""
"$dddd - 详细工作日\n"
"$ddd - 简短工作日\n"
"$dd - 日\n"
"$d - 日 w\\o 零\n"
"$MMMM - 详细月份\n"
"$MMM - 简短月份\n"
"$MM - 月\n"
"$M - 月 w\\o 零\n"
"$yyyy - 年\n"
"$yy - 简短年份\n"
"$hh - 小时 (24 小时制)\n"
"$h - 小时 w\\o 零 (24 小时制)\n"
"$mm - 分\n"
"$m - 分 w\\o 零\n"
"$ss - 秒\n"
"$s - 秒 w\\o 零"
#: po/rc.cpp:30 rc.cpp:30
msgid "Custom uptime format"
msgstr "自定义启动时间显示格式"
#: po/rc.cpp:33 rc.cpp:33
msgid ""
"$dd - uptime days\n"
"$d - uptime days without zero\n"
"$hh - uptime hours\n"
"$h - uptime hours without zero\n"
"$mm - uptime minutes\n"
"$m - uptime minutes without zero"
msgstr ""
"$dd - 运行天数\n"
"$d - 运行天数不显示0\n"
"$hh - 运行小时数\n"
"$h - 运行小时数不显示0\n"
"$mm - 运行分钟数\n"
"$m - 运行分钟数不显示0"
#: po/rc.cpp:41 rc.cpp:41
msgid "Temperature units"
msgstr "温度单位"
#: po/rc.cpp:44 rc.cpp:44
msgid "Temperature devices"
msgstr "温度传感器"
#: po/rc.cpp:47 po/rc.cpp:53 po/rc.cpp:59 po/rc.cpp:65 po/rc.cpp:71 rc.cpp:47
#: rc.cpp:53 rc.cpp:59 rc.cpp:65 rc.cpp:71
msgid "Editable"
msgstr "可编辑的"
#: po/rc.cpp:50 rc.cpp:50
#, fuzzy
msgid "Fan devices"
msgstr "外界电源设备"
#: po/rc.cpp:56 rc.cpp:56
msgid "Mount points"
msgstr "挂载点"
#: po/rc.cpp:62 rc.cpp:62
msgid "HDD devices (speed)"
msgstr "硬盘(高速)"
#: po/rc.cpp:68 rc.cpp:68
msgid "HDD devices (temp)"
msgstr "硬盘(临时)"
#: po/rc.cpp:74 rc.cpp:74
msgid "Disable auto select device and set specified device"
msgstr "禁用自动选择设备和设置特殊设备"
#: po/rc.cpp:77 rc.cpp:77
msgid "Set network device"
msgstr "设置网络设备"
#: po/rc.cpp:80 rc.cpp:80
msgid "AC online tag"
msgstr "外接电源使用中标签"
#: po/rc.cpp:83 rc.cpp:83
msgid "Line, which returns when AC is online"
msgstr "外接电源使用时显示线条"
#: po/rc.cpp:86 rc.cpp:86
msgid "AC offline tag"
msgstr "外接电源未使用标签"
#: po/rc.cpp:89 rc.cpp:89
msgid "Line, which returns when AC is offline"
msgstr "外接电源未使用时显示线条"
#: po/rc.cpp:92 rc.cpp:92
msgid "Bars"
msgstr ""
#: po/rc.cpp:95 po/rc.cpp:162 po/rc.cpp:243 rc.cpp:95 rc.cpp:162 rc.cpp:243
msgid "Add"
msgstr "添加"
#: po/rc.cpp:101 rc.cpp:101
msgid "Time interval"
msgstr "时间周期"
#: po/rc.cpp:104 po/rc.cpp:231 rc.cpp:104 rc.cpp:231
msgid "Font"
msgstr "字体"
#: po/rc.cpp:107 rc.cpp:107
msgid "Font size"
msgstr "字体大小"
#: po/rc.cpp:110 rc.cpp:110
msgid "Font color"
msgstr "字体颜色"
#: po/rc.cpp:113 rc.cpp:113
msgid "Font style"
msgstr "字体样式"
#: po/rc.cpp:116 rc.cpp:116
msgid "Font weight"
msgstr "字体宽度"
#: po/rc.cpp:119 rc.cpp:119
msgid "hddtemp cmd"
msgstr "硬盘温度显示命令"
#: po/rc.cpp:122 rc.cpp:122
msgid "GPU device"
msgstr "GPU 设备"
#: po/rc.cpp:125 rc.cpp:125
msgid "HDD"
msgstr "硬盘"
#: po/rc.cpp:128 rc.cpp:128
msgid "Music player"
msgstr "音乐播放器"
#: po/rc.cpp:131 rc.cpp:131
msgid "MPD port"
msgstr "MPD 端口"
#: po/rc.cpp:134 rc.cpp:134
msgid "MPD address"
msgstr "MPD 地址"
#: po/rc.cpp:137 rc.cpp:137
msgid "ACPI path"
msgstr ""
#: po/rc.cpp:140 rc.cpp:140
#, fuzzy
msgid "\"/sys/class/power_supply/\" by default"
msgstr "默认为 \"/sys/class/power_supply/AC/online\""
#: po/rc.cpp:143 rc.cpp:143
msgid "<b>NOTE:</b> Player DBus interface should be an active"
msgstr "<b>提示:</b> 播放器 DBus 应当处于激活状态"
#: po/rc.cpp:146 rc.cpp:146
msgid "MPRIS player name"
msgstr "MPRIS 播放器名"
#: po/rc.cpp:149 rc.cpp:149
msgid ""
"Editable\n"
"del - remove item"
msgstr ""
"可编辑的\n"
"del - 移除项目"
#: po/rc.cpp:159 rc.cpp:159
msgid "Custom scripts"
msgstr ""
#: po/rc.cpp:165 rc.cpp:165
msgid "Configuration"
msgstr ""
#: po/rc.cpp:168 rc.cpp:168
msgid "Name"
msgstr ""
#: po/rc.cpp:171 rc.cpp:171
msgid "Comment"
msgstr ""
#: po/rc.cpp:174 rc.cpp:174
msgid "Value"
msgstr ""
#: po/rc.cpp:177 rc.cpp:177
#, fuzzy
msgid "Active color"
msgstr "电池使用状态提示颜色"
#: po/rc.cpp:180 rc.cpp:180
#, fuzzy
msgid "Inactive color"
msgstr "电池未使用状态提示颜色"
#: po/rc.cpp:183 rc.cpp:183
msgid "Type"
msgstr ""
#: po/rc.cpp:186 rc.cpp:186
msgid "Direction"
msgstr ""
#: po/rc.cpp:189 rc.cpp:189
msgid "Height"
msgstr ""
#: po/rc.cpp:192 rc.cpp:192
msgid "Width"
msgstr ""
#: po/rc.cpp:195 rc.cpp:195
msgid ""
"CPU, CPU clock, memory, swap and network labels support graphical tooltip. "
"To enable them just make needed checkbox fully checked."
msgstr ""
"CPU CPU 时钟,内存,虚拟内存和网络连接标签均支持图形化提示显示。 请在相应复"
"选框中勾选以启用该功能。 "
#: po/rc.cpp:198 rc.cpp:198
msgid "Number of values for tooltips"
msgstr "提示的数值"
#: po/rc.cpp:201 rc.cpp:201
msgid "Background"
msgstr "背景"
#: po/rc.cpp:204 rc.cpp:204
msgid "CPU color"
msgstr "CPU 颜色"
#: po/rc.cpp:207 rc.cpp:207
msgid "CPU clock color"
msgstr "CPU 时钟颜色"
#: po/rc.cpp:210 rc.cpp:210
msgid "Memory color"
msgstr "内存显示颜色"
#: po/rc.cpp:213 rc.cpp:213
msgid "Swap color"
msgstr "虚拟内存颜色"
#: po/rc.cpp:216 rc.cpp:216
msgid "Download speed color"
msgstr "下载速度颜色"
#: po/rc.cpp:219 rc.cpp:219
msgid "Upload speed color"
msgstr "上传速度颜色"
#: po/rc.cpp:222 rc.cpp:222
msgid "Battery active color"
msgstr "电池使用状态提示颜色"
#: po/rc.cpp:225 rc.cpp:225
msgid "Battery inactive color"
msgstr "电池未使用状态提示颜色"
#: po/rc.cpp:228 rc.cpp:228
msgid ""
"Detailed information may be found on <a href=\"http://arcanis.name/projects/"
"awesome-widgets/\">project homepage</a>"
msgstr ""
"详情请参照 <a href=\"http://arcanis.name/projects/ awesome-widgets/\">项目主"
"页</a>"
#: po/rc.cpp:234 rc.cpp:234
msgid "Ctrl+B"
msgstr "Ctrl+B"
#: po/rc.cpp:237 rc.cpp:237
msgid "Ctrl+I"
msgstr "Ctrl+I"
#: po/rc.cpp:240 rc.cpp:240
msgid "Ctrl+U"
msgstr "Ctrl+U"
#: po/rc.cpp:244 rc.cpp:244
msgctxt "NAME OF TRANSLATORS"
msgid "Your names"
msgstr "用户名"
#: po/rc.cpp:245 rc.cpp:245
msgctxt "EMAIL OF TRANSLATORS"
msgid "Your emails"
msgstr "用户邮箱"
#, fuzzy
#~ msgid "Interval"
#~ msgstr "时间周期"
#~ msgid "Desktop check cmd"
#~ msgstr "检测桌面命令"
#~ msgid "Custom command"
#~ msgstr "自定义命令"
#~ msgid "Battery device"
#~ msgstr "电池设备"
#~ msgid "\"/sys/class/power_supply/BAT0/capacity\" by default"
#~ msgstr "默认为 \"/sys/class/power_supply/BAT0/capacity\""

View File

@ -1,166 +0,0 @@
/***************************************************************************
* 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])->getImage(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

@ -1,295 +0,0 @@
<?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

@ -1,228 +0,0 @@
<?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

@ -0,0 +1,3 @@
[Project]
Manager=KDevCMakeManager
Name=awesome-widgets

View File

@ -0,0 +1,41 @@
set(SUBPROJECT ${PROJECT_LIBRARY})
message(STATUS "Subproject ${SUBPROJECT}")
add_definitions(-DTRANSLATION_DOMAIN=\"plasma_applet_org.kde.plasma.awesomewidget\")
include_directories(
${CMAKE_SOURCE_DIR}
${CMAKE_BINARY_DIR}
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_BINARY_DIR}/../
${PROJECT_TRDPARTY_DIR}
${Qt_INCLUDE}
${Kf5_INCLUDE}
)
file(GLOB SUBPROJECT_SOURCE *.cpp ${PROJECT_TRDPARTY_DIR}/qreplytimeout/*.cpp ${CMAKE_SOURCE_DIR}/*.cpp)
file(GLOB SUBPROJECT_HEADER *.h ${PROJECT_TRDPARTY_DIR}/qreplytimeout/*.h)
file(GLOB SUBPROJECT_UI *.ui)
set(SUBPROJECT_GRAPHITEMS ${CMAKE_CURRENT_SOURCE_DIR}/desktops)
set(SUBPROJECT_QUOTES ${CMAKE_CURRENT_SOURCE_DIR}/quotes)
set(SUBPROJECT_SCRIPTS ${CMAKE_CURRENT_SOURCE_DIR}/scripts)
set(SUBPROJECT_UPGRADE ${CMAKE_CURRENT_SOURCE_DIR}/upgrade)
set(SUBPROJECT_WEATHER ${CMAKE_CURRENT_SOURCE_DIR}/weather)
file(GLOB SUBPROJECT_WEATHER_JSON_IN *.json)
file(RELATIVE_PATH SUBPROJECT_WEATHER_JSON ${CMAKE_SOURCE_DIR} ${SUBPROJECT_WEATHER_JSON_IN})
# prepare
configure_file(${SUBPROJECT_WEATHER_JSON_IN} ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT_WEATHER_JSON})
qt5_wrap_cpp(SUBPROJECT_MOC_SOURCE ${SUBPROJECT_HEADER})
qt5_wrap_ui(SUBPROJECT_UI_HEADER ${SUBPROJECT_UI})
add_library(${SUBPROJECT} STATIC ${SUBPROJECT_SOURCE} ${SUBPROJECT_MOC_SOURCE}
${SUBPROJECT_HEADER} ${SUBPROJECT_UI_HEADER})
target_link_libraries(${SUBPROJECT} ${Qt_LIBRARIES} ${Kf5_LIBRARIES})
# install
install(DIRECTORY ${SUBPROJECT_GRAPHITEMS} DESTINATION ${DATA_INSTALL_DIR}/${PROJECT_NAME})
install(DIRECTORY ${SUBPROJECT_QUOTES} DESTINATION ${DATA_INSTALL_DIR}/${PROJECT_NAME})
install(DIRECTORY ${SUBPROJECT_SCRIPTS} DESTINATION ${DATA_INSTALL_DIR}/${PROJECT_NAME})
install(DIRECTORY ${SUBPROJECT_UPGRADE} DESTINATION ${DATA_INSTALL_DIR}/${PROJECT_NAME})
install(DIRECTORY ${SUBPROJECT_WEATHER} DESTINATION ${DATA_INSTALL_DIR}/${PROJECT_NAME})
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT_WEATHER_JSON} DESTINATION ${DATA_INSTALL_DIR}/${PROJECT_NAME}/weather)

View File

@ -0,0 +1,252 @@
/***************************************************************************
* 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 "abstractextitem.h"
#include <QDir>
#include <QSettings>
#include <QStandardPaths>
#include <QTime>
#include "awdebug.h"
#include "version.h"
AbstractExtItem::AbstractExtItem(QWidget *parent, const QString desktopName,
const QStringList directories)
: QDialog(parent),
m_fileName(desktopName),
m_dirs(directories)
{
qCDebug(LOG_LIB);
qCDebug(LOG_LIB) << "Desktop name" << desktopName;
qCDebug(LOG_LIB) << "Directories" << directories;
m_name = m_fileName;
}
AbstractExtItem::~AbstractExtItem()
{
qCDebug(LOG_LIB);
}
template <class T>
T *AbstractExtItem::copy(const QString _fileName, const int _number)
{
Q_UNUSED(_fileName)
Q_UNUSED(_number)
qCDebug(LOG_LIB);
// an analog of pure virtual method
return new T();
}
int AbstractExtItem::apiVersion() const
{
qCDebug(LOG_LIB);
return m_apiVersion;
}
QString AbstractExtItem::comment() const
{
qCDebug(LOG_LIB);
return m_comment;
}
QStringList AbstractExtItem::directories() const
{
qCDebug(LOG_LIB);
return m_dirs;
}
QString AbstractExtItem::fileName() const
{
qCDebug(LOG_LIB);
return m_fileName;
}
int AbstractExtItem::interval() const
{
qCDebug(LOG_LIB);
return m_interval;
}
bool AbstractExtItem::isActive() const
{
qCDebug(LOG_LIB);
return m_active;
}
QString AbstractExtItem::name() const
{
qCDebug(LOG_LIB);
return m_name;
}
int AbstractExtItem::number() const
{
qCDebug(LOG_LIB);
return m_number;
}
QString AbstractExtItem::tag(const QString _type) const
{
qCDebug(LOG_LIB);
qCDebug(LOG_LIB) << "Tag type" << _type;
return QString("%1%2").arg(_type).arg(m_number);
}
void AbstractExtItem::setApiVersion(const int _apiVersion)
{
qCDebug(LOG_LIB);
qCDebug(LOG_LIB) << "Version" << _apiVersion;
m_apiVersion = _apiVersion;
}
void AbstractExtItem::setActive(const bool _state)
{
qCDebug(LOG_LIB);
qCDebug(LOG_LIB) << "State" << _state;
m_active = _state;
}
void AbstractExtItem::setComment(const QString _comment)
{
qCDebug(LOG_LIB);
qCDebug(LOG_LIB) << "Comment" << _comment;
m_comment = _comment;
}
void AbstractExtItem::setInterval(const int _interval)
{
qCDebug(LOG_LIB);
qCDebug(LOG_LIB) << "Interval" << _interval;
if (_interval <= 0) return;
m_interval = _interval;
}
void AbstractExtItem::setName(const QString _name)
{
qCDebug(LOG_LIB);
qCDebug(LOG_LIB) << "Name" << _name;
m_name = _name;
}
void AbstractExtItem::setNumber(int _number)
{
qCDebug(LOG_LIB);
qCDebug(LOG_LIB) << "Number" << _number;
if (_number == -1)
_number = []() {
qCWarning(LOG_LIB) << "Number is empty, generate new one";
qsrand(QTime::currentTime().msec());
int n = qrand() % 1000;
qCInfo(LOG_LIB) << "Generated number is" << n;
return n;
}();
m_number = _number;
}
void AbstractExtItem::readConfiguration()
{
qCDebug(LOG_LIB);
for (int i=m_dirs.count()-1; i>=0; i--) {
if (!QDir(m_dirs.at(i)).entryList(QDir::Files).contains(m_fileName)) continue;
QSettings settings(QString("%1/%2").arg(m_dirs.at(i)).arg(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"), m_apiVersion).toInt());
setActive(settings.value(QString("X-AW-Active"), QVariant(m_active)).toString() == QString("true"));
setInterval(settings.value(QString("X-AW-Interval"), m_interval).toInt());
setNumber(settings.value(QString("X-AW-Number"), m_number).toInt());
settings.endGroup();
}
}
bool AbstractExtItem::tryDelete() const
{
qCDebug(LOG_LIB);
foreach(QString dir, m_dirs) {
bool status = QFile::remove(QString("%1/%2").arg(dir).arg(m_fileName));
qCInfo(LOG_LIB) << "Remove file" << QString("%1/%2").arg(dir).arg(m_fileName) << status;
}
// check if exists
foreach(QString dir, m_dirs)
if (QFile::exists(QString("%1/%2").arg(dir).arg(m_fileName))) return false;
return true;
}
void AbstractExtItem::writeConfiguration() const
{
qCDebug(LOG_LIB);
QSettings settings(QString("%1/%2").arg(m_dirs.first()).arg(m_fileName), QSettings::IniFormat);
qCInfo(LOG_LIB) << "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-Active"), QVariant(m_active).toString());
settings.setValue(QString("X-AW-Interval"), m_interval);
settings.setValue(QString("X-AW-Number"), m_number);
settings.endGroup();
settings.sync();
}

View File

@ -0,0 +1,84 @@
/***************************************************************************
* 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 ABSTRACTEXTITEM_H
#define ABSTRACTEXTITEM_H
#include <QDialog>
#include <QInputDialog>
#include <QVariant>
class AbstractExtItem : public QDialog
{
Q_OBJECT
Q_PROPERTY(bool active READ isActive WRITE setActive)
Q_PROPERTY(int apiVersion READ apiVersion WRITE setApiVersion)
Q_PROPERTY(QString comment READ comment WRITE setComment)
Q_PROPERTY(QStringList directories READ directories)
Q_PROPERTY(QString fileName READ fileName)
Q_PROPERTY(int interval READ interval WRITE setInterval)
Q_PROPERTY(QString name READ name WRITE setName)
Q_PROPERTY(int number READ number WRITE setNumber)
Q_PROPERTY(QString uniq READ uniq)
public:
explicit AbstractExtItem(QWidget *parent = nullptr, const QString desktopName = QString(),
const QStringList directories = QStringList());
virtual ~AbstractExtItem();
template <class T> T *copy(const QString _fileName, const int _number);
// get methods
int apiVersion() const;
QString comment() const;
QStringList directories() const;
QString fileName() const;
int interval() const;
bool isActive() const;
QString name() const;
int number() const;
QString tag(const QString _type) const;
virtual QString uniq() const = 0;
// set methods
void setApiVersion(const int _apiVersion = 0);
void setActive(const bool _state = true);
void setComment(const QString _comment = QString("empty"));
void setInterval(const int _interval = 1);
void setName(const QString _name = QString("none"));
void setNumber(int _number = -1);
public slots:
virtual void readConfiguration();
virtual QVariantHash run() = 0;
virtual int showConfiguration(const QVariant args = QVariant()) = 0;
bool tryDelete() const;
virtual void writeConfiguration() const;
private:
QString m_fileName;
QStringList m_dirs;
virtual void translate() = 0;
// properties
int m_apiVersion = 0;
bool m_active = true;
QString m_comment = QString("empty");
int m_interval = 1;
QString m_name = QString("none");
int m_number = -1;
};
#endif /* ABSTRACTEXTITEM_H */

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/ *
***************************************************************************/
#include "abstractextitemaggregator.h"
#include <KI18n/KLocalizedString>
#include <QHBoxLayout>
#include <QInputDialog>
#include <QLineEdit>
#include "awdebug.h"
AbstractExtItemAggregator::AbstractExtItemAggregator(QWidget *parent)
: QWidget(parent)
{
qCDebug(LOG_LIB);
dialog = new QDialog(this);
widgetDialog = new QListWidget(dialog);
dialogButtons = new QDialogButtonBox(QDialogButtonBox::Open | QDialogButtonBox::Close,
Qt::Vertical, dialog);
copyButton = dialogButtons->addButton(i18n("Copy"), QDialogButtonBox::ActionRole);
createButton = dialogButtons->addButton(i18n("Create"), QDialogButtonBox::ActionRole);
deleteButton = dialogButtons->addButton(i18n("Remove"), QDialogButtonBox::ActionRole);
QHBoxLayout *layout = new QHBoxLayout(dialog);
layout->addWidget(widgetDialog);
layout->addWidget(dialogButtons);
dialog->setLayout(layout);
connect(dialogButtons, SIGNAL(clicked(QAbstractButton *)),
this, SLOT(editItemButtonPressed(QAbstractButton *)));
connect(dialogButtons, SIGNAL(rejected()), dialog, SLOT(reject()));
connect(widgetDialog, SIGNAL(itemActivated(QListWidgetItem *)),
this, SLOT(editItemActivated(QListWidgetItem *)));
}
AbstractExtItemAggregator::~AbstractExtItemAggregator()
{
qCDebug(LOG_LIB);
delete dialog;
}
QString AbstractExtItemAggregator::getName()
{
qCDebug(LOG_LIB);
bool ok;
QString name = QInputDialog::getText(this, i18n("Enter file name"),
i18n("File name"), QLineEdit::Normal,
QString(""), &ok);
if ((!ok) || (name.isEmpty())) return QString("");
if (!name.endsWith(QString(".desktop"))) name += QString(".desktop");
return name;
}
QVariant AbstractExtItemAggregator::configArgs() const
{
qCDebug(LOG_LIB);
return m_configArgs;
}
void AbstractExtItemAggregator::setConfigArgs(const QVariant _configArgs)
{
qCDebug(LOG_LIB);
qCDebug(LOG_LIB) << "Configuration arguments" << _configArgs;
m_configArgs = _configArgs;
}
void AbstractExtItemAggregator::editItemActivated(QListWidgetItem *item)
{
Q_UNUSED(item)
qCDebug(LOG_LIB);
return editItem();
}
void AbstractExtItemAggregator::editItemButtonPressed(QAbstractButton *button)
{
qCDebug(LOG_LIB);
if (static_cast<QPushButton *>(button) == copyButton)
return copyItem();
else if (static_cast<QPushButton *>(button) == createButton)
return createItem();
else if (static_cast<QPushButton *>(button) == deleteButton)
return deleteItem();
else if (dialogButtons->buttonRole(button) == QDialogButtonBox::AcceptRole)
return editItem();
}

View File

@ -0,0 +1,65 @@
/***************************************************************************
* 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 ABSTRACTEXTITEMAGGREGATOR_H
#define ABSTRACTEXTITEMAGGREGATOR_H
#include <QDialog>
#include <QDialogButtonBox>
#include <QListWidget>
#include <QObject>
#include <QPushButton>
#include <QWidget>
// additinal class since QObject macro does not allow class templates
class AbstractExtItemAggregator : public QWidget
{
Q_OBJECT
Q_PROPERTY(QVariant configArgs READ configArgs WRITE setConfigArgs)
public:
explicit AbstractExtItemAggregator(QWidget *parent = nullptr);
virtual ~AbstractExtItemAggregator();
QString getName();
// ui
QDialog *dialog = nullptr;
QListWidget *widgetDialog = nullptr;
QDialogButtonBox *dialogButtons = nullptr;
QPushButton *copyButton = nullptr;
QPushButton *createButton = nullptr;
QPushButton *deleteButton = nullptr;
// get methods
QVariant configArgs() const;
// set methods
void setConfigArgs(const QVariant _configArgs);
private slots:
void editItemActivated(QListWidgetItem *item);
void editItemButtonPressed(QAbstractButton *button);
private:
QVariant m_configArgs;
// methods
virtual void copyItem() = 0;
virtual void createItem() = 0;
virtual void deleteItem() = 0;
virtual void editItem() = 0;
};
#endif /* ABSTRACTEXTITEMAGGREGATOR_H */

View File

@ -0,0 +1,139 @@
{
"__url": "http://openweathermap.org/weather-conditions",
"image": {
"__comment": "should be described as html image with full path inside",
"default": "",
"800": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/01d.png\">",
"801": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/02d.png\">",
"802": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/03d.png\">",
"803": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/03d.png\">",
"804": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/04d.png\">",
"300": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/09d.png\">",
"301": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/09d.png\">",
"302": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/09d.png\">",
"310": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/09d.png\">",
"311": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/09d.png\">",
"312": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/09d.png\">",
"313": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/09d.png\">",
"314": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/09d.png\">",
"321": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/09d.png\">",
"520": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/09d.png\">",
"521": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/09d.png\">",
"522": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/09d.png\">",
"531": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/09d.png\">",
"500": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/10d.png\">",
"501": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/10d.png\">",
"502": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/10d.png\">",
"503": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/10d.png\">",
"504": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/10d.png\">",
"200": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/11d.png\">",
"201": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/11d.png\">",
"202": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/11d.png\">",
"210": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/11d.png\">",
"211": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/11d.png\">",
"212": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/11d.png\">",
"221": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/11d.png\">",
"230": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/11d.png\">",
"231": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/11d.png\">",
"232": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/11d.png\">",
"511": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/13d.png\">",
"600": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/13d.png\">",
"601": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/13d.png\">",
"602": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/13d.png\">",
"611": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/13d.png\">",
"612": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/13d.png\">",
"615": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/13d.png\">",
"616": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/13d.png\">",
"620": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/13d.png\">",
"621": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/13d.png\">",
"622": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/13d.png\">",
"701": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/50d.png\">",
"711": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/50d.png\">",
"721": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/50d.png\">",
"731": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/50d.png\">",
"741": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/50d.png\">",
"751": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/50d.png\">",
"761": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/50d.png\">",
"762": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/50d.png\">",
"771": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/50d.png\">",
"781": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/50d.png\">"
},
"text": {
"default": "\u2604",
"800": "\u2600",
"801": "\u26C5",
"802": "\u2601",
"803": "\u2601",
"804": "\u2601",
"300": "\u2602",
"301": "\u2602",
"302": "\u2602",
"310": "\u2602",
"311": "\u2602",
"312": "\u2602",
"313": "\u2602",
"314": "\u2602",
"321": "\u2602",
"520": "\u2602",
"521": "\u2602",
"522": "\u2602",
"531": "\u2602",
"500": "\u2614",
"501": "\u2614",
"502": "\u2614",
"503": "\u2614",
"504": "\u2614",
"200": "\u2608",
"201": "\u2608",
"202": "\u2608",
"210": "\u2608",
"211": "\u2608",
"212": "\u2608",
"221": "\u2608",
"230": "\u2608",
"231": "\u2608",
"232": "\u2608",
"511": "\u2603",
"600": "\u2603",
"601": "\u2603",
"602": "\u2603",
"611": "\u2603",
"612": "\u2603",
"615": "\u2603",
"616": "\u2603",
"620": "\u2603",
"621": "\u2603",
"622": "\u2603",
"701": "\u26C5",
"711": "\u26C5",
"721": "\u26C5",
"731": "\u26C5",
"741": "\u26C5",
"751": "\u26C5",
"761": "\u26C5",
"762": "\u26C5",
"771": "\u26C5",
"781": "\u26C5"
}
}

View File

@ -9,3 +9,5 @@ X-AW-Type=Horizontal
X-AW-Direction=LeftToRight
X-AW-Height=25
X-AW-Width=100
X-AW-ApiVersion=2
X-AW-Number=3

View File

@ -9,3 +9,5 @@ X-AW-Type=Horizontal
X-AW-Direction=LeftToRight
X-AW-Height=25
X-AW-Width=100
X-AW-ApiVersion=2
X-AW-Number=0

View File

@ -9,3 +9,5 @@ X-AW-Type=Horizontal
X-AW-Direction=LeftToRight
X-AW-Height=25
X-AW-Width=100
X-AW-ApiVersion=2
X-AW-Number=1

View File

@ -9,3 +9,5 @@ X-AW-Type=Horizontal
X-AW-Direction=LeftToRight
X-AW-Height=25
X-AW-Width=100
X-AW-ApiVersion=2
X-AW-Number=2

View File

@ -0,0 +1,276 @@
/***************************************************************************
* 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 EXTITEMAGGREGATOR_H
#define EXTITEMAGGREGATOR_H
#include <KI18n/KLocalizedString>
#include <QDir>
#include <QSettings>
#include <QStandardPaths>
#include "awdebug.h"
#include "abstractextitemaggregator.h"
template <class T>
class ExtItemAggregator : public AbstractExtItemAggregator
{
public:
explicit ExtItemAggregator(QWidget *parent, const QString type)
: AbstractExtItemAggregator(parent),
m_type(type)
{
qCDebug(LOG_LIB);
qCDebug(LOG_LIB) << "Type" << type;
qSetMessagePattern(LOG_FORMAT);
initItems();
};
virtual ~ExtItemAggregator()
{
qCDebug(LOG_LIB);
m_items.clear();
}
void editItems()
{
qCDebug(LOG_LIB);
repaint();
int ret = dialog->exec();
qCInfo(LOG_LIB) << "Dialog returns" << ret;
};
void initItems()
{
qCDebug(LOG_LIB);
m_items.clear();
m_items = getItems();
};
T *itemByTag(const QString _tag) const
{
qCDebug(LOG_LIB);
qCDebug(LOG_LIB) << "Tag" << _tag;
T *found = nullptr;
foreach(T *item, m_items) {
if (item->tag() != _tag) continue;
found = item;
break;
}
if (found == nullptr)
qCWarning(LOG_LIB) << "Could not find item by tag" << _tag;
return found;
}
T *itemByTagNumber(const int _number) const
{
qCDebug(LOG_LIB);
qCDebug(LOG_LIB) << "Number" << _number;
T *found = nullptr;
foreach(T *item, m_items) {
if (item->number() != _number) continue;
found = item;
break;
}
if (found == nullptr)
qCWarning(LOG_LIB) << "Could not find item by number" << _number;
return found;
}
T *itemFromWidget() const
{
qCDebug(LOG_LIB);
QListWidgetItem *widgetItem = widgetDialog->currentItem();
if (widgetItem == nullptr) return nullptr;
T *found = nullptr;
foreach(T *item, m_items) {
if (item->fileName() != widgetItem->text()) continue;
found = item;
break;
}
if (found == nullptr)
qCWarning(LOG_LIB) << "Could not find item by name" << widgetItem->text();
return found;
};
QList<T *> items() const
{
qCDebug(LOG_LIB);
return m_items;
};
int uniqNumber() const
{
qCDebug(LOG_LIB);
QList<int> tagList;
foreach(T *item, m_items) tagList.append(item->number());
int number = 0;
while (tagList.contains(number)) number++;
return number;
};
private:
QList<T *> m_items;
QString m_type;
// init method
QList<T *> getItems()
{
qCDebug(LOG_LIB);
// create directory at $HOME
QString localDir = QString("%1/awesomewidgets/%2")
.arg(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation))
.arg(m_type);
QDir localDirectory;
if (localDirectory.mkpath(localDir))
qCInfo(LOG_LIB) << "Created directory" << localDir;
QStringList dirs = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation,
QString("awesomewidgets/%1").arg(m_type),
QStandardPaths::LocateDirectory);
QStringList names;
QList<T *> items;
foreach(QString dir, dirs) {
QStringList files = QDir(dir).entryList(QDir::Files, QDir::Name);
foreach(QString file, files) {
if (!file.endsWith(QString(".desktop"))) continue;
if (names.contains(file)) continue;
qCInfo(LOG_LIB) << "Found file" << file << "in" << dir;
names.append(file);
items.append(new T(this, file, dirs));
}
}
// sort items
std::sort(items.begin(), items.end(), [](const T *lhs, const T *rhs){
return lhs->number() < rhs->number();
});
return items;
};
void repaint()
{
qCDebug(LOG_LIB);
widgetDialog->clear();
foreach(T *_item, m_items) {
QListWidgetItem *item = new QListWidgetItem(_item->fileName(), widgetDialog);
QStringList tooltip;
tooltip.append(i18n("Name: %1", _item->name()));
tooltip.append(i18n("Comment: %1", _item->comment()));
tooltip.append(i18n("Identity: %1", _item->uniq()));
item->setToolTip(tooltip.join(QChar('\n')));
widgetDialog->addItem(item);
}
};
// methods
void copyItem()
{
qCDebug(LOG_LIB);
T *source = itemFromWidget();
QString fileName = getName();
int number = uniqNumber();
if ((source == nullptr) || (fileName.isEmpty())) {
qCWarning(LOG_LIB) << "Nothing to copy";
return;
}
T *newItem = source->copy(fileName, number);
if (newItem->showConfiguration(configArgs()) == 1) {
initItems();
repaint();
}
};
void createItem()
{
qCDebug(LOG_LIB);
QString fileName = getName();
int number = uniqNumber();
QStringList dirs = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation,
QString("awesomewidgets/%1").arg(m_type),
QStandardPaths::LocateDirectory);
if (fileName.isEmpty()) {
qCWarning(LOG_LIB) << "Nothing to create";
return;
};
T *newItem = new T(this, fileName, dirs);
newItem->setNumber(number);
if (newItem->showConfiguration(configArgs()) == 1) {
initItems();
repaint();
}
};
void deleteItem()
{
qCDebug(LOG_LIB);
T *source = itemFromWidget();
if (source == nullptr) {
qCWarning(LOG_LIB) << "Nothing to delete";
return;
};
if (source->tryDelete()) {
initItems();
repaint();
}
};
void editItem()
{
qCDebug(LOG_LIB);
T *source = itemFromWidget();
if (source == nullptr) {
qCWarning(LOG_LIB) << "Nothing to edit";
return;
};
if (source->showConfiguration(configArgs()) == 1) {
initItems();
repaint();
}
};
};
#endif /* EXTITEMAGGREGATOR_H */

View File

@ -0,0 +1,268 @@
/***************************************************************************
* 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 "extquotes.h"
#include "ui_extquotes.h"
#include <KI18n/KLocalizedString>
#include <QDir>
#include <QJsonDocument>
#include <QJsonParseError>
#include <QNetworkAccessManager>
#include <QNetworkRequest>
#include <QSettings>
#include <qreplytimeout/qreplytimeout.h>
#include "awdebug.h"
#include "version.h"
ExtQuotes::ExtQuotes(QWidget *parent, const QString quotesName,
const QStringList directories)
: AbstractExtItem(parent, quotesName, directories),
ui(new Ui::ExtQuotes)
{
qCDebug(LOG_LIB);
readConfiguration();
ui->setupUi(this);
translate();
values[tag(QString("ask"))] = 0.0;
values[tag(QString("askchg"))] = 0.0;
values[tag(QString("percaskchg"))] = 0.0;
values[tag(QString("bid"))] = 0.0;
values[tag(QString("bidchg"))] = 0.0;
values[tag(QString("percbidchg"))] = 0.0;
values[tag(QString("price"))] = 0.0;
values[tag(QString("pricechg"))] = 0.0;
values[tag(QString("percpricechg"))] = 0.0;
manager = new QNetworkAccessManager(this);
connect(manager, SIGNAL(finished(QNetworkReply *)),
this, SLOT(quotesReplyReceived(QNetworkReply *)));
}
ExtQuotes::~ExtQuotes()
{
qCDebug(LOG_LIB);
disconnect(manager, SIGNAL(finished(QNetworkReply *)), this, SLOT(quotesReplyReceived(QNetworkReply *)));
delete manager;
delete ui;
}
ExtQuotes *ExtQuotes::copy(const QString _fileName, const int _number)
{
qCDebug(LOG_LIB);
qCDebug(LOG_LIB) << "File" << _fileName;
qCDebug(LOG_LIB) << "Number" << _number;
ExtQuotes *item = new ExtQuotes(static_cast<QWidget *>(parent()), _fileName, directories());
item->setActive(isActive());
item->setApiVersion(apiVersion());
item->setComment(comment());
item->setInterval(interval());
item->setName(name());
item->setNumber(_number);
item->setTicker(ticker());
return item;
}
QString ExtQuotes::ticker() const
{
qCDebug(LOG_LIB);
return m_ticker;
}
QString ExtQuotes::uniq() const
{
qCDebug(LOG_LIB);
return m_ticker;
}
void ExtQuotes::setTicker(const QString _ticker)
{
qCDebug(LOG_LIB);
qCDebug(LOG_LIB) << "Ticker" << _ticker;
m_ticker = _ticker;
}
void ExtQuotes::readConfiguration()
{
qCDebug(LOG_LIB);
AbstractExtItem::readConfiguration();
for (int i=directories().count()-1; i>=0; i--) {
if (!QDir(directories().at(i)).entryList(QDir::Files).contains(fileName())) continue;
QSettings settings(QString("%1/%2").arg(directories().at(i)).arg(fileName()), QSettings::IniFormat);
settings.beginGroup(QString("Desktop Entry"));
setTicker(settings.value(QString("X-AW-Ticker"), m_ticker).toString());
settings.endGroup();
}
// update for current API
if ((apiVersion() > 0) && (apiVersion() < AWEQAPI)) {
qCWarning(LOG_LIB) << "Bump API version from" << apiVersion() << "to" << AWEQAPI;
setApiVersion(AWEQAPI);
writeConfiguration();
}
}
QVariantHash ExtQuotes::run()
{
qCDebug(LOG_LIB);
if ((!isActive()) || (isRunning)) return values;
if (times == 1) {
qCInfo(LOG_LIB) << "Send request";
isRunning = true;
QNetworkReply *reply = manager->get(QNetworkRequest(QUrl(url())));
new QReplyTimeout(reply, 1000);
}
// update value
if (times >= interval()) times = 0;
times++;
return values;
}
int ExtQuotes::showConfiguration(const QVariant args)
{
Q_UNUSED(args)
qCDebug(LOG_LIB);
ui->lineEdit_name->setText(name());
ui->lineEdit_comment->setText(comment());
ui->label_numberValue->setText(QString("%1").arg(number()));
ui->lineEdit_ticker->setText(m_ticker);
ui->checkBox_active->setCheckState(isActive() ? Qt::Checked : Qt::Unchecked);
ui->spinBox_interval->setValue(interval());
int ret = exec();
if (ret != 1) return ret;
setName(ui->lineEdit_name->text());
setComment(ui->lineEdit_comment->text());
setNumber(ui->label_numberValue->text().toInt());
setApiVersion(AWEQAPI);
setTicker(ui->lineEdit_ticker->text());
setActive(ui->checkBox_active->checkState() == Qt::Checked);
setInterval(ui->spinBox_interval->value());
writeConfiguration();
return ret;
}
void ExtQuotes::writeConfiguration() const
{
qCDebug(LOG_LIB);
AbstractExtItem::writeConfiguration();
QSettings settings(QString("%1/%2").arg(directories().first()).arg(fileName()), QSettings::IniFormat);
qCInfo(LOG_LIB) << "Configuration file" << settings.fileName();
settings.beginGroup(QString("Desktop Entry"));
settings.setValue(QString("X-AW-Ticker"), m_ticker);
settings.endGroup();
settings.sync();
}
void ExtQuotes::quotesReplyReceived(QNetworkReply *reply)
{
qCDebug(LOG_LIB);
qCDebug(LOG_LIB) << "Return code" << reply->error();
qCDebug(LOG_LIB) << "Reply error message" << reply->errorString();
isRunning = false;
QJsonParseError error;
QJsonDocument jsonDoc = QJsonDocument::fromJson(reply->readAll(), &error);
reply->deleteLater();
if ((reply->error() != QNetworkReply::NoError) ||
(error.error != QJsonParseError::NoError)) {
qCWarning(LOG_LIB) << "Parse error" << error.errorString();
return;
}
QVariantMap jsonQuotes = jsonDoc.toVariant().toMap()[QString("query")].toMap();
jsonQuotes = jsonQuotes[QString("results")].toMap()[QString("quote")].toMap();
float value;
// ask
value = jsonQuotes[QString("Ask")].toString().toFloat();
values[tag(QString("askchg"))] = values[QString("ask")].toFloat() == 0.0 ? 0.0 :
value - values[QString("ask")].toFloat();
values[tag(QString("percaskchg"))] = 100.0 * values[QString("askchg")].toFloat() / values[QString("ask")].toFloat();
values[tag(QString("ask"))] = value;
// bid
value = jsonQuotes[QString("Bid")].toString().toFloat();
values[tag(QString("bidchg"))] = values[QString("bid")].toFloat() == 0.0 ? 0.0 :
value - values[QString("bid")].toFloat();
values[tag(QString("percbidchg"))] = 100.0 * values[QString("bidchg")].toFloat() / values[QString("bid")].toFloat();
values[tag(QString("bid"))] = value;
// last trade
value = jsonQuotes[QString("LastTradePriceOnly")].toString().toFloat();
values[tag(QString("pricechg"))] = values[QString("price")].toFloat() == 0.0 ? 0.0 :
value - values[QString("price")].toFloat();
values[tag(QString("percpricechg"))] = 100.0 * values[QString("pricechg")].toFloat() / values[QString("price")].toFloat();
values[tag(QString("price"))] = value;
}
void ExtQuotes::translate()
{
qCDebug(LOG_LIB);
ui->label_name->setText(i18n("Name"));
ui->label_comment->setText(i18n("Comment"));
ui->label_number->setText(i18n("Tag"));
ui->label->setText(i18n("<html><head/><body><p>Use YAHOO! finance ticker to get quotes for the instrument. Refer to <a href=\"http://finance.yahoo.com/\"><span style=\" text-decoration: underline; color:#0057ae;\">http://finance.yahoo.com/</span></a></p></body></html>"));
ui->label_ticker->setText(i18n("Ticker"));
ui->checkBox_active->setText(i18n("Active"));
ui->label_interval->setText(i18n("Interval"));
}
QString ExtQuotes::url() const
{
qCDebug(LOG_LIB);
QString apiUrl = QString(YAHOO_URL);
apiUrl.replace(QString("$TICKER"), m_ticker);
qCInfo(LOG_LIB) << "API url" << apiUrl;
return apiUrl;
}

View File

@ -0,0 +1,72 @@
/***************************************************************************
* 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 EXTQUOTES_H
#define EXTQUOTES_H
#include <QMap>
#include <QNetworkReply>
#include "abstractextitem.h"
#define YAHOO_URL "https://query.yahooapis.com/v1/public/yql?q=select * from yahoo.finance.quotes where symbol=\"$TICKER\"&env=store://datatables.org/alltableswithkeys&format=json"
namespace Ui {
class ExtQuotes;
}
class ExtQuotes : public AbstractExtItem
{
Q_OBJECT
Q_PROPERTY(QString ticker READ ticker WRITE setTicker)
public:
explicit ExtQuotes(QWidget *parent = nullptr, const QString quotesName = QString(),
const QStringList directories = QStringList());
virtual ~ExtQuotes();
ExtQuotes *copy(const QString _fileName, const int _number);
// get methods
QString ticker() const;
QString uniq() const;
// set methods
void setTicker(const QString _ticker = QString("EURUSD=X"));
public slots:
void readConfiguration();
QVariantHash run();
int showConfiguration(const QVariant args = QVariant());
void writeConfiguration() const;
private slots:
void quotesReplyReceived(QNetworkReply *reply);
private:
QNetworkAccessManager *manager;
bool isRunning = false;
Ui::ExtQuotes *ui;
void translate();
QString url() const;
// properties
QString m_ticker = QString("EURUSD=X");
// values
int times = 0;
QVariantHash values;
};
#endif /* EXTQUOTES_H */

View File

@ -0,0 +1,240 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ExtQuotes</class>
<widget class="QDialog" name="ExtQuotes">
<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_number">
<item>
<widget class="QLabel" name="label_number">
<property name="text">
<string>Tag</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_numberValue">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Use YAHOO! finance ticker to get quotes for the instrument. Refer to &lt;a href=&quot;http://finance.yahoo.com/&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0057ae;&quot;&gt;http://finance.yahoo.com/&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&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="layout_ticker">
<item>
<widget class="QLabel" name="label_ticker">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Ticker</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_ticker"/>
</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_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>10</number>
</property>
<property name="value">
<number>60</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>ExtQuotes</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>ExtQuotes</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,437 @@
/***************************************************************************
* 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 <KI18n/KLocalizedString>
#include <QDir>
#include <QJsonDocument>
#include <QJsonParseError>
#include <QSettings>
#include <QStandardPaths>
#include <QTextCodec>
#include "awdebug.h"
#include "version.h"
ExtScript::ExtScript(QWidget *parent, const QString scriptName,
const QStringList directories)
: AbstractExtItem(parent, scriptName, directories),
ui(new Ui::ExtScript)
{
qCDebug(LOG_LIB);
readConfiguration();
readJsonFilters();
ui->setupUi(this);
translate();
value[tag(QString("custom"))] = QString("");
process = new QProcess(this);
connect(process, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(updateValue()));
process->waitForFinished(0);
}
ExtScript::~ExtScript()
{
qCDebug(LOG_LIB);
process->kill();
delete process;
delete ui;
}
ExtScript *ExtScript::copy(const QString _fileName, const int _number)
{
qCDebug(LOG_LIB);
qCDebug(LOG_LIB) << "File" << _fileName;
qCDebug(LOG_LIB) << "Number" << _number;
ExtScript *item = new ExtScript(static_cast<QWidget *>(parent()), _fileName, directories());
item->setActive(isActive());
item->setApiVersion(apiVersion());
item->setComment(comment());
item->setExecutable(executable());
item->setHasOutput(hasOutput());
item->setInterval(interval());
item->setName(name());
item->setNumber(_number);
item->setPrefix(prefix());
item->setRedirect(redirect());
return item;
}
QString ExtScript::executable() const
{
qCDebug(LOG_LIB);
return m_executable;
}
QStringList ExtScript::filters() const
{
qCDebug(LOG_LIB);
return m_filters;
}
bool ExtScript::hasOutput() const
{
qCDebug(LOG_LIB);
return m_output;
}
QString ExtScript::prefix() const
{
qCDebug(LOG_LIB);
return m_prefix;
}
ExtScript::Redirect ExtScript::redirect() const
{
qCDebug(LOG_LIB);
return m_redirect;
}
QString ExtScript::uniq() const
{
qCDebug(LOG_LIB);
return m_executable;
}
QString ExtScript::strRedirect() const
{
qCDebug(LOG_LIB);
QString value;
switch (m_redirect) {
case stdout2stderr:
value = QString("stdout2stderr");
break;
case stderr2stdout:
value = QString("stderr2stdout");
break;
case nothing:
default:
value = QString("nothing");
break;
}
return value;
}
void ExtScript::setExecutable(const QString _executable)
{
qCDebug(LOG_LIB);
qCDebug(LOG_LIB) << "Executable" << _executable;
m_executable = _executable;
}
void ExtScript::setFilters(const QStringList _filters)
{
qCDebug(LOG_LIB);
qCDebug(LOG_LIB) << "Filters" << _filters;
std::for_each(_filters.cbegin(), _filters.cend(),
[this](QString filter) { return updateFilter(filter); });
// foreach(QString filter, _filters)
// updateFilter(filter);
}
void ExtScript::setHasOutput(const bool _state)
{
qCDebug(LOG_LIB);
qCDebug(LOG_LIB) << "State" << _state;
m_output = _state;
}
void ExtScript::setPrefix(const QString _prefix)
{
qCDebug(LOG_LIB);
qCDebug(LOG_LIB) << "Prefix" << _prefix;
m_prefix = _prefix;
}
void ExtScript::setRedirect(const Redirect _redirect)
{
qCDebug(LOG_LIB);
qCDebug(LOG_LIB) << "Redirect" << _redirect;
m_redirect = _redirect;
}
void ExtScript::setStrRedirect(const QString _redirect)
{
qCDebug(LOG_LIB);
qCDebug(LOG_LIB) << "Redirect" << _redirect;
if (_redirect == QString("stdout2sdterr"))
m_redirect = stdout2stderr;
else if (_redirect == QString("stderr2sdtout"))
m_redirect = stderr2stdout;
else
m_redirect = nothing;
}
QString ExtScript::applyFilters(QString _value) const
{
qCDebug(LOG_LIB);
qCDebug(LOG_LIB) << "Value" << _value;
foreach(QString filt, m_filters) {
qCInfo(LOG_LIB) << "Found filter" << filt;
QVariantMap filter = jsonFilters[filt].toMap();
if (filter.isEmpty()) {
qCWarning(LOG_LIB) << "Could not find filter" << _value << "in the json";
continue;
}
foreach(QString f, filter.keys())
_value.replace(f, filter[f].toString());
}
return _value;
}
void ExtScript::updateFilter(const QString _filter, const bool _add)
{
qCDebug(LOG_LIB);
qCDebug(LOG_LIB) << "Filter" << _filter;
qCDebug(LOG_LIB) << "Should be added" << _add;
if (_add) {
if (m_filters.contains(_filter)) return;
m_filters.append(_filter);
} else {
m_filters.removeOne(_filter);
}
}
void ExtScript::readConfiguration()
{
qCDebug(LOG_LIB);
AbstractExtItem::readConfiguration();
for (int i=directories().count()-1; i>=0; i--) {
if (!QDir(directories().at(i)).entryList(QDir::Files).contains(fileName())) continue;
QSettings settings(QString("%1/%2").arg(directories().at(i)).arg(fileName()), QSettings::IniFormat);
settings.beginGroup(QString("Desktop Entry"));
setExecutable(settings.value(QString("Exec"), m_executable).toString());
setPrefix(settings.value(QString("X-AW-Prefix"), m_prefix).toString());
setHasOutput(settings.value(QString("X-AW-Output"), QVariant(m_output)).toString() == QString("true"));
setStrRedirect(settings.value(QString("X-AW-Redirect"), strRedirect()).toString());
// api == 3
setFilters(settings.value(QString("X-AW-Filters"), m_filters).toString()
.split(QChar(','), QString::SkipEmptyParts));
settings.endGroup();
}
if (!m_output)
setRedirect(stdout2stderr);
// update for current API
if ((apiVersion() > 0) && (apiVersion() < AWESAPI)) {
qCWarning(LOG_LIB) << "Bump API version from" << apiVersion() << "to" << AWESAPI;
setApiVersion(AWESAPI);
writeConfiguration();
}
}
void ExtScript::readJsonFilters()
{
qCDebug(LOG_LIB);
QString fileName = QStandardPaths::locate(QStandardPaths::GenericDataLocation,
QString("awesomewidgets/scripts/awesomewidgets-extscripts-filters.json"));
qCInfo(LOG_LIB) << "Filters file" << fileName;
QFile jsonFile(fileName);
if (!jsonFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
qCWarning(LOG_LIB) << "Could not open" << fileName;
return;
}
QString jsonText = jsonFile.readAll();
jsonFile.close();
QJsonParseError error;
QJsonDocument jsonDoc = QJsonDocument::fromJson(jsonText.toUtf8(), &error);
if (error.error != QJsonParseError::NoError) {
qCWarning(LOG_LIB) << "Parse error" << error.errorString();
return;
}
jsonFilters = jsonDoc.toVariant().toMap();
qCInfo(LOG_LIB) << "Filters" << jsonFilters;
}
QVariantHash ExtScript::run()
{
qCDebug(LOG_LIB);
if (!isActive()) return value;
if ((times == 1) && (process->state() == QProcess::NotRunning)) {
QStringList cmdList;
if (!m_prefix.isEmpty()) cmdList.append(m_prefix);
cmdList.append(m_executable);
qCInfo(LOG_LIB) << "Run cmd" << cmdList.join(QChar(' '));
process->start(cmdList.join(QChar(' ')));
} else if (times >= interval())
times = 0;
times++;
return value;
}
int ExtScript::showConfiguration(const QVariant args)
{
Q_UNUSED(args)
qCDebug(LOG_LIB);
ui->lineEdit_name->setText(name());
ui->lineEdit_comment->setText(comment());
ui->label_numberValue->setText(QString("%1").arg(number()));
ui->lineEdit_command->setText(m_executable);
ui->lineEdit_prefix->setText(m_prefix);
ui->checkBox_active->setCheckState(isActive() ? Qt::Checked : Qt::Unchecked);
ui->checkBox_output->setCheckState(m_output ? Qt::Checked : Qt::Unchecked);
ui->comboBox_redirect->setCurrentIndex(static_cast<int>(m_redirect));
ui->spinBox_interval->setValue(interval());
// filters
ui->checkBox_colorFilter->setCheckState(m_filters.contains(QString("color")) ? Qt::Checked : Qt::Unchecked);
ui->checkBox_linesFilter->setCheckState(m_filters.contains(QString("newline")) ? Qt::Checked : Qt::Unchecked);
ui->checkBox_spaceFilter->setCheckState(m_filters.contains(QString("space")) ? Qt::Checked : Qt::Unchecked);
int ret = exec();
if (ret != 1) return ret;
setName(ui->lineEdit_name->text());
setComment(ui->lineEdit_comment->text());
setNumber(ui->label_numberValue->text().toInt());
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());
// filters
updateFilter(QString("color"), ui->checkBox_colorFilter->checkState() == Qt::Checked);
updateFilter(QString("newline"), ui->checkBox_linesFilter->checkState() == Qt::Checked);
updateFilter(QString("space"), ui->checkBox_spaceFilter->checkState() == Qt::Checked);
writeConfiguration();
return ret;
}
void ExtScript::writeConfiguration() const
{
qCDebug(LOG_LIB);
AbstractExtItem::writeConfiguration();
QSettings settings(QString("%1/%2").arg(directories().first()).arg(fileName()), QSettings::IniFormat);
qCInfo(LOG_LIB) << "Configuration file" << settings.fileName();
settings.beginGroup(QString("Desktop Entry"));
settings.setValue(QString("Exec"), m_executable);
settings.setValue(QString("X-AW-Prefix"), m_prefix);
settings.setValue(QString("X-AW-Output"), QVariant(m_output).toString());
settings.setValue(QString("X-AW-Redirect"), strRedirect());
settings.setValue(QString("X-AW-Filters"), m_filters.join(QChar(',')));
settings.endGroup();
settings.sync();
}
void ExtScript::updateValue()
{
qCDebug(LOG_LIB);
qCInfo(LOG_LIB) << "Cmd returns" << process->exitCode();
QString qdebug = QTextCodec::codecForMib(106)->toUnicode(process->readAllStandardError()).trimmed();
qCInfo(LOG_LIB) << "Error" << qdebug;
QString qoutput = QTextCodec::codecForMib(106)->toUnicode(process->readAllStandardOutput()).trimmed();
qCInfo(LOG_LIB) << "Error" << qoutput;
QString strValue;
switch (m_redirect) {
case stdout2stderr:
break;
case stderr2stdout:
strValue = QString("%1\n%2").arg(qdebug).arg(qoutput);
break;
case nothing:
default:
strValue = qoutput;
break;
}
// filters
value[tag(QString("custom"))] = applyFilters(strValue);
}
void ExtScript::translate()
{
qCDebug(LOG_LIB);
ui->label_name->setText(i18n("Name"));
ui->label_comment->setText(i18n("Comment"));
ui->label_number->setText(i18n("Tag"));
ui->label_command->setText(i18n("Command"));
ui->label_prefix->setText(i18n("Prefix"));
ui->checkBox_active->setText(i18n("Active"));
ui->checkBox_output->setText(i18n("Has output"));
ui->label_redirect->setText(i18n("Redirect"));
ui->label_interval->setText(i18n("Interval"));
ui->groupBox_filters->setTitle(i18n("Additional filters"));
ui->checkBox_colorFilter->setText(i18n("Wrap colors"));
ui->checkBox_linesFilter->setText(i18n("Wrap new lines"));
ui->checkBox_spaceFilter->setText(i18n("Wrap spaces"));
}

View File

@ -0,0 +1,99 @@
/***************************************************************************
* 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 <QMap>
#include <QProcess>
#include "abstractextitem.h"
namespace Ui {
class ExtScript;
}
class ExtScript : public AbstractExtItem
{
Q_OBJECT
Q_PROPERTY(QString executable READ executable WRITE setExecutable)
Q_PROPERTY(QStringList filters READ filters WRITE setFilters)
Q_PROPERTY(bool output READ hasOutput WRITE setHasOutput)
Q_PROPERTY(QString prefix READ prefix WRITE setPrefix)
Q_PROPERTY(Redirect redirect READ redirect WRITE setRedirect)
public:
enum Redirect {
stdout2stderr = 0,
nothing,
stderr2stdout
};
explicit ExtScript(QWidget *parent = nullptr, const QString scriptName = QString(),
const QStringList directories = QStringList());
virtual ~ExtScript();
ExtScript *copy(const QString _fileName, const int _number);
// get methods
QString executable() const;
QStringList filters() const;
bool hasOutput() const;
QString prefix() const;
Redirect redirect() const;
QString uniq() const;
// derivatives
QString strRedirect() const;
// set methods
void setExecutable(const QString _executable = QString("/usr/bin/true"));
void setFilters(const QStringList _filters = QStringList());
void setHasOutput(const bool _state = true);
void setPrefix(const QString _prefix = QString(""));
void setRedirect(const Redirect _redirect = nothing);
void setStrRedirect(const QString _redirect = QString("nothing"));
// filters
QString applyFilters(QString _value) const;
void updateFilter(const QString _filter, const bool _add = true);
public slots:
void readConfiguration();
void readJsonFilters();
QVariantHash run();
int showConfiguration(const QVariant args = QVariant());
void writeConfiguration() const;
private slots:
void updateValue();
private:
QProcess *process = nullptr;
Ui::ExtScript *ui;
void translate();
// properties
QString m_executable = QString("/usr/bin/true");
QStringList m_filters = QStringList();
bool m_output = true;
QString m_prefix = QString("");
Redirect m_redirect = nothing;
// internal properties
Q_PID childProcess = 0;
QVariantMap jsonFilters = QVariantMap();
int times = 0;
QVariantHash value;
};
#endif /* EXTSCRIPT_H */

View File

@ -0,0 +1,406 @@
<?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>424</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_number">
<item>
<widget class="QLabel" name="label_number">
<property name="text">
<string>Tag</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_numberValue">
<property name="text">
<string/>
</property>
</widget>
</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>
<property name="maximum">
<number>10000</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QGroupBox" name="groupBox_filters">
<property name="title">
<string>Additional filters</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="layout_colorFilter">
<item>
<spacer name="spacer_colorFilter">
<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_colorFilter">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Wrap colors</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_linesFilter">
<item>
<spacer name="spacer_linesFilter">
<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_linesFilter">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Wrap new lines</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_spaceFilter">
<item>
<spacer name="spacer_spaceFilter">
<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_spaceFilter">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Wrap spaces</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</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,262 @@
/***************************************************************************
* 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 <KI18n/KLocalizedString>
#include <QDir>
#include <QRegExp>
#include <QSettings>
#include <QTextCodec>
#include "awdebug.h"
#include "version.h"
ExtUpgrade::ExtUpgrade(QWidget *parent, const QString upgradeName,
const QStringList directories)
: AbstractExtItem(parent, upgradeName, directories),
ui(new Ui::ExtUpgrade)
{
qCDebug(LOG_LIB);
readConfiguration();
ui->setupUi(this);
translate();
value[tag(QString("pkgcount"))] = 0;
process = new QProcess(this);
connect(process, SIGNAL(finished(int)), this, SLOT(updateValue()));
process->waitForFinished(0);
}
ExtUpgrade::~ExtUpgrade()
{
qCDebug(LOG_LIB);
process->kill();
delete process;
delete ui;
}
ExtUpgrade *ExtUpgrade::copy(const QString _fileName, const int _number)
{
qCDebug(LOG_LIB);
qCDebug(LOG_LIB) << "File" << _fileName;
qCDebug(LOG_LIB) << "Number" << _number;
ExtUpgrade *item = new ExtUpgrade(static_cast<QWidget *>(parent()), _fileName, directories());
item->setActive(isActive());
item->setApiVersion(apiVersion());
item->setComment(comment());
item->setExecutable(executable());
item->setFilter(filter());
item->setInterval(interval());
item->setName(name());
item->setNumber(_number);
item->setNull(null());
return item;
}
QString ExtUpgrade::executable() const
{
qCDebug(LOG_LIB);
return m_executable;
}
QString ExtUpgrade::filter() const
{
qCDebug(LOG_LIB);
return m_filter;
}
int ExtUpgrade::null() const
{
qCDebug(LOG_LIB);
return m_null;
}
QString ExtUpgrade::uniq() const
{
qCDebug(LOG_LIB);
return m_executable;
}
void ExtUpgrade::setExecutable(const QString _executable)
{
qCDebug(LOG_LIB);
qCDebug(LOG_LIB) << "Executable" << _executable;
m_executable = _executable;
}
void ExtUpgrade::setFilter(const QString _filter)
{
qCDebug(LOG_LIB);
qCDebug(LOG_LIB) << "Filter" << _filter;
m_filter = _filter;
}
void ExtUpgrade::setNull(const int _null)
{
qCDebug(LOG_LIB);
qCDebug(LOG_LIB) << "Null lines" << _null;
if (_null < 0) return;
m_null = _null;
}
void ExtUpgrade::readConfiguration()
{
qCDebug(LOG_LIB);
AbstractExtItem::readConfiguration();
for (int i=directories().count()-1; i>=0; i--) {
if (!QDir(directories().at(i)).entryList(QDir::Files).contains(fileName())) continue;
QSettings settings(QString("%1/%2").arg(directories().at(i)).arg(fileName()), QSettings::IniFormat);
settings.beginGroup(QString("Desktop Entry"));
setExecutable(settings.value(QString("Exec"), m_executable).toString());
setNull(settings.value(QString("X-AW-Null"), m_null).toInt());
// api == 3
setFilter(settings.value(QString("X-AW-Filter"), m_filter).toString());
settings.endGroup();
}
// update for current API
if ((apiVersion() > 0) && (apiVersion() < AWEUAPI)) {
qCWarning(LOG_LIB) << "Bump API version from" << apiVersion() << "to" << AWEUAPI;
setApiVersion(AWEUAPI);
writeConfiguration();
}
}
QVariantHash ExtUpgrade::run()
{
qCDebug(LOG_LIB);
if (!isActive()) return value;
if ((times == 1) && (process->state() == QProcess::NotRunning)) {
QString cmd = QString("sh -c \"%1\"").arg(m_executable);
qCInfo(LOG_LIB) << "Run cmd" << cmd;
process->start(cmd);
} else if (times >= interval())
times = 0;
times++;
return value;
}
int ExtUpgrade::showConfiguration(const QVariant args)
{
Q_UNUSED(args)
qCDebug(LOG_LIB);
ui->lineEdit_name->setText(name());
ui->lineEdit_comment->setText(comment());
ui->label_numberValue->setText(QString("%1").arg(number()));
ui->lineEdit_command->setText(m_executable);
ui->lineEdit_filter->setText(m_filter);
ui->checkBox_active->setCheckState(isActive() ? Qt::Checked : Qt::Unchecked);
ui->spinBox_null->setValue(m_null);
ui->spinBox_interval->setValue(interval());
int ret = exec();
if (ret != 1) return ret;
setName(ui->lineEdit_name->text());
setComment(ui->lineEdit_comment->text());
setNumber(ui->label_numberValue->text().toInt());
setApiVersion(AWEUAPI);
setExecutable(ui->lineEdit_command->text());
setFilter(ui->lineEdit_filter->text());
setActive(ui->checkBox_active->checkState() == Qt::Checked);
setNull(ui->spinBox_null->value());
setInterval(ui->spinBox_interval->value());
writeConfiguration();
return ret;
}
void ExtUpgrade::writeConfiguration() const
{
qCDebug(LOG_LIB);
AbstractExtItem::writeConfiguration();
QSettings settings(QString("%1/%2").arg(directories().first()).arg(fileName()), QSettings::IniFormat);
qCInfo(LOG_LIB) << "Configuration file" << settings.fileName();
settings.beginGroup(QString("Desktop Entry"));
settings.setValue(QString("Exec"), m_executable);
settings.setValue(QString("X-AW-Filter"), m_filter);
settings.setValue(QString("X-AW-Null"), m_null);
settings.endGroup();
settings.sync();
}
void ExtUpgrade::updateValue()
{
qCDebug(LOG_LIB);
qCInfo(LOG_LIB) << "Cmd returns" << process->exitCode();
qCInfo(LOG_LIB) << "Error" << process->readAllStandardError();
QString qoutput = QTextCodec::codecForMib(106)->toUnicode(process->readAllStandardOutput()).trimmed();
value[tag(QString("pkgcount"))] = [this](QString output) {
return m_filter.isEmpty() ?
output.split(QChar('\n'), QString::SkipEmptyParts).count() - m_null :
output.split(QChar('\n'), QString::SkipEmptyParts).filter(QRegExp(m_filter)).count();
}(qoutput);
}
void ExtUpgrade::translate()
{
qCDebug(LOG_LIB);
ui->label_name->setText(i18n("Name"));
ui->label_comment->setText(i18n("Comment"));
ui->label_number->setText(i18n("Tag"));
ui->label_command->setText(i18n("Command"));
ui->label_filter->setText(i18n("Filter"));
ui->checkBox_active->setText(i18n("Active"));
ui->label_null->setText(i18n("Null"));
ui->label_interval->setText(i18n("Interval"));
}

View File

@ -0,0 +1,75 @@
/***************************************************************************
* 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 <QProcess>
#include "abstractextitem.h"
namespace Ui {
class ExtUpgrade;
}
class ExtUpgrade : public AbstractExtItem
{
Q_OBJECT
Q_PROPERTY(QString executable READ executable WRITE setExecutable)
Q_PROPERTY(QString filter READ filter WRITE setFilter)
Q_PROPERTY(int null READ null WRITE setNull)
public:
explicit ExtUpgrade(QWidget *parent = nullptr, const QString upgradeName = QString(),
const QStringList directories = QStringList());
virtual ~ExtUpgrade();
ExtUpgrade *copy(const QString _fileName, const int _number);
// get methods
QString executable() const;
QString filter() const;
int null() const;
QString uniq() const;
// set methods
void setExecutable(const QString _executable = QString("/usr/bin/true"));
void setFilter(const QString _filter = QString());
void setNull(const int _null = 0);
public slots:
void readConfiguration();
QVariantHash run();
int showConfiguration(const QVariant args = QVariant());
void writeConfiguration() const;
private slots:
void updateValue();
private:
QProcess *process = nullptr;
Ui::ExtUpgrade *ui;
void translate();
// properties
QString m_executable = QString("/usr/bin/true");
QString m_filter = QString("");
int m_null = 0;
// internal properties
int times = 0;
QVariantHash value;
};
#endif /* EXTUPGRADE_H */

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ExtScript</class>
<widget class="QDialog" name="ExtScript">
<class>ExtUpgrade</class>
<widget class="QDialog" name="ExtUpgrade">
<property name="geometry">
<rect>
<x>0</x>
@ -60,6 +60,27 @@
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_number">
<item>
<widget class="QLabel" name="label_number">
<property name="text">
<string>Tag</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_numberValue">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_command">
<item>
@ -84,9 +105,9 @@
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_prefix">
<layout class="QHBoxLayout" name="layout_filter">
<item>
<widget class="QLabel" name="label_prefix">
<widget class="QLabel" name="label_filter">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
@ -94,7 +115,7 @@
</sizepolicy>
</property>
<property name="text">
<string>Prefix</string>
<string>Filter</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
@ -102,7 +123,7 @@
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_prefix"/>
<widget class="QLineEdit" name="lineEdit_filter"/>
</item>
</layout>
</item>
@ -137,41 +158,11 @@
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_output">
<layout class="QHBoxLayout" name="layout_null">
<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>
<widget class="QLabel" name="label_null">
<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>
<string>Null</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
@ -179,22 +170,13 @@
</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 class="QSpinBox" name="spinBox_null">
<property name="minimum">
<number>0</number>
</property>
<property name="value">
<number>0</number>
</property>
</widget>
</item>
</layout>
@ -216,6 +198,15 @@
<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>
@ -250,7 +241,7 @@
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>ExtScript</receiver>
<receiver>ExtUpgrade</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
@ -266,7 +257,7 @@
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>ExtScript</receiver>
<receiver>ExtUpgrade</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">

View File

@ -0,0 +1,395 @@
/***************************************************************************
* 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 "extweather.h"
#include "ui_extweather.h"
#include <KI18n/KLocalizedString>
#include <QDir>
#include <QJsonDocument>
#include <QJsonParseError>
#include <QNetworkAccessManager>
#include <QNetworkRequest>
#include <QSettings>
#include <QStandardPaths>
#include <qreplytimeout/qreplytimeout.h>
#include "awdebug.h"
#include "version.h"
ExtWeather::ExtWeather(QWidget *parent, const QString weatherName,
const QStringList directories)
: AbstractExtItem(parent, weatherName, directories),
ui(new Ui::ExtWeather)
{
qCDebug(LOG_LIB);
readConfiguration();
readJsonMap();
ui->setupUi(this);
translate();
values[tag(QString("weatherId"))] = 0;
values[tag(QString("weather"))] = QString("");
values[tag(QString("humidity"))] = 0;
values[tag(QString("pressure"))] = 0.0;
values[tag(QString("temperature"))] = 0.0;
manager = new QNetworkAccessManager(this);
connect(manager, SIGNAL(finished(QNetworkReply *)),
this, SLOT(weatherReplyReceived(QNetworkReply *)));
}
ExtWeather::~ExtWeather()
{
qCDebug(LOG_LIB);
disconnect(manager, SIGNAL(finished(QNetworkReply *)),
this, SLOT(weatherReplyReceived(QNetworkReply *)));
delete manager;
delete ui;
}
ExtWeather *ExtWeather::copy(const QString _fileName, const int _number)
{
qCDebug(LOG_LIB);
qCDebug(LOG_LIB) << "File" << _fileName;
qCDebug(LOG_LIB) << "Number" << _number;
ExtWeather *item = new ExtWeather(static_cast<QWidget *>(parent()), _fileName, directories());
item->setActive(isActive());
item->setApiVersion(apiVersion());
item->setCity(city());
item->setComment(comment());
item->setCountry(country());
item->setInterval(interval());
item->setImage(image());
item->setName(name());
item->setNumber(_number);
item->setTs(ts());
return item;
}
QString ExtWeather::weatherFromInt(const int _id) const
{
qCDebug(LOG_LIB);
qCDebug(LOG_LIB) << "Weather ID" << _id;
QVariantMap map = jsonMap[m_image ? QString("image") : QString("text")].toMap();
return map.value(QString::number(_id), map[QString("default")]).toString();
}
QString ExtWeather::city() const
{
qCDebug(LOG_LIB);
return m_city;
}
QString ExtWeather::country() const
{
qCDebug(LOG_LIB);
return m_country;
}
bool ExtWeather::image() const
{
qCDebug(LOG_LIB);
return m_image;
}
int ExtWeather::ts() const
{
qCDebug(LOG_LIB);
return m_ts;
}
QString ExtWeather::uniq() const
{
qCDebug(LOG_LIB);
return QString("%1 (%2) at %3").arg(m_city).arg(m_country).arg(m_ts);
}
void ExtWeather::setCity(const QString _city)
{
qCDebug(LOG_LIB);
qCDebug(LOG_LIB) << "City" << _city;
m_city = _city;
}
void ExtWeather::setCountry(const QString _country)
{
qCDebug(LOG_LIB);
qCDebug(LOG_LIB) << "Country" << _country;
m_country = _country;
}
void ExtWeather::setImage(const bool _image)
{
qCDebug(LOG_LIB);
qCDebug(LOG_LIB) << "Use image" << _image;
m_image = _image;
}
void ExtWeather::setTs(const int _ts)
{
qCDebug(LOG_LIB);
qCDebug(LOG_LIB) << "Timestamp" << _ts;
m_ts = _ts;
}
void ExtWeather::readConfiguration()
{
qCDebug(LOG_LIB);
AbstractExtItem::readConfiguration();
for (int i=directories().count()-1; i>=0; i--) {
if (!QDir(directories().at(i)).entryList(QDir::Files).contains(fileName())) continue;
QSettings settings(QString("%1/%2").arg(directories().at(i)).arg(fileName()), QSettings::IniFormat);
settings.beginGroup(QString("Desktop Entry"));
setCity(settings.value(QString("X-AW-City"), m_city).toString());
setCountry(settings.value(QString("X-AW-Country"), m_country).toString());
setTs(settings.value(QString("X-AW-TS"), m_ts).toInt());
// api == 2
setImage(settings.value(QString("X-AW-Image"), QVariant(m_image)).toString() == QString("true"));
settings.endGroup();
}
// update for current API
if ((apiVersion() > 0) && (apiVersion() < AWEWAPI)) {
qCWarning(LOG_LIB) << "Bump API version from" << apiVersion() << "to" << AWEWAPI;
setApiVersion(AWEWAPI);
writeConfiguration();
}
}
void ExtWeather::readJsonMap()
{
qCDebug(LOG_LIB);
QString fileName = QStandardPaths::locate(QStandardPaths::GenericDataLocation,
QString("awesomewidgets/weather/awesomewidgets-extweather-ids.json"));
qCInfo(LOG_LIB) << "Map file" << fileName;
QFile jsonFile(fileName);
if (!jsonFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
qCWarning(LOG_LIB) << "Could not open" << fileName;
return;
}
QString jsonText = jsonFile.readAll();
jsonFile.close();
QJsonParseError error;
QJsonDocument jsonDoc = QJsonDocument::fromJson(jsonText.toUtf8(), &error);
if (error.error != QJsonParseError::NoError) {
qCWarning(LOG_LIB) << "Parse error" << error.errorString();
return;
}
jsonMap = jsonDoc.toVariant().toMap();
qCInfo(LOG_LIB) << "Weather map" << jsonMap;
}
QVariantHash ExtWeather::run()
{
qCDebug(LOG_LIB);
if ((!isActive()) || (isRunning)) return values;
if (times == 1) {
qCInfo(LOG_LIB) << "Send request";
isRunning = true;
QNetworkReply *reply = manager->get(QNetworkRequest(QUrl(url(m_ts != 0))));
new QReplyTimeout(reply, 1000);
}
// update value
if (times >= interval()) times = 0;
times++;
return values;
}
int ExtWeather::showConfiguration(const QVariant args)
{
Q_UNUSED(args)
qCDebug(LOG_LIB);
ui->lineEdit_name->setText(name());
ui->lineEdit_comment->setText(comment());
ui->label_numberValue->setText(QString("%1").arg(number()));
ui->lineEdit_city->setText(m_city);
ui->lineEdit_country->setText(m_country);
ui->spinBox_timestamp->setValue(m_ts);
ui->checkBox_image->setCheckState(m_image ? Qt::Checked : Qt::Unchecked);
ui->checkBox_active->setCheckState(isActive() ? Qt::Checked : Qt::Unchecked);
ui->spinBox_interval->setValue(interval());
int ret = exec();
if (ret != 1) return ret;
setName(ui->lineEdit_name->text());
setComment(ui->lineEdit_comment->text());
setNumber(ui->label_numberValue->text().toInt());
setApiVersion(AWEWAPI);
setCity(ui->lineEdit_city->text());
setCountry(ui->lineEdit_country->text());
setTs(ui->spinBox_timestamp->value());
setImage(ui->checkBox_image->checkState() == Qt::Checked);
setActive(ui->checkBox_active->checkState() == Qt::Checked);
setInterval(ui->spinBox_interval->value());
writeConfiguration();
return ret;
}
void ExtWeather::writeConfiguration() const
{
qCDebug(LOG_LIB);
AbstractExtItem::writeConfiguration();
QSettings settings(QString("%1/%2").arg(directories().first()).arg(fileName()), QSettings::IniFormat);
qCInfo(LOG_LIB) << "Configuration file" << settings.fileName();
settings.beginGroup(QString("Desktop Entry"));
settings.setValue(QString("X-AW-City"), m_city);
settings.setValue(QString("X-AW-Country"), m_country);
settings.setValue(QString("X-AW-Image"), m_image);
settings.setValue(QString("X-AW-TS"), m_ts);
settings.endGroup();
settings.sync();
}
void ExtWeather::weatherReplyReceived(QNetworkReply *reply)
{
qCDebug(LOG_LIB);
qCDebug(LOG_LIB) << "Return code" << reply->error();
qCDebug(LOG_LIB) << "Reply error message" << reply->errorString();
isRunning = false;
QJsonParseError error;
QJsonDocument jsonDoc = QJsonDocument::fromJson(reply->readAll(), &error);
reply->deleteLater();
if ((reply->error() != QNetworkReply::NoError) ||
(error.error != QJsonParseError::NoError)) {
qCWarning(LOG_LIB) << "Parse error" << error.errorString();
return;
}
// convert to map
QVariantMap json = jsonDoc.toVariant().toMap();
if (json[QString("cod")].toInt() != 200) {
qCWarning(LOG_LIB) << "Invalid return code";
return;
}
QVariantHash data;
if (m_ts == 0)
data = parseSingleJson(json);
else {
QVariantList list = json[QString("list")].toList();
data = parseSingleJson(list.count() <= m_ts ? list.at(m_ts-1).toMap() : list.last().toMap());
}
foreach(QString key, data.keys()) values[tag(key)] = data[key];
}
QVariantHash ExtWeather::parseSingleJson(const QVariantMap json) const
{
qCDebug(LOG_LIB);
qCDebug(LOG_LIB) << "Single json data" << json;
QVariantHash output;
// weather status
QVariantList weather = json[QString("weather")].toList();
if (!weather.isEmpty()) {
int _id = weather.first().toMap()[QString("id")].toInt();
output[QString("weatherId")] = _id;
output[QString("weather")] = weatherFromInt(_id);
}
// main data
QVariantMap mainWeather = json[QString("main")].toMap();
if (!weather.isEmpty()) {
output[QString("humidity")] = mainWeather[QString("humidity")].toFloat();
output[QString("pressure")] = mainWeather[QString("pressure")].toFloat();
output[QString("temperature")] = mainWeather[QString("temp")].toFloat();
}
return output;
}
void ExtWeather::translate()
{
qCDebug(LOG_LIB);
ui->label_name->setText(i18n("Name"));
ui->label_comment->setText(i18n("Comment"));
ui->label_number->setText(i18n("Tag"));
ui->label_city->setText(i18n("City"));
ui->label_country->setText(i18n("Country"));
ui->label_timestamp->setText(i18n("Timestamp"));
ui->checkBox_image->setText(i18n("Use images"));
ui->checkBox_active->setText(i18n("Active"));
ui->label_interval->setText(i18n("Interval"));
}
QString ExtWeather::url(const bool isForecast) const
{
qCDebug(LOG_LIB);
qCDebug(LOG_LIB) << "Is forecast" << isForecast;
QString apiUrl = isForecast ? QString(OWM_FORECAST_URL) : QString(OWM_URL);
apiUrl.replace(QString("$CITY"), m_city);
apiUrl.replace(QString("$COUNTRY"), m_country);
qCInfo(LOG_LIB) << "API url" << apiUrl;
return apiUrl;
}

View File

@ -0,0 +1,89 @@
/***************************************************************************
* 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 EXTWEATHER_H
#define EXTWEATHER_H
#include <QMap>
#include <QNetworkReply>
#include "abstractextitem.h"
#define OWM_URL "http://api.openweathermap.org/data/2.5/weather?q=$CITY,$COUNTRY&units=metric"
#define OWM_FORECAST_URL "http://api.openweathermap.org/data/2.5/forecast?q=$CITY,$COUNTRY&units=metric"
namespace Ui {
class ExtWeather;
}
class ExtWeather : public AbstractExtItem
{
Q_OBJECT
Q_PROPERTY(QString city READ city WRITE setCity)
Q_PROPERTY(QString country READ country WRITE setCountry)
Q_PROPERTY(bool image READ image WRITE setImage)
Q_PROPERTY(int ts READ ts WRITE setTs)
public:
explicit ExtWeather(QWidget *parent = nullptr, const QString weatherName = QString(),
const QStringList directories = QStringList());
virtual ~ExtWeather();
ExtWeather *copy(const QString _fileName, const int _number);
QString weatherFromInt(const int _id) const;
// get methods
QString city() const;
QString country() const;
bool image() const;
int ts() const;
QString uniq() const;
// set methods
void setCity(const QString _city = QString("London"));
void setCountry(const QString _country = QString("uk"));
void setImage(const bool _image = false);
void setTs(const int _ts = 0);
public slots:
void readConfiguration();
void readJsonMap();
QVariantHash run();
int showConfiguration(const QVariant args = QVariant());
void writeConfiguration() const;
private slots:
void weatherReplyReceived(QNetworkReply *reply);
private:
QNetworkAccessManager *manager;
bool isRunning = false;
Ui::ExtWeather *ui;
QVariantHash parseSingleJson(const QVariantMap json) const;
void translate();
QString url(const bool isForecast = false) const;
// properties
QString m_city = QString("London");
QString m_country = QString("uk");
bool m_image = false;
int m_ts = 0;
QVariantMap jsonMap = QVariantMap();
// values
int times = 0;
QVariantHash values;
};
#endif /* EXTWEATHER_H */

View File

@ -0,0 +1,301 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ExtWeather</class>
<widget class="QDialog" name="ExtWeather">
<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_number">
<item>
<widget class="QLabel" name="label_number">
<property name="text">
<string>Tag</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_numberValue">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_city">
<item>
<widget class="QLabel" name="label_city">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>City</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_city"/>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_country">
<item>
<widget class="QLabel" name="label_country">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Country</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_country"/>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_timestamp">
<item>
<widget class="QLabel" name="label_timestamp">
<property name="text">
<string>Timestamp</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinBox_timestamp">
<property name="maximum">
<number>40</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_image">
<item>
<spacer name="spacer_image">
<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_image">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Use images</string>
</property>
</widget>
</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_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>10</number>
</property>
<property name="value">
<number>60</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>ExtWeather</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>ExtWeather</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,520 @@
/***************************************************************************
* 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 <KI18n/KLocalizedString>
#include <QBuffer>
#include <QColorDialog>
#include <QDir>
#include <QGraphicsEllipseItem>
#include <QGraphicsScene>
#include <QGraphicsView>
#include <QSettings>
#include "awdebug.h"
#include "version.h"
GraphicalItem::GraphicalItem(QWidget *parent, const QString desktopName,
const QStringList directories)
: AbstractExtItem(parent, desktopName, directories),
ui(new Ui::GraphicalItem)
{
qCDebug(LOG_LIB);
readConfiguration();
ui->setupUi(this);
translate();
connect(ui->pushButton_activeColor, SIGNAL(clicked()), this, SLOT(changeColor()));
connect(ui->pushButton_inactiveColor, SIGNAL(clicked()), this, SLOT(changeColor()));
}
GraphicalItem::~GraphicalItem()
{
qCDebug(LOG_LIB);
delete ui;
}
GraphicalItem *GraphicalItem::copy(const QString _fileName, const int _number)
{
qCDebug(LOG_LIB);
qCDebug(LOG_LIB) << "File" << _fileName;
qCDebug(LOG_LIB) << "Number" << _number;
GraphicalItem *item = new GraphicalItem(static_cast<QWidget *>(parent()), _fileName, directories());
item->setActive(isActive());
item->setActiveColor(activeColor());
item->setApiVersion(apiVersion());
item->setBar(bar());
item->setComment(comment());
item->setDirection(direction());
item->setHeight(height());
item->setInactiveColor(inactiveColor());
item->setInterval(interval());
item->setName(QString("bar%1").arg(_number));
item->setNumber(_number);
item->setType(type());
item->setWidth(width());
return item;
}
QString GraphicalItem::image(const float value) const
{
qCDebug(LOG_LIB);
qCDebug(LOG_LIB) << "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 = view->grab().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::bar() const
{
qCDebug(LOG_LIB);
return m_bar;
}
QString GraphicalItem::activeColor() const
{
qCDebug(LOG_LIB);
return m_activeColor;
}
QString GraphicalItem::inactiveColor() const
{
qCDebug(LOG_LIB);
return m_inactiveColor;
}
QString GraphicalItem::tag() const
{
qCDebug(LOG_LIB);
return name() + m_bar;
}
GraphicalItem::Type GraphicalItem::type() const
{
qCDebug(LOG_LIB);
return m_type;
}
QString GraphicalItem::strType() const
{
qCDebug(LOG_LIB);
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() const
{
qCDebug(LOG_LIB);
return m_direction;
}
QString GraphicalItem::strDirection() const
{
qCDebug(LOG_LIB);
QString value;
switch (m_direction) {
case RightToLeft:
value = QString("RightToLeft");
break;
default:
value = QString("LeftToRight");
break;
}
return value;
}
int GraphicalItem::height() const
{
qCDebug(LOG_LIB);
return m_height;
}
int GraphicalItem::width() const
{
qCDebug(LOG_LIB);
return m_width;
}
QString GraphicalItem::uniq() const
{
qCDebug(LOG_LIB);
return m_bar;
}
void GraphicalItem::setBar(const QString _bar)
{
qCDebug(LOG_LIB);
qCDebug(LOG_LIB) << "Bar" << _bar;
if (!_bar.contains(QRegExp(QString("^(cpu(?!cl).*|gpu$|mem$|swap$|hdd[0-9].*|bat.*)")))) {
qCWarning(LOG_LIB) << "Unsupported bar type" << _bar;
m_bar = QString("none");
} else
m_bar = _bar;
}
void GraphicalItem::setActiveColor(const QString _color)
{
qCDebug(LOG_LIB);
qCDebug(LOG_LIB) << "Color" << _color;
m_activeColor = _color;
}
void GraphicalItem::setInactiveColor(const QString _color)
{
qCDebug(LOG_LIB);
qCDebug(LOG_LIB) << "Color" << _color;
m_inactiveColor = _color;
}
void GraphicalItem::setType(const Type _type)
{
qCDebug(LOG_LIB);
qCDebug(LOG_LIB) << "Type" << _type;
m_type = _type;
}
void GraphicalItem::setStrType(const QString _type)
{
qCDebug(LOG_LIB);
qCDebug(LOG_LIB) << "Type" << _type;
if (_type == QString("Vertical"))
setType(Vertical);
else if (_type == QString("Circle"))
setType(Circle);
else
setType(Horizontal);
}
void GraphicalItem::setDirection(const Direction _direction)
{
qCDebug(LOG_LIB);
qCDebug(LOG_LIB) << "Direction" << _direction;
m_direction = _direction;
}
void GraphicalItem::setStrDirection(const QString _direction)
{
qCDebug(LOG_LIB);
qCDebug(LOG_LIB) << "Direction" << _direction;
if (_direction == QString("RightToLeft"))
setDirection(RightToLeft);
else
setDirection(LeftToRight);
}
void GraphicalItem::setHeight(const int _height)
{
qCDebug(LOG_LIB);
qCDebug(LOG_LIB) << "Height" << _height;
if (_height <= 0) return;
m_height = _height;
}
void GraphicalItem::setWidth(const int _width)
{
qCDebug(LOG_LIB);
qCDebug(LOG_LIB) << "Width" << _width;
if (_width <= 0) return;
m_width = _width;
}
void GraphicalItem::readConfiguration()
{
qCDebug(LOG_LIB);
AbstractExtItem::readConfiguration();
for (int i=directories().count()-1; i>=0; i--) {
if (!QDir(directories().at(i)).entryList(QDir::Files).contains(fileName())) continue;
QSettings settings(QString("%1/%2").arg(directories().at(i)).arg(fileName()), QSettings::IniFormat);
settings.beginGroup(QString("Desktop Entry"));
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());
// api == 2
if (apiVersion() < 2) setNumber(bar().remove(QString("bar")).toInt());
settings.endGroup();
}
// update for current API
if ((apiVersion() > 0) && (apiVersion() < AWGIAPI)) {
qCWarning(LOG_LIB) << "Bump API version from" << apiVersion() << "to" << AWGIAPI;
setApiVersion(AWGIAPI);
writeConfiguration();
}
}
QVariantHash GraphicalItem::run()
{
qCDebug(LOG_LIB);
// required by abstract class
return QVariantHash();
}
int GraphicalItem::showConfiguration(const QVariant args)
{
qCDebug(LOG_LIB);
qCDebug(LOG_LIB) << "Combobox arguments" << args;
QStringList tags = args.toStringList();
ui->label_nameValue->setText(name());
ui->lineEdit_comment->setText(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;
}
void GraphicalItem::writeConfiguration() const
{
qCDebug(LOG_LIB);
AbstractExtItem::writeConfiguration();
QSettings settings(QString("%1/%2").arg(directories().first()).arg(fileName()), QSettings::IniFormat);
qCInfo(LOG_LIB) << "Configuration file" << settings.fileName();
settings.beginGroup(QString("Desktop Entry"));
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()
{
qCDebug(LOG_LIB);
QColor color = stringToColor((static_cast<QPushButton *>(sender()))->text());
QColor newColor = QColorDialog::getColor(color, this, tr("Select color"),
QColorDialog::ShowAlphaChannel);
if (!newColor.isValid()) return;
qCInfo(LOG_LIB) << "Selected color" << newColor;
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()));
return static_cast<QPushButton *>(sender())->setText(colorText.join(QChar(',')));
}
QColor GraphicalItem::stringToColor(const QString _color) const
{
qCDebug(LOG_LIB);
qCDebug(LOG_LIB) << "Color" << _color;
QColor qcolor;
QStringList listColor = _color.split(QChar(','));
while (listColor.count() < 4)
listColor.append(QString("0"));
qcolor.setRed(listColor.at(0).toInt());
qcolor.setGreen(listColor.at(1).toInt());
qcolor.setBlue(listColor.at(2).toInt());
qcolor.setAlpha(listColor.at(3).toInt());
return qcolor;
}
void GraphicalItem::translate()
{
qCDebug(LOG_LIB);
ui->label_name->setText(i18n("Name"));
ui->label_comment->setText(i18n("Comment"));
ui->label_value->setText(i18n("Value"));
ui->label_activeColor->setText(i18n("Active color"));
ui->label_inactiveColor->setText(i18n("Inactive color"));
ui->label_type->setText(i18n("Type"));
ui->label_direction->setText(i18n("Direction"));
ui->label_height->setText(i18n("Height"));
ui->label_width->setText(i18n("Width"));
}

View File

@ -0,0 +1,106 @@
/***************************************************************************
* 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 "abstractextitem.h"
namespace Ui {
class GraphicalItem;
}
class GraphicalItem : public AbstractExtItem
{
Q_OBJECT
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 = nullptr, const QString desktopName = QString(),
const QStringList directories = QStringList());
virtual ~GraphicalItem();
GraphicalItem *copy(const QString _fileName, const int _number);
QString image(const float value) const;
// get methods
QString bar() const;
QString activeColor() const;
QString inactiveColor() const;
QString tag() const;
Type type() const;
QString strType() const;
Direction direction() const;
QString strDirection() const;
int height() const;
int width() const;
QString uniq() const;
// set methods
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();
QVariantHash run();
int showConfiguration(const QVariant args = QVariant());
void writeConfiguration() const;
private slots:
void changeColor();
private:
QString m_fileName;
QStringList m_dirs;
Ui::GraphicalItem *ui;
QColor stringToColor(const QString _color) const;
void translate();
// properties
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 */

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