add images feature to extweather (apiver == 2)
@ -26,11 +26,14 @@
|
||||
#endif /* LOG_FORMAT */
|
||||
|
||||
// define info log level
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
|
||||
#ifndef qCInfo
|
||||
// #if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
|
||||
// #ifndef qCInfo
|
||||
// redefine info because it doesn't log properly
|
||||
#ifdef qCInfo
|
||||
#undef qCInfo
|
||||
#define qCInfo qCDebug
|
||||
#endif /* qCInfo */
|
||||
#endif /* QT_VERSION */
|
||||
// #endif /* QT_VERSION */
|
||||
|
||||
|
||||
Q_DECLARE_LOGGING_CATEGORY(LOG_AW)
|
||||
|
@ -46,10 +46,6 @@ AWKeys::AWKeys(QObject *parent)
|
||||
qCDebug(LOG_AW);
|
||||
|
||||
// logging
|
||||
// disable info because QtMsgType has invalid enum order
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 5, 0)
|
||||
const_cast<QLoggingCategory &>(LOG_AW()).setEnabled(QtMsgType::QtInfoMsg, false);
|
||||
#endif /* QT_VERSION */
|
||||
qSetMessagePattern(LOG_FORMAT);
|
||||
|
||||
// backend
|
||||
@ -172,6 +168,16 @@ QStringList AWKeys::dictKeys(const bool sorted, const QString regexp) const
|
||||
qCDebug(LOG_AW) << "Filter" << regexp;
|
||||
|
||||
QStringList allKeys;
|
||||
// weather
|
||||
for (int i=extWeather->items().count()-1; i>=0; i--) {
|
||||
if (!extWeather->items().at(i)->isActive()) continue;
|
||||
allKeys.append(extWeather->items().at(i)->tag(QString("weatherId")));
|
||||
allKeys.append(extWeather->items().at(i)->tag(QString("weather")));
|
||||
allKeys.append(extWeather->items().at(i)->tag(QString("humidity")));
|
||||
allKeys.append(extWeather->items().at(i)->tag(QString("pressure")));
|
||||
allKeys.append(extWeather->items().at(i)->tag(QString("temperature")));
|
||||
allKeys.append(extWeather->items().at(i)->tag(QString("timestamp")));
|
||||
}
|
||||
// time
|
||||
allKeys.append(QString("time"));
|
||||
allKeys.append(QString("isotime"));
|
||||
@ -297,16 +303,6 @@ QStringList AWKeys::dictKeys(const bool sorted, const QString regexp) const
|
||||
allKeys.append(QString("la15"));
|
||||
allKeys.append(QString("la5"));
|
||||
allKeys.append(QString("la1"));
|
||||
// weather
|
||||
for (int i=extWeather->items().count()-1; i>=0; i--) {
|
||||
if (!extWeather->items().at(i)->isActive()) continue;
|
||||
allKeys.append(extWeather->items().at(i)->tag(QString("weatherId")));
|
||||
allKeys.append(extWeather->items().at(i)->tag(QString("weather")));
|
||||
allKeys.append(extWeather->items().at(i)->tag(QString("humidity")));
|
||||
allKeys.append(extWeather->items().at(i)->tag(QString("pressure")));
|
||||
allKeys.append(extWeather->items().at(i)->tag(QString("temperature")));
|
||||
allKeys.append(extWeather->items().at(i)->tag(QString("timestamp")));
|
||||
}
|
||||
// bars
|
||||
QStringList graphicalItemsKeys;
|
||||
foreach(GraphicalItem *item, graphicalItems->items())
|
||||
@ -905,7 +901,8 @@ QString AWKeys::parsePattern() const
|
||||
// main keys
|
||||
foreach(QString key, foundKeys)
|
||||
parsed.replace(QString("$%1").arg(key), [](QString key, QString value) {
|
||||
if (!key.startsWith(QString("custom")))
|
||||
if ((!key.startsWith(QString("custom"))) &&
|
||||
(!key.startsWith(QString("weather"))))
|
||||
value.replace(QString(" "), QString(" "));
|
||||
return value;
|
||||
}(key, values[key]));
|
||||
|
@ -20,6 +20,11 @@ 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})
|
||||
@ -33,3 +38,4 @@ install(DIRECTORY ${SUBPROJECT_QUOTES} DESTINATION ${DATA_INSTALL_DIR}/${PROJECT
|
||||
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)
|
||||
|
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"
|
||||
}
|
||||
}
|
@ -40,10 +40,6 @@ public:
|
||||
qCDebug(LOG_LIB);
|
||||
qCDebug(LOG_LIB) << "Type" << type;
|
||||
|
||||
// disable info because QtMsgType has invalid enum order
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 5, 0)
|
||||
const_cast<QLoggingCategory &>(LOG_LIB()).setEnabled(QtMsgType::QtInfoMsg, false);
|
||||
#endif /* QT_VERSION */
|
||||
qSetMessagePattern(LOG_FORMAT);
|
||||
|
||||
initItems();
|
||||
|
@ -288,7 +288,7 @@ void ExtScript::readJsonFilters()
|
||||
|
||||
QString fileName = QStandardPaths::locate(QStandardPaths::GenericDataLocation,
|
||||
QString("awesomewidgets/scripts/awesomewidgets-extscripts-filters.json"));
|
||||
qCInfo(LOG_LIB) << "Configuration file" << fileName;
|
||||
qCInfo(LOG_LIB) << "Filters file" << fileName;
|
||||
QFile jsonFile(fileName);
|
||||
if (!jsonFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
qCWarning(LOG_LIB) << "Could not open" << fileName;
|
||||
@ -305,7 +305,7 @@ void ExtScript::readJsonFilters()
|
||||
}
|
||||
jsonFilters = jsonDoc.toVariant().toMap();
|
||||
|
||||
qCDebug(LOG_LIB) << "Filters" << jsonFilters;
|
||||
qCInfo(LOG_LIB) << "Filters" << jsonFilters;
|
||||
}
|
||||
|
||||
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QNetworkRequest>
|
||||
#include <QSettings>
|
||||
#include <QStandardPaths>
|
||||
|
||||
#include <qreplytimeout/qreplytimeout.h>
|
||||
|
||||
@ -41,6 +42,7 @@ ExtWeather::ExtWeather(QWidget *parent, const QString weatherName,
|
||||
qCDebug(LOG_LIB);
|
||||
|
||||
readConfiguration();
|
||||
readJsonMap();
|
||||
ui->setupUi(this);
|
||||
translate();
|
||||
|
||||
@ -81,6 +83,7 @@ ExtWeather *ExtWeather::copy(const QString _fileName, const int _number)
|
||||
item->setComment(comment());
|
||||
item->setCountry(country());
|
||||
item->setInterval(interval());
|
||||
item->setImage(image());
|
||||
item->setName(name());
|
||||
item->setNumber(_number);
|
||||
item->setTs(ts());
|
||||
@ -92,100 +95,10 @@ ExtWeather *ExtWeather::copy(const QString _fileName, const int _number)
|
||||
QString ExtWeather::weatherFromInt(const int _id) const
|
||||
{
|
||||
qCDebug(LOG_LIB);
|
||||
qCDebug(LOG_LIB) << "ID" << _id;
|
||||
// refer to http://openweathermap.org/weather-conditions
|
||||
qCDebug(LOG_LIB) << "Weather ID" << _id;
|
||||
|
||||
QString weather;
|
||||
switch (_id) {
|
||||
case 800:
|
||||
// 01d
|
||||
weather = QString("\u2600");
|
||||
break;
|
||||
case 801:
|
||||
// 02d
|
||||
weather = QString("\u26C5");
|
||||
break;
|
||||
case 802:
|
||||
case 803:
|
||||
// 03d
|
||||
weather = QString("\u2601");
|
||||
break;
|
||||
case 804:
|
||||
// 04d
|
||||
weather = QString("\u2601");
|
||||
break;
|
||||
case 300:
|
||||
case 301:
|
||||
case 302:
|
||||
case 310:
|
||||
case 311:
|
||||
case 312:
|
||||
case 313:
|
||||
case 314:
|
||||
case 321:
|
||||
case 520:
|
||||
case 521:
|
||||
case 522:
|
||||
case 531:
|
||||
// 09d
|
||||
weather = QString("\u2602");
|
||||
break;
|
||||
case 500:
|
||||
case 501:
|
||||
case 502:
|
||||
case 503:
|
||||
case 504:
|
||||
// 10d
|
||||
weather = QString("\u2614");
|
||||
break;
|
||||
case 200:
|
||||
case 201:
|
||||
case 202:
|
||||
case 210:
|
||||
case 211:
|
||||
case 212:
|
||||
case 221:
|
||||
case 230:
|
||||
case 231:
|
||||
case 232:
|
||||
// 11d
|
||||
weather = QString("\u2608");
|
||||
break;
|
||||
case 511:
|
||||
case 600:
|
||||
case 601:
|
||||
case 602:
|
||||
case 611:
|
||||
case 612:
|
||||
case 615:
|
||||
case 616:
|
||||
case 620:
|
||||
case 621:
|
||||
case 622:
|
||||
// 13d
|
||||
weather = QString("\u2603");
|
||||
// weather = QString("\u26C4");
|
||||
break;
|
||||
case 701:
|
||||
case 711:
|
||||
case 721:
|
||||
case 731:
|
||||
case 741:
|
||||
case 751:
|
||||
case 761:
|
||||
case 762:
|
||||
case 771:
|
||||
case 781:
|
||||
// 50d
|
||||
weather = QString("\u26C5");
|
||||
break;
|
||||
default:
|
||||
// extreme other conditions
|
||||
weather = QString("\u2604");
|
||||
break;
|
||||
}
|
||||
|
||||
return weather;
|
||||
QVariantMap map = jsonMap[m_image ? QString("image") : QString("text")].toMap();
|
||||
return map.value(QString::number(_id), map[QString("default")]).toString();
|
||||
}
|
||||
|
||||
|
||||
@ -205,6 +118,14 @@ QString ExtWeather::country() const
|
||||
}
|
||||
|
||||
|
||||
bool ExtWeather::image() const
|
||||
{
|
||||
qCDebug(LOG_LIB);
|
||||
|
||||
return m_image;
|
||||
}
|
||||
|
||||
|
||||
int ExtWeather::ts() const
|
||||
{
|
||||
qCDebug(LOG_LIB);
|
||||
@ -239,6 +160,15 @@ void ExtWeather::setCountry(const QString _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);
|
||||
@ -261,6 +191,8 @@ void ExtWeather::readConfiguration()
|
||||
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();
|
||||
}
|
||||
|
||||
@ -273,6 +205,33 @@ void ExtWeather::readConfiguration()
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
@ -304,6 +263,7 @@ int ExtWeather::showConfiguration(const QVariant args)
|
||||
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());
|
||||
|
||||
@ -316,6 +276,7 @@ int ExtWeather::showConfiguration(const QVariant args)
|
||||
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());
|
||||
|
||||
@ -335,6 +296,7 @@ void ExtWeather::writeConfiguration() const
|
||||
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();
|
||||
|
||||
@ -413,6 +375,7 @@ void ExtWeather::translate()
|
||||
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"));
|
||||
}
|
||||
|
@ -36,6 +36,7 @@ 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:
|
||||
@ -47,15 +48,18 @@ public:
|
||||
// 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;
|
||||
@ -73,7 +77,9 @@ private:
|
||||
// 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;
|
||||
|
@ -148,6 +148,36 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_image">
|
||||
<item>
|
||||
<spacer name="spacer_image">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_image">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Use images</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_active">
|
||||
<item>
|
||||
|
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 |
@ -3,9 +3,10 @@ Comment=London current weather
|
||||
Encoding=UTF-8
|
||||
Name=London current
|
||||
X-AW-Active=false
|
||||
X-AW-ApiVersion=1
|
||||
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
|
||||
|
@ -43,9 +43,6 @@ DPAdds::DPAdds(QObject *parent)
|
||||
qCDebug(LOG_DP);
|
||||
|
||||
// logging
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 5, 0)
|
||||
const_cast<QLoggingCategory &>(LOG_DP()).setEnabled(QtMsgType::QtInfoMsg, false);
|
||||
#endif /* QT_VERSION */
|
||||
qSetMessagePattern(LOG_FORMAT);
|
||||
|
||||
connect(KWindowSystem::self(), SIGNAL(currentDesktopChanged(int)), this, SIGNAL(desktopChanged()));
|
||||
|
@ -49,9 +49,6 @@ ExtendedSysMon::ExtendedSysMon(QObject *parent, const QVariantList &args)
|
||||
qCDebug(LOG_ESM);
|
||||
|
||||
// logging
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 5, 0)
|
||||
const_cast<QLoggingCategory &>(LOG_ESM()).setEnabled(QtMsgType::QtInfoMsg, false);
|
||||
#endif /* QT_VERSION */
|
||||
qSetMessagePattern(LOG_FORMAT);
|
||||
|
||||
setMinimumPollingInterval(333);
|
||||
|
@ -8,7 +8,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: https://github.com/arcan1s/awesome-widgets/issues\n"
|
||||
"POT-Creation-Date: 2015-08-24 23:21+0300\n"
|
||||
"POT-Creation-Date: 2015-08-30 16:30+0300\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
@ -463,6 +463,9 @@ msgstr ""
|
||||
msgid "Timestamp"
|
||||
msgstr ""
|
||||
|
||||
msgid "Use images"
|
||||
msgstr ""
|
||||
|
||||
msgid "Value"
|
||||
msgstr ""
|
||||
|
||||
|
@ -6,8 +6,8 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: https://github.com/arcan1s/awesome-widgets/issues\n"
|
||||
"POT-Creation-Date: 2015-08-24 23:21+0300\n"
|
||||
"PO-Revision-Date: 2015-08-24 23:21+0300\n"
|
||||
"POT-Creation-Date: 2015-08-30 16:30+0300\n"
|
||||
"PO-Revision-Date: 2015-08-30 16:30+0300\n"
|
||||
"Last-Translator: Evgeniy Alekseev <esalexeev@gmail.com>\n"
|
||||
"Language-Team: English <kde-russian@lists.kde.ru>\n"
|
||||
"Language: ru\n"
|
||||
@ -472,6 +472,9 @@ msgstr "Country"
|
||||
msgid "Timestamp"
|
||||
msgstr "Timestamp"
|
||||
|
||||
msgid "Use images"
|
||||
msgstr "Use images"
|
||||
|
||||
msgid "Value"
|
||||
msgstr "Value"
|
||||
|
||||
|
@ -7,7 +7,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: https://github.com/arcan1s/awesome-widgets/issues\n"
|
||||
"POT-Creation-Date: 2015-08-24 23:21+0300\n"
|
||||
"POT-Creation-Date: 2015-08-30 16:30+0300\n"
|
||||
"PO-Revision-Date: 2015-07-31 22:13+0300\n"
|
||||
"Last-Translator: Evgeniy Alekseev <esalexeev@gmail.com>\n"
|
||||
"Language-Team: Spanish <kde-russian@lists.kde.ru>\n"
|
||||
@ -483,6 +483,9 @@ msgstr ""
|
||||
msgid "Timestamp"
|
||||
msgstr "Hora"
|
||||
|
||||
msgid "Use images"
|
||||
msgstr ""
|
||||
|
||||
msgid "Value"
|
||||
msgstr "Valor"
|
||||
|
||||
|
@ -7,7 +7,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: https://github.com/arcan1s/awesome-widgets/issues\n"
|
||||
"POT-Creation-Date: 2015-08-24 23:21+0300\n"
|
||||
"POT-Creation-Date: 2015-08-30 16:30+0300\n"
|
||||
"PO-Revision-Date: 2015-07-31 22:16+0300\n"
|
||||
"Last-Translator: Evgeniy Alekseev <esalexeev@gmail.com>\n"
|
||||
"Language-Team: French <kde-russian@lists.kde.ru>\n"
|
||||
@ -489,6 +489,9 @@ msgstr ""
|
||||
msgid "Timestamp"
|
||||
msgstr "Durée"
|
||||
|
||||
msgid "Use images"
|
||||
msgstr ""
|
||||
|
||||
#, fuzzy
|
||||
msgid "Value"
|
||||
msgstr "Valeur: %1"
|
||||
|
@ -8,7 +8,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Awesome widgets\n"
|
||||
"Report-Msgid-Bugs-To: https://github.com/arcan1s/awesome-widgets/issues\n"
|
||||
"POT-Creation-Date: 2015-08-24 23:21+0300\n"
|
||||
"POT-Creation-Date: 2015-08-30 16:30+0300\n"
|
||||
"PO-Revision-Date: 2015-08-20 22:52+0300\n"
|
||||
"Last-Translator: Evgeniy Alekseev <esalexeev@gmail.com>\n"
|
||||
"Language-Team: Dutch <kde-i18n-nl@kde.org>\n"
|
||||
@ -486,6 +486,9 @@ msgstr ""
|
||||
msgid "Timestamp"
|
||||
msgstr ""
|
||||
|
||||
msgid "Use images"
|
||||
msgstr ""
|
||||
|
||||
msgid "Value"
|
||||
msgstr "Waarde"
|
||||
|
||||
|
@ -6,7 +6,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: https://github.com/arcan1s/awesome-widgets/issues\n"
|
||||
"POT-Creation-Date: 2015-08-24 23:21+0300\n"
|
||||
"POT-Creation-Date: 2015-08-30 16:30+0300\n"
|
||||
"PO-Revision-Date: 2015-07-31 22:21+0300\n"
|
||||
"Last-Translator: Evgeniy Alekseev <esalexeev@gmail.com>\n"
|
||||
"Language-Team: Russian <kde-russian@lists.kde.ru>\n"
|
||||
@ -477,6 +477,9 @@ msgstr ""
|
||||
msgid "Timestamp"
|
||||
msgstr "Hora"
|
||||
|
||||
msgid "Use images"
|
||||
msgstr ""
|
||||
|
||||
msgid "Value"
|
||||
msgstr "Valor"
|
||||
|
||||
|
@ -6,8 +6,8 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: https://github.com/arcan1s/awesome-widgets/issues\n"
|
||||
"POT-Creation-Date: 2015-08-24 23:21+0300\n"
|
||||
"PO-Revision-Date: 2015-08-24 23:22+0300\n"
|
||||
"POT-Creation-Date: 2015-08-30 16:30+0300\n"
|
||||
"PO-Revision-Date: 2015-08-30 16:31+0300\n"
|
||||
"Last-Translator: Evgeniy Alekseev <esalexeev@gmail.com>\n"
|
||||
"Language-Team: Russian <kde-russian@lists.kde.ru>\n"
|
||||
"Language: ru\n"
|
||||
@ -473,6 +473,9 @@ msgstr "Страна"
|
||||
msgid "Timestamp"
|
||||
msgstr "Таймштамп"
|
||||
|
||||
msgid "Use images"
|
||||
msgstr "Использовать изображения"
|
||||
|
||||
msgid "Value"
|
||||
msgstr "Значение"
|
||||
|
||||
|
@ -6,7 +6,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: https://github.com/arcan1s/awesome-widgets/issues\n"
|
||||
"POT-Creation-Date: 2015-08-24 23:21+0300\n"
|
||||
"POT-Creation-Date: 2015-08-30 16:30+0300\n"
|
||||
"PO-Revision-Date: 2015-07-31 22:23+0300\n"
|
||||
"Last-Translator: Evgeniy Alekseev <esalexeev@gmail.com>\n"
|
||||
"Language-Team: Ukrainian <kde-russian@lists.kde.ru>\n"
|
||||
@ -483,6 +483,9 @@ msgstr ""
|
||||
msgid "Timestamp"
|
||||
msgstr "Час"
|
||||
|
||||
msgid "Use images"
|
||||
msgstr ""
|
||||
|
||||
msgid "Value"
|
||||
msgstr "Значення"
|
||||
|
||||
|
@ -7,7 +7,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: https://github.com/arcan1s/awesome-widgets/issues\n"
|
||||
"POT-Creation-Date: 2015-08-24 23:21+0300\n"
|
||||
"POT-Creation-Date: 2015-08-30 16:30+0300\n"
|
||||
"PO-Revision-Date: 2015-07-31 22:24+0300\n"
|
||||
"Last-Translator: Evgeniy Alekseev <esalexeev@gmail.com>\n"
|
||||
"Language-Team: Russian <kde-russian@lists.kde.ru>\n"
|
||||
@ -484,6 +484,9 @@ msgstr ""
|
||||
msgid "Timestamp"
|
||||
msgstr ""
|
||||
|
||||
msgid "Use images"
|
||||
msgstr ""
|
||||
|
||||
msgid "Value"
|
||||
msgstr ""
|
||||
|
||||
|
@ -20,7 +20,7 @@
|
||||
// extupgrade api version
|
||||
#define AWEUAPI 3
|
||||
// extweather api version
|
||||
#define AWEWAPI 1
|
||||
#define AWEWAPI 2
|
||||
// available time keys
|
||||
#define TIME_KEYS "dddd,ddd,dd,d,MMMM,MMM,MM,M,yyyy,yy,hh,h,HH,H,mm,m,ss,s,t,ap,a,AP,A"
|
||||
|
||||
|