Compare commits
71 Commits
Author | SHA1 | Date | |
---|---|---|---|
24b143f43a | |||
df473c53b5 | |||
3122c2fa8c | |||
08cb7d9abe | |||
e38863ebc2 | |||
1cddf6f14d | |||
7405b2ba1d | |||
6fbe897b27 | |||
5f7c35a37c | |||
6173b60806 | |||
4c9e39ec9b | |||
429393998c | |||
c9acb0bdcd | |||
16305a91c4 | |||
bbb9aa0747 | |||
983b808247 | |||
c61a5ac092 | |||
3b6df44489 | |||
4742617e3e | |||
880a986782 | |||
b699095f38 | |||
a065e96bc3 | |||
1110929b14 | |||
c7d998eb12 | |||
eb63ef5e96 | |||
327d5a7ff9 | |||
2b9505207c | |||
cd36c4ed68 | |||
903a1a454d | |||
cf5d713d2e | |||
467a3bf508 | |||
4e78e0e1dd | |||
d01fb91e36 | |||
61ed3a444f | |||
494590475a | |||
27ab7d9cd7 | |||
1869a68122 | |||
aa0a4b417d | |||
41deb8ef72 | |||
aa15e13713 | |||
ad63f78929 | |||
224e558a98 | |||
a391df2804 | |||
755d0b39f8 | |||
fcd612880f | |||
5aff2d2e4e | |||
5a52c056a7 | |||
42615a6fdc | |||
b431d2c6cf | |||
f96b3fcb07 | |||
f534a6854a | |||
b51c97abbb | |||
8dc3510a30 | |||
fce098cb5c | |||
5f4bf9ec29 | |||
8c73b2560b | |||
78931b3ae0 | |||
a53c5ec38c | |||
3bac9ac09f | |||
b82d78bcbe | |||
396fa95ec3 | |||
c6cadba4b6 | |||
daa362fc16 | |||
26c51007e0 | |||
7919e6d250 | |||
88c3e780cf | |||
7f4dfe1060 | |||
15d88ee3ba | |||
104bb52557 | |||
9a6b883905 | |||
fd8f2127d9 |
77
CHANGELOG
@ -1,3 +1,70 @@
|
||||
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
|
||||
* 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
|
||||
@ -17,7 +84,7 @@ Ver.2.2.0:
|
||||
* small changes in widget logic
|
||||
* edit window preview painting
|
||||
* KDE4 code upgrade to new ABI
|
||||
* dataengine optimization
|
||||
* DataEngine optimization
|
||||
* PKGCMD was replaced by ExtUpgrade
|
||||
|
||||
Ver.2.1.0:
|
||||
@ -92,7 +159,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:
|
||||
@ -121,7 +188,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
|
||||
|
||||
@ -169,8 +236,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
|
||||
|
||||
|
73
CHANGELOG-RU
@ -1,3 +1,70 @@
|
||||
Вер.2.4.0:
|
||||
+ добавлена поддержка погоды
|
||||
+ добавлена поддержка LA (теги la1, la5, la15)
|
||||
+ добавлена кнопка "Сбросить кеш"
|
||||
+ добавлена поддержка сборки с clang
|
||||
+ добавлен ExtItem агрегатор
|
||||
+ добавлено время в дебаг вывод
|
||||
+ добавлена возможность отключить монитор плеера
|
||||
- исправлен баг с неправильным расчетам скорости сети
|
||||
- исправлен баг с неправильной инициализацией диалога шрифтов
|
||||
* переписаны 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
|
||||
@ -17,7 +84,7 @@
|
||||
* незначительно изменена логика работы виджета
|
||||
* исправлена отрисовка превью окон
|
||||
* обновление кодовой базы KDE4 под новый ABI
|
||||
* оптимизация работы dataengine
|
||||
* оптимизация работы DataEngine
|
||||
* PKGCMD были заменены на ExtUpgrade
|
||||
|
||||
Вер.2.1.0:
|
||||
@ -92,7 +159,7 @@
|
||||
+ добавлено поле текущий рабочий стол (теги $name, $number, $total)
|
||||
+ добавлена возможность взаимодействия с плеерами через mpris
|
||||
* добавлено использование сабмодулей
|
||||
* dataengine переписан с использованием tasks
|
||||
* DataEngine переписан с использованием tasks
|
||||
* фикс чтения температуры nvidia
|
||||
|
||||
Вер.1.10.2:
|
||||
@ -121,7 +188,7 @@
|
||||
- удален util.py
|
||||
- удалены функции createNotifyrc, поскольку они больше не нужны
|
||||
* рефакторинг конфигурационного интерфейса
|
||||
* настройки плеера были перенесены из виджета в dataengine
|
||||
* настройки плеера были перенесены из виджета в DataEngine
|
||||
* исправлен вызов readme под четырехсимвольное обозначение
|
||||
* перенос readme с md на html
|
||||
|
||||
|
12
README.md
@ -27,8 +27,7 @@ Instruction
|
||||
Dependencies
|
||||
------------
|
||||
|
||||
* kdebase-workspace (*if KDE4 is used*) **or** plasma-framework (*if KF5 is used*)
|
||||
* lm_sensors (*for definition temperature device*)
|
||||
* plasma-framework
|
||||
|
||||
Optional dependencies
|
||||
---------------------
|
||||
@ -36,13 +35,13 @@ Optional dependencies
|
||||
* proprietary video driver
|
||||
* hddtemp
|
||||
* smartmontools
|
||||
* music player (mpd or supported MPRIS)
|
||||
* music player (mpd or MPRIS supported)
|
||||
|
||||
Make dependencies
|
||||
-----------------
|
||||
|
||||
* cmake
|
||||
* automoc4 (*if KDE4 is used*) or extra-cmake-modules (*if KF5 is used*)
|
||||
* extra-cmake-modules
|
||||
|
||||
Installation
|
||||
------------
|
||||
@ -54,7 +53,7 @@ Installation
|
||||
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr ../
|
||||
make && sudo make install
|
||||
|
||||
**NOTE** on Plasma 5 it may require `-DKDE_INSTALL_USE_QT_SYS_PATHS=ON` flag
|
||||
**NOTE** on Plasma 5 it very likely requires `-DKDE_INSTALL_USE_QT_SYS_PATHS=ON` flag
|
||||
|
||||
Additional information
|
||||
======================
|
||||
@ -72,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
|
||||
|
@ -2,25 +2,22 @@
|
||||
|
||||
pkgname=plasma5-applet-awesome-widgets
|
||||
_pkgname=awesome-widgets
|
||||
pkgver=2.2.1
|
||||
pkgver=2.4.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=('plasma-framework')
|
||||
optdepends=("amarok: for music player monitor"
|
||||
"clementine: for music player monitor"
|
||||
"catalyst: for GPU monitor"
|
||||
optdepends=("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")
|
||||
"nvidia-utils: for GPU monitor")
|
||||
makedepends=('cmake' 'extra-cmake-modules')
|
||||
source=(https://github.com/arcan1s/awesome-widgets/releases/download/V.${pkgver}/${_pkgname}-${pkgver}-src.tar.xz)
|
||||
install=${pkgname}.install
|
||||
md5sums=('74099a8150aa1992b8a168934878d928')
|
||||
md5sums=('9b870da6ecefef584f11b6ba6bf9a397')
|
||||
backup=('etc/xdg/plasma-dataengine-extsysmon.conf')
|
||||
|
||||
prepare() {
|
54
arch/PKGBUILD-git
Normal file
@ -0,0 +1,54 @@
|
||||
# Maintainer: Evgeniy Alekseev <arcanis at archlinux dot org>
|
||||
|
||||
pkgname=plasma5-applet-awesome-widgets
|
||||
_pkgname=awesome-widgets
|
||||
pkgver=2.2.1.r15.g78931b3
|
||||
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/)
|
||||
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
|
||||
}
|
@ -1,43 +0,0 @@
|
||||
# Maintainer: Evgeniy Alekseev <arcanis at archlinux dot org>
|
||||
|
||||
pkgname=kdeplasma-applets-awesome-widgets
|
||||
_pkgname=awesome-widgets
|
||||
pkgver=2.2.1
|
||||
pkgrel=1
|
||||
pkgdesc="Collection of minimalistic Plasmoids which look like Awesome WM widgets (ex-PyTextMonitor)"
|
||||
arch=('i686' 'x86_64')
|
||||
url="http://arcanis.name/projects/awesome-widgets"
|
||||
license=('GPL3')
|
||||
depends=('kdebase-workspace' 'lm_sensors')
|
||||
optdepends=("amarok: for music player monitor"
|
||||
"clementine: for music player monitor"
|
||||
"catalyst: for GPU monitor"
|
||||
"hddtemp: for HDD temperature monitor"
|
||||
"smartmontools: for HDD temperature monitor"
|
||||
"mpd: for music player monitor"
|
||||
"nvidia-utils: for GPU monitor"
|
||||
"qmmp: for music player monitor")
|
||||
makedepends=('automoc4' 'cmake')
|
||||
source=(https://github.com/arcan1s/awesome-widgets/releases/download/V.${pkgver}/${_pkgname}-${pkgver}-src.tar.xz)
|
||||
install=${pkgname}.install
|
||||
md5sums=('74099a8150aa1992b8a168934878d928')
|
||||
backup=('usr/share/config/plasma-dataengine-extsysmon.conf')
|
||||
|
||||
prepare() {
|
||||
rm -rf "${srcdir}/build"
|
||||
mkdir "${srcdir}/build"
|
||||
}
|
||||
|
||||
build () {
|
||||
cd "${srcdir}/build"
|
||||
cmake -DBUILD_KDE4=ON \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DCMAKE_INSTALL_PREFIX=$(kde4-config --prefix) \
|
||||
"../${_pkgname}"
|
||||
make
|
||||
}
|
||||
|
||||
package() {
|
||||
cd "${srcdir}/build"
|
||||
make DESTDIR="${pkgdir}" install
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
post_install() {
|
||||
kbuildsycoca4 > /dev/null 2>&1
|
||||
}
|
||||
|
||||
post_upgrade() {
|
||||
post_install "$1"
|
||||
}
|
||||
|
||||
post_remove() {
|
||||
post_install "$1"
|
||||
}
|
@ -1,27 +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/.$//g')
|
||||
MINOR=$(grep -m1 PROJECT_VERSION_MINOR sources/CMakeLists.txt | awk '{print $2}' | sed 's/.$//g')
|
||||
PATCH=$(grep -m1 PROJECT_VERSION_PATCH sources/CMakeLists.txt | awk '{print $2}' | sed 's/.$//g')
|
||||
VERSION="${MAJOR}.${MINOR}.${PATCH}"
|
||||
|
||||
# update submodules
|
||||
git submodule update --init --recursive
|
||||
|
||||
# build dataengine
|
||||
ARCHIVE="extsysmon"
|
||||
# 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}"
|
||||
|
||||
# build widget
|
||||
ARCHIVE="awesome-widgets"
|
||||
FILES="AUTHORS CHANGELOG CHANGELOG-RU COPYING"
|
||||
IGNORELIST="build usr .kdev4 sources.kdev4"
|
||||
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}"
|
||||
@ -34,8 +25,8 @@ 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}'/" arch/PKGBUILD{-kf5,-kde4}
|
||||
sed -i "s/pkgver=[0-9.]*/pkgver=${VERSION}/" arch/PKGBUILD{-kf5,-kde4}
|
||||
sed -i "/md5sums=('[0-9A-Fa-f]*/s/[^'][^)]*/md5sums=('${MD5SUMS}'/" arch/PKGBUILD
|
||||
sed -i "s/pkgver=[0-9.]*/pkgver=${VERSION}/" arch/PKGBUILD
|
||||
# clear
|
||||
find . -type f -name '*src.tar.xz' -not -name "*${VERSION}-src.tar.xz" -exec rm -rf {} \;
|
||||
find arch -type l -xtype l -exec rm -rf {} \;
|
||||
|
Before Width: | Height: | Size: 42 KiB After Width: | Height: | Size: 42 KiB |
Before Width: | Height: | Size: 75 KiB After Width: | Height: | Size: 48 KiB |
Before Width: | Height: | Size: 59 KiB After Width: | Height: | Size: 55 KiB |
Before Width: | Height: | Size: 44 KiB After Width: | Height: | Size: 40 KiB |
Before Width: | Height: | Size: 83 KiB After Width: | Height: | Size: 53 KiB |
BIN
screenshots/config_06.png
Normal file
After Width: | Height: | Size: 49 KiB |
BIN
screenshots/dp_config_01.png
Normal file
After Width: | Height: | Size: 39 KiB |
BIN
screenshots/dp_config_02.png
Normal file
After Width: | Height: | Size: 42 KiB |
BIN
screenshots/dp_config_03.png
Normal file
After Width: | Height: | Size: 38 KiB |
BIN
screenshots/dp_config_04.png
Normal file
After Width: | Height: | Size: 38 KiB |
23
sources/.kdev4/awesomewidgets.kdev4
Normal file
@ -0,0 +1,23 @@
|
||||
[Buildset]
|
||||
BuildItems=@Variant(\x00\x00\x00\t\x00\x00\x00\x00\x01\x00\x00\x00\x0b\x00\x00\x00\x00\x01\x00\x00\x00\x1e\x00a\x00w\x00e\x00s\x00o\x00m\x00e\x00-\x00w\x00i\x00d\x00g\x00e\x00t\x00s)
|
||||
|
||||
[CMake]
|
||||
Build Directory Count=1
|
||||
Current Build Directory Index=0
|
||||
ProjectRootRelative=./
|
||||
|
||||
[CMake][CMake Build Directory 0]
|
||||
Build Directory Path=file:///home/arcanis/Documents/github/awesome-widgets/build
|
||||
Build Type=Debug
|
||||
CMake Binary=file:///usr/bin/cmake
|
||||
Environment Profile=
|
||||
Extra Arguments=
|
||||
Install Directory=file:///usr
|
||||
|
||||
[Defines And Includes][Compiler]
|
||||
Name=GCC
|
||||
Path=gcc
|
||||
Type=GCC
|
||||
|
||||
[Project]
|
||||
VersionControlSupport=kdevgit
|
@ -8,7 +8,7 @@ ProjectRootRelative=./
|
||||
|
||||
[CMake][CMake Build Directory 0]
|
||||
Build Directory Path=file:///home/arcanis/Documents/github/awesome-widgets/build
|
||||
Build Type=Debug
|
||||
Build Type=Release
|
||||
CMake Binary=file:///usr/bin/cmake
|
||||
Environment Profile=
|
||||
Extra Arguments=
|
||||
|
2
sources/3rdparty/pdebug
vendored
18
sources/3rdparty/qreplytimeout/qreplytimeout.cpp
vendored
Normal 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();
|
||||
}
|
17
sources/3rdparty/qreplytimeout/qreplytimeout.h
vendored
Normal 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();
|
||||
};
|
@ -1,54 +1,63 @@
|
||||
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 (awesomewidgets)
|
||||
set (PROJECT_AUTHOR "Evgeniy Alekseev")
|
||||
set (PROJECT_CONTACT "esalexeev@gmail.com")
|
||||
set (PROJECT_LICENSE "GPLv3")
|
||||
set (PROJECT_VERSION_MAJOR 2)
|
||||
set (PROJECT_VERSION_MINOR 2)
|
||||
set (PROJECT_VERSION_PATCH 1)
|
||||
set (PROJECT_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH})
|
||||
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_KDE4 "Build on KDE4" OFF)
|
||||
# update minimum cmake version
|
||||
if (NOT BUILD_KDE4)
|
||||
cmake_minimum_required (VERSION 2.8.12)
|
||||
endif ()
|
||||
option(BUILD_PLASMOIDS "Build plasmoids" ON)
|
||||
|
||||
# flags
|
||||
if (CMAKE_COMPILER_IS_GNUCXX)
|
||||
set (CMAKE_CXX_FLAGS "-Wall -Wno-cpp -std=c++11")
|
||||
set (CMAKE_CXX_FLAGS_DEBUG "-g -O0")
|
||||
set (CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG")
|
||||
# avoid newer gcc warnings
|
||||
add_definitions (-D_DEFAULT_SOURCE)
|
||||
else ()
|
||||
message (STATUS "Unknown compiler")
|
||||
endif ()
|
||||
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 (extsysmon)
|
||||
if (BUILD_KDE4)
|
||||
add_subdirectory (awesome-widget-kde4)
|
||||
add_subdirectory (desktop-panel-kde4)
|
||||
else ()
|
||||
add_subdirectory (awesome-widget-kf5)
|
||||
add_subdirectory (desktop-panel-kf5)
|
||||
endif ()
|
||||
|
||||
# translations
|
||||
add_subdirectory (translations)
|
||||
add_subdirectory(awesomewidgets)
|
||||
add_subdirectory(extsysmon)
|
||||
if(BUILD_PLASMOIDS)
|
||||
add_subdirectory(awesome-widget)
|
||||
add_subdirectory(desktop-panel)
|
||||
add_subdirectory(translations)
|
||||
endif()
|
||||
|
@ -1,45 +0,0 @@
|
||||
# set project name
|
||||
set (SUBPROJECT plasma_applet_awesome-widget)
|
||||
set (PLUGIN_NAME ${SUBPROJECT})
|
||||
message (STATUS "Subproject ${SUBPROJECT}")
|
||||
|
||||
# find required libaries
|
||||
find_package (KDE4 REQUIRED)
|
||||
add_definitions (${QT_DEFINITIONS} ${KDE4_DEFINITIONS})
|
||||
|
||||
include (KDE4Defaults)
|
||||
include_directories (${CMAKE_SOURCE_DIR}
|
||||
${CMAKE_BINARY_DIR}
|
||||
${KDE4_INCLUDES}
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
${CMAKE_CURRENT_BINARY_DIR}/../
|
||||
${PROJECT_TRDPARTY_DIR}
|
||||
../extsysmon
|
||||
${CMAKE_CURRENT_BINARY_DIR}/../extsysmon)
|
||||
|
||||
# set sources
|
||||
file (GLOB SUBPROJECT_DESKTOP_IN *.desktop)
|
||||
file (RELATIVE_PATH SUBPROJECT_DESKTOP ${CMAKE_SOURCE_DIR} ${SUBPROJECT_DESKTOP_IN})
|
||||
file (GLOB_RECURSE SUBPROJECT_SOURCE *.cpp ${PROJECT_TRDPARTY_DIR}/task/*.cpp
|
||||
${PROJECT_TRDPARTY_DIR}/fontdialog/*.cpp
|
||||
../extsysmon/extscript.cpp
|
||||
../extsysmon/extupgrade.cpp)
|
||||
set (TASK_HEADER ${PROJECT_TRDPARTY_DIR}/task/task.h)
|
||||
file (GLOB SUBPROJECT_UI *.ui ${PROJECT_TRDPARTY_DIR}/about/*.ui)
|
||||
file (GLOB SUBPROJECT_NOTIFY *.notifyrc)
|
||||
set (SUBPROJECT_DESKTOPS ${CMAKE_CURRENT_SOURCE_DIR}/desktops)
|
||||
|
||||
# prepare
|
||||
configure_file (${SUBPROJECT_DESKTOP_IN} ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT_DESKTOP})
|
||||
|
||||
# make
|
||||
qt4_wrap_cpp (TASK_MOC_SOURCE ${TASK_HEADER})
|
||||
kde4_add_ui_files (SUBPROJECT_SOURCE ${SUBPROJECT_UI})
|
||||
kde4_add_plugin (${PLUGIN_NAME} ${SUBPROJECT_SOURCE} ${TASK_MOC_SOURCE})
|
||||
target_link_libraries (${PLUGIN_NAME} ${KDE4_PLASMA_LIBS} ${KDE4_KDEUI_LIBS} ${KDE4_KIO_LIBS})
|
||||
|
||||
# install
|
||||
install (TARGETS ${PLUGIN_NAME} DESTINATION ${PLUGIN_INSTALL_DIR})
|
||||
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT_DESKTOP} DESTINATION ${SERVICES_INSTALL_DIR})
|
||||
install (FILES ${SUBPROJECT_NOTIFY} DESTINATION ${DATA_INSTALL_DIR}/${PLUGIN_NAME})
|
||||
install (DIRECTORY ${SUBPROJECT_DESKTOPS} DESTINATION ${DATA_INSTALL_DIR}/${PLUGIN_NAME})
|
@ -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>
|
@ -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>
|
@ -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("extsysmon"));
|
||||
sysmonEngine = dataEngine(QString("systemmonitor"));
|
||||
connect(sysmonEngine, SIGNAL(sourceAdded(QString)), this, SLOT(addDiskDevice(QString)));
|
||||
timeEngine = dataEngine(QString("time"));
|
||||
|
||||
// tooltip
|
||||
toolTip = Plasma::ToolTipContent();
|
||||
toolTip.setMainText(QString("Awesome Widget"));
|
||||
toolTip.setSubText(QString(""));
|
||||
toolTipScene = new QGraphicsScene();
|
||||
toolTipView = new QGraphicsView(toolTipScene);
|
||||
toolTipView->setStyleSheet(QString("background: transparent"));
|
||||
toolTipView->setContentsMargins(0, 0, 0, 0);
|
||||
toolTipView->setFrameShape(QFrame::NoFrame);
|
||||
toolTipView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
toolTipView->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
Plasma::ToolTipManager::self()->setContent(this, toolTip);
|
||||
|
||||
// body
|
||||
createActions();
|
||||
mainLayout = new QGraphicsGridLayout();
|
||||
mainLayout->setContentsMargins(1, 1, 1, 1);
|
||||
setLayout(mainLayout);
|
||||
textLabel = new CustomLabel(this, debug);
|
||||
textLabel->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
|
||||
QGraphicsProxyWidget *pw = new QGraphicsProxyWidget(this);
|
||||
pw->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
|
||||
textLabel->setAttribute(Qt::WA_TranslucentBackground, true);
|
||||
pw->setWidget(textLabel);
|
||||
mainLayout->addItem(pw, 0, 0);
|
||||
|
||||
// read variables
|
||||
configChanged();
|
||||
timer = new QTimer(this);
|
||||
timer->setSingleShot(false);
|
||||
timer->setInterval(configuration[QString("interval")].toInt());
|
||||
connect(timer, SIGNAL(timeout()), this, SLOT(updateText()));
|
||||
connect(timer, SIGNAL(timeout()), this, SLOT(updateTooltip()));
|
||||
timer->start();
|
||||
// check for updates
|
||||
connect(this, SIGNAL(thereIsUpdates(QString)), this, SLOT(showUpdates(QString)));
|
||||
if (configuration[QString("checkUpdates")].toInt() == 2)
|
||||
checkUpdates();
|
||||
}
|
||||
|
||||
|
||||
void AwesomeWidget::replyRecieved(QNetworkReply *reply)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QString answer = reply->readAll();
|
||||
if (!answer.contains(QString("tag_name"))) return;
|
||||
QString version = QString(VERSION);
|
||||
if (debug) qDebug() << PDEBUG << answer;
|
||||
for (int i=0; i<answer.split(QString("tag_name")).count(); i++) {
|
||||
version = answer.split(QString("tag_name"))[1].split(QChar(','))[0];
|
||||
version.remove(QChar('"'));
|
||||
version.remove(QChar(':'));
|
||||
version.remove(QString("V."));
|
||||
break;
|
||||
}
|
||||
|
||||
int old_major = QString(VERSION).split(QChar('.'))[0].toInt();
|
||||
int old_minor = QString(VERSION).split(QChar('.'))[1].toInt();
|
||||
int old_patch = QString(VERSION).split(QChar('.'))[2].toInt();
|
||||
int new_major = QString(version).split(QChar('.'))[0].toInt();
|
||||
int new_minor = QString(version).split(QChar('.'))[1].toInt();
|
||||
int new_patch = QString(version).split(QChar('.'))[2].toInt();
|
||||
if ((old_major < new_major) ||
|
||||
((old_major == new_major) && (old_minor < new_minor)) ||
|
||||
((old_major == new_major) && (old_minor == new_minor) && (old_patch < new_patch)))
|
||||
emit(thereIsUpdates(version));
|
||||
}
|
||||
|
||||
|
||||
void AwesomeWidget::addDiskDevice(const QString source)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QRegExp diskRegexp = QRegExp(QString("disk/(?:md|sd|hd)[a-z|0-9]_.*/Rate/(?:rblk)"));
|
||||
if (diskRegexp.indexIn(source) > -1) {
|
||||
QStringList splitSource = source.split(QChar('/'));
|
||||
QString device = splitSource[0] + QString("/") + splitSource[1];
|
||||
diskDevices.append(device);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QStringList AwesomeWidget::findKeys()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QStringList selectedKeys;
|
||||
for (int i=0; i<keys.count(); i++)
|
||||
if (configuration[QString("text")].contains(QString("$") + keys[i])) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Found key" << keys[i];
|
||||
selectedKeys.append(keys[i]);
|
||||
}
|
||||
|
||||
return selectedKeys;
|
||||
}
|
||||
|
||||
|
||||
QStringList AwesomeWidget::getKeys()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QStringList allKeys;
|
||||
// time
|
||||
allKeys.append(QString("time"));
|
||||
allKeys.append(QString("isotime"));
|
||||
allKeys.append(QString("shorttime"));
|
||||
allKeys.append(QString("longtime"));
|
||||
allKeys.append(QString("ctime"));
|
||||
// uptime
|
||||
allKeys.append(QString("uptime"));
|
||||
allKeys.append(QString("cuptime"));
|
||||
// cpuclock
|
||||
for (int i=counts[QString("cpu")]-1; i>=0; i--)
|
||||
allKeys.append(QString("cpucl") + QString::number(i));
|
||||
allKeys.append(QString("cpucl"));
|
||||
// cpu
|
||||
for (int i=counts[QString("cpu")]-1; i>=0; i--)
|
||||
allKeys.append(QString("cpu") + QString::number(i));
|
||||
allKeys.append(QString("cpu"));
|
||||
// temperature
|
||||
for (int i=counts[QString("temp")]-1; i>=0; i--)
|
||||
allKeys.append(QString("temp") + QString::number(i));
|
||||
for (int i=counts[QString("fan")]-1; i>=0; i--)
|
||||
allKeys.append(QString("fan") + QString::number(i));
|
||||
// gputemp
|
||||
allKeys.append(QString("gputemp"));
|
||||
// gpu
|
||||
allKeys.append(QString("gpu"));
|
||||
// memory
|
||||
allKeys.append(QString("memmb"));
|
||||
allKeys.append(QString("memgb"));
|
||||
allKeys.append(QString("memfreemb"));
|
||||
allKeys.append(QString("memfreegb"));
|
||||
allKeys.append(QString("memtotmb"));
|
||||
allKeys.append(QString("memtotgb"));
|
||||
allKeys.append(QString("memusedmb"));
|
||||
allKeys.append(QString("memusedgb"));
|
||||
allKeys.append(QString("mem"));
|
||||
// swap
|
||||
allKeys.append(QString("swapmb"));
|
||||
allKeys.append(QString("swapgb"));
|
||||
allKeys.append(QString("swapfreemb"));
|
||||
allKeys.append(QString("swapfreegb"));
|
||||
allKeys.append(QString("swaptotmb"));
|
||||
allKeys.append(QString("swaptotgb"));
|
||||
allKeys.append(QString("swap"));
|
||||
// hdd
|
||||
for (int i=counts[QString("mount")]-1; i>=0; i--) {
|
||||
allKeys.append(QString("hddmb") + QString::number(i));
|
||||
allKeys.append(QString("hddgb") + QString::number(i));
|
||||
allKeys.append(QString("hddfreemb") + QString::number(i));
|
||||
allKeys.append(QString("hddfreegb") + QString::number(i));
|
||||
allKeys.append(QString("hddtotmb") + QString::number(i));
|
||||
allKeys.append(QString("hddtotgb") + QString::number(i));
|
||||
allKeys.append(QString("hdd") + QString::number(i));
|
||||
}
|
||||
// hdd speed
|
||||
for (int i=counts[QString("disk")]-1; i>=0; i--) {
|
||||
allKeys.append(QString("hddr") + QString::number(i));
|
||||
allKeys.append(QString("hddw") + QString::number(i));
|
||||
}
|
||||
// hdd temp
|
||||
for (int i=counts[QString("hddtemp")]-1; i>=0; i--) {
|
||||
allKeys.append(QString("hddtemp") + QString::number(i));
|
||||
allKeys.append(QString("hddtemp") + QString::number(i));
|
||||
}
|
||||
// network
|
||||
allKeys.append(QString("down"));
|
||||
allKeys.append(QString("up"));
|
||||
allKeys.append(QString("netdev"));
|
||||
// battery
|
||||
allKeys.append(QString("ac"));
|
||||
for (int i=counts[QString("bat")]-1; i>=0; i--)
|
||||
allKeys.append(QString("bat") + QString::number(i));
|
||||
allKeys.append(QString("bat"));
|
||||
// player
|
||||
allKeys.append(QString("album"));
|
||||
allKeys.append(QString("artist"));
|
||||
allKeys.append(QString("duration"));
|
||||
allKeys.append(QString("progress"));
|
||||
allKeys.append(QString("title"));
|
||||
// ps
|
||||
allKeys.append(QString("pscount"));
|
||||
allKeys.append(QString("pstotal"));
|
||||
allKeys.append(QString("ps"));
|
||||
// package manager
|
||||
for (int i=counts[QString("pkg")]-1; i>=0; i--)
|
||||
allKeys.append(QString("pkgcount") + QString::number(i));
|
||||
// custom
|
||||
for (int i=counts[QString("custom")]-1; i>=0; i--)
|
||||
allKeys.append(QString("custom") + QString::number(i));
|
||||
// desktop
|
||||
allKeys.append(QString("desktop"));
|
||||
allKeys.append(QString("ndesktop"));
|
||||
allKeys.append(QString("tdesktops"));
|
||||
|
||||
return allKeys;
|
||||
}
|
||||
|
||||
|
||||
QStringList AwesomeWidget::findGraphicalItems()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QStringList orderedKeys;
|
||||
for (int i=0; i<graphicalItems.count(); i++)
|
||||
orderedKeys.append(graphicalItems[i]->name() + graphicalItems[i]->bar());
|
||||
orderedKeys.sort();
|
||||
QStringList selectedKeys;
|
||||
for (int i=orderedKeys.count()-1; i>=0; i--)
|
||||
if (configuration[QString("text")].contains(QString("$") + orderedKeys[i])) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Found key" << orderedKeys[i];
|
||||
selectedKeys.append(orderedKeys[i]);
|
||||
}
|
||||
|
||||
return selectedKeys;
|
||||
}
|
||||
|
||||
|
||||
void AwesomeWidget::getGraphicalItems()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
graphicalItems.clear();
|
||||
// create directory at $HOME
|
||||
QString localDir = KStandardDirs::locateLocal("data", "plasma_applet_awesome-widget/desktops");
|
||||
if (KStandardDirs::makeDir(localDir))
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Created directory" << localDir;
|
||||
|
||||
QStringList dirs = KGlobal::dirs()->findDirs("data", "plasma_applet_awesome-widget/desktops");
|
||||
QStringList names;
|
||||
for (int i=0; i<dirs.count(); i++) {
|
||||
QStringList files = QDir(dirs[i]).entryList(QDir::Files, QDir::Name);
|
||||
for (int j=0; j<files.count(); j++) {
|
||||
if (!files[j].endsWith(QString(".desktop"))) continue;
|
||||
if (names.contains(files[j])) continue;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Found file" << files[j] << "in" << dirs[i];
|
||||
names.append(files[j]);
|
||||
graphicalItems.append(new GraphicalItem(0, files[j], dirs, debug));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
GraphicalItem *AwesomeWidget::getItemByTag(const QString tag)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
GraphicalItem *item = nullptr;
|
||||
for (int i=0; i< graphicalItems.count(); i++) {
|
||||
if ((graphicalItems[i]->name() + graphicalItems[i]->bar()) != tag) continue;
|
||||
item = graphicalItems[i];
|
||||
break;
|
||||
}
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
|
||||
void AwesomeWidget::showKsysguard()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QString cmd = QString("ksysguard");
|
||||
if (debug) qDebug() << PDEBUG << ":" << "cmd" << cmd;
|
||||
TaskResult process = runTask(cmd);
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
||||
if (process.exitCode != 0)
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
||||
}
|
||||
|
||||
|
||||
void AwesomeWidget::showReadme()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QDesktopServices::openUrl(QString("http://arcanis.name/projects/awesome-widgets/"));
|
||||
}
|
||||
|
||||
|
||||
void AwesomeWidget::showUpdates(QString version)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QString text;
|
||||
text += i18n("Current version : %1", QString(VERSION)) + QString("\n");
|
||||
text += i18n("New version : %1", version) + QString("\n\n");
|
||||
text += i18n("Click \"Ok\" to download");
|
||||
int select = QMessageBox::information(0, i18n("There are updates"), text, QMessageBox::Ok | QMessageBox::Cancel);
|
||||
switch (select) {
|
||||
case QMessageBox::Ok:
|
||||
QDesktopServices::openUrl(QString(RELEASES) + version);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
K_EXPORT_PLASMA_APPLET(awesome-widget, AwesomeWidget)
|
@ -1,154 +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 ExtUpgrade;
|
||||
class GraphicalItem;
|
||||
class QGraphicsGridLayout;
|
||||
class QGraphicsScene;
|
||||
class QNetworkReply;
|
||||
|
||||
class AwesomeWidget : public Plasma::Applet
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
AwesomeWidget(QObject *parent, const QVariantList &args);
|
||||
~AwesomeWidget();
|
||||
QString getNetworkDevice();
|
||||
int getNumberCpus();
|
||||
float getTemp(const float temp);
|
||||
QStringList getTimeKeys();
|
||||
void init();
|
||||
// de configuration
|
||||
QMap<QString, QString> readDataEngineConfiguration();
|
||||
void writeDataEngineConfiguration(const QMap<QString, QString> settings);
|
||||
|
||||
public slots:
|
||||
// contextual actions
|
||||
void showKsysguard();
|
||||
void showReadme();
|
||||
void showUpdates(QString version);
|
||||
// dataengine
|
||||
void addDiskDevice(const QString source);
|
||||
void connectToEngine();
|
||||
void dataUpdated(const QString &sourceName, const Plasma::DataEngine::Data &data);
|
||||
void disconnectFromEngine();
|
||||
// configuration interface
|
||||
void configAccepted();
|
||||
void configChanged();
|
||||
// update events
|
||||
void sendNotification(const QString eventId, const QString message);
|
||||
void updateNetworkDevice(const bool delay = true);
|
||||
void updateText(const bool clear = false);
|
||||
void updateTooltip();
|
||||
|
||||
private slots:
|
||||
void checkUpdates();
|
||||
void reinit();
|
||||
void replyRecieved(QNetworkReply *reply);
|
||||
// configuration interface
|
||||
void addBar();
|
||||
void addCustomScript();
|
||||
void addPkgCommand();
|
||||
void contextMenuBars(const QPoint pos);
|
||||
void contextMenuCustomCommand(const QPoint pos);
|
||||
void contextMenuPkgCommand(const QPoint pos);
|
||||
void copyBar(const QString original);
|
||||
void copyCustomCommand(const QString original);
|
||||
void copyPkgCommand(const QString original);
|
||||
void editBar(QListWidgetItem *item);
|
||||
void editCustomCommand(QListWidgetItem *item);
|
||||
void editPkgCommand(QListWidgetItem *item);
|
||||
void editFanItem(QListWidgetItem *item);
|
||||
void editHddItem(QListWidgetItem *item);
|
||||
void editHddSpeedItem(QListWidgetItem *item);
|
||||
void editMountItem(QListWidgetItem *item);
|
||||
void editTempItem(QListWidgetItem *item);
|
||||
void setFontFormating();
|
||||
void setFormating();
|
||||
|
||||
signals:
|
||||
void thereIsUpdates(QString version);
|
||||
|
||||
protected:
|
||||
QList<QAction *> contextualActions();
|
||||
void createConfigurationInterface(KConfigDialog *parent);
|
||||
|
||||
private:
|
||||
// functions
|
||||
void createActions();
|
||||
QStringList findKeys();
|
||||
QStringList getKeys();
|
||||
QStringList findGraphicalItems();
|
||||
void getGraphicalItems();
|
||||
GraphicalItem *getItemByTag(const QString tag);
|
||||
QList<ExtScript *> initScripts();
|
||||
QList<ExtUpgrade *> initUpgrades();
|
||||
// ui
|
||||
QGraphicsGridLayout *mainLayout = nullptr;
|
||||
CustomLabel *textLabel = nullptr;
|
||||
QTimer *timer = nullptr;
|
||||
QList<QAction *> contextMenu;
|
||||
// tooltip
|
||||
Plasma::ToolTipContent toolTip;
|
||||
QGraphicsScene *toolTipScene = nullptr;
|
||||
QGraphicsView *toolTipView = nullptr;
|
||||
// values
|
||||
int networkDeviceUpdate = 0;
|
||||
QMap<QString, int> counts;
|
||||
QMap<QString, QList<float>> tooltipValues;
|
||||
QMap<QString, QString> values;
|
||||
// debug
|
||||
bool debug;
|
||||
// data engine
|
||||
Plasma::DataEngine *extsysmonEngine = nullptr;
|
||||
Plasma::DataEngine *sysmonEngine = nullptr;
|
||||
Plasma::DataEngine *timeEngine = nullptr;
|
||||
// configuration interface
|
||||
Ui::About uiAboutConfig;
|
||||
Ui::AdvancedWindow uiAdvancedConfig;
|
||||
Ui::AppearanceWindow uiAppConfig;
|
||||
Ui::ConfigWindow uiWidConfig;
|
||||
Ui::DEWindow uiDEConfig;
|
||||
Ui::TooltipWindow uiTooltipConfig;
|
||||
// configuration
|
||||
QMap<QString, QString> configuration;
|
||||
QStringList diskDevices, keys, formatLine, foundKeys;
|
||||
QList<GraphicalItem *> graphicalItems;
|
||||
QStringList foundBars;
|
||||
};
|
||||
|
||||
|
||||
#endif /* AWESOME_WIDGET_H */
|
@ -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));
|
||||
}
|
@ -1,440 +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>"/sys/class/power_supply/" 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><b>NOTE:</b> Player DBus interface should be an active</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_mprisSelect">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_mpris">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>MPRIS player name</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox_mpris">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="editable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">auto</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">amarok</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">audacious</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">clementine</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">deadbeef</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">vlc</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">qmmp</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">xmms2</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<layout class="QVBoxLayout" name="layout_custom">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_customAdd">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_custom">
|
||||
<property name="text">
|
||||
<string>Custom scripts</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="spacer_custom">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_custom">
|
||||
<property name="text">
|
||||
<string>Add</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QListWidget" name="listWidget_custom">
|
||||
<property name="contextMenuPolicy">
|
||||
<enum>Qt::CustomContextMenu</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="9" column="0">
|
||||
<layout class="QVBoxLayout" name="layout_pkgCommand">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_pkgCommandAdd">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_pkgCommand">
|
||||
<property name="text">
|
||||
<string>Package manager</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="spacer_pkgCommand">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_pkgCommand">
|
||||
<property name="text">
|
||||
<string>Add</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QListWidget" name="listWidget_pkgCommand">
|
||||
<property name="contextMenuPolicy">
|
||||
<enum>Qt::CustomContextMenu</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
@ -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, configuration[QString("interval")].toInt());
|
||||
// player
|
||||
regExp = QRegExp(QString("(album|artist|duration|progress|title)"));
|
||||
if (foundKeys.indexOf(regExp) > -1)
|
||||
extsysmonEngine->connectSource(QString("player"),
|
||||
this, configuration[QString("interval")].toInt());
|
||||
// ps
|
||||
regExp = QRegExp(QString("ps.*"));
|
||||
if (foundKeys.indexOf(regExp) > -1)
|
||||
extsysmonEngine->connectSource(QString("ps"),
|
||||
this, configuration[QString("interval")].toInt());
|
||||
// swap
|
||||
regExp = QRegExp(QString("(^|bar[0-9].*)swap.*"));
|
||||
if ((foundKeys.indexOf(regExp) > -1) ||
|
||||
(configuration[QString("swapTooltip")].toInt() == 2) ||
|
||||
(foundBars.indexOf(regExp) > -1)) {
|
||||
sysmonEngine->connectSource(QString("mem/swap/free"),
|
||||
this, configuration[QString("interval")].toInt());
|
||||
sysmonEngine->connectSource(QString("mem/swap/used"),
|
||||
this, configuration[QString("interval")].toInt());
|
||||
}
|
||||
// temp
|
||||
regExp = QRegExp(QString("temp.*"));
|
||||
if (foundKeys.indexOf(regExp) > -1)
|
||||
for (int i=0; i<configuration[QString("tempDevice")].split(QString("@@")).count(); i++)
|
||||
sysmonEngine->connectSource(configuration[QString("tempDevice")].split(QString("@@"))[i],
|
||||
this, configuration[QString("interval")].toInt());
|
||||
// time
|
||||
regExp = QRegExp(QString("(^|iso|short|long|c)time"));
|
||||
if (foundKeys.indexOf(regExp) > -1)
|
||||
timeEngine->connectSource(QString("Local"),
|
||||
this, 1000);
|
||||
// uptime
|
||||
regExp = QRegExp(QString("(^|c)uptime"));
|
||||
if (foundKeys.indexOf(regExp) > -1)
|
||||
sysmonEngine->connectSource(QString("system/uptime"),
|
||||
this, configuration[QString("interval")].toInt());
|
||||
}
|
||||
|
||||
|
||||
void AwesomeWidget::dataUpdated(const QString &sourceName, const Plasma::DataEngine::Data &data)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Source" << sourceName;
|
||||
|
||||
// regular expressions
|
||||
QRegExp cpuRegExp = QRegExp(QString("cpu/cpu.*/TotalLoad"));
|
||||
QRegExp cpuclRegExp = QRegExp(QString("cpu/cpu.*/clock"));
|
||||
QRegExp hddrRegExp = QRegExp(QString("disk/.*/Rate/rblk"));
|
||||
QRegExp hddwRegExp = QRegExp(QString("disk/.*/Rate/wblk"));
|
||||
QRegExp mountFillRegExp = QRegExp(QString("partitions/.*/filllevel"));
|
||||
QRegExp mountFreeRegExp = QRegExp(QString("partitions/.*/freespace"));
|
||||
QRegExp mountUsedRegExp = QRegExp(QString("partitions/.*/usedspace"));
|
||||
QRegExp netRecRegExp = QRegExp(QString("network/interfaces/.*/receiver/data"));
|
||||
QRegExp netTransRegExp = QRegExp(QString("network/interfaces/.*/transmitter/data"));
|
||||
QRegExp tempRegExp = QRegExp(QString("lmsensors/.*"));
|
||||
|
||||
if (data.keys().isEmpty()) return;
|
||||
if (sourceName == QString("battery")) {
|
||||
for (int i=0; i<data.keys().count(); i++) {
|
||||
if (data.keys()[i] == QString("ac")) {
|
||||
if (data[QString("ac")].toBool())
|
||||
values[QString("ac")] = configuration[QString("acOnline")];
|
||||
else
|
||||
values[QString("ac")] = configuration[QString("acOffline")];
|
||||
} else {
|
||||
values[data.keys()[i]] = QString("%1").arg(data[data.keys()[i]].toFloat(), 3, 'f', 0);
|
||||
if (foundBars.indexOf(QRegExp(QString("bar[0-9].*bat"))) > -1) {
|
||||
for (int j=0; j<foundBars.count(); j++) {
|
||||
if (getItemByTag(foundBars[j])->bar() != data.keys()[i]) continue;
|
||||
values[foundBars[j]] = values[data.keys()[i]];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((configuration[QString("batteryTooltip")].toInt() == 2) &&
|
||||
(!isnan(data[QString("bat")].toFloat()))) {
|
||||
if (tooltipValues[QString("bat")].count() > configuration[QString("tooltipNumber")].toInt())
|
||||
tooltipValues[QString("bat")].takeFirst();
|
||||
if (data[QString("ac")].toBool())
|
||||
tooltipValues[QString("bat")].append(data[QString("bat")].toFloat());
|
||||
else
|
||||
tooltipValues[QString("bat")].append(-data[QString("bat")].toFloat());
|
||||
}
|
||||
} else if (sourceName == QString("cpu/system/TotalLoad")) {
|
||||
values[QString("cpu")] = QString("%1").arg(data[QString("value")].toFloat(), 5, 'f', 1);
|
||||
if (foundBars.indexOf(QRegExp(QString("bar[0-9].*cpu(?!cl).*"))) > -1) {
|
||||
for (int j=0; j<foundBars.count(); j++) {
|
||||
if (getItemByTag(foundBars[j])->bar() != QString("cpu")) continue;
|
||||
values[foundBars[j]] = QString("%1").arg(data[QString("value")].toFloat());
|
||||
}
|
||||
}
|
||||
if ((configuration[QString("cpuTooltip")].toInt() == 2) &&
|
||||
(!isnan(data[QString("value")].toFloat()))) {
|
||||
if (tooltipValues[QString("cpu")].count() > configuration[QString("tooltipNumber")].toInt())
|
||||
tooltipValues[QString("cpu")].takeFirst();
|
||||
tooltipValues[QString("cpu")].append(data[QString("value")].toFloat());
|
||||
}
|
||||
} else if (sourceName.contains(cpuRegExp)) {
|
||||
QString number = sourceName;
|
||||
number.remove(QString("cpu/cpu"));
|
||||
number.remove(QString("/TotalLoad"));
|
||||
values[QString("cpu") + number] = QString("%1").arg(data[QString("value")].toFloat(), 5, 'f', 1);
|
||||
if (foundBars.indexOf(QRegExp(QString("bar[0-9].*cpu(?!cl).*"))) > -1) {
|
||||
for (int j=0; j<foundBars.count(); j++) {
|
||||
if (getItemByTag(foundBars[j])->bar() != (QString("cpu") + number)) continue;
|
||||
values[foundBars[j]] = values[QString("cpu") + number];
|
||||
}
|
||||
}
|
||||
} else if (sourceName == QString("cpu/system/AverageClock")) {
|
||||
values[QString("cpucl")] = QString("%1").arg(data[QString("value")].toFloat(), 4, 'f', 0);
|
||||
if ((configuration[QString("cpuclTooltip")].toInt() == 2) &&
|
||||
(!isnan(data[QString("value")].toFloat()))) {
|
||||
if (tooltipValues[QString("cpucl")].count() > configuration[QString("tooltipNumber")].toInt())
|
||||
tooltipValues[QString("cpucl")].takeFirst();
|
||||
tooltipValues[QString("cpucl")].append(data[QString("value")].toFloat());
|
||||
}
|
||||
} else if (sourceName.contains(cpuclRegExp)) {
|
||||
QString number = sourceName;
|
||||
number.remove(QString("cpu/cpu"));
|
||||
number.remove(QString("/clock"));
|
||||
values[QString("cpucl") + number] = QString("%1").arg(data[QString("value")].toFloat(), 4, 'f', 0);
|
||||
} else if (sourceName == QString("custom")) {
|
||||
for (int i=0; i<data.keys().count(); i++)
|
||||
values[data.keys()[i]] = data[data.keys()[i]].toString();
|
||||
} else if (sourceName == QString("desktop")) {
|
||||
values[QString("desktop")] = data[QString("currentName")].toString();
|
||||
values[QString("ndesktop")] = QString("%1").arg(data[QString("currentNumber")].toInt());
|
||||
values[QString("tdesktops")] = QString("%1").arg(data[QString("number")].toInt());
|
||||
} else if (sourceName.contains(hddrRegExp)) {
|
||||
QString device = sourceName;
|
||||
device.remove(QString("/Rate/rblk"));
|
||||
for (int i=0; i<counts[QString("disk")]; i++)
|
||||
if (configuration[QString("disk")].split(QString("@@"))[i] == device) {
|
||||
values[QString("hddr") + QString::number(i)] = QString("%1").arg(data[QString("value")].toFloat(), 5, 'f', 0);
|
||||
break;
|
||||
}
|
||||
} else if (sourceName.contains(hddwRegExp)) {
|
||||
QString device = sourceName;
|
||||
device.remove(QString("/Rate/wblk"));
|
||||
for (int i=0; i<counts[QString("disk")]; i++)
|
||||
if (configuration[QString("disk")].split(QString("@@"))[i] == device) {
|
||||
values[QString("hddw") + QString::number(i)] = QString("%1").arg(data[QString("value")].toFloat(), 5, 'f', 0);
|
||||
break;
|
||||
}
|
||||
} else if (sourceName == QString("gpu")) {
|
||||
values[QString("gpu")] = QString("%1").arg(data[QString("value")].toFloat(), 5, 'f', 1);
|
||||
if (foundBars.indexOf(QRegExp(QString("bar[0-9].*gpu"))) > -1) {
|
||||
for (int j=0; j<foundBars.count(); j++) {
|
||||
if (getItemByTag(foundBars[j])->bar() != QString("gpu")) continue;
|
||||
values[foundBars[j]] = values[QString("gpu")];
|
||||
}
|
||||
}
|
||||
} else if (sourceName == QString("gputemp")) {
|
||||
values[QString("gputemp")] = QString("%1").arg(getTemp(data[QString("value")].toFloat()), 4, 'f', 1);
|
||||
} else if (sourceName.contains(mountFillRegExp)) {
|
||||
QString mount = sourceName;
|
||||
mount.remove(QString("partitions"));
|
||||
mount.remove(QString("/filllevel"));
|
||||
for (int i=0; i<counts[QString("mount")]; i++)
|
||||
if (configuration[QString("mount")].split(QString("@@"))[i] == mount) {
|
||||
values[QString("hdd") + QString::number(i)] = QString("%1").arg(data[QString("value")].toFloat(), 5, 'f', 1);
|
||||
if (foundBars.indexOf(QRegExp(QString("bar[0-9].*hdd([0-9].*"))) > -1) {
|
||||
for (int j=0; j<foundBars.count(); j++) {
|
||||
if (getItemByTag(foundBars[j])->bar() != (QString("hdd") + QString::number(i))) continue;
|
||||
values[foundBars[j]] = values[QString("hdd") + QString::number(i)];
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (sourceName.contains(mountFreeRegExp)) {
|
||||
QString mount = sourceName;
|
||||
mount.remove(QString("partitions"));
|
||||
mount.remove(QString("/freespace"));
|
||||
for (int i=0; i<counts[QString("mount")]; i++)
|
||||
if (configuration[QString("mount")].split(QString("@@"))[i] == mount) {
|
||||
values[QString("hddfreemb") + QString::number(i)] = QString("%1").arg(
|
||||
data[QString("value")].toFloat() / 1024.0, 5, 'f', 0);
|
||||
values[QString("hddfreegb") + QString::number(i)] = QString("%1").arg(
|
||||
data[QString("value")].toFloat() / (1024.0 * 1024.0), 5, 'f', 1);
|
||||
break;
|
||||
}
|
||||
} else if (sourceName.contains(mountUsedRegExp)) {
|
||||
QString mount = sourceName;
|
||||
mount.remove(QString("partitions"));
|
||||
mount.remove(QString("/usedspace"));
|
||||
for (int i=0; i<counts[QString("mount")]; i++)
|
||||
if (configuration[QString("mount")].split(QString("@@"))[i] == mount) {
|
||||
values[QString("hddmb") + QString::number(i)] = QString("%1").arg(
|
||||
data[QString("value")].toFloat() / 1024.0, 5, 'f', 0);
|
||||
values[QString("hddgb") + QString::number(i)] = QString("%1").arg(
|
||||
data[QString("value")].toFloat() / (1024.0 * 1024.0), 5, 'f', 1);
|
||||
// total
|
||||
values[QString("hddtotmb") + QString::number(i)] = QString("%1").arg(
|
||||
values[QString("hddfreemb") + QString::number(i)].toInt() +
|
||||
values[QString("hddmb") + QString::number(i)].toInt());
|
||||
values[QString("hddtotgb") + QString::number(i)] = QString("%1").arg(
|
||||
values[QString("hddfreegb") + QString::number(i)].toFloat() +
|
||||
values[QString("hddgb") + QString::number(i)].toFloat(),
|
||||
5, 'f', 1);
|
||||
break;
|
||||
}
|
||||
} else if (sourceName == QString("hddtemp")) {
|
||||
for (int i=0; i<data.keys().count(); i++)
|
||||
for (int j=0; j<counts[QString("hddtemp")]; j++)
|
||||
if (data.keys()[i] == configuration[QString("hdd")].split(QString("@@"))[j]) {
|
||||
values[QString("hddtemp") + QString::number(j)] = QString("%1").arg(getTemp(data[data.keys()[i]].toFloat()), 4, 'f', 1);
|
||||
break;
|
||||
}
|
||||
} else if (sourceName == QString("mem/physical/application")) {
|
||||
values[QString("memmb")] = QString("%1").arg(data[QString("value")].toFloat() / 1024.0, 5, 'f', 0);
|
||||
values[QString("memgb")] = QString("%1").arg(data[QString("value")].toFloat() / (1024.0 * 1024.0), 5, 'f', 1);
|
||||
} else if (sourceName == QString("mem/physical/free")) {
|
||||
values[QString("memfreemb")] = QString("%1").arg(data[QString("value")].toFloat() / 1024.0, 5, 'f', 0);
|
||||
values[QString("memfreegb")] = QString("%1").arg(data[QString("value")].toFloat() / (1024.0 * 1024.0), 4, 'f', 1);
|
||||
} else if (sourceName == QString("mem/physical/used")) {
|
||||
values[QString("memusedmb")] = QString("%1").arg(data[QString("value")].toFloat() / 1024.0, 0, 'f', 0);
|
||||
values[QString("memusedgb")] = QString("%1").arg(data[QString("value")].toFloat() / (1024.0 * 1024.0), 4, 'f', 1);
|
||||
// total
|
||||
values[QString("memtotmb")] = QString("%1").arg(
|
||||
values[QString("memusedmb")].toInt() + values[QString("memfreemb")].toInt(), 5);
|
||||
values[QString("memtotgb")] = QString("%1").arg(
|
||||
values[QString("memusedgb")].toFloat() + values[QString("memfreegb")].toFloat(),
|
||||
4, 'f', 1);
|
||||
// percentage
|
||||
values[QString("mem")] = QString("%1").arg(100.0 * values[QString("memmb")].toFloat() / values[QString("memtotmb")].toFloat(),
|
||||
5, 'f', 1);
|
||||
if ((configuration[QString("memTooltip")].toInt() == 2) &&
|
||||
(!isnan(values[QString("mem")].toFloat()))) {
|
||||
if (tooltipValues[QString("mem")].count() > configuration[QString("tooltipNumber")].toInt())
|
||||
tooltipValues[QString("mem")].takeFirst();
|
||||
tooltipValues[QString("mem")].append(values[QString("mem")].toFloat());
|
||||
}
|
||||
if (foundBars.indexOf(QRegExp(QString("bar[0-9].*mem"))) > -1) {
|
||||
for (int j=0; j<foundBars.count(); j++) {
|
||||
if (getItemByTag(foundBars[j])->bar() != QString("mem")) continue;
|
||||
values[foundBars[j]] = values[QString("mem")];
|
||||
}
|
||||
}
|
||||
} else if (sourceName.contains(netRecRegExp)) {
|
||||
values[QString("down")] = QString("%1").arg(data[QString("value")].toFloat(), 4, 'f', 0);
|
||||
if ((configuration[QString("downTooltip")].toInt() == 2) &&
|
||||
(!isnan(data[QString("value")].toFloat()))) {
|
||||
if (tooltipValues[QString("down")].count() > configuration[QString("tooltipNumber")].toInt())
|
||||
tooltipValues[QString("down")].takeFirst();
|
||||
tooltipValues[QString("down")].append(data[QString("value")].toFloat());
|
||||
}
|
||||
networkDeviceUpdate++;
|
||||
if (networkDeviceUpdate >= 30) {
|
||||
networkDeviceUpdate = 0;
|
||||
if (configuration[QString("useCustomNetdev")].toInt() == 0) {
|
||||
sysmonEngine->disconnectSource(QString("network/interfaces/") + values[QString("netdev")] + QString("/transmitter/data"), this);
|
||||
sysmonEngine->disconnectSource(QString("network/interfaces/") + values[QString("netdev")] + QString("/receiver/data"), this);
|
||||
updateNetworkDevice(false);
|
||||
sysmonEngine->connectSource(QString("network/interfaces/") + values[QString("netdev")] + QString("/transmitter/data"),
|
||||
this, configuration[QString("interval")].toInt());
|
||||
sysmonEngine->connectSource(QString("network/interfaces/") + values[QString("netdev")] + QString("/receiver/data"),
|
||||
this, configuration[QString("interval")].toInt());
|
||||
}
|
||||
}
|
||||
} else if (sourceName.contains(netTransRegExp)) {
|
||||
values[QString("up")] = QString("%1").arg(data[QString("value")].toFloat(), 4, 'f', 0);
|
||||
if ((configuration[QString("downTooltip")].toInt() == 2) &&
|
||||
(!isnan(data[QString("value")].toFloat()))) {
|
||||
if (tooltipValues[QString("up")].count() > configuration[QString("tooltipNumber")].toInt())
|
||||
tooltipValues[QString("up")].takeFirst();
|
||||
tooltipValues[QString("up")].append(data[QString("value")].toFloat());
|
||||
}
|
||||
} else if (sourceName == QString("pkg")) {
|
||||
for (int i=0; i<data.keys().count(); i++)
|
||||
values[data.keys()[i].toLower()] = QString("%1").arg(data[data.keys()[i]].toInt(), 2);
|
||||
} else if (sourceName == QString("player")) {
|
||||
values[QString("album")] = data[QString("album")].toString();
|
||||
values[QString("artist")] = data[QString("artist")].toString();
|
||||
values[QString("duration")] = data[QString("duration")].toString();
|
||||
values[QString("progress")] = data[QString("progress")].toString();
|
||||
values[QString("title")] = data[QString("title")].toString();
|
||||
} else if (sourceName == QString("ps")) {
|
||||
values[QString("ps")] = data[QString("ps")].toString();
|
||||
values[QString("pscount")] = QString("%1").arg(data[QString("psCount")].toInt(), 2);
|
||||
values[QString("pstotal")] = QString("%1").arg(data[QString("psTotal")].toInt(), 3);
|
||||
} else if (sourceName == QString("mem/swap/free")) {
|
||||
values[QString("swapfreemb")] = QString("%1").arg(data[QString("value")].toFloat() / 1024.0, 5, 'f', 0);
|
||||
values[QString("swapfreegb")] = QString("%1").arg(data[QString("value")].toFloat() / (1024.0 * 1024.0), 4, 'f', 1);
|
||||
} else if (sourceName == QString("mem/swap/used")) {
|
||||
values[QString("swapmb")] = QString("%1").arg(data[QString("value")].toFloat() / 1024.0, 5, 'f', 0);
|
||||
values[QString("swapgb")] = QString("%1").arg(data[QString("value")].toFloat() / (1024.0 * 1024.0), 4, 'f', 1);
|
||||
// total
|
||||
values[QString("swaptotmb")] = QString("%1").arg(
|
||||
values[QString("swapmb")].toInt() + values[QString("swapfreemb")].toInt(), 5);
|
||||
values[QString("swaptotgb")] = QString("%1").arg(
|
||||
values[QString("swapgb")].toFloat() + values[QString("swapfreegb")].toFloat(), 4, 'f', 1);
|
||||
// percentage
|
||||
values[QString("swap")] = QString("%1").arg(100.0 * values[QString("swapmb")].toFloat() / values[QString("swaptotmb")].toFloat(),
|
||||
5, 'f', 1);
|
||||
if ((configuration[QString("swapTooltip")].toInt() == 2) &&
|
||||
(!isnan(values[QString("swap")].toFloat()))) {
|
||||
if (tooltipValues[QString("swap")].count() > configuration[QString("tooltipNumber")].toInt())
|
||||
tooltipValues[QString("swap")].takeFirst();
|
||||
tooltipValues[QString("swap")].append(values[QString("swap")].toFloat());
|
||||
}
|
||||
if (foundBars.indexOf(QRegExp(QString("bar[0-9].*swap"))) > -1) {
|
||||
for (int j=0; j<foundBars.count(); j++) {
|
||||
if (getItemByTag(foundBars[j])->bar() != QString("swap")) continue;
|
||||
values[foundBars[j]] = values[QString("swap")];
|
||||
}
|
||||
}
|
||||
} else if (sourceName.contains(tempRegExp)) {
|
||||
if (data[QString("units")].toString() == QString("rpm")) {
|
||||
for (int i=0; i<counts[QString("fan")]; i++)
|
||||
if (sourceName == configuration[QString("fanDevice")].split(QString("@@"))[i]) {
|
||||
values[QString("fan") + QString::number(i)] = QString("%1").arg(data[QString("value")].toFloat(), 4, 'f', 1);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
for (int i=0; i<counts[QString("temp")]; i++)
|
||||
if (sourceName == configuration[QString("tempDevice")].split(QString("@@"))[i]) {
|
||||
values[QString("temp") + QString::number(i)] = QString("%1").arg(getTemp(data[QString("value")].toFloat()), 4, 'f', 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (sourceName == QString("Local")) {
|
||||
values[QString("time")] = data[QString("DateTime")].toDateTime().toString(Qt::TextDate);
|
||||
values[QString("isotime")] = data[QString("DateTime")].toDateTime().toString(Qt::ISODate);
|
||||
values[QString("shorttime")] = data[QString("DateTime")].toDateTime().toString(Qt::SystemLocaleShortDate);
|
||||
values[QString("longtime")] = data[QString("DateTime")].toDateTime().toString(Qt::SystemLocaleLongDate);
|
||||
QStringList timeKeys = getTimeKeys();
|
||||
values[QString("ctime")] = configuration[QString("customTime")];
|
||||
for (int i=0; i<timeKeys.count(); i++)
|
||||
values[QString("ctime")].replace(QString("$") + timeKeys[i],
|
||||
data[QString("DateTime")].toDateTime().toString(timeKeys[i]));
|
||||
} else if (sourceName == QString("system/uptime")) {
|
||||
int uptime = data[QString("value")].toFloat();
|
||||
int seconds = uptime - uptime % 60;
|
||||
int minutes = seconds / 60 % 60;
|
||||
int hours = ((seconds / 60) - minutes) / 60 % 24;
|
||||
int days = (((seconds / 60) - minutes) / 60 - hours) / 24;
|
||||
values[QString("uptime")] = QString("%1d%2h%3m").arg(days, 3).arg(hours, 2).arg(minutes, 2);
|
||||
values[QString("cuptime")] = configuration[QString("customUptime")];
|
||||
values[QString("cuptime")].replace(QString("$dd"), QString("%1").arg(days, 3, 10, QChar('0')));
|
||||
values[QString("cuptime")].replace(QString("$d"), QString("%1").arg(days));
|
||||
values[QString("cuptime")].replace(QString("$hh"), QString("%1").arg(hours, 2, 10, QChar('0')));
|
||||
values[QString("cuptime")].replace(QString("$h"), QString("%1").arg(hours));
|
||||
values[QString("cuptime")].replace(QString("$mm"), QString("%1").arg(minutes, 2, 10, QChar('0')));
|
||||
values[QString("cuptime")].replace(QString("$m"), QString("%1").arg(minutes));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void AwesomeWidget::disconnectFromEngine()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
QRegExp regExp;
|
||||
|
||||
// battery
|
||||
regExp = QRegExp(QString("(^|bar[0-9].*)(ac|bat.*)"));
|
||||
if ((foundKeys.indexOf(regExp) > -1) ||
|
||||
(configuration[QString("batteryTooltip")].toInt() == 2) ||
|
||||
(foundBars.indexOf(regExp) > -1))
|
||||
extsysmonEngine->disconnectSource(QString("battery"), this);
|
||||
// cpu
|
||||
regExp = QRegExp(QString("(^|bar[0-9].*)cpu(?!cl).*"));
|
||||
if ((foundKeys.indexOf(regExp) > -1) ||
|
||||
(configuration[QString("cpuTooltip")].toInt() == 2) ||
|
||||
(foundBars.indexOf(regExp) > -1)) {
|
||||
sysmonEngine->disconnectSource(QString("cpu/system/TotalLoad"), this);
|
||||
for (int i=0; i<counts[QString("cpu")]; i++)
|
||||
sysmonEngine->disconnectSource(QString("cpu/cpu") + QString::number(i) + QString("/TotalLoad"), this);
|
||||
}
|
||||
// cpuclock
|
||||
regExp = QRegExp(QString("cpucl.*"));
|
||||
if ((foundKeys.indexOf(regExp) > -1) ||
|
||||
(configuration[QString("cpuclTooltip")].toInt() == 2)) {
|
||||
sysmonEngine->disconnectSource(QString("cpu/system/AverageClock"), this);
|
||||
for (int i=0; i<counts[QString("cpu")]; i++)
|
||||
sysmonEngine->disconnectSource(QString("cpu/cpu") + QString::number(i) + QString("/clock"), this);
|
||||
}
|
||||
// custom command
|
||||
regExp = QRegExp(QString("custom.*"));
|
||||
if (foundKeys.indexOf(regExp) > -1)
|
||||
extsysmonEngine->disconnectSource(QString("custom"), this);
|
||||
// desktop
|
||||
regExp = QRegExp(QString(".*desktop.*"));
|
||||
if (foundKeys.indexOf(regExp) > -1)
|
||||
extsysmonEngine->disconnectSource(QString("desktop"), this);
|
||||
// disk speed
|
||||
regExp = QRegExp(QString("hdd[rw].*"));
|
||||
if (foundKeys.indexOf(regExp) > -1)
|
||||
for (int i=0; i<configuration[QString("disk")].split(QString("@@")).count(); i++) {
|
||||
sysmonEngine->disconnectSource(configuration[QString("disk")].split(QString("@@"))[i] + QString("/Rate/rblk"), this);
|
||||
sysmonEngine->disconnectSource(configuration[QString("disk")].split(QString("@@"))[i] + QString("/Rate/wblk"), this);
|
||||
}
|
||||
// fan
|
||||
regExp = QRegExp(QString("fan.*"));
|
||||
if (foundKeys.indexOf(regExp) > -1)
|
||||
for (int i=0; i<configuration[QString("fanDevice")].split(QString("@@")).count(); i++)
|
||||
sysmonEngine->disconnectSource(configuration[QString("fanDevice")].split(QString("@@"))[i], this);
|
||||
// gpu
|
||||
regExp = QRegExp(QString("(^|bar[0-9].*)gpu"));
|
||||
if ((foundKeys.indexOf(regExp) > -1) ||
|
||||
(foundBars.indexOf(regExp) > -1))
|
||||
extsysmonEngine->disconnectSource(QString("gpu"), this);
|
||||
// gputemp
|
||||
regExp = QRegExp(QString("gputemp"));
|
||||
if (foundKeys.indexOf(regExp) > -1)
|
||||
extsysmonEngine->disconnectSource(QString("gputemp"), this);
|
||||
// mount
|
||||
regExp = QRegExp(QString("(^|bar[0-9].*)hdd([0-9]|mb|gb|freemb|freegb|totmb|totgb).*"));
|
||||
if ((foundKeys.indexOf(regExp) > -1) ||
|
||||
(foundBars.indexOf(regExp) > -1))
|
||||
for (int i=0; i<configuration[QString("mount")].split(QString("@@")).count(); i++) {
|
||||
sysmonEngine->disconnectSource(QString("partitions") + configuration[QString("mount")].split(QString("@@"))[i] + QString("/filllevel"), this);
|
||||
sysmonEngine->disconnectSource(QString("partitions") + configuration[QString("mount")].split(QString("@@"))[i] + QString("/freespace"), this);
|
||||
sysmonEngine->disconnectSource(QString("partitions") + configuration[QString("mount")].split(QString("@@"))[i] + QString("/usedspace"), this);
|
||||
}
|
||||
// hddtemp
|
||||
regExp = QRegExp(QString("hddtemp.*"));
|
||||
if (foundKeys.indexOf(regExp) > -1)
|
||||
extsysmonEngine->disconnectSource(QString("hddtemp"), this);
|
||||
// memory
|
||||
regExp = QRegExp(QString("(^|bar[0-9].*)mem.*"));
|
||||
if ((foundKeys.indexOf(regExp) > -1) ||
|
||||
(configuration[QString("memTooltip")].toInt() == 2) ||
|
||||
(foundBars.indexOf(regExp) > -1)) {
|
||||
sysmonEngine->disconnectSource(QString("mem/physical/free"), this);
|
||||
sysmonEngine->disconnectSource(QString("mem/physical/used"), this);
|
||||
sysmonEngine->disconnectSource(QString("mem/physical/application"), this);
|
||||
}
|
||||
// network
|
||||
regExp = QRegExp(QString("(down|up|netdev)"));
|
||||
if ((foundKeys.indexOf(regExp) > -1) ||
|
||||
(configuration[QString("downTooltip")].toInt() == 2)) {
|
||||
sysmonEngine->disconnectSource(QString("network/interfaces/") + values[QString("netdev")] + QString("/transmitter/data"), this);
|
||||
sysmonEngine->disconnectSource(QString("network/interfaces/") + values[QString("netdev")] + QString("/receiver/data"), this);
|
||||
}
|
||||
// package manager
|
||||
regExp = QRegExp(QString("pkgcount.*"));
|
||||
if (foundKeys.indexOf(regExp) > -1)
|
||||
extsysmonEngine->disconnectSource(QString("pkg"), this);
|
||||
// player
|
||||
regExp = QRegExp(QString("(album|artist|duration|progress|title)"));
|
||||
if (foundKeys.indexOf(regExp) > -1)
|
||||
extsysmonEngine->disconnectSource(QString("player"), this);
|
||||
// ps
|
||||
regExp = QRegExp(QString("ps.*"));
|
||||
if (foundKeys.indexOf(regExp) > -1)
|
||||
extsysmonEngine->disconnectSource(QString("ps"), this);
|
||||
// swap
|
||||
regExp = QRegExp(QString("(^|bar[0-9].*)swap.*"));
|
||||
if ((foundKeys.indexOf(regExp) > -1) ||
|
||||
(configuration[QString("swapTooltip")].toInt() == 2) ||
|
||||
(foundBars.indexOf(regExp) > -1)) {
|
||||
sysmonEngine->disconnectSource(QString("mem/swap/free"), this);
|
||||
sysmonEngine->disconnectSource(QString("mem/swap/used"), this);
|
||||
}
|
||||
// temp
|
||||
regExp = QRegExp(QString("temp.*"));
|
||||
if (foundKeys.indexOf(regExp) > -1)
|
||||
for (int i=0; i<configuration[QString("tempDevice")].split(QString("@@")).count(); i++)
|
||||
sysmonEngine->disconnectSource(configuration[QString("tempDevice")].split(QString("@@"))[i], this);
|
||||
// time
|
||||
regExp = QRegExp(QString("(^|iso|short|long|c)time"));
|
||||
if (foundKeys.indexOf(regExp) > -1)
|
||||
timeEngine->disconnectSource(QString("Local"), this);
|
||||
// uptime
|
||||
regExp = QRegExp(QString("(^|c)uptime"));
|
||||
if (foundKeys.indexOf(regExp) > -1)
|
||||
sysmonEngine->disconnectSource(QString("system/uptime"), this);
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
[Desktop Entry]
|
||||
Encoding=UTF-8
|
||||
Name=bar0
|
||||
Comment=Simple cpu bar
|
||||
X-AW-Value=cpu
|
||||
X-AW-ActiveColor="0,0,0,255"
|
||||
X-AW-InactiveColor="255,255,255,255"
|
||||
X-AW-Type=Horizontal
|
||||
X-AW-Direction=LeftToRight
|
||||
X-AW-Height=25
|
||||
X-AW-Width=100
|
||||
X-AW-ApiVersion=1
|
@ -1,12 +0,0 @@
|
||||
[Desktop Entry]
|
||||
Encoding=UTF-8
|
||||
Name=bar1
|
||||
Comment=Simple mem bar
|
||||
X-AW-Value=mem
|
||||
X-AW-ActiveColor="0,0,0,255"
|
||||
X-AW-InactiveColor="255,255,255,255"
|
||||
X-AW-Type=Horizontal
|
||||
X-AW-Direction=LeftToRight
|
||||
X-AW-Height=25
|
||||
X-AW-Width=100
|
||||
X-AW-ApiVersion=1
|
@ -1,12 +0,0 @@
|
||||
[Desktop Entry]
|
||||
Encoding=UTF-8
|
||||
Name=bar2
|
||||
Comment=Simple swap bar
|
||||
X-AW-Value=swap
|
||||
X-AW-ActiveColor="0,0,0,255"
|
||||
X-AW-InactiveColor="255,255,255,255"
|
||||
X-AW-Type=Horizontal
|
||||
X-AW-Direction=LeftToRight
|
||||
X-AW-Height=25
|
||||
X-AW-Width=100
|
||||
X-AW-ApiVersion=1
|
@ -1,25 +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
|
||||
# API version
|
||||
X-AW-ApiVersion=1
|
@ -1,523 +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>
|
||||
|
||||
#include "version.h"
|
||||
|
||||
|
||||
GraphicalItem::GraphicalItem(QWidget *parent, const QString desktopName, const QStringList directories, const bool debugCmd)
|
||||
: QDialog(parent),
|
||||
m_fileName(desktopName),
|
||||
m_dirs(directories),
|
||||
debug(debugCmd),
|
||||
ui(new Ui::GraphicalItem)
|
||||
{
|
||||
readConfiguration();
|
||||
|
||||
ui->setupUi(this);
|
||||
connect(ui->pushButton_activeColor, SIGNAL(clicked()), this, SLOT(changeColor()));
|
||||
connect(ui->pushButton_inactiveColor, SIGNAL(clicked()), this, SLOT(changeColor()));
|
||||
}
|
||||
|
||||
|
||||
GraphicalItem::~GraphicalItem()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
||||
QString GraphicalItem::image(const float value)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Value" << value;
|
||||
if (m_bar == QString("none")) return QString("");
|
||||
|
||||
QColor active = stringToColor(m_activeColor);
|
||||
QColor inactive = stringToColor(m_inactiveColor);
|
||||
float percent = value / 100.0;
|
||||
int scale[2] = {1, 1};
|
||||
QPen pen = QPen();
|
||||
QGraphicsScene *scene = new QGraphicsScene();
|
||||
scene->setBackgroundBrush(QBrush(Qt::NoBrush));
|
||||
QGraphicsView *view = new QGraphicsView(scene);
|
||||
view->setStyleSheet(QString("background: transparent"));
|
||||
view->setContentsMargins(0, 0, 0, 0);
|
||||
view->setFrameShape(QFrame::NoFrame);
|
||||
view->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
view->resize(m_width + 5.0, m_height + 5.0);
|
||||
|
||||
// paint
|
||||
switch(m_type) {
|
||||
case Vertical:
|
||||
pen.setWidth(m_width);
|
||||
// inactive
|
||||
pen.setColor(inactive);
|
||||
scene->addLine(0.5 * m_width, -0.5 * m_width, 0.5 * m_width,
|
||||
(1.0 - percent) * m_height - 0.5 * m_width, pen);
|
||||
// active
|
||||
pen.setColor(active);
|
||||
scene->addLine(0.5 * m_width, (1.0 - percent) * m_height + 0.5 * m_width,
|
||||
0.5 * m_width, m_height + 0.5 * m_width, pen);
|
||||
// scale
|
||||
scale[1] = -2 * static_cast<int>(m_direction) + 1;
|
||||
break;
|
||||
case Circle:
|
||||
QGraphicsEllipseItem *circle;
|
||||
pen.setWidth(1.0);
|
||||
// inactive
|
||||
pen.setColor(inactive);
|
||||
circle = scene->addEllipse(0.0, 0.0, m_width, m_height, pen, QBrush(inactive, Qt::SolidPattern));
|
||||
circle->setSpanAngle(- (1.0 - percent) * 360.0 * 16.0);
|
||||
circle->setStartAngle(90.0 * 16.0 - percent * 360.0 * 16.0);
|
||||
// active
|
||||
pen.setColor(active);
|
||||
circle = scene->addEllipse(0.0, 0.0, m_width, m_height, pen, QBrush(active, Qt::SolidPattern));
|
||||
circle->setSpanAngle(- percent * 360.0 * 16.0);
|
||||
circle->setStartAngle(90.0 * 16.0);
|
||||
// scale
|
||||
scale[0] = -2 * static_cast<int>(m_direction) + 1;
|
||||
break;
|
||||
default:
|
||||
pen.setWidth(m_height);
|
||||
// inactive
|
||||
pen.setColor(inactive);
|
||||
scene->addLine(percent * m_width + 0.5 * m_height, 0.5 * m_height,
|
||||
m_width + 0.5 * m_height, 0.5 * m_height, pen);
|
||||
// active
|
||||
pen.setColor(active);
|
||||
scene->addLine(-0.5 * m_height, 0.5 * m_height,
|
||||
percent * m_width - 0.5 * m_height, 0.5 * m_height, pen);
|
||||
// scale
|
||||
scale[0] = -2 * static_cast<int>(m_direction) + 1;
|
||||
break;
|
||||
}
|
||||
|
||||
// convert
|
||||
QPixmap pixmap = QPixmap::grabWidget(view).transformed(QTransform().scale(scale[0], scale[1]));
|
||||
QByteArray byteArray;
|
||||
QBuffer buffer(&byteArray);
|
||||
pixmap.save(&buffer, "PNG");
|
||||
QString url = QString("<img src=\"data:image/png;base64,%1\"/>").arg(QString(byteArray.toBase64()));
|
||||
delete view;
|
||||
delete scene;
|
||||
|
||||
return url;
|
||||
}
|
||||
|
||||
|
||||
QString GraphicalItem::fileName()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return m_fileName;
|
||||
}
|
||||
|
||||
|
||||
int GraphicalItem::apiVersion()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return m_apiVersion;
|
||||
}
|
||||
|
||||
|
||||
QString GraphicalItem::name()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return m_name;
|
||||
}
|
||||
|
||||
|
||||
QString GraphicalItem::comment()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return m_comment;
|
||||
}
|
||||
|
||||
|
||||
QString GraphicalItem::bar()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return m_bar;
|
||||
}
|
||||
|
||||
|
||||
QString GraphicalItem::activeColor()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return m_activeColor;
|
||||
}
|
||||
|
||||
|
||||
QString GraphicalItem::inactiveColor()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return m_inactiveColor;
|
||||
}
|
||||
|
||||
|
||||
GraphicalItem::Type GraphicalItem::type()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return m_type;
|
||||
}
|
||||
|
||||
|
||||
QString GraphicalItem::strType()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QString value;
|
||||
switch(m_type) {
|
||||
case Vertical:
|
||||
value = QString("Vertical");
|
||||
break;
|
||||
case Circle:
|
||||
value = QString("Circle");
|
||||
break;
|
||||
default:
|
||||
value = QString("Horizontal");
|
||||
break;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
GraphicalItem::Direction GraphicalItem::direction()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return m_direction;
|
||||
}
|
||||
|
||||
|
||||
QString GraphicalItem::strDirection()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QString value;
|
||||
switch (m_direction) {
|
||||
case RightToLeft:
|
||||
value = QString("RightToLeft");
|
||||
break;
|
||||
default:
|
||||
value = QString("LeftToRight");
|
||||
break;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
int GraphicalItem::height()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return m_height;
|
||||
}
|
||||
|
||||
|
||||
int GraphicalItem::width()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return m_width;
|
||||
}
|
||||
|
||||
|
||||
void GraphicalItem::setApiVersion(const int _apiVersion)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Version" << _apiVersion;
|
||||
|
||||
m_apiVersion = _apiVersion;
|
||||
}
|
||||
|
||||
|
||||
void GraphicalItem::setName(const QString _name)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Name" << _name;
|
||||
|
||||
m_name = _name;
|
||||
}
|
||||
|
||||
|
||||
void GraphicalItem::setComment(const QString _comment)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Comment" << _comment;
|
||||
|
||||
m_comment = _comment;
|
||||
}
|
||||
|
||||
|
||||
void GraphicalItem::setBar(const QString _bar)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Bar" << _bar;
|
||||
|
||||
if ((!_bar.contains(QRegExp(QString("cpu(?!cl).*")))) &&
|
||||
(!_bar.contains(QRegExp(QString("gpu")))) &&
|
||||
(!_bar.contains(QRegExp(QString("mem")))) &&
|
||||
(!_bar.contains(QRegExp(QString("swap")))) &&
|
||||
(!_bar.contains(QRegExp(QString("hdd[0-9].*")))) &&
|
||||
(!_bar.contains(QRegExp(QString("bat.*")))))
|
||||
m_bar = QString("none");
|
||||
else
|
||||
m_bar = _bar;
|
||||
}
|
||||
|
||||
|
||||
void GraphicalItem::setActiveColor(const QString _color)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Color" << _color;
|
||||
|
||||
m_activeColor = _color;
|
||||
}
|
||||
|
||||
|
||||
void GraphicalItem::setInactiveColor(const QString _color)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Color" << _color;
|
||||
|
||||
m_inactiveColor = _color;
|
||||
}
|
||||
|
||||
|
||||
void GraphicalItem::setType(const Type _type)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Type" << _type;
|
||||
|
||||
m_type = _type;
|
||||
}
|
||||
|
||||
|
||||
void GraphicalItem::setStrType(const QString _type)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Type" << _type;
|
||||
|
||||
if (_type == QString("Vertical"))
|
||||
setType(Vertical);
|
||||
else if (_type == QString("Circle"))
|
||||
setType(Circle);
|
||||
else
|
||||
setType(Horizontal);
|
||||
}
|
||||
|
||||
|
||||
void GraphicalItem::setDirection(const Direction _direction)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Direction" << _direction;
|
||||
|
||||
m_direction = _direction;
|
||||
}
|
||||
|
||||
|
||||
void GraphicalItem::setStrDirection(const QString _direction)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Direction" << _direction;
|
||||
|
||||
if (_direction == QString("RightToLeft"))
|
||||
setDirection(RightToLeft);
|
||||
else
|
||||
setDirection(LeftToRight);
|
||||
}
|
||||
|
||||
|
||||
void GraphicalItem::setHeight(const int _height)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Height" << _height;
|
||||
if (_height <= 0) return;
|
||||
|
||||
m_height = _height;
|
||||
}
|
||||
|
||||
|
||||
void GraphicalItem::setWidth(const int _width)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Width" << _width;
|
||||
if (_width <= 0) return;
|
||||
|
||||
m_width = _width;
|
||||
}
|
||||
|
||||
|
||||
void GraphicalItem::readConfiguration()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
for (int i=m_dirs.count()-1; i>=0; i--) {
|
||||
if (!QDir(m_dirs[i]).entryList(QDir::Files).contains(m_fileName)) continue;
|
||||
QSettings settings(m_dirs[i] + QDir::separator() + m_fileName, QSettings::IniFormat);
|
||||
|
||||
settings.beginGroup(QString("Desktop Entry"));
|
||||
setName(settings.value(QString("Name"), m_name).toString());
|
||||
setComment(settings.value(QString("Comment"), m_comment).toString());
|
||||
setApiVersion(settings.value(QString("X-AW-ApiVersion"), AWGIAPI).toInt());
|
||||
setBar(settings.value(QString("X-AW-Value"), m_bar).toString());
|
||||
setActiveColor(settings.value(QString("X-AW-ActiveColor"), m_activeColor).toString());
|
||||
setInactiveColor(settings.value(QString("X-AW-InactiveColor"), m_inactiveColor).toString());
|
||||
setStrType(settings.value(QString("X-AW-Type"), strType()).toString());
|
||||
setStrDirection(settings.value(QString("X-AW-Direction"), strDirection()).toString());
|
||||
setHeight(settings.value(QString("X-AW-Height"), m_height).toInt());
|
||||
setWidth(settings.value(QString("X-AW-Width"), m_width).toInt());
|
||||
settings.endGroup();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int GraphicalItem::showConfiguration(const QStringList tags)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
ui->label_nameValue->setText(m_name);
|
||||
ui->lineEdit_comment->setText(m_comment);
|
||||
ui->comboBox_value->addItems(tags);
|
||||
ui->comboBox_value->addItem(m_bar);
|
||||
ui->comboBox_value->setCurrentIndex(ui->comboBox_value->count() - 1);
|
||||
ui->pushButton_activeColor->setText(m_activeColor);
|
||||
ui->pushButton_inactiveColor->setText(m_inactiveColor);
|
||||
ui->comboBox_type->setCurrentIndex(static_cast<int>(m_type));
|
||||
ui->comboBox_direction->setCurrentIndex(static_cast<int>(m_direction));
|
||||
ui->spinBox_height->setValue(m_height);
|
||||
ui->spinBox_width->setValue(m_width);
|
||||
|
||||
int ret = exec();
|
||||
if (ret != 1) return ret;
|
||||
|
||||
setName(ui->label_nameValue->text());
|
||||
setComment(ui->lineEdit_comment->text());
|
||||
setApiVersion(AWGIAPI);
|
||||
setBar(ui->comboBox_value->currentText());
|
||||
setActiveColor(ui->pushButton_activeColor->text().remove(QChar('&')));
|
||||
setInactiveColor(ui->pushButton_inactiveColor->text().remove(QChar('&')));
|
||||
setStrType(ui->comboBox_type->currentText());
|
||||
setStrDirection(ui->comboBox_direction->currentText());
|
||||
setHeight(ui->spinBox_height->value());
|
||||
setWidth(ui->spinBox_width->value());
|
||||
|
||||
writeConfiguration();
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int GraphicalItem::tryDelete()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
for (int i=0; i<m_dirs.count(); i++)
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Remove file" << m_dirs[i] + QDir::separator() + m_fileName <<
|
||||
QFile::remove(m_dirs[i] + QDir::separator() + m_fileName);
|
||||
|
||||
// check if exists
|
||||
for (int i=0; i<m_dirs.count(); i++)
|
||||
if (QFile::exists(m_dirs[i] + QDir::separator() + m_fileName)) return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
void GraphicalItem::writeConfiguration()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QSettings settings(m_dirs[0] + QDir::separator() + m_fileName, QSettings::IniFormat);
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Configuration file" << settings.fileName();
|
||||
|
||||
settings.beginGroup(QString("Desktop Entry"));
|
||||
settings.setValue(QString("Encoding"), QString("UTF-8"));
|
||||
settings.setValue(QString("Name"), m_name);
|
||||
settings.setValue(QString("Comment"), m_comment);
|
||||
settings.setValue(QString("X-AW-ApiVersion"), m_apiVersion);
|
||||
settings.setValue(QString("X-AW-Value"), m_bar);
|
||||
settings.setValue(QString("X-AW-ActiveColor"), m_activeColor);
|
||||
settings.setValue(QString("X-AW-InactiveColor"), m_inactiveColor);
|
||||
settings.setValue(QString("X-AW-Type"), strType());
|
||||
settings.setValue(QString("X-AW-Direction"), strDirection());
|
||||
settings.setValue(QString("X-AW-Height"), m_height);
|
||||
settings.setValue(QString("X-AW-Width"), m_width);
|
||||
settings.endGroup();
|
||||
|
||||
settings.sync();
|
||||
}
|
||||
|
||||
|
||||
void GraphicalItem::changeColor()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QColor color = stringToColor(((QPushButton *)sender())->text());
|
||||
QColor newColor = QColorDialog::getColor(color, 0, i18n("Select color"),
|
||||
QColorDialog::ShowAlphaChannel);
|
||||
if (!newColor.isValid()) return;
|
||||
|
||||
QStringList colorText;
|
||||
colorText.append(QString("%1").arg(newColor.red()));
|
||||
colorText.append(QString("%1").arg(newColor.green()));
|
||||
colorText.append(QString("%1").arg(newColor.blue()));
|
||||
colorText.append(QString("%1").arg(newColor.alpha()));
|
||||
dynamic_cast<QPushButton *>(sender())->setText(colorText.join(QChar(',')));
|
||||
}
|
||||
|
||||
|
||||
QColor GraphicalItem::stringToColor(const QString _color)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Color" << _color;
|
||||
|
||||
QColor qcolor;
|
||||
QStringList listColor = _color.split(QChar(','));
|
||||
while (listColor.count() < 4)
|
||||
listColor.append(QString("0"));
|
||||
qcolor.setRed(listColor[0].toInt());
|
||||
qcolor.setGreen(listColor[1].toInt());
|
||||
qcolor.setBlue(listColor[2].toInt());
|
||||
qcolor.setAlpha(listColor[3].toInt());
|
||||
|
||||
return qcolor;
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
[Global]
|
||||
IconName=system
|
||||
Name=Awesome Widget
|
||||
Comment=Awesome widget information
|
||||
|
||||
[Event/system]
|
||||
Name=System information
|
||||
Comment=System information
|
||||
Action=Popup
|
||||
|
||||
[Event/tag]
|
||||
Name=Tag information
|
||||
Comment=Tag information
|
||||
Action=Popup
|
@ -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])->image(values[foundBars[i]].toFloat()));
|
||||
text.replace(QString("$\\$\\"), QString("$$"));
|
||||
}
|
||||
textLabel->setText(formatLine[0] + text + formatLine[1]);
|
||||
mainLayout->itemAt(0, 0)->updateGeometry();
|
||||
updateGeometry();
|
||||
}
|
||||
|
||||
|
||||
void AwesomeWidget::updateTooltip()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
toolTipView->resize(100.0 * counts[QString("tooltip")], 105.0);
|
||||
// boundaries
|
||||
QMap<QString, float> boundaries;
|
||||
boundaries[QString("cpu")] = 100.0;
|
||||
boundaries[QString("cpucl")] = 4000.0;
|
||||
boundaries[QString("mem")] = 100.0;
|
||||
boundaries[QString("swap")] = 100.0;
|
||||
boundaries[QString("down")] = 1.0;
|
||||
if (configuration[QString("downTooltip")].toInt() == 2) {
|
||||
for (int i=0; i<tooltipValues[QString("down")].count(); i++)
|
||||
if (boundaries[QString("down")] < tooltipValues[QString("down")][i])
|
||||
boundaries[QString("down")] = tooltipValues[QString("down")][i];
|
||||
for (int i=0; i<tooltipValues[QString("up")].count(); i++)
|
||||
if (boundaries[QString("down")] < tooltipValues[QString("up")][i])
|
||||
boundaries[QString("down")] = tooltipValues[QString("up")][i];
|
||||
boundaries[QString("down")] *= 1.2;
|
||||
}
|
||||
boundaries[QString("up")] = boundaries[QString("down")];
|
||||
boundaries[QString("bat")] = 100.0;
|
||||
|
||||
// create image
|
||||
toolTipScene->clear();
|
||||
QPen pen = QPen();
|
||||
if (configuration[QString("useTooltipBackground")].toInt() == 2)
|
||||
toolTipScene->setBackgroundBrush(QColor(configuration[QString("tooltipBackground")]));
|
||||
else
|
||||
toolTipScene->setBackgroundBrush(QBrush(Qt::NoBrush));
|
||||
bool down = false;
|
||||
bool isBattery = false;
|
||||
QStringList trueKeys;
|
||||
if (tooltipValues.contains(QString("cpu"))) trueKeys.append(QString("cpu"));
|
||||
if (tooltipValues.contains(QString("cpucl"))) trueKeys.append(QString("cpucl"));
|
||||
if (tooltipValues.contains(QString("mem"))) trueKeys.append(QString("mem"));
|
||||
if (tooltipValues.contains(QString("swap"))) trueKeys.append(QString("swap"));
|
||||
if (tooltipValues.contains(QString("down"))) trueKeys.append(QString("down"));
|
||||
if (tooltipValues.contains(QString("up"))) trueKeys.append(QString("up"));
|
||||
if (tooltipValues.contains(QString("bat"))) trueKeys.append(QString("bat"));
|
||||
for (int i=0; i<trueKeys.count(); i++) {
|
||||
float normX = 100.0 / (float)tooltipValues[trueKeys[i]].count();
|
||||
float normY = 100.0 / (1.5 * boundaries[trueKeys[i]]);
|
||||
if (trueKeys[i] == QString("bat"))
|
||||
isBattery = true;
|
||||
else
|
||||
isBattery = false;
|
||||
if (!isBattery) pen.setColor(QColor(configuration[trueKeys[i] + QString("Color")]));
|
||||
float shift = i * 100.0;
|
||||
if (down) shift -= 100.0;
|
||||
for (int j=0; j<tooltipValues[trueKeys[i]].count()-1; j++) {
|
||||
float x1 = j * normX + shift;
|
||||
float y1 = - fabs(tooltipValues[trueKeys[i]][j]) * normY + 5.0;
|
||||
float x2 = (j + 1) * normX + shift;
|
||||
float y2 = - fabs(tooltipValues[trueKeys[i]][j+1]) * normY + 5.0;
|
||||
if (isBattery) {
|
||||
if (tooltipValues[trueKeys[i]][j+1] > 0)
|
||||
pen.setColor(QColor(configuration[QString("batteryColor")]));
|
||||
else
|
||||
pen.setColor(QColor(configuration[QString("batteryInColor")]));
|
||||
}
|
||||
toolTipScene->addLine(x1, y1, x2, y2, pen);
|
||||
}
|
||||
if (trueKeys[i] == QString("down")) down = true;
|
||||
}
|
||||
|
||||
toolTip.setImage(QPixmap::grabWidget(toolTipView));
|
||||
Plasma::ToolTipManager::self()->setContent(this, toolTip);
|
||||
}
|
@ -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>
|
@ -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 <a href="http://arcanis.name/projects/awesome-widgets/">project homepage</a></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>
|
@ -1,19 +0,0 @@
|
||||
# set project name
|
||||
set (SUBPROJECT plasma_applet_awesome-widget)
|
||||
message (STATUS "Subproject ${SUBPROJECT}")
|
||||
|
||||
# prepare
|
||||
configure_file (metadata.desktop ${CMAKE_CURRENT_SOURCE_DIR}/package/metadata.desktop)
|
||||
|
||||
find_package (ECM 0.0.12 REQUIRED NO_MODULE)
|
||||
set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR})
|
||||
|
||||
find_package (Qt5 REQUIRED COMPONENTS Core Network Qml)
|
||||
find_package (KF5 REQUIRED COMPONENTS I18n Notifications Plasma)
|
||||
|
||||
include (KDEInstallDirs)
|
||||
include (KDECMakeSettings)
|
||||
include (KDECompilerSettings)
|
||||
|
||||
add_subdirectory (plugin)
|
||||
plasma_install_package (package org.kde.plasma.awesomewidget)
|
@ -1,44 +0,0 @@
|
||||
set (PLUGIN_NAME awplugin)
|
||||
|
||||
add_definitions (${Qt5Core_DEFINITIONS} ${Qt5Network_DEFINITIONS})
|
||||
set (Qt_INCLUDE ${Qt5Core_INCLUDE_DIRS}
|
||||
${Qt5Network_INCLUDE_DIRS}
|
||||
${Qt5Qml_INCLUDE_DIRS})
|
||||
set (Qt_LIBRARIES ${Qt5Core_LIBRARIES}
|
||||
${Qt5Network_LIBRARIES}
|
||||
${Qt5Qml_LIBRARIES})
|
||||
set (Kf5_INCLUDE ${I18n_INCLUDE_DIR}
|
||||
${Notifications_INCLUDE_DIR})
|
||||
set (Kf5_LIBRARIES KF5::I18n
|
||||
KF5::Notifications)
|
||||
|
||||
include_directories (${CMAKE_SOURCE_DIR}
|
||||
${CMAKE_BINARY_DIR}
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
${CMAKE_CURRENT_BINARY_DIR}/../
|
||||
${PROJECT_TRDPARTY_DIR}
|
||||
../../extsysmon
|
||||
${CMAKE_CURRENT_BINARY_DIR}/../../extsysmon
|
||||
${Qt_INCLUDE}
|
||||
${Kf5_INCLUDE})
|
||||
|
||||
file (GLOB SUBPROJECT_SOURCE *.cpp)
|
||||
file (GLOB SUBPROJECT_NOTIFY *.notifyrc)
|
||||
file (GLOB SUBPROJECT_UI *.ui)
|
||||
# task source is required by extscripts
|
||||
file (GLOB_RECURSE SUBPROJECT_SOURCE *.cpp ${PROJECT_TRDPARTY_DIR}/task/*.cpp
|
||||
${PROJECT_TRDPARTY_DIR}/fontdialog/*.cpp
|
||||
../../extsysmon/extscript.cpp
|
||||
../../extsysmon/extupgrade.cpp)
|
||||
set (TASK_HEADER ${PROJECT_TRDPARTY_DIR}/task/task.h)
|
||||
set (SUBPROJECT_DESKTOPS ${CMAKE_CURRENT_SOURCE_DIR}/desktops)
|
||||
|
||||
qt5_wrap_cpp (TASK_MOC_SOURCE ${TASK_HEADER})
|
||||
qt5_wrap_ui (SUBPROJECT_UI_HEADER ${SUBPROJECT_UI})
|
||||
add_library (${PLUGIN_NAME} SHARED ${SUBPROJECT_SOURCE} ${SUBPROJECT_UI_HEADER} ${TASK_MOC_SOURCE})
|
||||
target_link_libraries (${PLUGIN_NAME} ${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})
|
||||
install (DIRECTORY ${SUBPROJECT_DESKTOPS} DESTINATION ${DATA_INSTALL_DIR}/${PROJECT_NAME})
|
@ -1,50 +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 "awesomewidget.h"
|
||||
|
||||
#include <QtQml>
|
||||
|
||||
#include "awactions.h"
|
||||
#include "awkeys.h"
|
||||
|
||||
|
||||
static QObject *awactions_singletontype_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
|
||||
{
|
||||
Q_UNUSED(engine);
|
||||
Q_UNUSED(scriptEngine);
|
||||
|
||||
return new AWActions();
|
||||
}
|
||||
|
||||
|
||||
static QObject *awkeys_singletontype_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
|
||||
{
|
||||
Q_UNUSED(engine);
|
||||
Q_UNUSED(scriptEngine);
|
||||
|
||||
return new AWKeys();
|
||||
}
|
||||
|
||||
|
||||
void AWPlugin::registerTypes(const char *uri)
|
||||
{
|
||||
Q_ASSERT(uri == QLatin1String("org.kde.plasma.private.awesomewidget"));
|
||||
|
||||
qmlRegisterSingletonType<AWActions>(uri, 1, 0, "AWActions", awactions_singletontype_provider);
|
||||
qmlRegisterSingletonType<AWKeys>(uri, 1, 0, "AWKeys", awkeys_singletontype_provider);
|
||||
}
|
@ -1,121 +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 AWKEYS_H
|
||||
#define AWKEYS_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QListWidget>
|
||||
#include <QMap>
|
||||
#include <QObject>
|
||||
#include <QStringList>
|
||||
#include <QPushButton>
|
||||
#include <QVariant>
|
||||
|
||||
|
||||
class AWToolTip;
|
||||
class ExtScript;
|
||||
class ExtUpgrade;
|
||||
class GraphicalItem;
|
||||
|
||||
class AWKeys : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
enum RequestedItem {
|
||||
Nothing,
|
||||
RequestedGraphicalItem,
|
||||
RequestedExtScript,
|
||||
RequestedExtUpgrade
|
||||
};
|
||||
|
||||
public:
|
||||
AWKeys(QObject *parent = 0);
|
||||
~AWKeys();
|
||||
|
||||
Q_INVOKABLE void initKeys(const QString pattern,
|
||||
const QMap<QString, QVariant> tooltipParams,
|
||||
const bool popup = false);
|
||||
Q_INVOKABLE bool isDebugEnabled();
|
||||
Q_INVOKABLE QString parsePattern(const QString pattern);
|
||||
Q_INVOKABLE QString toolTipImage();
|
||||
Q_INVOKABLE QSize toolTipSize();
|
||||
// keys
|
||||
Q_INVOKABLE bool addDevice(const QString source);
|
||||
Q_INVOKABLE QStringList dictKeys();
|
||||
Q_INVOKABLE QStringList getDiskDevices();
|
||||
Q_INVOKABLE QStringList getFanDevices();
|
||||
Q_INVOKABLE QStringList getHddDevices(const bool needAbstract = false);
|
||||
Q_INVOKABLE QStringList getMountDevices();
|
||||
Q_INVOKABLE QStringList getNetworkDevices();
|
||||
Q_INVOKABLE QStringList getTempDevices();
|
||||
Q_INVOKABLE bool setDataBySource(const QString sourceName,
|
||||
const QMap<QString, QVariant> data,
|
||||
const QMap<QString, QVariant> params);
|
||||
// values
|
||||
Q_INVOKABLE void graphicalValueByKey();
|
||||
Q_INVOKABLE QString infoByKey(QString key);
|
||||
Q_INVOKABLE QString valueByKey(QString key);
|
||||
// configuration
|
||||
Q_INVOKABLE void editItem(const QString type);
|
||||
|
||||
private slots:
|
||||
void editItemButtonPressed(QAbstractButton *button);
|
||||
void copyBar(const QString original);
|
||||
void copyScript(const QString original);
|
||||
void copyUpgrade(const QString original);
|
||||
|
||||
private:
|
||||
// methods
|
||||
bool checkKeys(const QMap<QString, QVariant> data);
|
||||
QString networkDevice();
|
||||
int numberCpus();
|
||||
float temperature(const float temp, const QString units = QString("Celsius"));
|
||||
// find methods
|
||||
QStringList findGraphicalItems(const QString pattern);
|
||||
QStringList findKeys(const QString pattern);
|
||||
// get methods
|
||||
QList<ExtScript *> getExtScripts();
|
||||
QList<ExtUpgrade *> getExtUpgrade();
|
||||
QList<GraphicalItem *> getGraphicalItems();
|
||||
GraphicalItem *getItemByTag(const QString tag);
|
||||
QStringList getTimeKeys();
|
||||
AWToolTip *toolTip = nullptr;
|
||||
// graphical elements
|
||||
QDialog *dialog = nullptr;
|
||||
QListWidget *widgetDialog = nullptr;
|
||||
QDialogButtonBox *dialogButtons = nullptr;
|
||||
QPushButton *copyButton = nullptr;
|
||||
QPushButton *createButton = nullptr;
|
||||
QPushButton *deleteButton = nullptr;
|
||||
RequestedItem requestedItem = Nothing;
|
||||
// variables
|
||||
bool debug = false;
|
||||
bool enablePopup = false;
|
||||
bool ready = false;
|
||||
QList<GraphicalItem *> graphicalItems;
|
||||
QList<ExtScript *> extScripts;
|
||||
QList<ExtUpgrade *> extUpgrade;
|
||||
QStringList foundBars, foundKeys, keys;
|
||||
QMap<QString, QString> values;
|
||||
QStringList diskDevices, fanDevices, mountDevices, tempDevices;
|
||||
};
|
||||
|
||||
|
||||
#endif /* AWKEYS_H */
|
@ -1,12 +0,0 @@
|
||||
[Desktop Entry]
|
||||
Encoding=UTF-8
|
||||
Name=bar3
|
||||
Comment=Simple bat bar
|
||||
X-AW-Value=bat
|
||||
X-AW-ActiveColor="0,0,0,255"
|
||||
X-AW-InactiveColor="255,255,255,255"
|
||||
X-AW-Type=Horizontal
|
||||
X-AW-Direction=LeftToRight
|
||||
X-AW-Height=25
|
||||
X-AW-Width=100
|
||||
X-AW-ApiVersion=1
|
@ -1,25 +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
|
||||
# API version
|
||||
X-AW-ApiVersion=1
|
@ -1,115 +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
|
||||
Q_PROPERTY(int apiVersion READ apiVersion WRITE setApiVersion)
|
||||
Q_PROPERTY(QString name READ name WRITE setName)
|
||||
Q_PROPERTY(QString comment READ comment WRITE setComment)
|
||||
Q_PROPERTY(QString bar READ bar WRITE setBar)
|
||||
Q_PROPERTY(QString activeColor READ activeColor WRITE setActiveColor)
|
||||
Q_PROPERTY(QString inactiveColor READ inactiveColor WRITE setInactiveColor)
|
||||
Q_PROPERTY(Type type READ type WRITE setType)
|
||||
Q_PROPERTY(Direction direction READ direction WRITE setDirection)
|
||||
Q_PROPERTY(int height READ height WRITE setHeight)
|
||||
Q_PROPERTY(int width READ width WRITE setWidth)
|
||||
|
||||
public:
|
||||
enum Direction {
|
||||
LeftToRight = 0,
|
||||
RightToLeft
|
||||
};
|
||||
enum Type {
|
||||
Horizontal = 0,
|
||||
Vertical,
|
||||
Circle
|
||||
};
|
||||
|
||||
explicit GraphicalItem(QWidget *parent = 0, const QString desktopName = QString(),
|
||||
const QStringList directories = QStringList(), const bool debugCmd = false);
|
||||
~GraphicalItem();
|
||||
QString fileName();
|
||||
QString image(const float value);
|
||||
// get methods
|
||||
int apiVersion();
|
||||
QString name();
|
||||
QString comment();
|
||||
QString bar();
|
||||
QString activeColor();
|
||||
QString inactiveColor();
|
||||
Type type();
|
||||
QString strType();
|
||||
Direction direction();
|
||||
QString strDirection();
|
||||
int height();
|
||||
int width();
|
||||
// set methods
|
||||
void setApiVersion(const int _apiVersion = 0);
|
||||
void setName(const QString _name = QString("none"));
|
||||
void setComment(const QString _comment = QString("empty"));
|
||||
void setBar(const QString _bar = QString("cpu"));
|
||||
void setActiveColor(const QString _color = QString("0,0,0,130"));
|
||||
void setInactiveColor(const QString _color = QString("255,255,255,130"));
|
||||
void setType(const Type _type = Horizontal);
|
||||
void setStrType(const QString _type = QString("Horizontal"));
|
||||
void setDirection(const Direction _direction = LeftToRight);
|
||||
void setStrDirection(const QString _direction = QString("LeftToRight"));
|
||||
void setHeight(const int _height = 100);
|
||||
void setWidth(const int _width = 100);
|
||||
|
||||
public slots:
|
||||
void readConfiguration();
|
||||
int showConfiguration(const QStringList tags = QStringList());
|
||||
int tryDelete();
|
||||
void writeConfiguration();
|
||||
|
||||
private slots:
|
||||
void changeColor();
|
||||
|
||||
private:
|
||||
QColor stringToColor(const QString _color);
|
||||
QString m_fileName;
|
||||
QStringList m_dirs;
|
||||
bool debug;
|
||||
Ui::GraphicalItem *ui;
|
||||
// properties
|
||||
int m_apiVersion = 0;
|
||||
QString m_name = QString("none");
|
||||
QString m_comment = QString("empty");
|
||||
QString m_bar = QString("cpu");
|
||||
QString m_activeColor = QString("0,0,0,130");
|
||||
QString m_inactiveColor = QString("255,255,255,130");
|
||||
Type m_type = Horizontal;
|
||||
Direction m_direction = LeftToRight;
|
||||
int m_height = 100;
|
||||
int m_width = 100;
|
||||
};
|
||||
|
||||
|
||||
#endif /* GRAPHICALITEM_H */
|
7
sources/awesome-widget/CMakeLists.txt
Normal file
@ -0,0 +1,7 @@
|
||||
set(SUBPROJECT plasma_applet_awesome-widget)
|
||||
message(STATUS "Subproject ${SUBPROJECT}")
|
||||
|
||||
configure_file(metadata.desktop ${CMAKE_CURRENT_SOURCE_DIR}/package/metadata.desktop)
|
||||
|
||||
add_subdirectory(plugin)
|
||||
plasma_install_package(package org.kde.plasma.awesomewidget)
|
@ -14,9 +14,18 @@
|
||||
|
||||
<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>
|
@ -24,17 +24,21 @@ 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: AWKeys.isDebugEnabled()
|
||||
property bool debug: awActions.isDebugEnabled()
|
||||
|
||||
|
||||
Column {
|
||||
id: pageColumn
|
||||
width: units.gridUnit * 25
|
||||
anchors.fill: parent
|
||||
QtControls.TabView {
|
||||
height: parent.height
|
||||
width: parent.width
|
||||
@ -45,28 +49,37 @@ Item {
|
||||
QtControls.Label {
|
||||
QtLayouts.Layout.fillWidth: true
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
text: AWActions.getAboutText("header")
|
||||
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")
|
||||
text: awActions.getAboutText("description")
|
||||
}
|
||||
|
||||
QtControls.Label {
|
||||
QtLayouts.Layout.fillWidth: true
|
||||
horizontalAlignment: Text.AlignLeft
|
||||
textFormat: Text.RichText
|
||||
text: AWActions.getAboutText("links")
|
||||
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")
|
||||
text: awActions.getAboutText("copy")
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -79,14 +92,17 @@ Item {
|
||||
QtLayouts.Layout.fillWidth: true
|
||||
wrapMode: Text.WordWrap
|
||||
horizontalAlignment: Text.AlignJustify
|
||||
text: AWActions.getAboutText("translators")
|
||||
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")
|
||||
text: awActions.getAboutText("3rdparty")
|
||||
onLinkActivated: Qt.openUrlExternally(link);
|
||||
}
|
||||
}
|
||||
}
|
@ -17,48 +17,28 @@
|
||||
|
||||
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: advancedPage
|
||||
// backend
|
||||
AWActions {
|
||||
id: awActions;
|
||||
}
|
||||
|
||||
width: childrenRect.width
|
||||
height: childrenRect.height
|
||||
implicitWidth: pageColumn.implicitWidth
|
||||
implicitHeight: pageColumn.implicitHeight
|
||||
|
||||
property bool debug: AWKeys.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 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
|
||||
@ -69,7 +49,47 @@ Item {
|
||||
|
||||
Column {
|
||||
id: pageColumn
|
||||
width: units.gridUnit * 25
|
||||
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
|
||||
@ -84,6 +104,20 @@ Item {
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
@ -227,64 +261,17 @@ Item {
|
||||
QtControls.Label {
|
||||
height: parent.height
|
||||
width: parent.width * 2 / 5
|
||||
horizontalAlignment: Text.AlignRight
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
text: i18n("Bars")
|
||||
}
|
||||
QtControls.Button {
|
||||
id: selectFont
|
||||
width: parent.width * 3 / 5
|
||||
text: i18n("Edit bars")
|
||||
onClicked: AWKeys.editItem("graphicalitem")
|
||||
text: i18n("Drop key cache")
|
||||
onClicked: awActions.dropCache()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 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.log("[advanced::onNewData] : Update source " + sourceName)
|
||||
|
||||
AWKeys.setDataBySource(sourceName, data, settings)
|
||||
}
|
||||
}
|
||||
|
||||
PlasmaCore.DataSource {
|
||||
id: extsysmonDE
|
||||
engine: "extsysmon"
|
||||
connectedSources: ["battery", "custom", "desktop", "netdev", "gpu",
|
||||
"gputemp", "hddtemp", "pkg", "player", "ps", "update"]
|
||||
interval: 5000
|
||||
|
||||
onNewData: {
|
||||
if (debug) console.log("[advanced::onNewData] : Update source " + sourceName)
|
||||
|
||||
AWKeys.setDataBySource(sourceName, data, settings)
|
||||
}
|
||||
}
|
||||
|
||||
PlasmaCore.DataSource {
|
||||
id: timeDE
|
||||
engine: "time"
|
||||
connectedSources: ["Local"]
|
||||
interval: 5000
|
||||
|
||||
onNewData: {
|
||||
if (debug) console.log("[advanced::onNewData] : Update source " + sourceName)
|
||||
|
||||
AWKeys.setDataBySource(sourceName, data, settings)
|
||||
}
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
if (debug) console.log("[advanced::onCompleted]")
|
||||
|
||||
// init submodule
|
||||
AWKeys.initKeys(plasmoid.configuration.text, tooltipSettings)
|
||||
}
|
||||
}
|
@ -25,12 +25,17 @@ 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: AWKeys.isDebugEnabled()
|
||||
property bool debug: awActions.isDebugEnabled()
|
||||
property variant weight: {
|
||||
25: 0,
|
||||
50: 1,
|
||||
@ -49,7 +54,7 @@ Item {
|
||||
|
||||
Column {
|
||||
id: pageColumn
|
||||
width: units.gridUnit * 25
|
||||
anchors.fill: parent
|
||||
Row {
|
||||
height: implicitHeight
|
||||
width: parent.width
|
||||
@ -84,7 +89,10 @@ Item {
|
||||
id: selectFont
|
||||
width: parent.width * 2 / 3
|
||||
text: plasmoid.configuration.fontFamily
|
||||
onClicked: fontDialog.visible = true
|
||||
onClicked: {
|
||||
fontDialog.setFont()
|
||||
fontDialog.visible = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -224,13 +232,22 @@ Item {
|
||||
QtDialogs.FontDialog {
|
||||
id: fontDialog
|
||||
title: i18n("Select a font")
|
||||
font: Qt.font({ family: selectFont.text, pointSize: fontSize.value, weight: Font.Normal })
|
||||
signal setFont
|
||||
|
||||
onAccepted: {
|
||||
selectFont.text = fontDialog.font.family
|
||||
fontSize.value = fontDialog.font.pointSize
|
||||
fontStyle.currentIndex = fontDialog.font.italic ? 1 : 0
|
||||
fontWeight.currentIndex = weight[fontDialog.font.weight]
|
||||
}
|
||||
onSetFont: {
|
||||
fontDialog.font = Qt.font({
|
||||
family: selectFont.text,
|
||||
pointSize: fontSize.value > 0 ? fontSize.value : 12,
|
||||
italic: fontStyle.currentIndex == 1,
|
||||
weight: Font.Normal,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
@ -26,12 +26,20 @@ 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: AWKeys.isDebugEnabled()
|
||||
property bool debug: awActions.isDebugEnabled()
|
||||
property variant tooltipSettings: {
|
||||
"tooltipNumber": plasmoid.configuration.tooltipNumber,
|
||||
"useTooltipBackground": plasmoid.configuration.useTooltipBackground,
|
||||
@ -53,11 +61,11 @@ Item {
|
||||
"batInTooltipColor": plasmoid.configuration.batInTooltipColor
|
||||
}
|
||||
|
||||
property variant cfg_dataengine: AWActions.readDataEngineConfiguration()
|
||||
property variant cfg_dataengine: awActions.readDataEngineConfiguration()
|
||||
|
||||
Column {
|
||||
id: pageColumn
|
||||
width: units.gridUnit * 25
|
||||
anchors.fill: parent
|
||||
Row {
|
||||
height: implicitHeight
|
||||
width: parent.width
|
||||
@ -87,7 +95,7 @@ Item {
|
||||
QtControls.Button {
|
||||
width: parent.width * 3 / 5
|
||||
text: i18n("Edit scripts")
|
||||
onClicked: AWKeys.editItem("extscript")
|
||||
onClicked: awKeys.editItem("extscript")
|
||||
}
|
||||
}
|
||||
|
||||
@ -105,11 +113,10 @@ Item {
|
||||
id: gpuDev
|
||||
width: parent.width * 3 / 5
|
||||
model: ["auto", "disable", "ati", "nvidia"]
|
||||
onCurrentIndexChanged: cfg_dataengine["GPUDEV"] = gpuDev.currentText
|
||||
Component.onCompleted: {
|
||||
for (var i=0; i<model.length; i++) {
|
||||
if (model[i] == cfg_dataengine["GPUDEV"]) {
|
||||
gpuDev.currentIndex = i;
|
||||
currentIndex = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -129,8 +136,7 @@ Item {
|
||||
QtControls.ComboBox {
|
||||
id: hdd
|
||||
width: parent.width * 3 / 5
|
||||
model: AWKeys.getHddDevices(true)
|
||||
onCurrentIndexChanged: cfg_dataengine["HDDDEV"] = hdd.currentText
|
||||
model: awKeys.getHddDevices(true)
|
||||
Component.onCompleted: {
|
||||
for (var i=0; i<model.length; i++) {
|
||||
if (model[i] == cfg_dataengine["HDDDEV"]) {
|
||||
@ -225,8 +231,7 @@ Item {
|
||||
QtControls.ComboBox {
|
||||
id: player
|
||||
width: parent.width * 3 / 5
|
||||
model: ["mpris", "mpd"]
|
||||
onCurrentIndexChanged: cfg_dataengine["PLAYER"] = model[currentIndex]
|
||||
model: ["disable", "mpris", "mpd"]
|
||||
Component.onCompleted: {
|
||||
for (var i=0; i<model.length; i++) {
|
||||
if (model[i] == cfg_dataengine["PLAYER"]) {
|
||||
@ -237,6 +242,23 @@ Item {
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
@ -250,7 +272,24 @@ Item {
|
||||
QtControls.Button {
|
||||
width: parent.width * 3 / 5
|
||||
text: i18n("Edit command")
|
||||
onClicked: AWKeys.editItem("extupgrade")
|
||||
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")
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -259,13 +298,16 @@ Item {
|
||||
if (debug) console.log("[dataengine::onCompleted]")
|
||||
|
||||
// init submodule
|
||||
AWKeys.initKeys(plasmoid.configuration.text, tooltipSettings)
|
||||
awKeys.initKeys(plasmoid.configuration.text)
|
||||
}
|
||||
|
||||
Component.onDestruction: {
|
||||
if (debug) console.log("[dataengine::onDestruction]")
|
||||
|
||||
cfg_dataengine["GPUDEV"] = gpuDev.currentText
|
||||
cfg_dataengine["HDDDEV"] = hdd.currentText
|
||||
cfg_dataengine["PLAYER"] = player.currentText
|
||||
cfg_dataengine["MPRIS"] = mpris.currentText
|
||||
AWActions.writeDataEngineConfiguration(cfg_dataengine)
|
||||
awActions.writeDataEngineConfiguration(cfg_dataengine)
|
||||
}
|
||||
}
|
@ -28,8 +28,15 @@ import "."
|
||||
|
||||
Item {
|
||||
id: main
|
||||
// backend
|
||||
AWKeys {
|
||||
id: awKeys;
|
||||
}
|
||||
AWActions {
|
||||
id: awActions;
|
||||
}
|
||||
|
||||
property bool debug: AWKeys.isDebugEnabled()
|
||||
property bool debug: awActions.isDebugEnabled()
|
||||
property variant settings: {
|
||||
"customTime": plasmoid.configuration.customTime,
|
||||
"customUptime": plasmoid.configuration.customUptime,
|
||||
@ -55,10 +62,15 @@ Item {
|
||||
"downTooltipColor": plasmoid.configuration.downTooltipColor,
|
||||
"upTooltipColor": plasmoid.configuration.upTooltipColor,
|
||||
"batTooltipColor": plasmoid.configuration.batTooltipColor,
|
||||
"batInTooltipColor": plasmoid.configuration.batInTooltipColor
|
||||
"batInTooltipColor": plasmoid.configuration.batInTooltipColor,
|
||||
// additinal field to parse AC status
|
||||
"acOnline": plasmoid.configuration.acOnline
|
||||
}
|
||||
|
||||
signal needUpdate
|
||||
signal dropSource(string sourceName)
|
||||
signal needTextUpdate(string newText)
|
||||
signal needToolTipUpdate(string newText)
|
||||
signal sizeUpdate
|
||||
|
||||
|
||||
// init
|
||||
@ -67,8 +79,7 @@ Item {
|
||||
|
||||
Layout.fillWidth: plasmoid.formFactor != PlasmaCore.Planar
|
||||
Layout.fillHeight: plasmoid.formFactor != PlasmaCore.Planar
|
||||
Layout.minimumHeight: text.contentHeight
|
||||
Layout.minimumWidth: text.contentWidth
|
||||
Layout.alignment: Qt.AlignVCenter | Qt.AlignHCenter
|
||||
|
||||
Plasmoid.icon: "utilities-system-monitor"
|
||||
Plasmoid.backgroundHints: plasmoid.configuration.background ? "DefaultBackground" : "NoBackground"
|
||||
@ -82,28 +93,29 @@ Item {
|
||||
|
||||
onNewData: {
|
||||
if (debug) console.log("[main::onNewData] : Update source " + sourceName)
|
||||
systemmonitorDE.interval = plasmoid.configuration.interval
|
||||
|
||||
if (AWKeys.setDataBySource(sourceName, data, settings)) disconnectSource(sourceName)
|
||||
awKeys.setDataBySource(sourceName, data, settings)
|
||||
}
|
||||
|
||||
onSourceAdded: {
|
||||
if (debug) console.log("[main::onSourceAdded] : Source " + source)
|
||||
|
||||
AWKeys.addDevice(source)
|
||||
awKeys.addDevice(source)
|
||||
}
|
||||
}
|
||||
|
||||
PlasmaCore.DataSource {
|
||||
id: extsysmonDE
|
||||
engine: "extsysmon"
|
||||
connectedSources: ["battery", "custom", "desktop", "netdev", "gpu",
|
||||
"gputemp", "hddtemp", "pkg", "player", "ps", "update"]
|
||||
connectedSources: extsysmonDE.sources
|
||||
interval: plasmoid.configuration.interval
|
||||
|
||||
onNewData: {
|
||||
if (debug) console.log("[main::onNewData] : Update source " + sourceName)
|
||||
extsysmonDE.interval = plasmoid.configuration.interval
|
||||
|
||||
if (AWKeys.setDataBySource(sourceName, data, settings)) needUpdate()
|
||||
awKeys.setDataBySource(sourceName, data, settings)
|
||||
}
|
||||
}
|
||||
|
||||
@ -116,42 +128,38 @@ Item {
|
||||
onNewData: {
|
||||
if (debug) console.log("[main::onNewData] : Update source " + sourceName)
|
||||
|
||||
AWKeys.setDataBySource(sourceName, data, settings)
|
||||
awKeys.setDataBySource(sourceName, data, settings)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ui
|
||||
Grid {
|
||||
columns: 1
|
||||
Text {
|
||||
id: text
|
||||
anchors.fill: parent
|
||||
renderType: Text.NativeRendering
|
||||
textFormat: Text.RichText
|
||||
wrapMode: Text.NoWrap
|
||||
|
||||
Text {
|
||||
id: text
|
||||
height: contentHeight
|
||||
width: contentWidth
|
||||
textFormat: Text.RichText
|
||||
wrapMode: Text.NoWrap
|
||||
horizontalAlignment: general.align[plasmoid.configuration.textAlign]
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
|
||||
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]
|
||||
|
||||
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]
|
||||
text: plasmoid.configuration.text
|
||||
|
||||
text: plasmoid.configuration.text
|
||||
|
||||
PlasmaCore.ToolTipArea {
|
||||
height: tooltip.height
|
||||
width: tooltip.width
|
||||
mainItem: Text {
|
||||
id: tooltip
|
||||
height: contentHeight
|
||||
width: contentWidth
|
||||
textFormat: Text.RichText
|
||||
}
|
||||
PlasmaCore.ToolTipArea {
|
||||
height: tooltip.height
|
||||
width: tooltip.width
|
||||
mainItem: Text {
|
||||
id: tooltip
|
||||
height: contentHeight
|
||||
width: contentWidth
|
||||
textFormat: Text.RichText
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -165,44 +173,86 @@ Item {
|
||||
plasmoid.setAction("checkUpdates", i18n("Check updates"), "system-software-update")
|
||||
// plasmoid.setAction("report", i18n("Mail to developers"), "email")
|
||||
// init submodule
|
||||
Plasmoid.userConfiguringChanged(true)
|
||||
Plasmoid.userConfiguringChanged(false)
|
||||
// connect data
|
||||
awKeys.dropSourceFromDataengine.connect(dropSource)
|
||||
awKeys.needTextToBeUpdated.connect(needTextUpdate)
|
||||
awKeys.needToolTipToBeUpdated.connect(needToolTipUpdate)
|
||||
}
|
||||
|
||||
onNeedUpdate: {
|
||||
if (debug) console.log("[main::onNeedUpdate]")
|
||||
onDropSource: {
|
||||
if (debug) console.log("[main::onDropSource]")
|
||||
if (debug) console.log("[main::onDropSource] : Source " + sourceName)
|
||||
|
||||
text.text = AWKeys.parsePattern(plasmoid.configuration.text)
|
||||
tooltip.text = AWKeys.toolTipImage()
|
||||
systemmonitorDE.disconnectSource(sourceName)
|
||||
}
|
||||
|
||||
onNeedTextUpdate: {
|
||||
if (debug) console.log("[main::onNeedTextUpdate]")
|
||||
|
||||
text.text = newText
|
||||
sizeUpdate()
|
||||
}
|
||||
|
||||
onNeedToolTipUpdate: {
|
||||
if (debug) console.log("[main::onNeedToolTipUpdate]")
|
||||
|
||||
tooltip.text = newText
|
||||
}
|
||||
|
||||
onSizeUpdate: {
|
||||
if (debug) console.log("[main::onSizeUpdate]")
|
||||
|
||||
if (plasmoid.configuration.height == 0) {
|
||||
Layout.minimumHeight = text.contentHeight
|
||||
Layout.maximumHeight = -1
|
||||
} else {
|
||||
Layout.minimumHeight = plasmoid.configuration.height
|
||||
Layout.maximumHeight = plasmoid.configuration.height
|
||||
}
|
||||
if (plasmoid.configuration.width == 0) {
|
||||
Layout.minimumWidth = text.contentWidth
|
||||
Layout.maximumWidth = -1
|
||||
} else {
|
||||
Layout.minimumWidth = plasmoid.configuration.width
|
||||
Layout.maximumWidth = plasmoid.configuration.width
|
||||
}
|
||||
}
|
||||
|
||||
Plasmoid.onUserConfiguringChanged: {
|
||||
if (plasmoid.userConfiguring) return
|
||||
if (debug) console.log("[main::onUserConfiguringChanged]")
|
||||
|
||||
// init submodule
|
||||
AWKeys.initKeys(plasmoid.configuration.text, tooltipSettings, plasmoid.configuration.notify)
|
||||
awKeys.initKeys(plasmoid.configuration.text)
|
||||
awKeys.initTooltip(tooltipSettings)
|
||||
awKeys.setPopupEnabled(plasmoid.configuration.notify)
|
||||
awKeys.setWrapNewLines(plasmoid.configuration.wrapNewLines)
|
||||
|
||||
needTextUpdate(plasmoid.configuration.text)
|
||||
}
|
||||
|
||||
function action_checkUpdates() {
|
||||
if (debug) console.log("[main::action_checkUpdates]")
|
||||
|
||||
AWActions.checkUpdates()
|
||||
awActions.checkUpdates()
|
||||
}
|
||||
|
||||
function action_showReadme() {
|
||||
if (debug) console.log("[main::action_showReadme]")
|
||||
|
||||
AWActions.showReadme()
|
||||
awActions.showReadme()
|
||||
}
|
||||
|
||||
function action_report() {
|
||||
if (debug) console.log("[main::action_report]")
|
||||
|
||||
AWActions.sendEmail()
|
||||
awActions.sendEmail()
|
||||
}
|
||||
|
||||
function action_requestKey() {
|
||||
if (debug) console.log("[main::action_requestKey]")
|
||||
|
||||
AWKeys.graphicalValueByKey()
|
||||
awKeys.graphicalValueByKey()
|
||||
}
|
||||
}
|
@ -25,12 +25,17 @@ 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: AWKeys.isDebugEnabled()
|
||||
property bool debug: awActions.isDebugEnabled()
|
||||
|
||||
property alias cfg_tooltipNumber: tooltipNumber.value
|
||||
property alias cfg_useTooltipBackground: useTooltipBackground.checked
|
||||
@ -53,7 +58,7 @@ Item {
|
||||
|
||||
Column {
|
||||
id: pageColumn
|
||||
width: units.gridUnit * 25
|
||||
anchors.fill: parent
|
||||
QtControls.Label {
|
||||
width: parent.width
|
||||
horizontalAlignment: Text.AlignHCenter
|
@ -24,12 +24,20 @@ 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: AWKeys.isDebugEnabled()
|
||||
property bool debug: awActions.isDebugEnabled()
|
||||
property variant settings: {
|
||||
"customTime": plasmoid.configuration.customTime,
|
||||
"customUptime": plasmoid.configuration.customUptime,
|
||||
@ -63,19 +71,21 @@ Item {
|
||||
|
||||
Column {
|
||||
id: pageColumn
|
||||
width: units.gridUnit * 25
|
||||
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"
|
||||
|
||||
@ -87,7 +97,7 @@ Item {
|
||||
"family": plasmoid.configuration.fontFamily,
|
||||
"size": plasmoid.configuration.fontSize
|
||||
}
|
||||
var font = AWActions.getFont(defaultFont)
|
||||
var font = awActions.getFont(defaultFont)
|
||||
var pos = textPattern.cursorPosition
|
||||
var selected = textPattern.selectedText
|
||||
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
||||
@ -98,6 +108,7 @@ Item {
|
||||
}
|
||||
}
|
||||
QtControls.Button {
|
||||
width: parent.width / 12
|
||||
iconName: "format-indent-more"
|
||||
|
||||
onClicked: {
|
||||
@ -111,6 +122,7 @@ Item {
|
||||
}
|
||||
|
||||
QtControls.Button {
|
||||
width: parent.width / 12
|
||||
iconName: "format-text-bold"
|
||||
|
||||
onClicked: {
|
||||
@ -123,6 +135,7 @@ Item {
|
||||
}
|
||||
}
|
||||
QtControls.Button {
|
||||
width: parent.width / 12
|
||||
iconName: "format-text-italic"
|
||||
|
||||
onClicked: {
|
||||
@ -135,6 +148,7 @@ Item {
|
||||
}
|
||||
}
|
||||
QtControls.Button {
|
||||
width: parent.width / 12
|
||||
iconName: "format-text-underline"
|
||||
|
||||
onClicked: {
|
||||
@ -147,6 +161,7 @@ Item {
|
||||
}
|
||||
}
|
||||
QtControls.Button {
|
||||
width: parent.width / 12
|
||||
iconName: "format-text-strikethrough"
|
||||
|
||||
onClicked: {
|
||||
@ -160,6 +175,7 @@ Item {
|
||||
}
|
||||
|
||||
QtControls.Button {
|
||||
width: parent.width / 12
|
||||
iconName: "format-justify-left"
|
||||
|
||||
onClicked: {
|
||||
@ -168,10 +184,11 @@ Item {
|
||||
var pos = textPattern.cursorPosition
|
||||
var selected = textPattern.selectedText
|
||||
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
||||
textPattern.insert(pos, "<p align=\"left\">" + selected + "</p")
|
||||
textPattern.insert(pos, "<p align=\"left\">" + selected + "</p>")
|
||||
}
|
||||
}
|
||||
QtControls.Button {
|
||||
width: parent.width / 12
|
||||
iconName: "format-justify-center"
|
||||
|
||||
onClicked: {
|
||||
@ -180,10 +197,11 @@ Item {
|
||||
var pos = textPattern.cursorPosition
|
||||
var selected = textPattern.selectedText
|
||||
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
||||
textPattern.insert(pos, "<p align=\"center\">" + selected + "</p")
|
||||
textPattern.insert(pos, "<p align=\"center\">" + selected + "</p>")
|
||||
}
|
||||
}
|
||||
QtControls.Button {
|
||||
width: parent.width / 12
|
||||
iconName: "format-justify-right"
|
||||
|
||||
onClicked: {
|
||||
@ -192,10 +210,11 @@ Item {
|
||||
var pos = textPattern.cursorPosition
|
||||
var selected = textPattern.selectedText
|
||||
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
||||
textPattern.insert(pos, "<p align=\"right\">" + selected + "</p")
|
||||
textPattern.insert(pos, "<p align=\"right\">" + selected + "</p>")
|
||||
}
|
||||
}
|
||||
QtControls.Button {
|
||||
width: parent.width / 12
|
||||
iconName: "format-justify-fill"
|
||||
|
||||
onClicked: {
|
||||
@ -204,7 +223,7 @@ Item {
|
||||
var pos = textPattern.cursorPosition
|
||||
var selected = textPattern.selectedText
|
||||
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
||||
textPattern.insert(pos, "<p align=\"justify\">" + selected + "</p")
|
||||
textPattern.insert(pos, "<p align=\"justify\">" + selected + "</p>")
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -238,17 +257,28 @@ Item {
|
||||
|
||||
var message = i18n("Tag: %1", tags.currentText)
|
||||
message += "<br>"
|
||||
message += i18n("Value: %1", AWKeys.valueByKey(tags.currentText))
|
||||
message += i18n("Value: %1", awKeys.valueByKey(tags.currentText))
|
||||
message += "<br>"
|
||||
message += i18n("Info: %1", AWKeys.infoByKey(tags.currentText))
|
||||
AWActions.sendNotification("tag", message)
|
||||
message += i18n("Info: %1", awKeys.infoByKey(tags.currentText))
|
||||
awActions.sendNotification("tag", message)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
@ -265,21 +295,20 @@ Item {
|
||||
onNewData: {
|
||||
if (debug) console.log("[widget::onNewData] : Update source " + sourceName)
|
||||
|
||||
AWKeys.setDataBySource(sourceName, data, settings)
|
||||
awKeys.setDataBySource(sourceName, data, settings)
|
||||
}
|
||||
}
|
||||
|
||||
PlasmaCore.DataSource {
|
||||
id: extsysmonDE
|
||||
engine: "extsysmon"
|
||||
connectedSources: ["battery", "custom", "desktop", "netdev", "gpu",
|
||||
"gputemp", "hddtemp", "pkg", "player", "ps", "update"]
|
||||
connectedSources: extsysmonDE.sources
|
||||
interval: 5000
|
||||
|
||||
onNewData: {
|
||||
if (debug) console.log("[widget::onNewData] : Update source " + sourceName)
|
||||
|
||||
AWKeys.setDataBySource(sourceName, data, settings)
|
||||
awKeys.setDataBySource(sourceName, data, settings)
|
||||
}
|
||||
}
|
||||
|
||||
@ -292,7 +321,7 @@ Item {
|
||||
onNewData: {
|
||||
if (debug) console.log("[widget::onNewData] : Update source " + sourceName)
|
||||
|
||||
AWKeys.setDataBySource(sourceName, data, settings)
|
||||
awKeys.setDataBySource(sourceName, data, settings)
|
||||
}
|
||||
}
|
||||
|
||||
@ -300,7 +329,7 @@ Item {
|
||||
if (debug) console.log("[widget::onCompleted]")
|
||||
|
||||
// init submodule
|
||||
AWKeys.initKeys(plasmoid.configuration.text, tooltipSettings)
|
||||
tags.model = AWKeys.dictKeys()
|
||||
awKeys.initKeys(plasmoid.configuration.text)
|
||||
tags.model = awKeys.dictKeys(true)
|
||||
}
|
||||
}
|
@ -12,12 +12,15 @@ 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-Version=@PROJECT_VERSION@
|
||||
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=
|
25
sources/awesome-widget/plugin/CMakeLists.txt
Normal 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_RECURSE SUBPROJECT_SOURCE *.cpp ${PROJECT_TRDPARTY_DIR}/fontdialog/*.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})
|
@ -23,6 +23,8 @@
|
||||
#include <QDebug>
|
||||
#include <QDesktopServices>
|
||||
#include <QDir>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonParseError>
|
||||
#include <QMessageBox>
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QNetworkRequest>
|
||||
@ -67,7 +69,26 @@ void AWActions::checkUpdates()
|
||||
}
|
||||
|
||||
|
||||
void AWActions::runCmd(const QString cmd)
|
||||
bool AWActions::dropCache() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QString fileName = QString("%1/awesomewidgets.ndx")
|
||||
.arg(QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation));
|
||||
|
||||
return QFile(fileName).remove();
|
||||
}
|
||||
|
||||
|
||||
bool AWActions::isDebugEnabled() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return debug;
|
||||
}
|
||||
|
||||
|
||||
void AWActions::runCmd(const QString cmd) const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd" << cmd;
|
||||
@ -79,13 +100,13 @@ void AWActions::runCmd(const QString cmd)
|
||||
}
|
||||
|
||||
|
||||
void AWActions::sendEmail()
|
||||
void AWActions::sendEmail() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
}
|
||||
|
||||
|
||||
void AWActions::showReadme()
|
||||
void AWActions::showReadme() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
@ -93,7 +114,7 @@ void AWActions::showReadme()
|
||||
}
|
||||
|
||||
|
||||
QString AWActions::getAboutText(const QString type)
|
||||
QString AWActions::getAboutText(const QString type) const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Type" << type;
|
||||
@ -101,6 +122,8 @@ QString AWActions::getAboutText(const QString 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"))
|
||||
@ -120,9 +143,9 @@ QString AWActions::getAboutText(const QString type)
|
||||
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[i].split(QChar(','))[0])
|
||||
.arg(trdPartyList[i].split(QChar(','))[1])
|
||||
.arg(trdPartyList[i].split(QChar(','))[2]);
|
||||
.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(", ")));
|
||||
}
|
||||
|
||||
@ -130,11 +153,11 @@ QString AWActions::getAboutText(const QString type)
|
||||
}
|
||||
|
||||
|
||||
QMap<QString, QVariant> AWActions::getFont(const QMap<QString, QVariant> defaultFont)
|
||||
QVariantMap AWActions::getFont(const QVariantMap defaultFont) const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QMap<QString, QVariant> fontMap;
|
||||
QVariantMap fontMap;
|
||||
CFont defaultCFont = CFont(defaultFont[QString("family")].toString(),
|
||||
defaultFont[QString("size")].toInt(),
|
||||
400, false, defaultFont[QString("color")].toString());
|
||||
@ -148,20 +171,20 @@ QMap<QString, QVariant> AWActions::getFont(const QMap<QString, QVariant> default
|
||||
}
|
||||
|
||||
|
||||
QMap<QString, QVariant> AWActions::readDataEngineConfiguration()
|
||||
QVariantMap AWActions::readDataEngineConfiguration() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QString fileName = QStandardPaths::locate(QStandardPaths::ConfigLocation, QString("plasma-dataengine-extsysmon.conf"));
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Configuration file" << fileName;
|
||||
QSettings settings(fileName, QSettings::IniFormat);
|
||||
QMap<QString, QVariant> configuration;
|
||||
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 hddtemp"));
|
||||
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"));
|
||||
@ -172,7 +195,7 @@ QMap<QString, QVariant> AWActions::readDataEngineConfiguration()
|
||||
}
|
||||
|
||||
|
||||
void AWActions::writeDataEngineConfiguration(const QMap<QString, QVariant> configuration)
|
||||
void AWActions::writeDataEngineConfiguration(const QVariantMap configuration) const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
@ -195,16 +218,17 @@ void AWActions::writeDataEngineConfiguration(const QMap<QString, QVariant> confi
|
||||
}
|
||||
|
||||
|
||||
void AWActions::sendNotification(const QString eventId, const QString message, const bool enablePopup)
|
||||
void AWActions::sendNotification(const QString eventId, const QString message,
|
||||
const bool enablePopup)
|
||||
{
|
||||
if ((eventId == QString("event")) && (!enablePopup)) return;
|
||||
|
||||
KNotification *notification = KNotification::event(eventId, QString("Awesome Widget ::: ") + eventId, message);
|
||||
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)
|
||||
void AWActions::showUpdates(QString version) const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
@ -213,7 +237,8 @@ void AWActions::showUpdates(QString version)
|
||||
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);
|
||||
int select = QMessageBox::information(nullptr, i18n("There are updates"), text,
|
||||
QMessageBox::Ok | QMessageBox::Cancel);
|
||||
switch (select) {
|
||||
case QMessageBox::Ok:
|
||||
QDesktopServices::openUrl(QString(RELEASES) + version);
|
||||
@ -222,30 +247,32 @@ void AWActions::showUpdates(QString version)
|
||||
}
|
||||
|
||||
|
||||
void AWActions::versionReplyRecieved(QNetworkReply *reply)
|
||||
void AWActions::versionReplyRecieved(QNetworkReply *reply) const
|
||||
{
|
||||
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;
|
||||
QJsonParseError error;
|
||||
QJsonDocument jsonDoc = QJsonDocument::fromJson(reply->readAll(), &error);
|
||||
reply->deleteLater();
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Json parse error" << error.errorString();
|
||||
if ((reply->error() != QNetworkReply::NoError) ||
|
||||
(error.error != QJsonParseError::NoError)) {
|
||||
return;
|
||||
}
|
||||
|
||||
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();
|
||||
// convert to map
|
||||
QVariantMap firstRelease = jsonDoc.toVariant().toList().first().toMap();
|
||||
QString version = firstRelease[QString("tag_name")].toString();
|
||||
version.remove(QString("V."));
|
||||
|
||||
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)))
|
||||
showUpdates(version);
|
||||
return showUpdates(version);
|
||||
}
|
@ -19,7 +19,6 @@
|
||||
#ifndef AWACTIONS_H
|
||||
#define AWACTIONS_H
|
||||
|
||||
#include <QMap>
|
||||
#include <QObject>
|
||||
#include <QVariant>
|
||||
|
||||
@ -31,26 +30,29 @@ class AWActions : public QObject
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
AWActions(QObject *parent = 0);
|
||||
AWActions(QObject *parent = nullptr);
|
||||
~AWActions();
|
||||
|
||||
Q_INVOKABLE void checkUpdates();
|
||||
Q_INVOKABLE void runCmd(const QString cmd = QString("/usr/bin/true"));
|
||||
Q_INVOKABLE void sendEmail();
|
||||
Q_INVOKABLE void showReadme();
|
||||
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 = "header");
|
||||
Q_INVOKABLE QMap<QString, QVariant> getFont(const QMap<QString, QVariant> defaultFont);
|
||||
Q_INVOKABLE QString getAboutText(const QString type = QString("header")) const;
|
||||
Q_INVOKABLE QVariantMap getFont(const QVariantMap defaultFont) const;
|
||||
// dataengine
|
||||
Q_INVOKABLE QMap<QString, QVariant> readDataEngineConfiguration();
|
||||
Q_INVOKABLE void writeDataEngineConfiguration(const QMap<QString, QVariant> configuration);
|
||||
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);
|
||||
Q_INVOKABLE static void sendNotification(const QString eventId, const QString message,
|
||||
const bool enablePopup = false);
|
||||
|
||||
private slots:
|
||||
void showUpdates(QString version);
|
||||
void versionReplyRecieved(QNetworkReply *reply);
|
||||
void showUpdates(QString version) const;
|
||||
void versionReplyRecieved(QNetworkReply *reply) const;
|
||||
|
||||
private:
|
||||
// variables
|
@ -15,31 +15,18 @@
|
||||
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef CUSTOMLABEL_H
|
||||
#define CUSTOMLABEL_H
|
||||
#include "awesomewidget.h"
|
||||
|
||||
#include <QLabel>
|
||||
#include <QtQml>
|
||||
|
||||
#include "awactions.h"
|
||||
#include "awkeys.h"
|
||||
|
||||
|
||||
class AwesomeWidget;
|
||||
|
||||
class CustomLabel : public QLabel
|
||||
void AWPlugin::registerTypes(const char *uri)
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_ASSERT(uri == QLatin1String("org.kde.plasma.private.awesomewidget"));
|
||||
|
||||
public:
|
||||
CustomLabel(AwesomeWidget *wid, const bool debugCmd = false);
|
||||
~CustomLabel();
|
||||
void setPopupEnabled(const bool state);
|
||||
|
||||
protected:
|
||||
void mousePressEvent(QMouseEvent *event);
|
||||
|
||||
private:
|
||||
AwesomeWidget *widget;
|
||||
bool debug;
|
||||
bool enablePopup = true;
|
||||
};
|
||||
|
||||
|
||||
#endif /* CUSTOMLABEL_H */
|
||||
qmlRegisterType<AWActions>(uri, 1, 0, "AWActions");
|
||||
qmlRegisterType<AWKeys>(uri, 1, 0, "AWKeys");
|
||||
}
|
@ -22,8 +22,6 @@
|
||||
#include <QQmlExtensionPlugin>
|
||||
|
||||
|
||||
class QQmlEngine;
|
||||
|
||||
class AWPlugin : public QQmlExtensionPlugin
|
||||
{
|
||||
Q_OBJECT
|
974
sources/awesome-widget/plugin/awkeys.cpp
Normal file
@ -0,0 +1,974 @@
|
||||
/***************************************************************************
|
||||
* 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 <QDebug>
|
||||
#include <QDir>
|
||||
#include <QInputDialog>
|
||||
#include <QNetworkInterface>
|
||||
#include <QProcessEnvironment>
|
||||
#include <QRegExp>
|
||||
#include <QSettings>
|
||||
#include <QStandardPaths>
|
||||
#include <QThread>
|
||||
|
||||
#include <pdebug/pdebug.h>
|
||||
|
||||
#include "awactions.h"
|
||||
#include "awtooltip.h"
|
||||
#include "extquotes.h"
|
||||
#include "extscript.h"
|
||||
#include "extupgrade.h"
|
||||
#include "extweather.h"
|
||||
#include "graphicalitem.h"
|
||||
#include "version.h"
|
||||
|
||||
|
||||
AWKeys::AWKeys(QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
// debug
|
||||
QProcessEnvironment environment = QProcessEnvironment::systemEnvironment();
|
||||
QString debugEnv = environment.value(QString("DEBUG"), QString("no"));
|
||||
debug = (debugEnv == QString("yes"));
|
||||
|
||||
// backend
|
||||
graphicalItems = new ExtItemAggregator<GraphicalItem>(nullptr, QString("desktops"), debug);
|
||||
extQuotes = new ExtItemAggregator<ExtQuotes>(nullptr, QString("quotes"), debug);
|
||||
extScripts = new ExtItemAggregator<ExtScript>(nullptr, QString("scripts"), debug);
|
||||
extUpgrade = new ExtItemAggregator<ExtUpgrade>(nullptr, QString("upgrade"), debug);
|
||||
extWeather = new ExtItemAggregator<ExtWeather>(nullptr, QString("weather"), debug);
|
||||
connect(this, SIGNAL(needToBeUpdated()), this, SLOT(dataUpdate()));
|
||||
}
|
||||
|
||||
|
||||
AWKeys::~AWKeys()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
if (toolTip != nullptr) delete toolTip;
|
||||
|
||||
delete graphicalItems;
|
||||
delete extQuotes;
|
||||
delete extScripts;
|
||||
delete extUpgrade;
|
||||
delete extWeather;
|
||||
}
|
||||
|
||||
|
||||
void AWKeys::initKeys(const QString currentPattern)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
// clear
|
||||
keys.clear();
|
||||
foundBars.clear();
|
||||
foundKeys.clear();
|
||||
|
||||
// init
|
||||
pattern = currentPattern;
|
||||
// update network and hdd list
|
||||
addKeyToCache(QString("Hdd"));
|
||||
addKeyToCache(QString("Network"));
|
||||
loadKeysFromCache();
|
||||
reinitKeys();
|
||||
}
|
||||
|
||||
|
||||
void AWKeys::initTooltip(const QVariantMap tooltipParams)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
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)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
enablePopup = popup;
|
||||
}
|
||||
|
||||
|
||||
void AWKeys::setWrapNewLines(const bool wrap)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
wrapNewLines = wrap;
|
||||
}
|
||||
|
||||
|
||||
QString AWKeys::parsePattern() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (keys.isEmpty()) return pattern;
|
||||
|
||||
QString parsed = pattern;
|
||||
parsed.replace(QString("$$"), QString("$\\$\\"));
|
||||
foreach(QString key, foundKeys)
|
||||
parsed.replace(QString("$%1").arg(key), htmlValue(key));
|
||||
foreach(QString bar, foundBars)
|
||||
parsed.replace(QString("$%1").arg(bar), getItemByTag(bar)->image(valueByKey(bar).toFloat()));
|
||||
parsed.replace(QString("$\\$\\"), QString("$$"));
|
||||
// wrap new lines if required
|
||||
if (wrapNewLines) parsed.replace(QString("\n"), QString("<br>"));
|
||||
|
||||
return parsed;
|
||||
}
|
||||
|
||||
|
||||
QSize AWKeys::toolTipSize() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (toolTip == nullptr) return QSize();
|
||||
|
||||
return toolTip->getSize();
|
||||
}
|
||||
|
||||
|
||||
void AWKeys::addDevice(const QString source)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Source" << source;
|
||||
|
||||
QRegExp diskRegexp = QRegExp(QString("disk/(?:md|sd|hd)[a-z|0-9]_.*/Rate/(?:rblk)"));
|
||||
QRegExp mountRegexp = QRegExp(QString("partitions/.*/filllevel"));
|
||||
QRegExp tempRegexp = QRegExp(QString("lmsensors/.*"));
|
||||
|
||||
if (diskRegexp.indexIn(source) > -1) {
|
||||
QString device = source;
|
||||
device.remove(QString("/Rate/rblk"));
|
||||
addKeyToCache(QString("Disk"), device);
|
||||
} else if (mountRegexp.indexIn(source) > -1) {
|
||||
QString device = source;
|
||||
device.remove(QString("partitions")).remove(QString("/filllevel"));
|
||||
addKeyToCache(QString("Mount"), device);
|
||||
} else if (tempRegexp.indexIn(source) > -1) {
|
||||
addKeyToCache(QString("Temp"), source);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QStringList AWKeys::dictKeys(const bool sorted) const
|
||||
{
|
||||
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=numberCpus()-1; i>=0; i--)
|
||||
allKeys.append(QString("cpucl%1").arg(i));
|
||||
allKeys.append(QString("cpucl"));
|
||||
// cpu
|
||||
for (int i=numberCpus()-1; i>=0; i--)
|
||||
allKeys.append(QString("cpu%1").arg(i));
|
||||
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("down%1").arg(i));
|
||||
allKeys.append(QString("up%1").arg(i));
|
||||
}
|
||||
allKeys.append(QString("down"));
|
||||
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"));
|
||||
// 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"));
|
||||
// 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")));
|
||||
}
|
||||
// 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;
|
||||
}
|
||||
|
||||
|
||||
QStringList AWKeys::getHddDevices() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
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)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Source" << sourceName;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Data" << data;
|
||||
|
||||
if (sourceName == QString("update")) return emit(needToBeUpdated());
|
||||
|
||||
// checking
|
||||
if (keys.isEmpty()) return;
|
||||
|
||||
// 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 (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 ((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(netRecRegExp)) {
|
||||
// download speed
|
||||
QString device = sourceName;
|
||||
float value = data[QString("value")].toFloat();
|
||||
device.remove(QString("network/interfaces/")).remove(QString("/receiver/data"));
|
||||
QStringList allNetworkDevices = networkDevices;
|
||||
for (int i=0; i<allNetworkDevices.count(); i++) {
|
||||
if (allNetworkDevices.at(i) != device) continue;
|
||||
if (value > 1000.0)
|
||||
values[QString("down%1").arg(i)] = QString("%1").arg(value / 1024.0, 4, 'f', 1);
|
||||
else
|
||||
values[QString("down%1").arg(i)] = QString("%1").arg(value, 4, 'f', 0);
|
||||
break;
|
||||
}
|
||||
if (device == values[QString("netdev")]) {
|
||||
if (value > 1000.0)
|
||||
values[QString("down")] = QString("%1").arg(value / 1024.0, 4, 'f', 1);
|
||||
else
|
||||
values[QString("down")] = QString("%1").arg(value, 4, 'f', 0);
|
||||
}
|
||||
} else if (sourceName.contains(netTransRegExp)) {
|
||||
// upload speed
|
||||
QString device = sourceName;
|
||||
float value = data[QString("value")].toFloat();
|
||||
device.remove(QString("network/interfaces/")).remove(QString("/transmitter/data"));
|
||||
QStringList allNetworkDevices = networkDevices;
|
||||
for (int i=0; i<allNetworkDevices.count(); i++) {
|
||||
if (allNetworkDevices.at(i) != device) continue;
|
||||
if (value > 1000.0)
|
||||
values[QString("up%1").arg(i)] = QString("%1").arg(data[QString("value")].toFloat() / 1024.0, 4, 'f', 1);
|
||||
else
|
||||
values[QString("up%1").arg(i)] = QString("%1").arg(data[QString("value")].toFloat(), 4, 'f', 0);
|
||||
break;
|
||||
}
|
||||
if (device == values[QString("netdev")]) {
|
||||
if (value > 1000.0)
|
||||
values[QString("up")] = QString("%1").arg(value / 1024.0, 4, 'f', 1);
|
||||
else
|
||||
values[QString("up")] = QString("%1").arg(value, 4, 'f', 0);
|
||||
}
|
||||
} 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
|
||||
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")) {
|
||||
// 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 ((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.contains(tempRegExp)) {
|
||||
// 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")) {
|
||||
// time
|
||||
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);
|
||||
values[QString("ctime")] = params[QString("customTime")].toString();
|
||||
foreach(QString key, getTimeKeys())
|
||||
values[QString("ctime")].replace(QString("$%1").arg(key),
|
||||
data[QString("DateTime")].toDateTime().toString(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 {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Source" << sourceName << "not found";
|
||||
emit(dropSourceFromDataengine(sourceName));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void AWKeys::graphicalValueByKey() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
bool ok;
|
||||
QString tag = QInputDialog::getItem(nullptr, i18n("Select tag"), i18n("Tag"),
|
||||
dictKeys(true), 0, false, &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
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "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
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Requested key" << key;
|
||||
|
||||
key.remove(QRegExp(QString("^bar[0-9]{1,}")));
|
||||
|
||||
return values[key];
|
||||
}
|
||||
|
||||
|
||||
void AWKeys::editItem(const QString type)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
if (type == QString("graphicalitem")) {
|
||||
QStringList bars;
|
||||
bars.append(keys.filter((QRegExp(QString("^cpu(?!cl).*")))));
|
||||
bars.append(keys.filter((QRegExp(QString("^gpu$")))));
|
||||
bars.append(keys.filter((QRegExp(QString("^mem$")))));
|
||||
bars.append(keys.filter((QRegExp(QString("^swap$")))));
|
||||
bars.append(keys.filter((QRegExp(QString("^hdd[0-9].*")))));
|
||||
bars.append(keys.filter((QRegExp(QString("^bat.*")))));
|
||||
graphicalItems->setConfigArgs(bars);
|
||||
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() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
emit(needTextToBeUpdated(parsePattern()));
|
||||
if (toolTip != nullptr) emit(toolTip->updateData(values));
|
||||
}
|
||||
|
||||
|
||||
void AWKeys::loadKeysFromCache()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QString fileName = QString("%1/awesomewidgets.ndx")
|
||||
.arg(QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation));
|
||||
if (debug) qDebug() << PDEBUG << ":" << "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()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
keys = dictKeys();
|
||||
foundBars = findGraphicalItems();
|
||||
foundKeys = findKeys();
|
||||
}
|
||||
|
||||
|
||||
void AWKeys::addKeyToCache(const QString type, const QString key)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Key type" << type;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Key" << key;
|
||||
|
||||
QString fileName = QString("%1/awesomewidgets.ndx").arg(QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation));
|
||||
if (debug) qDebug() << PDEBUG << ":" << "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;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "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;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "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;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "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();
|
||||
}
|
||||
|
||||
|
||||
QString AWKeys::htmlValue(QString key) const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Requested key" << key;
|
||||
|
||||
QString value = values[key];
|
||||
if (!key.startsWith(QString("custom")))
|
||||
value.replace(QString(" "), QString(" "));
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
int AWKeys::numberCpus() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return QThread::idealThreadCount();
|
||||
}
|
||||
|
||||
|
||||
float AWKeys::temperature(const float temp, const QString units) const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
QStringList AWKeys::findGraphicalItems() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QStringList orderedKeys;
|
||||
foreach(GraphicalItem *item, graphicalItems->items())
|
||||
orderedKeys.append(item->name() + item->bar());
|
||||
orderedKeys.sort();
|
||||
|
||||
QStringList selectedKeys;
|
||||
for (int i=orderedKeys.count()-1; i>=0; i--)
|
||||
if (pattern.contains(QString("$%1").arg(orderedKeys.at(i)))) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Found key" << orderedKeys.at(i);
|
||||
selectedKeys.append(orderedKeys.at(i));
|
||||
}
|
||||
|
||||
return selectedKeys;
|
||||
}
|
||||
|
||||
|
||||
QStringList AWKeys::findKeys() const
|
||||
{
|
||||
QStringList selectedKeys;
|
||||
foreach(QString key, keys) {
|
||||
if (key.startsWith(QString("bar"))) continue;
|
||||
if (pattern.contains(QString("$%1").arg(key))) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Found key" << key;
|
||||
selectedKeys.append(key);
|
||||
}
|
||||
}
|
||||
|
||||
return selectedKeys;
|
||||
}
|
||||
|
||||
|
||||
GraphicalItem *AWKeys::getItemByTag(const QString tag) const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
GraphicalItem *item = nullptr;
|
||||
foreach(GraphicalItem *gitem, graphicalItems->items()) {
|
||||
if ((gitem->name() + gitem->bar()) != tag) continue;
|
||||
item = gitem;
|
||||
break;
|
||||
}
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
|
||||
QStringList AWKeys::getTimeKeys() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QStringList keys;
|
||||
keys.append(QString("dddd"));
|
||||
keys.append(QString("ddd"));
|
||||
keys.append(QString("dd"));
|
||||
keys.append(QString("d"));
|
||||
keys.append(QString("MMMM"));
|
||||
keys.append(QString("MMM"));
|
||||
keys.append(QString("MM"));
|
||||
keys.append(QString("M"));
|
||||
keys.append(QString("yyyy"));
|
||||
keys.append(QString("yy"));
|
||||
keys.append(QString("hh"));
|
||||
keys.append(QString("h"));
|
||||
keys.append(QString("mm"));
|
||||
keys.append(QString("m"));
|
||||
keys.append(QString("ss"));
|
||||
keys.append(QString("s"));
|
||||
|
||||
return keys;
|
||||
}
|
103
sources/awesome-widget/plugin/awkeys.h
Normal file
@ -0,0 +1,103 @@
|
||||
/***************************************************************************
|
||||
* 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"
|
||||
|
||||
|
||||
class AWToolTip;
|
||||
class ExtQuotes;
|
||||
class ExtScript;
|
||||
class ExtUpgrade;
|
||||
class ExtWeather;
|
||||
class GraphicalItem;
|
||||
|
||||
class AWKeys : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
AWKeys(QObject *parent = nullptr);
|
||||
~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 setWrapNewLines(const bool wrap = false);
|
||||
Q_INVOKABLE QString parsePattern() const;
|
||||
Q_INVOKABLE QSize toolTipSize() const;
|
||||
// keys
|
||||
Q_INVOKABLE void addDevice(const QString source);
|
||||
Q_INVOKABLE QStringList dictKeys(const bool sorted = false) const;
|
||||
Q_INVOKABLE QStringList 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() const;
|
||||
void loadKeysFromCache();
|
||||
void reinitKeys();
|
||||
|
||||
private:
|
||||
// methods
|
||||
void addKeyToCache(const QString type, const QString key = QString(""));
|
||||
QString htmlValue(QString key) const;
|
||||
int numberCpus() const;
|
||||
float temperature(const float temp, const QString units) const;
|
||||
// find methods
|
||||
QStringList findGraphicalItems() const;
|
||||
QStringList findKeys() const;
|
||||
// get methods
|
||||
GraphicalItem *getItemByTag(const QString tag) const;
|
||||
QStringList getTimeKeys() const;
|
||||
AWToolTip *toolTip = nullptr;
|
||||
bool debug = false;
|
||||
bool enablePopup = false;
|
||||
bool wrapNewLines = false;
|
||||
ExtItemAggregator<GraphicalItem> *graphicalItems;
|
||||
ExtItemAggregator<ExtQuotes> *extQuotes;
|
||||
ExtItemAggregator<ExtScript> *extScripts;
|
||||
ExtItemAggregator<ExtUpgrade> *extUpgrade;
|
||||
ExtItemAggregator<ExtWeather> *extWeather;
|
||||
QString pattern;
|
||||
QStringList foundBars, foundKeys, keys;
|
||||
QHash<QString, QString> values;
|
||||
QStringList diskDevices, hddDevices, mountDevices, networkDevices, tempDevices;
|
||||
};
|
||||
|
||||
|
||||
#endif /* AWKEYS_H */
|
@ -17,6 +17,7 @@
|
||||
|
||||
#include "awtooltip.h"
|
||||
|
||||
#include <QBuffer>
|
||||
#include <QDebug>
|
||||
#include <QProcessEnvironment>
|
||||
#include <math.h>
|
||||
@ -24,17 +25,16 @@
|
||||
#include <pdebug/pdebug.h>
|
||||
|
||||
|
||||
AWToolTip::AWToolTip(QObject *parent,
|
||||
QMap<QString, QVariant> settings)
|
||||
AWToolTip::AWToolTip(QObject *parent, QVariantMap settings)
|
||||
: QObject(parent),
|
||||
configuration(settings)
|
||||
configuration(qvariant_cast<QVariantHash>(settings))
|
||||
{
|
||||
// debug
|
||||
QProcessEnvironment environment = QProcessEnvironment::systemEnvironment();
|
||||
QString debugEnv = environment.value(QString("DEBUG"), QString("no"));
|
||||
debug = (debugEnv == QString("yes"));
|
||||
|
||||
toolTipScene = new QGraphicsScene();
|
||||
toolTipScene = new QGraphicsScene(nullptr);
|
||||
toolTipView = new QGraphicsView(toolTipScene);
|
||||
toolTipView->setStyleSheet(QString("background: transparent"));
|
||||
toolTipView->setContentsMargins(0, 0, 0, 0);
|
||||
@ -66,6 +66,9 @@ AWToolTip::AWToolTip(QObject *parent,
|
||||
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>)));
|
||||
}
|
||||
|
||||
|
||||
@ -73,12 +76,33 @@ AWToolTip::~AWToolTip()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
delete toolTipView;
|
||||
delete toolTipScene;
|
||||
}
|
||||
|
||||
|
||||
QSize AWToolTip::getSize()
|
||||
void AWToolTip::dataUpdate(QHash<QString, QString> values)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
// 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());
|
||||
// network may be showed as float (MB/s) or as int (KB/s)
|
||||
setData(QString("downTooltip"), values[QString("down")].contains(QChar('.')) ?
|
||||
values[QString("down")].toFloat() * 1024.0 : values[QString("down")].toFloat());
|
||||
setData(QString("upTooltip"), values[QString("up")].contains(QChar('.')) ?
|
||||
values[QString("up")].toFloat() * 1024.0 : values[QString("up")].toFloat());
|
||||
|
||||
emit(toolTipPainted(htmlImage()));
|
||||
}
|
||||
|
||||
|
||||
QSize AWToolTip::getSize() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
@ -86,6 +110,19 @@ QSize AWToolTip::getSize()
|
||||
}
|
||||
|
||||
|
||||
QString AWToolTip::htmlImage()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QPixmap rawImage = image();
|
||||
QByteArray byteArray;
|
||||
QBuffer buffer(&byteArray);
|
||||
rawImage.save(&buffer, "PNG");
|
||||
|
||||
return QString("<img src=\"data:image/png;base64,%1\"/>").arg(QString(byteArray.toBase64()));
|
||||
}
|
||||
|
||||
|
||||
QPixmap AWToolTip::image()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
@ -95,32 +132,31 @@ QPixmap AWToolTip::image()
|
||||
toolTipScene->clear();
|
||||
QPen pen = QPen();
|
||||
// background
|
||||
if (configuration[QString("useTooltipBackground")].toBool())
|
||||
toolTipScene->setBackgroundBrush(QBrush(QColor(configuration[QString("tooltipBackground")].toString())));
|
||||
else
|
||||
toolTipScene->setBackgroundBrush(QBrush(Qt::NoBrush));
|
||||
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[i]].count());
|
||||
float normY = 100.0 / (1.5 * boundaries[requiredKeys[i]]);
|
||||
if (requiredKeys[i] != QString("batTooltip"))
|
||||
pen.setColor(QColor(configuration[requiredKeys[i] + QString("Color")].toString()));
|
||||
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[i]].count()-1; j++) {
|
||||
for (int j=0; j<data[requiredKeys.at(i)].count()-1; j++) {
|
||||
float x1 = j * normX + shift;
|
||||
float y1 = - fabs(data[requiredKeys[i]][j]) * normY + 5.0;
|
||||
float y1 = - fabs(data[requiredKeys.at(i)].at(j)) * normY + 5.0;
|
||||
float x2 = (j + 1) * normX + shift;
|
||||
float y2 = - fabs(data[requiredKeys[i]][j+1]) * normY + 5.0;
|
||||
if (requiredKeys[i] == QString("batTooltip")) {
|
||||
if (data[requiredKeys[i]][j+1] > 0)
|
||||
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[i] == QString("downTooltip")) down = true;
|
||||
if (requiredKeys.at(i) == QString("downTooltip")) down = true;
|
||||
}
|
||||
|
||||
return toolTipView->grab();
|
||||
@ -143,12 +179,12 @@ void AWToolTip::setData(const QString source, float value, const bool ac)
|
||||
data[source].append(-value);
|
||||
|
||||
if ((source == QString("downTooltip")) || (source == QString("upTooltip"))) {
|
||||
for (int i=0; i<data[QString("downTooltip")].count(); i++)
|
||||
if (boundaries[QString("downTooltip")] < data[QString("downTooltip")][i])
|
||||
boundaries[QString("downTooltip")] = data[QString("downTooltip")][i];
|
||||
for (int i=0; i<data[QString("upTooltip")].count(); i++)
|
||||
if (boundaries[QString("downTooltip")] < data[QString("upTooltip")][i])
|
||||
boundaries[QString("downTooltip")] = data[QString("upTooltip")][i];
|
||||
foreach(float val, data[QString("downTooltip")])
|
||||
if (boundaries[QString("downTooltip")] < val)
|
||||
boundaries[QString("downTooltip")] = val;
|
||||
foreach(float val, data[QString("upTooltip")])
|
||||
if (boundaries[QString("downTooltip")] < val)
|
||||
boundaries[QString("downTooltip")] = val;
|
||||
boundaries[QString("downTooltip")] *= 1.2;
|
||||
boundaries[QString("upTooltip")] = boundaries[QString("downTooltip")];
|
||||
}
|
@ -21,7 +21,7 @@
|
||||
|
||||
#include <QGraphicsScene>
|
||||
#include <QGraphicsView>
|
||||
#include <QMap>
|
||||
#include <QHash>
|
||||
#include <QObject>
|
||||
#include <QPixmap>
|
||||
#include <QVariant>
|
||||
@ -32,25 +32,31 @@ class AWToolTip : public QObject
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
AWToolTip(QObject *parent = 0,
|
||||
QMap<QString, QVariant> settings = QMap<QString, QVariant>());
|
||||
AWToolTip(QObject *parent = nullptr, QVariantMap settings = QVariantMap());
|
||||
~AWToolTip();
|
||||
|
||||
QSize getSize();
|
||||
QSize getSize() const;
|
||||
QString htmlImage();
|
||||
QPixmap image();
|
||||
void setData(const QString source, float value,
|
||||
const bool ac = true);
|
||||
|
||||
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 ac = true);
|
||||
// variables
|
||||
bool debug = false;
|
||||
int counts = 0;
|
||||
QMap<QString, QVariant> configuration;
|
||||
QMap<QString, float> boundaries;
|
||||
QMap<QString, QList<float>> data;
|
||||
QVariantHash configuration;
|
||||
QHash<QString, float> boundaries;
|
||||
QHash<QString, QList<float>> data;
|
||||
QStringList requiredKeys;
|
||||
QSize size;
|
||||
};
|
35
sources/awesomewidgets/CMakeLists.txt
Normal file
@ -0,0 +1,35 @@
|
||||
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_RECURSE SUBPROJECT_SOURCE *.cpp ${PROJECT_TRDPARTY_DIR}/qreplytimeout/*.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)
|
||||
|
||||
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})
|
@ -15,42 +15,49 @@
|
||||
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include "extupgrade.h"
|
||||
#include "ui_extupgrade.h"
|
||||
#include "abstractextitem.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
#include <QSettings>
|
||||
#include <QTextCodec>
|
||||
#include <QStandardPaths>
|
||||
#include <QTime>
|
||||
|
||||
#include <pdebug/pdebug.h>
|
||||
#include <task/taskadds.h>
|
||||
|
||||
#include "version.h"
|
||||
|
||||
|
||||
ExtUpgrade::ExtUpgrade(QWidget *parent, const QString upgradeName, const QStringList directories, const bool debugCmd) :
|
||||
QDialog(parent),
|
||||
m_fileName(upgradeName),
|
||||
m_dirs(directories),
|
||||
debug(debugCmd),
|
||||
ui(new Ui::ExtUpgrade)
|
||||
AbstractExtItem::AbstractExtItem(QWidget *parent, const QString desktopName,
|
||||
const QStringList directories, const bool debugCmd)
|
||||
: QDialog(parent),
|
||||
m_fileName(desktopName),
|
||||
m_dirs(directories),
|
||||
debug(debugCmd)
|
||||
{
|
||||
m_name = m_fileName;
|
||||
readConfiguration();
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
|
||||
ExtUpgrade::~ExtUpgrade()
|
||||
AbstractExtItem::~AbstractExtItem()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
||||
int ExtUpgrade::apiVersion()
|
||||
template <class T>
|
||||
T *AbstractExtItem::copy(const QString fileName, const int number)
|
||||
{
|
||||
Q_UNUSED(fileName)
|
||||
Q_UNUSED(number)
|
||||
|
||||
// an analog of pure virtual method
|
||||
return new T();
|
||||
}
|
||||
|
||||
|
||||
|
||||
int AbstractExtItem::apiVersion() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
@ -58,7 +65,7 @@ int ExtUpgrade::apiVersion()
|
||||
}
|
||||
|
||||
|
||||
QString ExtUpgrade::comment()
|
||||
QString AbstractExtItem::comment() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
@ -66,15 +73,15 @@ QString ExtUpgrade::comment()
|
||||
}
|
||||
|
||||
|
||||
QString ExtUpgrade::executable()
|
||||
QStringList AbstractExtItem::directories() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return m_executable;
|
||||
return m_dirs;
|
||||
}
|
||||
|
||||
|
||||
QString ExtUpgrade::fileName()
|
||||
QString AbstractExtItem::fileName() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
@ -82,7 +89,7 @@ QString ExtUpgrade::fileName()
|
||||
}
|
||||
|
||||
|
||||
int ExtUpgrade::interval()
|
||||
int AbstractExtItem::interval() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
@ -90,23 +97,7 @@ int ExtUpgrade::interval()
|
||||
}
|
||||
|
||||
|
||||
QString ExtUpgrade::name()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return m_name;
|
||||
}
|
||||
|
||||
|
||||
int ExtUpgrade::null()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return m_null;
|
||||
}
|
||||
|
||||
|
||||
bool ExtUpgrade::isActive()
|
||||
bool AbstractExtItem::isActive() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
@ -114,7 +105,32 @@ bool ExtUpgrade::isActive()
|
||||
}
|
||||
|
||||
|
||||
void ExtUpgrade::setApiVersion(const int _apiVersion)
|
||||
QString AbstractExtItem::name() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return m_name;
|
||||
}
|
||||
|
||||
|
||||
int AbstractExtItem::number() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return m_number;
|
||||
}
|
||||
|
||||
|
||||
QString AbstractExtItem::tag(const QString _type) const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Tag type" << _type;
|
||||
|
||||
return QString("%1%2").arg(_type).arg(m_number);
|
||||
}
|
||||
|
||||
|
||||
void AbstractExtItem::setApiVersion(const int _apiVersion)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Version" << _apiVersion;
|
||||
@ -123,16 +139,16 @@ void ExtUpgrade::setApiVersion(const int _apiVersion)
|
||||
}
|
||||
|
||||
|
||||
void ExtUpgrade::setActive(const bool state)
|
||||
void AbstractExtItem::setActive(const bool _state)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "State" << state;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "State" << _state;
|
||||
|
||||
m_active = state;
|
||||
m_active = _state;
|
||||
}
|
||||
|
||||
|
||||
void ExtUpgrade::setComment(const QString _comment)
|
||||
void AbstractExtItem::setComment(const QString _comment)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Comment" << _comment;
|
||||
@ -141,25 +157,17 @@ void ExtUpgrade::setComment(const QString _comment)
|
||||
}
|
||||
|
||||
|
||||
void ExtUpgrade::setExecutable(const QString _executable)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Executable" << _executable;
|
||||
|
||||
m_executable = _executable;
|
||||
}
|
||||
|
||||
|
||||
void ExtUpgrade::setInterval(const int _interval)
|
||||
void AbstractExtItem::setInterval(const int _interval)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Interval" << _interval;
|
||||
if (_interval <= 0) return;
|
||||
|
||||
m_interval = _interval;
|
||||
}
|
||||
|
||||
|
||||
void ExtUpgrade::setName(const QString _name)
|
||||
void AbstractExtItem::setName(const QString _name)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Name" << _name;
|
||||
@ -168,120 +176,72 @@ void ExtUpgrade::setName(const QString _name)
|
||||
}
|
||||
|
||||
|
||||
void ExtUpgrade::setNull(const int _null)
|
||||
void AbstractExtItem::setNumber(int _number)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Null lines" << _null;
|
||||
if (_null < 0) return;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Number" << _number;
|
||||
if (_number == -1) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Number is empty, generate new one";
|
||||
qsrand(QTime::currentTime().msec());
|
||||
_number = qrand() % 1000;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Generated number is" << _number;
|
||||
}
|
||||
|
||||
m_null = _null;
|
||||
m_number = _number;
|
||||
}
|
||||
|
||||
|
||||
void ExtUpgrade::readConfiguration()
|
||||
void AbstractExtItem::readConfiguration()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
for (int i=m_dirs.count()-1; i>=0; i--) {
|
||||
if (!QDir(m_dirs[i]).entryList(QDir::Files).contains(m_fileName)) continue;
|
||||
QSettings settings(m_dirs[i] + QDir::separator() + m_fileName, QSettings::IniFormat);
|
||||
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"), AWESAPI).toInt());
|
||||
setExecutable(settings.value(QString("Exec"), m_executable).toString());
|
||||
setApiVersion(settings.value(QString("X-AW-ApiVersion"), m_apiVersion).toInt());
|
||||
setActive(settings.value(QString("X-AW-Active"), QVariant(m_active)).toString() == QString("true"));
|
||||
setNull(settings.value(QString("X-AW-Null"), m_null).toInt());
|
||||
setInterval(settings.value(QString("X-AW-Interval"), m_interval).toInt());
|
||||
setNumber(settings.value(QString("X-AW-Number"), m_number).toInt());
|
||||
settings.endGroup();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int ExtUpgrade::run()
|
||||
bool AbstractExtItem::tryDelete() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (!m_active) return value;
|
||||
|
||||
if (times == 1) {
|
||||
TaskResult process = runTask(QString("bash -c \"") + m_executable + QString("\""));
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
||||
if (process.exitCode != 0)
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
||||
|
||||
QString qoutput = QTextCodec::codecForMib(106)->toUnicode(process.output).trimmed();
|
||||
value = qoutput.split(QChar('\n'), QString::SkipEmptyParts).count() - m_null;
|
||||
foreach(QString dir, m_dirs) {
|
||||
bool status = QFile::remove(QString("%1/%2").arg(dir).arg(m_fileName));
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Remove file" << QString("%1/%2").arg(dir).arg(m_fileName) << status;
|
||||
}
|
||||
|
||||
// update value
|
||||
times++;
|
||||
if (times >= m_interval) times = 0;
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
int ExtUpgrade::showConfiguration()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
ui->lineEdit_name->setText(m_name);
|
||||
ui->lineEdit_comment->setText(m_comment);
|
||||
ui->lineEdit_command->setText(m_executable);
|
||||
if (m_active)
|
||||
ui->checkBox_active->setCheckState(Qt::Checked);
|
||||
else
|
||||
ui->checkBox_active->setCheckState(Qt::Unchecked);
|
||||
ui->spinBox_null->setValue(m_null);
|
||||
ui->spinBox_interval->setValue(m_interval);
|
||||
|
||||
int ret = exec();
|
||||
if (ret != 1) return ret;
|
||||
setName(ui->lineEdit_name->text());
|
||||
setComment(ui->lineEdit_comment->text());
|
||||
setApiVersion(AWEUAPI);
|
||||
setExecutable(ui->lineEdit_command->text());
|
||||
setActive(ui->checkBox_active->checkState() == Qt::Checked);
|
||||
setNull(ui->spinBox_null->value());
|
||||
setInterval(ui->spinBox_interval->value());
|
||||
|
||||
writeConfiguration();
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int ExtUpgrade::tryDelete()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
for (int i=0; i<m_dirs.count(); i++)
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Remove file" << m_dirs[i] + QDir::separator() + m_fileName <<
|
||||
QFile::remove(m_dirs[i] + QDir::separator() + m_fileName);
|
||||
|
||||
// check if exists
|
||||
for (int i=0; i<m_dirs.count(); i++)
|
||||
if (QFile::exists(m_dirs[i] + QDir::separator() + m_fileName)) return 0;
|
||||
return 1;
|
||||
foreach(QString dir, m_dirs)
|
||||
if (QFile::exists(QString("%1/%2").arg(dir).arg(m_fileName))) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void ExtUpgrade::writeConfiguration()
|
||||
void AbstractExtItem::writeConfiguration() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QSettings settings(m_dirs[0] + QDir::separator() + m_fileName, QSettings::IniFormat);
|
||||
QSettings settings(QString("%1/%2").arg(m_dirs.first()).arg(m_fileName), QSettings::IniFormat);
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Configuration file" << settings.fileName();
|
||||
|
||||
settings.beginGroup(QString("Desktop Entry"));
|
||||
settings.setValue(QString("Encoding"), QString("UTF-8"));
|
||||
settings.setValue(QString("Name"), m_name);
|
||||
settings.setValue(QString("Comment"), m_comment);
|
||||
settings.setValue(QString("Exec"), m_executable);
|
||||
settings.setValue(QString("X-AW-ApiVersion"), m_apiVersion);
|
||||
settings.setValue(QString("X-AW-Active"), QVariant(m_active).toString());
|
||||
settings.setValue(QString("X-AW-Null"), m_null);
|
||||
settings.setValue(QString("X-AW-Interval"), m_interval);
|
||||
settings.setValue(QString("X-AW-Number"), m_number);
|
||||
settings.endGroup();
|
||||
|
||||
settings.sync();
|
86
sources/awesomewidgets/abstractextitem.h
Normal file
@ -0,0 +1,86 @@
|
||||
/***************************************************************************
|
||||
* This file is part of awesome-widgets *
|
||||
* *
|
||||
* awesome-widgets is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* awesome-widgets is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef 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(),
|
||||
const bool debugCmd = false);
|
||||
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;
|
||||
bool debug;
|
||||
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 */
|
115
sources/awesomewidgets/abstractextitemaggregator.cpp
Normal 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 <QDebug>
|
||||
#include <QHBoxLayout>
|
||||
#include <QInputDialog>
|
||||
#include <QLineEdit>
|
||||
|
||||
#include <pdebug/pdebug.h>
|
||||
|
||||
|
||||
AbstractExtItemAggregator::AbstractExtItemAggregator(QWidget *parent, const bool debugCmd)
|
||||
: QWidget(parent),
|
||||
debug(debugCmd)
|
||||
{
|
||||
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()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
delete dialog;
|
||||
}
|
||||
|
||||
|
||||
QString AbstractExtItemAggregator::getName()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
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
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return m_configArgs;
|
||||
}
|
||||
|
||||
|
||||
void AbstractExtItemAggregator::setConfigArgs(const QVariant _configArgs)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Configuration arguments" << _configArgs;
|
||||
|
||||
m_configArgs = _configArgs;
|
||||
}
|
||||
|
||||
|
||||
void AbstractExtItemAggregator::editItemActivated(QListWidgetItem *item)
|
||||
{
|
||||
Q_UNUSED(item)
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return editItem();
|
||||
}
|
||||
|
||||
|
||||
void AbstractExtItemAggregator::editItemButtonPressed(QAbstractButton *button)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
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();
|
||||
}
|
66
sources/awesomewidgets/abstractextitemaggregator.h
Normal file
@ -0,0 +1,66 @@
|
||||
/***************************************************************************
|
||||
* 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:
|
||||
AbstractExtItemAggregator(QWidget *parent = nullptr, const bool debugCmd = false);
|
||||
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:
|
||||
bool debug;
|
||||
QVariant m_configArgs;
|
||||
// methods
|
||||
virtual void copyItem() = 0;
|
||||
virtual void createItem() = 0;
|
||||
virtual void deleteItem() = 0;
|
||||
virtual void editItem() = 0;
|
||||
};
|
||||
|
||||
|
||||
#endif /* ABSTRACTEXTITEMAGGREGATOR_H */
|
@ -9,4 +9,5 @@ X-AW-Type=Horizontal
|
||||
X-AW-Direction=LeftToRight
|
||||
X-AW-Height=25
|
||||
X-AW-Width=100
|
||||
X-AW-ApiVersion=1
|
||||
X-AW-ApiVersion=2
|
||||
X-AW-Number=3
|
@ -9,4 +9,5 @@ X-AW-Type=Horizontal
|
||||
X-AW-Direction=LeftToRight
|
||||
X-AW-Height=25
|
||||
X-AW-Width=100
|
||||
X-AW-ApiVersion=1
|
||||
X-AW-ApiVersion=2
|
||||
X-AW-Number=0
|
@ -9,4 +9,5 @@ X-AW-Type=Horizontal
|
||||
X-AW-Direction=LeftToRight
|
||||
X-AW-Height=25
|
||||
X-AW-Width=100
|
||||
X-AW-ApiVersion=1
|
||||
X-AW-ApiVersion=2
|
||||
X-AW-Number=1
|
@ -9,4 +9,5 @@ X-AW-Type=Horizontal
|
||||
X-AW-Direction=LeftToRight
|
||||
X-AW-Height=25
|
||||
X-AW-Width=100
|
||||
X-AW-ApiVersion=1
|
||||
X-AW-ApiVersion=2
|
||||
X-AW-Number=2
|
221
sources/awesomewidgets/extitemaggregator.h
Normal file
@ -0,0 +1,221 @@
|
||||
/***************************************************************************
|
||||
* 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 <QDebug>
|
||||
#include <QDir>
|
||||
#include <QSettings>
|
||||
#include <QStandardPaths>
|
||||
|
||||
#include <pdebug/pdebug.h>
|
||||
|
||||
#include "abstractextitemaggregator.h"
|
||||
|
||||
|
||||
template <class T>
|
||||
class ExtItemAggregator : public AbstractExtItemAggregator
|
||||
{
|
||||
public:
|
||||
explicit ExtItemAggregator(QWidget *parent, const QString type,
|
||||
const bool debugCmd = false)
|
||||
: AbstractExtItemAggregator(parent, debugCmd),
|
||||
debug(debugCmd),
|
||||
m_type(type)
|
||||
{
|
||||
initItems();
|
||||
};
|
||||
|
||||
~ExtItemAggregator()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
m_items.clear();
|
||||
}
|
||||
|
||||
void editItems()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
repaint();
|
||||
int ret = dialog->exec();
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Dialog returns" << ret;
|
||||
};
|
||||
|
||||
void initItems()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
m_items.clear();
|
||||
m_items = getItems();
|
||||
};
|
||||
|
||||
T *itemFromWidget() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QListWidgetItem *item = widgetDialog->currentItem();
|
||||
if (item == nullptr) return nullptr;
|
||||
|
||||
int originalItem = -1;
|
||||
for (int i=0; i<m_items.count(); i++) {
|
||||
if (m_items.at(i)->fileName() != item->text()) continue;
|
||||
originalItem = i;
|
||||
break;
|
||||
}
|
||||
|
||||
return originalItem == -1 ? nullptr : m_items[originalItem];
|
||||
};
|
||||
|
||||
QList<T *> items() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return m_items;
|
||||
};
|
||||
|
||||
int uniqNumber() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QList<int> tagList;
|
||||
foreach(T *item, m_items) tagList.append(item->number());
|
||||
int number = 0;
|
||||
while (tagList.contains(number)) number++;
|
||||
|
||||
return number;
|
||||
};
|
||||
|
||||
private:
|
||||
bool debug;
|
||||
QList<T *> m_items;
|
||||
QString m_type;
|
||||
|
||||
// init method
|
||||
QList<T *> getItems()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
// create directory at $HOME
|
||||
QString localDir = QString("%1/awesomewidgets/%2")
|
||||
.arg(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation))
|
||||
.arg(m_type);
|
||||
QDir localDirectory;
|
||||
if (localDirectory.mkpath(localDir))
|
||||
if (debug) qDebug() << PDEBUG << ":" << "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;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Found file" << file << "in" << dir;
|
||||
names.append(file);
|
||||
items.append(new T(this, file, dirs, debug));
|
||||
}
|
||||
}
|
||||
|
||||
return items;
|
||||
};
|
||||
|
||||
void repaint()
|
||||
{
|
||||
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()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
T *source = itemFromWidget();
|
||||
QString fileName = getName();
|
||||
int number = uniqNumber();
|
||||
if ((source == nullptr) || (fileName.isEmpty())) return;
|
||||
|
||||
T *newItem = source->copy(fileName, number);
|
||||
if (newItem->showConfiguration(configArgs()) == 1) {
|
||||
initItems();
|
||||
repaint();
|
||||
}
|
||||
};
|
||||
|
||||
void createItem()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QString fileName = getName();
|
||||
int number = uniqNumber();
|
||||
QStringList dirs = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation,
|
||||
QString("awesomewidgets/%1").arg(m_type),
|
||||
QStandardPaths::LocateDirectory);
|
||||
if (fileName.isEmpty()) return;
|
||||
|
||||
T *newItem = new T(this, fileName, dirs, debug);
|
||||
newItem->setNumber(number);
|
||||
if (newItem->showConfiguration(configArgs()) == 1) {
|
||||
initItems();
|
||||
repaint();
|
||||
}
|
||||
};
|
||||
|
||||
void deleteItem()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
T *source = itemFromWidget();
|
||||
if (source == nullptr) return;
|
||||
|
||||
if (source->tryDelete()) {
|
||||
initItems();
|
||||
repaint();
|
||||
}
|
||||
};
|
||||
|
||||
void editItem()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
T *source = itemFromWidget();
|
||||
if (source == nullptr) return;
|
||||
|
||||
if (source->showConfiguration(configArgs()) == 1) {
|
||||
initItems();
|
||||
repaint();
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
#endif /* EXTITEMAGGREGATOR_H */
|
266
sources/awesomewidgets/extquotes.cpp
Normal file
@ -0,0 +1,266 @@
|
||||
/***************************************************************************
|
||||
* 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 <QDebug>
|
||||
#include <QDir>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonParseError>
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QNetworkRequest>
|
||||
#include <QSettings>
|
||||
|
||||
#include <pdebug/pdebug.h>
|
||||
#include <qreplytimeout/qreplytimeout.h>
|
||||
|
||||
#include "version.h"
|
||||
|
||||
|
||||
ExtQuotes::ExtQuotes(QWidget *parent, const QString quotesName,
|
||||
const QStringList directories, const bool debugCmd)
|
||||
: AbstractExtItem(parent, quotesName, directories, debugCmd),
|
||||
debug(debugCmd),
|
||||
ui(new Ui::ExtQuotes)
|
||||
{
|
||||
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()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
disconnect(manager, SIGNAL(finished(QNetworkReply *)), this, SLOT(quotesReplyReceived(QNetworkReply *)));
|
||||
|
||||
delete manager;
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
||||
ExtQuotes *ExtQuotes::copy(const QString fileName, const int number)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
ExtQuotes *item = new ExtQuotes(static_cast<QWidget *>(parent()), fileName,
|
||||
directories(), debug);
|
||||
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
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return m_ticker;
|
||||
}
|
||||
|
||||
|
||||
QString ExtQuotes::uniq() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return m_ticker;
|
||||
}
|
||||
|
||||
|
||||
void ExtQuotes::setTicker(const QString _ticker)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Ticker" << _ticker;
|
||||
|
||||
m_ticker = _ticker;
|
||||
}
|
||||
|
||||
|
||||
void ExtQuotes::readConfiguration()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
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)) {
|
||||
setApiVersion(AWEQAPI);
|
||||
writeConfiguration();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QVariantHash ExtQuotes::run()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if ((!isActive()) || (isRunning)) return values;
|
||||
|
||||
if (times == 1) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "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)
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
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
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
AbstractExtItem::writeConfiguration();
|
||||
|
||||
QSettings settings(QString("%1/%2").arg(directories().first()).arg(fileName()), QSettings::IniFormat);
|
||||
if (debug) qDebug() << PDEBUG << ":" << "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)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Return code" << reply->error();
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Reply error message" << reply->errorString();
|
||||
|
||||
isRunning = false;
|
||||
QJsonParseError error;
|
||||
QJsonDocument jsonDoc = QJsonDocument::fromJson(reply->readAll(), &error);
|
||||
reply->deleteLater();
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Json parse error" << error.errorString();
|
||||
if ((reply->error() != QNetworkReply::NoError) ||
|
||||
(error.error != QJsonParseError::NoError)) {
|
||||
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()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
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
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QString apiUrl = QString(YAHOO_URL);
|
||||
apiUrl.replace(QString("$TICKER"), m_ticker);
|
||||
if (debug) qDebug() << PDEBUG << ":" << "API url" << apiUrl;
|
||||
|
||||
return apiUrl;
|
||||
}
|
74
sources/awesomewidgets/extquotes.h
Normal file
@ -0,0 +1,74 @@
|
||||
/***************************************************************************
|
||||
* 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(),
|
||||
const bool debugCmd = false);
|
||||
~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:
|
||||
bool debug;
|
||||
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 */
|
@ -1,13 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>GraphicalItem</class>
|
||||
<widget class="QDialog" name="GraphicalItem">
|
||||
<class>ExtQuotes</class>
|
||||
<widget class="QDialog" name="ExtQuotes">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>416</width>
|
||||
<height>325</height>
|
||||
<width>420</width>
|
||||
<height>301</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -18,6 +18,12 @@
|
||||
<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>
|
||||
@ -27,11 +33,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_nameValue">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="lineEdit_name"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
@ -59,11 +61,11 @@
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_value">
|
||||
<layout class="QHBoxLayout" name="layout_number">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_value">
|
||||
<widget class="QLabel" name="label_number">
|
||||
<property name="text">
|
||||
<string>Value</string>
|
||||
<string>Tag</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
@ -71,20 +73,39 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox_value">
|
||||
<property name="editable">
|
||||
<bool>false</bool>
|
||||
<widget class="QLabel" name="label_numberValue">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_activeColor">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string><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></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_activeColor">
|
||||
<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>Active color</string>
|
||||
<string>Ticker</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
@ -92,20 +113,46 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_activeColor">
|
||||
<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 notr="true"/>
|
||||
<string>Active</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_inactiveColor">
|
||||
<layout class="QHBoxLayout" name="layout_interval">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_inactiveColor">
|
||||
<widget class="QLabel" name="label_interval">
|
||||
<property name="text">
|
||||
<string>Inactive color</string>
|
||||
<string>Interval</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
@ -113,118 +160,18 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_inactiveColor">
|
||||
<property name="text">
|
||||
<string notr="true"/>
|
||||
<widget class="QSpinBox" name="spinBox_interval">
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_type">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_type">
|
||||
<property name="text">
|
||||
<string>Type</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox_type">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">Horizontal</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">Vertical</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">Circle</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_direction">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_direction">
|
||||
<property name="text">
|
||||
<string>Direction</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox_direction">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">LeftToRight</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">RightToLeft</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_height">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_height">
|
||||
<property name="text">
|
||||
<string>Height</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBox_height">
|
||||
<property name="maximum">
|
||||
<number>2000</number>
|
||||
<number>10000</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>25</number>
|
||||
<number>10</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_width">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_width">
|
||||
<property name="text">
|
||||
<string>Width</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBox_width">
|
||||
<property name="maximum">
|
||||
<number>2000</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>25</number>
|
||||
<property name="value">
|
||||
<number>60</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -260,7 +207,7 @@
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>GraphicalItem</receiver>
|
||||
<receiver>ExtQuotes</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
@ -276,7 +223,7 @@
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>GraphicalItem</receiver>
|
||||
<receiver>ExtQuotes</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
432
sources/awesomewidgets/extscript.cpp
Normal file
@ -0,0 +1,432 @@
|
||||
/***************************************************************************
|
||||
* 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 <QDebug>
|
||||
#include <QDir>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonParseError>
|
||||
#include <QSettings>
|
||||
#include <QStandardPaths>
|
||||
#include <QTextCodec>
|
||||
|
||||
#include <pdebug/pdebug.h>
|
||||
|
||||
#include "version.h"
|
||||
|
||||
|
||||
ExtScript::ExtScript(QWidget *parent, const QString scriptName,
|
||||
const QStringList directories, const bool debugCmd)
|
||||
: AbstractExtItem(parent, scriptName, directories, debugCmd),
|
||||
debug(debugCmd),
|
||||
ui(new Ui::ExtScript)
|
||||
{
|
||||
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()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
process->kill();
|
||||
delete process;
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
||||
ExtScript *ExtScript::copy(const QString fileName, const int number)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
ExtScript *item = new ExtScript(static_cast<QWidget *>(parent()), fileName,
|
||||
directories(), debug);
|
||||
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
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return m_executable;
|
||||
}
|
||||
|
||||
|
||||
QStringList ExtScript::filters() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return m_filters;
|
||||
}
|
||||
|
||||
|
||||
bool ExtScript::hasOutput() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return m_output;
|
||||
}
|
||||
|
||||
|
||||
QString ExtScript::prefix() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return m_prefix;
|
||||
}
|
||||
|
||||
|
||||
ExtScript::Redirect ExtScript::redirect() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return m_redirect;
|
||||
}
|
||||
|
||||
|
||||
QString ExtScript::uniq() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return m_executable;
|
||||
}
|
||||
|
||||
|
||||
QString ExtScript::strRedirect() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
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)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Executable" << _executable;
|
||||
|
||||
m_executable = _executable;
|
||||
}
|
||||
|
||||
|
||||
void ExtScript::setFilters(const QStringList _filters)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Filters" << _filters;
|
||||
|
||||
foreach(QString filter, _filters)
|
||||
updateFilter(filter);
|
||||
}
|
||||
|
||||
|
||||
void ExtScript::setHasOutput(const bool _state)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "State" << _state;
|
||||
|
||||
m_output = _state;
|
||||
}
|
||||
|
||||
|
||||
void ExtScript::setPrefix(const QString _prefix)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Prefix" << _prefix;
|
||||
|
||||
m_prefix = _prefix;
|
||||
}
|
||||
|
||||
|
||||
void ExtScript::setRedirect(const Redirect _redirect)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Redirect" << _redirect;
|
||||
|
||||
m_redirect = _redirect;
|
||||
}
|
||||
|
||||
|
||||
void ExtScript::setStrRedirect(const QString _redirect)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Redirect" << _redirect;
|
||||
|
||||
if (_redirect == QString("stdout2sdterr"))
|
||||
m_redirect = stdout2stderr;
|
||||
else if (_redirect == QString("stderr2sdtout"))
|
||||
m_redirect = stderr2stdout;
|
||||
else
|
||||
m_redirect = nothing;
|
||||
}
|
||||
|
||||
|
||||
QString ExtScript::applyFilters(QString _value) const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Value" << _value;
|
||||
|
||||
foreach(QString filt, m_filters) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Found filter" << filt;
|
||||
QVariantMap filter = jsonFilters[filt].toMap();
|
||||
if (filter.isEmpty()) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Could not find filter 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)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Filter" << _filter;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Should be added" << _add;
|
||||
|
||||
if (_add) {
|
||||
if (m_filters.contains(_filter)) return;
|
||||
m_filters.append(_filter);
|
||||
} else {
|
||||
m_filters.removeOne(_filter);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ExtScript::readConfiguration()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
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)) {
|
||||
setApiVersion(AWESAPI);
|
||||
writeConfiguration();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ExtScript::readJsonFilters()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QString fileName = QStandardPaths::locate(QStandardPaths::GenericDataLocation,
|
||||
QString("awesomewidgets/scripts/awesomewidgets-extscripts-filters.json"));
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Configuration file" << fileName;
|
||||
QFile jsonFile(fileName);
|
||||
if (!jsonFile.open(QIODevice::ReadOnly | QIODevice::Text))
|
||||
return;
|
||||
QString jsonText = jsonFile.readAll();
|
||||
jsonFile.close();
|
||||
|
||||
QJsonParseError error;
|
||||
QJsonDocument jsonDoc = QJsonDocument::fromJson(jsonText.toUtf8(), &error);
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Json parse error" << error.errorString();
|
||||
if (error.error != QJsonParseError::NoError) return;
|
||||
jsonFilters = jsonDoc.toVariant().toMap();
|
||||
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Filters" << jsonFilters;
|
||||
}
|
||||
|
||||
|
||||
QVariantHash ExtScript::run()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
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);
|
||||
if (debug) qDebug() << PDEBUG << ":" << "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)
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
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
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
AbstractExtItem::writeConfiguration();
|
||||
|
||||
QSettings settings(QString("%1/%2").arg(directories().first()).arg(fileName()), QSettings::IniFormat);
|
||||
if (debug) qDebug() << PDEBUG << ":" << "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()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process->exitCode();
|
||||
QString qdebug = QTextCodec::codecForMib(106)->toUnicode(process->readAllStandardError()).trimmed();
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Error" << qdebug;
|
||||
QString qoutput = QTextCodec::codecForMib(106)->toUnicode(process->readAllStandardOutput()).trimmed();
|
||||
QString strValue;
|
||||
|
||||
switch (m_redirect) {
|
||||
case stdout2stderr:
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Debug" << qdebug;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Output" << qoutput;
|
||||
break;
|
||||
case stderr2stdout:
|
||||
strValue = QString("%1\n%2").arg(qdebug).arg(qoutput);
|
||||
break;
|
||||
case nothing:
|
||||
default:
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Debug" << qdebug;
|
||||
strValue = qoutput;
|
||||
break;
|
||||
}
|
||||
|
||||
// filters
|
||||
value[tag(QString("custom"))] = applyFilters(strValue);
|
||||
}
|
||||
|
||||
|
||||
void ExtScript::translate()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
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"));
|
||||
}
|
@ -18,24 +18,23 @@
|
||||
#ifndef EXTSCRIPT_H
|
||||
#define EXTSCRIPT_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QMap>
|
||||
#include <QProcess>
|
||||
|
||||
#include "abstractextitem.h"
|
||||
|
||||
|
||||
namespace Ui {
|
||||
class ExtScript;
|
||||
class ExtScript;
|
||||
}
|
||||
|
||||
class ExtScript : public QDialog
|
||||
class ExtScript : public AbstractExtItem
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(int apiVersion READ apiVersion WRITE setApiVersion)
|
||||
Q_PROPERTY(QString name READ name WRITE setName)
|
||||
Q_PROPERTY(QString comment READ comment WRITE setComment)
|
||||
Q_PROPERTY(QString executable READ executable WRITE setExecutable)
|
||||
Q_PROPERTY(QString prefix READ prefix WRITE setPrefix)
|
||||
Q_PROPERTY(bool active READ isActive WRITE setActive)
|
||||
Q_PROPERTY(QStringList filters READ filters WRITE setFilters)
|
||||
Q_PROPERTY(bool output READ hasOutput WRITE setHasOutput)
|
||||
Q_PROPERTY(int interval READ interval WRITE setInterval)
|
||||
Q_PROPERTY(QString prefix READ prefix WRITE setPrefix)
|
||||
Q_PROPERTY(Redirect redirect READ redirect WRITE setRedirect)
|
||||
|
||||
public:
|
||||
@ -45,57 +44,57 @@ public:
|
||||
stderr2stdout
|
||||
};
|
||||
|
||||
explicit ExtScript(QWidget *parent = 0, const QString scriptName = QString(),
|
||||
const QStringList directories = QStringList(), const bool debugCmd = false);
|
||||
explicit ExtScript(QWidget *parent = nullptr, const QString scriptName = QString(),
|
||||
const QStringList directories = QStringList(),
|
||||
const bool debugCmd = false);
|
||||
~ExtScript();
|
||||
ExtScript *copy(const QString fileName, const int number);
|
||||
// get methods
|
||||
int apiVersion();
|
||||
QString comment();
|
||||
QString executable();
|
||||
QString fileName();
|
||||
int interval();
|
||||
QString name();
|
||||
QString prefix();
|
||||
Redirect redirect();
|
||||
QString strRedirect();
|
||||
bool hasOutput();
|
||||
bool isActive();
|
||||
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 setApiVersion(const int _apiVersion = 0);
|
||||
void setActive(const bool _state = true);
|
||||
void setComment(const QString _comment = QString("empty"));
|
||||
void setExecutable(const QString _executable = QString("/usr/bin/true"));
|
||||
void setFilters(const QStringList _filters = QStringList());
|
||||
void setHasOutput(const bool _state = true);
|
||||
void setInterval(const int _interval = 1);
|
||||
void setName(const QString _name = QString("none"));
|
||||
void setPrefix(const QString _prefix = QString(""));
|
||||
void setRedirect(const Redirect _redirect = nothing);
|
||||
void setStrRedirect(const QString _redirect = QString("nothing"));
|
||||
// filters
|
||||
QString applyFilters(QString _value) const;
|
||||
void updateFilter(const QString _filter, const bool _add = true);
|
||||
|
||||
public slots:
|
||||
void readConfiguration();
|
||||
QString run();
|
||||
int showConfiguration();
|
||||
int tryDelete();
|
||||
void writeConfiguration();
|
||||
void readJsonFilters();
|
||||
QVariantHash run();
|
||||
int showConfiguration(const QVariant args = QVariant());
|
||||
void writeConfiguration() const;
|
||||
|
||||
private slots:
|
||||
void updateValue();
|
||||
|
||||
private:
|
||||
QString m_fileName;
|
||||
QStringList m_dirs;
|
||||
bool debug;
|
||||
QProcess *process = nullptr;
|
||||
Ui::ExtScript *ui;
|
||||
void translate();
|
||||
// properties
|
||||
int m_apiVersion = 0;
|
||||
bool m_active = true;
|
||||
QString m_comment = QString("empty");
|
||||
QString m_executable = QString("/usr/bin/true");
|
||||
int m_interval = 1;
|
||||
QString m_name = QString("none");
|
||||
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;
|
||||
QString value = QString();
|
||||
QVariantHash value;
|
||||
};
|
||||
|
||||
|
406
sources/awesomewidgets/extscript.ui
Normal 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>
|
230
sources/awesomewidgets/extupgrade.cpp
Normal file
@ -0,0 +1,230 @@
|
||||
/***************************************************************************
|
||||
* 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 <QDebug>
|
||||
#include <QDir>
|
||||
#include <QSettings>
|
||||
#include <QTextCodec>
|
||||
|
||||
#include <pdebug/pdebug.h>
|
||||
|
||||
#include "version.h"
|
||||
|
||||
|
||||
ExtUpgrade::ExtUpgrade(QWidget *parent, const QString upgradeName,
|
||||
const QStringList directories, const bool debugCmd)
|
||||
: AbstractExtItem(parent, upgradeName, directories, debugCmd),
|
||||
debug(debugCmd),
|
||||
ui(new Ui::ExtUpgrade)
|
||||
{
|
||||
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()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
process->kill();
|
||||
delete process;
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
||||
ExtUpgrade *ExtUpgrade::copy(const QString fileName, const int number)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
ExtUpgrade *item = new ExtUpgrade(static_cast<QWidget *>(parent()), fileName,
|
||||
directories(), debug);
|
||||
item->setActive(isActive());
|
||||
item->setApiVersion(apiVersion());
|
||||
item->setComment(comment());
|
||||
item->setExecutable(executable());
|
||||
item->setInterval(interval());
|
||||
item->setName(name());
|
||||
item->setNumber(number);
|
||||
item->setNull(null());
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
|
||||
QString ExtUpgrade::executable() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return m_executable;
|
||||
}
|
||||
|
||||
|
||||
int ExtUpgrade::null() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return m_null;
|
||||
}
|
||||
|
||||
|
||||
QString ExtUpgrade::uniq() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return m_executable;
|
||||
}
|
||||
|
||||
|
||||
void ExtUpgrade::setExecutable(const QString _executable)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Executable" << _executable;
|
||||
|
||||
m_executable = _executable;
|
||||
}
|
||||
|
||||
|
||||
void ExtUpgrade::setNull(const int _null)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Null lines" << _null;
|
||||
if (_null < 0) return;
|
||||
|
||||
m_null = _null;
|
||||
}
|
||||
|
||||
|
||||
void ExtUpgrade::readConfiguration()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
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());
|
||||
settings.endGroup();
|
||||
}
|
||||
|
||||
// update for current API
|
||||
if ((apiVersion() > 0) && (apiVersion() < AWEUAPI)) {
|
||||
setApiVersion(AWEUAPI);
|
||||
writeConfiguration();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QVariantHash ExtUpgrade::run()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (!isActive()) return value;
|
||||
|
||||
if ((times == 1) && (process->state() == QProcess::NotRunning))
|
||||
process->start(QString("sh -c \"%1\"").arg(m_executable));
|
||||
else if (times >= interval())
|
||||
times = 0;
|
||||
times++;
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
int ExtUpgrade::showConfiguration(const QVariant args)
|
||||
{
|
||||
Q_UNUSED(args)
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
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->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());
|
||||
setActive(ui->checkBox_active->checkState() == Qt::Checked);
|
||||
setNull(ui->spinBox_null->value());
|
||||
setInterval(ui->spinBox_interval->value());
|
||||
|
||||
writeConfiguration();
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
void ExtUpgrade::writeConfiguration() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
AbstractExtItem::writeConfiguration();
|
||||
|
||||
QSettings settings(QString("%1/%2").arg(directories().first()).arg(fileName()), QSettings::IniFormat);
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Configuration file" << settings.fileName();
|
||||
|
||||
settings.beginGroup(QString("Desktop Entry"));
|
||||
settings.setValue(QString("Exec"), m_executable);
|
||||
settings.setValue(QString("X-AW-Null"), m_null);
|
||||
settings.endGroup();
|
||||
|
||||
settings.sync();
|
||||
}
|
||||
|
||||
|
||||
void ExtUpgrade::updateValue()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process->exitCode();
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Error" << process->readAllStandardError();
|
||||
|
||||
QString qoutput = QTextCodec::codecForMib(106)->toUnicode(process->readAllStandardOutput()).trimmed();
|
||||
value[tag(QString("pkgcount"))] = qoutput.split(QChar('\n'), QString::SkipEmptyParts).count() - m_null;
|
||||
}
|
||||
|
||||
|
||||
void ExtUpgrade::translate()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
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->checkBox_active->setText(i18n("Active"));
|
||||
ui->label_null->setText(i18n("Null"));
|
||||
ui->label_interval->setText(i18n("Interval"));
|
||||
}
|
@ -18,68 +18,55 @@
|
||||
#ifndef EXTUPGRADE_H
|
||||
#define EXTUPGRADE_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QProcess>
|
||||
|
||||
#include "abstractextitem.h"
|
||||
|
||||
|
||||
namespace Ui {
|
||||
class ExtUpgrade;
|
||||
class ExtUpgrade;
|
||||
}
|
||||
|
||||
class ExtUpgrade : public QDialog
|
||||
class ExtUpgrade : public AbstractExtItem
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(int apiVersion READ apiVersion WRITE setApiVersion)
|
||||
Q_PROPERTY(QString name READ name WRITE setName)
|
||||
Q_PROPERTY(QString comment READ comment WRITE setComment)
|
||||
Q_PROPERTY(QString executable READ executable WRITE setExecutable)
|
||||
Q_PROPERTY(int null READ null WRITE setNull)
|
||||
Q_PROPERTY(bool active READ isActive WRITE setActive)
|
||||
Q_PROPERTY(int interval READ interval WRITE setInterval)
|
||||
|
||||
public:
|
||||
explicit ExtUpgrade(QWidget *parent = 0, const QString upgradeName = QString(),
|
||||
const QStringList directories = QStringList(), const bool debugCmd = false);
|
||||
explicit ExtUpgrade(QWidget *parent = nullptr, const QString upgradeName = QString(),
|
||||
const QStringList directories = QStringList(),
|
||||
const bool debugCmd = false);
|
||||
~ExtUpgrade();
|
||||
ExtUpgrade *copy(const QString fileName, const int number);
|
||||
// get methods
|
||||
int apiVersion();
|
||||
QString comment();
|
||||
QString executable();
|
||||
QString fileName();
|
||||
int interval();
|
||||
QString name();
|
||||
int null();
|
||||
bool isActive();
|
||||
QString executable() const;
|
||||
int null() const;
|
||||
QString uniq() const;
|
||||
// set methods
|
||||
void setApiVersion(const int _apiVersion = 0);
|
||||
void setActive(const bool _state = true);
|
||||
void setComment(const QString _comment = QString("empty"));
|
||||
void setExecutable(const QString _executable = QString("/usr/bin/true"));
|
||||
void setName(const QString _name = QString("none"));
|
||||
void setNull(const int _null = 0);
|
||||
void setInterval(const int _interval = 0);
|
||||
|
||||
public slots:
|
||||
void readConfiguration();
|
||||
int run();
|
||||
int showConfiguration();
|
||||
int tryDelete();
|
||||
void writeConfiguration();
|
||||
QVariantHash run();
|
||||
int showConfiguration(const QVariant args = QVariant());
|
||||
void writeConfiguration() const;
|
||||
|
||||
private slots:
|
||||
void updateValue();
|
||||
|
||||
private:
|
||||
QString m_fileName;
|
||||
QStringList m_dirs;
|
||||
bool debug;
|
||||
QProcess *process = nullptr;
|
||||
Ui::ExtUpgrade *ui;
|
||||
void translate();
|
||||
// properties
|
||||
int m_apiVersion = 0;
|
||||
bool m_active = true;
|
||||
QString m_comment = QString("empty");
|
||||
QString m_executable = QString("/usr/bin/true");
|
||||
QString m_name = QString("none");
|
||||
int m_null = 0;
|
||||
int m_interval = 3600;
|
||||
// internal properties
|
||||
int times = 0;
|
||||
int value = 0;
|
||||
QVariantHash value;
|
||||
};
|
||||
|
||||
|
@ -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>
|
429
sources/awesomewidgets/extweather.cpp
Normal file
@ -0,0 +1,429 @@
|
||||
/***************************************************************************
|
||||
* 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 <QDebug>
|
||||
#include <QDir>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonParseError>
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QNetworkRequest>
|
||||
#include <QSettings>
|
||||
|
||||
#include <pdebug/pdebug.h>
|
||||
#include <qreplytimeout/qreplytimeout.h>
|
||||
|
||||
#include "version.h"
|
||||
|
||||
|
||||
ExtWeather::ExtWeather(QWidget *parent, const QString weatherName,
|
||||
const QStringList directories, const bool debugCmd)
|
||||
: AbstractExtItem(parent, weatherName, directories, debugCmd),
|
||||
debug(debugCmd),
|
||||
ui(new Ui::ExtWeather)
|
||||
{
|
||||
readConfiguration();
|
||||
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()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
disconnect(manager, SIGNAL(finished(QNetworkReply *)),
|
||||
this, SLOT(weatherReplyReceived(QNetworkReply *)));
|
||||
|
||||
delete manager;
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
||||
ExtWeather *ExtWeather::copy(const QString fileName, const int number)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
ExtWeather *item = new ExtWeather(static_cast<QWidget *>(parent()), fileName,
|
||||
directories(), debug);
|
||||
item->setActive(isActive());
|
||||
item->setApiVersion(apiVersion());
|
||||
item->setCity(city());
|
||||
item->setComment(comment());
|
||||
item->setCountry(country());
|
||||
item->setInterval(interval());
|
||||
item->setName(name());
|
||||
item->setNumber(number);
|
||||
item->setTs(ts());
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
|
||||
QString ExtWeather::weatherFromInt(const int _id) const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "ID" << _id;
|
||||
// refer to http://openweathermap.org/weather-conditions
|
||||
|
||||
QString weather;
|
||||
switch (_id) {
|
||||
case 800:
|
||||
// 01d
|
||||
weather = QString("\u2600");
|
||||
break;
|
||||
case 801:
|
||||
// 02d
|
||||
weather = QString("\u26C5");
|
||||
break;
|
||||
case 802:
|
||||
case 803:
|
||||
// 03d
|
||||
weather = QString("\u2601");
|
||||
break;
|
||||
case 804:
|
||||
// 04d
|
||||
weather = QString("\u2601");
|
||||
break;
|
||||
case 300:
|
||||
case 301:
|
||||
case 302:
|
||||
case 310:
|
||||
case 311:
|
||||
case 312:
|
||||
case 313:
|
||||
case 314:
|
||||
case 321:
|
||||
case 520:
|
||||
case 521:
|
||||
case 522:
|
||||
case 531:
|
||||
// 09d
|
||||
weather = QString("\u2602");
|
||||
break;
|
||||
case 500:
|
||||
case 501:
|
||||
case 502:
|
||||
case 503:
|
||||
case 504:
|
||||
// 10d
|
||||
weather = QString("\u2614");
|
||||
break;
|
||||
case 200:
|
||||
case 201:
|
||||
case 202:
|
||||
case 210:
|
||||
case 211:
|
||||
case 212:
|
||||
case 221:
|
||||
case 230:
|
||||
case 231:
|
||||
case 232:
|
||||
// 11d
|
||||
weather = QString("\u2608");
|
||||
break;
|
||||
case 511:
|
||||
case 600:
|
||||
case 601:
|
||||
case 602:
|
||||
case 611:
|
||||
case 612:
|
||||
case 615:
|
||||
case 616:
|
||||
case 620:
|
||||
case 621:
|
||||
case 622:
|
||||
// 13d
|
||||
weather = QString("\u2603");
|
||||
// weather = QString("\u26C4");
|
||||
break;
|
||||
case 701:
|
||||
case 711:
|
||||
case 721:
|
||||
case 731:
|
||||
case 741:
|
||||
case 751:
|
||||
case 761:
|
||||
case 762:
|
||||
case 771:
|
||||
case 781:
|
||||
// 50d
|
||||
weather = QString("\u26C5");
|
||||
break;
|
||||
default:
|
||||
// extreme other conditions
|
||||
weather = QString("\u2604");
|
||||
break;
|
||||
}
|
||||
|
||||
return weather;
|
||||
}
|
||||
|
||||
|
||||
QString ExtWeather::city() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return m_city;
|
||||
}
|
||||
|
||||
|
||||
QString ExtWeather::country() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return m_country;
|
||||
}
|
||||
|
||||
|
||||
int ExtWeather::ts() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return m_ts;
|
||||
}
|
||||
|
||||
|
||||
QString ExtWeather::uniq() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return QString("%1 (%2) at %3").arg(m_city).arg(m_country).arg(m_ts);
|
||||
}
|
||||
|
||||
|
||||
void ExtWeather::setCity(const QString _city)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "City" << _city;
|
||||
|
||||
m_city = _city;
|
||||
}
|
||||
|
||||
|
||||
void ExtWeather::setCountry(const QString _country)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Country" << _country;
|
||||
|
||||
m_country = _country;
|
||||
}
|
||||
|
||||
|
||||
void ExtWeather::setTs(const int _ts)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Timestamp" << _ts;
|
||||
|
||||
m_ts = _ts;
|
||||
}
|
||||
|
||||
|
||||
void ExtWeather::readConfiguration()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
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());
|
||||
settings.endGroup();
|
||||
}
|
||||
|
||||
// update for current API
|
||||
if ((apiVersion() > 0) && (apiVersion() < AWEWAPI)) {
|
||||
setApiVersion(AWEWAPI);
|
||||
writeConfiguration();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QVariantHash ExtWeather::run()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if ((!isActive()) || (isRunning)) return values;
|
||||
|
||||
if (times == 1) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "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)
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
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_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());
|
||||
setActive(ui->checkBox_active->checkState() == Qt::Checked);
|
||||
setInterval(ui->spinBox_interval->value());
|
||||
|
||||
writeConfiguration();
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
void ExtWeather::writeConfiguration() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
AbstractExtItem::writeConfiguration();
|
||||
|
||||
QSettings settings(QString("%1/%2").arg(directories().first()).arg(fileName()), QSettings::IniFormat);
|
||||
if (debug) qDebug() << PDEBUG << ":" << "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-TS"), m_ts);
|
||||
settings.endGroup();
|
||||
|
||||
settings.sync();
|
||||
}
|
||||
|
||||
|
||||
void ExtWeather::weatherReplyReceived(QNetworkReply *reply)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Return code" << reply->error();
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Reply error message" << reply->errorString();
|
||||
|
||||
isRunning = false;
|
||||
QJsonParseError error;
|
||||
QJsonDocument jsonDoc = QJsonDocument::fromJson(reply->readAll(), &error);
|
||||
reply->deleteLater();
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Json parse error" << error.errorString();
|
||||
if ((reply->error() != QNetworkReply::NoError) ||
|
||||
(error.error != QJsonParseError::NoError)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// convert to map
|
||||
QVariantMap json = jsonDoc.toVariant().toMap();
|
||||
if (json[QString("cod")].toInt() != 200) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "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
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
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()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
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_active->setText(i18n("Active"));
|
||||
ui->label_interval->setText(i18n("Interval"));
|
||||
}
|
||||
|
||||
|
||||
QString ExtWeather::url(const bool isForecast) const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << "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);
|
||||
if (debug) qDebug() << PDEBUG << ":" << "API url" << apiUrl;
|
||||
|
||||
return apiUrl;
|
||||
}
|
85
sources/awesomewidgets/extweather.h
Normal file
@ -0,0 +1,85 @@
|
||||
/***************************************************************************
|
||||
* 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(int ts READ ts WRITE setTs)
|
||||
|
||||
public:
|
||||
explicit ExtWeather(QWidget *parent = nullptr, const QString weatherName = QString(),
|
||||
const QStringList directories = QStringList(),
|
||||
const bool debugCmd = false);
|
||||
~ExtWeather();
|
||||
ExtWeather *copy(const QString fileName, const int number);
|
||||
QString weatherFromInt(const int _id) const;
|
||||
// get methods
|
||||
QString city() const;
|
||||
QString country() const;
|
||||
int ts() const;
|
||||
QString uniq() const;
|
||||
// set methods
|
||||
void setCity(const QString _city = QString("London"));
|
||||
void setCountry(const QString _country = QString("uk"));
|
||||
void setTs(const int _ts = 0);
|
||||
|
||||
public slots:
|
||||
void readConfiguration();
|
||||
QVariantHash run();
|
||||
int showConfiguration(const QVariant args = QVariant());
|
||||
void writeConfiguration() const;
|
||||
|
||||
private slots:
|
||||
void weatherReplyReceived(QNetworkReply *reply);
|
||||
|
||||
private:
|
||||
bool debug;
|
||||
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");
|
||||
int m_ts = 0;
|
||||
// values
|
||||
int times = 0;
|
||||
QVariantHash values;
|
||||
};
|
||||
|
||||
|
||||
#endif /* EXTWEATHER_H */
|
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ExtScript</class>
|
||||
<widget class="QDialog" name="ExtScript">
|
||||
<class>ExtWeather</class>
|
||||
<widget class="QDialog" name="ExtWeather">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
@ -61,17 +61,11 @@
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_command">
|
||||
<layout class="QHBoxLayout" name="layout_number">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_command">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<widget class="QLabel" name="label_number">
|
||||
<property name="text">
|
||||
<string>Command</string>
|
||||
<string>Tag</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
@ -79,14 +73,18 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_command"/>
|
||||
<widget class="QLabel" name="label_numberValue">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_prefix">
|
||||
<layout class="QHBoxLayout" name="layout_city">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_prefix">
|
||||
<widget class="QLabel" name="label_city">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
@ -94,7 +92,7 @@
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Prefix</string>
|
||||
<string>City</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
@ -102,7 +100,51 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_prefix"/>
|
||||
<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>
|
||||
@ -136,69 +178,6 @@
|
||||
</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>
|
||||
@ -216,6 +195,15 @@
|
||||
<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>
|
||||
@ -250,7 +238,7 @@
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>ExtScript</receiver>
|
||||
<receiver>ExtWeather</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
@ -266,7 +254,7 @@
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>ExtScript</receiver>
|
||||
<receiver>ExtWeather</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
@ -34,16 +34,16 @@
|
||||
#include "version.h"
|
||||
|
||||
|
||||
GraphicalItem::GraphicalItem(QWidget *parent, const QString desktopName, const QStringList directories, const bool debugCmd)
|
||||
: QDialog(parent),
|
||||
m_fileName(desktopName),
|
||||
m_dirs(directories),
|
||||
GraphicalItem::GraphicalItem(QWidget *parent, const QString desktopName,
|
||||
const QStringList directories, const bool debugCmd)
|
||||
: AbstractExtItem(parent, desktopName, directories, debugCmd),
|
||||
debug(debugCmd),
|
||||
ui(new Ui::GraphicalItem)
|
||||
{
|
||||
readConfiguration();
|
||||
|
||||
ui->setupUi(this);
|
||||
translate();
|
||||
|
||||
connect(ui->pushButton_activeColor, SIGNAL(clicked()), this, SLOT(changeColor()));
|
||||
connect(ui->pushButton_inactiveColor, SIGNAL(clicked()), this, SLOT(changeColor()));
|
||||
}
|
||||
@ -57,7 +57,31 @@ GraphicalItem::~GraphicalItem()
|
||||
}
|
||||
|
||||
|
||||
QString GraphicalItem::image(const float value)
|
||||
GraphicalItem *GraphicalItem::copy(const QString fileName, const int number)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
GraphicalItem *item = new GraphicalItem(static_cast<QWidget *>(parent()),
|
||||
fileName, directories(), debug);
|
||||
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
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Value" << value;
|
||||
@ -137,39 +161,7 @@ QString GraphicalItem::image(const float value)
|
||||
}
|
||||
|
||||
|
||||
QString GraphicalItem::fileName()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return m_fileName;
|
||||
}
|
||||
|
||||
|
||||
int GraphicalItem::apiVersion()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return m_apiVersion;
|
||||
}
|
||||
|
||||
|
||||
QString GraphicalItem::name()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return m_name;
|
||||
}
|
||||
|
||||
|
||||
QString GraphicalItem::comment()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return m_comment;
|
||||
}
|
||||
|
||||
|
||||
QString GraphicalItem::bar()
|
||||
QString GraphicalItem::bar() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
@ -177,7 +169,7 @@ QString GraphicalItem::bar()
|
||||
}
|
||||
|
||||
|
||||
QString GraphicalItem::activeColor()
|
||||
QString GraphicalItem::activeColor() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
@ -185,7 +177,7 @@ QString GraphicalItem::activeColor()
|
||||
}
|
||||
|
||||
|
||||
QString GraphicalItem::inactiveColor()
|
||||
QString GraphicalItem::inactiveColor() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
@ -193,7 +185,7 @@ QString GraphicalItem::inactiveColor()
|
||||
}
|
||||
|
||||
|
||||
GraphicalItem::Type GraphicalItem::type()
|
||||
GraphicalItem::Type GraphicalItem::type() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
@ -201,7 +193,7 @@ GraphicalItem::Type GraphicalItem::type()
|
||||
}
|
||||
|
||||
|
||||
QString GraphicalItem::strType()
|
||||
QString GraphicalItem::strType() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
@ -222,7 +214,7 @@ QString GraphicalItem::strType()
|
||||
}
|
||||
|
||||
|
||||
GraphicalItem::Direction GraphicalItem::direction()
|
||||
GraphicalItem::Direction GraphicalItem::direction() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
@ -230,7 +222,7 @@ GraphicalItem::Direction GraphicalItem::direction()
|
||||
}
|
||||
|
||||
|
||||
QString GraphicalItem::strDirection()
|
||||
QString GraphicalItem::strDirection() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
@ -248,7 +240,7 @@ QString GraphicalItem::strDirection()
|
||||
}
|
||||
|
||||
|
||||
int GraphicalItem::height()
|
||||
int GraphicalItem::height() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
@ -256,7 +248,7 @@ int GraphicalItem::height()
|
||||
}
|
||||
|
||||
|
||||
int GraphicalItem::width()
|
||||
int GraphicalItem::width() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
@ -264,30 +256,11 @@ int GraphicalItem::width()
|
||||
}
|
||||
|
||||
|
||||
void GraphicalItem::setApiVersion(const int _apiVersion)
|
||||
QString GraphicalItem::uniq() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Version" << _apiVersion;
|
||||
|
||||
m_apiVersion = _apiVersion;
|
||||
}
|
||||
|
||||
|
||||
void GraphicalItem::setName(const QString _name)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Name" << _name;
|
||||
|
||||
m_name = _name;
|
||||
}
|
||||
|
||||
|
||||
void GraphicalItem::setComment(const QString _comment)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Comment" << _comment;
|
||||
|
||||
m_comment = _comment;
|
||||
return m_bar;
|
||||
}
|
||||
|
||||
|
||||
@ -393,15 +366,13 @@ void GraphicalItem::setWidth(const int _width)
|
||||
void GraphicalItem::readConfiguration()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
AbstractExtItem::readConfiguration();
|
||||
|
||||
for (int i=m_dirs.count()-1; i>=0; i--) {
|
||||
if (!QDir(m_dirs[i]).entryList(QDir::Files).contains(m_fileName)) continue;
|
||||
QSettings settings(m_dirs[i] + QDir::separator() + m_fileName, QSettings::IniFormat);
|
||||
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"));
|
||||
setName(settings.value(QString("Name"), m_name).toString());
|
||||
setComment(settings.value(QString("Comment"), m_comment).toString());
|
||||
setApiVersion(settings.value(QString("X-AW-ApiVersion"), AWGIAPI).toInt());
|
||||
setBar(settings.value(QString("X-AW-Value"), m_bar).toString());
|
||||
setActiveColor(settings.value(QString("X-AW-ActiveColor"), m_activeColor).toString());
|
||||
setInactiveColor(settings.value(QString("X-AW-InactiveColor"), m_inactiveColor).toString());
|
||||
@ -409,17 +380,35 @@ void GraphicalItem::readConfiguration()
|
||||
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)) {
|
||||
setApiVersion(AWGIAPI);
|
||||
writeConfiguration();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int GraphicalItem::showConfiguration(const QStringList tags)
|
||||
QVariantHash GraphicalItem::run()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
ui->label_nameValue->setText(m_name);
|
||||
ui->lineEdit_comment->setText(m_comment);
|
||||
// required by abstract class
|
||||
return QVariantHash();
|
||||
}
|
||||
|
||||
|
||||
int GraphicalItem::showConfiguration(const QVariant args)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
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);
|
||||
@ -449,33 +438,15 @@ int GraphicalItem::showConfiguration(const QStringList tags)
|
||||
}
|
||||
|
||||
|
||||
int GraphicalItem::tryDelete()
|
||||
void GraphicalItem::writeConfiguration() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
AbstractExtItem::writeConfiguration();
|
||||
|
||||
for (int i=0; i<m_dirs.count(); i++)
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Remove file" << m_dirs[i] + QDir::separator() + m_fileName <<
|
||||
QFile::remove(m_dirs[i] + QDir::separator() + m_fileName);
|
||||
|
||||
// check if exists
|
||||
for (int i=0; i<m_dirs.count(); i++)
|
||||
if (QFile::exists(m_dirs[i] + QDir::separator() + m_fileName)) return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
void GraphicalItem::writeConfiguration()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QSettings settings(m_dirs[0] + QDir::separator() + m_fileName, QSettings::IniFormat);
|
||||
QSettings settings(QString("%1/%2").arg(directories().first()).arg(fileName()), QSettings::IniFormat);
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Configuration file" << settings.fileName();
|
||||
|
||||
settings.beginGroup(QString("Desktop Entry"));
|
||||
settings.setValue(QString("Encoding"), QString("UTF-8"));
|
||||
settings.setValue(QString("Name"), m_name);
|
||||
settings.setValue(QString("Comment"), m_comment);
|
||||
settings.setValue(QString("X-AW-ApiVersion"), m_apiVersion);
|
||||
settings.setValue(QString("X-AW-Value"), m_bar);
|
||||
settings.setValue(QString("X-AW-ActiveColor"), m_activeColor);
|
||||
settings.setValue(QString("X-AW-InactiveColor"), m_inactiveColor);
|
||||
@ -493,8 +464,8 @@ void GraphicalItem::changeColor()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QColor color = stringToColor(((QPushButton *)sender())->text());
|
||||
QColor newColor = QColorDialog::getColor(color, 0, i18n("Select color"),
|
||||
QColor color = stringToColor((static_cast<QPushButton *>(sender()))->text());
|
||||
QColor newColor = QColorDialog::getColor(color, this, tr("Select color"),
|
||||
QColorDialog::ShowAlphaChannel);
|
||||
if (!newColor.isValid()) return;
|
||||
|
||||
@ -503,11 +474,11 @@ void GraphicalItem::changeColor()
|
||||
colorText.append(QString("%1").arg(newColor.green()));
|
||||
colorText.append(QString("%1").arg(newColor.blue()));
|
||||
colorText.append(QString("%1").arg(newColor.alpha()));
|
||||
dynamic_cast<QPushButton *>(sender())->setText(colorText.join(QChar(',')));
|
||||
static_cast<QPushButton *>(sender())->setText(colorText.join(QChar(',')));
|
||||
}
|
||||
|
||||
|
||||
QColor GraphicalItem::stringToColor(const QString _color)
|
||||
QColor GraphicalItem::stringToColor(const QString _color) const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Color" << _color;
|
||||
@ -516,10 +487,26 @@ QColor GraphicalItem::stringToColor(const QString _color)
|
||||
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());
|
||||
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()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
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"));
|
||||
}
|
@ -19,19 +19,17 @@
|
||||
#define GRAPHICALITEM_H
|
||||
|
||||
#include <QColor>
|
||||
#include <QDialog>
|
||||
|
||||
#include "abstractextitem.h"
|
||||
|
||||
|
||||
namespace Ui {
|
||||
class GraphicalItem;
|
||||
class GraphicalItem;
|
||||
}
|
||||
|
||||
class GraphicalItem : public QDialog
|
||||
class GraphicalItem : public AbstractExtItem
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(int apiVersion READ apiVersion WRITE setApiVersion)
|
||||
Q_PROPERTY(QString name READ name WRITE setName)
|
||||
Q_PROPERTY(QString comment READ comment WRITE setComment)
|
||||
Q_PROPERTY(QString bar READ bar WRITE setBar)
|
||||
Q_PROPERTY(QString activeColor READ activeColor WRITE setActiveColor)
|
||||
Q_PROPERTY(QString inactiveColor READ inactiveColor WRITE setInactiveColor)
|
||||
@ -51,28 +49,24 @@ public:
|
||||
Circle
|
||||
};
|
||||
|
||||
explicit GraphicalItem(QWidget *parent = 0, const QString desktopName = QString(),
|
||||
const QStringList directories = QStringList(), const bool debugCmd = false);
|
||||
explicit GraphicalItem(QWidget *parent = nullptr, const QString desktopName = QString(),
|
||||
const QStringList directories = QStringList(),
|
||||
const bool debugCmd = false);
|
||||
~GraphicalItem();
|
||||
QString fileName();
|
||||
QString image(const float value);
|
||||
GraphicalItem *copy(const QString fileName, const int number);
|
||||
QString image(const float value) const;
|
||||
// get methods
|
||||
int apiVersion();
|
||||
QString name();
|
||||
QString comment();
|
||||
QString bar();
|
||||
QString activeColor();
|
||||
QString inactiveColor();
|
||||
Type type();
|
||||
QString strType();
|
||||
Direction direction();
|
||||
QString strDirection();
|
||||
int height();
|
||||
int width();
|
||||
QString bar() const;
|
||||
QString activeColor() const;
|
||||
QString inactiveColor() 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 setApiVersion(const int _apiVersion = 0);
|
||||
void setName(const QString _name = QString("none"));
|
||||
void setComment(const QString _comment = QString("empty"));
|
||||
void setBar(const QString _bar = QString("cpu"));
|
||||
void setActiveColor(const QString _color = QString("0,0,0,130"));
|
||||
void setInactiveColor(const QString _color = QString("255,255,255,130"));
|
||||
@ -85,19 +79,20 @@ public:
|
||||
|
||||
public slots:
|
||||
void readConfiguration();
|
||||
int showConfiguration(const QStringList tags = QStringList());
|
||||
int tryDelete();
|
||||
void writeConfiguration();
|
||||
QVariantHash run();
|
||||
int showConfiguration(const QVariant args = QVariant());
|
||||
void writeConfiguration() const;
|
||||
|
||||
private slots:
|
||||
void changeColor();
|
||||
|
||||
private:
|
||||
QColor stringToColor(const QString _color);
|
||||
QString m_fileName;
|
||||
QStringList m_dirs;
|
||||
bool debug;
|
||||
Ui::GraphicalItem *ui;
|
||||
QColor stringToColor(const QString _color) const;
|
||||
void translate();
|
||||
// properties
|
||||
int m_apiVersion = 0;
|
||||
QString m_name = QString("none");
|