Compare commits
90 Commits
V.2.2.2
...
release-2.
Author | SHA1 | Date | |
---|---|---|---|
ae4e7deddd | |||
be26033ff7 | |||
70020d0aef | |||
7218defe19 | |||
200ecc7196 | |||
6689bea9a7 | |||
5940ec4531 | |||
2716f77eb2 | |||
cfdcaae036 | |||
82c1839634 | |||
08dae3b02b | |||
cc2b1b7b8a | |||
4c27382467 | |||
aacb50c946 | |||
466faf53fa | |||
8228d1d06b | |||
37726370ee | |||
07305d7578 | |||
b97c821c8f | |||
b50c1d2363 | |||
713aa611d9 | |||
319755179f | |||
9509d87962 | |||
6d58a3f05c | |||
2cca290630 | |||
29b75e2b12 | |||
835eb00f0d | |||
a5e9b32b28 | |||
fbdc9112aa | |||
b3fc0501ba | |||
a74c65a2a3 | |||
4858c9dbcd | |||
3601b4246d | |||
241e13ffd8 | |||
7a5d2d5dd4 | |||
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 |
3
.gitmodules
vendored
@ -1,6 +1,3 @@
|
|||||||
[submodule "sources/3rdparty/pdebug"]
|
|
||||||
path = sources/3rdparty/pdebug
|
|
||||||
url = https://github.com/arcan1s/qtadds-pdebug.git
|
|
||||||
[submodule "sources/3rdparty/task"]
|
[submodule "sources/3rdparty/task"]
|
||||||
path = sources/3rdparty/task
|
path = sources/3rdparty/task
|
||||||
url = https://github.com/arcan1s/qtadds-taskadds-qprocess.git
|
url = https://github.com/arcan1s/qtadds-taskadds-qprocess.git
|
||||||
|
11
.travis.yml.bckp
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
install:
|
||||||
|
- sudo apt-get update -qq
|
||||||
|
- sudo apt-get install -y cmake extra-cmake-modules g++ git libkf5i18n-dev libkf5notifications-dev libkf5service-dev libkf5windowsystem-dev plasma-framework-dev qtbase5-dev qtdeclarative5-dev
|
||||||
|
- git submobule update --init
|
||||||
|
- rm -rf build
|
||||||
|
- mkdir build
|
||||||
|
|
||||||
|
script:
|
||||||
|
- cd build
|
||||||
|
- cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release -DKDE_INSTALL_USE_QT_SYS_PATHS=ON ../sources
|
||||||
|
- make
|
57
CHANGELOG
@ -1,16 +1,69 @@
|
|||||||
|
+ add tags upunits, downunits
|
||||||
|
- fix warning for empty tooltip image
|
||||||
|
|
||||||
|
Ver.2.4.0:
|
||||||
|
+ add support of weather items
|
||||||
|
+ add support of load average (la1, la5, la15 tags)
|
||||||
|
+ add "drop key cache" button
|
||||||
|
+ add support of clang building
|
||||||
|
+ create ExtItems aggregator
|
||||||
|
+ add time to debug information
|
||||||
|
+ add ability to disable player monitor
|
||||||
|
- fix bug with invalid network data calculation
|
||||||
|
- fix warning with fond dialog init
|
||||||
|
- fix bug with no object deletions (#60)
|
||||||
|
* rewrite ExtItems to use own abstract class
|
||||||
|
* improve work with data updating (#57)
|
||||||
|
* move to signal-slot interface painting
|
||||||
|
* move plugin part back to private
|
||||||
|
* cast plugin as type, not signleton (#57)
|
||||||
|
* change logic in data building inside DataEngine
|
||||||
|
* edit build and drop different DataEngine packaging
|
||||||
|
* rewrite QMap to QHash if possible
|
||||||
|
* rewrite to use iterators if possible
|
||||||
|
* list of desktops is now represented as QStringList
|
||||||
|
* refactoring
|
||||||
|
|
||||||
|
Ver.2.3.3:
|
||||||
|
* change text rendering from Qt to native
|
||||||
|
|
||||||
|
Ver.2.3.2:
|
||||||
|
+ change network speed units from KB/s to MB/s if value is more than 1000 KB/s (metrics are the same)
|
||||||
|
- fix bug with no actions on link activation (thanks to infans)
|
||||||
|
* improve quotes support, e.g. fix plasma crash
|
||||||
|
* rewrite main widget to signal-slot update model
|
||||||
|
* improve battery calculation for system which has several batteries
|
||||||
|
|
||||||
|
Ver.2.3.1:
|
||||||
|
- fix bug with no updates from configuration UI
|
||||||
|
- fix invalid vertical tab parsing
|
||||||
|
* translation update
|
||||||
|
* merge fan tags to temp ones, improve lmsensors tags handling
|
||||||
|
|
||||||
|
Ver.2.3.0:
|
||||||
|
+ implement fitlers support to ExtScripts (ApiVer = 3) (#53)
|
||||||
|
+ implement ability to wrap `\n` as new lines (#53)
|
||||||
|
+ implement key sorting in comboboxes
|
||||||
|
+ implement (perc)(bid|ask|price)chg tag support (ApiVer = 2)
|
||||||
|
+ implement timeouts to quotes (#54)
|
||||||
|
- fix bug with invalid html parsing
|
||||||
|
* move from XML to JSON in ExtQuotes (ApiVer = 2)
|
||||||
|
* more pretty configuration UI
|
||||||
|
* some part of refactoring
|
||||||
|
|
||||||
Ver.2.2.2:
|
Ver.2.2.2:
|
||||||
+ add quotes support (#46)
|
+ add quotes support (#46)
|
||||||
+ add support of properties height and width (#47)
|
+ add support of properties height and width (#47)
|
||||||
+ add transtaltion support to the plugins (#50)
|
+ add transtaltion support to the plugins (#50)
|
||||||
+ add support of key caching
|
+ add support of key caching
|
||||||
+ add support of X-AW-Number to ExtScript and ExtUpgrade (ApiVer=2)
|
+ 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 reconnection to DataEngine (in some cases some values are not updated)
|
||||||
+ add widgets width and height update
|
+ add widgets width and height update
|
||||||
- fix bug with Ext* items update (#49)
|
- fix bug with Ext* items update (#49)
|
||||||
- fix bug with GPUDEV, HDDDEV settings saving from UI
|
- fix bug with GPUDEV, HDDDEV settings saving from UI
|
||||||
- fix Desktop Panel settings
|
- fix Desktop Panel settings
|
||||||
- fix bug with adding paragraph settings
|
- fix bug with adding paragraph settings
|
||||||
* drop support of KDE4 support, created a separate branch
|
* drop support of KDE4 support, created a separated branch
|
||||||
* increase intervals limits (#48)
|
* increase intervals limits (#48)
|
||||||
* hddtemp was replaced to smartctl by default
|
* hddtemp was replaced to smartctl by default
|
||||||
* plugins were moved from private
|
* plugins were moved from private
|
||||||
|
50
CHANGELOG-RU
@ -1,3 +1,53 @@
|
|||||||
|
Вер.2.4.0:
|
||||||
|
+ добавлена поддержка погоды
|
||||||
|
+ добавлена поддержка LA (теги la1, la5, la15)
|
||||||
|
+ добавлена кнопка "Сбросить кеш"
|
||||||
|
+ добавлена поддержка сборки с clang
|
||||||
|
+ добавлен ExtItem агрегатор
|
||||||
|
+ добавлено время в дебаг вывод
|
||||||
|
+ добавлена возможность отключить монитор плеера
|
||||||
|
- исправлен баг с неправильным расчетам скорости сети
|
||||||
|
- исправлен баг с неправильной инициализацией диалога шрифтов
|
||||||
|
- исправлен баг с отсутствием удаления объектов (#60)
|
||||||
|
* переписаны ExtItems для использования собственного абстрактного класса
|
||||||
|
* улучшена работа с обновлениями виджета (#57)
|
||||||
|
* рисование интерфейса переписано на модель сигнал-слот
|
||||||
|
* плагин опять стал приватным
|
||||||
|
* исправлен каст плагина с синглтона (#57)
|
||||||
|
* изменена логика показа данных в DataEngine
|
||||||
|
* изменена сборка пакета и прекращена поддержка отдельного пакета с DataEngine
|
||||||
|
* замена QMap на QHash, если возможно
|
||||||
|
* замена циклов на итераторы, если возможно
|
||||||
|
* список рабочий столов сейчас представлен, как QStringList
|
||||||
|
* рефакторинг
|
||||||
|
|
||||||
|
Вер.2.3.3:
|
||||||
|
* изменен рендеринг с Qt на нативный
|
||||||
|
|
||||||
|
Вер.2.3.2:
|
||||||
|
+ добавлено изменение скорости интернета с KB/s на MB/s, если величина более 1000 KB/s
|
||||||
|
- пофикшен баг с отсутствием действия при активации ссылки (спасибо infans)
|
||||||
|
* улучшена поддержка котировок, например пофикшен возможный сегфолт плазмы
|
||||||
|
* переписать основной виджет к модели сигнал-слот
|
||||||
|
* улучшена поддержка расчета заряда батареи для нескольких батарей
|
||||||
|
|
||||||
|
Вер.2.3.1:
|
||||||
|
- пофикшен баг с отсутствием обновлений значений из настроек
|
||||||
|
- убрана поддержка фильтра `\t`
|
||||||
|
* обновлены переводы
|
||||||
|
* теги fan были объединены с temp, улучшена поддержка тегов lmsensors
|
||||||
|
|
||||||
|
Вер.2.3.0:
|
||||||
|
+ добавлена поддержка фильтров в ExtScript (ApiVer = 3) (#53)
|
||||||
|
+ добавлена возможность отображать `\n`, как перенос строки (#53)
|
||||||
|
+ добавлена сортировка ключей в комбобоксах
|
||||||
|
+ добавлена поддержка тегов (perc)(bid|ask|price)chg (ApiVer = 2)
|
||||||
|
+ добавлены таймауты запросов котировок (#54)
|
||||||
|
- исправлен баг с неправильным парсингом html
|
||||||
|
* ExtQuotes теперь использует JSON вместо XML (ApiVer = 2)
|
||||||
|
* более красивый UI настроек
|
||||||
|
* некоторый рефакторинг
|
||||||
|
|
||||||
Вер.2.2.2:
|
Вер.2.2.2:
|
||||||
+ добавлена поддержка котировок (#46)
|
+ добавлена поддержка котировок (#46)
|
||||||
+ добавлена поддержка свойств height и width (#47)
|
+ добавлена поддержка свойств height и width (#47)
|
||||||
|
12
README.md
@ -27,8 +27,7 @@ Instruction
|
|||||||
Dependencies
|
Dependencies
|
||||||
------------
|
------------
|
||||||
|
|
||||||
* kdebase-workspace (*if KDE4 is used*) **or** plasma-framework (*if KF5 is used*)
|
* plasma-framework
|
||||||
* lm_sensors (*for definition temperature device*)
|
|
||||||
|
|
||||||
Optional dependencies
|
Optional dependencies
|
||||||
---------------------
|
---------------------
|
||||||
@ -36,13 +35,13 @@ Optional dependencies
|
|||||||
* proprietary video driver
|
* proprietary video driver
|
||||||
* hddtemp
|
* hddtemp
|
||||||
* smartmontools
|
* smartmontools
|
||||||
* music player (mpd or supported MPRIS)
|
* music player (mpd or MPRIS supported)
|
||||||
|
|
||||||
Make dependencies
|
Make dependencies
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
* cmake
|
* cmake
|
||||||
* automoc4 (*if KDE4 is used*) or extra-cmake-modules (*if KF5 is used*)
|
* extra-cmake-modules
|
||||||
|
|
||||||
Installation
|
Installation
|
||||||
------------
|
------------
|
||||||
@ -54,7 +53,7 @@ Installation
|
|||||||
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr ../
|
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr ../
|
||||||
make && sudo make install
|
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
|
Additional information
|
||||||
======================
|
======================
|
||||||
@ -72,4 +71,5 @@ Links
|
|||||||
* [Scripts and bars](http://arcanis.name/en/2014/12/19/aw-v21-bells-and-whistles/)
|
* [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)
|
* 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)
|
* 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
|
||||||
|
@ -1,43 +0,0 @@
|
|||||||
# Maintainer: Evgeniy Alekseev <arcanis at archlinux dot org>
|
|
||||||
|
|
||||||
pkgname=plasma5-applet-awesome-widgets
|
|
||||||
_pkgname=awesome-widgets
|
|
||||||
pkgver=2.2.2
|
|
||||||
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"
|
|
||||||
"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')
|
|
||||||
source=(https://github.com/arcan1s/awesome-widgets/releases/download/V.${pkgver}/${_pkgname}-${pkgver}-src.tar.xz)
|
|
||||||
install=${pkgname}.install
|
|
||||||
md5sums=('73e176a124f8bfe43a0a112307624bfe')
|
|
||||||
backup=('etc/xdg/plasma-dataengine-extsysmon.conf')
|
|
||||||
|
|
||||||
prepare() {
|
|
||||||
rm -rf "${srcdir}/build"
|
|
||||||
mkdir "${srcdir}/build"
|
|
||||||
}
|
|
||||||
|
|
||||||
build () {
|
|
||||||
cd "${srcdir}/build"
|
|
||||||
cmake -DKDE_INSTALL_USE_QT_SYS_PATHS=ON \
|
|
||||||
-DCMAKE_BUILD_TYPE=Release \
|
|
||||||
-DCMAKE_INSTALL_PREFIX=/usr \
|
|
||||||
"../${_pkgname}"
|
|
||||||
make
|
|
||||||
}
|
|
||||||
|
|
||||||
package() {
|
|
||||||
cd "${srcdir}/build"
|
|
||||||
make DESTDIR="${pkgdir}" install
|
|
||||||
}
|
|
@ -1,23 +1,14 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
SRCDIR="sources"
|
SRCDIR="sources"
|
||||||
MAJOR=$(grep -m1 PROJECT_VERSION_MAJOR sources/CMakeLists.txt | awk '{print $3}' | sed 's/.$//g')
|
MAJOR=$(grep -m1 PROJECT_VERSION_MAJOR sources/CMakeLists.txt | awk '{print $2}' | sed 's/^.\(.*\)..$/\1/')
|
||||||
MINOR=$(grep -m1 PROJECT_VERSION_MINOR sources/CMakeLists.txt | awk '{print $3}' | sed 's/.$//g')
|
MINOR=$(grep -m1 PROJECT_VERSION_MINOR sources/CMakeLists.txt | awk '{print $2}' | sed 's/^.\(.*\)..$/\1/')
|
||||||
PATCH=$(grep -m1 PROJECT_VERSION_PATCH sources/CMakeLists.txt | awk '{print $3}' | sed 's/.$//g')
|
PATCH=$(grep -m1 PROJECT_VERSION_PATCH sources/CMakeLists.txt | awk '{print $2}' | sed 's/^.\(.*\)..$/\1/')
|
||||||
VERSION="${MAJOR}.${MINOR}.${PATCH}"
|
VERSION="${MAJOR}.${MINOR}.${PATCH}"
|
||||||
|
|
||||||
# update submodules
|
# update submodules
|
||||||
git submodule update --init --recursive
|
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
|
# build widget
|
||||||
ARCHIVE="awesome-widgets"
|
ARCHIVE="awesome-widgets"
|
||||||
FILES="AUTHORS CHANGELOG CHANGELOG-RU COPYING"
|
FILES="AUTHORS CHANGELOG CHANGELOG-RU COPYING"
|
||||||
@ -29,13 +20,13 @@ cp -r "${SRCDIR}" "${ARCHIVE}"
|
|||||||
for FILE in ${FILES[*]}; do cp -r "$FILE" "${ARCHIVE}"; done
|
for FILE in ${FILES[*]}; do cp -r "$FILE" "${ARCHIVE}"; done
|
||||||
for FILE in ${IGNORELIST[*]}; do rm -rf "${ARCHIVE}/${FILE}"; done
|
for FILE in ${IGNORELIST[*]}; do rm -rf "${ARCHIVE}/${FILE}"; done
|
||||||
tar cJf "${ARCHIVE}-${VERSION}-src.tar.xz" "${ARCHIVE}"
|
tar cJf "${ARCHIVE}-${VERSION}-src.tar.xz" "${ARCHIVE}"
|
||||||
ln -sf "../${ARCHIVE}-${VERSION}-src.tar.xz" arch
|
ln -sf "../${ARCHIVE}-${VERSION}-src.tar.xz" packages
|
||||||
rm -rf "${ARCHIVE}"
|
rm -rf "${ARCHIVE}"
|
||||||
|
|
||||||
# update md5sum
|
# update md5sum
|
||||||
MD5SUMS=$(md5sum ${ARCHIVE}-${VERSION}-src.tar.xz | awk '{print $1}')
|
MD5SUMS=$(md5sum ${ARCHIVE}-${VERSION}-src.tar.xz | awk '{print $1}')
|
||||||
sed -i "/md5sums=('[0-9A-Fa-f]*/s/[^'][^)]*/md5sums=('${MD5SUMS}'/" arch/PKGBUILD
|
sed -i "/md5sums=('[0-9A-Fa-f]*/s/[^'][^)]*/md5sums=('${MD5SUMS}'/" packages/PKGBUILD
|
||||||
sed -i "s/pkgver=[0-9.]*/pkgver=${VERSION}/" arch/PKGBUILD
|
sed -i "s/pkgver=[0-9.]*/pkgver=${VERSION}/" packages/PKGBUILD
|
||||||
# clear
|
# clear
|
||||||
find . -type f -name '*src.tar.xz' -not -name "*${VERSION}-src.tar.xz" -exec rm -rf {} \;
|
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 {} \;
|
find packages -type l -xtype l -exec rm -rf {} \;
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
pkgname=plasma5-applet-awesome-widgets
|
pkgname=plasma5-applet-awesome-widgets
|
||||||
_pkgname=awesome-widgets
|
_pkgname=awesome-widgets
|
||||||
pkgver=2.2.1.r15.g78931b3
|
pkgver=2.4.0.r34.gbe26033
|
||||||
pkgrel=1
|
pkgrel=1
|
||||||
pkgdesc="Collection of minimalistic Plasmoids which look like Awesome WM widgets (ex-PyTextMonitor). Git version"
|
pkgdesc="Collection of minimalistic Plasmoids which look like Awesome WM widgets (ex-PyTextMonitor). Git version"
|
||||||
arch=('i686' 'x86_64')
|
arch=('i686' 'x86_64')
|
||||||
@ -17,8 +17,8 @@ optdepends=("amarok: for music player monitor"
|
|||||||
"mpd: for music player monitor"
|
"mpd: for music player monitor"
|
||||||
"nvidia-utils: for GPU monitor"
|
"nvidia-utils: for GPU monitor"
|
||||||
"qmmp: for music player monitor")
|
"qmmp: for music player monitor")
|
||||||
makedepends=('cmake' 'extra-cmake-modules')
|
makedepends=('cmake' 'extra-cmake-modules' 'git')
|
||||||
source=(${_pkgname}::git+https://github.com/arcan1s/awesome-widgets/)
|
source=(${_pkgname}::git+https://github.com/arcan1s/awesome-widgets.git#branch=release-2.4.0)
|
||||||
install=${pkgname}.install
|
install=${pkgname}.install
|
||||||
md5sums=('SKIP')
|
md5sums=('SKIP')
|
||||||
backup=('etc/xdg/plasma-dataengine-extsysmon.conf')
|
backup=('etc/xdg/plasma-dataengine-extsysmon.conf')
|
11
packages/build-requirements.deb.txt
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
cmake
|
||||||
|
extra-cmake-modules
|
||||||
|
g++
|
||||||
|
git
|
||||||
|
libkf5i18n-dev
|
||||||
|
libkf5notifications-dev
|
||||||
|
libkf5service-dev
|
||||||
|
libkf5windowsystem-dev
|
||||||
|
plasma-framework-dev
|
||||||
|
qtbase5-dev
|
||||||
|
qtdeclarative5-dev
|
0
packages/build-requirements.rpm.txt
Normal file
@ -19,5 +19,8 @@ Name=GCC
|
|||||||
Path=gcc
|
Path=gcc
|
||||||
Type=GCC
|
Type=GCC
|
||||||
|
|
||||||
|
[Launch]
|
||||||
|
Launch Configurations=
|
||||||
|
|
||||||
[Project]
|
[Project]
|
||||||
VersionControlSupport=kdevgit
|
VersionControlSupport=kdevgit
|
||||||
|
1
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,46 +1,67 @@
|
|||||||
cmake_minimum_required (VERSION 2.8.12)
|
cmake_minimum_required(VERSION 2.8.12)
|
||||||
|
|
||||||
cmake_policy (SET CMP0003 OLD)
|
# some fucking magic
|
||||||
cmake_policy (SET CMP0002 OLD)
|
cmake_policy(SET CMP0003 OLD)
|
||||||
cmake_policy (SET CMP0011 NEW)
|
cmake_policy(SET CMP0002 OLD)
|
||||||
cmake_policy (SET CMP0015 NEW)
|
cmake_policy(SET CMP0011 NEW)
|
||||||
|
cmake_policy(SET CMP0015 NEW)
|
||||||
|
if (POLICY CMP0063)
|
||||||
|
cmake_policy(SET CMP0063 OLD)
|
||||||
|
endif()
|
||||||
|
|
||||||
project (awesomewidgets)
|
project(awesomewidgets)
|
||||||
set (PROJECT_AUTHOR "Evgeniy Alekseev")
|
set(PROJECT_AUTHOR "Evgeniy Alekseev")
|
||||||
set (PROJECT_CONTACT "esalexeev@gmail.com")
|
set(PROJECT_CONTACT "esalexeev@gmail.com")
|
||||||
set (PROJECT_LICENSE "GPLv3")
|
set(PROJECT_LICENSE "GPL3")
|
||||||
set (PROJECT_VERSION_MAJOR 2)
|
set(PROJECT_VERSION_MAJOR "2")
|
||||||
set (PROJECT_VERSION_MINOR 2)
|
set(PROJECT_VERSION_MINOR "4")
|
||||||
set (PROJECT_VERSION_PATCH 2)
|
set(PROJECT_VERSION_PATCH "0")
|
||||||
set (PROJECT_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH})
|
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_DATE "%Y-%m-%d %H:%M" UTC)
|
||||||
string (TIMESTAMP CURRENT_YEAR "%Y")
|
string(TIMESTAMP CURRENT_YEAR "%Y")
|
||||||
|
|
||||||
message (STATUS "Project: ${PROJECT_NAME}")
|
message(STATUS "Project: ${PROJECT_NAME}")
|
||||||
message (STATUS "Version: ${PROJECT_VERSION}")
|
message(STATUS "Version: ${PROJECT_VERSION}")
|
||||||
message (STATUS "Build date: ${CURRENT_DATE}")
|
message(STATUS "Build date: ${CURRENT_DATE}")
|
||||||
|
|
||||||
|
option(BUILD_PLASMOIDS "Build plasmoids" ON)
|
||||||
|
option(BUILD_DEB_PACKAGE "Build deb package" OFF)
|
||||||
|
option(BUILD_RPM_PACKAGE "Build rpm package" OFF)
|
||||||
|
|
||||||
# flags
|
# flags
|
||||||
if (CMAKE_COMPILER_IS_GNUCXX)
|
if(CMAKE_COMPILER_IS_GNUCXX)
|
||||||
set (CMAKE_CXX_FLAGS "-Wall -Wno-cpp -std=c++11")
|
set(CMAKE_CXX_FLAGS "-Wall -Wno-cpp -std=c++11")
|
||||||
set (CMAKE_CXX_FLAGS_DEBUG "-g -O0")
|
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0")
|
||||||
set (CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG")
|
set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG")
|
||||||
# avoid newer gcc warnings
|
# avoid newer gcc warnings
|
||||||
add_definitions (-D_DEFAULT_SOURCE)
|
add_definitions(-D_DEFAULT_SOURCE)
|
||||||
else ()
|
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||||
message (STATUS "Unknown compiler")
|
set(CMAKE_CXX_FLAGS "-Wall -std=c++11 -stdlib=libc++")
|
||||||
endif ()
|
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0")
|
||||||
if (CMAKE_BUILD_TYPE MATCHES Debug)
|
set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG")
|
||||||
set (CMAKE_VERBOSE_MAKEFILE ON)
|
# linker flags
|
||||||
endif ()
|
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)
|
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_TRDPARTY_DIR ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty)
|
||||||
|
set(PROJECT_LIBRARY awesomewidgets)
|
||||||
|
include(libraries.cmake)
|
||||||
|
|
||||||
add_subdirectory (extsysmon)
|
add_subdirectory(awesomewidgets)
|
||||||
add_subdirectory (awesome-widget)
|
add_subdirectory(extsysmon)
|
||||||
add_subdirectory (desktop-panel)
|
if(BUILD_PLASMOIDS)
|
||||||
|
add_subdirectory(awesome-widget)
|
||||||
|
add_subdirectory(desktop-panel)
|
||||||
|
add_subdirectory(translations)
|
||||||
|
endif()
|
||||||
|
|
||||||
# translations
|
include(packages-recipe.cmake)
|
||||||
add_subdirectory (translations)
|
|
||||||
|
25
sources/awdebug.cpp
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* This file is part of awesome-widgets *
|
||||||
|
* *
|
||||||
|
* awesome-widgets is free software: you can redistribute it and/or *
|
||||||
|
* modify it under the terms of the GNU General Public License as *
|
||||||
|
* published by the Free Software Foundation, either version 3 of the *
|
||||||
|
* License, or (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* awesome-widgets is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
#include "awdebug.h"
|
||||||
|
|
||||||
|
|
||||||
|
Q_LOGGING_CATEGORY(LOG_AW, "org.kde.plasma.awesomewidget", QtMsgType::QtWarningMsg)
|
||||||
|
Q_LOGGING_CATEGORY(LOG_DP, "org.kde.plasma.desktoppanel", QtMsgType::QtWarningMsg)
|
||||||
|
Q_LOGGING_CATEGORY(LOG_ESM, "org.kde.plasma.extsysmon", QtMsgType::QtWarningMsg)
|
||||||
|
Q_LOGGING_CATEGORY(LOG_LIB, "org.kde.plasma.awesomewidgets", QtMsgType::QtWarningMsg)
|
45
sources/awdebug.h
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* This file is part of awesome-widgets *
|
||||||
|
* *
|
||||||
|
* awesome-widgets is free software: you can redistribute it and/or *
|
||||||
|
* modify it under the terms of the GNU General Public License as *
|
||||||
|
* published by the Free Software Foundation, either version 3 of the *
|
||||||
|
* License, or (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* awesome-widgets is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef AWDEBUG_H
|
||||||
|
#define AWDEBUG_H
|
||||||
|
|
||||||
|
#include <QLoggingCategory>
|
||||||
|
|
||||||
|
#ifndef LOG_FORMAT
|
||||||
|
#define LOG_FORMAT "[%{time yyyy-MM-ddTHH:mm:ss.zzz}][%{if-debug}DD%{endif}%{if-info}II%{endif}%{if-warning}WW%{endif}%{if-critical}CC%{endif}%{if-fatal}FF%{endif}][%{category}][%{function}] %{message}"
|
||||||
|
#endif /* LOG_FORMAT */
|
||||||
|
|
||||||
|
// define info log level
|
||||||
|
// #if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
|
||||||
|
// #ifndef qCInfo
|
||||||
|
// redefine info because it doesn't log properly
|
||||||
|
#ifdef qCInfo
|
||||||
|
#undef qCInfo
|
||||||
|
#endif /* qCInfo */
|
||||||
|
#define qCInfo qCDebug
|
||||||
|
// #endif /* QT_VERSION */
|
||||||
|
|
||||||
|
|
||||||
|
Q_DECLARE_LOGGING_CATEGORY(LOG_AW)
|
||||||
|
Q_DECLARE_LOGGING_CATEGORY(LOG_DP)
|
||||||
|
Q_DECLARE_LOGGING_CATEGORY(LOG_ESM)
|
||||||
|
Q_DECLARE_LOGGING_CATEGORY(LOG_LIB)
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* AWDEBUG_H */
|
@ -1,19 +1,7 @@
|
|||||||
# set project name
|
set(SUBPROJECT plasma_applet_awesome-widget)
|
||||||
set (SUBPROJECT plasma_applet_awesome-widget)
|
message(STATUS "Subproject ${SUBPROJECT}")
|
||||||
message (STATUS "Subproject ${SUBPROJECT}")
|
|
||||||
|
|
||||||
# prepare
|
configure_file(metadata.desktop ${CMAKE_CURRENT_SOURCE_DIR}/package/metadata.desktop)
|
||||||
configure_file (metadata.desktop ${CMAKE_CURRENT_SOURCE_DIR}/package/metadata.desktop)
|
|
||||||
|
|
||||||
find_package (ECM 0.0.12 REQUIRED NO_MODULE)
|
add_subdirectory(plugin)
|
||||||
set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR})
|
plasma_install_package(package org.kde.plasma.awesomewidget)
|
||||||
|
|
||||||
find_package (Qt5 REQUIRED COMPONENTS Core Network Qml Xml)
|
|
||||||
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)
|
|
||||||
|
@ -23,6 +23,9 @@
|
|||||||
<entry name="notify" type="bool">
|
<entry name="notify" type="bool">
|
||||||
<default>true</default>
|
<default>true</default>
|
||||||
</entry>
|
</entry>
|
||||||
|
<entry name="wrapNewLines" type="bool">
|
||||||
|
<default>false</default>
|
||||||
|
</entry>
|
||||||
<entry name="background" type="bool">
|
<entry name="background" type="bool">
|
||||||
<default>true</default>
|
<default>true</default>
|
||||||
</entry>
|
</entry>
|
||||||
@ -44,6 +47,9 @@
|
|||||||
<entry name="checkUpdates" type="bool">
|
<entry name="checkUpdates" type="bool">
|
||||||
<default>true</default>
|
<default>true</default>
|
||||||
</entry>
|
</entry>
|
||||||
|
<entry name="translateStrings" type="bool">
|
||||||
|
<default>true</default>
|
||||||
|
</entry>
|
||||||
</group>
|
</group>
|
||||||
|
|
||||||
<group name="Tooltip">
|
<group name="Tooltip">
|
||||||
|
@ -19,17 +19,21 @@ import QtQuick 2.0
|
|||||||
import QtQuick.Controls 1.3 as QtControls
|
import QtQuick.Controls 1.3 as QtControls
|
||||||
import QtQuick.Layouts 1.0 as QtLayouts
|
import QtQuick.Layouts 1.0 as QtLayouts
|
||||||
|
|
||||||
import org.kde.plasma.awesomewidget 1.0
|
import org.kde.plasma.private.awesomewidget 1.0
|
||||||
|
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: aboutPage
|
id: aboutPage
|
||||||
|
AWActions {
|
||||||
|
id: awActions;
|
||||||
|
}
|
||||||
|
|
||||||
width: childrenRect.width
|
width: childrenRect.width
|
||||||
height: childrenRect.height
|
height: childrenRect.height
|
||||||
implicitWidth: pageColumn.implicitWidth
|
implicitWidth: pageColumn.implicitWidth
|
||||||
implicitHeight: pageColumn.implicitHeight
|
implicitHeight: pageColumn.implicitHeight
|
||||||
|
|
||||||
property bool debug: AWKeys.isDebugEnabled()
|
property bool debug: awActions.isDebugEnabled()
|
||||||
|
|
||||||
|
|
||||||
Column {
|
Column {
|
||||||
@ -45,28 +49,37 @@ Item {
|
|||||||
QtControls.Label {
|
QtControls.Label {
|
||||||
QtLayouts.Layout.fillWidth: true
|
QtLayouts.Layout.fillWidth: true
|
||||||
horizontalAlignment: Text.AlignHCenter
|
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 {
|
QtControls.Label {
|
||||||
QtLayouts.Layout.fillWidth: true
|
QtLayouts.Layout.fillWidth: true
|
||||||
horizontalAlignment: Text.AlignJustify
|
horizontalAlignment: Text.AlignJustify
|
||||||
text: AWActions.getAboutText("description")
|
text: awActions.getAboutText("description")
|
||||||
}
|
}
|
||||||
|
|
||||||
QtControls.Label {
|
QtControls.Label {
|
||||||
QtLayouts.Layout.fillWidth: true
|
QtLayouts.Layout.fillWidth: true
|
||||||
horizontalAlignment: Text.AlignLeft
|
horizontalAlignment: Text.AlignLeft
|
||||||
textFormat: Text.RichText
|
textFormat: Text.RichText
|
||||||
text: AWActions.getAboutText("links")
|
text: awActions.getAboutText("links")
|
||||||
|
onLinkActivated: Qt.openUrlExternally(link);
|
||||||
}
|
}
|
||||||
|
|
||||||
QtControls.Label {
|
QtControls.Label {
|
||||||
|
QtLayouts.Layout.fillHeight: true
|
||||||
QtLayouts.Layout.fillWidth: true
|
QtLayouts.Layout.fillWidth: true
|
||||||
font.capitalization: Font.SmallCaps
|
font.capitalization: Font.SmallCaps
|
||||||
horizontalAlignment: Text.AlignHCenter
|
horizontalAlignment: Text.AlignHCenter
|
||||||
|
verticalAlignment: Text.AlignBottom
|
||||||
textFormat: Text.RichText
|
textFormat: Text.RichText
|
||||||
text: AWActions.getAboutText("copy")
|
text: awActions.getAboutText("copy")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -79,14 +92,17 @@ Item {
|
|||||||
QtLayouts.Layout.fillWidth: true
|
QtLayouts.Layout.fillWidth: true
|
||||||
wrapMode: Text.WordWrap
|
wrapMode: Text.WordWrap
|
||||||
horizontalAlignment: Text.AlignJustify
|
horizontalAlignment: Text.AlignJustify
|
||||||
text: AWActions.getAboutText("translators")
|
text: awActions.getAboutText("translators")
|
||||||
}
|
}
|
||||||
|
|
||||||
QtControls.Label {
|
QtControls.Label {
|
||||||
|
QtLayouts.Layout.fillHeight: true
|
||||||
QtLayouts.Layout.fillWidth: true
|
QtLayouts.Layout.fillWidth: true
|
||||||
horizontalAlignment: Text.AlignJustify
|
horizontalAlignment: Text.AlignJustify
|
||||||
|
verticalAlignment: Text.AlignTop
|
||||||
textFormat: Text.RichText
|
textFormat: Text.RichText
|
||||||
text: AWActions.getAboutText("3rdparty")
|
text: awActions.getAboutText("3rdparty")
|
||||||
|
onLinkActivated: Qt.openUrlExternally(link);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -94,6 +110,6 @@ Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
if (debug) console.log("[about::onCompleted]")
|
if (debug) console.debug()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,27 +18,35 @@
|
|||||||
import QtQuick 2.0
|
import QtQuick 2.0
|
||||||
import QtQuick.Controls 1.3 as QtControls
|
import QtQuick.Controls 1.3 as QtControls
|
||||||
|
|
||||||
import org.kde.plasma.awesomewidget 1.0
|
import org.kde.plasma.private.awesomewidget 1.0
|
||||||
|
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: advancedPage
|
id: advancedPage
|
||||||
|
// backend
|
||||||
|
AWActions {
|
||||||
|
id: awActions;
|
||||||
|
}
|
||||||
|
|
||||||
width: childrenRect.width
|
width: childrenRect.width
|
||||||
height: childrenRect.height
|
height: childrenRect.height
|
||||||
implicitWidth: pageColumn.implicitWidth
|
implicitWidth: pageColumn.implicitWidth
|
||||||
implicitHeight: pageColumn.implicitHeight
|
implicitHeight: pageColumn.implicitHeight
|
||||||
|
|
||||||
property bool debug: AWKeys.isDebugEnabled()
|
property bool debug: awActions.isDebugEnabled()
|
||||||
|
|
||||||
property alias cfg_height: widgetHeight.value
|
property alias cfg_height: widgetHeight.value
|
||||||
property alias cfg_width: widgetWidth.value
|
property alias cfg_width: widgetWidth.value
|
||||||
property alias cfg_notify: notify.checked
|
property alias cfg_notify: notify.checked
|
||||||
|
property alias cfg_wrapNewLines: wrapNewLines.checked
|
||||||
property alias cfg_background: background.checked
|
property alias cfg_background: background.checked
|
||||||
property alias cfg_customTime: customTime.text
|
property alias cfg_customTime: customTime.text
|
||||||
property alias cfg_customUptime: customUptime.text
|
property alias cfg_customUptime: customUptime.text
|
||||||
property string cfg_tempUnits: tempUnits.currentText
|
property string cfg_tempUnits: tempUnits.currentText
|
||||||
property alias cfg_acOnline: acOnline.text
|
property alias cfg_acOnline: acOnline.text
|
||||||
property alias cfg_acOffline: acOffline.text
|
property alias cfg_acOffline: acOffline.text
|
||||||
|
property alias cfg_checkUpdates: updates.checked
|
||||||
|
property alias cfg_translateStrings: translate.checked
|
||||||
|
|
||||||
|
|
||||||
Column {
|
Column {
|
||||||
@ -98,6 +106,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 {
|
Row {
|
||||||
height: implicitHeight
|
height: implicitHeight
|
||||||
width: parent.width
|
width: parent.width
|
||||||
@ -192,8 +214,10 @@ Item {
|
|||||||
]
|
]
|
||||||
onCurrentIndexChanged: cfg_tempUnits = model[currentIndex]["name"]
|
onCurrentIndexChanged: cfg_tempUnits = model[currentIndex]["name"]
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
|
if (debug) console.debug()
|
||||||
for (var i = 0; i < model.length; i++) {
|
for (var i = 0; i < model.length; i++) {
|
||||||
if (model[i]["name"] == plasmoid.configuration.tempUnits) {
|
if (model[i]["name"] == plasmoid.configuration.tempUnits) {
|
||||||
|
if (debug) console.info("Found", model[i]["name"], "on", i)
|
||||||
tempUnits.currentIndex = i;
|
tempUnits.currentIndex = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -234,9 +258,52 @@ Item {
|
|||||||
text: plasmoid.configuration.acOffline
|
text: plasmoid.configuration.acOffline
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Row {
|
||||||
|
height: implicitHeight
|
||||||
|
width: parent.width
|
||||||
|
QtControls.Label {
|
||||||
|
height: parent.heigth
|
||||||
|
width: parent.width * 2 / 5
|
||||||
|
}
|
||||||
|
QtControls.CheckBox {
|
||||||
|
id: updates
|
||||||
|
width: parent.width * 3 / 5
|
||||||
|
text: i18n("Check updates on startup")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Row {
|
||||||
|
height: implicitHeight
|
||||||
|
width: parent.width
|
||||||
|
QtControls.Label {
|
||||||
|
height: parent.heigth
|
||||||
|
width: parent.width * 2 / 5
|
||||||
|
}
|
||||||
|
QtControls.CheckBox {
|
||||||
|
id: translate
|
||||||
|
width: parent.width * 3 / 5
|
||||||
|
text: i18n("Translate strings")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Row {
|
||||||
|
height: implicitHeight
|
||||||
|
width: parent.width
|
||||||
|
QtControls.Label {
|
||||||
|
height: parent.height
|
||||||
|
width: parent.width * 2 / 5
|
||||||
|
}
|
||||||
|
QtControls.Button {
|
||||||
|
id: selectFont
|
||||||
|
width: parent.width * 3 / 5
|
||||||
|
text: i18n("Drop key cache")
|
||||||
|
onClicked: awActions.dropCache()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
if (debug) console.log("[advanced::onCompleted]")
|
if (debug) console.debug()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,17 +20,22 @@ import QtQuick.Controls 1.3 as QtControls
|
|||||||
import QtQuick.Controls.Styles 1.3 as QtStyles
|
import QtQuick.Controls.Styles 1.3 as QtStyles
|
||||||
import QtQuick.Dialogs 1.1 as QtDialogs
|
import QtQuick.Dialogs 1.1 as QtDialogs
|
||||||
|
|
||||||
import org.kde.plasma.awesomewidget 1.0
|
import org.kde.plasma.private.awesomewidget 1.0
|
||||||
|
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: appearancePage
|
id: appearancePage
|
||||||
|
// backend
|
||||||
|
AWActions {
|
||||||
|
id: awActions;
|
||||||
|
}
|
||||||
|
|
||||||
width: childrenRect.width
|
width: childrenRect.width
|
||||||
height: childrenRect.height
|
height: childrenRect.height
|
||||||
implicitWidth: pageColumn.implicitWidth
|
implicitWidth: pageColumn.implicitWidth
|
||||||
implicitHeight: pageColumn.implicitHeight
|
implicitHeight: pageColumn.implicitHeight
|
||||||
|
|
||||||
property bool debug: AWKeys.isDebugEnabled()
|
property bool debug: awActions.isDebugEnabled()
|
||||||
property variant weight: {
|
property variant weight: {
|
||||||
25: 0,
|
25: 0,
|
||||||
50: 1,
|
50: 1,
|
||||||
@ -84,7 +89,11 @@ Item {
|
|||||||
id: selectFont
|
id: selectFont
|
||||||
width: parent.width * 2 / 3
|
width: parent.width * 2 / 3
|
||||||
text: plasmoid.configuration.fontFamily
|
text: plasmoid.configuration.fontFamily
|
||||||
onClicked: fontDialog.visible = true
|
onClicked: {
|
||||||
|
if (debug) console.debug()
|
||||||
|
fontDialog.setFont()
|
||||||
|
fontDialog.visible = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -146,8 +155,10 @@ Item {
|
|||||||
]
|
]
|
||||||
onCurrentIndexChanged: cfg_fontWeight = model[currentIndex]["name"]
|
onCurrentIndexChanged: cfg_fontWeight = model[currentIndex]["name"]
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
|
if (debug) console.debug()
|
||||||
for (var i = 0; i < model.length; i++) {
|
for (var i = 0; i < model.length; i++) {
|
||||||
if (model[i]["name"] == plasmoid.configuration.fontWeight) {
|
if (model[i]["name"] == plasmoid.configuration.fontWeight) {
|
||||||
|
if (debug) console.info("Found", model[i]["name"], "on", i)
|
||||||
fontWeight.currentIndex = i;
|
fontWeight.currentIndex = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -181,8 +192,10 @@ Item {
|
|||||||
]
|
]
|
||||||
onCurrentIndexChanged: cfg_fontStyle = model[currentIndex]["name"]
|
onCurrentIndexChanged: cfg_fontStyle = model[currentIndex]["name"]
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
|
if (debug) console.debug()
|
||||||
for (var i = 0; i < model.length; i++) {
|
for (var i = 0; i < model.length; i++) {
|
||||||
if (model[i]["name"] == plasmoid.configuration.fontStyle) {
|
if (model[i]["name"] == plasmoid.configuration.fontStyle) {
|
||||||
|
if (debug) console.info("Found", model[i]["name"], "on", i)
|
||||||
fontStyle.currentIndex = i;
|
fontStyle.currentIndex = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -224,16 +237,27 @@ Item {
|
|||||||
QtDialogs.FontDialog {
|
QtDialogs.FontDialog {
|
||||||
id: fontDialog
|
id: fontDialog
|
||||||
title: i18n("Select a font")
|
title: i18n("Select a font")
|
||||||
font: Qt.font({ family: selectFont.text, pointSize: fontSize.value, weight: Font.Normal })
|
signal setFont
|
||||||
|
|
||||||
onAccepted: {
|
onAccepted: {
|
||||||
|
if (debug) console.debug()
|
||||||
selectFont.text = fontDialog.font.family
|
selectFont.text = fontDialog.font.family
|
||||||
fontSize.value = fontDialog.font.pointSize
|
fontSize.value = fontDialog.font.pointSize
|
||||||
fontStyle.currentIndex = fontDialog.font.italic ? 1 : 0
|
fontStyle.currentIndex = fontDialog.font.italic ? 1 : 0
|
||||||
fontWeight.currentIndex = weight[fontDialog.font.weight]
|
fontWeight.currentIndex = weight[fontDialog.font.weight]
|
||||||
}
|
}
|
||||||
|
onSetFont: {
|
||||||
|
if (debug) console.debug()
|
||||||
|
fontDialog.font = Qt.font({
|
||||||
|
family: selectFont.text,
|
||||||
|
pointSize: fontSize.value > 0 ? fontSize.value : 12,
|
||||||
|
italic: fontStyle.currentIndex == 1,
|
||||||
|
weight: Font.Normal,
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
if (debug) console.log("[appearance::onCompleted]")
|
if (debug) console.debug()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,39 +21,27 @@ import QtQuick.Dialogs 1.1 as QtDialogs
|
|||||||
import QtQuick.Layouts 1.0 as QtLayouts
|
import QtQuick.Layouts 1.0 as QtLayouts
|
||||||
import QtQuick.Controls.Styles 1.3 as QtStyles
|
import QtQuick.Controls.Styles 1.3 as QtStyles
|
||||||
|
|
||||||
import org.kde.plasma.awesomewidget 1.0
|
import org.kde.plasma.private.awesomewidget 1.0
|
||||||
|
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: dataenginePage
|
id: dataenginePage
|
||||||
|
// backend
|
||||||
|
AWKeys {
|
||||||
|
id: awKeys;
|
||||||
|
}
|
||||||
|
AWActions {
|
||||||
|
id: awActions;
|
||||||
|
}
|
||||||
|
|
||||||
width: childrenRect.width
|
width: childrenRect.width
|
||||||
height: childrenRect.height
|
height: childrenRect.height
|
||||||
implicitWidth: pageColumn.implicitWidth
|
implicitWidth: pageColumn.implicitWidth
|
||||||
implicitHeight: pageColumn.implicitHeight
|
implicitHeight: pageColumn.implicitHeight
|
||||||
|
|
||||||
property bool debug: AWKeys.isDebugEnabled()
|
property bool debug: awActions.isDebugEnabled()
|
||||||
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 variant cfg_dataengine: AWActions.readDataEngineConfiguration()
|
property variant cfg_dataengine: awActions.readDataEngineConfiguration()
|
||||||
|
|
||||||
Column {
|
Column {
|
||||||
id: pageColumn
|
id: pageColumn
|
||||||
@ -71,23 +59,7 @@ Item {
|
|||||||
QtControls.TextField {
|
QtControls.TextField {
|
||||||
width: parent.width * 3 / 5
|
width: parent.width * 3 / 5
|
||||||
text: cfg_dataengine["ACPIPATH"]
|
text: cfg_dataengine["ACPIPATH"]
|
||||||
}
|
onEditingFinished: cfg_dataengine["ACPIPATH"] = text
|
||||||
}
|
|
||||||
|
|
||||||
Row {
|
|
||||||
height: implicitHeight
|
|
||||||
width: parent.width
|
|
||||||
QtControls.Label {
|
|
||||||
height: parent.height
|
|
||||||
width: parent.width * 2 / 5
|
|
||||||
horizontalAlignment: Text.AlignRight
|
|
||||||
verticalAlignment: Text.AlignVCenter
|
|
||||||
text: i18n("Custom scripts")
|
|
||||||
}
|
|
||||||
QtControls.Button {
|
|
||||||
width: parent.width * 3 / 5
|
|
||||||
text: i18n("Edit scripts")
|
|
||||||
onClicked: AWKeys.editItem("extscript")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,8 +78,10 @@ Item {
|
|||||||
width: parent.width * 3 / 5
|
width: parent.width * 3 / 5
|
||||||
model: ["auto", "disable", "ati", "nvidia"]
|
model: ["auto", "disable", "ati", "nvidia"]
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
|
if (debug) console.debug()
|
||||||
for (var i=0; i<model.length; i++) {
|
for (var i=0; i<model.length; i++) {
|
||||||
if (model[i] == cfg_dataengine["GPUDEV"]) {
|
if (model[i] == cfg_dataengine["GPUDEV"]) {
|
||||||
|
if (debug) console.info("Found", model[i], "on", i)
|
||||||
currentIndex = i;
|
currentIndex = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -128,10 +102,12 @@ Item {
|
|||||||
QtControls.ComboBox {
|
QtControls.ComboBox {
|
||||||
id: hdd
|
id: hdd
|
||||||
width: parent.width * 3 / 5
|
width: parent.width * 3 / 5
|
||||||
model: AWKeys.getHddDevices(true)
|
model: awKeys.getHddDevices(true)
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
|
if (debug) console.debug()
|
||||||
for (var i=0; i<model.length; i++) {
|
for (var i=0; i<model.length; i++) {
|
||||||
if (model[i] == cfg_dataengine["HDDDEV"]) {
|
if (model[i] == cfg_dataengine["HDDDEV"]) {
|
||||||
|
if (debug) console.info("Found", model[i], "on", i)
|
||||||
hdd.currentIndex = i;
|
hdd.currentIndex = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -152,6 +128,7 @@ Item {
|
|||||||
QtControls.TextField {
|
QtControls.TextField {
|
||||||
width: parent.width * 3 / 5
|
width: parent.width * 3 / 5
|
||||||
text: cfg_dataengine["HDDTEMPCMD"]
|
text: cfg_dataengine["HDDTEMPCMD"]
|
||||||
|
onEditingFinished: cfg_dataengine["HDDTEMPCMD"] = text
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -168,6 +145,7 @@ Item {
|
|||||||
QtControls.TextField {
|
QtControls.TextField {
|
||||||
width: parent.width * 3 / 5
|
width: parent.width * 3 / 5
|
||||||
text: cfg_dataengine["MPDADDRESS"]
|
text: cfg_dataengine["MPDADDRESS"]
|
||||||
|
onEditingFinished: cfg_dataengine["MPDADDRESS"] = text
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -187,6 +165,7 @@ Item {
|
|||||||
maximumValue: 65535
|
maximumValue: 65535
|
||||||
stepSize: 1
|
stepSize: 1
|
||||||
value: cfg_dataengine["MPDPORT"]
|
value: cfg_dataengine["MPDPORT"]
|
||||||
|
onEditingFinished: cfg_dataengine["MPDPORT"] = value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -223,10 +202,12 @@ Item {
|
|||||||
QtControls.ComboBox {
|
QtControls.ComboBox {
|
||||||
id: player
|
id: player
|
||||||
width: parent.width * 3 / 5
|
width: parent.width * 3 / 5
|
||||||
model: ["mpris", "mpd"]
|
model: ["disable", "mpris", "mpd"]
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
|
if (debug) console.debug()
|
||||||
for (var i=0; i<model.length; i++) {
|
for (var i=0; i<model.length; i++) {
|
||||||
if (model[i] == cfg_dataengine["PLAYER"]) {
|
if (model[i] == cfg_dataengine["PLAYER"]) {
|
||||||
|
if (debug) console.info("Found", model[i], "on", i)
|
||||||
player.currentIndex = i;
|
player.currentIndex = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -234,6 +215,43 @@ 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("Player data symbols")
|
||||||
|
}
|
||||||
|
QtControls.SpinBox {
|
||||||
|
width: parent.width * 3 / 5
|
||||||
|
minimumValue: 1
|
||||||
|
maximumValue: 100
|
||||||
|
stepSize: 1
|
||||||
|
value: cfg_dataengine["PLAYERSYMBOLS"]
|
||||||
|
onEditingFinished: cfg_dataengine["PLAYERSYMBOLS"] = value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Row {
|
||||||
|
height: implicitHeight
|
||||||
|
width: parent.width
|
||||||
|
QtControls.Label {
|
||||||
|
height: parent.height
|
||||||
|
width: parent.width * 2 / 5
|
||||||
|
horizontalAlignment: Text.AlignRight
|
||||||
|
verticalAlignment: Text.AlignVCenter
|
||||||
|
text: i18n("Custom scripts")
|
||||||
|
}
|
||||||
|
QtControls.Button {
|
||||||
|
width: parent.width * 3 / 5
|
||||||
|
text: i18n("Edit scripts")
|
||||||
|
onClicked: awKeys.editItem("extscript")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Row {
|
Row {
|
||||||
height: implicitHeight
|
height: implicitHeight
|
||||||
width: parent.width
|
width: parent.width
|
||||||
@ -247,7 +265,7 @@ Item {
|
|||||||
QtControls.Button {
|
QtControls.Button {
|
||||||
width: parent.width * 3 / 5
|
width: parent.width * 3 / 5
|
||||||
text: i18n("Edit tickers")
|
text: i18n("Edit tickers")
|
||||||
onClicked: AWKeys.editItem("extquotes")
|
onClicked: awKeys.editItem("extquotes")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -264,25 +282,42 @@ Item {
|
|||||||
QtControls.Button {
|
QtControls.Button {
|
||||||
width: parent.width * 3 / 5
|
width: parent.width * 3 / 5
|
||||||
text: i18n("Edit command")
|
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")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
if (debug) console.log("[dataengine::onCompleted]")
|
if (debug) console.debug()
|
||||||
|
|
||||||
// init submodule
|
// init submodule
|
||||||
AWKeys.initKeys(plasmoid.configuration.text, tooltipSettings)
|
awKeys.initKeys(plasmoid.configuration.text)
|
||||||
}
|
}
|
||||||
|
|
||||||
Component.onDestruction: {
|
Component.onDestruction: {
|
||||||
if (debug) console.log("[dataengine::onDestruction]")
|
if (debug) console.debug()
|
||||||
|
|
||||||
cfg_dataengine["GPUDEV"] = gpuDev.currentText
|
cfg_dataengine["GPUDEV"] = gpuDev.currentText
|
||||||
cfg_dataengine["HDDDEV"] = hdd.currentText
|
cfg_dataengine["HDDDEV"] = hdd.currentText
|
||||||
cfg_dataengine["PLAYER"] = player.currentText
|
cfg_dataengine["PLAYER"] = player.currentText
|
||||||
cfg_dataengine["MPRIS"] = mpris.currentText
|
cfg_dataengine["MPRIS"] = mpris.currentText
|
||||||
AWActions.writeDataEngineConfiguration(cfg_dataengine)
|
awActions.writeDataEngineConfiguration(cfg_dataengine)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,14 +22,21 @@ import org.kde.plasma.plasmoid 2.0
|
|||||||
import org.kde.plasma.core 2.0 as PlasmaCore
|
import org.kde.plasma.core 2.0 as PlasmaCore
|
||||||
import org.kde.plasma.components 2.0 as PlasmaComponents
|
import org.kde.plasma.components 2.0 as PlasmaComponents
|
||||||
|
|
||||||
import org.kde.plasma.awesomewidget 1.0
|
import org.kde.plasma.private.awesomewidget 1.0
|
||||||
import "."
|
import "."
|
||||||
|
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: main
|
id: main
|
||||||
|
// backend
|
||||||
|
AWKeys {
|
||||||
|
id: awKeys;
|
||||||
|
}
|
||||||
|
AWActions {
|
||||||
|
id: awActions;
|
||||||
|
}
|
||||||
|
|
||||||
property bool debug: AWKeys.isDebugEnabled()
|
property bool debug: awActions.isDebugEnabled()
|
||||||
property variant settings: {
|
property variant settings: {
|
||||||
"customTime": plasmoid.configuration.customTime,
|
"customTime": plasmoid.configuration.customTime,
|
||||||
"customUptime": plasmoid.configuration.customUptime,
|
"customUptime": plasmoid.configuration.customUptime,
|
||||||
@ -55,10 +62,14 @@ Item {
|
|||||||
"downTooltipColor": plasmoid.configuration.downTooltipColor,
|
"downTooltipColor": plasmoid.configuration.downTooltipColor,
|
||||||
"upTooltipColor": plasmoid.configuration.upTooltipColor,
|
"upTooltipColor": plasmoid.configuration.upTooltipColor,
|
||||||
"batTooltipColor": plasmoid.configuration.batTooltipColor,
|
"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
|
signal sizeUpdate
|
||||||
|
|
||||||
|
|
||||||
@ -81,17 +92,16 @@ Item {
|
|||||||
interval: plasmoid.configuration.interval
|
interval: plasmoid.configuration.interval
|
||||||
|
|
||||||
onNewData: {
|
onNewData: {
|
||||||
if (debug) console.log("[main::onNewData] : Update source " + sourceName)
|
if (debug) console.debug("Update source", sourceName)
|
||||||
// FIXME: ugly workaround to make some sources working
|
|
||||||
systemmonitorDE.interval = plasmoid.configuration.interval
|
systemmonitorDE.interval = plasmoid.configuration.interval
|
||||||
|
|
||||||
if (AWKeys.setDataBySource(sourceName, data, settings)) disconnectSource(sourceName)
|
awKeys.setDataBySource(sourceName, data, settings)
|
||||||
}
|
}
|
||||||
|
|
||||||
onSourceAdded: {
|
onSourceAdded: {
|
||||||
if (debug) console.log("[main::onSourceAdded] : Source " + source)
|
if (debug) console.debug("Source", source)
|
||||||
|
|
||||||
AWKeys.addDevice(source)
|
awKeys.addDevice(source)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,11 +112,10 @@ Item {
|
|||||||
interval: plasmoid.configuration.interval
|
interval: plasmoid.configuration.interval
|
||||||
|
|
||||||
onNewData: {
|
onNewData: {
|
||||||
if (debug) console.log("[main::onNewData] : Update source " + sourceName)
|
if (debug) console.debug("Update source", sourceName)
|
||||||
// FIXME: ugly workaround to make some sources working
|
|
||||||
extsysmonDE.interval = plasmoid.configuration.interval
|
extsysmonDE.interval = plasmoid.configuration.interval
|
||||||
|
|
||||||
if (AWKeys.setDataBySource(sourceName, data, settings)) needUpdate()
|
awKeys.setDataBySource(sourceName, data, settings)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,9 +126,9 @@ Item {
|
|||||||
interval: 1000
|
interval: 1000
|
||||||
|
|
||||||
onNewData: {
|
onNewData: {
|
||||||
if (debug) console.log("[main::onNewData] : Update source " + sourceName)
|
if (debug) console.debug("Update source", sourceName)
|
||||||
|
|
||||||
AWKeys.setDataBySource(sourceName, data, settings)
|
awKeys.setDataBySource(sourceName, data, settings)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,6 +137,7 @@ Item {
|
|||||||
Text {
|
Text {
|
||||||
id: text
|
id: text
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
renderType: Text.NativeRendering
|
||||||
textFormat: Text.RichText
|
textFormat: Text.RichText
|
||||||
wrapMode: Text.NoWrap
|
wrapMode: Text.NoWrap
|
||||||
|
|
||||||
@ -140,8 +150,6 @@ Item {
|
|||||||
font.pointSize: plasmoid.configuration.fontSize
|
font.pointSize: plasmoid.configuration.fontSize
|
||||||
font.weight: general.fontWeight[plasmoid.configuration.fontWeight]
|
font.weight: general.fontWeight[plasmoid.configuration.fontWeight]
|
||||||
|
|
||||||
text: plasmoid.configuration.text
|
|
||||||
|
|
||||||
PlasmaCore.ToolTipArea {
|
PlasmaCore.ToolTipArea {
|
||||||
height: tooltip.height
|
height: tooltip.height
|
||||||
width: tooltip.width
|
width: tooltip.width
|
||||||
@ -155,7 +163,7 @@ Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
if (debug) console.log("[main::onCompleted]")
|
if (debug) console.debug()
|
||||||
|
|
||||||
// actions
|
// actions
|
||||||
plasmoid.setAction("requestKey", i18n("Request key"), "utilities-system-monitor")
|
plasmoid.setAction("requestKey", i18n("Request key"), "utilities-system-monitor")
|
||||||
@ -164,29 +172,48 @@ Item {
|
|||||||
// plasmoid.setAction("report", i18n("Mail to developers"), "email")
|
// plasmoid.setAction("report", i18n("Mail to developers"), "email")
|
||||||
// init submodule
|
// init submodule
|
||||||
Plasmoid.userConfiguringChanged(false)
|
Plasmoid.userConfiguringChanged(false)
|
||||||
|
// connect data
|
||||||
|
awKeys.dropSourceFromDataengine.connect(dropSource)
|
||||||
|
awKeys.needTextToBeUpdated.connect(needTextUpdate)
|
||||||
|
awKeys.needToolTipToBeUpdated.connect(needToolTipUpdate)
|
||||||
|
// check updates if required
|
||||||
|
if (plasmoid.configuration.checkUpdates) return action_checkUpdates()
|
||||||
}
|
}
|
||||||
|
|
||||||
onNeedUpdate: {
|
onDropSource: {
|
||||||
if (debug) console.log("[main::onNeedUpdate]")
|
if (debug) console.debug()
|
||||||
|
if (debug) console.debug("Source", sourceName)
|
||||||
|
|
||||||
text.text = AWKeys.parsePattern()
|
systemmonitorDE.disconnectSource(sourceName)
|
||||||
tooltip.text = AWKeys.toolTipImage()
|
}
|
||||||
|
|
||||||
|
onNeedTextUpdate: {
|
||||||
|
if (debug) console.debug()
|
||||||
|
|
||||||
|
text.text = newText
|
||||||
sizeUpdate()
|
sizeUpdate()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onNeedToolTipUpdate: {
|
||||||
|
if (debug) console.debug()
|
||||||
|
|
||||||
|
tooltip.text = newText
|
||||||
|
}
|
||||||
|
|
||||||
onSizeUpdate: {
|
onSizeUpdate: {
|
||||||
if (debug) console.log("[main::onSizeUpdate]")
|
if (debug) console.debug()
|
||||||
|
// 16 is a magic number
|
||||||
|
// in other case plasmoid will increase own size on each update
|
||||||
|
|
||||||
if (plasmoid.configuration.height == 0) {
|
if (plasmoid.configuration.height == 0) {
|
||||||
Layout.minimumHeight = text.contentHeight
|
Layout.minimumHeight = text.contentHeight - 16
|
||||||
Layout.maximumHeight = -1
|
Layout.maximumHeight = -1
|
||||||
} else {
|
} else {
|
||||||
Layout.minimumHeight = plasmoid.configuration.height
|
Layout.minimumHeight = plasmoid.configuration.height
|
||||||
Layout.maximumHeight = plasmoid.configuration.height
|
Layout.maximumHeight = plasmoid.configuration.height
|
||||||
}
|
}
|
||||||
if (plasmoid.configuration.width == 0) {
|
if (plasmoid.configuration.width == 0) {
|
||||||
Layout.minimumWidth = text.contentWidth
|
Layout.minimumWidth = text.contentWidth - 16
|
||||||
Layout.maximumWidth = -1
|
Layout.maximumWidth = -1
|
||||||
} else {
|
} else {
|
||||||
Layout.minimumWidth = plasmoid.configuration.width
|
Layout.minimumWidth = plasmoid.configuration.width
|
||||||
@ -196,35 +223,37 @@ Item {
|
|||||||
|
|
||||||
Plasmoid.onUserConfiguringChanged: {
|
Plasmoid.onUserConfiguringChanged: {
|
||||||
if (plasmoid.userConfiguring) return
|
if (plasmoid.userConfiguring) return
|
||||||
if (debug) console.log("[main::onUserConfiguringChanged]")
|
if (debug) console.debug()
|
||||||
|
|
||||||
// init submodule
|
// init submodule
|
||||||
AWKeys.initKeys(plasmoid.configuration.text, tooltipSettings, plasmoid.configuration.notify)
|
awKeys.initKeys(plasmoid.configuration.text)
|
||||||
|
awKeys.initTooltip(tooltipSettings)
|
||||||
needUpdate()
|
awKeys.setPopupEnabled(plasmoid.configuration.notify)
|
||||||
|
awKeys.setTranslateStrings(plasmoid.configuration.translateStrings)
|
||||||
|
awKeys.setWrapNewLines(plasmoid.configuration.wrapNewLines)
|
||||||
}
|
}
|
||||||
|
|
||||||
function action_checkUpdates() {
|
function action_checkUpdates() {
|
||||||
if (debug) console.log("[main::action_checkUpdates]")
|
if (debug) console.debug()
|
||||||
|
|
||||||
AWActions.checkUpdates()
|
return awActions.checkUpdates()
|
||||||
}
|
}
|
||||||
|
|
||||||
function action_showReadme() {
|
function action_showReadme() {
|
||||||
if (debug) console.log("[main::action_showReadme]")
|
if (debug) console.debug()
|
||||||
|
|
||||||
AWActions.showReadme()
|
return awActions.showReadme()
|
||||||
}
|
}
|
||||||
|
|
||||||
function action_report() {
|
function action_report() {
|
||||||
if (debug) console.log("[main::action_report]")
|
if (debug) console.debug()
|
||||||
|
|
||||||
AWActions.sendEmail()
|
return awActions.sendEmail()
|
||||||
}
|
}
|
||||||
|
|
||||||
function action_requestKey() {
|
function action_requestKey() {
|
||||||
if (debug) console.log("[main::action_requestKey]")
|
if (debug) console.debug()
|
||||||
|
|
||||||
AWKeys.graphicalValueByKey()
|
return awKeys.graphicalValueByKey()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1 +1 @@
|
|||||||
singleton general general.qml
|
singleton general 1.0 general.qml
|
||||||
|
@ -20,17 +20,22 @@ import QtQuick.Controls 1.3 as QtControls
|
|||||||
import QtQuick.Controls.Styles 1.3 as QtStyles
|
import QtQuick.Controls.Styles 1.3 as QtStyles
|
||||||
import QtQuick.Dialogs 1.1 as QtDialogs
|
import QtQuick.Dialogs 1.1 as QtDialogs
|
||||||
|
|
||||||
import org.kde.plasma.awesomewidget 1.0
|
import org.kde.plasma.private.awesomewidget 1.0
|
||||||
|
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: tooltipPage
|
id: tooltipPage
|
||||||
|
// backend
|
||||||
|
AWActions {
|
||||||
|
id: awActions;
|
||||||
|
}
|
||||||
|
|
||||||
width: childrenRect.width
|
width: childrenRect.width
|
||||||
height: childrenRect.height
|
height: childrenRect.height
|
||||||
implicitWidth: pageColumn.implicitWidth
|
implicitWidth: pageColumn.implicitWidth
|
||||||
implicitHeight: pageColumn.implicitHeight
|
implicitHeight: pageColumn.implicitHeight
|
||||||
|
|
||||||
property bool debug: AWKeys.isDebugEnabled()
|
property bool debug: awActions.isDebugEnabled()
|
||||||
|
|
||||||
property alias cfg_tooltipNumber: tooltipNumber.value
|
property alias cfg_tooltipNumber: tooltipNumber.value
|
||||||
property alias cfg_useTooltipBackground: useTooltipBackground.checked
|
property alias cfg_useTooltipBackground: useTooltipBackground.checked
|
||||||
@ -508,6 +513,6 @@ Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
if (debug) console.log("[tooltip::onCompleted]")
|
if (debug) console.debug()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,17 +19,25 @@ import QtQuick 2.0
|
|||||||
import QtQuick.Controls 1.3 as QtControls
|
import QtQuick.Controls 1.3 as QtControls
|
||||||
import org.kde.plasma.core 2.0 as PlasmaCore
|
import org.kde.plasma.core 2.0 as PlasmaCore
|
||||||
|
|
||||||
import org.kde.plasma.awesomewidget 1.0
|
import org.kde.plasma.private.awesomewidget 1.0
|
||||||
|
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: widgetPage
|
id: widgetPage
|
||||||
|
// backend
|
||||||
|
AWKeys {
|
||||||
|
id: awKeys;
|
||||||
|
}
|
||||||
|
AWActions {
|
||||||
|
id: awActions;
|
||||||
|
}
|
||||||
|
|
||||||
width: childrenRect.width
|
width: childrenRect.width
|
||||||
height: childrenRect.height
|
height: childrenRect.height
|
||||||
implicitWidth: pageColumn.implicitWidth
|
implicitWidth: pageColumn.implicitWidth
|
||||||
implicitHeight: pageColumn.implicitHeight
|
implicitHeight: pageColumn.implicitHeight
|
||||||
|
|
||||||
property bool debug: AWKeys.isDebugEnabled()
|
property bool debug: awActions.isDebugEnabled()
|
||||||
property variant settings: {
|
property variant settings: {
|
||||||
"customTime": plasmoid.configuration.customTime,
|
"customTime": plasmoid.configuration.customTime,
|
||||||
"customUptime": plasmoid.configuration.customUptime,
|
"customUptime": plasmoid.configuration.customUptime,
|
||||||
@ -70,24 +78,25 @@ Item {
|
|||||||
verticalAlignment: Text.AlignVCenter
|
verticalAlignment: Text.AlignVCenter
|
||||||
wrapMode: Text.WordWrap
|
wrapMode: Text.WordWrap
|
||||||
text: i18n("Detailed information may be found on <a href=\"http://arcanis.name/projects/awesome-widgets/\">project homepage</a>")
|
text: i18n("Detailed information may be found on <a href=\"http://arcanis.name/projects/awesome-widgets/\">project homepage</a>")
|
||||||
|
onLinkActivated: Qt.openUrlExternally(link);
|
||||||
}
|
}
|
||||||
|
|
||||||
Row {
|
Row {
|
||||||
height: implicitHeight
|
height: implicitHeight
|
||||||
width: parent.width
|
width: parent.width
|
||||||
QtControls.Button {
|
QtControls.Button {
|
||||||
|
width: parent.width * 3 / 12
|
||||||
text: i18n("Font")
|
text: i18n("Font")
|
||||||
iconName: "font"
|
iconName: "font"
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (debug) console.log("[widget::onClicked] : Font button")
|
if (debug) console.debug("Font button")
|
||||||
|
|
||||||
var defaultFont = {
|
var defaultFont = {
|
||||||
"color": plasmoid.configuration.fontColor,
|
"color": plasmoid.configuration.fontColor,
|
||||||
"family": plasmoid.configuration.fontFamily,
|
"family": plasmoid.configuration.fontFamily,
|
||||||
"size": plasmoid.configuration.fontSize
|
"size": plasmoid.configuration.fontSize
|
||||||
}
|
}
|
||||||
var font = AWActions.getFont(defaultFont)
|
var font = awActions.getFont(defaultFont)
|
||||||
var pos = textPattern.cursorPosition
|
var pos = textPattern.cursorPosition
|
||||||
var selected = textPattern.selectedText
|
var selected = textPattern.selectedText
|
||||||
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
||||||
@ -98,11 +107,11 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
QtControls.Button {
|
QtControls.Button {
|
||||||
|
width: parent.width / 12
|
||||||
iconName: "format-indent-more"
|
iconName: "format-indent-more"
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (debug) console.log("[widget::onClicked] : Indent button")
|
if (debug) console.debug("Indent button")
|
||||||
|
|
||||||
var pos = textPattern.cursorPosition
|
var pos = textPattern.cursorPosition
|
||||||
var selected = textPattern.selectedText
|
var selected = textPattern.selectedText
|
||||||
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
||||||
@ -111,11 +120,11 @@ Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
QtControls.Button {
|
QtControls.Button {
|
||||||
|
width: parent.width / 12
|
||||||
iconName: "format-text-bold"
|
iconName: "format-text-bold"
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (debug) console.log("[widget::onClicked] : Bold button")
|
if (debug) console.debug("Bold button")
|
||||||
|
|
||||||
var pos = textPattern.cursorPosition
|
var pos = textPattern.cursorPosition
|
||||||
var selected = textPattern.selectedText
|
var selected = textPattern.selectedText
|
||||||
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
||||||
@ -123,11 +132,11 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
QtControls.Button {
|
QtControls.Button {
|
||||||
|
width: parent.width / 12
|
||||||
iconName: "format-text-italic"
|
iconName: "format-text-italic"
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (debug) console.log("[widget::onClicked] : Italic button")
|
if (debug) console.debug("Italic button")
|
||||||
|
|
||||||
var pos = textPattern.cursorPosition
|
var pos = textPattern.cursorPosition
|
||||||
var selected = textPattern.selectedText
|
var selected = textPattern.selectedText
|
||||||
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
||||||
@ -135,11 +144,11 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
QtControls.Button {
|
QtControls.Button {
|
||||||
|
width: parent.width / 12
|
||||||
iconName: "format-text-underline"
|
iconName: "format-text-underline"
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (debug) console.log("[widget::onClicked] : Underline button")
|
if (debug) console.debug("Underline button")
|
||||||
|
|
||||||
var pos = textPattern.cursorPosition
|
var pos = textPattern.cursorPosition
|
||||||
var selected = textPattern.selectedText
|
var selected = textPattern.selectedText
|
||||||
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
||||||
@ -147,11 +156,11 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
QtControls.Button {
|
QtControls.Button {
|
||||||
|
width: parent.width / 12
|
||||||
iconName: "format-text-strikethrough"
|
iconName: "format-text-strikethrough"
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (debug) console.log("[widget::onClicked] : Strike button")
|
if (debug) console.debug("Strike button")
|
||||||
|
|
||||||
var pos = textPattern.cursorPosition
|
var pos = textPattern.cursorPosition
|
||||||
var selected = textPattern.selectedText
|
var selected = textPattern.selectedText
|
||||||
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
||||||
@ -160,11 +169,11 @@ Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
QtControls.Button {
|
QtControls.Button {
|
||||||
|
width: parent.width / 12
|
||||||
iconName: "format-justify-left"
|
iconName: "format-justify-left"
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (debug) console.log("[widget::onClicked] : Left button")
|
if (debug) console.debug("Left button")
|
||||||
|
|
||||||
var pos = textPattern.cursorPosition
|
var pos = textPattern.cursorPosition
|
||||||
var selected = textPattern.selectedText
|
var selected = textPattern.selectedText
|
||||||
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
||||||
@ -172,11 +181,11 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
QtControls.Button {
|
QtControls.Button {
|
||||||
|
width: parent.width / 12
|
||||||
iconName: "format-justify-center"
|
iconName: "format-justify-center"
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (debug) console.log("[widget::onClicked] : Center button")
|
if (debug) console.debug("Center button")
|
||||||
|
|
||||||
var pos = textPattern.cursorPosition
|
var pos = textPattern.cursorPosition
|
||||||
var selected = textPattern.selectedText
|
var selected = textPattern.selectedText
|
||||||
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
||||||
@ -184,11 +193,11 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
QtControls.Button {
|
QtControls.Button {
|
||||||
|
width: parent.width / 12
|
||||||
iconName: "format-justify-right"
|
iconName: "format-justify-right"
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (debug) console.log("[widget::onClicked] : Right button")
|
if (debug) console.debug("Right button")
|
||||||
|
|
||||||
var pos = textPattern.cursorPosition
|
var pos = textPattern.cursorPosition
|
||||||
var selected = textPattern.selectedText
|
var selected = textPattern.selectedText
|
||||||
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
||||||
@ -196,11 +205,11 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
QtControls.Button {
|
QtControls.Button {
|
||||||
|
width: parent.width / 12
|
||||||
iconName: "format-justify-fill"
|
iconName: "format-justify-fill"
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (debug) console.log("[widget::onClicked] : Justify button")
|
if (debug) console.debug("Justify button")
|
||||||
|
|
||||||
var pos = textPattern.cursorPosition
|
var pos = textPattern.cursorPosition
|
||||||
var selected = textPattern.selectedText
|
var selected = textPattern.selectedText
|
||||||
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
||||||
@ -212,17 +221,81 @@ Item {
|
|||||||
Row {
|
Row {
|
||||||
height: implicitHeight
|
height: implicitHeight
|
||||||
width: parent.width
|
width: parent.width
|
||||||
|
QtControls.ComboBox {
|
||||||
|
width: (parent.width - addTagButton.width - showValueButton.width - addLambdaButton.width) / 2
|
||||||
|
textRole: "label"
|
||||||
|
model: [
|
||||||
|
{
|
||||||
|
'label': i18n("AC"),
|
||||||
|
'regexp': "^(ac|bat).*"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'label': i18n("Bars"),
|
||||||
|
'regexp': "^bar.*"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'label': i18n("CPU"),
|
||||||
|
'regexp': "^(cpu|gpu|la|ps|temp(?!erature)).*"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'label': i18n("Desktops"),
|
||||||
|
'regexp': "^(n|t)?desktop(s)?"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'label': i18n("HDD"),
|
||||||
|
'regexp': "^hdd.*"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'label': i18n("Memory"),
|
||||||
|
'regexp': "^(mem|swap).*"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'label': i18n("Network"),
|
||||||
|
'regexp': "^(netdev|(down|up(?!time)).*)"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'label': i18n("Music player"),
|
||||||
|
'regexp': "(^|d|s)(album|artist|duration|progress|title)"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'label': i18n("Scripts"),
|
||||||
|
'regexp': "^custom.*"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'label': i18n("Time"),
|
||||||
|
'regexp': ".*time$"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'label': i18n("Quotes"),
|
||||||
|
'regexp': "^(perc)?(ask|bid|price)(chg)?.*"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'label': i18n("Upgrades"),
|
||||||
|
'regexp': "^pkgcount.*"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'label': i18n("Weathers"),
|
||||||
|
'regexp': "^(weather(Id)?|humidity|pressure|temperature|timestamp)"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
onCurrentIndexChanged: {
|
||||||
|
if (debug) console.debug()
|
||||||
|
tags.model = awKeys.dictKeys(true, model[currentIndex]["regexp"])
|
||||||
|
if (debug) console.info("Init model", tags.model, "for", model[currentIndex]["label"])
|
||||||
|
tags.currentIndex = -1
|
||||||
|
}
|
||||||
|
}
|
||||||
QtControls.ComboBox {
|
QtControls.ComboBox {
|
||||||
id: tags
|
id: tags
|
||||||
width: parent.width - addTagButton.width - showValueButton.width
|
width: (parent.width - addTagButton.width - showValueButton.width - addLambdaButton.width) / 2
|
||||||
}
|
}
|
||||||
QtControls.Button {
|
QtControls.Button {
|
||||||
id: addTagButton
|
id: addTagButton
|
||||||
text: i18n("Add")
|
text: i18n("Add")
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (debug) console.log("[widget::onClicked] : Add tag button")
|
if (!tags.currentText) return
|
||||||
|
if (debug) console.debug("Add tag button")
|
||||||
var pos = textPattern.cursorPosition
|
var pos = textPattern.cursorPosition
|
||||||
var selected = textPattern.selectedText
|
var selected = textPattern.selectedText
|
||||||
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
||||||
@ -234,14 +307,26 @@ Item {
|
|||||||
text: i18n("Show value")
|
text: i18n("Show value")
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (debug) console.log("[widget::onClicked] : Show tag button")
|
if (!tags.currentText) return
|
||||||
|
if (debug) console.debug("Show tag button")
|
||||||
var message = i18n("Tag: %1", tags.currentText)
|
var message = i18n("Tag: %1", tags.currentText)
|
||||||
message += "<br>"
|
message += "<br>"
|
||||||
message += i18n("Value: %1", AWKeys.valueByKey(tags.currentText))
|
message += i18n("Value: %1", awKeys.valueByKey(tags.currentText))
|
||||||
message += "<br>"
|
message += "<br>"
|
||||||
message += i18n("Info: %1", AWKeys.infoByKey(tags.currentText))
|
message += i18n("Info: %1", awKeys.infoByKey(tags.currentText))
|
||||||
AWActions.sendNotification("tag", message)
|
awActions.sendNotification("tag", message)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
QtControls.Button {
|
||||||
|
id: addLambdaButton
|
||||||
|
text: i18n("Add lambda")
|
||||||
|
|
||||||
|
onClicked: {
|
||||||
|
if (debug) console.debug("Lambda button")
|
||||||
|
var pos = textPattern.cursorPosition
|
||||||
|
var selected = textPattern.selectedText
|
||||||
|
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
||||||
|
textPattern.insert(pos, selected + "${{\n\n}}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -252,7 +337,7 @@ Item {
|
|||||||
QtControls.Button {
|
QtControls.Button {
|
||||||
width: parent.width
|
width: parent.width
|
||||||
text: i18n("Edit bars")
|
text: i18n("Edit bars")
|
||||||
onClicked: AWKeys.editItem("graphicalitem")
|
onClicked: awKeys.editItem("graphicalitem")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -274,9 +359,8 @@ Item {
|
|||||||
interval: 5000
|
interval: 5000
|
||||||
|
|
||||||
onNewData: {
|
onNewData: {
|
||||||
if (debug) console.log("[widget::onNewData] : Update source " + sourceName)
|
if (debug) console.debug("Update source", sourceName)
|
||||||
|
awKeys.setDataBySource(sourceName, data, settings)
|
||||||
AWKeys.setDataBySource(sourceName, data, settings)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -287,9 +371,8 @@ Item {
|
|||||||
interval: 5000
|
interval: 5000
|
||||||
|
|
||||||
onNewData: {
|
onNewData: {
|
||||||
if (debug) console.log("[widget::onNewData] : Update source " + sourceName)
|
if (debug) console.debug("Update source", sourceName)
|
||||||
|
awKeys.setDataBySource(sourceName, data, settings)
|
||||||
AWKeys.setDataBySource(sourceName, data, settings)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -300,17 +383,15 @@ Item {
|
|||||||
interval: 5000
|
interval: 5000
|
||||||
|
|
||||||
onNewData: {
|
onNewData: {
|
||||||
if (debug) console.log("[widget::onNewData] : Update source " + sourceName)
|
if (debug) console.debug("Update source", sourceName)
|
||||||
|
awKeys.setDataBySource(sourceName, data, settings)
|
||||||
AWKeys.setDataBySource(sourceName, data, settings)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
if (debug) console.log("[widget::onCompleted]")
|
if (debug) console.debug()
|
||||||
|
|
||||||
// init submodule
|
// init submodule
|
||||||
AWKeys.initKeys(plasmoid.configuration.text, tooltipSettings)
|
awKeys.initKeys(plasmoid.configuration.text)
|
||||||
tags.model = AWKeys.dictKeys()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ X-Plasma-RemoteLocation=
|
|||||||
X-KDE-PluginInfo-Author=Evgeniy Alekseev aka arcanis
|
X-KDE-PluginInfo-Author=Evgeniy Alekseev aka arcanis
|
||||||
X-KDE-PluginInfo-Email=esalexeev@gmail.com
|
X-KDE-PluginInfo-Email=esalexeev@gmail.com
|
||||||
X-KDE-PluginInfo-Name=org.kde.plasma.awesomewidget
|
X-KDE-PluginInfo-Name=org.kde.plasma.awesomewidget
|
||||||
X-KDE-PluginInfo-Version=2.2.2
|
X-KDE-PluginInfo-Version=2.4.0
|
||||||
X-KDE-PluginInfo-Website=http://arcanis.name/projects/awesome-widgets/
|
X-KDE-PluginInfo-Website=http://arcanis.name/projects/awesome-widgets/
|
||||||
X-KDE-PluginInfo-Category=System Information
|
X-KDE-PluginInfo-Category=System Information
|
||||||
X-KDE-PluginInfo-Depends=
|
X-KDE-PluginInfo-Depends=
|
||||||
|
@ -1,44 +1,25 @@
|
|||||||
set (PLUGIN_NAME awplugin)
|
set(PLUGIN_NAME awplugin)
|
||||||
add_definitions(-DTRANSLATION_DOMAIN=\"plasma_applet_org.kde.plasma.awesomewidget\")
|
add_definitions(-DTRANSLATION_DOMAIN=\"plasma_applet_org.kde.plasma.awesomewidget\")
|
||||||
|
|
||||||
add_definitions (${Qt5Core_DEFINITIONS} ${Qt5Network_DEFINITIONS} ${Qt5Xml_DEFINITIONS})
|
include_directories(
|
||||||
set (Qt_INCLUDE ${Qt5Core_INCLUDE_DIRS}
|
${CMAKE_SOURCE_DIR}
|
||||||
${Qt5Network_INCLUDE_DIRS}
|
${CMAKE_BINARY_DIR}
|
||||||
${Qt5Qml_INCLUDE_DIRS}
|
${CMAKE_CURRENT_BINARY_DIR}
|
||||||
${Qt5Xml_INCLUDE_DIRS})
|
${CMAKE_CURRENT_BINARY_DIR}/../
|
||||||
set (Qt_LIBRARIES ${Qt5Core_LIBRARIES}
|
${CMAKE_CURRENT_SOURCE_DIR}/../../${PROJECT_LIBRARY}/
|
||||||
${Qt5Network_LIBRARIES}
|
${PROJECT_TRDPARTY_DIR}
|
||||||
${Qt5Qml_LIBRARIES}
|
${Qt_INCLUDE}
|
||||||
${Qt5Xml_LIBRARIES})
|
${Kf5_INCLUDE}
|
||||||
set (Kf5_INCLUDE ${I18n_INCLUDE_DIR}
|
)
|
||||||
${Notifications_INCLUDE_DIR})
|
|
||||||
set (Kf5_LIBRARIES KF5::I18n
|
|
||||||
KF5::Notifications)
|
|
||||||
|
|
||||||
include_directories (${CMAKE_SOURCE_DIR}
|
file(GLOB SUBPROJECT_SOURCE *.cpp ${PROJECT_TRDPARTY_DIR}/fontdialog/*.cpp ${CMAKE_SOURCE_DIR}/*.cpp)
|
||||||
${CMAKE_BINARY_DIR}
|
file(GLOB SUBPROJECT_UI *.ui)
|
||||||
${CMAKE_CURRENT_BINARY_DIR}
|
file(GLOB SUBPROJECT_NOTIFY *.notifyrc)
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/../
|
|
||||||
${PROJECT_TRDPARTY_DIR}
|
|
||||||
../../extsysmon
|
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/../../extsysmon
|
|
||||||
${Qt_INCLUDE}
|
|
||||||
${Kf5_INCLUDE})
|
|
||||||
|
|
||||||
# task source is required by extscripts
|
qt5_wrap_ui(SUBPROJECT_UI_HEADER ${SUBPROJECT_UI})
|
||||||
file (GLOB_RECURSE SUBPROJECT_SOURCE *.cpp ${PROJECT_TRDPARTY_DIR}/fontdialog/*.cpp
|
add_library(${PLUGIN_NAME} SHARED ${SUBPROJECT_SOURCE} ${SUBPROJECT_UI_HEADER})
|
||||||
../../extsysmon/extquotes.cpp
|
target_link_libraries(${PLUGIN_NAME} ${PROJECT_LIBRARY} ${Qt_LIBRARIES} ${Kf5_LIBRARIES})
|
||||||
../../extsysmon/extscript.cpp
|
|
||||||
../../extsysmon/extupgrade.cpp)
|
|
||||||
file (GLOB SUBPROJECT_UI *.ui)
|
|
||||||
file (GLOB SUBPROJECT_NOTIFY *.notifyrc)
|
|
||||||
set (SUBPROJECT_DESKTOP ${CMAKE_CURRENT_SOURCE_DIR}/desktops)
|
|
||||||
|
|
||||||
qt5_wrap_ui (SUBPROJECT_UI_HEADER ${SUBPROJECT_UI})
|
install(TARGETS ${PLUGIN_NAME} DESTINATION ${QML_INSTALL_DIR}/org/kde/plasma/private/awesomewidget)
|
||||||
add_library (${PLUGIN_NAME} SHARED ${SUBPROJECT_SOURCE} ${SUBPROJECT_UI_HEADER})
|
install(FILES qmldir DESTINATION ${QML_INSTALL_DIR}/org/kde/plasma/private/awesomewidget)
|
||||||
target_link_libraries (${PLUGIN_NAME} ${Qt_LIBRARIES} ${Kf5_LIBRARIES})
|
install(FILES ${SUBPROJECT_NOTIFY} DESTINATION ${KNOTIFYRC_INSTALL_DIR})
|
||||||
|
|
||||||
install (TARGETS ${PLUGIN_NAME} DESTINATION ${QML_INSTALL_DIR}/org/kde/plasma/awesomewidget)
|
|
||||||
install (FILES qmldir DESTINATION ${QML_INSTALL_DIR}/org/kde/plasma/awesomewidget)
|
|
||||||
install (FILES ${SUBPROJECT_NOTIFY} DESTINATION ${KNOTIFYRC_INSTALL_DIR})
|
|
||||||
install (DIRECTORY ${SUBPROJECT_DESKTOP} DESTINATION ${DATA_INSTALL_DIR}/${PROJECT_NAME})
|
|
||||||
|
@ -20,9 +20,10 @@
|
|||||||
#include <KI18n/KLocalizedString>
|
#include <KI18n/KLocalizedString>
|
||||||
#include <KNotifications/KNotification>
|
#include <KNotifications/KNotification>
|
||||||
|
|
||||||
#include <QDebug>
|
|
||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
#include <QJsonDocument>
|
||||||
|
#include <QJsonParseError>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QNetworkAccessManager>
|
#include <QNetworkAccessManager>
|
||||||
#include <QNetworkRequest>
|
#include <QNetworkRequest>
|
||||||
@ -33,32 +34,27 @@
|
|||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
|
|
||||||
#include <fontdialog/fontdialog.h>
|
#include <fontdialog/fontdialog.h>
|
||||||
#include <pdebug/pdebug.h>
|
|
||||||
|
|
||||||
#include "extscript.h"
|
#include "awdebug.h"
|
||||||
#include "graphicalitem.h"
|
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
|
||||||
|
|
||||||
AWActions::AWActions(QObject *parent)
|
AWActions::AWActions(QObject *parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
{
|
{
|
||||||
// debug
|
qCDebug(LOG_AW);
|
||||||
QProcessEnvironment environment = QProcessEnvironment::systemEnvironment();
|
|
||||||
QString debugEnv = environment.value(QString("DEBUG"), QString("no"));
|
|
||||||
debug = (debugEnv == QString("yes"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
AWActions::~AWActions()
|
AWActions::~AWActions()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
qCDebug(LOG_AW);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void AWActions::checkUpdates()
|
void AWActions::checkUpdates()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
qCDebug(LOG_AW);
|
||||||
|
|
||||||
QNetworkAccessManager *manager = new QNetworkAccessManager(this);
|
QNetworkAccessManager *manager = new QNetworkAccessManager(this);
|
||||||
connect(manager, SIGNAL(finished(QNetworkReply *)), this, SLOT(versionReplyRecieved(QNetworkReply *)));
|
connect(manager, SIGNAL(finished(QNetworkReply *)), this, SLOT(versionReplyRecieved(QNetworkReply *)));
|
||||||
@ -67,10 +63,29 @@ void AWActions::checkUpdates()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void AWActions::runCmd(const QString cmd)
|
bool AWActions::dropCache() const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
qCDebug(LOG_AW);
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd" << cmd;
|
|
||||||
|
QString fileName = QString("%1/awesomewidgets.ndx")
|
||||||
|
.arg(QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation));
|
||||||
|
|
||||||
|
return QFile(fileName).remove();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool AWActions::isDebugEnabled() const
|
||||||
|
{
|
||||||
|
qCDebug(LOG_AW);
|
||||||
|
|
||||||
|
return LOG_AW().isDebugEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void AWActions::runCmd(const QString cmd) const
|
||||||
|
{
|
||||||
|
qCDebug(LOG_AW);
|
||||||
|
qCDebug(LOG_AW) << "Cmd" << cmd;
|
||||||
|
|
||||||
QProcess command;
|
QProcess command;
|
||||||
sendNotification(QString("Info"), i18n("Run %1", cmd));
|
sendNotification(QString("Info"), i18n("Run %1", cmd));
|
||||||
@ -79,28 +94,30 @@ void AWActions::runCmd(const QString cmd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void AWActions::sendEmail()
|
void AWActions::sendEmail() const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
qCDebug(LOG_AW);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void AWActions::showReadme()
|
void AWActions::showReadme() const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
qCDebug(LOG_AW);
|
||||||
|
|
||||||
QDesktopServices::openUrl(QString(HOMEPAGE));
|
QDesktopServices::openUrl(QString(HOMEPAGE));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString AWActions::getAboutText(const QString type)
|
QString AWActions::getAboutText(const QString type) const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
qCDebug(LOG_AW);
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Type" << type;
|
qCDebug(LOG_AW) << "Type" << type;
|
||||||
|
|
||||||
QString text;
|
QString text;
|
||||||
if (type == QString("header"))
|
if (type == QString("header"))
|
||||||
text = QString(NAME);
|
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"))
|
else if (type == QString("description"))
|
||||||
text = i18n("A set of minimalistic plasmoid widgets");
|
text = i18n("A set of minimalistic plasmoid widgets");
|
||||||
else if (type == QString("links"))
|
else if (type == QString("links"))
|
||||||
@ -120,9 +137,9 @@ QString AWActions::getAboutText(const QString type)
|
|||||||
QStringList trdPartyList = QString(TRDPARTY_LICENSE).split(QChar(';'), QString::SkipEmptyParts);
|
QStringList trdPartyList = QString(TRDPARTY_LICENSE).split(QChar(';'), QString::SkipEmptyParts);
|
||||||
for (int i=0; i<trdPartyList.count(); i++)
|
for (int i=0; i<trdPartyList.count(); i++)
|
||||||
trdPartyList[i] = QString("<a href=\"%3\">%1</a> (%2 license)")
|
trdPartyList[i] = QString("<a href=\"%3\">%1</a> (%2 license)")
|
||||||
.arg(trdPartyList[i].split(QChar(','))[0])
|
.arg(trdPartyList.at(i).split(QChar(','))[0])
|
||||||
.arg(trdPartyList[i].split(QChar(','))[1])
|
.arg(trdPartyList.at(i).split(QChar(','))[1])
|
||||||
.arg(trdPartyList[i].split(QChar(','))[2]);
|
.arg(trdPartyList.at(i).split(QChar(','))[2]);
|
||||||
text = i18n("This software uses: %1", trdPartyList.join(QString(", ")));
|
text = i18n("This software uses: %1", trdPartyList.join(QString(", ")));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,11 +147,12 @@ 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;
|
qCDebug(LOG_AW);
|
||||||
|
qCDebug(LOG_AW) << "Default font is" << defaultFont;
|
||||||
|
|
||||||
QMap<QString, QVariant> fontMap;
|
QVariantMap fontMap;
|
||||||
CFont defaultCFont = CFont(defaultFont[QString("family")].toString(),
|
CFont defaultCFont = CFont(defaultFont[QString("family")].toString(),
|
||||||
defaultFont[QString("size")].toInt(),
|
defaultFont[QString("size")].toInt(),
|
||||||
400, false, defaultFont[QString("color")].toString());
|
400, false, defaultFont[QString("color")].toString());
|
||||||
@ -148,14 +166,14 @@ QMap<QString, QVariant> AWActions::getFont(const QMap<QString, QVariant> default
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QMap<QString, QVariant> AWActions::readDataEngineConfiguration()
|
QVariantMap AWActions::readDataEngineConfiguration() const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
qCDebug(LOG_AW);
|
||||||
|
|
||||||
QString fileName = QStandardPaths::locate(QStandardPaths::ConfigLocation, QString("plasma-dataengine-extsysmon.conf"));
|
QString fileName = QStandardPaths::locate(QStandardPaths::ConfigLocation, QString("plasma-dataengine-extsysmon.conf"));
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Configuration file" << fileName;
|
qCInfo(LOG_AW) << "Configuration file" << fileName;
|
||||||
QSettings settings(fileName, QSettings::IniFormat);
|
QSettings settings(fileName, QSettings::IniFormat);
|
||||||
QMap<QString, QVariant> configuration;
|
QVariantMap configuration;
|
||||||
|
|
||||||
settings.beginGroup(QString("Configuration"));
|
settings.beginGroup(QString("Configuration"));
|
||||||
configuration[QString("ACPIPATH")] = settings.value(QString("ACPIPATH"), QString("/sys/class/power_supply/"));
|
configuration[QString("ACPIPATH")] = settings.value(QString("ACPIPATH"), QString("/sys/class/power_supply/"));
|
||||||
@ -166,19 +184,20 @@ QMap<QString, QVariant> AWActions::readDataEngineConfiguration()
|
|||||||
configuration[QString("MPDPORT")] = settings.value(QString("MPDPORT"), QString("6600"));
|
configuration[QString("MPDPORT")] = settings.value(QString("MPDPORT"), QString("6600"));
|
||||||
configuration[QString("MPRIS")] = settings.value(QString("MPRIS"), QString("auto"));
|
configuration[QString("MPRIS")] = settings.value(QString("MPRIS"), QString("auto"));
|
||||||
configuration[QString("PLAYER")] = settings.value(QString("PLAYER"), QString("mpris"));
|
configuration[QString("PLAYER")] = settings.value(QString("PLAYER"), QString("mpris"));
|
||||||
|
configuration[QString("PLAYERSYMBOLS")] = settings.value(QString("PLAYERSYMBOLS"), QString("10"));
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
|
|
||||||
return configuration;
|
return configuration;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void AWActions::writeDataEngineConfiguration(const QMap<QString, QVariant> configuration)
|
void AWActions::writeDataEngineConfiguration(const QVariantMap configuration) const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
qCDebug(LOG_AW);
|
||||||
|
|
||||||
QString fileName = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) + QString("/plasma-dataengine-extsysmon.conf");
|
QString fileName = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) + QString("/plasma-dataengine-extsysmon.conf");
|
||||||
QSettings settings(fileName, QSettings::IniFormat);
|
QSettings settings(fileName, QSettings::IniFormat);
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Configuration file" << settings.fileName();
|
qCInfo(LOG_AW) << "Configuration file" << settings.fileName();
|
||||||
|
|
||||||
settings.beginGroup(QString("Configuration"));
|
settings.beginGroup(QString("Configuration"));
|
||||||
settings.setValue(QString("ACPIPATH"), configuration[QString("ACPIPATH")]);
|
settings.setValue(QString("ACPIPATH"), configuration[QString("ACPIPATH")]);
|
||||||
@ -189,14 +208,19 @@ void AWActions::writeDataEngineConfiguration(const QMap<QString, QVariant> confi
|
|||||||
settings.setValue(QString("MPDPORT"), configuration[QString("MPDPORT")]);
|
settings.setValue(QString("MPDPORT"), configuration[QString("MPDPORT")]);
|
||||||
settings.setValue(QString("MPRIS"), configuration[QString("MPRIS")]);
|
settings.setValue(QString("MPRIS"), configuration[QString("MPRIS")]);
|
||||||
settings.setValue(QString("PLAYER"), configuration[QString("PLAYER")]);
|
settings.setValue(QString("PLAYER"), configuration[QString("PLAYER")]);
|
||||||
|
settings.setValue(QString("PLAYERSYMBOLS"), configuration[QString("PLAYERSYMBOLS")]);
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
|
|
||||||
settings.sync();
|
settings.sync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void AWActions::sendNotification(const QString eventId, const QString message, const bool enablePopup)
|
void AWActions::sendNotification(const QString eventId, const QString message,
|
||||||
|
const bool enablePopup)
|
||||||
{
|
{
|
||||||
|
qCDebug(LOG_AW);
|
||||||
|
qCDebug(LOG_AW) << "Event" << eventId;
|
||||||
|
qCDebug(LOG_AW) << "Message" << message;
|
||||||
if ((eventId == QString("event")) && (!enablePopup)) return;
|
if ((eventId == QString("event")) && (!enablePopup)) return;
|
||||||
|
|
||||||
KNotification *notification = KNotification::event(eventId, QString("Awesome Widget ::: %1").arg(eventId), message);
|
KNotification *notification = KNotification::event(eventId, QString("Awesome Widget ::: %1").arg(eventId), message);
|
||||||
@ -204,16 +228,17 @@ void AWActions::sendNotification(const QString eventId, const QString message, c
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void AWActions::showUpdates(QString version)
|
void AWActions::showUpdates(QString version) const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
qCDebug(LOG_AW);
|
||||||
|
|
||||||
QString text;
|
QString text;
|
||||||
text += i18n("Current version : %1", QString(VERSION)) + QString("\n");
|
text += i18n("Current version : %1", QString(VERSION)) + QString("\n");
|
||||||
text += i18n("New version : %1", version) + QString("\n\n");
|
text += i18n("New version : %1", version) + QString("\n\n");
|
||||||
text += i18n("Click \"Ok\" to download");
|
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) {
|
switch (select) {
|
||||||
case QMessageBox::Ok:
|
case QMessageBox::Ok:
|
||||||
QDesktopServices::openUrl(QString(RELEASES) + version);
|
QDesktopServices::openUrl(QString(RELEASES) + version);
|
||||||
@ -222,30 +247,35 @@ void AWActions::showUpdates(QString version)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void AWActions::versionReplyRecieved(QNetworkReply *reply)
|
void AWActions::versionReplyRecieved(QNetworkReply *reply) const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
qCDebug(LOG_AW);
|
||||||
|
qCDebug(LOG_AW) << "Return code" << reply->error();
|
||||||
|
qCDebug(LOG_AW) << "Reply error message" << reply->errorString();
|
||||||
|
|
||||||
QString answer = reply->readAll();
|
QJsonParseError error;
|
||||||
if (!answer.contains(QString("tag_name"))) return;
|
QJsonDocument jsonDoc = QJsonDocument::fromJson(reply->readAll(), &error);
|
||||||
QString version = QString(VERSION);
|
reply->deleteLater();
|
||||||
if (debug) qDebug() << PDEBUG << answer;
|
if ((reply->error() != QNetworkReply::NoError) ||
|
||||||
for (int i=0; i<answer.split(QString("tag_name")).count(); i++) {
|
(error.error != QJsonParseError::NoError)) {
|
||||||
version = answer.split(QString("tag_name"))[1].split(QChar(','))[0];
|
qCWarning(LOG_AW) << "Parse error" << error.errorString();
|
||||||
version.remove(QChar('"'));
|
return;
|
||||||
version.remove(QChar(':'));
|
|
||||||
version.remove(QString("V."));
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int old_major = QString(VERSION).split(QChar('.'))[0].toInt();
|
// convert to map
|
||||||
int old_minor = QString(VERSION).split(QChar('.'))[1].toInt();
|
QVariantMap firstRelease = jsonDoc.toVariant().toList().first().toMap();
|
||||||
int old_patch = QString(VERSION).split(QChar('.'))[2].toInt();
|
QString version = firstRelease[QString("tag_name")].toString();
|
||||||
int new_major = QString(version).split(QChar('.'))[0].toInt();
|
version.remove(QString("V."));
|
||||||
int new_minor = QString(version).split(QChar('.'))[1].toInt();
|
qCInfo(LOG_AW) << "Found version" << version;
|
||||||
int new_patch = QString(version).split(QChar('.'))[2].toInt();
|
|
||||||
|
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) ||
|
if ((old_major < new_major) ||
|
||||||
((old_major == new_major) && (old_minor < new_minor)) ||
|
((old_major == new_major) && (old_minor < new_minor)) ||
|
||||||
((old_major == new_major) && (old_minor == new_minor) && (old_patch < new_patch)))
|
((old_major == new_major) && (old_minor == new_minor) && (old_patch < new_patch)))
|
||||||
showUpdates(version);
|
return showUpdates(version);
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,6 @@
|
|||||||
#ifndef AWACTIONS_H
|
#ifndef AWACTIONS_H
|
||||||
#define AWACTIONS_H
|
#define AWACTIONS_H
|
||||||
|
|
||||||
#include <QMap>
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
|
|
||||||
@ -31,31 +30,31 @@ class AWActions : public QObject
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AWActions(QObject *parent = nullptr);
|
explicit AWActions(QObject *parent = nullptr);
|
||||||
~AWActions();
|
virtual ~AWActions();
|
||||||
|
|
||||||
Q_INVOKABLE void checkUpdates();
|
Q_INVOKABLE void checkUpdates();
|
||||||
Q_INVOKABLE void runCmd(const QString cmd = QString("/usr/bin/true"));
|
Q_INVOKABLE bool dropCache() const;
|
||||||
Q_INVOKABLE void sendEmail();
|
Q_INVOKABLE bool isDebugEnabled() const;
|
||||||
Q_INVOKABLE void showReadme();
|
Q_INVOKABLE void runCmd(const QString cmd = QString("/usr/bin/true")) const;
|
||||||
|
Q_INVOKABLE void sendEmail() const;
|
||||||
|
Q_INVOKABLE void showReadme() const;
|
||||||
// configuration slots
|
// configuration slots
|
||||||
Q_INVOKABLE QString getAboutText(const QString type = QString("header"));
|
Q_INVOKABLE QString getAboutText(const QString type = QString("header")) const;
|
||||||
Q_INVOKABLE QMap<QString, QVariant> getFont(const QMap<QString, QVariant> defaultFont);
|
Q_INVOKABLE QVariantMap getFont(const QVariantMap defaultFont) const;
|
||||||
// dataengine
|
// dataengine
|
||||||
Q_INVOKABLE QMap<QString, QVariant> readDataEngineConfiguration();
|
Q_INVOKABLE QVariantMap readDataEngineConfiguration() const;
|
||||||
Q_INVOKABLE void writeDataEngineConfiguration(const QMap<QString, QVariant> configuration);
|
Q_INVOKABLE void writeDataEngineConfiguration(const QVariantMap configuration) const;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
Q_INVOKABLE static void sendNotification(const QString eventId, const QString message,
|
Q_INVOKABLE static void sendNotification(const QString eventId, const QString message,
|
||||||
const bool enablePopup = false);
|
const bool enablePopup = false);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void showUpdates(QString version);
|
void showUpdates(QString version) const;
|
||||||
void versionReplyRecieved(QNetworkReply *reply);
|
void versionReplyRecieved(QNetworkReply *reply) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// variables
|
|
||||||
bool debug = false;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -23,28 +23,10 @@
|
|||||||
#include "awkeys.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)
|
void AWPlugin::registerTypes(const char *uri)
|
||||||
{
|
{
|
||||||
Q_ASSERT(uri == QLatin1String("org.kde.plasma.awesomewidget"));
|
Q_ASSERT(uri == QLatin1String("org.kde.plasma.private.awesomewidget"));
|
||||||
|
|
||||||
qmlRegisterSingletonType<AWActions>(uri, 1, 0, "AWActions", awactions_singletontype_provider);
|
qmlRegisterType<AWActions>(uri, 1, 0, "AWActions");
|
||||||
qmlRegisterSingletonType<AWKeys>(uri, 1, 0, "AWKeys", awkeys_singletontype_provider);
|
qmlRegisterType<AWKeys>(uri, 1, 0, "AWKeys");
|
||||||
}
|
}
|
||||||
|
@ -19,106 +19,82 @@
|
|||||||
#ifndef AWKEYS_H
|
#ifndef AWKEYS_H
|
||||||
#define AWKEYS_H
|
#define AWKEYS_H
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QHash>
|
||||||
#include <QDialogButtonBox>
|
|
||||||
#include <QListWidget>
|
|
||||||
#include <QMap>
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QPushButton>
|
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
|
|
||||||
|
#include "extitemaggregator.h"
|
||||||
|
#include "version.h"
|
||||||
|
|
||||||
|
|
||||||
class AWToolTip;
|
class AWToolTip;
|
||||||
class ExtQuotes;
|
class ExtQuotes;
|
||||||
class ExtScript;
|
class ExtScript;
|
||||||
class ExtUpgrade;
|
class ExtUpgrade;
|
||||||
|
class ExtWeather;
|
||||||
class GraphicalItem;
|
class GraphicalItem;
|
||||||
|
|
||||||
class AWKeys : public QObject
|
class AWKeys : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
enum RequestedItem {
|
|
||||||
Nothing,
|
|
||||||
RequestedGraphicalItem,
|
|
||||||
RequestedExtQuotes,
|
|
||||||
RequestedExtScript,
|
|
||||||
RequestedExtUpgrade
|
|
||||||
};
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AWKeys(QObject *parent = nullptr);
|
explicit AWKeys(QObject *parent = nullptr);
|
||||||
~AWKeys();
|
virtual ~AWKeys();
|
||||||
|
|
||||||
Q_INVOKABLE void initKeys(const QString currentPattern,
|
Q_INVOKABLE void initKeys(const QString currentPattern);
|
||||||
const QMap<QString, QVariant> tooltipParams,
|
Q_INVOKABLE void initTooltip(const QVariantMap tooltipParams);
|
||||||
const bool popup = false);
|
Q_INVOKABLE void setPopupEnabled(const bool popup = false);
|
||||||
Q_INVOKABLE bool isDebugEnabled();
|
Q_INVOKABLE void setTranslateStrings(const bool translate = false);
|
||||||
Q_INVOKABLE QString parsePattern();
|
Q_INVOKABLE void setWrapNewLines(const bool wrap = false);
|
||||||
Q_INVOKABLE QString toolTipImage();
|
Q_INVOKABLE QSize toolTipSize() const;
|
||||||
Q_INVOKABLE QSize toolTipSize();
|
|
||||||
// keys
|
// keys
|
||||||
Q_INVOKABLE void addDevice(const QString source);
|
Q_INVOKABLE void addDevice(const QString source);
|
||||||
Q_INVOKABLE QStringList dictKeys();
|
Q_INVOKABLE QStringList dictKeys(const bool sorted = false,
|
||||||
Q_INVOKABLE QStringList getHddDevices();
|
const QString regexp = QString()) const;
|
||||||
Q_INVOKABLE bool setDataBySource(const QString sourceName,
|
Q_INVOKABLE QStringList getHddDevices() const;
|
||||||
const QMap<QString, QVariant> data,
|
Q_INVOKABLE void setDataBySource(const QString sourceName, const QVariantMap data,
|
||||||
const QMap<QString, QVariant> params);
|
const QVariantMap params);
|
||||||
// values
|
// values
|
||||||
Q_INVOKABLE void graphicalValueByKey();
|
Q_INVOKABLE void graphicalValueByKey() const;
|
||||||
Q_INVOKABLE QString infoByKey(QString key);
|
Q_INVOKABLE QString infoByKey(QString key) const;
|
||||||
Q_INVOKABLE QString valueByKey(QString key);
|
Q_INVOKABLE QString valueByKey(QString key) const;
|
||||||
// configuration
|
// configuration
|
||||||
Q_INVOKABLE void editItem(const QString type);
|
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:
|
private slots:
|
||||||
|
void dataUpdate();
|
||||||
void loadKeysFromCache();
|
void loadKeysFromCache();
|
||||||
void reinitKeys();
|
void reinitKeys();
|
||||||
// editor
|
|
||||||
void editItemButtonPressed(QAbstractButton *button);
|
|
||||||
void copyBar(const QString original);
|
|
||||||
void copyQuotes(const QString original);
|
|
||||||
void copyScript(const QString original);
|
|
||||||
void copyUpgrade(const QString original);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// methods
|
// methods
|
||||||
void addKeyToCache(const QString type, const QString key = QString(""));
|
void addKeyToCache(const QString type, const QString key = QString(""));
|
||||||
bool checkKeys(const QMap<QString, QVariant> data);
|
void calculateLambdas();
|
||||||
QString networkDevice();
|
QString parsePattern() const;
|
||||||
int numberCpus();
|
float temperature(const float temp, const QString units) const;
|
||||||
float temperature(const float temp, const QString units);
|
|
||||||
// find methods
|
|
||||||
QStringList findGraphicalItems();
|
|
||||||
QStringList findKeys();
|
|
||||||
// get methods
|
// get methods
|
||||||
QList<ExtQuotes *> getExtQuotes();
|
|
||||||
QList<ExtScript *> getExtScripts();
|
|
||||||
QList<ExtUpgrade *> getExtUpgrade();
|
|
||||||
QList<GraphicalItem *> getGraphicalItems();
|
|
||||||
GraphicalItem *getItemByTag(const QString tag);
|
|
||||||
QStringList getTimeKeys();
|
|
||||||
AWToolTip *toolTip = nullptr;
|
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 enablePopup = false;
|
||||||
QList<GraphicalItem *> graphicalItems;
|
bool translateStrings = false;
|
||||||
QList<ExtQuotes *> extQuotes;
|
bool wrapNewLines = false;
|
||||||
QList<ExtScript *> extScripts;
|
ExtItemAggregator<GraphicalItem> *graphicalItems;
|
||||||
QList<ExtUpgrade *> extUpgrade;
|
ExtItemAggregator<ExtQuotes> *extQuotes;
|
||||||
QStringList foundBars, foundKeys, keys;
|
ExtItemAggregator<ExtScript> *extScripts;
|
||||||
|
ExtItemAggregator<ExtUpgrade> *extUpgrade;
|
||||||
|
ExtItemAggregator<ExtWeather> *extWeather;
|
||||||
QString pattern;
|
QString pattern;
|
||||||
QMap<QString, QString> values;
|
QStringList foundBars, foundKeys, foundLambdas;
|
||||||
QStringList diskDevices, fanDevices, hddDevices, mountDevices, networkDevices, tempDevices;
|
QStringList timeKeys = QString(TIME_KEYS).split(QChar(','));
|
||||||
|
QHash<QString, QString> values;
|
||||||
|
QStringList diskDevices, hddDevices, mountDevices, networkDevices, tempDevices;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -17,24 +17,19 @@
|
|||||||
|
|
||||||
#include "awtooltip.h"
|
#include "awtooltip.h"
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QBuffer>
|
||||||
#include <QProcessEnvironment>
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
#include <pdebug/pdebug.h>
|
#include "awdebug.h"
|
||||||
|
|
||||||
|
|
||||||
AWToolTip::AWToolTip(QObject *parent,
|
AWToolTip::AWToolTip(QObject *parent, QVariantMap settings)
|
||||||
QMap<QString, QVariant> settings)
|
|
||||||
: QObject(parent),
|
: QObject(parent),
|
||||||
configuration(settings)
|
configuration(qvariant_cast<QVariantHash>(settings))
|
||||||
{
|
{
|
||||||
// debug
|
qCDebug(LOG_AW);
|
||||||
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 = new QGraphicsView(toolTipScene);
|
||||||
toolTipView->setStyleSheet(QString("background: transparent"));
|
toolTipView->setStyleSheet(QString("background: transparent"));
|
||||||
toolTipView->setContentsMargins(0, 0, 0, 0);
|
toolTipView->setContentsMargins(0, 0, 0, 0);
|
||||||
@ -66,70 +61,108 @@ AWToolTip::AWToolTip(QObject *parent,
|
|||||||
if (configuration[QString("downTooltip")].toBool()) requiredKeys.append(QString("downTooltip"));
|
if (configuration[QString("downTooltip")].toBool()) requiredKeys.append(QString("downTooltip"));
|
||||||
if (configuration[QString("upTooltip")].toBool()) requiredKeys.append(QString("upTooltip"));
|
if (configuration[QString("upTooltip")].toBool()) requiredKeys.append(QString("upTooltip"));
|
||||||
if (configuration[QString("batTooltip")].toBool()) requiredKeys.append(QString("batTooltip"));
|
if (configuration[QString("batTooltip")].toBool()) requiredKeys.append(QString("batTooltip"));
|
||||||
|
|
||||||
|
connect(this, SIGNAL(updateData(QHash<QString, QString>)),
|
||||||
|
this, SLOT(dataUpdate(QHash<QString, QString>)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
AWToolTip::~AWToolTip()
|
AWToolTip::~AWToolTip()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
qCDebug(LOG_AW);
|
||||||
|
|
||||||
delete toolTipView;
|
|
||||||
delete toolTipScene;
|
delete toolTipScene;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QSize AWToolTip::getSize()
|
void AWToolTip::dataUpdate(QHash<QString, QString> values)
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
qCDebug(LOG_AW);
|
||||||
|
|
||||||
|
// battery update requires info is AC online or not
|
||||||
|
setData(QString("batTooltip"), values[QString("bat")].toFloat(),
|
||||||
|
values[QString("ac")] == configuration[QString("acOnline")]);
|
||||||
|
// usual case
|
||||||
|
setData(QString("cpuTooltip"), values[QString("cpu")].toFloat());
|
||||||
|
setData(QString("cpuclTooltip"), values[QString("cpucl")].toFloat());
|
||||||
|
setData(QString("memTooltip"), values[QString("mem")].toFloat());
|
||||||
|
setData(QString("swapTooltip"), values[QString("swap")].toFloat());
|
||||||
|
setData(QString("downTooltip"), values[QString("downkb")].toFloat());
|
||||||
|
setData(QString("upTooltip"), values[QString("upkb")].toFloat());
|
||||||
|
|
||||||
|
emit(toolTipPainted(htmlImage()));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QSize AWToolTip::getSize() const
|
||||||
|
{
|
||||||
|
qCDebug(LOG_AW);
|
||||||
|
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString AWToolTip::htmlImage()
|
||||||
|
{
|
||||||
|
qCDebug(LOG_AW);
|
||||||
|
|
||||||
|
QPixmap rawImage = image();
|
||||||
|
QByteArray byteArray;
|
||||||
|
QBuffer buffer(&byteArray);
|
||||||
|
rawImage.save(&buffer, "PNG");
|
||||||
|
|
||||||
|
return byteArray.isEmpty() ? QString() :
|
||||||
|
QString("<img src=\"data:image/png;base64,%1\"/>").arg(QString(byteArray.toBase64()));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QPixmap AWToolTip::image()
|
QPixmap AWToolTip::image()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
qCDebug(LOG_AW);
|
||||||
|
|
||||||
toolTipView->resize(size);
|
toolTipView->resize(size);
|
||||||
// create image
|
// create image
|
||||||
toolTipScene->clear();
|
toolTipScene->clear();
|
||||||
QPen pen = QPen();
|
QPen pen = QPen();
|
||||||
// background
|
// background
|
||||||
if (configuration[QString("useTooltipBackground")].toBool())
|
toolTipScene->setBackgroundBrush(configuration[QString("useTooltipBackground")].toBool() ?
|
||||||
toolTipScene->setBackgroundBrush(QBrush(QColor(configuration[QString("tooltipBackground")].toString())));
|
QBrush(QColor(configuration[QString("tooltipBackground")].toString())) :
|
||||||
else
|
QBrush(Qt::NoBrush));
|
||||||
toolTipScene->setBackgroundBrush(QBrush(Qt::NoBrush));
|
|
||||||
bool down = false;
|
bool down = false;
|
||||||
for (int i=0; i<requiredKeys.count(); i++) {
|
for (int i=0; i<requiredKeys.count(); i++) {
|
||||||
float normX = 100.0 / static_cast<float>(data[requiredKeys[i]].count());
|
float normX = 100.0 / static_cast<float>(data[requiredKeys.at(i)].count());
|
||||||
float normY = 100.0 / (1.5 * boundaries[requiredKeys[i]]);
|
float normY = 100.0 / (1.5 * boundaries[requiredKeys.at(i)]);
|
||||||
if (requiredKeys[i] != QString("batTooltip"))
|
if (requiredKeys.at(i) != QString("batTooltip"))
|
||||||
pen.setColor(QColor(configuration[QString("%1Color").arg(requiredKeys[i])].toString()));
|
pen.setColor(QColor(configuration[QString("%1Color").arg(requiredKeys.at(i))].toString()));
|
||||||
float shift = i * 100.0;
|
float shift = i * 100.0;
|
||||||
if (down) shift -= 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++) {
|
||||||
|
// some magic here
|
||||||
float x1 = j * normX + shift;
|
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 x2 = (j + 1) * normX + shift;
|
||||||
float y2 = - fabs(data[requiredKeys[i]][j+1]) * normY + 5.0;
|
float y2 = - fabs(data[requiredKeys.at(i)].at(j+1)) * normY + 5.0;
|
||||||
if (requiredKeys[i] == QString("batTooltip")) {
|
if (requiredKeys.at(i) == QString("batTooltip")) {
|
||||||
if (data[requiredKeys[i]][j+1] > 0)
|
if (data[requiredKeys.at(i)].at(j+1) > 0)
|
||||||
pen.setColor(QColor(configuration[QString("batTooltipColor")].toString()));
|
pen.setColor(QColor(configuration[QString("batTooltipColor")].toString()));
|
||||||
else
|
else
|
||||||
pen.setColor(QColor(configuration[QString("batInTooltipColor")].toString()));
|
pen.setColor(QColor(configuration[QString("batInTooltipColor")].toString()));
|
||||||
}
|
}
|
||||||
toolTipScene->addLine(x1, y1, x2, y2, pen);
|
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();
|
return toolTipView->grab();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void AWToolTip::setData(const QString source, float value, const bool ac)
|
void AWToolTip::setData(const QString source, float value, const bool dontInvert)
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
qCDebug(LOG_AW);
|
||||||
|
qCDebug(LOG_AW) << "Source" << source;
|
||||||
|
qCDebug(LOG_AW) << "Value" << value;
|
||||||
|
qCDebug(LOG_AW) << "Do not invert value" << dontInvert;
|
||||||
|
|
||||||
if (data[source].count() == 0)
|
if (data[source].count() == 0)
|
||||||
data[source].append(0.0);
|
data[source].append(0.0);
|
||||||
@ -137,19 +170,12 @@ void AWToolTip::setData(const QString source, float value, const bool ac)
|
|||||||
data[source].takeFirst();
|
data[source].takeFirst();
|
||||||
if (isnan(value)) value = 0.0;
|
if (isnan(value)) value = 0.0;
|
||||||
|
|
||||||
if (ac)
|
// invert values for different battery colours
|
||||||
data[source].append(value);
|
data[source].append(dontInvert ? value : -value);
|
||||||
else
|
|
||||||
data[source].append(-value);
|
|
||||||
|
|
||||||
if ((source == QString("downTooltip")) || (source == QString("upTooltip"))) {
|
if (source == QString("downTooltip")) {
|
||||||
for (int i=0; i<data[QString("downTooltip")].count(); i++)
|
QList<float> netValues = data[QString("downTooltip")] + data[QString("upTooltip")];
|
||||||
if (boundaries[QString("downTooltip")] < data[QString("downTooltip")][i])
|
boundaries[QString("downTooltip")] = 1.2 * *std::max_element(netValues.cbegin(), netValues.cend());
|
||||||
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];
|
|
||||||
boundaries[QString("downTooltip")] *= 1.2;
|
|
||||||
boundaries[QString("upTooltip")] = boundaries[QString("downTooltip")];
|
boundaries[QString("upTooltip")] = boundaries[QString("downTooltip")];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
#include <QGraphicsScene>
|
#include <QGraphicsScene>
|
||||||
#include <QGraphicsView>
|
#include <QGraphicsView>
|
||||||
#include <QMap>
|
#include <QHash>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QPixmap>
|
#include <QPixmap>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
@ -32,25 +32,30 @@ class AWToolTip : public QObject
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AWToolTip(QObject *parent = nullptr,
|
explicit AWToolTip(QObject *parent = nullptr, QVariantMap settings = QVariantMap());
|
||||||
QMap<QString, QVariant> settings = QMap<QString, QVariant>());
|
virtual ~AWToolTip();
|
||||||
~AWToolTip();
|
QSize getSize() const;
|
||||||
|
QString htmlImage();
|
||||||
QSize getSize();
|
|
||||||
QPixmap image();
|
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:
|
private:
|
||||||
// ui
|
// ui
|
||||||
QGraphicsScene *toolTipScene = nullptr;
|
QGraphicsScene *toolTipScene = nullptr;
|
||||||
QGraphicsView *toolTipView = nullptr;
|
QGraphicsView *toolTipView = nullptr;
|
||||||
|
void setData(const QString source, float value,
|
||||||
|
const bool dontInvert = true);
|
||||||
// variables
|
// variables
|
||||||
bool debug = false;
|
|
||||||
int counts = 0;
|
int counts = 0;
|
||||||
QMap<QString, QVariant> configuration;
|
QVariantHash configuration;
|
||||||
QMap<QString, float> boundaries;
|
QHash<QString, float> boundaries;
|
||||||
QMap<QString, QList<float>> data;
|
QHash<QString, QList<float>> data;
|
||||||
QStringList requiredKeys;
|
QStringList requiredKeys;
|
||||||
QSize size;
|
QSize size;
|
||||||
};
|
};
|
||||||
|
@ -1,3 +1,2 @@
|
|||||||
module org.kde.plasma.awesomewidget
|
module org.kde.plasma.private.awesomewidget
|
||||||
|
|
||||||
plugin awplugin
|
plugin awplugin
|
||||||
|
41
sources/awesomewidgets/CMakeLists.txt
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
set(SUBPROJECT ${PROJECT_LIBRARY})
|
||||||
|
message(STATUS "Subproject ${SUBPROJECT}")
|
||||||
|
add_definitions(-DTRANSLATION_DOMAIN=\"plasma_applet_org.kde.plasma.awesomewidget\")
|
||||||
|
|
||||||
|
include_directories(
|
||||||
|
${CMAKE_SOURCE_DIR}
|
||||||
|
${CMAKE_BINARY_DIR}
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/../
|
||||||
|
${PROJECT_TRDPARTY_DIR}
|
||||||
|
${Qt_INCLUDE}
|
||||||
|
${Kf5_INCLUDE}
|
||||||
|
)
|
||||||
|
|
||||||
|
file(GLOB SUBPROJECT_SOURCE *.cpp ${PROJECT_TRDPARTY_DIR}/qreplytimeout/*.cpp ${CMAKE_SOURCE_DIR}/*.cpp)
|
||||||
|
file(GLOB SUBPROJECT_HEADER *.h ${PROJECT_TRDPARTY_DIR}/qreplytimeout/*.h)
|
||||||
|
file(GLOB SUBPROJECT_UI *.ui)
|
||||||
|
set(SUBPROJECT_GRAPHITEMS ${CMAKE_CURRENT_SOURCE_DIR}/desktops)
|
||||||
|
set(SUBPROJECT_QUOTES ${CMAKE_CURRENT_SOURCE_DIR}/quotes)
|
||||||
|
set(SUBPROJECT_SCRIPTS ${CMAKE_CURRENT_SOURCE_DIR}/scripts)
|
||||||
|
set(SUBPROJECT_UPGRADE ${CMAKE_CURRENT_SOURCE_DIR}/upgrade)
|
||||||
|
set(SUBPROJECT_WEATHER ${CMAKE_CURRENT_SOURCE_DIR}/weather)
|
||||||
|
file(GLOB SUBPROJECT_WEATHER_JSON_IN *.json)
|
||||||
|
file(RELATIVE_PATH SUBPROJECT_WEATHER_JSON ${CMAKE_SOURCE_DIR} ${SUBPROJECT_WEATHER_JSON_IN})
|
||||||
|
|
||||||
|
# prepare
|
||||||
|
configure_file(${SUBPROJECT_WEATHER_JSON_IN} ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT_WEATHER_JSON})
|
||||||
|
|
||||||
|
qt5_wrap_cpp(SUBPROJECT_MOC_SOURCE ${SUBPROJECT_HEADER})
|
||||||
|
qt5_wrap_ui(SUBPROJECT_UI_HEADER ${SUBPROJECT_UI})
|
||||||
|
add_library(${SUBPROJECT} STATIC ${SUBPROJECT_SOURCE} ${SUBPROJECT_MOC_SOURCE}
|
||||||
|
${SUBPROJECT_HEADER} ${SUBPROJECT_UI_HEADER})
|
||||||
|
target_link_libraries(${SUBPROJECT} ${Qt_LIBRARIES} ${Kf5_LIBRARIES})
|
||||||
|
|
||||||
|
# install
|
||||||
|
install(DIRECTORY ${SUBPROJECT_GRAPHITEMS} DESTINATION ${DATA_INSTALL_DIR}/${PROJECT_NAME})
|
||||||
|
install(DIRECTORY ${SUBPROJECT_QUOTES} DESTINATION ${DATA_INSTALL_DIR}/${PROJECT_NAME})
|
||||||
|
install(DIRECTORY ${SUBPROJECT_SCRIPTS} DESTINATION ${DATA_INSTALL_DIR}/${PROJECT_NAME})
|
||||||
|
install(DIRECTORY ${SUBPROJECT_UPGRADE} DESTINATION ${DATA_INSTALL_DIR}/${PROJECT_NAME})
|
||||||
|
install(DIRECTORY ${SUBPROJECT_WEATHER} DESTINATION ${DATA_INSTALL_DIR}/${PROJECT_NAME})
|
||||||
|
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT_WEATHER_JSON} DESTINATION ${DATA_INSTALL_DIR}/${PROJECT_NAME}/weather)
|
252
sources/awesomewidgets/abstractextitem.cpp
Normal file
@ -0,0 +1,252 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* This file is part of awesome-widgets *
|
||||||
|
* *
|
||||||
|
* awesome-widgets is free software: you can redistribute it and/or *
|
||||||
|
* modify it under the terms of the GNU General Public License as *
|
||||||
|
* published by the Free Software Foundation, either version 3 of the *
|
||||||
|
* License, or (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* awesome-widgets is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#include "abstractextitem.h"
|
||||||
|
|
||||||
|
#include <QDir>
|
||||||
|
#include <QSettings>
|
||||||
|
#include <QStandardPaths>
|
||||||
|
#include <QTime>
|
||||||
|
|
||||||
|
#include "awdebug.h"
|
||||||
|
#include "version.h"
|
||||||
|
|
||||||
|
|
||||||
|
AbstractExtItem::AbstractExtItem(QWidget *parent, const QString desktopName,
|
||||||
|
const QStringList directories)
|
||||||
|
: QDialog(parent),
|
||||||
|
m_fileName(desktopName),
|
||||||
|
m_dirs(directories)
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
qCDebug(LOG_LIB) << "Desktop name" << desktopName;
|
||||||
|
qCDebug(LOG_LIB) << "Directories" << directories;
|
||||||
|
|
||||||
|
m_name = m_fileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
AbstractExtItem::~AbstractExtItem()
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
T *AbstractExtItem::copy(const QString _fileName, const int _number)
|
||||||
|
{
|
||||||
|
Q_UNUSED(_fileName)
|
||||||
|
Q_UNUSED(_number)
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
|
// an analog of pure virtual method
|
||||||
|
return new T();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int AbstractExtItem::apiVersion() const
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
|
return m_apiVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString AbstractExtItem::comment() const
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
|
return m_comment;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QStringList AbstractExtItem::directories() const
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
|
return m_dirs;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString AbstractExtItem::fileName() const
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
|
return m_fileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int AbstractExtItem::interval() const
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
|
return m_interval;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool AbstractExtItem::isActive() const
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
|
return m_active;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString AbstractExtItem::name() const
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
|
return m_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int AbstractExtItem::number() const
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
|
return m_number;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString AbstractExtItem::tag(const QString _type) const
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
qCDebug(LOG_LIB) << "Tag type" << _type;
|
||||||
|
|
||||||
|
return QString("%1%2").arg(_type).arg(m_number);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void AbstractExtItem::setApiVersion(const int _apiVersion)
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
qCDebug(LOG_LIB) << "Version" << _apiVersion;
|
||||||
|
|
||||||
|
m_apiVersion = _apiVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void AbstractExtItem::setActive(const bool _state)
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
qCDebug(LOG_LIB) << "State" << _state;
|
||||||
|
|
||||||
|
m_active = _state;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void AbstractExtItem::setComment(const QString _comment)
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
qCDebug(LOG_LIB) << "Comment" << _comment;
|
||||||
|
|
||||||
|
m_comment = _comment;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void AbstractExtItem::setInterval(const int _interval)
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
qCDebug(LOG_LIB) << "Interval" << _interval;
|
||||||
|
if (_interval <= 0) return;
|
||||||
|
|
||||||
|
m_interval = _interval;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void AbstractExtItem::setName(const QString _name)
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
qCDebug(LOG_LIB) << "Name" << _name;
|
||||||
|
|
||||||
|
m_name = _name;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void AbstractExtItem::setNumber(int _number)
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
qCDebug(LOG_LIB) << "Number" << _number;
|
||||||
|
if (_number == -1)
|
||||||
|
_number = []() {
|
||||||
|
qCWarning(LOG_LIB) << "Number is empty, generate new one";
|
||||||
|
qsrand(QTime::currentTime().msec());
|
||||||
|
int n = qrand() % 1000;
|
||||||
|
qCInfo(LOG_LIB) << "Generated number is" << n;
|
||||||
|
return n;
|
||||||
|
}();
|
||||||
|
|
||||||
|
m_number = _number;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void AbstractExtItem::readConfiguration()
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
|
for (int i=m_dirs.count()-1; i>=0; i--) {
|
||||||
|
if (!QDir(m_dirs.at(i)).entryList(QDir::Files).contains(m_fileName)) continue;
|
||||||
|
QSettings settings(QString("%1/%2").arg(m_dirs.at(i)).arg(m_fileName), QSettings::IniFormat);
|
||||||
|
|
||||||
|
settings.beginGroup(QString("Desktop Entry"));
|
||||||
|
setName(settings.value(QString("Name"), m_name).toString());
|
||||||
|
setComment(settings.value(QString("Comment"), m_comment).toString());
|
||||||
|
setApiVersion(settings.value(QString("X-AW-ApiVersion"), m_apiVersion).toInt());
|
||||||
|
setActive(settings.value(QString("X-AW-Active"), QVariant(m_active)).toString() == QString("true"));
|
||||||
|
setInterval(settings.value(QString("X-AW-Interval"), m_interval).toInt());
|
||||||
|
setNumber(settings.value(QString("X-AW-Number"), m_number).toInt());
|
||||||
|
settings.endGroup();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool AbstractExtItem::tryDelete() const
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
|
foreach(QString dir, m_dirs) {
|
||||||
|
bool status = QFile::remove(QString("%1/%2").arg(dir).arg(m_fileName));
|
||||||
|
qCInfo(LOG_LIB) << "Remove file" << QString("%1/%2").arg(dir).arg(m_fileName) << status;
|
||||||
|
}
|
||||||
|
|
||||||
|
// check if exists
|
||||||
|
foreach(QString dir, m_dirs)
|
||||||
|
if (QFile::exists(QString("%1/%2").arg(dir).arg(m_fileName))) return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void AbstractExtItem::writeConfiguration() const
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
|
QSettings settings(QString("%1/%2").arg(m_dirs.first()).arg(m_fileName), QSettings::IniFormat);
|
||||||
|
qCInfo(LOG_LIB) << "Configuration file" << settings.fileName();
|
||||||
|
|
||||||
|
settings.beginGroup(QString("Desktop Entry"));
|
||||||
|
settings.setValue(QString("Encoding"), QString("UTF-8"));
|
||||||
|
settings.setValue(QString("Name"), m_name);
|
||||||
|
settings.setValue(QString("Comment"), m_comment);
|
||||||
|
settings.setValue(QString("X-AW-ApiVersion"), m_apiVersion);
|
||||||
|
settings.setValue(QString("X-AW-Active"), QVariant(m_active).toString());
|
||||||
|
settings.setValue(QString("X-AW-Interval"), m_interval);
|
||||||
|
settings.setValue(QString("X-AW-Number"), m_number);
|
||||||
|
settings.endGroup();
|
||||||
|
|
||||||
|
settings.sync();
|
||||||
|
}
|
@ -15,82 +15,70 @@
|
|||||||
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
#ifndef EXTUPGRADE_H
|
#ifndef ABSTRACTEXTITEM_H
|
||||||
#define EXTUPGRADE_H
|
#define ABSTRACTEXTITEM_H
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include <QProcess>
|
#include <QInputDialog>
|
||||||
|
#include <QVariant>
|
||||||
|
|
||||||
|
|
||||||
namespace Ui {
|
class AbstractExtItem : public QDialog
|
||||||
class ExtUpgrade;
|
|
||||||
}
|
|
||||||
|
|
||||||
class ExtUpgrade : public QDialog
|
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
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(int number READ number WRITE setNumber)
|
|
||||||
Q_PROPERTY(bool active READ isActive WRITE setActive)
|
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(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:
|
public:
|
||||||
explicit ExtUpgrade(QWidget *parent = nullptr, const QString upgradeName = QString(),
|
explicit AbstractExtItem(QWidget *parent = nullptr, const QString desktopName = QString(),
|
||||||
const QStringList directories = QStringList(), const bool debugCmd = false);
|
const QStringList directories = QStringList());
|
||||||
~ExtUpgrade();
|
virtual ~AbstractExtItem();
|
||||||
|
template <class T> T *copy(const QString _fileName, const int _number);
|
||||||
// get methods
|
// get methods
|
||||||
int apiVersion();
|
int apiVersion() const;
|
||||||
QString comment();
|
QString comment() const;
|
||||||
QString executable();
|
QStringList directories() const;
|
||||||
QString fileName();
|
QString fileName() const;
|
||||||
int interval();
|
int interval() const;
|
||||||
QString name();
|
bool isActive() const;
|
||||||
int null();
|
QString name() const;
|
||||||
int number();
|
int number() const;
|
||||||
QString tag();
|
QString tag(const QString _type) const;
|
||||||
bool isActive();
|
virtual QString uniq() const = 0;
|
||||||
// set methods
|
// set methods
|
||||||
void setApiVersion(const int _apiVersion = 0);
|
void setApiVersion(const int _apiVersion = 0);
|
||||||
void setActive(const bool _state = true);
|
void setActive(const bool _state = true);
|
||||||
void setComment(const QString _comment = QString("empty"));
|
void setComment(const QString _comment = QString("empty"));
|
||||||
void setExecutable(const QString _executable = QString("/usr/bin/true"));
|
void setInterval(const int _interval = 1);
|
||||||
void setName(const QString _name = QString("none"));
|
void setName(const QString _name = QString("none"));
|
||||||
void setNull(const int _null = 0);
|
|
||||||
void setNumber(int _number = -1);
|
void setNumber(int _number = -1);
|
||||||
void setInterval(const int _interval = 0);
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void readConfiguration();
|
virtual void readConfiguration();
|
||||||
int run();
|
virtual QVariantHash run() = 0;
|
||||||
int showConfiguration();
|
virtual int showConfiguration(const QVariant args = QVariant()) = 0;
|
||||||
bool tryDelete();
|
bool tryDelete() const;
|
||||||
void writeConfiguration();
|
virtual void writeConfiguration() const;
|
||||||
|
|
||||||
private slots:
|
|
||||||
void updateValue();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString m_fileName;
|
QString m_fileName;
|
||||||
QStringList m_dirs;
|
QStringList m_dirs;
|
||||||
bool debug;
|
virtual void translate() = 0;
|
||||||
QProcess *process = nullptr;
|
|
||||||
Ui::ExtUpgrade *ui;
|
|
||||||
// properties
|
// properties
|
||||||
int m_apiVersion = 0;
|
int m_apiVersion = 0;
|
||||||
bool m_active = true;
|
bool m_active = true;
|
||||||
QString m_comment = QString("empty");
|
QString m_comment = QString("empty");
|
||||||
QString m_executable = QString("/usr/bin/true");
|
int m_interval = 1;
|
||||||
QString m_name = QString("none");
|
QString m_name = QString("none");
|
||||||
int m_null = 0;
|
|
||||||
int m_number = -1;
|
int m_number = -1;
|
||||||
int m_interval = 3600;
|
|
||||||
int times = 0;
|
|
||||||
int value = 0;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif /* EXTUPGRADE_H */
|
#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 <QHBoxLayout>
|
||||||
|
#include <QInputDialog>
|
||||||
|
#include <QLineEdit>
|
||||||
|
|
||||||
|
#include "awdebug.h"
|
||||||
|
|
||||||
|
|
||||||
|
AbstractExtItemAggregator::AbstractExtItemAggregator(QWidget *parent)
|
||||||
|
: QWidget(parent)
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
|
dialog = new QDialog(this);
|
||||||
|
widgetDialog = new QListWidget(dialog);
|
||||||
|
dialogButtons = new QDialogButtonBox(QDialogButtonBox::Open | QDialogButtonBox::Close,
|
||||||
|
Qt::Vertical, dialog);
|
||||||
|
copyButton = dialogButtons->addButton(i18n("Copy"), QDialogButtonBox::ActionRole);
|
||||||
|
createButton = dialogButtons->addButton(i18n("Create"), QDialogButtonBox::ActionRole);
|
||||||
|
deleteButton = dialogButtons->addButton(i18n("Remove"), QDialogButtonBox::ActionRole);
|
||||||
|
QHBoxLayout *layout = new QHBoxLayout(dialog);
|
||||||
|
layout->addWidget(widgetDialog);
|
||||||
|
layout->addWidget(dialogButtons);
|
||||||
|
dialog->setLayout(layout);
|
||||||
|
|
||||||
|
connect(dialogButtons, SIGNAL(clicked(QAbstractButton *)),
|
||||||
|
this, SLOT(editItemButtonPressed(QAbstractButton *)));
|
||||||
|
connect(dialogButtons, SIGNAL(rejected()), dialog, SLOT(reject()));
|
||||||
|
connect(widgetDialog, SIGNAL(itemActivated(QListWidgetItem *)),
|
||||||
|
this, SLOT(editItemActivated(QListWidgetItem *)));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
AbstractExtItemAggregator::~AbstractExtItemAggregator()
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
|
delete dialog;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString AbstractExtItemAggregator::getName()
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
|
bool ok;
|
||||||
|
QString name = QInputDialog::getText(this, i18n("Enter file name"),
|
||||||
|
i18n("File name"), QLineEdit::Normal,
|
||||||
|
QString(""), &ok);
|
||||||
|
if ((!ok) || (name.isEmpty())) return QString("");
|
||||||
|
if (!name.endsWith(QString(".desktop"))) name += QString(".desktop");
|
||||||
|
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QVariant AbstractExtItemAggregator::configArgs() const
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
|
return m_configArgs;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void AbstractExtItemAggregator::setConfigArgs(const QVariant _configArgs)
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
qCDebug(LOG_LIB) << "Configuration arguments" << _configArgs;
|
||||||
|
|
||||||
|
m_configArgs = _configArgs;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void AbstractExtItemAggregator::editItemActivated(QListWidgetItem *item)
|
||||||
|
{
|
||||||
|
Q_UNUSED(item)
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
|
return editItem();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void AbstractExtItemAggregator::editItemButtonPressed(QAbstractButton *button)
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
|
if (static_cast<QPushButton *>(button) == copyButton)
|
||||||
|
return copyItem();
|
||||||
|
else if (static_cast<QPushButton *>(button) == createButton)
|
||||||
|
return createItem();
|
||||||
|
else if (static_cast<QPushButton *>(button) == deleteButton)
|
||||||
|
return deleteItem();
|
||||||
|
else if (dialogButtons->buttonRole(button) == QDialogButtonBox::AcceptRole)
|
||||||
|
return editItem();
|
||||||
|
}
|
65
sources/awesomewidgets/abstractextitemaggregator.h
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* This file is part of awesome-widgets *
|
||||||
|
* *
|
||||||
|
* awesome-widgets is free software: you can redistribute it and/or *
|
||||||
|
* modify it under the terms of the GNU General Public License as *
|
||||||
|
* published by the Free Software Foundation, either version 3 of the *
|
||||||
|
* License, or (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* awesome-widgets is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef ABSTRACTEXTITEMAGGREGATOR_H
|
||||||
|
#define ABSTRACTEXTITEMAGGREGATOR_H
|
||||||
|
|
||||||
|
#include <QDialog>
|
||||||
|
#include <QDialogButtonBox>
|
||||||
|
#include <QListWidget>
|
||||||
|
#include <QObject>
|
||||||
|
#include <QPushButton>
|
||||||
|
#include <QWidget>
|
||||||
|
|
||||||
|
|
||||||
|
// additinal class since QObject macro does not allow class templates
|
||||||
|
class AbstractExtItemAggregator : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(QVariant configArgs READ configArgs WRITE setConfigArgs)
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit AbstractExtItemAggregator(QWidget *parent = nullptr);
|
||||||
|
virtual ~AbstractExtItemAggregator();
|
||||||
|
QString getName();
|
||||||
|
// ui
|
||||||
|
QDialog *dialog = nullptr;
|
||||||
|
QListWidget *widgetDialog = nullptr;
|
||||||
|
QDialogButtonBox *dialogButtons = nullptr;
|
||||||
|
QPushButton *copyButton = nullptr;
|
||||||
|
QPushButton *createButton = nullptr;
|
||||||
|
QPushButton *deleteButton = nullptr;
|
||||||
|
// get methods
|
||||||
|
QVariant configArgs() const;
|
||||||
|
// set methods
|
||||||
|
void setConfigArgs(const QVariant _configArgs);
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void editItemActivated(QListWidgetItem *item);
|
||||||
|
void editItemButtonPressed(QAbstractButton *button);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QVariant m_configArgs;
|
||||||
|
// methods
|
||||||
|
virtual void copyItem() = 0;
|
||||||
|
virtual void createItem() = 0;
|
||||||
|
virtual void deleteItem() = 0;
|
||||||
|
virtual void editItem() = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* ABSTRACTEXTITEMAGGREGATOR_H */
|
139
sources/awesomewidgets/awesomewidgets-extweather-ids.json
Normal file
@ -0,0 +1,139 @@
|
|||||||
|
{
|
||||||
|
"__url": "http://openweathermap.org/weather-conditions",
|
||||||
|
|
||||||
|
"image": {
|
||||||
|
"__comment": "should be described as html image with full path inside",
|
||||||
|
|
||||||
|
"default": "",
|
||||||
|
|
||||||
|
"800": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/01d.png\">",
|
||||||
|
|
||||||
|
"801": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/02d.png\">",
|
||||||
|
|
||||||
|
"802": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/03d.png\">",
|
||||||
|
"803": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/03d.png\">",
|
||||||
|
|
||||||
|
"804": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/04d.png\">",
|
||||||
|
|
||||||
|
"300": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/09d.png\">",
|
||||||
|
"301": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/09d.png\">",
|
||||||
|
"302": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/09d.png\">",
|
||||||
|
"310": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/09d.png\">",
|
||||||
|
"311": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/09d.png\">",
|
||||||
|
"312": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/09d.png\">",
|
||||||
|
"313": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/09d.png\">",
|
||||||
|
"314": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/09d.png\">",
|
||||||
|
"321": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/09d.png\">",
|
||||||
|
"520": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/09d.png\">",
|
||||||
|
"521": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/09d.png\">",
|
||||||
|
"522": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/09d.png\">",
|
||||||
|
"531": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/09d.png\">",
|
||||||
|
|
||||||
|
"500": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/10d.png\">",
|
||||||
|
"501": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/10d.png\">",
|
||||||
|
"502": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/10d.png\">",
|
||||||
|
"503": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/10d.png\">",
|
||||||
|
"504": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/10d.png\">",
|
||||||
|
|
||||||
|
"200": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/11d.png\">",
|
||||||
|
"201": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/11d.png\">",
|
||||||
|
"202": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/11d.png\">",
|
||||||
|
"210": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/11d.png\">",
|
||||||
|
"211": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/11d.png\">",
|
||||||
|
"212": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/11d.png\">",
|
||||||
|
"221": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/11d.png\">",
|
||||||
|
"230": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/11d.png\">",
|
||||||
|
"231": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/11d.png\">",
|
||||||
|
"232": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/11d.png\">",
|
||||||
|
|
||||||
|
"511": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/13d.png\">",
|
||||||
|
"600": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/13d.png\">",
|
||||||
|
"601": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/13d.png\">",
|
||||||
|
"602": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/13d.png\">",
|
||||||
|
"611": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/13d.png\">",
|
||||||
|
"612": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/13d.png\">",
|
||||||
|
"615": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/13d.png\">",
|
||||||
|
"616": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/13d.png\">",
|
||||||
|
"620": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/13d.png\">",
|
||||||
|
"621": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/13d.png\">",
|
||||||
|
"622": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/13d.png\">",
|
||||||
|
|
||||||
|
"701": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/50d.png\">",
|
||||||
|
"711": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/50d.png\">",
|
||||||
|
"721": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/50d.png\">",
|
||||||
|
"731": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/50d.png\">",
|
||||||
|
"741": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/50d.png\">",
|
||||||
|
"751": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/50d.png\">",
|
||||||
|
"761": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/50d.png\">",
|
||||||
|
"762": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/50d.png\">",
|
||||||
|
"771": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/50d.png\">",
|
||||||
|
"781": "<img src=\"@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/weather/50d.png\">"
|
||||||
|
},
|
||||||
|
|
||||||
|
"text": {
|
||||||
|
"default": "\u2604",
|
||||||
|
|
||||||
|
"800": "\u2600",
|
||||||
|
|
||||||
|
"801": "\u26C5",
|
||||||
|
|
||||||
|
"802": "\u2601",
|
||||||
|
"803": "\u2601",
|
||||||
|
|
||||||
|
"804": "\u2601",
|
||||||
|
|
||||||
|
"300": "\u2602",
|
||||||
|
"301": "\u2602",
|
||||||
|
"302": "\u2602",
|
||||||
|
"310": "\u2602",
|
||||||
|
"311": "\u2602",
|
||||||
|
"312": "\u2602",
|
||||||
|
"313": "\u2602",
|
||||||
|
"314": "\u2602",
|
||||||
|
"321": "\u2602",
|
||||||
|
"520": "\u2602",
|
||||||
|
"521": "\u2602",
|
||||||
|
"522": "\u2602",
|
||||||
|
"531": "\u2602",
|
||||||
|
|
||||||
|
"500": "\u2614",
|
||||||
|
"501": "\u2614",
|
||||||
|
"502": "\u2614",
|
||||||
|
"503": "\u2614",
|
||||||
|
"504": "\u2614",
|
||||||
|
|
||||||
|
"200": "\u2608",
|
||||||
|
"201": "\u2608",
|
||||||
|
"202": "\u2608",
|
||||||
|
"210": "\u2608",
|
||||||
|
"211": "\u2608",
|
||||||
|
"212": "\u2608",
|
||||||
|
"221": "\u2608",
|
||||||
|
"230": "\u2608",
|
||||||
|
"231": "\u2608",
|
||||||
|
"232": "\u2608",
|
||||||
|
|
||||||
|
"511": "\u2603",
|
||||||
|
"600": "\u2603",
|
||||||
|
"601": "\u2603",
|
||||||
|
"602": "\u2603",
|
||||||
|
"611": "\u2603",
|
||||||
|
"612": "\u2603",
|
||||||
|
"615": "\u2603",
|
||||||
|
"616": "\u2603",
|
||||||
|
"620": "\u2603",
|
||||||
|
"621": "\u2603",
|
||||||
|
"622": "\u2603",
|
||||||
|
|
||||||
|
"701": "\u26C5",
|
||||||
|
"711": "\u26C5",
|
||||||
|
"721": "\u26C5",
|
||||||
|
"731": "\u26C5",
|
||||||
|
"741": "\u26C5",
|
||||||
|
"751": "\u26C5",
|
||||||
|
"761": "\u26C5",
|
||||||
|
"762": "\u26C5",
|
||||||
|
"771": "\u26C5",
|
||||||
|
"781": "\u26C5"
|
||||||
|
}
|
||||||
|
}
|
@ -9,4 +9,5 @@ X-AW-Type=Horizontal
|
|||||||
X-AW-Direction=LeftToRight
|
X-AW-Direction=LeftToRight
|
||||||
X-AW-Height=25
|
X-AW-Height=25
|
||||||
X-AW-Width=100
|
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-Direction=LeftToRight
|
||||||
X-AW-Height=25
|
X-AW-Height=25
|
||||||
X-AW-Width=100
|
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-Direction=LeftToRight
|
||||||
X-AW-Height=25
|
X-AW-Height=25
|
||||||
X-AW-Width=100
|
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-Direction=LeftToRight
|
||||||
X-AW-Height=25
|
X-AW-Height=25
|
||||||
X-AW-Width=100
|
X-AW-Width=100
|
||||||
X-AW-ApiVersion=1
|
X-AW-ApiVersion=2
|
||||||
|
X-AW-Number=2
|
276
sources/awesomewidgets/extitemaggregator.h
Normal file
@ -0,0 +1,276 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* This file is part of awesome-widgets *
|
||||||
|
* *
|
||||||
|
* awesome-widgets is free software: you can redistribute it and/or *
|
||||||
|
* modify it under the terms of the GNU General Public License as *
|
||||||
|
* published by the Free Software Foundation, either version 3 of the *
|
||||||
|
* License, or (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* awesome-widgets is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef EXTITEMAGGREGATOR_H
|
||||||
|
#define EXTITEMAGGREGATOR_H
|
||||||
|
|
||||||
|
#include <KI18n/KLocalizedString>
|
||||||
|
|
||||||
|
#include <QDir>
|
||||||
|
#include <QSettings>
|
||||||
|
#include <QStandardPaths>
|
||||||
|
|
||||||
|
#include "awdebug.h"
|
||||||
|
|
||||||
|
#include "abstractextitemaggregator.h"
|
||||||
|
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
class ExtItemAggregator : public AbstractExtItemAggregator
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit ExtItemAggregator(QWidget *parent, const QString type)
|
||||||
|
: AbstractExtItemAggregator(parent),
|
||||||
|
m_type(type)
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
qCDebug(LOG_LIB) << "Type" << type;
|
||||||
|
|
||||||
|
qSetMessagePattern(LOG_FORMAT);
|
||||||
|
|
||||||
|
initItems();
|
||||||
|
};
|
||||||
|
|
||||||
|
virtual ~ExtItemAggregator()
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
|
m_items.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void editItems()
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
|
repaint();
|
||||||
|
int ret = dialog->exec();
|
||||||
|
qCInfo(LOG_LIB) << "Dialog returns" << ret;
|
||||||
|
};
|
||||||
|
|
||||||
|
void initItems()
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
|
m_items.clear();
|
||||||
|
m_items = getItems();
|
||||||
|
};
|
||||||
|
|
||||||
|
T *itemByTag(const QString _tag) const
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
qCDebug(LOG_LIB) << "Tag" << _tag;
|
||||||
|
|
||||||
|
T *found = nullptr;
|
||||||
|
foreach(T *item, m_items) {
|
||||||
|
if (item->tag() != _tag) continue;
|
||||||
|
found = item;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (found == nullptr)
|
||||||
|
qCWarning(LOG_LIB) << "Could not find item by tag" << _tag;
|
||||||
|
|
||||||
|
return found;
|
||||||
|
}
|
||||||
|
|
||||||
|
T *itemByTagNumber(const int _number) const
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
qCDebug(LOG_LIB) << "Number" << _number;
|
||||||
|
|
||||||
|
T *found = nullptr;
|
||||||
|
foreach(T *item, m_items) {
|
||||||
|
if (item->number() != _number) continue;
|
||||||
|
found = item;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (found == nullptr)
|
||||||
|
qCWarning(LOG_LIB) << "Could not find item by number" << _number;
|
||||||
|
|
||||||
|
return found;
|
||||||
|
}
|
||||||
|
|
||||||
|
T *itemFromWidget() const
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
|
QListWidgetItem *widgetItem = widgetDialog->currentItem();
|
||||||
|
if (widgetItem == nullptr) return nullptr;
|
||||||
|
|
||||||
|
T *found = nullptr;
|
||||||
|
foreach(T *item, m_items) {
|
||||||
|
if (item->fileName() != widgetItem->text()) continue;
|
||||||
|
found = item;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (found == nullptr)
|
||||||
|
qCWarning(LOG_LIB) << "Could not find item by name" << widgetItem->text();
|
||||||
|
|
||||||
|
return found;
|
||||||
|
};
|
||||||
|
|
||||||
|
QList<T *> items() const
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
|
return m_items;
|
||||||
|
};
|
||||||
|
|
||||||
|
int uniqNumber() const
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
|
QList<int> tagList;
|
||||||
|
foreach(T *item, m_items) tagList.append(item->number());
|
||||||
|
int number = 0;
|
||||||
|
while (tagList.contains(number)) number++;
|
||||||
|
|
||||||
|
return number;
|
||||||
|
};
|
||||||
|
|
||||||
|
private:
|
||||||
|
QList<T *> m_items;
|
||||||
|
QString m_type;
|
||||||
|
|
||||||
|
// init method
|
||||||
|
QList<T *> getItems()
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
|
// create directory at $HOME
|
||||||
|
QString localDir = QString("%1/awesomewidgets/%2")
|
||||||
|
.arg(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation))
|
||||||
|
.arg(m_type);
|
||||||
|
QDir localDirectory;
|
||||||
|
if (localDirectory.mkpath(localDir))
|
||||||
|
qCInfo(LOG_LIB) << "Created directory" << localDir;
|
||||||
|
|
||||||
|
QStringList dirs = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation,
|
||||||
|
QString("awesomewidgets/%1").arg(m_type),
|
||||||
|
QStandardPaths::LocateDirectory);
|
||||||
|
QStringList names;
|
||||||
|
QList<T *> items;
|
||||||
|
foreach(QString dir, dirs) {
|
||||||
|
QStringList files = QDir(dir).entryList(QDir::Files, QDir::Name);
|
||||||
|
foreach(QString file, files) {
|
||||||
|
if (!file.endsWith(QString(".desktop"))) continue;
|
||||||
|
if (names.contains(file)) continue;
|
||||||
|
qCInfo(LOG_LIB) << "Found file" << file << "in" << dir;
|
||||||
|
names.append(file);
|
||||||
|
items.append(new T(this, file, dirs));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// sort items
|
||||||
|
std::sort(items.begin(), items.end(), [](const T *lhs, const T *rhs){
|
||||||
|
return lhs->number() < rhs->number();
|
||||||
|
});
|
||||||
|
return items;
|
||||||
|
};
|
||||||
|
|
||||||
|
void repaint()
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
|
widgetDialog->clear();
|
||||||
|
foreach(T *_item, m_items) {
|
||||||
|
QListWidgetItem *item = new QListWidgetItem(_item->fileName(), widgetDialog);
|
||||||
|
QStringList tooltip;
|
||||||
|
tooltip.append(i18n("Name: %1", _item->name()));
|
||||||
|
tooltip.append(i18n("Comment: %1", _item->comment()));
|
||||||
|
tooltip.append(i18n("Identity: %1", _item->uniq()));
|
||||||
|
item->setToolTip(tooltip.join(QChar('\n')));
|
||||||
|
widgetDialog->addItem(item);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// methods
|
||||||
|
void copyItem()
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
|
T *source = itemFromWidget();
|
||||||
|
QString fileName = getName();
|
||||||
|
int number = uniqNumber();
|
||||||
|
if ((source == nullptr) || (fileName.isEmpty())) {
|
||||||
|
qCWarning(LOG_LIB) << "Nothing to copy";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
T *newItem = source->copy(fileName, number);
|
||||||
|
if (newItem->showConfiguration(configArgs()) == 1) {
|
||||||
|
initItems();
|
||||||
|
repaint();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
void createItem()
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
|
QString fileName = getName();
|
||||||
|
int number = uniqNumber();
|
||||||
|
QStringList dirs = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation,
|
||||||
|
QString("awesomewidgets/%1").arg(m_type),
|
||||||
|
QStandardPaths::LocateDirectory);
|
||||||
|
if (fileName.isEmpty()) {
|
||||||
|
qCWarning(LOG_LIB) << "Nothing to create";
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
|
T *newItem = new T(this, fileName, dirs);
|
||||||
|
newItem->setNumber(number);
|
||||||
|
if (newItem->showConfiguration(configArgs()) == 1) {
|
||||||
|
initItems();
|
||||||
|
repaint();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
void deleteItem()
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
|
T *source = itemFromWidget();
|
||||||
|
if (source == nullptr) {
|
||||||
|
qCWarning(LOG_LIB) << "Nothing to delete";
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
|
if (source->tryDelete()) {
|
||||||
|
initItems();
|
||||||
|
repaint();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
void editItem()
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
|
T *source = itemFromWidget();
|
||||||
|
if (source == nullptr) {
|
||||||
|
qCWarning(LOG_LIB) << "Nothing to edit";
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
|
if (source->showConfiguration(configArgs()) == 1) {
|
||||||
|
initItems();
|
||||||
|
repaint();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* EXTITEMAGGREGATOR_H */
|
268
sources/awesomewidgets/extquotes.cpp
Normal file
@ -0,0 +1,268 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* This file is part of awesome-widgets *
|
||||||
|
* *
|
||||||
|
* awesome-widgets is free software: you can redistribute it and/or *
|
||||||
|
* modify it under the terms of the GNU General Public License as *
|
||||||
|
* published by the Free Software Foundation, either version 3 of the *
|
||||||
|
* License, or (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* awesome-widgets is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#include "extquotes.h"
|
||||||
|
#include "ui_extquotes.h"
|
||||||
|
|
||||||
|
#include <KI18n/KLocalizedString>
|
||||||
|
|
||||||
|
#include <QDir>
|
||||||
|
#include <QJsonDocument>
|
||||||
|
#include <QJsonParseError>
|
||||||
|
#include <QNetworkAccessManager>
|
||||||
|
#include <QNetworkRequest>
|
||||||
|
#include <QSettings>
|
||||||
|
|
||||||
|
#include <qreplytimeout/qreplytimeout.h>
|
||||||
|
|
||||||
|
#include "awdebug.h"
|
||||||
|
#include "version.h"
|
||||||
|
|
||||||
|
|
||||||
|
ExtQuotes::ExtQuotes(QWidget *parent, const QString quotesName,
|
||||||
|
const QStringList directories)
|
||||||
|
: AbstractExtItem(parent, quotesName, directories),
|
||||||
|
ui(new Ui::ExtQuotes)
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
|
readConfiguration();
|
||||||
|
ui->setupUi(this);
|
||||||
|
translate();
|
||||||
|
|
||||||
|
values[tag(QString("ask"))] = 0.0;
|
||||||
|
values[tag(QString("askchg"))] = 0.0;
|
||||||
|
values[tag(QString("percaskchg"))] = 0.0;
|
||||||
|
values[tag(QString("bid"))] = 0.0;
|
||||||
|
values[tag(QString("bidchg"))] = 0.0;
|
||||||
|
values[tag(QString("percbidchg"))] = 0.0;
|
||||||
|
values[tag(QString("price"))] = 0.0;
|
||||||
|
values[tag(QString("pricechg"))] = 0.0;
|
||||||
|
values[tag(QString("percpricechg"))] = 0.0;
|
||||||
|
|
||||||
|
manager = new QNetworkAccessManager(this);
|
||||||
|
connect(manager, SIGNAL(finished(QNetworkReply *)),
|
||||||
|
this, SLOT(quotesReplyReceived(QNetworkReply *)));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ExtQuotes::~ExtQuotes()
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
|
disconnect(manager, SIGNAL(finished(QNetworkReply *)), this, SLOT(quotesReplyReceived(QNetworkReply *)));
|
||||||
|
|
||||||
|
delete manager;
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ExtQuotes *ExtQuotes::copy(const QString _fileName, const int _number)
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
qCDebug(LOG_LIB) << "File" << _fileName;
|
||||||
|
qCDebug(LOG_LIB) << "Number" << _number;
|
||||||
|
|
||||||
|
ExtQuotes *item = new ExtQuotes(static_cast<QWidget *>(parent()), _fileName, directories());
|
||||||
|
item->setActive(isActive());
|
||||||
|
item->setApiVersion(apiVersion());
|
||||||
|
item->setComment(comment());
|
||||||
|
item->setInterval(interval());
|
||||||
|
item->setName(name());
|
||||||
|
item->setNumber(_number);
|
||||||
|
item->setTicker(ticker());
|
||||||
|
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString ExtQuotes::ticker() const
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
|
return m_ticker;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString ExtQuotes::uniq() const
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
|
return m_ticker;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ExtQuotes::setTicker(const QString _ticker)
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
qCDebug(LOG_LIB) << "Ticker" << _ticker;
|
||||||
|
|
||||||
|
m_ticker = _ticker;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ExtQuotes::readConfiguration()
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
AbstractExtItem::readConfiguration();
|
||||||
|
|
||||||
|
for (int i=directories().count()-1; i>=0; i--) {
|
||||||
|
if (!QDir(directories().at(i)).entryList(QDir::Files).contains(fileName())) continue;
|
||||||
|
QSettings settings(QString("%1/%2").arg(directories().at(i)).arg(fileName()), QSettings::IniFormat);
|
||||||
|
|
||||||
|
settings.beginGroup(QString("Desktop Entry"));
|
||||||
|
setTicker(settings.value(QString("X-AW-Ticker"), m_ticker).toString());
|
||||||
|
settings.endGroup();
|
||||||
|
}
|
||||||
|
|
||||||
|
// update for current API
|
||||||
|
if ((apiVersion() > 0) && (apiVersion() < AWEQAPI)) {
|
||||||
|
qCWarning(LOG_LIB) << "Bump API version from" << apiVersion() << "to" << AWEQAPI;
|
||||||
|
setApiVersion(AWEQAPI);
|
||||||
|
writeConfiguration();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QVariantHash ExtQuotes::run()
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
if ((!isActive()) || (isRunning)) return values;
|
||||||
|
|
||||||
|
if (times == 1) {
|
||||||
|
qCInfo(LOG_LIB) << "Send request";
|
||||||
|
isRunning = true;
|
||||||
|
QNetworkReply *reply = manager->get(QNetworkRequest(QUrl(url())));
|
||||||
|
new QReplyTimeout(reply, 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
// update value
|
||||||
|
if (times >= interval()) times = 0;
|
||||||
|
times++;
|
||||||
|
|
||||||
|
return values;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int ExtQuotes::showConfiguration(const QVariant args)
|
||||||
|
{
|
||||||
|
Q_UNUSED(args)
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
|
ui->lineEdit_name->setText(name());
|
||||||
|
ui->lineEdit_comment->setText(comment());
|
||||||
|
ui->label_numberValue->setText(QString("%1").arg(number()));
|
||||||
|
ui->lineEdit_ticker->setText(m_ticker);
|
||||||
|
ui->checkBox_active->setCheckState(isActive() ? Qt::Checked : Qt::Unchecked);
|
||||||
|
ui->spinBox_interval->setValue(interval());
|
||||||
|
|
||||||
|
int ret = exec();
|
||||||
|
if (ret != 1) return ret;
|
||||||
|
setName(ui->lineEdit_name->text());
|
||||||
|
setComment(ui->lineEdit_comment->text());
|
||||||
|
setNumber(ui->label_numberValue->text().toInt());
|
||||||
|
setApiVersion(AWEQAPI);
|
||||||
|
setTicker(ui->lineEdit_ticker->text());
|
||||||
|
setActive(ui->checkBox_active->checkState() == Qt::Checked);
|
||||||
|
setInterval(ui->spinBox_interval->value());
|
||||||
|
|
||||||
|
writeConfiguration();
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ExtQuotes::writeConfiguration() const
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
AbstractExtItem::writeConfiguration();
|
||||||
|
|
||||||
|
QSettings settings(QString("%1/%2").arg(directories().first()).arg(fileName()), QSettings::IniFormat);
|
||||||
|
qCInfo(LOG_LIB) << "Configuration file" << settings.fileName();
|
||||||
|
|
||||||
|
settings.beginGroup(QString("Desktop Entry"));
|
||||||
|
settings.setValue(QString("X-AW-Ticker"), m_ticker);
|
||||||
|
settings.endGroup();
|
||||||
|
|
||||||
|
settings.sync();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ExtQuotes::quotesReplyReceived(QNetworkReply *reply)
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
qCDebug(LOG_LIB) << "Return code" << reply->error();
|
||||||
|
qCDebug(LOG_LIB) << "Reply error message" << reply->errorString();
|
||||||
|
|
||||||
|
isRunning = false;
|
||||||
|
QJsonParseError error;
|
||||||
|
QJsonDocument jsonDoc = QJsonDocument::fromJson(reply->readAll(), &error);
|
||||||
|
reply->deleteLater();
|
||||||
|
if ((reply->error() != QNetworkReply::NoError) ||
|
||||||
|
(error.error != QJsonParseError::NoError)) {
|
||||||
|
qCWarning(LOG_LIB) << "Parse error" << error.errorString();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
QVariantMap jsonQuotes = jsonDoc.toVariant().toMap()[QString("query")].toMap();
|
||||||
|
jsonQuotes = jsonQuotes[QString("results")].toMap()[QString("quote")].toMap();
|
||||||
|
float value;
|
||||||
|
|
||||||
|
// ask
|
||||||
|
value = jsonQuotes[QString("Ask")].toString().toFloat();
|
||||||
|
values[tag(QString("askchg"))] = values[QString("ask")].toFloat() == 0.0 ? 0.0 :
|
||||||
|
value - values[QString("ask")].toFloat();
|
||||||
|
values[tag(QString("percaskchg"))] = 100.0 * values[QString("askchg")].toFloat() / values[QString("ask")].toFloat();
|
||||||
|
values[tag(QString("ask"))] = value;
|
||||||
|
|
||||||
|
// bid
|
||||||
|
value = jsonQuotes[QString("Bid")].toString().toFloat();
|
||||||
|
values[tag(QString("bidchg"))] = values[QString("bid")].toFloat() == 0.0 ? 0.0 :
|
||||||
|
value - values[QString("bid")].toFloat();
|
||||||
|
values[tag(QString("percbidchg"))] = 100.0 * values[QString("bidchg")].toFloat() / values[QString("bid")].toFloat();
|
||||||
|
values[tag(QString("bid"))] = value;
|
||||||
|
|
||||||
|
// last trade
|
||||||
|
value = jsonQuotes[QString("LastTradePriceOnly")].toString().toFloat();
|
||||||
|
values[tag(QString("pricechg"))] = values[QString("price")].toFloat() == 0.0 ? 0.0 :
|
||||||
|
value - values[QString("price")].toFloat();
|
||||||
|
values[tag(QString("percpricechg"))] = 100.0 * values[QString("pricechg")].toFloat() / values[QString("price")].toFloat();
|
||||||
|
values[tag(QString("price"))] = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ExtQuotes::translate()
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
|
ui->label_name->setText(i18n("Name"));
|
||||||
|
ui->label_comment->setText(i18n("Comment"));
|
||||||
|
ui->label_number->setText(i18n("Tag"));
|
||||||
|
ui->label->setText(i18n("<html><head/><body><p>Use YAHOO! finance ticker to get quotes for the instrument. Refer to <a href=\"http://finance.yahoo.com/\"><span style=\" text-decoration: underline; color:#0057ae;\">http://finance.yahoo.com/</span></a></p></body></html>"));
|
||||||
|
ui->label_ticker->setText(i18n("Ticker"));
|
||||||
|
ui->checkBox_active->setText(i18n("Active"));
|
||||||
|
ui->label_interval->setText(i18n("Interval"));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString ExtQuotes::url() const
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
|
QString apiUrl = QString(YAHOO_URL);
|
||||||
|
apiUrl.replace(QString("$TICKER"), m_ticker);
|
||||||
|
qCInfo(LOG_LIB) << "API url" << apiUrl;
|
||||||
|
|
||||||
|
return apiUrl;
|
||||||
|
}
|
@ -18,79 +18,54 @@
|
|||||||
#ifndef EXTQUOTES_H
|
#ifndef EXTQUOTES_H
|
||||||
#define EXTQUOTES_H
|
#define EXTQUOTES_H
|
||||||
|
|
||||||
#include <QDialog>
|
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
|
#include <QNetworkReply>
|
||||||
|
|
||||||
#define YAHOO_URL "https://query.yahooapis.com/v1/public/yql?q=select * from yahoo.finance.quotes where symbol in (\"$TICKER\")&env=store://datatables.org/alltableswithkeys"
|
#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"
|
||||||
|
|
||||||
class QNetworkReply;
|
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class ExtQuotes;
|
class ExtQuotes;
|
||||||
}
|
}
|
||||||
|
|
||||||
class ExtQuotes : public QDialog
|
class ExtQuotes : public AbstractExtItem
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
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(int interval READ interval WRITE setInterval)
|
|
||||||
Q_PROPERTY(bool active READ isActive WRITE setActive)
|
|
||||||
Q_PROPERTY(int number READ number WRITE setNumber)
|
|
||||||
Q_PROPERTY(QString ticker READ ticker WRITE setTicker)
|
Q_PROPERTY(QString ticker READ ticker WRITE setTicker)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit ExtQuotes(QWidget *parent = nullptr, const QString quotesName = QString(),
|
explicit ExtQuotes(QWidget *parent = nullptr, const QString quotesName = QString(),
|
||||||
const QStringList directories = QStringList(), const bool debugCmd = false);
|
const QStringList directories = QStringList());
|
||||||
~ExtQuotes();
|
virtual ~ExtQuotes();
|
||||||
|
ExtQuotes *copy(const QString _fileName, const int _number);
|
||||||
// get methods
|
// get methods
|
||||||
int apiVersion();
|
QString ticker() const;
|
||||||
QString comment();
|
QString uniq() const;
|
||||||
QString fileName();
|
|
||||||
int interval();
|
|
||||||
bool isActive();
|
|
||||||
QString name();
|
|
||||||
int number();
|
|
||||||
QString tag(const QString _type = QString("price"));
|
|
||||||
QString ticker();
|
|
||||||
// set methods
|
// 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 = 0);
|
|
||||||
void setName(const QString _name = QString("none"));
|
|
||||||
void setNumber(int _number = -1);
|
|
||||||
void setTicker(const QString _ticker = QString("EURUSD=X"));
|
void setTicker(const QString _ticker = QString("EURUSD=X"));
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void readConfiguration();
|
void readConfiguration();
|
||||||
QMap<QString, float> run();
|
QVariantHash run();
|
||||||
int showConfiguration();
|
int showConfiguration(const QVariant args = QVariant());
|
||||||
bool tryDelete();
|
void writeConfiguration() const;
|
||||||
void writeConfiguration();
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void quotesReplyReceived(QNetworkReply *reply);
|
void quotesReplyReceived(QNetworkReply *reply);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString m_fileName;
|
QNetworkAccessManager *manager;
|
||||||
QStringList m_dirs;
|
bool isRunning = false;
|
||||||
bool debug;
|
|
||||||
Ui::ExtQuotes *ui;
|
Ui::ExtQuotes *ui;
|
||||||
QString url();
|
void translate();
|
||||||
|
QString url() const;
|
||||||
// properties
|
// properties
|
||||||
int m_apiVersion = 0;
|
|
||||||
bool m_active = true;
|
|
||||||
QString m_comment = QString("empty");
|
|
||||||
int m_interval = 60;
|
|
||||||
QString m_name = QString("none");
|
|
||||||
int m_number = -1;
|
|
||||||
QString m_ticker = QString("EURUSD=X");
|
QString m_ticker = QString("EURUSD=X");
|
||||||
// values
|
// values
|
||||||
int times = 0;
|
int times = 0;
|
||||||
QMap<QString, float> values;
|
QVariantHash values;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
437
sources/awesomewidgets/extscript.cpp
Normal file
@ -0,0 +1,437 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* This file is part of awesome-widgets *
|
||||||
|
* *
|
||||||
|
* awesome-widgets is free software: you can redistribute it and/or *
|
||||||
|
* modify it under the terms of the GNU General Public License as *
|
||||||
|
* published by the Free Software Foundation, either version 3 of the *
|
||||||
|
* License, or (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* awesome-widgets is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#include "extscript.h"
|
||||||
|
#include "ui_extscript.h"
|
||||||
|
|
||||||
|
#include <KI18n/KLocalizedString>
|
||||||
|
|
||||||
|
#include <QDir>
|
||||||
|
#include <QJsonDocument>
|
||||||
|
#include <QJsonParseError>
|
||||||
|
#include <QSettings>
|
||||||
|
#include <QStandardPaths>
|
||||||
|
#include <QTextCodec>
|
||||||
|
|
||||||
|
#include "awdebug.h"
|
||||||
|
#include "version.h"
|
||||||
|
|
||||||
|
|
||||||
|
ExtScript::ExtScript(QWidget *parent, const QString scriptName,
|
||||||
|
const QStringList directories)
|
||||||
|
: AbstractExtItem(parent, scriptName, directories),
|
||||||
|
ui(new Ui::ExtScript)
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
|
readConfiguration();
|
||||||
|
readJsonFilters();
|
||||||
|
ui->setupUi(this);
|
||||||
|
translate();
|
||||||
|
|
||||||
|
value[tag(QString("custom"))] = QString("");
|
||||||
|
|
||||||
|
process = new QProcess(this);
|
||||||
|
connect(process, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(updateValue()));
|
||||||
|
process->waitForFinished(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ExtScript::~ExtScript()
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
|
process->kill();
|
||||||
|
delete process;
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ExtScript *ExtScript::copy(const QString _fileName, const int _number)
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
qCDebug(LOG_LIB) << "File" << _fileName;
|
||||||
|
qCDebug(LOG_LIB) << "Number" << _number;
|
||||||
|
|
||||||
|
ExtScript *item = new ExtScript(static_cast<QWidget *>(parent()), _fileName, directories());
|
||||||
|
item->setActive(isActive());
|
||||||
|
item->setApiVersion(apiVersion());
|
||||||
|
item->setComment(comment());
|
||||||
|
item->setExecutable(executable());
|
||||||
|
item->setHasOutput(hasOutput());
|
||||||
|
item->setInterval(interval());
|
||||||
|
item->setName(name());
|
||||||
|
item->setNumber(_number);
|
||||||
|
item->setPrefix(prefix());
|
||||||
|
item->setRedirect(redirect());
|
||||||
|
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString ExtScript::executable() const
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
|
return m_executable;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QStringList ExtScript::filters() const
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
|
return m_filters;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool ExtScript::hasOutput() const
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
|
return m_output;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString ExtScript::prefix() const
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
|
return m_prefix;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ExtScript::Redirect ExtScript::redirect() const
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
|
return m_redirect;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString ExtScript::uniq() const
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
|
return m_executable;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString ExtScript::strRedirect() const
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
|
QString value;
|
||||||
|
switch (m_redirect) {
|
||||||
|
case stdout2stderr:
|
||||||
|
value = QString("stdout2stderr");
|
||||||
|
break;
|
||||||
|
case stderr2stdout:
|
||||||
|
value = QString("stderr2stdout");
|
||||||
|
break;
|
||||||
|
case nothing:
|
||||||
|
default:
|
||||||
|
value = QString("nothing");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ExtScript::setExecutable(const QString _executable)
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
qCDebug(LOG_LIB) << "Executable" << _executable;
|
||||||
|
|
||||||
|
m_executable = _executable;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ExtScript::setFilters(const QStringList _filters)
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
qCDebug(LOG_LIB) << "Filters" << _filters;
|
||||||
|
|
||||||
|
std::for_each(_filters.cbegin(), _filters.cend(),
|
||||||
|
[this](QString filter) { return updateFilter(filter); });
|
||||||
|
// foreach(QString filter, _filters)
|
||||||
|
// updateFilter(filter);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ExtScript::setHasOutput(const bool _state)
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
qCDebug(LOG_LIB) << "State" << _state;
|
||||||
|
|
||||||
|
m_output = _state;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ExtScript::setPrefix(const QString _prefix)
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
qCDebug(LOG_LIB) << "Prefix" << _prefix;
|
||||||
|
|
||||||
|
m_prefix = _prefix;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ExtScript::setRedirect(const Redirect _redirect)
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
qCDebug(LOG_LIB) << "Redirect" << _redirect;
|
||||||
|
|
||||||
|
m_redirect = _redirect;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ExtScript::setStrRedirect(const QString _redirect)
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
qCDebug(LOG_LIB) << "Redirect" << _redirect;
|
||||||
|
|
||||||
|
if (_redirect == QString("stdout2sdterr"))
|
||||||
|
m_redirect = stdout2stderr;
|
||||||
|
else if (_redirect == QString("stderr2sdtout"))
|
||||||
|
m_redirect = stderr2stdout;
|
||||||
|
else
|
||||||
|
m_redirect = nothing;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString ExtScript::applyFilters(QString _value) const
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
qCDebug(LOG_LIB) << "Value" << _value;
|
||||||
|
|
||||||
|
foreach(QString filt, m_filters) {
|
||||||
|
qCInfo(LOG_LIB) << "Found filter" << filt;
|
||||||
|
QVariantMap filter = jsonFilters[filt].toMap();
|
||||||
|
if (filter.isEmpty()) {
|
||||||
|
qCWarning(LOG_LIB) << "Could not find filter" << _value << "in the json";
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
foreach(QString f, filter.keys())
|
||||||
|
_value.replace(f, filter[f].toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
return _value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ExtScript::updateFilter(const QString _filter, const bool _add)
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
qCDebug(LOG_LIB) << "Filter" << _filter;
|
||||||
|
qCDebug(LOG_LIB) << "Should be added" << _add;
|
||||||
|
|
||||||
|
if (_add) {
|
||||||
|
if (m_filters.contains(_filter)) return;
|
||||||
|
m_filters.append(_filter);
|
||||||
|
} else {
|
||||||
|
m_filters.removeOne(_filter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ExtScript::readConfiguration()
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
AbstractExtItem::readConfiguration();
|
||||||
|
|
||||||
|
for (int i=directories().count()-1; i>=0; i--) {
|
||||||
|
if (!QDir(directories().at(i)).entryList(QDir::Files).contains(fileName())) continue;
|
||||||
|
QSettings settings(QString("%1/%2").arg(directories().at(i)).arg(fileName()), QSettings::IniFormat);
|
||||||
|
|
||||||
|
settings.beginGroup(QString("Desktop Entry"));
|
||||||
|
setExecutable(settings.value(QString("Exec"), m_executable).toString());
|
||||||
|
setPrefix(settings.value(QString("X-AW-Prefix"), m_prefix).toString());
|
||||||
|
setHasOutput(settings.value(QString("X-AW-Output"), QVariant(m_output)).toString() == QString("true"));
|
||||||
|
setStrRedirect(settings.value(QString("X-AW-Redirect"), strRedirect()).toString());
|
||||||
|
// api == 3
|
||||||
|
setFilters(settings.value(QString("X-AW-Filters"), m_filters).toString()
|
||||||
|
.split(QChar(','), QString::SkipEmptyParts));
|
||||||
|
settings.endGroup();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!m_output)
|
||||||
|
setRedirect(stdout2stderr);
|
||||||
|
|
||||||
|
// update for current API
|
||||||
|
if ((apiVersion() > 0) && (apiVersion() < AWESAPI)) {
|
||||||
|
qCWarning(LOG_LIB) << "Bump API version from" << apiVersion() << "to" << AWESAPI;
|
||||||
|
setApiVersion(AWESAPI);
|
||||||
|
writeConfiguration();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ExtScript::readJsonFilters()
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
|
QString fileName = QStandardPaths::locate(QStandardPaths::GenericDataLocation,
|
||||||
|
QString("awesomewidgets/scripts/awesomewidgets-extscripts-filters.json"));
|
||||||
|
qCInfo(LOG_LIB) << "Filters file" << fileName;
|
||||||
|
QFile jsonFile(fileName);
|
||||||
|
if (!jsonFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||||
|
qCWarning(LOG_LIB) << "Could not open" << fileName;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
QString jsonText = jsonFile.readAll();
|
||||||
|
jsonFile.close();
|
||||||
|
|
||||||
|
QJsonParseError error;
|
||||||
|
QJsonDocument jsonDoc = QJsonDocument::fromJson(jsonText.toUtf8(), &error);
|
||||||
|
if (error.error != QJsonParseError::NoError) {
|
||||||
|
qCWarning(LOG_LIB) << "Parse error" << error.errorString();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
jsonFilters = jsonDoc.toVariant().toMap();
|
||||||
|
|
||||||
|
qCInfo(LOG_LIB) << "Filters" << jsonFilters;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QVariantHash ExtScript::run()
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
if (!isActive()) return value;
|
||||||
|
|
||||||
|
if ((times == 1) && (process->state() == QProcess::NotRunning)) {
|
||||||
|
QStringList cmdList;
|
||||||
|
if (!m_prefix.isEmpty()) cmdList.append(m_prefix);
|
||||||
|
cmdList.append(m_executable);
|
||||||
|
qCInfo(LOG_LIB) << "Run cmd" << cmdList.join(QChar(' '));
|
||||||
|
process->start(cmdList.join(QChar(' ')));
|
||||||
|
} else if (times >= interval())
|
||||||
|
times = 0;
|
||||||
|
times++;
|
||||||
|
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int ExtScript::showConfiguration(const QVariant args)
|
||||||
|
{
|
||||||
|
Q_UNUSED(args)
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
|
ui->lineEdit_name->setText(name());
|
||||||
|
ui->lineEdit_comment->setText(comment());
|
||||||
|
ui->label_numberValue->setText(QString("%1").arg(number()));
|
||||||
|
ui->lineEdit_command->setText(m_executable);
|
||||||
|
ui->lineEdit_prefix->setText(m_prefix);
|
||||||
|
ui->checkBox_active->setCheckState(isActive() ? Qt::Checked : Qt::Unchecked);
|
||||||
|
ui->checkBox_output->setCheckState(m_output ? Qt::Checked : Qt::Unchecked);
|
||||||
|
ui->comboBox_redirect->setCurrentIndex(static_cast<int>(m_redirect));
|
||||||
|
ui->spinBox_interval->setValue(interval());
|
||||||
|
// filters
|
||||||
|
ui->checkBox_colorFilter->setCheckState(m_filters.contains(QString("color")) ? Qt::Checked : Qt::Unchecked);
|
||||||
|
ui->checkBox_linesFilter->setCheckState(m_filters.contains(QString("newline")) ? Qt::Checked : Qt::Unchecked);
|
||||||
|
ui->checkBox_spaceFilter->setCheckState(m_filters.contains(QString("space")) ? Qt::Checked : Qt::Unchecked);
|
||||||
|
|
||||||
|
int ret = exec();
|
||||||
|
if (ret != 1) return ret;
|
||||||
|
setName(ui->lineEdit_name->text());
|
||||||
|
setComment(ui->lineEdit_comment->text());
|
||||||
|
setNumber(ui->label_numberValue->text().toInt());
|
||||||
|
setApiVersion(AWESAPI);
|
||||||
|
setExecutable(ui->lineEdit_command->text());
|
||||||
|
setPrefix(ui->lineEdit_prefix->text());
|
||||||
|
setActive(ui->checkBox_active->checkState() == Qt::Checked);
|
||||||
|
setHasOutput(ui->checkBox_output->checkState() == Qt::Checked);
|
||||||
|
setStrRedirect(ui->comboBox_redirect->currentText());
|
||||||
|
setInterval(ui->spinBox_interval->value());
|
||||||
|
// filters
|
||||||
|
updateFilter(QString("color"), ui->checkBox_colorFilter->checkState() == Qt::Checked);
|
||||||
|
updateFilter(QString("newline"), ui->checkBox_linesFilter->checkState() == Qt::Checked);
|
||||||
|
updateFilter(QString("space"), ui->checkBox_spaceFilter->checkState() == Qt::Checked);
|
||||||
|
|
||||||
|
writeConfiguration();
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ExtScript::writeConfiguration() const
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
AbstractExtItem::writeConfiguration();
|
||||||
|
|
||||||
|
QSettings settings(QString("%1/%2").arg(directories().first()).arg(fileName()), QSettings::IniFormat);
|
||||||
|
qCInfo(LOG_LIB) << "Configuration file" << settings.fileName();
|
||||||
|
|
||||||
|
settings.beginGroup(QString("Desktop Entry"));
|
||||||
|
settings.setValue(QString("Exec"), m_executable);
|
||||||
|
settings.setValue(QString("X-AW-Prefix"), m_prefix);
|
||||||
|
settings.setValue(QString("X-AW-Output"), QVariant(m_output).toString());
|
||||||
|
settings.setValue(QString("X-AW-Redirect"), strRedirect());
|
||||||
|
settings.setValue(QString("X-AW-Filters"), m_filters.join(QChar(',')));
|
||||||
|
settings.endGroup();
|
||||||
|
|
||||||
|
settings.sync();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ExtScript::updateValue()
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
|
qCInfo(LOG_LIB) << "Cmd returns" << process->exitCode();
|
||||||
|
QString qdebug = QTextCodec::codecForMib(106)->toUnicode(process->readAllStandardError()).trimmed();
|
||||||
|
qCInfo(LOG_LIB) << "Error" << qdebug;
|
||||||
|
QString qoutput = QTextCodec::codecForMib(106)->toUnicode(process->readAllStandardOutput()).trimmed();
|
||||||
|
qCInfo(LOG_LIB) << "Error" << qoutput;
|
||||||
|
QString strValue;
|
||||||
|
|
||||||
|
switch (m_redirect) {
|
||||||
|
case stdout2stderr:
|
||||||
|
break;
|
||||||
|
case stderr2stdout:
|
||||||
|
strValue = QString("%1\n%2").arg(qdebug).arg(qoutput);
|
||||||
|
break;
|
||||||
|
case nothing:
|
||||||
|
default:
|
||||||
|
strValue = qoutput;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// filters
|
||||||
|
value[tag(QString("custom"))] = applyFilters(strValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ExtScript::translate()
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
|
ui->label_name->setText(i18n("Name"));
|
||||||
|
ui->label_comment->setText(i18n("Comment"));
|
||||||
|
ui->label_number->setText(i18n("Tag"));
|
||||||
|
ui->label_command->setText(i18n("Command"));
|
||||||
|
ui->label_prefix->setText(i18n("Prefix"));
|
||||||
|
ui->checkBox_active->setText(i18n("Active"));
|
||||||
|
ui->checkBox_output->setText(i18n("Has output"));
|
||||||
|
ui->label_redirect->setText(i18n("Redirect"));
|
||||||
|
ui->label_interval->setText(i18n("Interval"));
|
||||||
|
ui->groupBox_filters->setTitle(i18n("Additional filters"));
|
||||||
|
ui->checkBox_colorFilter->setText(i18n("Wrap colors"));
|
||||||
|
ui->checkBox_linesFilter->setText(i18n("Wrap new lines"));
|
||||||
|
ui->checkBox_spaceFilter->setText(i18n("Wrap spaces"));
|
||||||
|
}
|
@ -18,26 +18,23 @@
|
|||||||
#ifndef EXTSCRIPT_H
|
#ifndef EXTSCRIPT_H
|
||||||
#define EXTSCRIPT_H
|
#define EXTSCRIPT_H
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QMap>
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
|
|
||||||
|
#include "abstractextitem.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class ExtScript;
|
class ExtScript;
|
||||||
}
|
}
|
||||||
|
|
||||||
class ExtScript : public QDialog
|
class ExtScript : public AbstractExtItem
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
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 executable READ executable WRITE setExecutable)
|
||||||
Q_PROPERTY(int number READ number WRITE setNumber)
|
Q_PROPERTY(QStringList filters READ filters WRITE setFilters)
|
||||||
Q_PROPERTY(QString prefix READ prefix WRITE setPrefix)
|
|
||||||
Q_PROPERTY(bool active READ isActive WRITE setActive)
|
|
||||||
Q_PROPERTY(bool output READ hasOutput WRITE setHasOutput)
|
Q_PROPERTY(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)
|
Q_PROPERTY(Redirect redirect READ redirect WRITE setRedirect)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -48,65 +45,54 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
explicit ExtScript(QWidget *parent = nullptr, const QString scriptName = QString(),
|
explicit ExtScript(QWidget *parent = nullptr, const QString scriptName = QString(),
|
||||||
const QStringList directories = QStringList(), const bool debugCmd = false);
|
const QStringList directories = QStringList());
|
||||||
~ExtScript();
|
virtual ~ExtScript();
|
||||||
|
ExtScript *copy(const QString _fileName, const int _number);
|
||||||
// get methods
|
// get methods
|
||||||
int apiVersion();
|
QString executable() const;
|
||||||
QString comment();
|
QStringList filters() const;
|
||||||
QString executable();
|
bool hasOutput() const;
|
||||||
QString fileName();
|
QString prefix() const;
|
||||||
int interval();
|
Redirect redirect() const;
|
||||||
QString name();
|
QString uniq() const;
|
||||||
int number();
|
// derivatives
|
||||||
QString prefix();
|
QString strRedirect() const;
|
||||||
Redirect redirect();
|
|
||||||
QString strRedirect();
|
|
||||||
QString tag();
|
|
||||||
bool hasOutput();
|
|
||||||
bool isActive();
|
|
||||||
// set methods
|
// 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 setExecutable(const QString _executable = QString("/usr/bin/true"));
|
||||||
|
void setFilters(const QStringList _filters = QStringList());
|
||||||
void setHasOutput(const bool _state = true);
|
void setHasOutput(const bool _state = true);
|
||||||
void setInterval(const int _interval = 1);
|
|
||||||
void setName(const QString _name = QString("none"));
|
|
||||||
void setNumber(int _number = -1);
|
|
||||||
void setPrefix(const QString _prefix = QString(""));
|
void setPrefix(const QString _prefix = QString(""));
|
||||||
void setRedirect(const Redirect _redirect = nothing);
|
void setRedirect(const Redirect _redirect = nothing);
|
||||||
void setStrRedirect(const QString _redirect = QString("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:
|
public slots:
|
||||||
void readConfiguration();
|
void readConfiguration();
|
||||||
QString run();
|
void readJsonFilters();
|
||||||
int showConfiguration();
|
QVariantHash run();
|
||||||
bool tryDelete();
|
int showConfiguration(const QVariant args = QVariant());
|
||||||
void writeConfiguration();
|
void writeConfiguration() const;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void updateValue();
|
void updateValue();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString m_fileName;
|
|
||||||
QStringList m_dirs;
|
|
||||||
bool debug;
|
|
||||||
QProcess *process = nullptr;
|
QProcess *process = nullptr;
|
||||||
Ui::ExtScript *ui;
|
Ui::ExtScript *ui;
|
||||||
|
void translate();
|
||||||
// properties
|
// properties
|
||||||
int m_apiVersion = 0;
|
|
||||||
bool m_active = true;
|
|
||||||
QString m_comment = QString("empty");
|
|
||||||
QString m_executable = QString("/usr/bin/true");
|
QString m_executable = QString("/usr/bin/true");
|
||||||
int m_interval = 1;
|
QStringList m_filters = QStringList();
|
||||||
QString m_name = QString("none");
|
|
||||||
int m_number = -1;
|
|
||||||
bool m_output = true;
|
bool m_output = true;
|
||||||
QString m_prefix = QString("");
|
QString m_prefix = QString("");
|
||||||
Redirect m_redirect = nothing;
|
Redirect m_redirect = nothing;
|
||||||
|
// internal properties
|
||||||
Q_PID childProcess = 0;
|
Q_PID childProcess = 0;
|
||||||
|
QVariantMap jsonFilters = QVariantMap();
|
||||||
int times = 0;
|
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>
|
262
sources/awesomewidgets/extupgrade.cpp
Normal file
@ -0,0 +1,262 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* This file is part of awesome-widgets *
|
||||||
|
* *
|
||||||
|
* awesome-widgets is free software: you can redistribute it and/or *
|
||||||
|
* modify it under the terms of the GNU General Public License as *
|
||||||
|
* published by the Free Software Foundation, either version 3 of the *
|
||||||
|
* License, or (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* awesome-widgets is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#include "extupgrade.h"
|
||||||
|
#include "ui_extupgrade.h"
|
||||||
|
|
||||||
|
#include <KI18n/KLocalizedString>
|
||||||
|
|
||||||
|
#include <QDir>
|
||||||
|
#include <QRegExp>
|
||||||
|
#include <QSettings>
|
||||||
|
#include <QTextCodec>
|
||||||
|
|
||||||
|
#include "awdebug.h"
|
||||||
|
#include "version.h"
|
||||||
|
|
||||||
|
|
||||||
|
ExtUpgrade::ExtUpgrade(QWidget *parent, const QString upgradeName,
|
||||||
|
const QStringList directories)
|
||||||
|
: AbstractExtItem(parent, upgradeName, directories),
|
||||||
|
ui(new Ui::ExtUpgrade)
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
|
readConfiguration();
|
||||||
|
ui->setupUi(this);
|
||||||
|
translate();
|
||||||
|
|
||||||
|
value[tag(QString("pkgcount"))] = 0;
|
||||||
|
|
||||||
|
process = new QProcess(this);
|
||||||
|
connect(process, SIGNAL(finished(int)), this, SLOT(updateValue()));
|
||||||
|
process->waitForFinished(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ExtUpgrade::~ExtUpgrade()
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
|
process->kill();
|
||||||
|
delete process;
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ExtUpgrade *ExtUpgrade::copy(const QString _fileName, const int _number)
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
qCDebug(LOG_LIB) << "File" << _fileName;
|
||||||
|
qCDebug(LOG_LIB) << "Number" << _number;
|
||||||
|
|
||||||
|
ExtUpgrade *item = new ExtUpgrade(static_cast<QWidget *>(parent()), _fileName, directories());
|
||||||
|
item->setActive(isActive());
|
||||||
|
item->setApiVersion(apiVersion());
|
||||||
|
item->setComment(comment());
|
||||||
|
item->setExecutable(executable());
|
||||||
|
item->setFilter(filter());
|
||||||
|
item->setInterval(interval());
|
||||||
|
item->setName(name());
|
||||||
|
item->setNumber(_number);
|
||||||
|
item->setNull(null());
|
||||||
|
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString ExtUpgrade::executable() const
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
|
return m_executable;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString ExtUpgrade::filter() const
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
|
return m_filter;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int ExtUpgrade::null() const
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
|
return m_null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString ExtUpgrade::uniq() const
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
|
return m_executable;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ExtUpgrade::setExecutable(const QString _executable)
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
qCDebug(LOG_LIB) << "Executable" << _executable;
|
||||||
|
|
||||||
|
m_executable = _executable;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ExtUpgrade::setFilter(const QString _filter)
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
qCDebug(LOG_LIB) << "Filter" << _filter;
|
||||||
|
|
||||||
|
m_filter = _filter;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ExtUpgrade::setNull(const int _null)
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
qCDebug(LOG_LIB) << "Null lines" << _null;
|
||||||
|
if (_null < 0) return;
|
||||||
|
|
||||||
|
m_null = _null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ExtUpgrade::readConfiguration()
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
AbstractExtItem::readConfiguration();
|
||||||
|
|
||||||
|
for (int i=directories().count()-1; i>=0; i--) {
|
||||||
|
if (!QDir(directories().at(i)).entryList(QDir::Files).contains(fileName())) continue;
|
||||||
|
QSettings settings(QString("%1/%2").arg(directories().at(i)).arg(fileName()), QSettings::IniFormat);
|
||||||
|
|
||||||
|
settings.beginGroup(QString("Desktop Entry"));
|
||||||
|
setExecutable(settings.value(QString("Exec"), m_executable).toString());
|
||||||
|
setNull(settings.value(QString("X-AW-Null"), m_null).toInt());
|
||||||
|
// api == 3
|
||||||
|
setFilter(settings.value(QString("X-AW-Filter"), m_filter).toString());
|
||||||
|
settings.endGroup();
|
||||||
|
}
|
||||||
|
|
||||||
|
// update for current API
|
||||||
|
if ((apiVersion() > 0) && (apiVersion() < AWEUAPI)) {
|
||||||
|
qCWarning(LOG_LIB) << "Bump API version from" << apiVersion() << "to" << AWEUAPI;
|
||||||
|
setApiVersion(AWEUAPI);
|
||||||
|
writeConfiguration();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QVariantHash ExtUpgrade::run()
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
if (!isActive()) return value;
|
||||||
|
|
||||||
|
if ((times == 1) && (process->state() == QProcess::NotRunning)) {
|
||||||
|
QString cmd = QString("sh -c \"%1\"").arg(m_executable);
|
||||||
|
qCInfo(LOG_LIB) << "Run cmd" << cmd;
|
||||||
|
process->start(cmd);
|
||||||
|
} else if (times >= interval())
|
||||||
|
times = 0;
|
||||||
|
times++;
|
||||||
|
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int ExtUpgrade::showConfiguration(const QVariant args)
|
||||||
|
{
|
||||||
|
Q_UNUSED(args)
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
|
ui->lineEdit_name->setText(name());
|
||||||
|
ui->lineEdit_comment->setText(comment());
|
||||||
|
ui->label_numberValue->setText(QString("%1").arg(number()));
|
||||||
|
ui->lineEdit_command->setText(m_executable);
|
||||||
|
ui->lineEdit_filter->setText(m_filter);
|
||||||
|
ui->checkBox_active->setCheckState(isActive() ? Qt::Checked : Qt::Unchecked);
|
||||||
|
ui->spinBox_null->setValue(m_null);
|
||||||
|
ui->spinBox_interval->setValue(interval());
|
||||||
|
|
||||||
|
int ret = exec();
|
||||||
|
if (ret != 1) return ret;
|
||||||
|
setName(ui->lineEdit_name->text());
|
||||||
|
setComment(ui->lineEdit_comment->text());
|
||||||
|
setNumber(ui->label_numberValue->text().toInt());
|
||||||
|
setApiVersion(AWEUAPI);
|
||||||
|
setExecutable(ui->lineEdit_command->text());
|
||||||
|
setFilter(ui->lineEdit_filter->text());
|
||||||
|
setActive(ui->checkBox_active->checkState() == Qt::Checked);
|
||||||
|
setNull(ui->spinBox_null->value());
|
||||||
|
setInterval(ui->spinBox_interval->value());
|
||||||
|
|
||||||
|
writeConfiguration();
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ExtUpgrade::writeConfiguration() const
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
AbstractExtItem::writeConfiguration();
|
||||||
|
|
||||||
|
QSettings settings(QString("%1/%2").arg(directories().first()).arg(fileName()), QSettings::IniFormat);
|
||||||
|
qCInfo(LOG_LIB) << "Configuration file" << settings.fileName();
|
||||||
|
|
||||||
|
settings.beginGroup(QString("Desktop Entry"));
|
||||||
|
settings.setValue(QString("Exec"), m_executable);
|
||||||
|
settings.setValue(QString("X-AW-Filter"), m_filter);
|
||||||
|
settings.setValue(QString("X-AW-Null"), m_null);
|
||||||
|
settings.endGroup();
|
||||||
|
|
||||||
|
settings.sync();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ExtUpgrade::updateValue()
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
|
qCInfo(LOG_LIB) << "Cmd returns" << process->exitCode();
|
||||||
|
qCInfo(LOG_LIB) << "Error" << process->readAllStandardError();
|
||||||
|
|
||||||
|
QString qoutput = QTextCodec::codecForMib(106)->toUnicode(process->readAllStandardOutput()).trimmed();
|
||||||
|
value[tag(QString("pkgcount"))] = [this](QString output) {
|
||||||
|
return m_filter.isEmpty() ?
|
||||||
|
output.split(QChar('\n'), QString::SkipEmptyParts).count() - m_null :
|
||||||
|
output.split(QChar('\n'), QString::SkipEmptyParts).filter(QRegExp(m_filter)).count();
|
||||||
|
}(qoutput);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ExtUpgrade::translate()
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
|
ui->label_name->setText(i18n("Name"));
|
||||||
|
ui->label_comment->setText(i18n("Comment"));
|
||||||
|
ui->label_number->setText(i18n("Tag"));
|
||||||
|
ui->label_command->setText(i18n("Command"));
|
||||||
|
ui->label_filter->setText(i18n("Filter"));
|
||||||
|
ui->checkBox_active->setText(i18n("Active"));
|
||||||
|
ui->label_null->setText(i18n("Null"));
|
||||||
|
ui->label_interval->setText(i18n("Interval"));
|
||||||
|
}
|
75
sources/awesomewidgets/extupgrade.h
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* This file is part of awesome-widgets *
|
||||||
|
* *
|
||||||
|
* awesome-widgets is free software: you can redistribute it and/or *
|
||||||
|
* modify it under the terms of the GNU General Public License as *
|
||||||
|
* published by the Free Software Foundation, either version 3 of the *
|
||||||
|
* License, or (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* awesome-widgets is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef EXTUPGRADE_H
|
||||||
|
#define EXTUPGRADE_H
|
||||||
|
|
||||||
|
#include <QProcess>
|
||||||
|
|
||||||
|
#include "abstractextitem.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
class ExtUpgrade;
|
||||||
|
}
|
||||||
|
|
||||||
|
class ExtUpgrade : public AbstractExtItem
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(QString executable READ executable WRITE setExecutable)
|
||||||
|
Q_PROPERTY(QString filter READ filter WRITE setFilter)
|
||||||
|
Q_PROPERTY(int null READ null WRITE setNull)
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit ExtUpgrade(QWidget *parent = nullptr, const QString upgradeName = QString(),
|
||||||
|
const QStringList directories = QStringList());
|
||||||
|
virtual ~ExtUpgrade();
|
||||||
|
ExtUpgrade *copy(const QString _fileName, const int _number);
|
||||||
|
// get methods
|
||||||
|
QString executable() const;
|
||||||
|
QString filter() const;
|
||||||
|
int null() const;
|
||||||
|
QString uniq() const;
|
||||||
|
// set methods
|
||||||
|
void setExecutable(const QString _executable = QString("/usr/bin/true"));
|
||||||
|
void setFilter(const QString _filter = QString());
|
||||||
|
void setNull(const int _null = 0);
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void readConfiguration();
|
||||||
|
QVariantHash run();
|
||||||
|
int showConfiguration(const QVariant args = QVariant());
|
||||||
|
void writeConfiguration() const;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void updateValue();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QProcess *process = nullptr;
|
||||||
|
Ui::ExtUpgrade *ui;
|
||||||
|
void translate();
|
||||||
|
// properties
|
||||||
|
QString m_executable = QString("/usr/bin/true");
|
||||||
|
QString m_filter = QString("");
|
||||||
|
int m_null = 0;
|
||||||
|
// internal properties
|
||||||
|
int times = 0;
|
||||||
|
QVariantHash value;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* EXTUPGRADE_H */
|
@ -104,6 +104,29 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="layout_filter">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_filter">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Filter</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLineEdit" name="lineEdit_filter"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="layout_active">
|
<layout class="QHBoxLayout" name="layout_active">
|
||||||
<item>
|
<item>
|
395
sources/awesomewidgets/extweather.cpp
Normal file
@ -0,0 +1,395 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* This file is part of awesome-widgets *
|
||||||
|
* *
|
||||||
|
* awesome-widgets is free software: you can redistribute it and/or *
|
||||||
|
* modify it under the terms of the GNU General Public License as *
|
||||||
|
* published by the Free Software Foundation, either version 3 of the *
|
||||||
|
* License, or (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* awesome-widgets is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#include "extweather.h"
|
||||||
|
#include "ui_extweather.h"
|
||||||
|
|
||||||
|
#include <KI18n/KLocalizedString>
|
||||||
|
|
||||||
|
#include <QDir>
|
||||||
|
#include <QJsonDocument>
|
||||||
|
#include <QJsonParseError>
|
||||||
|
#include <QNetworkAccessManager>
|
||||||
|
#include <QNetworkRequest>
|
||||||
|
#include <QSettings>
|
||||||
|
#include <QStandardPaths>
|
||||||
|
|
||||||
|
#include <qreplytimeout/qreplytimeout.h>
|
||||||
|
|
||||||
|
#include "awdebug.h"
|
||||||
|
#include "version.h"
|
||||||
|
|
||||||
|
|
||||||
|
ExtWeather::ExtWeather(QWidget *parent, const QString weatherName,
|
||||||
|
const QStringList directories)
|
||||||
|
: AbstractExtItem(parent, weatherName, directories),
|
||||||
|
ui(new Ui::ExtWeather)
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
|
readConfiguration();
|
||||||
|
readJsonMap();
|
||||||
|
ui->setupUi(this);
|
||||||
|
translate();
|
||||||
|
|
||||||
|
values[tag(QString("weatherId"))] = 0;
|
||||||
|
values[tag(QString("weather"))] = QString("");
|
||||||
|
values[tag(QString("humidity"))] = 0;
|
||||||
|
values[tag(QString("pressure"))] = 0.0;
|
||||||
|
values[tag(QString("temperature"))] = 0.0;
|
||||||
|
|
||||||
|
manager = new QNetworkAccessManager(this);
|
||||||
|
connect(manager, SIGNAL(finished(QNetworkReply *)),
|
||||||
|
this, SLOT(weatherReplyReceived(QNetworkReply *)));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ExtWeather::~ExtWeather()
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
|
disconnect(manager, SIGNAL(finished(QNetworkReply *)),
|
||||||
|
this, SLOT(weatherReplyReceived(QNetworkReply *)));
|
||||||
|
|
||||||
|
delete manager;
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ExtWeather *ExtWeather::copy(const QString _fileName, const int _number)
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
qCDebug(LOG_LIB) << "File" << _fileName;
|
||||||
|
qCDebug(LOG_LIB) << "Number" << _number;
|
||||||
|
|
||||||
|
ExtWeather *item = new ExtWeather(static_cast<QWidget *>(parent()), _fileName, directories());
|
||||||
|
item->setActive(isActive());
|
||||||
|
item->setApiVersion(apiVersion());
|
||||||
|
item->setCity(city());
|
||||||
|
item->setComment(comment());
|
||||||
|
item->setCountry(country());
|
||||||
|
item->setInterval(interval());
|
||||||
|
item->setImage(image());
|
||||||
|
item->setName(name());
|
||||||
|
item->setNumber(_number);
|
||||||
|
item->setTs(ts());
|
||||||
|
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString ExtWeather::weatherFromInt(const int _id) const
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
qCDebug(LOG_LIB) << "Weather ID" << _id;
|
||||||
|
|
||||||
|
QVariantMap map = jsonMap[m_image ? QString("image") : QString("text")].toMap();
|
||||||
|
return map.value(QString::number(_id), map[QString("default")]).toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString ExtWeather::city() const
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
|
return m_city;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString ExtWeather::country() const
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
|
return m_country;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool ExtWeather::image() const
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
|
return m_image;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int ExtWeather::ts() const
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
|
return m_ts;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString ExtWeather::uniq() const
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
|
return QString("%1 (%2) at %3").arg(m_city).arg(m_country).arg(m_ts);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ExtWeather::setCity(const QString _city)
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
qCDebug(LOG_LIB) << "City" << _city;
|
||||||
|
|
||||||
|
m_city = _city;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ExtWeather::setCountry(const QString _country)
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
qCDebug(LOG_LIB) << "Country" << _country;
|
||||||
|
|
||||||
|
m_country = _country;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ExtWeather::setImage(const bool _image)
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
qCDebug(LOG_LIB) << "Use image" << _image;
|
||||||
|
|
||||||
|
m_image = _image;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ExtWeather::setTs(const int _ts)
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
qCDebug(LOG_LIB) << "Timestamp" << _ts;
|
||||||
|
|
||||||
|
m_ts = _ts;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ExtWeather::readConfiguration()
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
AbstractExtItem::readConfiguration();
|
||||||
|
|
||||||
|
for (int i=directories().count()-1; i>=0; i--) {
|
||||||
|
if (!QDir(directories().at(i)).entryList(QDir::Files).contains(fileName())) continue;
|
||||||
|
QSettings settings(QString("%1/%2").arg(directories().at(i)).arg(fileName()), QSettings::IniFormat);
|
||||||
|
|
||||||
|
settings.beginGroup(QString("Desktop Entry"));
|
||||||
|
setCity(settings.value(QString("X-AW-City"), m_city).toString());
|
||||||
|
setCountry(settings.value(QString("X-AW-Country"), m_country).toString());
|
||||||
|
setTs(settings.value(QString("X-AW-TS"), m_ts).toInt());
|
||||||
|
// api == 2
|
||||||
|
setImage(settings.value(QString("X-AW-Image"), QVariant(m_image)).toString() == QString("true"));
|
||||||
|
settings.endGroup();
|
||||||
|
}
|
||||||
|
|
||||||
|
// update for current API
|
||||||
|
if ((apiVersion() > 0) && (apiVersion() < AWEWAPI)) {
|
||||||
|
qCWarning(LOG_LIB) << "Bump API version from" << apiVersion() << "to" << AWEWAPI;
|
||||||
|
setApiVersion(AWEWAPI);
|
||||||
|
writeConfiguration();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ExtWeather::readJsonMap()
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
|
QString fileName = QStandardPaths::locate(QStandardPaths::GenericDataLocation,
|
||||||
|
QString("awesomewidgets/weather/awesomewidgets-extweather-ids.json"));
|
||||||
|
qCInfo(LOG_LIB) << "Map file" << fileName;
|
||||||
|
QFile jsonFile(fileName);
|
||||||
|
if (!jsonFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||||
|
qCWarning(LOG_LIB) << "Could not open" << fileName;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
QString jsonText = jsonFile.readAll();
|
||||||
|
jsonFile.close();
|
||||||
|
|
||||||
|
QJsonParseError error;
|
||||||
|
QJsonDocument jsonDoc = QJsonDocument::fromJson(jsonText.toUtf8(), &error);
|
||||||
|
if (error.error != QJsonParseError::NoError) {
|
||||||
|
qCWarning(LOG_LIB) << "Parse error" << error.errorString();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
jsonMap = jsonDoc.toVariant().toMap();
|
||||||
|
|
||||||
|
qCInfo(LOG_LIB) << "Weather map" << jsonMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QVariantHash ExtWeather::run()
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
if ((!isActive()) || (isRunning)) return values;
|
||||||
|
|
||||||
|
if (times == 1) {
|
||||||
|
qCInfo(LOG_LIB) << "Send request";
|
||||||
|
isRunning = true;
|
||||||
|
QNetworkReply *reply = manager->get(QNetworkRequest(QUrl(url(m_ts != 0))));
|
||||||
|
new QReplyTimeout(reply, 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
// update value
|
||||||
|
if (times >= interval()) times = 0;
|
||||||
|
times++;
|
||||||
|
|
||||||
|
return values;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int ExtWeather::showConfiguration(const QVariant args)
|
||||||
|
{
|
||||||
|
Q_UNUSED(args)
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
|
ui->lineEdit_name->setText(name());
|
||||||
|
ui->lineEdit_comment->setText(comment());
|
||||||
|
ui->label_numberValue->setText(QString("%1").arg(number()));
|
||||||
|
ui->lineEdit_city->setText(m_city);
|
||||||
|
ui->lineEdit_country->setText(m_country);
|
||||||
|
ui->spinBox_timestamp->setValue(m_ts);
|
||||||
|
ui->checkBox_image->setCheckState(m_image ? Qt::Checked : Qt::Unchecked);
|
||||||
|
ui->checkBox_active->setCheckState(isActive() ? Qt::Checked : Qt::Unchecked);
|
||||||
|
ui->spinBox_interval->setValue(interval());
|
||||||
|
|
||||||
|
int ret = exec();
|
||||||
|
if (ret != 1) return ret;
|
||||||
|
setName(ui->lineEdit_name->text());
|
||||||
|
setComment(ui->lineEdit_comment->text());
|
||||||
|
setNumber(ui->label_numberValue->text().toInt());
|
||||||
|
setApiVersion(AWEWAPI);
|
||||||
|
setCity(ui->lineEdit_city->text());
|
||||||
|
setCountry(ui->lineEdit_country->text());
|
||||||
|
setTs(ui->spinBox_timestamp->value());
|
||||||
|
setImage(ui->checkBox_image->checkState() == Qt::Checked);
|
||||||
|
setActive(ui->checkBox_active->checkState() == Qt::Checked);
|
||||||
|
setInterval(ui->spinBox_interval->value());
|
||||||
|
|
||||||
|
writeConfiguration();
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ExtWeather::writeConfiguration() const
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
AbstractExtItem::writeConfiguration();
|
||||||
|
|
||||||
|
QSettings settings(QString("%1/%2").arg(directories().first()).arg(fileName()), QSettings::IniFormat);
|
||||||
|
qCInfo(LOG_LIB) << "Configuration file" << settings.fileName();
|
||||||
|
|
||||||
|
settings.beginGroup(QString("Desktop Entry"));
|
||||||
|
settings.setValue(QString("X-AW-City"), m_city);
|
||||||
|
settings.setValue(QString("X-AW-Country"), m_country);
|
||||||
|
settings.setValue(QString("X-AW-Image"), m_image);
|
||||||
|
settings.setValue(QString("X-AW-TS"), m_ts);
|
||||||
|
settings.endGroup();
|
||||||
|
|
||||||
|
settings.sync();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ExtWeather::weatherReplyReceived(QNetworkReply *reply)
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
qCDebug(LOG_LIB) << "Return code" << reply->error();
|
||||||
|
qCDebug(LOG_LIB) << "Reply error message" << reply->errorString();
|
||||||
|
|
||||||
|
isRunning = false;
|
||||||
|
QJsonParseError error;
|
||||||
|
QJsonDocument jsonDoc = QJsonDocument::fromJson(reply->readAll(), &error);
|
||||||
|
reply->deleteLater();
|
||||||
|
if ((reply->error() != QNetworkReply::NoError) ||
|
||||||
|
(error.error != QJsonParseError::NoError)) {
|
||||||
|
qCWarning(LOG_LIB) << "Parse error" << error.errorString();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// convert to map
|
||||||
|
QVariantMap json = jsonDoc.toVariant().toMap();
|
||||||
|
if (json[QString("cod")].toInt() != 200) {
|
||||||
|
qCWarning(LOG_LIB) << "Invalid return code";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariantHash data;
|
||||||
|
if (m_ts == 0)
|
||||||
|
data = parseSingleJson(json);
|
||||||
|
else {
|
||||||
|
QVariantList list = json[QString("list")].toList();
|
||||||
|
data = parseSingleJson(list.count() <= m_ts ? list.at(m_ts-1).toMap() : list.last().toMap());
|
||||||
|
}
|
||||||
|
foreach(QString key, data.keys()) values[tag(key)] = data[key];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QVariantHash ExtWeather::parseSingleJson(const QVariantMap json) const
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
qCDebug(LOG_LIB) << "Single json data" << json;
|
||||||
|
|
||||||
|
QVariantHash output;
|
||||||
|
|
||||||
|
// weather status
|
||||||
|
QVariantList weather = json[QString("weather")].toList();
|
||||||
|
if (!weather.isEmpty()) {
|
||||||
|
int _id = weather.first().toMap()[QString("id")].toInt();
|
||||||
|
output[QString("weatherId")] = _id;
|
||||||
|
output[QString("weather")] = weatherFromInt(_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
// main data
|
||||||
|
QVariantMap mainWeather = json[QString("main")].toMap();
|
||||||
|
if (!weather.isEmpty()) {
|
||||||
|
output[QString("humidity")] = mainWeather[QString("humidity")].toFloat();
|
||||||
|
output[QString("pressure")] = mainWeather[QString("pressure")].toFloat();
|
||||||
|
output[QString("temperature")] = mainWeather[QString("temp")].toFloat();
|
||||||
|
}
|
||||||
|
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ExtWeather::translate()
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
|
ui->label_name->setText(i18n("Name"));
|
||||||
|
ui->label_comment->setText(i18n("Comment"));
|
||||||
|
ui->label_number->setText(i18n("Tag"));
|
||||||
|
ui->label_city->setText(i18n("City"));
|
||||||
|
ui->label_country->setText(i18n("Country"));
|
||||||
|
ui->label_timestamp->setText(i18n("Timestamp"));
|
||||||
|
ui->checkBox_image->setText(i18n("Use images"));
|
||||||
|
ui->checkBox_active->setText(i18n("Active"));
|
||||||
|
ui->label_interval->setText(i18n("Interval"));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString ExtWeather::url(const bool isForecast) const
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
qCDebug(LOG_LIB) << "Is forecast" << isForecast;
|
||||||
|
|
||||||
|
QString apiUrl = isForecast ? QString(OWM_FORECAST_URL) : QString(OWM_URL);
|
||||||
|
apiUrl.replace(QString("$CITY"), m_city);
|
||||||
|
apiUrl.replace(QString("$COUNTRY"), m_country);
|
||||||
|
qCInfo(LOG_LIB) << "API url" << apiUrl;
|
||||||
|
|
||||||
|
return apiUrl;
|
||||||
|
}
|
89
sources/awesomewidgets/extweather.h
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* This file is part of awesome-widgets *
|
||||||
|
* *
|
||||||
|
* awesome-widgets is free software: you can redistribute it and/or *
|
||||||
|
* modify it under the terms of the GNU General Public License as *
|
||||||
|
* published by the Free Software Foundation, either version 3 of the *
|
||||||
|
* License, or (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* awesome-widgets is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef EXTWEATHER_H
|
||||||
|
#define EXTWEATHER_H
|
||||||
|
|
||||||
|
#include <QMap>
|
||||||
|
#include <QNetworkReply>
|
||||||
|
|
||||||
|
#include "abstractextitem.h"
|
||||||
|
|
||||||
|
#define OWM_URL "http://api.openweathermap.org/data/2.5/weather?q=$CITY,$COUNTRY&units=metric"
|
||||||
|
#define OWM_FORECAST_URL "http://api.openweathermap.org/data/2.5/forecast?q=$CITY,$COUNTRY&units=metric"
|
||||||
|
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
class ExtWeather;
|
||||||
|
}
|
||||||
|
|
||||||
|
class ExtWeather : public AbstractExtItem
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(QString city READ city WRITE setCity)
|
||||||
|
Q_PROPERTY(QString country READ country WRITE setCountry)
|
||||||
|
Q_PROPERTY(bool image READ image WRITE setImage)
|
||||||
|
Q_PROPERTY(int ts READ ts WRITE setTs)
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit ExtWeather(QWidget *parent = nullptr, const QString weatherName = QString(),
|
||||||
|
const QStringList directories = QStringList());
|
||||||
|
virtual ~ExtWeather();
|
||||||
|
ExtWeather *copy(const QString _fileName, const int _number);
|
||||||
|
QString weatherFromInt(const int _id) const;
|
||||||
|
// get methods
|
||||||
|
QString city() const;
|
||||||
|
QString country() const;
|
||||||
|
bool image() const;
|
||||||
|
int ts() const;
|
||||||
|
QString uniq() const;
|
||||||
|
// set methods
|
||||||
|
void setCity(const QString _city = QString("London"));
|
||||||
|
void setCountry(const QString _country = QString("uk"));
|
||||||
|
void setImage(const bool _image = false);
|
||||||
|
void setTs(const int _ts = 0);
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void readConfiguration();
|
||||||
|
void readJsonMap();
|
||||||
|
QVariantHash run();
|
||||||
|
int showConfiguration(const QVariant args = QVariant());
|
||||||
|
void writeConfiguration() const;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void weatherReplyReceived(QNetworkReply *reply);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QNetworkAccessManager *manager;
|
||||||
|
bool isRunning = false;
|
||||||
|
Ui::ExtWeather *ui;
|
||||||
|
QVariantHash parseSingleJson(const QVariantMap json) const;
|
||||||
|
void translate();
|
||||||
|
QString url(const bool isForecast = false) const;
|
||||||
|
// properties
|
||||||
|
QString m_city = QString("London");
|
||||||
|
QString m_country = QString("uk");
|
||||||
|
bool m_image = false;
|
||||||
|
int m_ts = 0;
|
||||||
|
QVariantMap jsonMap = QVariantMap();
|
||||||
|
// values
|
||||||
|
int times = 0;
|
||||||
|
QVariantHash values;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* EXTWEATHER_H */
|
@ -1,13 +1,13 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<ui version="4.0">
|
<ui version="4.0">
|
||||||
<class>ExtScript</class>
|
<class>ExtWeather</class>
|
||||||
<widget class="QDialog" name="ExtScript">
|
<widget class="QDialog" name="ExtWeather">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>420</width>
|
<width>420</width>
|
||||||
<height>304</height>
|
<height>301</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@ -82,9 +82,9 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="layout_command">
|
<layout class="QHBoxLayout" name="layout_city">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_command">
|
<widget class="QLabel" name="label_city">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
@ -92,7 +92,7 @@
|
|||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Command</string>
|
<string>City</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="alignment">
|
<property name="alignment">
|
||||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
@ -100,14 +100,14 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLineEdit" name="lineEdit_command"/>
|
<widget class="QLineEdit" name="lineEdit_city"/>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="layout_prefix">
|
<layout class="QHBoxLayout" name="layout_country">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_prefix">
|
<widget class="QLabel" name="label_country">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
@ -115,7 +115,7 @@
|
|||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Prefix</string>
|
<string>Country</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="alignment">
|
<property name="alignment">
|
||||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
@ -123,7 +123,58 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLineEdit" name="lineEdit_prefix"/>
|
<widget class="QLineEdit" name="lineEdit_country"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="layout_timestamp">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_timestamp">
|
||||||
|
<property name="text">
|
||||||
|
<string>Timestamp</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QSpinBox" name="spinBox_timestamp">
|
||||||
|
<property name="maximum">
|
||||||
|
<number>40</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="layout_image">
|
||||||
|
<item>
|
||||||
|
<spacer name="spacer_image">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="checkBox_image">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Use images</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
@ -157,69 +208,6 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</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>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="layout_interval">
|
<layout class="QHBoxLayout" name="layout_interval">
|
||||||
<item>
|
<item>
|
||||||
@ -240,6 +228,12 @@
|
|||||||
<property name="maximum">
|
<property name="maximum">
|
||||||
<number>10000</number>
|
<number>10000</number>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="singleStep">
|
||||||
|
<number>10</number>
|
||||||
|
</property>
|
||||||
|
<property name="value">
|
||||||
|
<number>60</number>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
@ -274,7 +268,7 @@
|
|||||||
<connection>
|
<connection>
|
||||||
<sender>buttonBox</sender>
|
<sender>buttonBox</sender>
|
||||||
<signal>accepted()</signal>
|
<signal>accepted()</signal>
|
||||||
<receiver>ExtScript</receiver>
|
<receiver>ExtWeather</receiver>
|
||||||
<slot>accept()</slot>
|
<slot>accept()</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
@ -290,7 +284,7 @@
|
|||||||
<connection>
|
<connection>
|
||||||
<sender>buttonBox</sender>
|
<sender>buttonBox</sender>
|
||||||
<signal>rejected()</signal>
|
<signal>rejected()</signal>
|
||||||
<receiver>ExtScript</receiver>
|
<receiver>ExtWeather</receiver>
|
||||||
<slot>reject()</slot>
|
<slot>reject()</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
@ -22,28 +22,27 @@
|
|||||||
|
|
||||||
#include <QBuffer>
|
#include <QBuffer>
|
||||||
#include <QColorDialog>
|
#include <QColorDialog>
|
||||||
#include <QDebug>
|
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QGraphicsEllipseItem>
|
#include <QGraphicsEllipseItem>
|
||||||
#include <QGraphicsScene>
|
#include <QGraphicsScene>
|
||||||
#include <QGraphicsView>
|
#include <QGraphicsView>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
|
|
||||||
#include <pdebug/pdebug.h>
|
#include "awdebug.h"
|
||||||
|
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
|
||||||
|
|
||||||
GraphicalItem::GraphicalItem(QWidget *parent, const QString desktopName, const QStringList directories, const bool debugCmd)
|
GraphicalItem::GraphicalItem(QWidget *parent, const QString desktopName,
|
||||||
: QDialog(parent),
|
const QStringList directories)
|
||||||
m_fileName(desktopName),
|
: AbstractExtItem(parent, desktopName, directories),
|
||||||
m_dirs(directories),
|
|
||||||
debug(debugCmd),
|
|
||||||
ui(new Ui::GraphicalItem)
|
ui(new Ui::GraphicalItem)
|
||||||
{
|
{
|
||||||
readConfiguration();
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
|
readConfiguration();
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
translate();
|
||||||
|
|
||||||
connect(ui->pushButton_activeColor, SIGNAL(clicked()), this, SLOT(changeColor()));
|
connect(ui->pushButton_activeColor, SIGNAL(clicked()), this, SLOT(changeColor()));
|
||||||
connect(ui->pushButton_inactiveColor, SIGNAL(clicked()), this, SLOT(changeColor()));
|
connect(ui->pushButton_inactiveColor, SIGNAL(clicked()), this, SLOT(changeColor()));
|
||||||
}
|
}
|
||||||
@ -51,22 +50,47 @@ GraphicalItem::GraphicalItem(QWidget *parent, const QString desktopName, const Q
|
|||||||
|
|
||||||
GraphicalItem::~GraphicalItem()
|
GraphicalItem::~GraphicalItem()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString GraphicalItem::image(const float value)
|
GraphicalItem *GraphicalItem::copy(const QString _fileName, const int _number)
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
qCDebug(LOG_LIB);
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Value" << value;
|
qCDebug(LOG_LIB) << "File" << _fileName;
|
||||||
|
qCDebug(LOG_LIB) << "Number" << _number;
|
||||||
|
|
||||||
|
GraphicalItem *item = new GraphicalItem(static_cast<QWidget *>(parent()), _fileName, directories());
|
||||||
|
item->setActive(isActive());
|
||||||
|
item->setActiveColor(activeColor());
|
||||||
|
item->setApiVersion(apiVersion());
|
||||||
|
item->setBar(bar());
|
||||||
|
item->setComment(comment());
|
||||||
|
item->setDirection(direction());
|
||||||
|
item->setHeight(height());
|
||||||
|
item->setInactiveColor(inactiveColor());
|
||||||
|
item->setInterval(interval());
|
||||||
|
item->setName(QString("bar%1").arg(_number));
|
||||||
|
item->setNumber(_number);
|
||||||
|
item->setType(type());
|
||||||
|
item->setWidth(width());
|
||||||
|
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString GraphicalItem::image(const float value) const
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
qCDebug(LOG_LIB) << "Value" << value;
|
||||||
if (m_bar == QString("none")) return QString("");
|
if (m_bar == QString("none")) return QString("");
|
||||||
|
|
||||||
QColor active = stringToColor(m_activeColor);
|
QColor active = stringToColor(m_activeColor);
|
||||||
QColor inactive = stringToColor(m_inactiveColor);
|
QColor inactive = stringToColor(m_inactiveColor);
|
||||||
float percent = value / 100.0;
|
float percent = value / 100.0;
|
||||||
int scale[2] = {1, 1};
|
int scale[2] = { 1, 1 };
|
||||||
QPen pen = QPen();
|
QPen pen = QPen();
|
||||||
QGraphicsScene *scene = new QGraphicsScene();
|
QGraphicsScene *scene = new QGraphicsScene();
|
||||||
scene->setBackgroundBrush(QBrush(Qt::NoBrush));
|
scene->setBackgroundBrush(QBrush(Qt::NoBrush));
|
||||||
@ -137,73 +161,49 @@ QString GraphicalItem::image(const float value)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString GraphicalItem::fileName()
|
QString GraphicalItem::bar() const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
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;
|
return m_bar;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString GraphicalItem::activeColor()
|
QString GraphicalItem::activeColor() const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
return m_activeColor;
|
return m_activeColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString GraphicalItem::inactiveColor()
|
QString GraphicalItem::inactiveColor() const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
return m_inactiveColor;
|
return m_inactiveColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
GraphicalItem::Type GraphicalItem::type()
|
QString GraphicalItem::tag() const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
|
return name() + m_bar;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
GraphicalItem::Type GraphicalItem::type() const
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
return m_type;
|
return m_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString GraphicalItem::strType()
|
QString GraphicalItem::strType() const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
QString value;
|
QString value;
|
||||||
switch (m_type) {
|
switch (m_type) {
|
||||||
@ -222,17 +222,17 @@ QString GraphicalItem::strType()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
GraphicalItem::Direction GraphicalItem::direction()
|
GraphicalItem::Direction GraphicalItem::direction() const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
return m_direction;
|
return m_direction;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString GraphicalItem::strDirection()
|
QString GraphicalItem::strDirection() const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
QString value;
|
QString value;
|
||||||
switch (m_direction) {
|
switch (m_direction) {
|
||||||
@ -248,70 +248,47 @@ QString GraphicalItem::strDirection()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int GraphicalItem::height()
|
int GraphicalItem::height() const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
return m_height;
|
return m_height;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int GraphicalItem::width()
|
int GraphicalItem::width() const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
return m_width;
|
return m_width;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GraphicalItem::setApiVersion(const int _apiVersion)
|
QString GraphicalItem::uniq() const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
qCDebug(LOG_LIB);
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Version" << _apiVersion;
|
|
||||||
|
|
||||||
m_apiVersion = _apiVersion;
|
return m_bar;
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
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)
|
void GraphicalItem::setBar(const QString _bar)
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
qCDebug(LOG_LIB);
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Bar" << _bar;
|
qCDebug(LOG_LIB) << "Bar" << _bar;
|
||||||
|
|
||||||
if ((!_bar.contains(QRegExp(QString("cpu(?!cl).*")))) &&
|
if (!_bar.contains(QRegExp(QString("^(cpu(?!cl).*|gpu$|mem$|swap$|hdd[0-9].*|bat.*)")))) {
|
||||||
(!_bar.contains(QRegExp(QString("gpu")))) &&
|
qCWarning(LOG_LIB) << "Unsupported bar type" << _bar;
|
||||||
(!_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");
|
m_bar = QString("none");
|
||||||
else
|
} else
|
||||||
m_bar = _bar;
|
m_bar = _bar;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GraphicalItem::setActiveColor(const QString _color)
|
void GraphicalItem::setActiveColor(const QString _color)
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
qCDebug(LOG_LIB);
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Color" << _color;
|
qCDebug(LOG_LIB) << "Color" << _color;
|
||||||
|
|
||||||
m_activeColor = _color;
|
m_activeColor = _color;
|
||||||
}
|
}
|
||||||
@ -319,8 +296,8 @@ void GraphicalItem::setActiveColor(const QString _color)
|
|||||||
|
|
||||||
void GraphicalItem::setInactiveColor(const QString _color)
|
void GraphicalItem::setInactiveColor(const QString _color)
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
qCDebug(LOG_LIB);
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Color" << _color;
|
qCDebug(LOG_LIB) << "Color" << _color;
|
||||||
|
|
||||||
m_inactiveColor = _color;
|
m_inactiveColor = _color;
|
||||||
}
|
}
|
||||||
@ -328,8 +305,8 @@ void GraphicalItem::setInactiveColor(const QString _color)
|
|||||||
|
|
||||||
void GraphicalItem::setType(const Type _type)
|
void GraphicalItem::setType(const Type _type)
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
qCDebug(LOG_LIB);
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Type" << _type;
|
qCDebug(LOG_LIB) << "Type" << _type;
|
||||||
|
|
||||||
m_type = _type;
|
m_type = _type;
|
||||||
}
|
}
|
||||||
@ -337,8 +314,8 @@ void GraphicalItem::setType(const Type _type)
|
|||||||
|
|
||||||
void GraphicalItem::setStrType(const QString _type)
|
void GraphicalItem::setStrType(const QString _type)
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
qCDebug(LOG_LIB);
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Type" << _type;
|
qCDebug(LOG_LIB) << "Type" << _type;
|
||||||
|
|
||||||
if (_type == QString("Vertical"))
|
if (_type == QString("Vertical"))
|
||||||
setType(Vertical);
|
setType(Vertical);
|
||||||
@ -351,8 +328,8 @@ void GraphicalItem::setStrType(const QString _type)
|
|||||||
|
|
||||||
void GraphicalItem::setDirection(const Direction _direction)
|
void GraphicalItem::setDirection(const Direction _direction)
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
qCDebug(LOG_LIB);
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Direction" << _direction;
|
qCDebug(LOG_LIB) << "Direction" << _direction;
|
||||||
|
|
||||||
m_direction = _direction;
|
m_direction = _direction;
|
||||||
}
|
}
|
||||||
@ -360,8 +337,8 @@ void GraphicalItem::setDirection(const Direction _direction)
|
|||||||
|
|
||||||
void GraphicalItem::setStrDirection(const QString _direction)
|
void GraphicalItem::setStrDirection(const QString _direction)
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
qCDebug(LOG_LIB);
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Direction" << _direction;
|
qCDebug(LOG_LIB) << "Direction" << _direction;
|
||||||
|
|
||||||
if (_direction == QString("RightToLeft"))
|
if (_direction == QString("RightToLeft"))
|
||||||
setDirection(RightToLeft);
|
setDirection(RightToLeft);
|
||||||
@ -372,8 +349,8 @@ void GraphicalItem::setStrDirection(const QString _direction)
|
|||||||
|
|
||||||
void GraphicalItem::setHeight(const int _height)
|
void GraphicalItem::setHeight(const int _height)
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
qCDebug(LOG_LIB);
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Height" << _height;
|
qCDebug(LOG_LIB) << "Height" << _height;
|
||||||
if (_height <= 0) return;
|
if (_height <= 0) return;
|
||||||
|
|
||||||
m_height = _height;
|
m_height = _height;
|
||||||
@ -382,8 +359,8 @@ void GraphicalItem::setHeight(const int _height)
|
|||||||
|
|
||||||
void GraphicalItem::setWidth(const int _width)
|
void GraphicalItem::setWidth(const int _width)
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
qCDebug(LOG_LIB);
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Width" << _width;
|
qCDebug(LOG_LIB) << "Width" << _width;
|
||||||
if (_width <= 0) return;
|
if (_width <= 0) return;
|
||||||
|
|
||||||
m_width = _width;
|
m_width = _width;
|
||||||
@ -392,16 +369,14 @@ void GraphicalItem::setWidth(const int _width)
|
|||||||
|
|
||||||
void GraphicalItem::readConfiguration()
|
void GraphicalItem::readConfiguration()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
qCDebug(LOG_LIB);
|
||||||
|
AbstractExtItem::readConfiguration();
|
||||||
|
|
||||||
for (int i=m_dirs.count()-1; i>=0; i--) {
|
for (int i=directories().count()-1; i>=0; i--) {
|
||||||
if (!QDir(m_dirs[i]).entryList(QDir::Files).contains(m_fileName)) continue;
|
if (!QDir(directories().at(i)).entryList(QDir::Files).contains(fileName())) continue;
|
||||||
QSettings settings(QString("%1/%2").arg(m_dirs[i]).arg(m_fileName), QSettings::IniFormat);
|
QSettings settings(QString("%1/%2").arg(directories().at(i)).arg(fileName()), QSettings::IniFormat);
|
||||||
|
|
||||||
settings.beginGroup(QString("Desktop Entry"));
|
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());
|
setBar(settings.value(QString("X-AW-Value"), m_bar).toString());
|
||||||
setActiveColor(settings.value(QString("X-AW-ActiveColor"), m_activeColor).toString());
|
setActiveColor(settings.value(QString("X-AW-ActiveColor"), m_activeColor).toString());
|
||||||
setInactiveColor(settings.value(QString("X-AW-InactiveColor"), m_inactiveColor).toString());
|
setInactiveColor(settings.value(QString("X-AW-InactiveColor"), m_inactiveColor).toString());
|
||||||
@ -409,17 +384,37 @@ void GraphicalItem::readConfiguration()
|
|||||||
setStrDirection(settings.value(QString("X-AW-Direction"), strDirection()).toString());
|
setStrDirection(settings.value(QString("X-AW-Direction"), strDirection()).toString());
|
||||||
setHeight(settings.value(QString("X-AW-Height"), m_height).toInt());
|
setHeight(settings.value(QString("X-AW-Height"), m_height).toInt());
|
||||||
setWidth(settings.value(QString("X-AW-Width"), m_width).toInt());
|
setWidth(settings.value(QString("X-AW-Width"), m_width).toInt());
|
||||||
|
// api == 2
|
||||||
|
if (apiVersion() < 2) setNumber(bar().remove(QString("bar")).toInt());
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// update for current API
|
||||||
|
if ((apiVersion() > 0) && (apiVersion() < AWGIAPI)) {
|
||||||
|
qCWarning(LOG_LIB) << "Bump API version from" << apiVersion() << "to" << AWGIAPI;
|
||||||
|
setApiVersion(AWGIAPI);
|
||||||
|
writeConfiguration();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int GraphicalItem::showConfiguration(const QStringList tags)
|
QVariantHash GraphicalItem::run()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
ui->label_nameValue->setText(m_name);
|
// required by abstract class
|
||||||
ui->lineEdit_comment->setText(m_comment);
|
return QVariantHash();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int GraphicalItem::showConfiguration(const QVariant args)
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
qCDebug(LOG_LIB) << "Combobox arguments" << args;
|
||||||
|
QStringList tags = args.toStringList();
|
||||||
|
|
||||||
|
ui->label_nameValue->setText(name());
|
||||||
|
ui->lineEdit_comment->setText(comment());
|
||||||
ui->comboBox_value->addItems(tags);
|
ui->comboBox_value->addItems(tags);
|
||||||
ui->comboBox_value->addItem(m_bar);
|
ui->comboBox_value->addItem(m_bar);
|
||||||
ui->comboBox_value->setCurrentIndex(ui->comboBox_value->count() - 1);
|
ui->comboBox_value->setCurrentIndex(ui->comboBox_value->count() - 1);
|
||||||
@ -449,33 +444,15 @@ int GraphicalItem::showConfiguration(const QStringList tags)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool GraphicalItem::tryDelete()
|
void GraphicalItem::writeConfiguration() const
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
qCDebug(LOG_LIB);
|
||||||
|
AbstractExtItem::writeConfiguration();
|
||||||
|
|
||||||
for (int i=0; i<m_dirs.count(); i++)
|
QSettings settings(QString("%1/%2").arg(directories().first()).arg(fileName()), QSettings::IniFormat);
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Remove file" << QString("%1/%2").arg(m_dirs[i]).arg(m_fileName) <<
|
qCInfo(LOG_LIB) << "Configuration file" << settings.fileName();
|
||||||
QFile::remove(QString("%1/%2").arg(m_dirs[i]).arg(m_fileName));
|
|
||||||
|
|
||||||
// check if exists
|
|
||||||
for (int i=0; i<m_dirs.count(); i++)
|
|
||||||
if (QFile::exists(QString("%1/%2").arg(m_dirs[i]).arg(m_fileName))) return false;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void GraphicalItem::writeConfiguration()
|
|
||||||
{
|
|
||||||
if (debug) qDebug() << PDEBUG;
|
|
||||||
|
|
||||||
QSettings settings(QString("%1/%2").arg(m_dirs[0]).arg(m_fileName), QSettings::IniFormat);
|
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Configuration file" << settings.fileName();
|
|
||||||
|
|
||||||
settings.beginGroup(QString("Desktop Entry"));
|
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-Value"), m_bar);
|
||||||
settings.setValue(QString("X-AW-ActiveColor"), m_activeColor);
|
settings.setValue(QString("X-AW-ActiveColor"), m_activeColor);
|
||||||
settings.setValue(QString("X-AW-InactiveColor"), m_inactiveColor);
|
settings.setValue(QString("X-AW-InactiveColor"), m_inactiveColor);
|
||||||
@ -491,35 +468,53 @@ void GraphicalItem::writeConfiguration()
|
|||||||
|
|
||||||
void GraphicalItem::changeColor()
|
void GraphicalItem::changeColor()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
QColor color = stringToColor((dynamic_cast<QPushButton *>(sender()))->text());
|
QColor color = stringToColor((static_cast<QPushButton *>(sender()))->text());
|
||||||
QColor newColor = QColorDialog::getColor(color, 0, i18n("Select color"),
|
QColor newColor = QColorDialog::getColor(color, this, tr("Select color"),
|
||||||
QColorDialog::ShowAlphaChannel);
|
QColorDialog::ShowAlphaChannel);
|
||||||
if (!newColor.isValid()) return;
|
if (!newColor.isValid()) return;
|
||||||
|
qCInfo(LOG_LIB) << "Selected color" << newColor;
|
||||||
|
|
||||||
QStringList colorText;
|
QStringList colorText;
|
||||||
colorText.append(QString("%1").arg(newColor.red()));
|
colorText.append(QString("%1").arg(newColor.red()));
|
||||||
colorText.append(QString("%1").arg(newColor.green()));
|
colorText.append(QString("%1").arg(newColor.green()));
|
||||||
colorText.append(QString("%1").arg(newColor.blue()));
|
colorText.append(QString("%1").arg(newColor.blue()));
|
||||||
colorText.append(QString("%1").arg(newColor.alpha()));
|
colorText.append(QString("%1").arg(newColor.alpha()));
|
||||||
dynamic_cast<QPushButton *>(sender())->setText(colorText.join(QChar(',')));
|
|
||||||
|
return 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;
|
qCDebug(LOG_LIB);
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Color" << _color;
|
qCDebug(LOG_LIB) << "Color" << _color;
|
||||||
|
|
||||||
QColor qcolor;
|
QColor qcolor;
|
||||||
QStringList listColor = _color.split(QChar(','));
|
QStringList listColor = _color.split(QChar(','));
|
||||||
while (listColor.count() < 4)
|
while (listColor.count() < 4)
|
||||||
listColor.append(QString("0"));
|
listColor.append(QString("0"));
|
||||||
qcolor.setRed(listColor[0].toInt());
|
qcolor.setRed(listColor.at(0).toInt());
|
||||||
qcolor.setGreen(listColor[1].toInt());
|
qcolor.setGreen(listColor.at(1).toInt());
|
||||||
qcolor.setBlue(listColor[2].toInt());
|
qcolor.setBlue(listColor.at(2).toInt());
|
||||||
qcolor.setAlpha(listColor[3].toInt());
|
qcolor.setAlpha(listColor.at(3).toInt());
|
||||||
|
|
||||||
return qcolor;
|
return qcolor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GraphicalItem::translate()
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB);
|
||||||
|
|
||||||
|
ui->label_name->setText(i18n("Name"));
|
||||||
|
ui->label_comment->setText(i18n("Comment"));
|
||||||
|
ui->label_value->setText(i18n("Value"));
|
||||||
|
ui->label_activeColor->setText(i18n("Active color"));
|
||||||
|
ui->label_inactiveColor->setText(i18n("Inactive color"));
|
||||||
|
ui->label_type->setText(i18n("Type"));
|
||||||
|
ui->label_direction->setText(i18n("Direction"));
|
||||||
|
ui->label_height->setText(i18n("Height"));
|
||||||
|
ui->label_width->setText(i18n("Width"));
|
||||||
|
}
|
@ -19,19 +19,17 @@
|
|||||||
#define GRAPHICALITEM_H
|
#define GRAPHICALITEM_H
|
||||||
|
|
||||||
#include <QColor>
|
#include <QColor>
|
||||||
#include <QDialog>
|
|
||||||
|
#include "abstractextitem.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class GraphicalItem;
|
class GraphicalItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
class GraphicalItem : public QDialog
|
class GraphicalItem : public AbstractExtItem
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
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 bar READ bar WRITE setBar)
|
||||||
Q_PROPERTY(QString activeColor READ activeColor WRITE setActiveColor)
|
Q_PROPERTY(QString activeColor READ activeColor WRITE setActiveColor)
|
||||||
Q_PROPERTY(QString inactiveColor READ inactiveColor WRITE setInactiveColor)
|
Q_PROPERTY(QString inactiveColor READ inactiveColor WRITE setInactiveColor)
|
||||||
@ -52,27 +50,23 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
explicit GraphicalItem(QWidget *parent = nullptr, const QString desktopName = QString(),
|
explicit GraphicalItem(QWidget *parent = nullptr, const QString desktopName = QString(),
|
||||||
const QStringList directories = QStringList(), const bool debugCmd = false);
|
const QStringList directories = QStringList());
|
||||||
~GraphicalItem();
|
virtual ~GraphicalItem();
|
||||||
QString fileName();
|
GraphicalItem *copy(const QString _fileName, const int _number);
|
||||||
QString image(const float value);
|
QString image(const float value) const;
|
||||||
// get methods
|
// get methods
|
||||||
int apiVersion();
|
QString bar() const;
|
||||||
QString name();
|
QString activeColor() const;
|
||||||
QString comment();
|
QString inactiveColor() const;
|
||||||
QString bar();
|
QString tag() const;
|
||||||
QString activeColor();
|
Type type() const;
|
||||||
QString inactiveColor();
|
QString strType() const;
|
||||||
Type type();
|
Direction direction() const;
|
||||||
QString strType();
|
QString strDirection() const;
|
||||||
Direction direction();
|
int height() const;
|
||||||
QString strDirection();
|
int width() const;
|
||||||
int height();
|
QString uniq() const;
|
||||||
int width();
|
|
||||||
// set methods
|
// 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 setBar(const QString _bar = QString("cpu"));
|
||||||
void setActiveColor(const QString _color = QString("0,0,0,130"));
|
void setActiveColor(const QString _color = QString("0,0,0,130"));
|
||||||
void setInactiveColor(const QString _color = QString("255,255,255,130"));
|
void setInactiveColor(const QString _color = QString("255,255,255,130"));
|
||||||
@ -85,23 +79,20 @@ public:
|
|||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void readConfiguration();
|
void readConfiguration();
|
||||||
int showConfiguration(const QStringList tags = QStringList());
|
QVariantHash run();
|
||||||
bool tryDelete();
|
int showConfiguration(const QVariant args = QVariant());
|
||||||
void writeConfiguration();
|
void writeConfiguration() const;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void changeColor();
|
void changeColor();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QColor stringToColor(const QString _color);
|
|
||||||
QString m_fileName;
|
QString m_fileName;
|
||||||
QStringList m_dirs;
|
QStringList m_dirs;
|
||||||
bool debug;
|
|
||||||
Ui::GraphicalItem *ui;
|
Ui::GraphicalItem *ui;
|
||||||
|
QColor stringToColor(const QString _color) const;
|
||||||
|
void translate();
|
||||||
// properties
|
// properties
|
||||||
int m_apiVersion = 0;
|
|
||||||
QString m_name = QString("none");
|
|
||||||
QString m_comment = QString("empty");
|
|
||||||
QString m_bar = QString("cpu");
|
QString m_bar = QString("cpu");
|
||||||
QString m_activeColor = QString("0,0,0,130");
|
QString m_activeColor = QString("0,0,0,130");
|
||||||
QString m_inactiveColor = QString("255,255,255,130");
|
QString m_inactiveColor = QString("255,255,255,130");
|
@ -4,6 +4,6 @@ Name=AAPL.NASDAQ
|
|||||||
Comment=Apple Inc
|
Comment=Apple Inc
|
||||||
X-AW-Ticker="AAPL"
|
X-AW-Ticker="AAPL"
|
||||||
X-AW-Active=false
|
X-AW-Active=false
|
||||||
X-AW-ApiVersion=1
|
X-AW-ApiVersion=2
|
||||||
X-AW-Interval=60
|
X-AW-Interval=60
|
||||||
X-AW-Number=0
|
X-AW-Number=0
|
@ -4,6 +4,6 @@ Name=EUR/RUB
|
|||||||
Comment=EUR/RUB
|
Comment=EUR/RUB
|
||||||
X-AW-Ticker="EURRUB=X"
|
X-AW-Ticker="EURRUB=X"
|
||||||
X-AW-Active=false
|
X-AW-Active=false
|
||||||
X-AW-ApiVersion=1
|
X-AW-ApiVersion=2
|
||||||
X-AW-Interval=60
|
X-AW-Interval=60
|
||||||
X-AW-Number=1
|
X-AW-Number=1
|
@ -4,6 +4,6 @@ Name=EUR/USD
|
|||||||
Comment=EUR/USD
|
Comment=EUR/USD
|
||||||
X-AW-Ticker="EURUSD=X"
|
X-AW-Ticker="EURUSD=X"
|
||||||
X-AW-Active=false
|
X-AW-Active=false
|
||||||
X-AW-ApiVersion=1
|
X-AW-ApiVersion=2
|
||||||
X-AW-Interval=60
|
X-AW-Interval=60
|
||||||
X-AW-Number=2
|
X-AW-Number=2
|
@ -4,6 +4,6 @@ Name=GOOG.NASDAQ
|
|||||||
Comment=Google Inc
|
Comment=Google Inc
|
||||||
X-AW-Ticker="GOOG"
|
X-AW-Ticker="GOOG"
|
||||||
X-AW-Active=false
|
X-AW-Active=false
|
||||||
X-AW-ApiVersion=1
|
X-AW-ApiVersion=2
|
||||||
X-AW-Interval=60
|
X-AW-Interval=60
|
||||||
X-AW-Number=3
|
X-AW-Number=3
|
@ -4,6 +4,6 @@ Name=MSFT.NASDAQ
|
|||||||
Comment=Microsoft Corp
|
Comment=Microsoft Corp
|
||||||
X-AW-Ticker="MSFT"
|
X-AW-Ticker="MSFT"
|
||||||
X-AW-Active=false
|
X-AW-Active=false
|
||||||
X-AW-ApiVersion=1
|
X-AW-ApiVersion=2
|
||||||
X-AW-Interval=60
|
X-AW-Interval=60
|
||||||
X-AW-Number=4
|
X-AW-Number=4
|
@ -4,6 +4,6 @@ Name=RTS
|
|||||||
Comment=RTS Index
|
Comment=RTS Index
|
||||||
X-AW-Ticker="RTS.RS"
|
X-AW-Ticker="RTS.RS"
|
||||||
X-AW-Active=false
|
X-AW-Active=false
|
||||||
X-AW-ApiVersion=1
|
X-AW-ApiVersion=2
|
||||||
X-AW-Interval=60
|
X-AW-Interval=60
|
||||||
X-AW-Number=5
|
X-AW-Number=5
|
@ -4,6 +4,6 @@ Name=S&P
|
|||||||
Comment=S&P 500 Index
|
Comment=S&P 500 Index
|
||||||
X-AW-Ticker="^GSPC"
|
X-AW-Ticker="^GSPC"
|
||||||
X-AW-Active=false
|
X-AW-Active=false
|
||||||
X-AW-ApiVersion=1
|
X-AW-ApiVersion=2
|
||||||
X-AW-Interval=60
|
X-AW-Interval=60
|
||||||
X-AW-Number=6
|
X-AW-Number=6
|
@ -4,6 +4,6 @@ Name=USD/RUB
|
|||||||
Comment=USD/RUB
|
Comment=USD/RUB
|
||||||
X-AW-Ticker="USDRUB=X"
|
X-AW-Ticker="USDRUB=X"
|
||||||
X-AW-Active=false
|
X-AW-Active=false
|
||||||
X-AW-ApiVersion=1
|
X-AW-ApiVersion=2
|
||||||
X-AW-Interval=60
|
X-AW-Interval=60
|
||||||
X-AW-Number=8
|
X-AW-Number=8
|
@ -4,6 +4,6 @@ Name=VIX
|
|||||||
Comment=Volatility S&P 500
|
Comment=Volatility S&P 500
|
||||||
X-AW-Ticker="^VIX"
|
X-AW-Ticker="^VIX"
|
||||||
X-AW-Active=false
|
X-AW-Active=false
|
||||||
X-AW-ApiVersion=1
|
X-AW-ApiVersion=2
|
||||||
X-AW-Interval=60
|
X-AW-Interval=60
|
||||||
X-AW-Number=7
|
X-AW-Number=7
|
@ -0,0 +1,29 @@
|
|||||||
|
{
|
||||||
|
"color": {
|
||||||
|
"\u001b[0;30m": "<span style=\"color:'#000000';\">",
|
||||||
|
"\u001b[1;30m": "<span style=\"color:'#808080';\">",
|
||||||
|
"\u001b[0;31m": "<span style=\"color:'#800000';\">",
|
||||||
|
"\u001b[1;31m": "<span style=\"color:'#ff0000';\">",
|
||||||
|
"\u001b[0;32m": "<span style=\"color:'#008000';\">",
|
||||||
|
"\u001b[1;32m": "<span style=\"color:'#00ff00';\">",
|
||||||
|
"\u001b[0;33m": "<span style=\"color:'#808000';\">",
|
||||||
|
"\u001b[1;33m": "<span style=\"color:'#ffff00';\">",
|
||||||
|
"\u001b[0;34m": "<span style=\"color:'#000080';\">",
|
||||||
|
"\u001b[1;34m": "<span style=\"color:'#0000ff';\">",
|
||||||
|
"\u001b[0;35m": "<span style=\"color:'#800080';\">",
|
||||||
|
"\u001b[1;35m": "<span style=\"color:'#ff00ff';\">",
|
||||||
|
"\u001b[0;36m": "<span style=\"color:'#008080';\">",
|
||||||
|
"\u001b[1;36m": "<span style=\"color:'#00ffff';\">",
|
||||||
|
"\u001b[0;37m": "<span style=\"color:'#c0c0c0';\">",
|
||||||
|
"\u001b[1;37m": "<span style=\"color:'#ffffff';\">",
|
||||||
|
"\u001b[0m": "</span>"
|
||||||
|
},
|
||||||
|
"newline": {
|
||||||
|
"\n": "<br>",
|
||||||
|
"\n\r": "<br>",
|
||||||
|
"\t": "	"
|
||||||
|
},
|
||||||
|
"space": {
|
||||||
|
" ": " "
|
||||||
|
}
|
||||||
|
}
|
@ -4,9 +4,10 @@ Name=aw-get-external-ip
|
|||||||
Comment=Custom command to get external IP
|
Comment=Custom command to get external IP
|
||||||
Exec=curl ip4.telize.com
|
Exec=curl ip4.telize.com
|
||||||
X-AW-Prefix=
|
X-AW-Prefix=
|
||||||
X-AW-Active=true
|
X-AW-Active=false
|
||||||
X-AW-Output=true
|
X-AW-Output=true
|
||||||
X-AW-Redirect=nothing
|
X-AW-Redirect=nothing
|
||||||
X-AW-Interval=1
|
X-AW-Interval=1
|
||||||
X-AW-ApiVersion=2
|
X-AW-ApiVersion=3
|
||||||
X-AW-Number=0
|
X-AW-Number=0
|
||||||
|
X-AW-Filters=
|
@ -4,7 +4,8 @@ Name=default-arch
|
|||||||
Comment=Archlinux upgrade info
|
Comment=Archlinux upgrade info
|
||||||
Exec=pacman -Qu
|
Exec=pacman -Qu
|
||||||
X-AW-Active=false
|
X-AW-Active=false
|
||||||
|
X-AW-Filter=
|
||||||
X-AW-Null=0
|
X-AW-Null=0
|
||||||
X-AW-Interval=3600
|
X-AW-Interval=3600
|
||||||
X-AW-ApiVersion=2
|
X-AW-ApiVersion=3
|
||||||
X-AW-Number=0
|
X-AW-Number=0
|
@ -4,7 +4,8 @@ Name=default-debian
|
|||||||
Comment=Debian upgrade info
|
Comment=Debian upgrade info
|
||||||
Exec=apt-show-versions -u -b
|
Exec=apt-show-versions -u -b
|
||||||
X-AW-Active=false
|
X-AW-Active=false
|
||||||
|
X-AW-Filter=
|
||||||
X-AW-Null=0
|
X-AW-Null=0
|
||||||
X-AW-Interval=3600
|
X-AW-Interval=3600
|
||||||
X-AW-ApiVersion=2
|
X-AW-ApiVersion=3
|
||||||
X-AW-Number=1
|
X-AW-Number=1
|
@ -4,7 +4,8 @@ Name=default-fedora
|
|||||||
Comment=Fedora upgrade info
|
Comment=Fedora upgrade info
|
||||||
Exec=yum list updates
|
Exec=yum list updates
|
||||||
X-AW-Active=false
|
X-AW-Active=false
|
||||||
|
X-AW-Filter=
|
||||||
X-AW-Null=3
|
X-AW-Null=3
|
||||||
X-AW-Interval=3600
|
X-AW-Interval=3600
|
||||||
X-AW-ApiVersion=2
|
X-AW-ApiVersion=3
|
||||||
X-AW-Number=2
|
X-AW-Number=2
|
@ -4,7 +4,8 @@ Name=default-mandriva
|
|||||||
Comment=Mandriva upgrade info
|
Comment=Mandriva upgrade info
|
||||||
Exec=urpmq --auto-select
|
Exec=urpmq --auto-select
|
||||||
X-AW-Active=false
|
X-AW-Active=false
|
||||||
|
X-AW-Filter=
|
||||||
X-AW-Null=0
|
X-AW-Null=0
|
||||||
X-AW-Interval=3600
|
X-AW-Interval=3600
|
||||||
X-AW-ApiVersion=2
|
X-AW-ApiVersion=3
|
||||||
X-AW-Number=3
|
X-AW-Number=3
|
@ -4,7 +4,8 @@ Name=default-ubuntu
|
|||||||
Comment=Ubuntu upgrade info
|
Comment=Ubuntu upgrade info
|
||||||
Exec=aptitude search '~U'
|
Exec=aptitude search '~U'
|
||||||
X-AW-Active=false
|
X-AW-Active=false
|
||||||
|
X-AW-Filter=
|
||||||
X-AW-Null=0
|
X-AW-Null=0
|
||||||
X-AW-Interval=3600
|
X-AW-Interval=3600
|
||||||
X-AW-ApiVersion=2
|
X-AW-ApiVersion=3
|
||||||
X-AW-Number=4
|
X-AW-Number=4
|
BIN
sources/awesomewidgets/weather/01d.png
Normal file
After Width: | Height: | Size: 2.8 KiB |
BIN
sources/awesomewidgets/weather/02d.png
Normal file
After Width: | Height: | Size: 2.9 KiB |
BIN
sources/awesomewidgets/weather/03d.png
Normal file
After Width: | Height: | Size: 2.5 KiB |
BIN
sources/awesomewidgets/weather/04d.png
Normal file
After Width: | Height: | Size: 2.7 KiB |
BIN
sources/awesomewidgets/weather/09d.png
Normal file
After Width: | Height: | Size: 3.7 KiB |
BIN
sources/awesomewidgets/weather/10d.png
Normal file
After Width: | Height: | Size: 3.7 KiB |
BIN
sources/awesomewidgets/weather/11d.png
Normal file
After Width: | Height: | Size: 3.7 KiB |
BIN
sources/awesomewidgets/weather/13d.png
Normal file
After Width: | Height: | Size: 3.8 KiB |
BIN
sources/awesomewidgets/weather/50d.png
Normal file
After Width: | Height: | Size: 3.3 KiB |
12
sources/awesomewidgets/weather/london.desktop
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
[Desktop Entry]
|
||||||
|
Comment=London current weather
|
||||||
|
Encoding=UTF-8
|
||||||
|
Name=London current
|
||||||
|
X-AW-Active=false
|
||||||
|
X-AW-ApiVersion=2
|
||||||
|
X-AW-City=London
|
||||||
|
X-AW-Country=uk
|
||||||
|
X-AW-Image=false
|
||||||
|
X-AW-Interval=3600
|
||||||
|
X-AW-Number=0
|
||||||
|
X-AW-TS=0
|
@ -1,19 +1,7 @@
|
|||||||
# set project name
|
set(SUBPROJECT plasma_applet_desktop-panel)
|
||||||
set (SUBPROJECT plasma_applet_desktop-panel)
|
message(STATUS "Subproject ${SUBPROJECT}")
|
||||||
message (STATUS "Subproject ${SUBPROJECT}")
|
|
||||||
|
|
||||||
# prepare
|
configure_file(metadata.desktop ${CMAKE_CURRENT_SOURCE_DIR}/package/metadata.desktop)
|
||||||
configure_file (metadata.desktop ${CMAKE_CURRENT_SOURCE_DIR}/package/metadata.desktop)
|
|
||||||
|
|
||||||
find_package (ECM 0.0.12 REQUIRED NO_MODULE)
|
add_subdirectory(plugin)
|
||||||
set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR})
|
plasma_install_package(package org.kde.plasma.desktoppanel)
|
||||||
|
|
||||||
find_package (Qt5 REQUIRED COMPONENTS Core Qml)
|
|
||||||
find_package (KF5 REQUIRED COMPONENTS I18n Notifications Plasma Service WindowSystem)
|
|
||||||
|
|
||||||
include (KDEInstallDirs)
|
|
||||||
include (KDECMakeSettings)
|
|
||||||
include (KDECompilerSettings)
|
|
||||||
|
|
||||||
add_subdirectory (plugin)
|
|
||||||
plasma_install_package (package org.kde.plasma.desktoppanel)
|
|
||||||
|
@ -38,9 +38,6 @@
|
|||||||
<entry name="mark" type="string">
|
<entry name="mark" type="string">
|
||||||
<default>¤</default>
|
<default>¤</default>
|
||||||
</entry>
|
</entry>
|
||||||
<entry name="panels" type="int">
|
|
||||||
<default>-1</default>
|
|
||||||
</entry>
|
|
||||||
</group>
|
</group>
|
||||||
|
|
||||||
<group name="Appearance">
|
<group name="Appearance">
|
||||||
|
@ -19,17 +19,22 @@ import QtQuick 2.0
|
|||||||
import QtQuick.Controls 1.3 as QtControls
|
import QtQuick.Controls 1.3 as QtControls
|
||||||
import QtQuick.Layouts 1.0 as QtLayouts
|
import QtQuick.Layouts 1.0 as QtLayouts
|
||||||
|
|
||||||
import org.kde.plasma.desktoppanel 1.0
|
import org.kde.plasma.private.desktoppanel 1.0
|
||||||
|
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: aboutPage
|
id: aboutPage
|
||||||
|
// backend
|
||||||
|
DPAdds {
|
||||||
|
id: dpAdds;
|
||||||
|
}
|
||||||
|
|
||||||
width: childrenRect.width
|
width: childrenRect.width
|
||||||
height: childrenRect.height
|
height: childrenRect.height
|
||||||
implicitWidth: pageColumn.implicitWidth
|
implicitWidth: pageColumn.implicitWidth
|
||||||
implicitHeight: pageColumn.implicitHeight
|
implicitHeight: pageColumn.implicitHeight
|
||||||
|
|
||||||
property bool debug: DPAdds.isDebugEnabled()
|
property bool debug: dpAdds.isDebugEnabled()
|
||||||
|
|
||||||
|
|
||||||
Column {
|
Column {
|
||||||
@ -45,28 +50,37 @@ Item {
|
|||||||
QtControls.Label {
|
QtControls.Label {
|
||||||
QtLayouts.Layout.fillWidth: true
|
QtLayouts.Layout.fillWidth: true
|
||||||
horizontalAlignment: Text.AlignHCenter
|
horizontalAlignment: Text.AlignHCenter
|
||||||
text: DPAdds.getAboutText("header")
|
text: dpAdds.getAboutText("header")
|
||||||
|
}
|
||||||
|
|
||||||
|
QtControls.Label {
|
||||||
|
QtLayouts.Layout.fillWidth: true
|
||||||
|
horizontalAlignment: Text.AlignHCenter
|
||||||
|
text: dpAdds.getAboutText("version")
|
||||||
}
|
}
|
||||||
|
|
||||||
QtControls.Label {
|
QtControls.Label {
|
||||||
QtLayouts.Layout.fillWidth: true
|
QtLayouts.Layout.fillWidth: true
|
||||||
horizontalAlignment: Text.AlignJustify
|
horizontalAlignment: Text.AlignJustify
|
||||||
text: DPAdds.getAboutText("description")
|
text: dpAdds.getAboutText("description")
|
||||||
}
|
}
|
||||||
|
|
||||||
QtControls.Label {
|
QtControls.Label {
|
||||||
QtLayouts.Layout.fillWidth: true
|
QtLayouts.Layout.fillWidth: true
|
||||||
horizontalAlignment: Text.AlignLeft
|
horizontalAlignment: Text.AlignLeft
|
||||||
textFormat: Text.RichText
|
textFormat: Text.RichText
|
||||||
text: DPAdds.getAboutText("links")
|
text: dpAdds.getAboutText("links")
|
||||||
|
onLinkActivated: Qt.openUrlExternally(link);
|
||||||
}
|
}
|
||||||
|
|
||||||
QtControls.Label {
|
QtControls.Label {
|
||||||
|
QtLayouts.Layout.fillHeight: true
|
||||||
QtLayouts.Layout.fillWidth: true
|
QtLayouts.Layout.fillWidth: true
|
||||||
font.capitalization: Font.SmallCaps
|
font.capitalization: Font.SmallCaps
|
||||||
horizontalAlignment: Text.AlignHCenter
|
horizontalAlignment: Text.AlignHCenter
|
||||||
|
verticalAlignment: Text.AlignBottom
|
||||||
textFormat: Text.RichText
|
textFormat: Text.RichText
|
||||||
text: DPAdds.getAboutText("copy")
|
text: dpAdds.getAboutText("copy")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -79,14 +93,17 @@ Item {
|
|||||||
QtLayouts.Layout.fillWidth: true
|
QtLayouts.Layout.fillWidth: true
|
||||||
wrapMode: Text.WordWrap
|
wrapMode: Text.WordWrap
|
||||||
horizontalAlignment: Text.AlignJustify
|
horizontalAlignment: Text.AlignJustify
|
||||||
text: DPAdds.getAboutText("translators")
|
text: dpAdds.getAboutText("translators")
|
||||||
}
|
}
|
||||||
|
|
||||||
QtControls.Label {
|
QtControls.Label {
|
||||||
|
QtLayouts.Layout.fillHeight: true
|
||||||
QtLayouts.Layout.fillWidth: true
|
QtLayouts.Layout.fillWidth: true
|
||||||
horizontalAlignment: Text.AlignJustify
|
horizontalAlignment: Text.AlignJustify
|
||||||
|
verticalAlignment: Text.AlignTop
|
||||||
textFormat: Text.RichText
|
textFormat: Text.RichText
|
||||||
text: DPAdds.getAboutText("3rdparty")
|
text: dpAdds.getAboutText("3rdparty")
|
||||||
|
onLinkActivated: Qt.openUrlExternally(link);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -94,6 +111,6 @@ Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
if (debug) console.log("[about::onCompleted]")
|
if (debug) console.debug()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,17 +20,22 @@ import QtQuick.Controls 1.3 as QtControls
|
|||||||
import QtQuick.Controls.Styles 1.3 as QtStyles
|
import QtQuick.Controls.Styles 1.3 as QtStyles
|
||||||
import QtQuick.Dialogs 1.1 as QtDialogs
|
import QtQuick.Dialogs 1.1 as QtDialogs
|
||||||
|
|
||||||
import org.kde.plasma.desktoppanel 1.0
|
import org.kde.plasma.private.desktoppanel 1.0
|
||||||
|
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: activeAppearancePage
|
id: activeAppearancePage
|
||||||
|
// backend
|
||||||
|
DPAdds {
|
||||||
|
id: dpAdds;
|
||||||
|
}
|
||||||
|
|
||||||
width: childrenRect.width
|
width: childrenRect.width
|
||||||
height: childrenRect.height
|
height: childrenRect.height
|
||||||
implicitWidth: pageColumn.implicitWidth
|
implicitWidth: pageColumn.implicitWidth
|
||||||
implicitHeight: pageColumn.implicitHeight
|
implicitHeight: pageColumn.implicitHeight
|
||||||
|
|
||||||
property bool debug: DPAdds.isDebugEnabled()
|
property bool debug: dpAdds.isDebugEnabled()
|
||||||
property variant weight: {
|
property variant weight: {
|
||||||
25: 0,
|
25: 0,
|
||||||
50: 1,
|
50: 1,
|
||||||
@ -63,7 +68,11 @@ Item {
|
|||||||
id: selectFont
|
id: selectFont
|
||||||
width: parent.width * 2 / 3
|
width: parent.width * 2 / 3
|
||||||
text: plasmoid.configuration.currentFontFamily
|
text: plasmoid.configuration.currentFontFamily
|
||||||
onClicked: fontDialog.visible = true
|
onClicked: {
|
||||||
|
if (debug) console.debug()
|
||||||
|
fontDialog.setFont()
|
||||||
|
fontDialog.visible = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -125,8 +134,10 @@ Item {
|
|||||||
]
|
]
|
||||||
onCurrentIndexChanged: cfg_currentFontWeight = model[currentIndex]["name"]
|
onCurrentIndexChanged: cfg_currentFontWeight = model[currentIndex]["name"]
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
|
if (debug) console.debug()
|
||||||
for (var i = 0; i < model.length; i++) {
|
for (var i = 0; i < model.length; i++) {
|
||||||
if (model[i]["name"] == plasmoid.configuration.currentFontWeight) {
|
if (model[i]["name"] == plasmoid.configuration.currentFontWeight) {
|
||||||
|
if (debug) console.info("Found", model[i]["name"], "on", i)
|
||||||
fontWeight.currentIndex = i;
|
fontWeight.currentIndex = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -160,8 +171,10 @@ Item {
|
|||||||
]
|
]
|
||||||
onCurrentIndexChanged: cfg_currentFontStyle = model[currentIndex]["name"]
|
onCurrentIndexChanged: cfg_currentFontStyle = model[currentIndex]["name"]
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
|
if (debug) console.debug()
|
||||||
for (var i = 0; i < model.length; i++) {
|
for (var i = 0; i < model.length; i++) {
|
||||||
if (model[i]["name"] == plasmoid.configuration.currentFontStyle) {
|
if (model[i]["name"] == plasmoid.configuration.currentFontStyle) {
|
||||||
|
if (debug) console.info("Found", model[i]["name"], "on", i)
|
||||||
fontStyle.currentIndex = i;
|
fontStyle.currentIndex = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -203,16 +216,27 @@ Item {
|
|||||||
QtDialogs.FontDialog {
|
QtDialogs.FontDialog {
|
||||||
id: fontDialog
|
id: fontDialog
|
||||||
title: i18n("Select a font")
|
title: i18n("Select a font")
|
||||||
font: Qt.font({ family: selectFont.text, pointSize: fontSize.value, weight: Font.Normal })
|
signal setFont
|
||||||
|
|
||||||
onAccepted: {
|
onAccepted: {
|
||||||
|
if (debug) console.debug()
|
||||||
selectFont.text = fontDialog.font.family
|
selectFont.text = fontDialog.font.family
|
||||||
fontSize.value = fontDialog.font.pointSize
|
fontSize.value = fontDialog.font.pointSize
|
||||||
fontStyle.currentIndex = fontDialog.font.italic ? 1 : 0
|
fontStyle.currentIndex = fontDialog.font.italic ? 1 : 0
|
||||||
fontWeight.currentIndex = weight[fontDialog.font.weight]
|
fontWeight.currentIndex = weight[fontDialog.font.weight]
|
||||||
}
|
}
|
||||||
|
onSetFont: {
|
||||||
|
if (debug) console.debug()
|
||||||
|
fontDialog.font = Qt.font({
|
||||||
|
family: selectFont.text,
|
||||||
|
pointSize: fontSize.value > 0 ? fontSize.value : 12,
|
||||||
|
italic: fontStyle.currentIndex == 1,
|
||||||
|
weight: Font.Normal,
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
if (debug) console.log("[activeapp::onCompleted]")
|
if (debug) console.debug()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,17 +20,22 @@ import QtQuick.Controls 1.3 as QtControls
|
|||||||
import QtQuick.Controls.Styles 1.3 as QtStyles
|
import QtQuick.Controls.Styles 1.3 as QtStyles
|
||||||
import QtQuick.Dialogs 1.1 as QtDialogs
|
import QtQuick.Dialogs 1.1 as QtDialogs
|
||||||
|
|
||||||
import org.kde.plasma.desktoppanel 1.0
|
import org.kde.plasma.private.desktoppanel 1.0
|
||||||
|
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: advancedPage
|
id: advancedPage
|
||||||
|
// backend
|
||||||
|
DPAdds {
|
||||||
|
id: dpAdds;
|
||||||
|
}
|
||||||
|
|
||||||
width: childrenRect.width
|
width: childrenRect.width
|
||||||
height: childrenRect.height
|
height: childrenRect.height
|
||||||
implicitWidth: pageColumn.implicitWidth
|
implicitWidth: pageColumn.implicitWidth
|
||||||
implicitHeight: pageColumn.implicitHeight
|
implicitHeight: pageColumn.implicitHeight
|
||||||
|
|
||||||
property bool debug: DPAdds.isDebugEnabled()
|
property bool debug: dpAdds.isDebugEnabled()
|
||||||
|
|
||||||
property alias cfg_height: widgetHeight.value
|
property alias cfg_height: widgetHeight.value
|
||||||
property alias cfg_width: widgetWidth.value
|
property alias cfg_width: widgetWidth.value
|
||||||
@ -123,8 +128,10 @@ Item {
|
|||||||
]
|
]
|
||||||
onCurrentIndexChanged: cfg_tooltipType = model[currentIndex]["name"]
|
onCurrentIndexChanged: cfg_tooltipType = model[currentIndex]["name"]
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
|
if (debug) console.debug()
|
||||||
for (var i = 0; i < model.length; i++) {
|
for (var i = 0; i < model.length; i++) {
|
||||||
if (model[i]["name"] == plasmoid.configuration.tooltipType) {
|
if (model[i]["name"] == plasmoid.configuration.tooltipType) {
|
||||||
|
if (debug) console.info("Found", model[i]["name"], "on", i)
|
||||||
tooltipType.currentIndex = i;
|
tooltipType.currentIndex = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -223,23 +230,6 @@ Item {
|
|||||||
onCurrentIndexChanged: cfg_mark = currentText
|
onCurrentIndexChanged: cfg_mark = currentText
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Row {
|
|
||||||
// height: implicitHeight
|
|
||||||
// width: parent.width
|
|
||||||
// QtControls.Label {
|
|
||||||
// height: parent.height
|
|
||||||
// width: parent.width * 2 / 5
|
|
||||||
// horizontalAlignment: Text.AlignRight
|
|
||||||
// verticalAlignment: Text.AlignVCenter
|
|
||||||
// text: i18n("Panels to be hidden")
|
|
||||||
// }
|
|
||||||
// QtControls.Button {
|
|
||||||
// width: parent.width * 3 / 5
|
|
||||||
// text: i18n("Edit panels")
|
|
||||||
// onClicked: cfg_panels = DPAdds.editPanelsToContol(plasmoid.configuration.panels)
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QtDialogs.ColorDialog {
|
QtDialogs.ColorDialog {
|
||||||
@ -250,6 +240,6 @@ Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
if (debug) console.log("[advanced::onCompleted]")
|
if (debug) console.debug()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,17 +20,22 @@ import QtQuick.Controls 1.3 as QtControls
|
|||||||
import QtQuick.Controls.Styles 1.3 as QtStyles
|
import QtQuick.Controls.Styles 1.3 as QtStyles
|
||||||
import QtQuick.Dialogs 1.1 as QtDialogs
|
import QtQuick.Dialogs 1.1 as QtDialogs
|
||||||
|
|
||||||
import org.kde.plasma.desktoppanel 1.0
|
import org.kde.plasma.private.desktoppanel 1.0
|
||||||
|
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: inactiveAppearancePage
|
id: inactiveAppearancePage
|
||||||
|
// backend
|
||||||
|
DPAdds {
|
||||||
|
id: dpAdds;
|
||||||
|
}
|
||||||
|
|
||||||
width: childrenRect.width
|
width: childrenRect.width
|
||||||
height: childrenRect.height
|
height: childrenRect.height
|
||||||
implicitWidth: pageColumn.implicitWidth
|
implicitWidth: pageColumn.implicitWidth
|
||||||
implicitHeight: pageColumn.implicitHeight
|
implicitHeight: pageColumn.implicitHeight
|
||||||
|
|
||||||
property bool debug: AWKeys.isDebugEnabled()
|
property bool debug: dpAdds.isDebugEnabled()
|
||||||
property variant weight: {
|
property variant weight: {
|
||||||
25: 0,
|
25: 0,
|
||||||
50: 1,
|
50: 1,
|
||||||
@ -63,7 +68,11 @@ Item {
|
|||||||
id: selectFont
|
id: selectFont
|
||||||
width: parent.width * 2 / 3
|
width: parent.width * 2 / 3
|
||||||
text: plasmoid.configuration.fontFamily
|
text: plasmoid.configuration.fontFamily
|
||||||
onClicked: fontDialog.visible = true
|
onClicked: {
|
||||||
|
if (debug) console.debug()
|
||||||
|
fontDialog.setFont()
|
||||||
|
fontDialog.visible = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -125,8 +134,10 @@ Item {
|
|||||||
]
|
]
|
||||||
onCurrentIndexChanged: cfg_fontWeight = model[currentIndex]["name"]
|
onCurrentIndexChanged: cfg_fontWeight = model[currentIndex]["name"]
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
|
if (debug) console.debug()
|
||||||
for (var i = 0; i < model.length; i++) {
|
for (var i = 0; i < model.length; i++) {
|
||||||
if (model[i]["name"] == plasmoid.configuration.fontWeight) {
|
if (model[i]["name"] == plasmoid.configuration.fontWeight) {
|
||||||
|
if (debug) console.info("Found", model[i]["name"], "on", i)
|
||||||
fontWeight.currentIndex = i;
|
fontWeight.currentIndex = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -160,8 +171,10 @@ Item {
|
|||||||
]
|
]
|
||||||
onCurrentIndexChanged: cfg_fontStyle = model[currentIndex]["name"]
|
onCurrentIndexChanged: cfg_fontStyle = model[currentIndex]["name"]
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
|
if (debug) console.debug()
|
||||||
for (var i = 0; i < model.length; i++) {
|
for (var i = 0; i < model.length; i++) {
|
||||||
if (model[i]["name"] == plasmoid.configuration.fontStyle) {
|
if (model[i]["name"] == plasmoid.configuration.fontStyle) {
|
||||||
|
if (debug) console.info("Found", model[i]["name"], "on", i)
|
||||||
fontStyle.currentIndex = i;
|
fontStyle.currentIndex = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -203,16 +216,27 @@ Item {
|
|||||||
QtDialogs.FontDialog {
|
QtDialogs.FontDialog {
|
||||||
id: fontDialog
|
id: fontDialog
|
||||||
title: i18n("Select a font")
|
title: i18n("Select a font")
|
||||||
font: Qt.font({ family: selectFont.text, pointSize: fontSize.value, weight: Font.Normal })
|
signal setFont
|
||||||
|
|
||||||
onAccepted: {
|
onAccepted: {
|
||||||
|
if (debug) console.debug()
|
||||||
selectFont.text = fontDialog.font.family
|
selectFont.text = fontDialog.font.family
|
||||||
fontSize.value = fontDialog.font.pointSize
|
fontSize.value = fontDialog.font.pointSize
|
||||||
fontStyle.currentIndex = fontDialog.font.italic ? 1 : 0
|
fontStyle.currentIndex = fontDialog.font.italic ? 1 : 0
|
||||||
fontWeight.currentIndex = weight[fontDialog.font.weight]
|
fontWeight.currentIndex = weight[fontDialog.font.weight]
|
||||||
}
|
}
|
||||||
|
onSetFont: {
|
||||||
|
if (debug) console.debug()
|
||||||
|
fontDialog.font = Qt.font({
|
||||||
|
family: selectFont.text,
|
||||||
|
pointSize: fontSize.value > 0 ? fontSize.value : 12,
|
||||||
|
italic: fontStyle.currentIndex == 1,
|
||||||
|
weight: Font.Normal,
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
if (debug) console.log("[inactiveapp::onCompleted]")
|
if (debug) console.debug()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,14 +22,18 @@ import org.kde.plasma.plasmoid 2.0
|
|||||||
import org.kde.plasma.core 2.0 as PlasmaCore
|
import org.kde.plasma.core 2.0 as PlasmaCore
|
||||||
import org.kde.plasma.components 2.0 as PlasmaComponents
|
import org.kde.plasma.components 2.0 as PlasmaComponents
|
||||||
|
|
||||||
import org.kde.plasma.desktoppanel 1.0
|
import org.kde.plasma.private.desktoppanel 1.0
|
||||||
import "."
|
import "."
|
||||||
|
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: main
|
id: main
|
||||||
|
// backend
|
||||||
|
DPAdds {
|
||||||
|
id: dpAdds;
|
||||||
|
}
|
||||||
|
|
||||||
property bool debug: DPAdds.isDebugEnabled()
|
property bool debug: dpAdds.isDebugEnabled()
|
||||||
property variant tooltipSettings: {
|
property variant tooltipSettings: {
|
||||||
"tooltipColor": plasmoid.configuration.tooltipColor,
|
"tooltipColor": plasmoid.configuration.tooltipColor,
|
||||||
"tooltipType": plasmoid.configuration.tooltipType,
|
"tooltipType": plasmoid.configuration.tooltipType,
|
||||||
@ -54,31 +58,32 @@ Item {
|
|||||||
// ui
|
// ui
|
||||||
GridLayout {
|
GridLayout {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
columns: plasmoid.configuration.verticalLayout ? 1 : DPAdds.numberOfDesktops()
|
columns: plasmoid.configuration.verticalLayout ? 1 : dpAdds.numberOfDesktops()
|
||||||
rows: plasmoid.configuration.verticalLayout ? DPAdds.numberOfDesktops() : 1
|
rows: plasmoid.configuration.verticalLayout ? dpAdds.numberOfDesktops() : 1
|
||||||
|
|
||||||
Repeater {
|
Repeater {
|
||||||
id: repeater
|
id: repeater
|
||||||
Layout.columnSpan: 0
|
Layout.columnSpan: 0
|
||||||
Layout.rowSpan: 0
|
Layout.rowSpan: 0
|
||||||
model: DPAdds.numberOfDesktops()
|
model: dpAdds.numberOfDesktops()
|
||||||
|
|
||||||
Text {
|
Text {
|
||||||
id: text
|
id: text
|
||||||
height: contentHeight
|
height: contentHeight
|
||||||
width: contentWidth
|
width: contentWidth
|
||||||
|
renderType: Text.NativeRendering
|
||||||
textFormat: Text.RichText
|
textFormat: Text.RichText
|
||||||
wrapMode: Text.NoWrap
|
wrapMode: Text.NoWrap
|
||||||
|
|
||||||
verticalAlignment: Text.AlignVCenter
|
verticalAlignment: Text.AlignVCenter
|
||||||
|
|
||||||
text: DPAdds.parsePattern(plasmoid.configuration.text, index + 1)
|
text: dpAdds.parsePattern(plasmoid.configuration.text, index + 1)
|
||||||
property alias tooltip: tooltip
|
property alias tooltip: tooltip
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
onClicked: DPAdds.setCurrentDesktop(index + 1);
|
onClicked: dpAdds.setCurrentDesktop(index + 1);
|
||||||
onEntered: needTooltipUpdate()
|
onEntered: needTooltipUpdate()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,16 +108,16 @@ Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onNeedUpdate: {
|
onNeedUpdate: {
|
||||||
if (debug) console.log("[main::onNeedUpdate]")
|
if (debug) console.debug()
|
||||||
|
|
||||||
for (var i=0; i<repeater.count; i++) {
|
for (var i=0; i<repeater.count; i++) {
|
||||||
if (!repeater.itemAt(i)) {
|
if (!repeater.itemAt(i)) {
|
||||||
if (debug) console.log("[main::onNeedUpdate] : Nothing to do here " + i)
|
if (debug) console.info("Nothing to do here", i)
|
||||||
timer.start()
|
timer.start()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
repeater.itemAt(i).text = DPAdds.parsePattern(plasmoid.configuration.text, i + 1)
|
repeater.itemAt(i).text = dpAdds.parsePattern(plasmoid.configuration.text, i + 1)
|
||||||
if (DPAdds.currentDesktop() == i + 1) {
|
if (dpAdds.currentDesktop() == i + 1) {
|
||||||
repeater.itemAt(i).color = plasmoid.configuration.currentFontColor
|
repeater.itemAt(i).color = plasmoid.configuration.currentFontColor
|
||||||
repeater.itemAt(i).font.family = plasmoid.configuration.currentFontFamily
|
repeater.itemAt(i).font.family = plasmoid.configuration.currentFontFamily
|
||||||
repeater.itemAt(i).font.italic = plasmoid.configuration.currentFontStyle == "italic" ? true : false
|
repeater.itemAt(i).font.italic = plasmoid.configuration.currentFontStyle == "italic" ? true : false
|
||||||
@ -133,15 +138,15 @@ Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onNeedTooltipUpdate: {
|
onNeedTooltipUpdate: {
|
||||||
if (debug) console.log("[main::onNeedTooltipUpdate]")
|
if (debug) console.debug()
|
||||||
|
|
||||||
for (var i=0; i<repeater.count; i++) {
|
for (var i=0; i<repeater.count; i++) {
|
||||||
repeater.itemAt(i).tooltip.text = DPAdds.toolTipImage(i + 1)
|
repeater.itemAt(i).tooltip.text = dpAdds.toolTipImage(i + 1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onSizeUpdate: {
|
onSizeUpdate: {
|
||||||
if (debug) console.log("[main::onSizeUpdate]")
|
if (debug) console.debug()
|
||||||
|
|
||||||
if (plasmoid.configuration.height == 0) {
|
if (plasmoid.configuration.height == 0) {
|
||||||
var newHeight = 0
|
var newHeight = 0
|
||||||
@ -165,29 +170,22 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Plasmoid.onActivated: {
|
|
||||||
if (debug) console.log("[main::onActivated]")
|
|
||||||
|
|
||||||
// DPAdds.changePanelsState()
|
|
||||||
}
|
|
||||||
|
|
||||||
Plasmoid.onUserConfiguringChanged: {
|
Plasmoid.onUserConfiguringChanged: {
|
||||||
if (plasmoid.userConfiguring) return
|
if (plasmoid.userConfiguring) return
|
||||||
if (debug) console.log("[main::onUserConfiguringChanged]")
|
if (debug) console.debug()
|
||||||
|
|
||||||
DPAdds.setMark(plasmoid.configuration.mark)
|
dpAdds.setMark(plasmoid.configuration.mark)
|
||||||
DPAdds.setPanelsToControl(plasmoid.configuration.panels)
|
dpAdds.setToolTipData(tooltipSettings)
|
||||||
DPAdds.setToolTipData(tooltipSettings)
|
|
||||||
|
|
||||||
needUpdate()
|
needUpdate()
|
||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
if (debug) console.log("[main::onCompleted]")
|
if (debug) console.debug()
|
||||||
|
|
||||||
// init submodule
|
// init submodule
|
||||||
Plasmoid.userConfiguringChanged(false)
|
Plasmoid.userConfiguringChanged(false)
|
||||||
DPAdds.desktopChanged.connect(needUpdate)
|
dpAdds.desktopChanged.connect(needUpdate)
|
||||||
DPAdds.windowListChanged.connect(needTooltipUpdate)
|
dpAdds.windowListChanged.connect(needTooltipUpdate)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1 +1 @@
|
|||||||
singleton general general.qml
|
singleton general 1.0 general.qml
|
||||||
|
@ -18,17 +18,22 @@
|
|||||||
import QtQuick 2.0
|
import QtQuick 2.0
|
||||||
import QtQuick.Controls 1.3 as QtControls
|
import QtQuick.Controls 1.3 as QtControls
|
||||||
|
|
||||||
import org.kde.plasma.desktoppanel 1.0
|
import org.kde.plasma.private.desktoppanel 1.0
|
||||||
|
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: widgetPage
|
id: widgetPage
|
||||||
|
// backend
|
||||||
|
DPAdds {
|
||||||
|
id: dpAdds;
|
||||||
|
}
|
||||||
|
|
||||||
width: childrenRect.width
|
width: childrenRect.width
|
||||||
height: childrenRect.height
|
height: childrenRect.height
|
||||||
implicitWidth: pageColumn.implicitWidth
|
implicitWidth: pageColumn.implicitWidth
|
||||||
implicitHeight: pageColumn.implicitHeight
|
implicitHeight: pageColumn.implicitHeight
|
||||||
|
|
||||||
property bool debug: DPAdds.isDebugEnabled()
|
property bool debug: dpAdds.isDebugEnabled()
|
||||||
|
|
||||||
property alias cfg_text: textPattern.text
|
property alias cfg_text: textPattern.text
|
||||||
|
|
||||||
@ -42,24 +47,25 @@ Item {
|
|||||||
verticalAlignment: Text.AlignVCenter
|
verticalAlignment: Text.AlignVCenter
|
||||||
wrapMode: Text.WordWrap
|
wrapMode: Text.WordWrap
|
||||||
text: i18n("Detailed information may be found on <a href=\"http://arcanis.name/projects/awesome-widgets/\">project homepage</a>")
|
text: i18n("Detailed information may be found on <a href=\"http://arcanis.name/projects/awesome-widgets/\">project homepage</a>")
|
||||||
|
onLinkActivated: Qt.openUrlExternally(link);
|
||||||
}
|
}
|
||||||
|
|
||||||
Row {
|
Row {
|
||||||
height: implicitHeight
|
height: implicitHeight
|
||||||
width: parent.width
|
width: parent.width
|
||||||
QtControls.Button {
|
QtControls.Button {
|
||||||
|
width: parent.width * 3 / 12
|
||||||
text: i18n("Font")
|
text: i18n("Font")
|
||||||
iconName: "font"
|
iconName: "font"
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (debug) console.log("[widget::onClicked] : Font button")
|
if (debug) console.debug("Font button")
|
||||||
|
|
||||||
var defaultFont = {
|
var defaultFont = {
|
||||||
"color": plasmoid.configuration.fontColor,
|
"color": plasmoid.configuration.fontColor,
|
||||||
"family": plasmoid.configuration.fontFamily,
|
"family": plasmoid.configuration.fontFamily,
|
||||||
"size": plasmoid.configuration.fontSize
|
"size": plasmoid.configuration.fontSize
|
||||||
}
|
}
|
||||||
var font = DPAdds.getFont(defaultFont)
|
var font = dpAdds.getFont(defaultFont)
|
||||||
var pos = textPattern.cursorPosition
|
var pos = textPattern.cursorPosition
|
||||||
var selected = textPattern.selectedText
|
var selected = textPattern.selectedText
|
||||||
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
||||||
@ -70,11 +76,11 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
QtControls.Button {
|
QtControls.Button {
|
||||||
|
width: parent.width / 12
|
||||||
iconName: "format-indent-more"
|
iconName: "format-indent-more"
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (debug) console.log("[widget::onClicked] : Indent button")
|
if (debug) console.debug("Indent button")
|
||||||
|
|
||||||
var pos = textPattern.cursorPosition
|
var pos = textPattern.cursorPosition
|
||||||
var selected = textPattern.selectedText
|
var selected = textPattern.selectedText
|
||||||
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
||||||
@ -83,11 +89,11 @@ Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
QtControls.Button {
|
QtControls.Button {
|
||||||
|
width: parent.width / 12
|
||||||
iconName: "format-text-bold"
|
iconName: "format-text-bold"
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (debug) console.log("[widget::onClicked] : Bold button")
|
if (debug) console.debug("Bold button")
|
||||||
|
|
||||||
var pos = textPattern.cursorPosition
|
var pos = textPattern.cursorPosition
|
||||||
var selected = textPattern.selectedText
|
var selected = textPattern.selectedText
|
||||||
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
||||||
@ -95,11 +101,11 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
QtControls.Button {
|
QtControls.Button {
|
||||||
|
width: parent.width / 12
|
||||||
iconName: "format-text-italic"
|
iconName: "format-text-italic"
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (debug) console.log("[widget::onClicked] : Italic button")
|
if (debug) console.debug("Italic button")
|
||||||
|
|
||||||
var pos = textPattern.cursorPosition
|
var pos = textPattern.cursorPosition
|
||||||
var selected = textPattern.selectedText
|
var selected = textPattern.selectedText
|
||||||
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
||||||
@ -107,11 +113,11 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
QtControls.Button {
|
QtControls.Button {
|
||||||
|
width: parent.width / 12
|
||||||
iconName: "format-text-underline"
|
iconName: "format-text-underline"
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (debug) console.log("[widget::onClicked] : Underline button")
|
if (debug) console.debug("Underline button")
|
||||||
|
|
||||||
var pos = textPattern.cursorPosition
|
var pos = textPattern.cursorPosition
|
||||||
var selected = textPattern.selectedText
|
var selected = textPattern.selectedText
|
||||||
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
||||||
@ -119,11 +125,11 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
QtControls.Button {
|
QtControls.Button {
|
||||||
|
width: parent.width / 12
|
||||||
iconName: "format-text-strikethrough"
|
iconName: "format-text-strikethrough"
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (debug) console.log("[widget::onClicked] : Strike button")
|
if (debug) console.debug("Strike button")
|
||||||
|
|
||||||
var pos = textPattern.cursorPosition
|
var pos = textPattern.cursorPosition
|
||||||
var selected = textPattern.selectedText
|
var selected = textPattern.selectedText
|
||||||
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
||||||
@ -132,11 +138,11 @@ Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
QtControls.Button {
|
QtControls.Button {
|
||||||
|
width: parent.width / 12
|
||||||
iconName: "format-justify-left"
|
iconName: "format-justify-left"
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (debug) console.log("[widget::onClicked] : Left button")
|
if (debug) console.debug("Left button")
|
||||||
|
|
||||||
var pos = textPattern.cursorPosition
|
var pos = textPattern.cursorPosition
|
||||||
var selected = textPattern.selectedText
|
var selected = textPattern.selectedText
|
||||||
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
||||||
@ -144,11 +150,11 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
QtControls.Button {
|
QtControls.Button {
|
||||||
|
width: parent.width / 12
|
||||||
iconName: "format-justify-center"
|
iconName: "format-justify-center"
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (debug) console.log("[widget::onClicked] : Center button")
|
if (debug) console.debug("Center button")
|
||||||
|
|
||||||
var pos = textPattern.cursorPosition
|
var pos = textPattern.cursorPosition
|
||||||
var selected = textPattern.selectedText
|
var selected = textPattern.selectedText
|
||||||
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
||||||
@ -156,11 +162,11 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
QtControls.Button {
|
QtControls.Button {
|
||||||
|
width: parent.width / 12
|
||||||
iconName: "format-justify-right"
|
iconName: "format-justify-right"
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (debug) console.log("[widget::onClicked] : Right button")
|
if (debug) console.debug("Right button")
|
||||||
|
|
||||||
var pos = textPattern.cursorPosition
|
var pos = textPattern.cursorPosition
|
||||||
var selected = textPattern.selectedText
|
var selected = textPattern.selectedText
|
||||||
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
||||||
@ -168,11 +174,11 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
QtControls.Button {
|
QtControls.Button {
|
||||||
|
width: parent.width / 12
|
||||||
iconName: "format-justify-fill"
|
iconName: "format-justify-fill"
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (debug) console.log("[widget::onClicked] : Justify button")
|
if (debug) console.debug("Justify button")
|
||||||
|
|
||||||
var pos = textPattern.cursorPosition
|
var pos = textPattern.cursorPosition
|
||||||
var selected = textPattern.selectedText
|
var selected = textPattern.selectedText
|
||||||
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
||||||
@ -187,15 +193,14 @@ Item {
|
|||||||
QtControls.ComboBox {
|
QtControls.ComboBox {
|
||||||
id: tags
|
id: tags
|
||||||
width: parent.width - addTagButton.width - showValueButton.width
|
width: parent.width - addTagButton.width - showValueButton.width
|
||||||
model: DPAdds.dictKeys()
|
model: dpAdds.dictKeys()
|
||||||
}
|
}
|
||||||
QtControls.Button {
|
QtControls.Button {
|
||||||
id: addTagButton
|
id: addTagButton
|
||||||
text: i18n("Add")
|
text: i18n("Add")
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (debug) console.log("[widget::onClicked] : Add tag button")
|
if (debug) console.debug("Add tag button")
|
||||||
|
|
||||||
var pos = textPattern.cursorPosition
|
var pos = textPattern.cursorPosition
|
||||||
var selected = textPattern.selectedText
|
var selected = textPattern.selectedText
|
||||||
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
||||||
@ -207,12 +212,11 @@ Item {
|
|||||||
text: i18n("Show value")
|
text: i18n("Show value")
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (debug) console.log("[widget::onClicked] : Show tag button")
|
if (debug) console.debug("Show tag button")
|
||||||
|
|
||||||
var message = i18n("Tag: %1", tags.currentText)
|
var message = i18n("Tag: %1", tags.currentText)
|
||||||
message += "<br>"
|
message += "<br>"
|
||||||
message += i18n("Value: %1", DPAdds.valueByKey(tags.currentText))
|
message += i18n("Value: %1", dpAdds.valueByKey(tags.currentText))
|
||||||
DPAdds.sendNotification("tag", message)
|
dpAdds.sendNotification("tag", message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -228,6 +232,6 @@ Item {
|
|||||||
|
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
if (debug) console.log("[widget::onCompleted]")
|
if (debug) console.debug()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ X-Plasma-RemoteLocation=
|
|||||||
X-KDE-PluginInfo-Author=Evgeniy Alekseev aka arcanis
|
X-KDE-PluginInfo-Author=Evgeniy Alekseev aka arcanis
|
||||||
X-KDE-PluginInfo-Email=esalexeev@gmail.com
|
X-KDE-PluginInfo-Email=esalexeev@gmail.com
|
||||||
X-KDE-PluginInfo-Name=org.kde.plasma.desktoppanel
|
X-KDE-PluginInfo-Name=org.kde.plasma.desktoppanel
|
||||||
X-KDE-PluginInfo-Version=2.2.2
|
X-KDE-PluginInfo-Version=2.4.0
|
||||||
X-KDE-PluginInfo-Website=http://arcanis.name/projects/awesome-widgets/
|
X-KDE-PluginInfo-Website=http://arcanis.name/projects/awesome-widgets/
|
||||||
X-KDE-PluginInfo-Category=System Information
|
X-KDE-PluginInfo-Category=System Information
|
||||||
X-KDE-PluginInfo-Depends=
|
X-KDE-PluginInfo-Depends=
|
||||||
|