mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-04-24 15:37:23 +00:00
refactor: refresh shared library
This commit is contained in:
parent
332d78eb25
commit
54acc5f780
@ -41,18 +41,17 @@ QString AWDebug::getAboutText(const QString &_type)
|
|||||||
} else if (_type == "description") {
|
} else if (_type == "description") {
|
||||||
text = i18n("A set of minimalistic plasmoid widgets");
|
text = i18n("A set of minimalistic plasmoid widgets");
|
||||||
} else if (_type == "links") {
|
} else if (_type == "links") {
|
||||||
text = i18n("Links:") + "<ul>" + QString("<li><a href=\"%1\">%2</a></li>").arg(HOMEPAGE).arg(i18n("Homepage"))
|
text = i18n("Links:") + "<ul>" + QString("<li><a href=\"%1\">%2</a></li>").arg(HOMEPAGE, i18n("Homepage"))
|
||||||
+ QString("<li><a href=\"%1\">%2</a></li>").arg(REPOSITORY).arg(i18n("Repository"))
|
+ QString("<li><a href=\"%1\">%2</a></li>").arg(REPOSITORY, i18n("Repository"))
|
||||||
+ QString("<li><a href=\"%1\">%2</a></li>").arg(BUGTRACKER).arg(i18n("Bugtracker"))
|
+ QString("<li><a href=\"%1\">%2</a></li>").arg(BUGTRACKER, i18n("Bugtracker"))
|
||||||
+ QString("<li><a href=\"%1\">%2</a></li>").arg(TRANSLATION).arg(i18n("Translation issue"))
|
+ QString("<li><a href=\"%1\">%2</a></li>").arg(TRANSLATION, i18n("Translation issue"))
|
||||||
+ QString("<li><a href=\"%1\">%2</a></li>").arg(AUR_PACKAGES).arg(i18n("AUR packages"))
|
+ QString("<li><a href=\"%1\">%2</a></li>").arg(AUR_PACKAGES, i18n("AUR packages"))
|
||||||
+ QString("<li><a href=\"%1\">%2</a></li>").arg(OPENSUSE_PACKAGES).arg(i18n("openSUSE packages"))
|
+ QString("<li><a href=\"%1\">%2</a></li>").arg(OPENSUSE_PACKAGES, i18n("openSUSE packages")) + "</ul>";
|
||||||
+ "</ul>";
|
|
||||||
} else if (_type == "copy") {
|
} else if (_type == "copy") {
|
||||||
text = QString("<small>© %1 <a href=\"mailto:%2\">%3</a><br>").arg(DATE).arg(EMAIL).arg(AUTHOR)
|
text = QString("<small>© %1 <a href=\"mailto:%2\">%3</a><br>").arg(DATE, EMAIL, AUTHOR)
|
||||||
+ i18nc("This software is licensed under %1", LICENSE) + "</small>";
|
+ i18n("This software is licensed under %1", LICENSE) + "</small>";
|
||||||
} else if (_type == "translators") {
|
} else if (_type == "translators") {
|
||||||
QStringList translatorList = QString(TRANSLATORS).split(',');
|
auto translatorList = QString(TRANSLATORS).split(',');
|
||||||
for (auto &translator : translatorList)
|
for (auto &translator : translatorList)
|
||||||
translator = QString("<li>%1</li>").arg(translator);
|
translator = QString("<li>%1</li>").arg(translator);
|
||||||
text = i18n("Translators:") + "<ul>" + translatorList.join("") + "</ul>";
|
text = i18n("Translators:") + "<ul>" + translatorList.join("") + "</ul>";
|
||||||
@ -60,16 +59,14 @@ QString AWDebug::getAboutText(const QString &_type)
|
|||||||
QStringList trdPartyList = QString(TRDPARTY_LICENSE).split(';', Qt::SkipEmptyParts);
|
QStringList trdPartyList = QString(TRDPARTY_LICENSE).split(';', Qt::SkipEmptyParts);
|
||||||
for (int i = 0; i < trdPartyList.count(); i++)
|
for (int i = 0; i < trdPartyList.count(); i++)
|
||||||
trdPartyList[i] = QString("<li><a href=\"%3\">%1</a> (%2 license)</li>")
|
trdPartyList[i] = QString("<li><a href=\"%3\">%1</a> (%2 license)</li>")
|
||||||
.arg(trdPartyList.at(i).split(',')[0])
|
.arg(trdPartyList.at(i).split(',')[0], trdPartyList.at(i).split(',')[1],
|
||||||
.arg(trdPartyList.at(i).split(',')[1])
|
trdPartyList.at(i).split(',')[2]);
|
||||||
.arg(trdPartyList.at(i).split(',')[2]);
|
|
||||||
text = i18n("This software uses:") + "<ul>" + trdPartyList.join("") + "</ul>";
|
text = i18n("This software uses:") + "<ul>" + trdPartyList.join("") + "</ul>";
|
||||||
} else if (_type == "thanks") {
|
} else if (_type == "thanks") {
|
||||||
QStringList thanks = QString(SPECIAL_THANKS).split(';', Qt::SkipEmptyParts);
|
QStringList thanks = QString(SPECIAL_THANKS).split(';', Qt::SkipEmptyParts);
|
||||||
for (int i = 0; i < thanks.count(); i++)
|
for (int i = 0; i < thanks.count(); i++)
|
||||||
thanks[i] = QString("<li><a href=\"%2\">%1</a></li>")
|
thanks[i]
|
||||||
.arg(thanks.at(i).split(',')[0])
|
= QString("<li><a href=\"%2\">%1</a></li>").arg(thanks.at(i).split(',')[0], thanks.at(i).split(',')[1]);
|
||||||
.arg(thanks.at(i).split(',')[1]);
|
|
||||||
text = i18n("Special thanks to:") + "<ul>" + thanks.join("") + "</ul>";
|
text = i18n("Special thanks to:") + "<ul>" + thanks.join("") + "</ul>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,6 +121,6 @@ void AWActions::sendNotification(const QString &_eventId, const QString &_messag
|
|||||||
{
|
{
|
||||||
qCDebug(LOG_AW) << "Event" << _eventId << "with message" << _message;
|
qCDebug(LOG_AW) << "Event" << _eventId << "with message" << _message;
|
||||||
|
|
||||||
auto *event = KNotification::event(_eventId, QString("Awesome Widget ::: %1").arg(_eventId), _message);
|
auto event = KNotification::event(_eventId, QString("Awesome Widget ::: %1").arg(_eventId), _message);
|
||||||
event->setComponentName("plasma-applet-org.kde.plasma.awesome-widget");
|
event->setComponentName("plasma-applet-org.kde.plasma.awesome-widget");
|
||||||
}
|
}
|
||||||
|
@ -84,8 +84,7 @@ bool AWConfigHelper::exportConfiguration(QObject *_nativeConfig, const QString &
|
|||||||
|
|
||||||
// extensions
|
// extensions
|
||||||
for (auto &item : m_dirs) {
|
for (auto &item : m_dirs) {
|
||||||
QStringList items
|
QStringList items = QDir(QString("%1/%2").arg(m_baseDir, item)).entryList({"*.desktop"}, QDir::Files);
|
||||||
= QDir(QString("%1/%2").arg(m_baseDir, item)).entryList({"*.desktop"}, QDir::Files);
|
|
||||||
settings.beginGroup(item);
|
settings.beginGroup(item);
|
||||||
for (auto &it : items)
|
for (auto &it : items)
|
||||||
copyExtensions(it, item, settings, false);
|
copyExtensions(it, item, settings, false);
|
||||||
|
@ -161,7 +161,7 @@ void AWFormatterHelper::initFormatters()
|
|||||||
// check if already exists
|
// check if already exists
|
||||||
auto values = m_formattersClasses.values();
|
auto values = m_formattersClasses.values();
|
||||||
if (std::any_of(values.cbegin(), values.cend(),
|
if (std::any_of(values.cbegin(), values.cend(),
|
||||||
[&filePath](const AWAbstractFormatter *item) { return (item->fileName() == filePath); }))
|
[&filePath](const AWAbstractFormatter *item) { return (item->filePath() == filePath); }))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
auto metadata = readMetadata(filePath);
|
auto metadata = readMetadata(filePath);
|
||||||
|
@ -80,7 +80,7 @@ QStringList AWKeyOperations::dictKeys() const
|
|||||||
{
|
{
|
||||||
QStringList allKeys;
|
QStringList allKeys;
|
||||||
// weather
|
// weather
|
||||||
for (auto &item : m_extWeather->activeItems()) {
|
for (auto item : m_extWeather->activeItems()) {
|
||||||
allKeys.append(item->tag("weatherId"));
|
allKeys.append(item->tag("weatherId"));
|
||||||
allKeys.append(item->tag("weather"));
|
allKeys.append(item->tag("weather"));
|
||||||
allKeys.append(item->tag("humidity"));
|
allKeys.append(item->tag("humidity"));
|
||||||
@ -140,10 +140,10 @@ QStringList AWKeyOperations::dictKeys() const
|
|||||||
allKeys.append(QString("battotal%1").arg(i));
|
allKeys.append(QString("battotal%1").arg(i));
|
||||||
}
|
}
|
||||||
// package manager
|
// package manager
|
||||||
for (auto &item : m_extUpgrade->activeItems())
|
for (auto item : m_extUpgrade->activeItems())
|
||||||
allKeys.append(item->tag("pkgcount"));
|
allKeys.append(item->tag("pkgcount"));
|
||||||
// quotes
|
// quotes
|
||||||
for (auto &item : m_extQuotes->activeItems()) {
|
for (auto item : m_extQuotes->activeItems()) {
|
||||||
allKeys.append(item->tag("price"));
|
allKeys.append(item->tag("price"));
|
||||||
allKeys.append(item->tag("pricechg"));
|
allKeys.append(item->tag("pricechg"));
|
||||||
allKeys.append(item->tag("percpricechg"));
|
allKeys.append(item->tag("percpricechg"));
|
||||||
@ -152,13 +152,13 @@ QStringList AWKeyOperations::dictKeys() const
|
|||||||
allKeys.append(item->tag("percvolumechg"));
|
allKeys.append(item->tag("percvolumechg"));
|
||||||
}
|
}
|
||||||
// custom
|
// custom
|
||||||
for (auto &item : m_extScripts->activeItems())
|
for (auto item : m_extScripts->activeItems())
|
||||||
allKeys.append(item->tag("custom"));
|
allKeys.append(item->tag("custom"));
|
||||||
// network requests
|
// network requests
|
||||||
for (auto &item : m_extNetRequest->activeItems())
|
for (auto item : m_extNetRequest->activeItems())
|
||||||
allKeys.append(item->tag("response"));
|
allKeys.append(item->tag("response"));
|
||||||
// bars
|
// bars
|
||||||
for (auto &item : m_graphicalItems->activeItems())
|
for (auto item : m_graphicalItems->activeItems())
|
||||||
allKeys.append(item->tag("bar"));
|
allKeys.append(item->tag("bar"));
|
||||||
// user defined keys
|
// user defined keys
|
||||||
allKeys.append(m_customKeys->keys());
|
allKeys.append(m_customKeys->keys());
|
||||||
|
@ -71,7 +71,7 @@ bool AWUpdateHelper::checkVersion()
|
|||||||
qCInfo(LOG_AW) << "Found version" << version << "actual one is" << m_foundVersion;
|
qCInfo(LOG_AW) << "Found version" << version << "actual one is" << m_foundVersion;
|
||||||
|
|
||||||
if ((version != m_foundVersion) && (!QString(CHANGELOG).isEmpty())) {
|
if ((version != m_foundVersion) && (!QString(CHANGELOG).isEmpty())) {
|
||||||
sendNotification(i18nc("Changelog of %1", VERSION), QString(CHANGELOG).replace('@', '\n'));
|
sendNotification(i18n("Changelog of %1", VERSION), QString(CHANGELOG).replace('@', '\n'));
|
||||||
return true;
|
return true;
|
||||||
} else if (version != m_foundVersion) {
|
} else if (version != m_foundVersion) {
|
||||||
qCWarning(LOG_AW) << "No changelog information provided";
|
qCWarning(LOG_AW) << "No changelog information provided";
|
||||||
@ -106,7 +106,7 @@ void AWUpdateHelper::showUpdates(const QVersionNumber &_version)
|
|||||||
qCDebug(LOG_AW) << "Version" << _version;
|
qCDebug(LOG_AW) << "Version" << _version;
|
||||||
|
|
||||||
QString text;
|
QString text;
|
||||||
text += i18nc("Current version : %1", VERSION);
|
text += i18n("Current version : %1", VERSION);
|
||||||
text += QString(COMMIT_SHA).isEmpty() ? "\n" : QString(" (%1)\n").arg(QString(COMMIT_SHA));
|
text += QString(COMMIT_SHA).isEmpty() ? "\n" : QString(" (%1)\n").arg(QString(COMMIT_SHA));
|
||||||
text += i18n("New version : %1", _version.toString()) + "\n\n";
|
text += i18n("New version : %1", _version.toString()) + "\n\n";
|
||||||
text += i18n("Click \"Ok\" to download");
|
text += i18n("Click \"Ok\" to download");
|
||||||
|
@ -29,13 +29,13 @@
|
|||||||
|
|
||||||
AbstractExtItem::AbstractExtItem(QObject *_parent, const QString &_filePath)
|
AbstractExtItem::AbstractExtItem(QObject *_parent, const QString &_filePath)
|
||||||
: QObject(_parent)
|
: QObject(_parent)
|
||||||
, m_fileName(_filePath)
|
, m_filePath(_filePath)
|
||||||
{
|
{
|
||||||
qCDebug(LOG_LIB) << __PRETTY_FUNCTION__;
|
qCDebug(LOG_LIB) << __PRETTY_FUNCTION__;
|
||||||
|
|
||||||
qCDebug(LOG_LIB) << "Desktop name" << _filePath;
|
qCDebug(LOG_LIB) << "Desktop name" << _filePath;
|
||||||
|
|
||||||
m_name = m_fileName;
|
m_name = m_filePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -95,10 +95,11 @@ void AbstractExtItem::startTimer()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString AbstractExtItem::writtableConfig() const
|
QString AbstractExtItem::writableConfig() const
|
||||||
{
|
{
|
||||||
auto path = m_fileName;
|
auto path = m_filePath;
|
||||||
auto name = QFileInfo(path).fileName();
|
auto name = fileName();
|
||||||
|
// extract subdirectory
|
||||||
path.remove(path.length() - name.length() - 1, name.length() + 1);
|
path.remove(path.length() - name.length() - 1, name.length() + 1);
|
||||||
auto dir = QFileInfo(path).fileName();
|
auto dir = QFileInfo(path).fileName();
|
||||||
|
|
||||||
@ -127,7 +128,13 @@ QString AbstractExtItem::cron() const
|
|||||||
|
|
||||||
QString AbstractExtItem::fileName() const
|
QString AbstractExtItem::fileName() const
|
||||||
{
|
{
|
||||||
return m_fileName;
|
return QFileInfo(filePath()).fileName();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString AbstractExtItem::filePath() const
|
||||||
|
{
|
||||||
|
return m_filePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -267,7 +274,7 @@ void AbstractExtItem::deinitSocket()
|
|||||||
|
|
||||||
m_socket->close();
|
m_socket->close();
|
||||||
QLocalServer::removeServer(socket());
|
QLocalServer::removeServer(socket());
|
||||||
disconnect(m_socket, &QLocalServer::newConnection, this, &AbstractExtItem::newConnectionReceived);
|
disconnect(m_socket, &QLocalServer::newConnection, this, &AbstractExtItem::requestDataUpdate);
|
||||||
delete m_socket;
|
delete m_socket;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -280,13 +287,13 @@ void AbstractExtItem::initSocket()
|
|||||||
m_socket = new QLocalServer(this);
|
m_socket = new QLocalServer(this);
|
||||||
auto listening = m_socket->listen(socket());
|
auto listening = m_socket->listen(socket());
|
||||||
qCInfo(LOG_LIB) << "Server listening on" << socket() << listening;
|
qCInfo(LOG_LIB) << "Server listening on" << socket() << listening;
|
||||||
connect(m_socket, &QLocalServer::newConnection, this, &AbstractExtItem::newConnectionReceived);
|
connect(m_socket, &QLocalServer::newConnection, this, &AbstractExtItem::requestDataUpdate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void AbstractExtItem::readConfiguration()
|
void AbstractExtItem::readConfiguration()
|
||||||
{
|
{
|
||||||
QSettings settings(m_fileName, QSettings::IniFormat);
|
QSettings settings(m_filePath, QSettings::IniFormat);
|
||||||
|
|
||||||
settings.beginGroup("Desktop Entry");
|
settings.beginGroup("Desktop Entry");
|
||||||
setName(settings.value("Name", name()).toString());
|
setName(settings.value("Name", name()).toString());
|
||||||
@ -303,8 +310,8 @@ void AbstractExtItem::readConfiguration()
|
|||||||
|
|
||||||
bool AbstractExtItem::tryDelete() const
|
bool AbstractExtItem::tryDelete() const
|
||||||
{
|
{
|
||||||
auto status = QFile::remove(m_fileName);
|
auto status = QFile::remove(m_filePath);
|
||||||
qCInfo(LOG_LIB) << "Remove file" << m_fileName << status;
|
qCInfo(LOG_LIB) << "Remove file" << m_filePath << status;
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
@ -312,7 +319,7 @@ bool AbstractExtItem::tryDelete() const
|
|||||||
|
|
||||||
void AbstractExtItem::writeConfiguration() const
|
void AbstractExtItem::writeConfiguration() const
|
||||||
{
|
{
|
||||||
QSettings settings(writtableConfig(), QSettings::IniFormat);
|
QSettings settings(writableConfig(), QSettings::IniFormat);
|
||||||
qCInfo(LOG_LIB) << "Configuration file" << settings.fileName();
|
qCInfo(LOG_LIB) << "Configuration file" << settings.fileName();
|
||||||
|
|
||||||
settings.beginGroup("Desktop Entry");
|
settings.beginGroup("Desktop Entry");
|
||||||
@ -329,9 +336,3 @@ void AbstractExtItem::writeConfiguration() const
|
|||||||
|
|
||||||
settings.sync();
|
settings.sync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void AbstractExtItem::newConnectionReceived()
|
|
||||||
{
|
|
||||||
emit(requestDataUpdate());
|
|
||||||
}
|
|
||||||
|
@ -32,6 +32,7 @@ class AbstractExtItem : public QObject
|
|||||||
Q_PROPERTY(QString comment READ comment WRITE setComment)
|
Q_PROPERTY(QString comment READ comment WRITE setComment)
|
||||||
Q_PROPERTY(QString cron READ cron WRITE setCron)
|
Q_PROPERTY(QString cron READ cron WRITE setCron)
|
||||||
Q_PROPERTY(QString fileName READ fileName)
|
Q_PROPERTY(QString fileName READ fileName)
|
||||||
|
Q_PROPERTY(QString filePath READ filePath)
|
||||||
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(QString name READ name WRITE setName)
|
||||||
Q_PROPERTY(int number READ number WRITE setNumber)
|
Q_PROPERTY(int number READ number WRITE setNumber)
|
||||||
@ -45,12 +46,13 @@ public:
|
|||||||
virtual AbstractExtItem *copy(const QString &_fileName, int _number) = 0;
|
virtual AbstractExtItem *copy(const QString &_fileName, int _number) = 0;
|
||||||
virtual void copyDefaults(AbstractExtItem *_other) const;
|
virtual void copyDefaults(AbstractExtItem *_other) const;
|
||||||
virtual void startTimer();
|
virtual void startTimer();
|
||||||
[[nodiscard]] QString writtableConfig() const;
|
[[nodiscard]] QString writableConfig() const;
|
||||||
// get methods
|
// get methods
|
||||||
[[nodiscard]] int apiVersion() const;
|
[[nodiscard]] int apiVersion() const;
|
||||||
[[nodiscard]] QString comment() const;
|
[[nodiscard]] QString comment() const;
|
||||||
[[nodiscard]] QString cron() const;
|
[[nodiscard]] QString cron() const;
|
||||||
[[nodiscard]] QString fileName() const;
|
[[nodiscard]] QString fileName() const;
|
||||||
|
[[nodiscard]] QString filePath() const;
|
||||||
[[nodiscard]] int interval() const;
|
[[nodiscard]] int interval() const;
|
||||||
[[nodiscard]] bool isActive() const;
|
[[nodiscard]] bool isActive() const;
|
||||||
[[nodiscard]] QString name() const;
|
[[nodiscard]] QString name() const;
|
||||||
@ -81,12 +83,9 @@ public slots:
|
|||||||
[[nodiscard]] virtual bool tryDelete() const;
|
[[nodiscard]] virtual bool tryDelete() const;
|
||||||
virtual void writeConfiguration() const;
|
virtual void writeConfiguration() const;
|
||||||
|
|
||||||
private slots:
|
|
||||||
void newConnectionReceived();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QCronScheduler *m_scheduler = nullptr;
|
QCronScheduler *m_scheduler = nullptr;
|
||||||
QString m_fileName = "/dev/null";
|
QString m_filePath = "";
|
||||||
int m_times = 0;
|
int m_times = 0;
|
||||||
// FIXME find a better way to do it
|
// FIXME find a better way to do it
|
||||||
virtual void translate(void *_ui) = 0;
|
virtual void translate(void *_ui) = 0;
|
||||||
|
@ -35,8 +35,7 @@ AbstractExtItemAggregator::AbstractExtItemAggregator(QObject *_parent, QString _
|
|||||||
// create directory at $HOME
|
// create directory at $HOME
|
||||||
auto localDir = QString("%1/awesomewidgets/%2")
|
auto localDir = QString("%1/awesomewidgets/%2")
|
||||||
.arg(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation), type());
|
.arg(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation), type());
|
||||||
QDir localDirectory;
|
if (QDir().mkpath(localDir))
|
||||||
if (localDirectory.mkpath(localDir))
|
|
||||||
qCInfo(LOG_LIB) << "Created directory" << localDir;
|
qCInfo(LOG_LIB) << "Created directory" << localDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,18 +101,13 @@ int AbstractExtItemAggregator::exec()
|
|||||||
auto createButton = ui->buttonBox->addButton(i18n("Create"), QDialogButtonBox::ActionRole);
|
auto createButton = ui->buttonBox->addButton(i18n("Create"), QDialogButtonBox::ActionRole);
|
||||||
auto deleteButton = ui->buttonBox->addButton(i18n("Remove"), QDialogButtonBox::ActionRole);
|
auto deleteButton = ui->buttonBox->addButton(i18n("Remove"), QDialogButtonBox::ActionRole);
|
||||||
|
|
||||||
connect(ui->buttonBox, &QDialogButtonBox::clicked, [&](QAbstractButton *_button) {
|
connect(copyButton, &QPushButton::clicked, [this, ui]() { copyItem(ui->listWidget); });
|
||||||
if (dynamic_cast<QPushButton *>(_button) == copyButton)
|
connect(createButton, &QPushButton::clicked, [this, ui]() { doCreateItem(ui->listWidget); });
|
||||||
copyItem(ui->listWidget);
|
connect(deleteButton, &QPushButton::clicked, [this, ui]() { deleteItem(ui->listWidget); });
|
||||||
else if (dynamic_cast<QPushButton *>(_button) == createButton)
|
connect(ui->buttonBox, &QDialogButtonBox::accepted, [this, ui]() { editItem(ui->listWidget); });
|
||||||
doCreateItem(ui->listWidget);
|
|
||||||
else if (dynamic_cast<QPushButton *>(_button) == deleteButton)
|
|
||||||
deleteItem(ui->listWidget);
|
|
||||||
else if (ui->buttonBox->buttonRole(_button) == QDialogButtonBox::AcceptRole)
|
|
||||||
editItem(ui->listWidget);
|
|
||||||
});
|
|
||||||
connect(ui->buttonBox, &QDialogButtonBox::rejected, [dialog]() { dialog->reject(); });
|
connect(ui->buttonBox, &QDialogButtonBox::rejected, [dialog]() { dialog->reject(); });
|
||||||
connect(ui->listWidget, &QListWidget::itemActivated, [&](QListWidgetItem *) { editItem(ui->listWidget); });
|
connect(ui->listWidget, &QListWidget::itemActivated, [this, ui](QListWidgetItem *) { editItem(ui->listWidget); });
|
||||||
|
|
||||||
repaintList(ui->listWidget);
|
repaintList(ui->listWidget);
|
||||||
auto ret = dialog->exec();
|
auto ret = dialog->exec();
|
||||||
@ -145,8 +139,8 @@ AbstractExtItem *AbstractExtItemAggregator::itemFromWidget(QListWidget *_widget)
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
AbstractExtItem *found = nullptr;
|
AbstractExtItem *found = nullptr;
|
||||||
for (auto &item : items()) {
|
for (auto item : items()) {
|
||||||
auto fileName = QFileInfo(item->fileName()).fileName();
|
auto fileName = item->fileName();
|
||||||
if (fileName != widgetItem->text())
|
if (fileName != widgetItem->text())
|
||||||
continue;
|
continue;
|
||||||
found = item;
|
found = item;
|
||||||
@ -162,8 +156,8 @@ AbstractExtItem *AbstractExtItemAggregator::itemFromWidget(QListWidget *_widget)
|
|||||||
void AbstractExtItemAggregator::repaintList(QListWidget *_widget) const
|
void AbstractExtItemAggregator::repaintList(QListWidget *_widget) const
|
||||||
{
|
{
|
||||||
_widget->clear();
|
_widget->clear();
|
||||||
for (auto &_item : items()) {
|
for (auto _item : items()) {
|
||||||
QString fileName = QFileInfo(_item->fileName()).fileName();
|
QString fileName = _item->fileName();
|
||||||
auto item = new QListWidgetItem(fileName, _widget);
|
auto item = new QListWidgetItem(fileName, _widget);
|
||||||
QStringList tooltip;
|
QStringList tooltip;
|
||||||
tooltip.append(i18n("Name: %1", _item->name()));
|
tooltip.append(i18n("Name: %1", _item->name()));
|
||||||
@ -178,9 +172,10 @@ void AbstractExtItemAggregator::repaintList(QListWidget *_widget) const
|
|||||||
int AbstractExtItemAggregator::uniqNumber() const
|
int AbstractExtItemAggregator::uniqNumber() const
|
||||||
{
|
{
|
||||||
QList<int> tagList;
|
QList<int> tagList;
|
||||||
for (auto &item : items())
|
for (auto item : items())
|
||||||
tagList.append(item->number());
|
tagList.append(item->number());
|
||||||
int number = 0;
|
|
||||||
|
auto number = 0;
|
||||||
while (tagList.contains(number))
|
while (tagList.contains(number))
|
||||||
number++;
|
number++;
|
||||||
|
|
||||||
@ -196,10 +191,8 @@ QVariant AbstractExtItemAggregator::configArgs() const
|
|||||||
|
|
||||||
QStringList AbstractExtItemAggregator::directories() const
|
QStringList AbstractExtItemAggregator::directories() const
|
||||||
{
|
{
|
||||||
auto dirs = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QString("awesomewidgets/%1").arg(type()),
|
return QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QString("awesomewidgets/%1").arg(type()),
|
||||||
QStandardPaths::LocateDirectory);
|
QStandardPaths::LocateDirectory);
|
||||||
|
|
||||||
return dirs;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -23,7 +23,6 @@
|
|||||||
#include "awdebug.h"
|
#include "awdebug.h"
|
||||||
|
|
||||||
|
|
||||||
class QAbstractButton;
|
|
||||||
class QListWidget;
|
class QListWidget;
|
||||||
class QListWidgetItem;
|
class QListWidgetItem;
|
||||||
|
|
||||||
@ -59,7 +58,7 @@ public:
|
|||||||
void deleteItem(QListWidget *_widget);
|
void deleteItem(QListWidget *_widget);
|
||||||
void editItem(QListWidget *_widget);
|
void editItem(QListWidget *_widget);
|
||||||
[[nodiscard]] int exec();
|
[[nodiscard]] int exec();
|
||||||
QString getName();
|
[[nodiscard]] static QString getName();
|
||||||
virtual void initItems() = 0;
|
virtual void initItems() = 0;
|
||||||
[[nodiscard]] AbstractExtItem *itemFromWidget(QListWidget *_widget) const;
|
[[nodiscard]] AbstractExtItem *itemFromWidget(QListWidget *_widget) const;
|
||||||
void repaintList(QListWidget *_widget) const;
|
void repaintList(QListWidget *_widget) const;
|
||||||
|
@ -113,7 +113,7 @@ void AWAbstractFormatter::readConfiguration()
|
|||||||
{
|
{
|
||||||
AbstractExtItem::readConfiguration();
|
AbstractExtItem::readConfiguration();
|
||||||
|
|
||||||
QSettings settings(fileName(), QSettings::IniFormat);
|
QSettings settings(filePath(), QSettings::IniFormat);
|
||||||
|
|
||||||
settings.beginGroup("Desktop Entry");
|
settings.beginGroup("Desktop Entry");
|
||||||
setStrType(settings.value("X-AW-Type", strType()).toString());
|
setStrType(settings.value("X-AW-Type", strType()).toString());
|
||||||
@ -125,7 +125,7 @@ void AWAbstractFormatter::writeConfiguration() const
|
|||||||
{
|
{
|
||||||
AbstractExtItem::writeConfiguration();
|
AbstractExtItem::writeConfiguration();
|
||||||
|
|
||||||
QSettings settings(writtableConfig(), QSettings::IniFormat);
|
QSettings settings(writableConfig(), QSettings::IniFormat);
|
||||||
qCInfo(LOG_LIB) << "Configuration file" << settings.fileName();
|
qCInfo(LOG_LIB) << "Configuration file" << settings.fileName();
|
||||||
|
|
||||||
settings.beginGroup("Desktop Entry");
|
settings.beginGroup("Desktop Entry");
|
||||||
|
@ -50,6 +50,7 @@ AWDateTimeFormatter *AWDateTimeFormatter::copy(const QString &_fileName, const i
|
|||||||
|
|
||||||
auto item = new AWDateTimeFormatter(parent(), _fileName);
|
auto item = new AWDateTimeFormatter(parent(), _fileName);
|
||||||
AWAbstractFormatter::copyDefaults(item);
|
AWAbstractFormatter::copyDefaults(item);
|
||||||
|
|
||||||
item->setFormat(format());
|
item->setFormat(format());
|
||||||
item->setTranslateString(translateString());
|
item->setTranslateString(translateString());
|
||||||
item->setNumber(_number);
|
item->setNumber(_number);
|
||||||
@ -91,7 +92,7 @@ void AWDateTimeFormatter::readConfiguration()
|
|||||||
{
|
{
|
||||||
AWAbstractFormatter::readConfiguration();
|
AWAbstractFormatter::readConfiguration();
|
||||||
|
|
||||||
QSettings settings(fileName(), QSettings::IniFormat);
|
QSettings settings(filePath(), QSettings::IniFormat);
|
||||||
|
|
||||||
settings.beginGroup("Desktop Entry");
|
settings.beginGroup("Desktop Entry");
|
||||||
setFormat(settings.value("X-AW-Format", format()).toString());
|
setFormat(settings.value("X-AW-Format", format()).toString());
|
||||||
@ -140,7 +141,7 @@ void AWDateTimeFormatter::writeConfiguration() const
|
|||||||
{
|
{
|
||||||
AWAbstractFormatter::writeConfiguration();
|
AWAbstractFormatter::writeConfiguration();
|
||||||
|
|
||||||
QSettings settings(writtableConfig(), QSettings::IniFormat);
|
QSettings settings(writableConfig(), QSettings::IniFormat);
|
||||||
qCInfo(LOG_LIB) << "Configuration file" << settings.fileName();
|
qCInfo(LOG_LIB) << "Configuration file" << settings.fileName();
|
||||||
|
|
||||||
settings.beginGroup("Desktop Entry");
|
settings.beginGroup("Desktop Entry");
|
||||||
|
@ -54,6 +54,7 @@ AWFloatFormatter *AWFloatFormatter::copy(const QString &_fileName, const int _nu
|
|||||||
|
|
||||||
auto item = new AWFloatFormatter(parent(), _fileName);
|
auto item = new AWFloatFormatter(parent(), _fileName);
|
||||||
AWAbstractFormatter::copyDefaults(item);
|
AWAbstractFormatter::copyDefaults(item);
|
||||||
|
|
||||||
item->setCount(count());
|
item->setCount(count());
|
||||||
item->setFormat(format());
|
item->setFormat(format());
|
||||||
item->setFillChar(fillChar());
|
item->setFillChar(fillChar());
|
||||||
@ -174,7 +175,7 @@ void AWFloatFormatter::readConfiguration()
|
|||||||
{
|
{
|
||||||
AWAbstractFormatter::readConfiguration();
|
AWAbstractFormatter::readConfiguration();
|
||||||
|
|
||||||
QSettings settings(fileName(), QSettings::IniFormat);
|
QSettings settings(filePath(), QSettings::IniFormat);
|
||||||
|
|
||||||
settings.beginGroup("Desktop Entry");
|
settings.beginGroup("Desktop Entry");
|
||||||
setCount(settings.value("X-AW-Width", count()).toInt());
|
setCount(settings.value("X-AW-Width", count()).toInt());
|
||||||
@ -238,7 +239,7 @@ void AWFloatFormatter::writeConfiguration() const
|
|||||||
{
|
{
|
||||||
AWAbstractFormatter::writeConfiguration();
|
AWAbstractFormatter::writeConfiguration();
|
||||||
|
|
||||||
QSettings settings(writtableConfig(), QSettings::IniFormat);
|
QSettings settings(writableConfig(), QSettings::IniFormat);
|
||||||
qCInfo(LOG_LIB) << "Configuration file" << settings.fileName();
|
qCInfo(LOG_LIB) << "Configuration file" << settings.fileName();
|
||||||
|
|
||||||
settings.beginGroup("Desktop Entry");
|
settings.beginGroup("Desktop Entry");
|
||||||
|
@ -41,10 +41,10 @@ QString AWJsonFormatter::convert(const QVariant &_value) const
|
|||||||
qCDebug(LOG_LIB) << "Convert value" << _value;
|
qCDebug(LOG_LIB) << "Convert value" << _value;
|
||||||
|
|
||||||
// check if _value is string and parse first if required
|
// check if _value is string and parse first if required
|
||||||
QJsonDocument json = _value.userType() == QMetaType::QString ? QJsonDocument::fromJson(_value.toString().toUtf8())
|
auto json = _value.userType() == QMetaType::QString ? QJsonDocument::fromJson(_value.toString().toUtf8())
|
||||||
: QJsonDocument::fromVariant(_value);
|
: QJsonDocument::fromVariant(_value);
|
||||||
QVariant converted = json.toVariant();
|
auto converted = json.toVariant();
|
||||||
for (auto &element : m_splittedPath)
|
for (auto &element : m_path)
|
||||||
converted = getFromJson(converted, element);
|
converted = getFromJson(converted, element);
|
||||||
|
|
||||||
return converted.toString();
|
return converted.toString();
|
||||||
@ -57,6 +57,7 @@ AWJsonFormatter *AWJsonFormatter::copy(const QString &_fileName, const int _numb
|
|||||||
|
|
||||||
auto item = new AWJsonFormatter(parent(), _fileName);
|
auto item = new AWJsonFormatter(parent(), _fileName);
|
||||||
AWAbstractFormatter::copyDefaults(item);
|
AWAbstractFormatter::copyDefaults(item);
|
||||||
|
|
||||||
item->setNumber(_number);
|
item->setNumber(_number);
|
||||||
item->setPath(path());
|
item->setPath(path());
|
||||||
|
|
||||||
@ -66,7 +67,8 @@ AWJsonFormatter *AWJsonFormatter::copy(const QString &_fileName, const int _numb
|
|||||||
|
|
||||||
QString AWJsonFormatter::path() const
|
QString AWJsonFormatter::path() const
|
||||||
{
|
{
|
||||||
return m_path;
|
return std::accumulate(m_path.cbegin(), m_path.cend(), QString(""),
|
||||||
|
[](auto acc, auto &value) { return QString("%1.%2").arg(acc, value.toString()); });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -74,8 +76,14 @@ void AWJsonFormatter::setPath(const QString &_path)
|
|||||||
{
|
{
|
||||||
qCDebug(LOG_LIB) << "Path" << _path;
|
qCDebug(LOG_LIB) << "Path" << _path;
|
||||||
|
|
||||||
m_path = _path;
|
m_path.clear();
|
||||||
initPath();
|
auto elements = _path.split('.', Qt::SkipEmptyParts);
|
||||||
|
|
||||||
|
for (auto &element : elements) {
|
||||||
|
bool ok;
|
||||||
|
auto number = element.toInt(&ok);
|
||||||
|
m_path.append(ok ? QVariant(number) : QVariant(element));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -83,7 +91,7 @@ void AWJsonFormatter::readConfiguration()
|
|||||||
{
|
{
|
||||||
AWAbstractFormatter::readConfiguration();
|
AWAbstractFormatter::readConfiguration();
|
||||||
|
|
||||||
QSettings settings(fileName(), QSettings::IniFormat);
|
QSettings settings(filePath(), QSettings::IniFormat);
|
||||||
|
|
||||||
settings.beginGroup("Desktop Entry");
|
settings.beginGroup("Desktop Entry");
|
||||||
setPath(settings.value("X-AW-Path", path()).toString());
|
setPath(settings.value("X-AW-Path", path()).toString());
|
||||||
@ -129,7 +137,7 @@ void AWJsonFormatter::writeConfiguration() const
|
|||||||
{
|
{
|
||||||
AWAbstractFormatter::writeConfiguration();
|
AWAbstractFormatter::writeConfiguration();
|
||||||
|
|
||||||
QSettings settings(writtableConfig(), QSettings::IniFormat);
|
QSettings settings(writableConfig(), QSettings::IniFormat);
|
||||||
qCInfo(LOG_LIB) << "Configuration file" << settings.fileName();
|
qCInfo(LOG_LIB) << "Configuration file" << settings.fileName();
|
||||||
|
|
||||||
settings.beginGroup("Desktop Entry");
|
settings.beginGroup("Desktop Entry");
|
||||||
@ -171,19 +179,6 @@ QVariant AWJsonFormatter::getFromMap(const QVariant &_value, const QString &_key
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void AWJsonFormatter::initPath()
|
|
||||||
{
|
|
||||||
m_splittedPath.clear();
|
|
||||||
QStringList splittedByDot = m_path.split('.', Qt::SkipEmptyParts);
|
|
||||||
|
|
||||||
for (auto &element : splittedByDot) {
|
|
||||||
bool ok;
|
|
||||||
int number = element.toInt(&ok);
|
|
||||||
m_splittedPath.append(ok ? QVariant(number) : QVariant(element));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void AWJsonFormatter::translate(void *_ui)
|
void AWJsonFormatter::translate(void *_ui)
|
||||||
{
|
{
|
||||||
auto ui = reinterpret_cast<Ui::AWJsonFormatter *>(_ui);
|
auto ui = reinterpret_cast<Ui::AWJsonFormatter *>(_ui);
|
||||||
|
@ -42,9 +42,7 @@ private:
|
|||||||
static QVariant getFromJson(const QVariant &_value, const QVariant &_element);
|
static QVariant getFromJson(const QVariant &_value, const QVariant &_element);
|
||||||
static QVariant getFromList(const QVariant &_value, int _index);
|
static QVariant getFromList(const QVariant &_value, int _index);
|
||||||
static QVariant getFromMap(const QVariant &_value, const QString &_key);
|
static QVariant getFromMap(const QVariant &_value, const QString &_key);
|
||||||
void initPath();
|
|
||||||
void translate(void *_ui) override;
|
void translate(void *_ui) override;
|
||||||
// properties
|
// properties
|
||||||
QString m_path;
|
QVariantList m_path;
|
||||||
QVariantList m_splittedPath;
|
|
||||||
};
|
};
|
||||||
|
@ -53,6 +53,7 @@ AWListFormatter *AWListFormatter::copy(const QString &_fileName, const int _numb
|
|||||||
|
|
||||||
auto item = new AWListFormatter(parent(), _fileName);
|
auto item = new AWListFormatter(parent(), _fileName);
|
||||||
AWAbstractFormatter::copyDefaults(item);
|
AWAbstractFormatter::copyDefaults(item);
|
||||||
|
|
||||||
item->setFilter(filter());
|
item->setFilter(filter());
|
||||||
item->setSeparator(separator());
|
item->setSeparator(separator());
|
||||||
item->setSorted(isSorted());
|
item->setSorted(isSorted());
|
||||||
@ -91,7 +92,7 @@ void AWListFormatter::setFilter(const QString &_filter)
|
|||||||
|
|
||||||
void AWListFormatter::setSeparator(const QString &_separator)
|
void AWListFormatter::setSeparator(const QString &_separator)
|
||||||
{
|
{
|
||||||
qCDebug(LOG_LIB) << "Separtor" << _separator;
|
qCDebug(LOG_LIB) << "Separator" << _separator;
|
||||||
|
|
||||||
m_separator = _separator;
|
m_separator = _separator;
|
||||||
}
|
}
|
||||||
@ -109,7 +110,7 @@ void AWListFormatter::readConfiguration()
|
|||||||
{
|
{
|
||||||
AWAbstractFormatter::readConfiguration();
|
AWAbstractFormatter::readConfiguration();
|
||||||
|
|
||||||
QSettings settings(fileName(), QSettings::IniFormat);
|
QSettings settings(filePath(), QSettings::IniFormat);
|
||||||
|
|
||||||
settings.beginGroup("Desktop Entry");
|
settings.beginGroup("Desktop Entry");
|
||||||
setFilter(settings.value("X-AW-Filter", filter()).toString());
|
setFilter(settings.value("X-AW-Filter", filter()).toString());
|
||||||
@ -161,7 +162,7 @@ void AWListFormatter::writeConfiguration() const
|
|||||||
{
|
{
|
||||||
AWAbstractFormatter::writeConfiguration();
|
AWAbstractFormatter::writeConfiguration();
|
||||||
|
|
||||||
QSettings settings(writtableConfig(), QSettings::IniFormat);
|
QSettings settings(writableConfig(), QSettings::IniFormat);
|
||||||
qCInfo(LOG_LIB) << "Configuration file" << settings.fileName();
|
qCInfo(LOG_LIB) << "Configuration file" << settings.fileName();
|
||||||
|
|
||||||
settings.beginGroup("Desktop Entry");
|
settings.beginGroup("Desktop Entry");
|
||||||
|
@ -47,6 +47,7 @@ AWNoFormatter *AWNoFormatter::copy(const QString &_fileName, const int _number)
|
|||||||
|
|
||||||
auto item = new AWNoFormatter(parent(), _fileName);
|
auto item = new AWNoFormatter(parent(), _fileName);
|
||||||
AWAbstractFormatter::copyDefaults(item);
|
AWAbstractFormatter::copyDefaults(item);
|
||||||
|
|
||||||
item->setNumber(_number);
|
item->setNumber(_number);
|
||||||
|
|
||||||
return item;
|
return item;
|
||||||
|
@ -34,5 +34,4 @@ public slots:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void translate(void *_ui) override;
|
void translate(void *_ui) override;
|
||||||
// properties
|
|
||||||
};
|
};
|
||||||
|
@ -61,6 +61,7 @@ AWScriptFormatter *AWScriptFormatter::copy(const QString &_fileName, const int _
|
|||||||
|
|
||||||
auto item = new AWScriptFormatter(parent(), _fileName);
|
auto item = new AWScriptFormatter(parent(), _fileName);
|
||||||
AWAbstractFormatter::copyDefaults(item);
|
AWAbstractFormatter::copyDefaults(item);
|
||||||
|
|
||||||
item->setAppendCode(appendCode());
|
item->setAppendCode(appendCode());
|
||||||
item->setCode(code());
|
item->setCode(code());
|
||||||
item->setHasReturn(hasReturn());
|
item->setHasReturn(hasReturn());
|
||||||
@ -125,7 +126,7 @@ void AWScriptFormatter::readConfiguration()
|
|||||||
{
|
{
|
||||||
AWAbstractFormatter::readConfiguration();
|
AWAbstractFormatter::readConfiguration();
|
||||||
|
|
||||||
QSettings settings(fileName(), QSettings::IniFormat);
|
QSettings settings(filePath(), QSettings::IniFormat);
|
||||||
|
|
||||||
settings.beginGroup("Desktop Entry");
|
settings.beginGroup("Desktop Entry");
|
||||||
setAppendCode(settings.value("X-AW-AppendCode", appendCode()).toBool());
|
setAppendCode(settings.value("X-AW-AppendCode", appendCode()).toBool());
|
||||||
@ -178,7 +179,7 @@ void AWScriptFormatter::writeConfiguration() const
|
|||||||
{
|
{
|
||||||
AWAbstractFormatter::writeConfiguration();
|
AWAbstractFormatter::writeConfiguration();
|
||||||
|
|
||||||
QSettings settings(writtableConfig(), QSettings::IniFormat);
|
QSettings settings(writableConfig(), QSettings::IniFormat);
|
||||||
qCInfo(LOG_LIB) << "Configuration file" << settings.fileName();
|
qCInfo(LOG_LIB) << "Configuration file" << settings.fileName();
|
||||||
|
|
||||||
settings.beginGroup("Desktop Entry");
|
settings.beginGroup("Desktop Entry");
|
||||||
|
@ -53,6 +53,7 @@ AWStringFormatter *AWStringFormatter::copy(const QString &_fileName, const int _
|
|||||||
|
|
||||||
auto item = new AWStringFormatter(parent(), _fileName);
|
auto item = new AWStringFormatter(parent(), _fileName);
|
||||||
AWAbstractFormatter::copyDefaults(item);
|
AWAbstractFormatter::copyDefaults(item);
|
||||||
|
|
||||||
item->setCount(count());
|
item->setCount(count());
|
||||||
item->setFillChar(fillChar());
|
item->setFillChar(fillChar());
|
||||||
item->setForceWidth(forceWidth());
|
item->setForceWidth(forceWidth());
|
||||||
@ -108,7 +109,7 @@ void AWStringFormatter::readConfiguration()
|
|||||||
{
|
{
|
||||||
AWAbstractFormatter::readConfiguration();
|
AWAbstractFormatter::readConfiguration();
|
||||||
|
|
||||||
QSettings settings(fileName(), QSettings::IniFormat);
|
QSettings settings(filePath(), QSettings::IniFormat);
|
||||||
|
|
||||||
settings.beginGroup("Desktop Entry");
|
settings.beginGroup("Desktop Entry");
|
||||||
setCount(settings.value("X-AW-Width", count()).toInt());
|
setCount(settings.value("X-AW-Width", count()).toInt());
|
||||||
@ -160,7 +161,7 @@ void AWStringFormatter::writeConfiguration() const
|
|||||||
{
|
{
|
||||||
AWAbstractFormatter::writeConfiguration();
|
AWAbstractFormatter::writeConfiguration();
|
||||||
|
|
||||||
QSettings settings(writtableConfig(), QSettings::IniFormat);
|
QSettings settings(writableConfig(), QSettings::IniFormat);
|
||||||
qCInfo(LOG_LIB) << "Configuration file" << settings.fileName();
|
qCInfo(LOG_LIB) << "Configuration file" << settings.fileName();
|
||||||
|
|
||||||
settings.beginGroup("Desktop Entry");
|
settings.beginGroup("Desktop Entry");
|
||||||
|
@ -23,6 +23,8 @@
|
|||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
|
|
||||||
|
#include <ranges>
|
||||||
|
|
||||||
#include "abstractextitemaggregator.h"
|
#include "abstractextitemaggregator.h"
|
||||||
#include "awdebug.h"
|
#include "awdebug.h"
|
||||||
|
|
||||||
@ -48,10 +50,12 @@ public:
|
|||||||
qCDebug(LOG_LIB) << __PRETTY_FUNCTION__;
|
qCDebug(LOG_LIB) << __PRETTY_FUNCTION__;
|
||||||
|
|
||||||
m_items.clear();
|
m_items.clear();
|
||||||
m_activeItems.clear();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
QList<T *> activeItems() { return m_activeItems; };
|
auto activeItems()
|
||||||
|
{
|
||||||
|
return m_items | std::ranges::views::filter([](auto item) { return item->isActive(); });
|
||||||
|
};
|
||||||
|
|
||||||
void editItems()
|
void editItems()
|
||||||
{
|
{
|
||||||
@ -62,14 +66,7 @@ public:
|
|||||||
void initItems() override
|
void initItems() override
|
||||||
{
|
{
|
||||||
m_items.clear();
|
m_items.clear();
|
||||||
m_activeItems.clear();
|
|
||||||
|
|
||||||
m_items = getItems();
|
m_items = getItems();
|
||||||
for (auto item : m_items) {
|
|
||||||
if (!item->isActive())
|
|
||||||
continue;
|
|
||||||
m_activeItems.append(static_cast<T *>(item));
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void initSockets()
|
void initSockets()
|
||||||
@ -85,41 +82,34 @@ public:
|
|||||||
{
|
{
|
||||||
qCDebug(LOG_LIB) << "Tag" << _tag << "with used type" << _type;
|
qCDebug(LOG_LIB) << "Tag" << _tag << "with used type" << _type;
|
||||||
|
|
||||||
T *found = nullptr;
|
auto found = std::find_if(m_items.cbegin(), m_items.cend(),
|
||||||
for (auto item : m_items) {
|
[&_tag, &_type](auto item) { return item->tag(_type) == _tag; });
|
||||||
if (item->tag(_type) != _tag)
|
|
||||||
continue;
|
|
||||||
found = static_cast<T *>(item);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (found == nullptr)
|
|
||||||
qCWarning(LOG_LIB) << "Could not find item by tag" << _tag;
|
|
||||||
|
|
||||||
return found;
|
if (found == std::end(m_items)) {
|
||||||
|
qCWarning(LOG_LIB) << "Could not find item by tag" << _tag;
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
return static_cast<T *>(*found);
|
||||||
};
|
};
|
||||||
|
|
||||||
T *itemByTagNumber(const int _number) const
|
T *itemByTagNumber(const int _number) const
|
||||||
{
|
{
|
||||||
qCDebug(LOG_LIB) << "Number" << _number;
|
qCDebug(LOG_LIB) << "Number" << _number;
|
||||||
|
|
||||||
T *found = nullptr;
|
auto found = std::find_if(m_items.cbegin(), m_items.cend(),
|
||||||
for (auto item : m_items) {
|
[_number](auto item) { return item->number() == _number; });
|
||||||
if (item->number() != _number)
|
|
||||||
continue;
|
|
||||||
found = static_cast<T *>(item);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (found == nullptr)
|
|
||||||
qCWarning(LOG_LIB) << "Could not find item by number" << _number;
|
|
||||||
|
|
||||||
return found;
|
if (found == std::end(m_items)) {
|
||||||
|
qCWarning(LOG_LIB) << "Could not find item by number" << _number;
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
return static_cast<T *>(*found);
|
||||||
};
|
};
|
||||||
|
|
||||||
[[nodiscard]] QList<AbstractExtItem *> items() const override { return m_items; };
|
[[nodiscard]] QList<AbstractExtItem *> items() const override { return m_items; };
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QList<AbstractExtItem *> m_items;
|
QList<AbstractExtItem *> m_items;
|
||||||
QList<T *> m_activeItems;
|
|
||||||
|
|
||||||
void doCreateItem(QListWidget *_widget) override { return createItem<T>(_widget); }
|
void doCreateItem(QListWidget *_widget) override { return createItem<T>(_widget); }
|
||||||
|
|
||||||
@ -127,8 +117,7 @@ private:
|
|||||||
{
|
{
|
||||||
QList<AbstractExtItem *> items;
|
QList<AbstractExtItem *> items;
|
||||||
|
|
||||||
auto dirs = directories();
|
for (auto &dir : directories()) {
|
||||||
for (auto &dir : dirs) {
|
|
||||||
auto files = QDir(dir).entryList(QDir::Files, QDir::Name);
|
auto files = QDir(dir).entryList(QDir::Files, QDir::Name);
|
||||||
for (auto &file : files) {
|
for (auto &file : files) {
|
||||||
// check filename
|
// check filename
|
||||||
@ -137,8 +126,7 @@ private:
|
|||||||
qCInfo(LOG_LIB) << "Found file" << file << "in" << dir;
|
qCInfo(LOG_LIB) << "Found file" << file << "in" << dir;
|
||||||
auto filePath = QString("%1/%2").arg(dir, file);
|
auto filePath = QString("%1/%2").arg(dir, file);
|
||||||
// check if already exists
|
// check if already exists
|
||||||
if (std::any_of(items.cbegin(), items.cend(),
|
if (std::any_of(items.cbegin(), items.cend(), [&file](auto item) { return item->fileName() == file; }))
|
||||||
[&filePath](AbstractExtItem *item) { return (item->fileName() == filePath); }))
|
|
||||||
continue;
|
continue;
|
||||||
items.append(new T(this, filePath));
|
items.append(new T(this, filePath));
|
||||||
}
|
}
|
||||||
|
@ -62,31 +62,31 @@ ExtNetworkRequest *ExtNetworkRequest::copy(const QString &_fileName, const int _
|
|||||||
|
|
||||||
auto item = new ExtNetworkRequest(parent(), _fileName);
|
auto item = new ExtNetworkRequest(parent(), _fileName);
|
||||||
copyDefaults(item);
|
copyDefaults(item);
|
||||||
|
|
||||||
item->setNumber(_number);
|
item->setNumber(_number);
|
||||||
item->setStringUrl(stringUrl());
|
item->setUrl(url());
|
||||||
|
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString ExtNetworkRequest::stringUrl() const
|
QString ExtNetworkRequest::url() const
|
||||||
{
|
|
||||||
return m_stringUrl;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QString ExtNetworkRequest::uniq() const
|
|
||||||
{
|
{
|
||||||
return m_url.toString();
|
return m_url.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ExtNetworkRequest::setStringUrl(const QString &_url)
|
QString ExtNetworkRequest::uniq() const
|
||||||
|
{
|
||||||
|
return url();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ExtNetworkRequest::setUrl(const QString &_url)
|
||||||
{
|
{
|
||||||
qCDebug(LOG_LIB) << "Url" << _url;
|
qCDebug(LOG_LIB) << "Url" << _url;
|
||||||
|
|
||||||
m_stringUrl = _url;
|
m_url = QUrl(_url);
|
||||||
initUrl();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -94,10 +94,10 @@ void ExtNetworkRequest::readConfiguration()
|
|||||||
{
|
{
|
||||||
AbstractExtItem::readConfiguration();
|
AbstractExtItem::readConfiguration();
|
||||||
|
|
||||||
QSettings settings(fileName(), QSettings::IniFormat);
|
QSettings settings(filePath(), QSettings::IniFormat);
|
||||||
|
|
||||||
settings.beginGroup("Desktop Entry");
|
settings.beginGroup("Desktop Entry");
|
||||||
setStringUrl(settings.value("X-AW-Url", stringUrl()).toString());
|
setUrl(settings.value("X-AW-Url", url()).toString());
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
|
|
||||||
bumpApi(AW_EXTNETREQUEST_API);
|
bumpApi(AW_EXTNETREQUEST_API);
|
||||||
@ -126,7 +126,7 @@ int ExtNetworkRequest::showConfiguration(QWidget *_parent, const QVariant &_args
|
|||||||
ui->lineEdit_name->setText(name());
|
ui->lineEdit_name->setText(name());
|
||||||
ui->lineEdit_comment->setText(comment());
|
ui->lineEdit_comment->setText(comment());
|
||||||
ui->label_numberValue->setText(QString("%1").arg(number()));
|
ui->label_numberValue->setText(QString("%1").arg(number()));
|
||||||
ui->lineEdit_url->setText(stringUrl());
|
ui->lineEdit_url->setText(url());
|
||||||
ui->checkBox_active->setCheckState(isActive() ? Qt::Checked : Qt::Unchecked);
|
ui->checkBox_active->setCheckState(isActive() ? Qt::Checked : Qt::Unchecked);
|
||||||
ui->lineEdit_schedule->setText(cron());
|
ui->lineEdit_schedule->setText(cron());
|
||||||
ui->lineEdit_socket->setText(socket());
|
ui->lineEdit_socket->setText(socket());
|
||||||
@ -138,7 +138,7 @@ int ExtNetworkRequest::showConfiguration(QWidget *_parent, const QVariant &_args
|
|||||||
setComment(ui->lineEdit_comment->text());
|
setComment(ui->lineEdit_comment->text());
|
||||||
setNumber(ui->label_numberValue->text().toInt());
|
setNumber(ui->label_numberValue->text().toInt());
|
||||||
setApiVersion(AW_EXTNETREQUEST_API);
|
setApiVersion(AW_EXTNETREQUEST_API);
|
||||||
setStringUrl(ui->lineEdit_url->text());
|
setUrl(ui->lineEdit_url->text());
|
||||||
setActive(ui->checkBox_active->checkState() == Qt::Checked);
|
setActive(ui->checkBox_active->checkState() == Qt::Checked);
|
||||||
setCron(ui->lineEdit_schedule->text());
|
setCron(ui->lineEdit_schedule->text());
|
||||||
setSocket(ui->lineEdit_socket->text());
|
setSocket(ui->lineEdit_socket->text());
|
||||||
@ -158,11 +158,11 @@ void ExtNetworkRequest::writeConfiguration() const
|
|||||||
{
|
{
|
||||||
AbstractExtItem::writeConfiguration();
|
AbstractExtItem::writeConfiguration();
|
||||||
|
|
||||||
QSettings settings(writtableConfig(), QSettings::IniFormat);
|
QSettings settings(writableConfig(), QSettings::IniFormat);
|
||||||
qCInfo(LOG_LIB) << "Configuration file" << settings.fileName();
|
qCInfo(LOG_LIB) << "Configuration file" << settings.fileName();
|
||||||
|
|
||||||
settings.beginGroup("Desktop Entry");
|
settings.beginGroup("Desktop Entry");
|
||||||
settings.setValue("X-AW-Url", stringUrl());
|
settings.setValue("X-AW-Url", url());
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
|
|
||||||
settings.sync();
|
settings.sync();
|
||||||
@ -190,12 +190,6 @@ void ExtNetworkRequest::sendRequest()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ExtNetworkRequest::initUrl()
|
|
||||||
{
|
|
||||||
m_url = QUrl(m_stringUrl);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void ExtNetworkRequest::translate(void *_ui)
|
void ExtNetworkRequest::translate(void *_ui)
|
||||||
{
|
{
|
||||||
auto ui = reinterpret_cast<Ui::ExtNetworkRequest *>(_ui);
|
auto ui = reinterpret_cast<Ui::ExtNetworkRequest *>(_ui);
|
||||||
|
@ -25,17 +25,17 @@
|
|||||||
class ExtNetworkRequest : public AbstractExtItem
|
class ExtNetworkRequest : public AbstractExtItem
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(QString stringUrl READ stringUrl WRITE setStringUrl)
|
Q_PROPERTY(QString url READ url WRITE setUrl)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit ExtNetworkRequest(QObject *_parent = nullptr, const QString &_filePath = "");
|
explicit ExtNetworkRequest(QObject *_parent = nullptr, const QString &_filePath = "");
|
||||||
~ExtNetworkRequest() override;
|
~ExtNetworkRequest() override;
|
||||||
ExtNetworkRequest *copy(const QString &_fileName, int _number) override;
|
ExtNetworkRequest *copy(const QString &_fileName, int _number) override;
|
||||||
// get methods
|
// get methods
|
||||||
[[nodiscard]] QString stringUrl() const;
|
[[nodiscard]] QString url() const;
|
||||||
[[nodiscard]] QString uniq() const override;
|
[[nodiscard]] QString uniq() const override;
|
||||||
// set methods
|
// set methods
|
||||||
void setStringUrl(const QString &_url);
|
void setUrl(const QString &_url);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void readConfiguration() override;
|
void readConfiguration() override;
|
||||||
@ -51,7 +51,6 @@ private:
|
|||||||
QNetworkAccessManager *m_manager = nullptr;
|
QNetworkAccessManager *m_manager = nullptr;
|
||||||
QUrl m_url;
|
QUrl m_url;
|
||||||
bool m_isRunning = false;
|
bool m_isRunning = false;
|
||||||
void initUrl();
|
|
||||||
void translate(void *_ui) override;
|
void translate(void *_ui) override;
|
||||||
// properties
|
// properties
|
||||||
QString m_stringUrl = "https://httpbin.org/get";
|
QString m_stringUrl = "https://httpbin.org/get";
|
||||||
|
@ -68,6 +68,7 @@ ExtQuotes *ExtQuotes::copy(const QString &_fileName, const int _number)
|
|||||||
|
|
||||||
auto item = new ExtQuotes(parent(), _fileName);
|
auto item = new ExtQuotes(parent(), _fileName);
|
||||||
copyDefaults(item);
|
copyDefaults(item);
|
||||||
|
|
||||||
item->setNumber(_number);
|
item->setNumber(_number);
|
||||||
item->setTicker(ticker());
|
item->setTicker(ticker());
|
||||||
|
|
||||||
@ -100,7 +101,7 @@ void ExtQuotes::readConfiguration()
|
|||||||
{
|
{
|
||||||
AbstractExtItem::readConfiguration();
|
AbstractExtItem::readConfiguration();
|
||||||
|
|
||||||
QSettings settings(fileName(), QSettings::IniFormat);
|
QSettings settings(filePath(), QSettings::IniFormat);
|
||||||
|
|
||||||
settings.beginGroup("Desktop Entry");
|
settings.beginGroup("Desktop Entry");
|
||||||
setTicker(settings.value("X-AW-Ticker", ticker()).toString());
|
setTicker(settings.value("X-AW-Ticker", ticker()).toString());
|
||||||
@ -164,7 +165,7 @@ void ExtQuotes::writeConfiguration() const
|
|||||||
{
|
{
|
||||||
AbstractExtItem::writeConfiguration();
|
AbstractExtItem::writeConfiguration();
|
||||||
|
|
||||||
QSettings settings(writtableConfig(), QSettings::IniFormat);
|
QSettings settings(writableConfig(), QSettings::IniFormat);
|
||||||
qCInfo(LOG_LIB) << "Configuration file" << settings.fileName();
|
qCInfo(LOG_LIB) << "Configuration file" << settings.fileName();
|
||||||
|
|
||||||
settings.beginGroup("Desktop Entry");
|
settings.beginGroup("Desktop Entry");
|
||||||
|
@ -63,6 +63,7 @@ ExtScript *ExtScript::copy(const QString &_fileName, const int _number)
|
|||||||
|
|
||||||
auto item = new ExtScript(parent(), _fileName);
|
auto item = new ExtScript(parent(), _fileName);
|
||||||
copyDefaults(item);
|
copyDefaults(item);
|
||||||
|
|
||||||
item->setExecutable(executable());
|
item->setExecutable(executable());
|
||||||
item->setNumber(_number);
|
item->setNumber(_number);
|
||||||
item->setRedirect(redirect());
|
item->setRedirect(redirect());
|
||||||
@ -179,8 +180,8 @@ QString ExtScript::applyFilters(QString _value) const
|
|||||||
qCWarning(LOG_LIB) << "Could not find filter" << _value << "in the json";
|
qCWarning(LOG_LIB) << "Could not find filter" << _value << "in the json";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
for (auto &f : filter.keys())
|
for (auto [key, value] : filter.asKeyValueRange())
|
||||||
_value.replace(f, filter[f].toString());
|
_value.replace(key, value.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
return _value;
|
return _value;
|
||||||
@ -205,7 +206,7 @@ void ExtScript::readConfiguration()
|
|||||||
{
|
{
|
||||||
AbstractExtItem::readConfiguration();
|
AbstractExtItem::readConfiguration();
|
||||||
|
|
||||||
QSettings settings(fileName(), QSettings::IniFormat);
|
QSettings settings(filePath(), QSettings::IniFormat);
|
||||||
|
|
||||||
settings.beginGroup("Desktop Entry");
|
settings.beginGroup("Desktop Entry");
|
||||||
setExecutable(settings.value("Exec", executable()).toString());
|
setExecutable(settings.value("Exec", executable()).toString());
|
||||||
@ -305,7 +306,7 @@ void ExtScript::writeConfiguration() const
|
|||||||
{
|
{
|
||||||
AbstractExtItem::writeConfiguration();
|
AbstractExtItem::writeConfiguration();
|
||||||
|
|
||||||
QSettings settings(writtableConfig(), QSettings::IniFormat);
|
QSettings settings(writableConfig(), QSettings::IniFormat);
|
||||||
qCInfo(LOG_LIB) << "Configuration file" << settings.fileName();
|
qCInfo(LOG_LIB) << "Configuration file" << settings.fileName();
|
||||||
|
|
||||||
settings.beginGroup("Desktop Entry");
|
settings.beginGroup("Desktop Entry");
|
||||||
@ -332,24 +333,24 @@ void ExtScript::updateValue()
|
|||||||
qCInfo(LOG_LIB) << "Error" << qdebug;
|
qCInfo(LOG_LIB) << "Error" << qdebug;
|
||||||
auto qoutput = QString::fromUtf8(m_process->readAllStandardOutput()).trimmed();
|
auto qoutput = QString::fromUtf8(m_process->readAllStandardOutput()).trimmed();
|
||||||
qCInfo(LOG_LIB) << "Output" << qoutput;
|
qCInfo(LOG_LIB) << "Output" << qoutput;
|
||||||
QString strValue;
|
|
||||||
|
|
||||||
|
QString result;
|
||||||
switch (redirect()) {
|
switch (redirect()) {
|
||||||
case Redirect::stdout2stderr:
|
case Redirect::stdout2stderr:
|
||||||
break;
|
break;
|
||||||
case Redirect::stderr2stdout:
|
case Redirect::stderr2stdout:
|
||||||
strValue = QString("%1\n%2").arg(qdebug).arg(qoutput);
|
result = QString("%1\n%2").arg(qdebug, qoutput);
|
||||||
break;
|
break;
|
||||||
case Redirect::swap:
|
case Redirect::swap:
|
||||||
strValue = qdebug;
|
result = qdebug;
|
||||||
break;
|
break;
|
||||||
case Redirect::nothing:
|
case Redirect::nothing:
|
||||||
strValue = qoutput;
|
result = qoutput;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// filters
|
// filters
|
||||||
m_values[tag("custom")] = applyFilters(strValue);
|
m_values[tag("custom")] = applyFilters(result);
|
||||||
emit(dataReceived(m_values));
|
emit(dataReceived(m_values));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,6 +59,7 @@ ExtUpgrade *ExtUpgrade::copy(const QString &_fileName, const int _number)
|
|||||||
|
|
||||||
auto item = new ExtUpgrade(parent(), _fileName);
|
auto item = new ExtUpgrade(parent(), _fileName);
|
||||||
copyDefaults(item);
|
copyDefaults(item);
|
||||||
|
|
||||||
item->setExecutable(executable());
|
item->setExecutable(executable());
|
||||||
item->setFilter(filter());
|
item->setFilter(filter());
|
||||||
item->setNumber(_number);
|
item->setNumber(_number);
|
||||||
@ -122,7 +123,7 @@ void ExtUpgrade::readConfiguration()
|
|||||||
{
|
{
|
||||||
AbstractExtItem::readConfiguration();
|
AbstractExtItem::readConfiguration();
|
||||||
|
|
||||||
QSettings settings(fileName(), QSettings::IniFormat);
|
QSettings settings(filePath(), QSettings::IniFormat);
|
||||||
|
|
||||||
settings.beginGroup("Desktop Entry");
|
settings.beginGroup("Desktop Entry");
|
||||||
setExecutable(settings.value("Exec", executable()).toString());
|
setExecutable(settings.value("Exec", executable()).toString());
|
||||||
@ -193,7 +194,7 @@ void ExtUpgrade::writeConfiguration() const
|
|||||||
{
|
{
|
||||||
AbstractExtItem::writeConfiguration();
|
AbstractExtItem::writeConfiguration();
|
||||||
|
|
||||||
QSettings settings(writtableConfig(), QSettings::IniFormat);
|
QSettings settings(writableConfig(), QSettings::IniFormat);
|
||||||
qCInfo(LOG_LIB) << "Configuration file" << settings.fileName();
|
qCInfo(LOG_LIB) << "Configuration file" << settings.fileName();
|
||||||
|
|
||||||
settings.beginGroup("Desktop Entry");
|
settings.beginGroup("Desktop Entry");
|
||||||
|
@ -71,6 +71,7 @@ ExtWeather *ExtWeather::copy(const QString &_fileName, const int _number)
|
|||||||
|
|
||||||
auto item = new ExtWeather(parent(), _fileName);
|
auto item = new ExtWeather(parent(), _fileName);
|
||||||
copyDefaults(item);
|
copyDefaults(item);
|
||||||
|
|
||||||
item->setCity(city());
|
item->setCity(city());
|
||||||
item->setCountry(country());
|
item->setCountry(country());
|
||||||
item->setImage(image());
|
item->setImage(image());
|
||||||
@ -212,7 +213,7 @@ void ExtWeather::readConfiguration()
|
|||||||
{
|
{
|
||||||
AbstractExtItem::readConfiguration();
|
AbstractExtItem::readConfiguration();
|
||||||
|
|
||||||
QSettings settings(fileName(), QSettings::IniFormat);
|
QSettings settings(filePath(), QSettings::IniFormat);
|
||||||
|
|
||||||
settings.beginGroup("Desktop Entry");
|
settings.beginGroup("Desktop Entry");
|
||||||
setCity(settings.value("X-AW-City", city()).toString());
|
setCity(settings.value("X-AW-City", city()).toString());
|
||||||
@ -313,7 +314,7 @@ void ExtWeather::writeConfiguration() const
|
|||||||
{
|
{
|
||||||
AbstractExtItem::writeConfiguration();
|
AbstractExtItem::writeConfiguration();
|
||||||
|
|
||||||
QSettings settings(writtableConfig(), QSettings::IniFormat);
|
QSettings settings(writableConfig(), QSettings::IniFormat);
|
||||||
qCInfo(LOG_LIB) << "Configuration file" << settings.fileName();
|
qCInfo(LOG_LIB) << "Configuration file" << settings.fileName();
|
||||||
|
|
||||||
settings.beginGroup("Desktop Entry");
|
settings.beginGroup("Desktop Entry");
|
||||||
|
@ -39,7 +39,7 @@ GraphicalItem::GraphicalItem(QObject *_parent, const QString &_filePath)
|
|||||||
|
|
||||||
// init scene
|
// init scene
|
||||||
m_scene = new QGraphicsScene();
|
m_scene = new QGraphicsScene();
|
||||||
m_scene->setBackgroundBrush(QBrush(Qt::NoBrush));
|
m_scene->setBackgroundBrush({Qt::NoBrush});
|
||||||
// init view
|
// init view
|
||||||
m_view = new QGraphicsView(m_scene);
|
m_view = new QGraphicsView(m_scene);
|
||||||
m_view->setStyleSheet("background: transparent");
|
m_view->setStyleSheet("background: transparent");
|
||||||
@ -61,6 +61,7 @@ GraphicalItem *GraphicalItem::copy(const QString &_fileName, const int _number)
|
|||||||
|
|
||||||
auto item = new GraphicalItem(parent(), _fileName);
|
auto item = new GraphicalItem(parent(), _fileName);
|
||||||
copyDefaults(item);
|
copyDefaults(item);
|
||||||
|
|
||||||
item->setActiveColor(activeColor());
|
item->setActiveColor(activeColor());
|
||||||
item->setBar(bar());
|
item->setBar(bar());
|
||||||
item->setCount(count());
|
item->setCount(count());
|
||||||
@ -83,44 +84,41 @@ QString GraphicalItem::image(const QVariant &value)
|
|||||||
qCDebug(LOG_LIB) << "Value" << value;
|
qCDebug(LOG_LIB) << "Value" << value;
|
||||||
|
|
||||||
m_scene->clear();
|
m_scene->clear();
|
||||||
int scale[2] = {1, 1};
|
auto scaleX = 1, scaleY = 1;
|
||||||
auto converted = GraphicalItemHelper::getPercents(value.toFloat(), minValue(), maxValue());
|
auto converted = GraphicalItemHelper::getPercents(value.toFloat(), minValue(), maxValue());
|
||||||
|
|
||||||
// paint
|
// paint
|
||||||
switch (m_type) {
|
switch (m_type) {
|
||||||
case Type::Vertical:
|
case Type::Vertical:
|
||||||
m_helper->paintVertical(converted);
|
m_helper->paintVertical(converted);
|
||||||
// scale
|
scaleY = -2 * static_cast<int>(direction()) + 1;
|
||||||
scale[1] = -2 * static_cast<int>(direction()) + 1;
|
|
||||||
break;
|
break;
|
||||||
case Type::Circle:
|
case Type::Circle:
|
||||||
m_helper->paintCircle(converted);
|
m_helper->paintCircle(converted);
|
||||||
// scale
|
scaleX = -2 * static_cast<int>(direction()) + 1;
|
||||||
scale[0] = -2 * static_cast<int>(direction()) + 1;
|
|
||||||
break;
|
break;
|
||||||
case Type::Graph:
|
case Type::Graph:
|
||||||
m_helper->paintGraph(converted);
|
m_helper->paintGraph(converted);
|
||||||
scale[0] = -2 * static_cast<int>(direction()) + 1;
|
scaleX = -2 * static_cast<int>(direction()) + 1;
|
||||||
scale[1] = -1;
|
scaleY = -1;
|
||||||
break;
|
break;
|
||||||
case Type::Bars:
|
case Type::Bars:
|
||||||
m_helper->paintBars(converted);
|
m_helper->paintBars(converted);
|
||||||
scale[0] = -2 * static_cast<int>(direction()) + 1;
|
scaleX = -2 * static_cast<int>(direction()) + 1;
|
||||||
scale[1] = -1;
|
scaleY = -1;
|
||||||
break;
|
break;
|
||||||
case Type::Horizontal:
|
case Type::Horizontal:
|
||||||
m_helper->paintHorizontal(converted);
|
m_helper->paintHorizontal(converted);
|
||||||
// scale
|
scaleX = -2 * static_cast<int>(direction()) + 1;
|
||||||
scale[0] = -2 * static_cast<int>(direction()) + 1;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// convert
|
// convert
|
||||||
auto pixmap = m_view->grab().transformed(QTransform().scale(scale[0], scale[1]));
|
auto pixmap = m_view->grab().transformed(QTransform().scale(scaleX, scaleY));
|
||||||
QByteArray byteArray;
|
QByteArray byteArray;
|
||||||
QBuffer buffer(&byteArray);
|
QBuffer buffer(&byteArray);
|
||||||
pixmap.save(&buffer, "PNG");
|
pixmap.save(&buffer, "PNG");
|
||||||
auto url = QString("<img src=\"data:image/png;base64,%1\"/>").arg(QString(byteArray.toBase64()));
|
auto url = QString("<img src=\"data:image/png;base64,%1\"/>").arg(byteArray.toBase64());
|
||||||
|
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
@ -393,7 +391,7 @@ void GraphicalItem::readConfiguration()
|
|||||||
{
|
{
|
||||||
AbstractExtItem::readConfiguration();
|
AbstractExtItem::readConfiguration();
|
||||||
|
|
||||||
QSettings settings(fileName(), QSettings::IniFormat);
|
QSettings settings(filePath(), QSettings::IniFormat);
|
||||||
|
|
||||||
settings.beginGroup("Desktop Entry");
|
settings.beginGroup("Desktop Entry");
|
||||||
setCount(settings.value("X-AW-Count", count()).toInt());
|
setCount(settings.value("X-AW-Count", count()).toInt());
|
||||||
@ -502,7 +500,7 @@ void GraphicalItem::writeConfiguration() const
|
|||||||
{
|
{
|
||||||
AbstractExtItem::writeConfiguration();
|
AbstractExtItem::writeConfiguration();
|
||||||
|
|
||||||
QSettings settings(writtableConfig(), QSettings::IniFormat);
|
QSettings settings(writableConfig(), QSettings::IniFormat);
|
||||||
qCInfo(LOG_LIB) << "Configuration file" << settings.fileName();
|
qCInfo(LOG_LIB) << "Configuration file" << settings.fileName();
|
||||||
|
|
||||||
settings.beginGroup("Desktop Entry");
|
settings.beginGroup("Desktop Entry");
|
||||||
|
@ -95,8 +95,8 @@ public slots:
|
|||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void changeColor(Ui::GraphicalItem *_ui);
|
void changeColor(Ui::GraphicalItem *_ui);
|
||||||
void changeCountState(Ui::GraphicalItem *_ui, int _state);
|
static void changeCountState(Ui::GraphicalItem *_ui, int _state);
|
||||||
void changeValue(Ui::GraphicalItem *_ui, int _state);
|
static void changeValue(Ui::GraphicalItem *_ui, int _state);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
GraphicalItemHelper *m_helper = nullptr;
|
GraphicalItemHelper *m_helper = nullptr;
|
||||||
|
@ -48,30 +48,9 @@ void GraphicalItemHelper::setParameters(const QString &_active, const QString &_
|
|||||||
|
|
||||||
// put images to pens if any otherwise set pen colors
|
// put images to pens if any otherwise set pen colors
|
||||||
// Images resize to content here as well
|
// Images resize to content here as well
|
||||||
if (isColor(_active)) {
|
m_activePen.setBrush(parseBrush(_active, _width, _height, QColor(0, 0, 0, 130)));
|
||||||
m_activePen.setBrush(QBrush(stringToColor(_active)));
|
m_inactivePen.setBrush(parseBrush(_inactive, _width, _height, QColor(255, 255, 255, 130)));
|
||||||
} else {
|
|
||||||
qCInfo(LOG_LIB) << "Found path, trying to load Pixmap from" << _active;
|
|
||||||
QPixmap pixmap = QPixmap(QUrl(_active).toLocalFile());
|
|
||||||
if (pixmap.isNull()) {
|
|
||||||
qCWarning(LOG_LIB) << "Invalid pixmap found" << _active;
|
|
||||||
m_activePen.setBrush(QBrush(QColor(0, 0, 0, 130)));
|
|
||||||
} else {
|
|
||||||
m_activePen.setBrush(QBrush(pixmap.scaled(_width, _height)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (isColor(_inactive)) {
|
|
||||||
m_inactivePen.setBrush(QBrush(stringToColor(_inactive)));
|
|
||||||
} else {
|
|
||||||
qCInfo(LOG_LIB) << "Found path, trying to load Pixmap from" << _inactive;
|
|
||||||
QPixmap pixmap = QPixmap(QUrl(_inactive).toLocalFile());
|
|
||||||
if (pixmap.isNull()) {
|
|
||||||
qCWarning(LOG_LIB) << "Invalid pixmap found" << _inactive;
|
|
||||||
m_inactivePen.setBrush(QBrush(QColor(255, 255, 255, 130)));
|
|
||||||
} else {
|
|
||||||
m_inactivePen.setBrush(QBrush(pixmap.scaled(_width, _height)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
m_width = _width;
|
m_width = _width;
|
||||||
m_height = _height;
|
m_height = _height;
|
||||||
m_count = _count;
|
m_count = _count;
|
||||||
@ -88,14 +67,14 @@ void GraphicalItemHelper::paintBars(const float _value)
|
|||||||
storeValue(_value);
|
storeValue(_value);
|
||||||
|
|
||||||
// default norms
|
// default norms
|
||||||
float normX = static_cast<float>(m_width) / static_cast<float>(m_values.count());
|
auto normX = static_cast<float>(m_width) / static_cast<float>(m_values.count());
|
||||||
auto normY = static_cast<float>(m_height - 1);
|
auto normY = static_cast<float>(m_height - 1);
|
||||||
// paint graph
|
// paint graph
|
||||||
for (int i = 0; i < m_values.count(); i++) {
|
for (auto i = 0; i < m_values.count(); ++i) {
|
||||||
float x = static_cast<float>(i) * normX;
|
auto x = static_cast<float>(i) * normX;
|
||||||
float y = 0.5f;
|
auto y = 0.5f;
|
||||||
float width = normX;
|
auto width = normX;
|
||||||
float height = m_values.at(i) * normY + 0.5f;
|
auto height = m_values.at(i) * normY + 0.5f;
|
||||||
m_scene->addRect(x, y, width, height, m_activePen, m_activePen.brush());
|
m_scene->addRect(x, y, width, height, m_activePen, m_activePen.brush());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -107,17 +86,16 @@ void GraphicalItemHelper::paintCircle(const float _percent)
|
|||||||
|
|
||||||
m_activePen.setWidth(1);
|
m_activePen.setWidth(1);
|
||||||
m_inactivePen.setWidth(1);
|
m_inactivePen.setWidth(1);
|
||||||
QGraphicsEllipseItem *circle;
|
|
||||||
// 16 is because of qt. From Qt documentation:
|
// 16 is because of qt. From Qt documentation:
|
||||||
// Returns the start angle for an ellipse segment in 16ths of a degree
|
// Returns the start angle for an ellipse segment in 16ths of a degree
|
||||||
|
|
||||||
// inactive
|
// inactive
|
||||||
circle = m_scene->addEllipse(0.0, 0.0, m_width, m_height, m_inactivePen, m_inactivePen.brush());
|
auto circle = m_scene->addEllipse(0.0, 0.0, m_width, m_height, m_inactivePen, m_inactivePen.brush());
|
||||||
circle->setSpanAngle(static_cast<int>(-(1.0f - _percent) * 360.0f * 16.0f));
|
circle->setSpanAngle(static_cast<int>(-(1.0 - _percent) * 360.0 * 16.0));
|
||||||
circle->setStartAngle(static_cast<int>(90.0f * 16.0f - _percent * 360.0f * 16.0f));
|
circle->setStartAngle(static_cast<int>(90.0 * 16.0 - _percent * 360.0 * 16.0));
|
||||||
// active
|
// active
|
||||||
circle = m_scene->addEllipse(0.0, 0.0, m_width, m_height, m_activePen, m_activePen.brush());
|
circle = m_scene->addEllipse(0.0, 0.0, m_width, m_height, m_activePen, m_activePen.brush());
|
||||||
circle->setSpanAngle(static_cast<int>(-_percent * 360.0f * 16.0f));
|
circle->setSpanAngle(static_cast<int>(-_percent * 360.0 * 16.0));
|
||||||
circle->setStartAngle(90 * 16);
|
circle->setStartAngle(90 * 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -132,16 +110,16 @@ void GraphicalItemHelper::paintGraph(const float _value)
|
|||||||
storeValue(_value);
|
storeValue(_value);
|
||||||
|
|
||||||
// default norms
|
// default norms
|
||||||
float normX = static_cast<float>(m_width) / static_cast<float>(m_values.count());
|
auto normX = static_cast<float>(m_width) / static_cast<float>(m_values.count());
|
||||||
auto normY = static_cast<float>(m_height - 1);
|
auto normY = static_cast<float>(m_height - 1);
|
||||||
// paint graph
|
// paint graph
|
||||||
for (int i = 0; i < m_values.count() - 1; i++) {
|
for (auto i = 0; i < m_values.count() - 1; ++i) {
|
||||||
// some magic here
|
// some magic here
|
||||||
auto value = static_cast<float>(i);
|
auto value = static_cast<float>(i);
|
||||||
float x1 = value * normX;
|
auto x1 = value * normX;
|
||||||
float y1 = m_values.at(i) * normY + 0.5f;
|
auto y1 = m_values.at(i) * normY + 0.5f;
|
||||||
float x2 = (value + 1) * normX;
|
auto x2 = (value + 1) * normX;
|
||||||
float y2 = m_values.at(i + 1) * normY + 0.5f;
|
auto y2 = m_values.at(i + 1) * normY + 0.5f;
|
||||||
m_scene->addLine(x1, y1, x2, y2, m_activePen);
|
m_scene->addLine(x1, y1, x2, y2, m_activePen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -200,7 +178,7 @@ QColor GraphicalItemHelper::stringToColor(const QString &_color)
|
|||||||
{
|
{
|
||||||
qCDebug(LOG_LIB) << "Color" << _color;
|
qCDebug(LOG_LIB) << "Color" << _color;
|
||||||
|
|
||||||
QStringList listColor = _color.split(',');
|
auto listColor = _color.split(',');
|
||||||
while (listColor.count() < 4)
|
while (listColor.count() < 4)
|
||||||
listColor.append("0");
|
listColor.append("0");
|
||||||
// remove prefix
|
// remove prefix
|
||||||
@ -216,6 +194,25 @@ QColor GraphicalItemHelper::stringToColor(const QString &_color)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QBrush GraphicalItemHelper::parseBrush(const QString &_input, const int _width, const int _height,
|
||||||
|
const QColor &_default)
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB) << "Input select" << _input;
|
||||||
|
|
||||||
|
if (isColor(_input)) {
|
||||||
|
return stringToColor(_input);
|
||||||
|
} else {
|
||||||
|
qCInfo(LOG_LIB) << "Found path, trying to load Pixmap from" << _input;
|
||||||
|
auto pixmap = QPixmap(QUrl(_input).toLocalFile());
|
||||||
|
if (!pixmap.isNull())
|
||||||
|
return pixmap.scaled(_width, _height);
|
||||||
|
}
|
||||||
|
|
||||||
|
qCWarning(LOG_LIB) << "Invalid pixmap found" << _input;
|
||||||
|
return _default;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void GraphicalItemHelper::storeValue(const float _value)
|
void GraphicalItemHelper::storeValue(const float _value)
|
||||||
{
|
{
|
||||||
qCDebug(LOG_LIB) << "Save value to array" << _value;
|
qCDebug(LOG_LIB) << "Save value to array" << _value;
|
||||||
|
@ -45,6 +45,7 @@ public:
|
|||||||
static QColor stringToColor(const QString &_color);
|
static QColor stringToColor(const QString &_color);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
static QBrush parseBrush(const QString &_input, const int _width, const int _height, const QColor &_default);
|
||||||
void storeValue(float _value);
|
void storeValue(float _value);
|
||||||
QGraphicsScene *m_scene = nullptr;
|
QGraphicsScene *m_scene = nullptr;
|
||||||
int m_count = 100;
|
int m_count = 100;
|
||||||
|
@ -46,6 +46,7 @@ void OWMWeatherProvider::initUrl(const QString &_city, const QString &_country,
|
|||||||
m_url = QUrl(OWM_WEATHER_URL);
|
m_url = QUrl(OWM_WEATHER_URL);
|
||||||
else
|
else
|
||||||
m_url = QUrl(OWM_FORECAST_URL);
|
m_url = QUrl(OWM_FORECAST_URL);
|
||||||
|
|
||||||
QUrlQuery params;
|
QUrlQuery params;
|
||||||
params.addQueryItem("q", QString("%1,%2").arg(_city, _country));
|
params.addQueryItem("q", QString("%1,%2").arg(_city, _country));
|
||||||
params.addQueryItem("units", "metric");
|
params.addQueryItem("units", "metric");
|
||||||
@ -59,7 +60,7 @@ QVariantHash OWMWeatherProvider::parse(const QVariantMap &_json) const
|
|||||||
|
|
||||||
if (_json["cod"].toInt() != 200) {
|
if (_json["cod"].toInt() != 200) {
|
||||||
qCWarning(LOG_LIB) << "Invalid OpenWeatherMap return code" << _json["cod"].toInt();
|
qCWarning(LOG_LIB) << "Invalid OpenWeatherMap return code" << _json["cod"].toInt();
|
||||||
return QVariantHash();
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_ts == 0) {
|
if (m_ts == 0) {
|
||||||
@ -84,14 +85,14 @@ QVariantHash OWMWeatherProvider::parseSingleJson(const QVariantMap &_json) const
|
|||||||
QVariantHash output;
|
QVariantHash output;
|
||||||
|
|
||||||
// weather status
|
// weather status
|
||||||
QVariantList weather = _json["weather"].toList();
|
auto weather = _json["weather"].toList();
|
||||||
if (!weather.isEmpty()) {
|
if (!weather.isEmpty()) {
|
||||||
int id = weather.first().toMap()["id"].toInt();
|
int id = weather.first().toMap()["id"].toInt();
|
||||||
output[tag("weatherId")] = id;
|
output[tag("weatherId")] = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
// main data
|
// main data
|
||||||
QVariantMap mainWeather = _json["main"].toMap();
|
auto mainWeather = _json["main"].toMap();
|
||||||
if (!weather.isEmpty()) {
|
if (!weather.isEmpty()) {
|
||||||
output[tag("humidity")] = mainWeather["humidity"].toDouble();
|
output[tag("humidity")] = mainWeather["humidity"].toDouble();
|
||||||
output[tag("pressure")] = mainWeather["pressure"].toDouble();
|
output[tag("pressure")] = mainWeather["pressure"].toDouble();
|
||||||
|
@ -51,7 +51,7 @@ void QCronScheduler::parse(const QString &_timer)
|
|||||||
{
|
{
|
||||||
qCDebug(LOG_LIB) << "Parse timer string" << _timer;
|
qCDebug(LOG_LIB) << "Parse timer string" << _timer;
|
||||||
|
|
||||||
QStringList fields = _timer.split(' ');
|
auto fields = _timer.split(' ');
|
||||||
if (fields.count() != 5)
|
if (fields.count() != 5)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -65,7 +65,7 @@ void QCronScheduler::parse(const QString &_timer)
|
|||||||
|
|
||||||
void QCronScheduler::expired()
|
void QCronScheduler::expired()
|
||||||
{
|
{
|
||||||
QDateTime now = QDateTime::currentDateTime();
|
auto now = QDateTime::currentDateTime();
|
||||||
|
|
||||||
if (m_schedule.minutes.contains(now.time().minute()) && m_schedule.hours.contains(now.time().hour())
|
if (m_schedule.minutes.contains(now.time().minute()) && m_schedule.hours.contains(now.time().hour())
|
||||||
&& m_schedule.days.contains(now.date().day()) && m_schedule.months.contains(now.date().month())
|
&& m_schedule.days.contains(now.date().day()) && m_schedule.months.contains(now.date().month())
|
||||||
@ -122,7 +122,7 @@ void QCronScheduler::QCronField::fromRange(const QString &_range, const int _min
|
|||||||
std::swap(minValue, maxValue);
|
std::swap(minValue, maxValue);
|
||||||
} else {
|
} else {
|
||||||
bool status;
|
bool status;
|
||||||
int value = _range.toInt(&status);
|
auto value = _range.toInt(&status);
|
||||||
if (!status || (value < _min) || (value > _max))
|
if (!status || (value < _min) || (value > _max))
|
||||||
value = -1;
|
value = -1;
|
||||||
minValue = value;
|
minValue = value;
|
||||||
@ -131,14 +131,14 @@ void QCronScheduler::QCronField::fromRange(const QString &_range, const int _min
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QList<int> QCronScheduler::QCronField::toList()
|
QList<int> QCronScheduler::QCronField::toList() const
|
||||||
{
|
{
|
||||||
// error checking
|
// error checking
|
||||||
if ((minValue == -1) || (maxValue == -1))
|
if ((minValue == -1) || (maxValue == -1))
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
QList<int> output;
|
QList<int> output;
|
||||||
for (auto &i = minValue; i <= maxValue; ++i) {
|
for (auto i = minValue; i <= maxValue; ++i) {
|
||||||
if (i % div != 0)
|
if (i % div != 0)
|
||||||
continue;
|
continue;
|
||||||
output.append(i);
|
output.append(i);
|
||||||
|
@ -39,7 +39,7 @@ public:
|
|||||||
int maxValue = -1;
|
int maxValue = -1;
|
||||||
int div = 1;
|
int div = 1;
|
||||||
void fromRange(const QString &_range, int _min, int _max);
|
void fromRange(const QString &_range, int _min, int _max);
|
||||||
QList<int> toList();
|
QList<int> toList() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
explicit QCronScheduler(QObject *_parent = nullptr);
|
explicit QCronScheduler(QObject *_parent = nullptr);
|
||||||
|
@ -40,6 +40,7 @@ void StooqQuotesProvider::initUrl(const QString &_asset)
|
|||||||
qCDebug(LOG_LIB) << "Init query for" << _asset;
|
qCDebug(LOG_LIB) << "Init query for" << _asset;
|
||||||
|
|
||||||
m_url = QUrl(STOOQ_QUOTES_URL);
|
m_url = QUrl(STOOQ_QUOTES_URL);
|
||||||
|
|
||||||
QUrlQuery params;
|
QUrlQuery params;
|
||||||
params.addQueryItem("s", _asset);
|
params.addQueryItem("s", _asset);
|
||||||
params.addQueryItem("f", "pv");
|
params.addQueryItem("f", "pv");
|
||||||
|
@ -41,6 +41,7 @@ void YahooQuotesProvider::initUrl(const QString &_asset)
|
|||||||
qCDebug(LOG_LIB) << "Init query for" << _asset;
|
qCDebug(LOG_LIB) << "Init query for" << _asset;
|
||||||
|
|
||||||
m_url = QUrl(YAHOO_QUOTES_URL);
|
m_url = QUrl(YAHOO_QUOTES_URL);
|
||||||
|
|
||||||
QUrlQuery params;
|
QUrlQuery params;
|
||||||
params.addQueryItem("format", "json");
|
params.addQueryItem("format", "json");
|
||||||
params.addQueryItem("env", "store://datatables.org/alltableswithkeys");
|
params.addQueryItem("env", "store://datatables.org/alltableswithkeys");
|
||||||
@ -56,12 +57,12 @@ QVariantHash YahooQuotesProvider::parse(const QByteArray &_source, const QVarian
|
|||||||
QVariantHash values;
|
QVariantHash values;
|
||||||
|
|
||||||
QJsonParseError error{};
|
QJsonParseError error{};
|
||||||
QJsonDocument jsonDoc = QJsonDocument::fromJson(_source, &error);
|
auto jsonDoc = QJsonDocument::fromJson(_source, &error);
|
||||||
if (error.error != QJsonParseError::NoError) {
|
if (error.error != QJsonParseError::NoError) {
|
||||||
qCWarning(LOG_LIB) << "Parse error" << error.errorString();
|
qCWarning(LOG_LIB) << "Parse error" << error.errorString();
|
||||||
return values;
|
return values;
|
||||||
}
|
}
|
||||||
QVariantMap jsonQuotes = jsonDoc.toVariant().toMap()["query"].toMap();
|
auto jsonQuotes = jsonDoc.toVariant().toMap()["query"].toMap();
|
||||||
jsonQuotes = jsonQuotes["results"].toMap()["quote"].toMap();
|
jsonQuotes = jsonQuotes["results"].toMap()["quote"].toMap();
|
||||||
|
|
||||||
// extract old data
|
// extract old data
|
||||||
|
@ -42,6 +42,7 @@ void YahooWeatherProvider::initUrl(const QString &_city, const QString &_country
|
|||||||
m_ts = ts;
|
m_ts = ts;
|
||||||
|
|
||||||
m_url = QUrl(YAHOO_WEATHER_URL);
|
m_url = QUrl(YAHOO_WEATHER_URL);
|
||||||
|
|
||||||
QUrlQuery params;
|
QUrlQuery params;
|
||||||
params.addQueryItem("format", "json");
|
params.addQueryItem("format", "json");
|
||||||
params.addQueryItem("env", "store://datatables.org/alltableswithkeys");
|
params.addQueryItem("env", "store://datatables.org/alltableswithkeys");
|
||||||
@ -54,14 +55,14 @@ QVariantHash YahooWeatherProvider::parse(const QVariantMap &_json) const
|
|||||||
{
|
{
|
||||||
qCDebug(LOG_LIB) << "Parse json" << _json;
|
qCDebug(LOG_LIB) << "Parse json" << _json;
|
||||||
|
|
||||||
QVariantMap jsonMap = _json["query"].toMap();
|
auto jsonMap = _json["query"].toMap();
|
||||||
if (jsonMap["count"].toInt() != 1) {
|
if (jsonMap["count"].toInt() != 1) {
|
||||||
qCWarning(LOG_LIB) << "Found data count" << _json["count"].toInt() << "is not 1";
|
qCWarning(LOG_LIB) << "Found data count" << _json["count"].toInt() << "is not 1";
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
QVariantMap results = jsonMap["results"].toMap()["channel"].toMap();
|
auto results = jsonMap["results"].toMap()["channel"].toMap();
|
||||||
QVariantMap item = results["item"].toMap();
|
auto item = results["item"].toMap();
|
||||||
QVariantMap atmosphere = results["atmosphere"].toMap();
|
auto atmosphere = results["atmosphere"].toMap();
|
||||||
|
|
||||||
return m_ts == 0 ? parseCurrent(item, atmosphere) : parseForecast(item);
|
return m_ts == 0 ? parseCurrent(item, atmosphere) : parseForecast(item);
|
||||||
}
|
}
|
||||||
@ -80,7 +81,7 @@ QVariantHash YahooWeatherProvider::parseCurrent(const QVariantMap &_json, const
|
|||||||
auto condition = _json["condition"].toMap();
|
auto condition = _json["condition"].toMap();
|
||||||
|
|
||||||
QVariantHash values;
|
QVariantHash values;
|
||||||
int id = _json["condition"].toMap()["code"].toInt();
|
auto id = _json["condition"].toMap()["code"].toInt();
|
||||||
values[tag("weatherId")] = id;
|
values[tag("weatherId")] = id;
|
||||||
values[tag("temperature")] = condition["temp"].toInt();
|
values[tag("temperature")] = condition["temp"].toInt();
|
||||||
values[tag("timestamp")] = condition["date"].toString();
|
values[tag("timestamp")] = condition["date"].toString();
|
||||||
@ -97,9 +98,9 @@ QVariantHash YahooWeatherProvider::parseForecast(const QVariantMap &_json) const
|
|||||||
qCDebug(LOG_LIB) << "Parse forecast from" << _json;
|
qCDebug(LOG_LIB) << "Parse forecast from" << _json;
|
||||||
|
|
||||||
QVariantHash values;
|
QVariantHash values;
|
||||||
QVariantList weatherList = _json["forecast"].toList();
|
auto weatherList = _json["forecast"].toList();
|
||||||
QVariantMap weatherMap = weatherList.count() < m_ts ? weatherList.last().toMap() : weatherList.at(m_ts).toMap();
|
auto weatherMap = weatherList.count() < m_ts ? weatherList.last().toMap() : weatherList.at(m_ts).toMap();
|
||||||
int id = weatherMap["code"].toInt();
|
auto id = weatherMap["code"].toInt();
|
||||||
values[tag("weatherId")] = id;
|
values[tag("weatherId")] = id;
|
||||||
values[tag("timestamp")] = weatherMap["date"].toString();
|
values[tag("timestamp")] = weatherMap["date"].toString();
|
||||||
// yahoo provides high and low temperatures. Lets calculate average one
|
// yahoo provides high and low temperatures. Lets calculate average one
|
||||||
|
@ -101,12 +101,12 @@ QString DPAdds::toolTipImage(const int _desktop) const
|
|||||||
return "";
|
return "";
|
||||||
|
|
||||||
// prepare
|
// prepare
|
||||||
DesktopWindowsInfo info = getInfoByDesktop(_desktop);
|
auto info = getInfoByDesktop(_desktop);
|
||||||
// special tooltip format for names
|
// special tooltip format for names
|
||||||
if (m_tooltipType == "names") {
|
if (m_tooltipType == "names") {
|
||||||
QStringList windowList;
|
QStringList windowList;
|
||||||
std::for_each(info.windowsData.cbegin(), info.windowsData.cend(),
|
std::for_each(info.windowsData.cbegin(), info.windowsData.cend(),
|
||||||
[&windowList](const WindowData &data) { windowList.append(data.name); });
|
[&windowList](auto &data) { windowList.append(data.name); });
|
||||||
return QString("<ul><li>%1</li></ul>").arg(windowList.join("</li><li>"));
|
return QString("<ul><li>%1</li></ul>").arg(windowList.join("</li><li>"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,16 +120,14 @@ QString DPAdds::toolTipImage(const int _desktop) const
|
|||||||
toolTipView->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
toolTipView->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||||
|
|
||||||
auto screens = QGuiApplication::screens();
|
auto screens = QGuiApplication::screens();
|
||||||
auto desktop
|
auto desktop = std::accumulate(screens.cbegin(), screens.cend(), QRect(0, 0, 0, 0),
|
||||||
= std::accumulate(screens.cbegin(), screens.cend(), QRect(0, 0, 0, 0), [](QRect source, const QScreen *screen) {
|
[](auto source, auto screen) { return source.united(screen->availableGeometry()); });
|
||||||
return source.united(screen->availableGeometry());
|
|
||||||
});
|
|
||||||
|
|
||||||
// update
|
// update
|
||||||
auto width = static_cast<float>(desktop.width());
|
auto width = static_cast<float>(desktop.width());
|
||||||
auto height = static_cast<float>(desktop.height());
|
auto height = static_cast<float>(desktop.height());
|
||||||
float margin = 5.0f * width / 400.0f;
|
auto margin = 5.0 * width / 400.0;
|
||||||
toolTipView->resize(static_cast<int>(width + 2.0f * margin), static_cast<int>(height + 2.0f * margin));
|
toolTipView->resize(static_cast<int>(width + 2.0 * margin), static_cast<int>(height + 2.0 * margin));
|
||||||
toolTipScene->clear();
|
toolTipScene->clear();
|
||||||
toolTipScene->setBackgroundBrush(QBrush(Qt::NoBrush));
|
toolTipScene->setBackgroundBrush(QBrush(Qt::NoBrush));
|
||||||
// borders
|
// borders
|
||||||
@ -139,22 +137,24 @@ QString DPAdds::toolTipImage(const int _desktop) const
|
|||||||
toolTipScene->addLine(width + 2.0 * margin, 0, 0, 0);
|
toolTipScene->addLine(width + 2.0 * margin, 0, 0, 0);
|
||||||
|
|
||||||
// with wayland countours only are supported
|
// with wayland countours only are supported
|
||||||
QPen pen = QPen();
|
auto pen = QPen();
|
||||||
pen.setWidthF(2.0 * width / 400.0);
|
pen.setWidthF(2.0 * width / 400.0);
|
||||||
pen.setColor(QColor(m_tooltipColor));
|
pen.setColor(QColor(m_tooltipColor));
|
||||||
for (auto &data : info.windowsData) {
|
for (auto &data : info.windowsData) {
|
||||||
QRect rect = data.rect;
|
auto rect = data.rect;
|
||||||
|
|
||||||
auto left = static_cast<float>(rect.left());
|
auto left = static_cast<float>(rect.left());
|
||||||
auto right = static_cast<float>(rect.right());
|
auto right = static_cast<float>(rect.right());
|
||||||
auto top = static_cast<float>(rect.top());
|
auto top = static_cast<float>(rect.top());
|
||||||
auto bottom = static_cast<float>(rect.bottom());
|
auto bottom = static_cast<float>(rect.bottom());
|
||||||
|
|
||||||
toolTipScene->addLine(left + margin, bottom + margin, left + margin, top + margin, pen);
|
toolTipScene->addLine(left + margin, bottom + margin, left + margin, top + margin, pen);
|
||||||
toolTipScene->addLine(left + margin, top + margin, right + margin, top + margin, pen);
|
toolTipScene->addLine(left + margin, top + margin, right + margin, top + margin, pen);
|
||||||
toolTipScene->addLine(right + margin, top + margin, right + margin, bottom + margin, pen);
|
toolTipScene->addLine(right + margin, top + margin, right + margin, bottom + margin, pen);
|
||||||
toolTipScene->addLine(right + margin, bottom + margin, left + margin, bottom + margin, pen);
|
toolTipScene->addLine(right + margin, bottom + margin, left + margin, bottom + margin, pen);
|
||||||
}
|
}
|
||||||
|
|
||||||
QPixmap image = toolTipView->grab().scaledToWidth(m_tooltipWidth);
|
auto image = toolTipView->grab().scaledToWidth(m_tooltipWidth);
|
||||||
QByteArray byteArray;
|
QByteArray byteArray;
|
||||||
QBuffer buffer(&byteArray);
|
QBuffer buffer(&byteArray);
|
||||||
image.save(&buffer, "PNG");
|
image.save(&buffer, "PNG");
|
||||||
@ -170,7 +170,7 @@ QString DPAdds::parsePattern(const QString &_pattern, const int _desktop) const
|
|||||||
{
|
{
|
||||||
qCDebug(LOG_DP) << "Pattern" << _pattern << "for desktop" << _desktop;
|
qCDebug(LOG_DP) << "Pattern" << _pattern << "for desktop" << _desktop;
|
||||||
|
|
||||||
QString parsed = _pattern;
|
auto parsed = _pattern;
|
||||||
parsed.replace("$$", "$\\$\\");
|
parsed.replace("$$", "$\\$\\");
|
||||||
for (auto &key : dictKeys())
|
for (auto &key : dictKeys())
|
||||||
parsed.replace(QString("$%1").arg(key), valueByKey(key, _desktop));
|
parsed.replace(QString("$%1").arg(key), valueByKey(key, _desktop));
|
||||||
@ -212,7 +212,7 @@ QString DPAdds::valueByKey(const QString &_key, int _desktop) const
|
|||||||
if (_desktop == -1)
|
if (_desktop == -1)
|
||||||
_desktop = currentDesktop();
|
_desktop = currentDesktop();
|
||||||
|
|
||||||
QString currentMark = currentDesktop() == _desktop ? m_mark : "";
|
auto currentMark = currentDesktop() == _desktop ? m_mark : "";
|
||||||
if (_key == "mark")
|
if (_key == "mark")
|
||||||
return QString("%1").arg(currentMark, m_mark.size(), QLatin1Char(' ')).replace(" ", " ");
|
return QString("%1").arg(currentMark, m_mark.size(), QLatin1Char(' ')).replace(" ", " ");
|
||||||
else if (_key == "name") {
|
else if (_key == "name") {
|
||||||
@ -241,10 +241,10 @@ QVariantMap DPAdds::getFont(const QVariantMap &_defaultFont)
|
|||||||
qCDebug(LOG_DP) << "Default font is" << _defaultFont;
|
qCDebug(LOG_DP) << "Default font is" << _defaultFont;
|
||||||
|
|
||||||
QVariantMap fontMap;
|
QVariantMap fontMap;
|
||||||
int ret = 0;
|
auto ret = 0;
|
||||||
CFont defaultCFont = CFont(_defaultFont["family"].toString(), _defaultFont["size"].toInt(), 400, false,
|
auto defaultCFont = CFont(_defaultFont["family"].toString(), _defaultFont["size"].toInt(), 400, false,
|
||||||
_defaultFont["color"].toString());
|
_defaultFont["color"].toString());
|
||||||
CFont font = CFontDialog::getFont(i18n("Select font"), defaultCFont, false, false, &ret);
|
auto font = CFontDialog::getFont(i18n("Select font"), defaultCFont, false, false, &ret);
|
||||||
|
|
||||||
fontMap["applied"] = ret;
|
fontMap["applied"] = ret;
|
||||||
fontMap["color"] = font.color().name();
|
fontMap["color"] = font.color().name();
|
||||||
@ -260,8 +260,7 @@ void DPAdds::sendNotification(const QString &_eventId, const QString &_message)
|
|||||||
{
|
{
|
||||||
qCDebug(LOG_DP) << "Event" << _eventId << "with message" << _message;
|
qCDebug(LOG_DP) << "Event" << _eventId << "with message" << _message;
|
||||||
|
|
||||||
KNotification *notification
|
auto notification = KNotification::event(_eventId, QString("Desktop Panel ::: %1").arg(_eventId), _message);
|
||||||
= KNotification::event(_eventId, QString("Desktop Panel ::: %1").arg(_eventId), _message);
|
|
||||||
notification->setComponentName("plasma-applet-org.kde.plasma.desktop-panel");
|
notification->setComponentName("plasma-applet-org.kde.plasma.desktop-panel");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -282,7 +281,7 @@ DPAdds::DesktopWindowsInfo DPAdds::getInfoByDesktop(const int _desktop) const
|
|||||||
auto desktop = m_vdi->desktopIds().at(_desktop);
|
auto desktop = m_vdi->desktopIds().at(_desktop);
|
||||||
|
|
||||||
DesktopWindowsInfo info;
|
DesktopWindowsInfo info;
|
||||||
for (auto i = 0; i < m_taskModel->rowCount(); i++) {
|
for (auto i = 0; i < m_taskModel->rowCount(); ++i) {
|
||||||
auto model = m_taskModel->index(i, 0);
|
auto model = m_taskModel->index(i, 0);
|
||||||
WindowData data;
|
WindowData data;
|
||||||
|
|
||||||
|
@ -27,6 +27,7 @@ namespace TaskManager
|
|||||||
class VirtualDesktopInfo;
|
class VirtualDesktopInfo;
|
||||||
class WindowTasksModel;
|
class WindowTasksModel;
|
||||||
} // namespace TaskManager
|
} // namespace TaskManager
|
||||||
|
|
||||||
class DPAdds : public QObject
|
class DPAdds : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -55,18 +55,18 @@ public:
|
|||||||
return item ? item->run() : QVariantHash();
|
return item ? item->run() : QVariantHash();
|
||||||
}
|
}
|
||||||
|
|
||||||
static KSysGuard::SensorInfo *makeSensorInfo(const QString &_name, const QVariant::Type type,
|
static KSysGuard::SensorInfo *makeSensorInfo(const QString &_name, const QVariant::Type _type,
|
||||||
const KSysGuard::Unit unit = KSysGuard::UnitNone, const double min = 0,
|
const KSysGuard::Unit _unit = KSysGuard::UnitNone,
|
||||||
const double max = 0)
|
const double _min = 0, const double _max = 0)
|
||||||
{
|
{
|
||||||
auto info = new KSysGuard::SensorInfo();
|
auto info = new KSysGuard::SensorInfo();
|
||||||
info->name = _name;
|
info->name = _name;
|
||||||
info->variantType = type;
|
info->variantType = _type;
|
||||||
|
|
||||||
info->unit = unit;
|
info->unit = _unit;
|
||||||
|
|
||||||
info->min = min;
|
info->min = _min;
|
||||||
info->max = max;
|
info->max = _max;
|
||||||
|
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ QHash<QString, KSysGuard::SensorInfo *> CustomSource::sources() const
|
|||||||
{
|
{
|
||||||
auto result = QHash<QString, KSysGuard::SensorInfo *>();
|
auto result = QHash<QString, KSysGuard::SensorInfo *>();
|
||||||
|
|
||||||
for (auto &item : m_extScripts->activeItems())
|
for (auto item : m_extScripts->activeItems())
|
||||||
result.insert(item->tag("custom"),
|
result.insert(item->tag("custom"),
|
||||||
makeSensorInfo(QString("Custom command '%1' output").arg(item->uniq()), QVariant::String));
|
makeSensorInfo(QString("Custom command '%1' output").arg(item->uniq()), QVariant::String));
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ QHash<QString, KSysGuard::SensorInfo *> QuotesSource::sources() const
|
|||||||
{
|
{
|
||||||
auto result = QHash<QString, KSysGuard::SensorInfo *>();
|
auto result = QHash<QString, KSysGuard::SensorInfo *>();
|
||||||
|
|
||||||
for (auto &item : m_extQuotes->activeItems()) {
|
for (auto item : m_extQuotes->activeItems()) {
|
||||||
result.insert(item->tag("pricechg"),
|
result.insert(item->tag("pricechg"),
|
||||||
makeSensorInfo(QString("Absolute price changes for '%1'").arg(item->uniq()), QVariant::Double));
|
makeSensorInfo(QString("Absolute price changes for '%1'").arg(item->uniq()), QVariant::Double));
|
||||||
result.insert(item->tag("price"),
|
result.insert(item->tag("price"),
|
||||||
|
@ -44,7 +44,7 @@ QHash<QString, KSysGuard::SensorInfo *> RequestSource::sources() const
|
|||||||
{
|
{
|
||||||
auto result = QHash<QString, KSysGuard::SensorInfo *>();
|
auto result = QHash<QString, KSysGuard::SensorInfo *>();
|
||||||
|
|
||||||
for (auto &item : m_extNetRequest->activeItems())
|
for (auto item : m_extNetRequest->activeItems())
|
||||||
result.insert(item->tag("response"),
|
result.insert(item->tag("response"),
|
||||||
makeSensorInfo(QString("Network response for %1").arg(item->uniq()), QVariant::String));
|
makeSensorInfo(QString("Network response for %1").arg(item->uniq()), QVariant::String));
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ QHash<QString, KSysGuard::SensorInfo *> UpgradeSource::sources() const
|
|||||||
{
|
{
|
||||||
auto result = QHash<QString, KSysGuard::SensorInfo *>();
|
auto result = QHash<QString, KSysGuard::SensorInfo *>();
|
||||||
|
|
||||||
for (auto &item : m_extUpgrade->activeItems())
|
for (auto item : m_extUpgrade->activeItems())
|
||||||
result.insert(item->tag("pkgcount"),
|
result.insert(item->tag("pkgcount"),
|
||||||
makeSensorInfo(QString("Package manager '%1' metadata").arg(item->uniq()), QVariant::Int));
|
makeSensorInfo(QString("Package manager '%1' metadata").arg(item->uniq()), QVariant::Int));
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ QHash<QString, KSysGuard::SensorInfo *> WeatherSource::sources() const
|
|||||||
{
|
{
|
||||||
auto result = QHash<QString, KSysGuard::SensorInfo *>();
|
auto result = QHash<QString, KSysGuard::SensorInfo *>();
|
||||||
|
|
||||||
for (auto &item : m_extWeather->activeItems()) {
|
for (auto item : m_extWeather->activeItems()) {
|
||||||
result.insert(item->tag("weatherId"), makeSensorInfo(QString("Numeric weather ID for '%1'").arg(item->uniq()),
|
result.insert(item->tag("weatherId"), makeSensorInfo(QString("Numeric weather ID for '%1'").arg(item->uniq()),
|
||||||
QVariant::Int, KSysGuard::UnitNone, 0, 1000));
|
QVariant::Int, KSysGuard::UnitNone, 0, 1000));
|
||||||
result.insert(item->tag("weather"),
|
result.insert(item->tag("weather"),
|
||||||
|
@ -27,14 +27,14 @@ void TestAbstractExtItem::initTestCase()
|
|||||||
{
|
{
|
||||||
AWTestLibrary::init();
|
AWTestLibrary::init();
|
||||||
auto names = AWTestLibrary::randomFilenames();
|
auto names = AWTestLibrary::randomFilenames();
|
||||||
fileName = names.first;
|
filePath = names.first;
|
||||||
writeFileName = names.second;
|
writeFilePath = names.second;
|
||||||
|
|
||||||
name = AWTestLibrary::randomString();
|
name = AWTestLibrary::randomString();
|
||||||
comment = AWTestLibrary::randomString();
|
comment = AWTestLibrary::randomString();
|
||||||
socket = AWTestLibrary::randomString();
|
socket = AWTestLibrary::randomString();
|
||||||
|
|
||||||
extItem = new ExtUpgrade(nullptr, fileName);
|
extItem = new ExtUpgrade(nullptr, filePath);
|
||||||
extItem->setActive(false);
|
extItem->setActive(false);
|
||||||
extItem->setApiVersion(1);
|
extItem->setApiVersion(1);
|
||||||
extItem->setComment(comment);
|
extItem->setComment(comment);
|
||||||
@ -47,7 +47,7 @@ void TestAbstractExtItem::initTestCase()
|
|||||||
|
|
||||||
void TestAbstractExtItem::cleanupTestCase()
|
void TestAbstractExtItem::cleanupTestCase()
|
||||||
{
|
{
|
||||||
QFile::remove(fileName);
|
QFile::remove(filePath);
|
||||||
delete extItem;
|
delete extItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,16 +57,16 @@ void TestAbstractExtItem::test_values()
|
|||||||
QCOMPARE(extItem->isActive(), false);
|
QCOMPARE(extItem->isActive(), false);
|
||||||
QCOMPARE(extItem->apiVersion(), 1);
|
QCOMPARE(extItem->apiVersion(), 1);
|
||||||
QCOMPARE(extItem->comment(), comment);
|
QCOMPARE(extItem->comment(), comment);
|
||||||
QCOMPARE(extItem->fileName(), fileName);
|
QCOMPARE(extItem->filePath(), filePath);
|
||||||
QCOMPARE(extItem->name(), name);
|
QCOMPARE(extItem->name(), name);
|
||||||
QVERIFY((extItem->number() > 0) && (extItem->number() < 1000));
|
QVERIFY((extItem->number() > 0) && (extItem->number() < 1000));
|
||||||
QCOMPARE(extItem->socket(), socket);
|
QCOMPARE(extItem->socket(), socket);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void TestAbstractExtItem::test_writtableFile()
|
void TestAbstractExtItem::test_writableFile()
|
||||||
{
|
{
|
||||||
QCOMPARE(extItem->writtableConfig(), writeFileName);
|
QCOMPARE(extItem->writableConfig(), writeFilePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -74,10 +74,10 @@ void TestAbstractExtItem::test_configuration()
|
|||||||
{
|
{
|
||||||
extItem->writeConfiguration();
|
extItem->writeConfiguration();
|
||||||
|
|
||||||
auto newExtItem = new ExtUpgrade(nullptr, writeFileName);
|
auto newExtItem = new ExtUpgrade(nullptr, writeFilePath);
|
||||||
QCOMPARE(newExtItem->isActive(), extItem->isActive());
|
QCOMPARE(newExtItem->isActive(), extItem->isActive());
|
||||||
QCOMPARE(newExtItem->comment(), extItem->comment());
|
QCOMPARE(newExtItem->comment(), extItem->comment());
|
||||||
QCOMPARE(newExtItem->fileName(), writeFileName);
|
QCOMPARE(newExtItem->filePath(), writeFilePath);
|
||||||
QCOMPARE(newExtItem->name(), extItem->name());
|
QCOMPARE(newExtItem->name(), extItem->name());
|
||||||
QCOMPARE(newExtItem->number(), extItem->number());
|
QCOMPARE(newExtItem->number(), extItem->number());
|
||||||
QCOMPARE(newExtItem->socket(), extItem->socket());
|
QCOMPARE(newExtItem->socket(), extItem->socket());
|
||||||
@ -97,10 +97,10 @@ void TestAbstractExtItem::test_bumpApi()
|
|||||||
|
|
||||||
void TestAbstractExtItem::test_delete()
|
void TestAbstractExtItem::test_delete()
|
||||||
{
|
{
|
||||||
auto newExtItem = new ExtUpgrade(nullptr, writeFileName);
|
auto newExtItem = new ExtUpgrade(nullptr, writeFilePath);
|
||||||
|
|
||||||
QVERIFY(newExtItem->tryDelete());
|
QVERIFY(newExtItem->tryDelete());
|
||||||
QVERIFY(!QFile::exists(writeFileName));
|
QVERIFY(!QFile::exists(writeFilePath));
|
||||||
|
|
||||||
delete newExtItem;
|
delete newExtItem;
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ private slots:
|
|||||||
void cleanupTestCase();
|
void cleanupTestCase();
|
||||||
// test
|
// test
|
||||||
void test_values();
|
void test_values();
|
||||||
void test_writtableFile();
|
void test_writableFile();
|
||||||
void test_configuration();
|
void test_configuration();
|
||||||
void test_bumpApi();
|
void test_bumpApi();
|
||||||
void test_delete();
|
void test_delete();
|
||||||
@ -44,6 +44,6 @@ private:
|
|||||||
QString cron = "* * * * *";
|
QString cron = "* * * * *";
|
||||||
QString name;
|
QString name;
|
||||||
QString socket;
|
QString socket;
|
||||||
QString fileName;
|
QString filePath;
|
||||||
QString writeFileName;
|
QString writeFilePath;
|
||||||
};
|
};
|
||||||
|
@ -41,7 +41,7 @@ void TestAWJsonFormatter::cleanupTestCase()
|
|||||||
|
|
||||||
void TestAWJsonFormatter::test_values()
|
void TestAWJsonFormatter::test_values()
|
||||||
{
|
{
|
||||||
QCOMPARE(formatter->path(), path);
|
QCOMPARE(formatter->path(), QString(".%1").arg(path));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user