changes in Extensions ABI

* rewrite aggregator to normal qt ui
* use X-AW prefix for formatters options
* fix logging
* use nullptr in headers
This commit is contained in:
Evgenii Alekseev 2016-05-13 13:23:25 +03:00
parent 326c65528d
commit 51c7299ad0
25 changed files with 186 additions and 117 deletions

View File

@ -295,7 +295,7 @@ void AWConfigHelper::readFile(QSettings &settings, const QString key,
file.close(); file.close();
settings.setValue(key, text); settings.setValue(key, text);
} else { } else {
qCWarning(LOG_LIB) << "Could not open" << file.fileName(); qCWarning(LOG_AW) << "Could not open" << file.fileName();
} }
} }
@ -316,6 +316,6 @@ void AWConfigHelper::writeFile(QSettings &settings, const QString key,
out.flush(); out.flush();
file.close(); file.close();
} else { } else {
qCWarning(LOG_LIB) << "Could not open" << file.fileName(); qCWarning(LOG_AW) << "Could not open" << file.fileName();
} }
} }

View File

@ -119,8 +119,8 @@ void AWFormatterHelper::initFormatters()
for (auto file : files) { for (auto file : files) {
if (!file.endsWith(QString(".desktop"))) if (!file.endsWith(QString(".desktop")))
continue; continue;
qCInfo(LOG_LIB) << "Found file" << file << "in" qCInfo(LOG_AW) << "Found file" << file << "in"
<< m_directories.at(i); << m_directories.at(i);
QString filePath QString filePath
= QString("%1/%2").arg(m_directories.at(i)).arg(file); = QString("%1/%2").arg(m_directories.at(i)).arg(file);
auto metadata = readMetadata(filePath); auto metadata = readMetadata(filePath);
@ -161,6 +161,10 @@ void AWFormatterHelper::initKeys()
for (auto key : keys) { for (auto key : keys) {
QString name = settings.value(key).toString(); QString name = settings.value(key).toString();
qCInfo(LOG_AW) << "Found formatter" << name << "for key" << key; qCInfo(LOG_AW) << "Found formatter" << name << "for key" << key;
if (!m_formattersClasses.contains(name)) {
qCWarning(LOG_AW) << "Invalid formatter" << name << "found in"
<< key;
}
m_formatters[key] = m_formattersClasses[name]; m_formatters[key] = m_formattersClasses[name];
} }
settings.endGroup(); settings.endGroup();
@ -175,7 +179,7 @@ void AWFormatterHelper::installDirectories()
QStandardPaths::GenericDataLocation)); QStandardPaths::GenericDataLocation));
QDir localDirectory; QDir localDirectory;
if (localDirectory.mkpath(localDir)) if (localDirectory.mkpath(localDir))
qCInfo(LOG_LIB) << "Created directory" << localDir; qCInfo(LOG_AW) << "Created directory" << localDir;
m_directories = QStandardPaths::locateAll( m_directories = QStandardPaths::locateAll(
QStandardPaths::GenericDataLocation, QStandardPaths::GenericDataLocation,
@ -196,7 +200,7 @@ AWFormatterHelper::readMetadata(const QString filePath) const
settings.beginGroup(QString("Desktop Entry")); settings.beginGroup(QString("Desktop Entry"));
QString name = settings.value(QString("Name"), filePath).toString(); QString name = settings.value(QString("Name"), filePath).toString();
QString type QString type
= settings.value(QString("Type"), QString("NoFormat")).toString(); = settings.value(QString("X-AW-Type"), QString("NoFormat")).toString();
FormatterClass formatter = defineFormatterClass(type); FormatterClass formatter = defineFormatterClass(type);
settings.endGroup(); settings.endGroup();
@ -212,9 +216,12 @@ void AWFormatterHelper::doCreateItem()
bool ok; bool ok;
QString select = QInputDialog::getItem( QString select = QInputDialog::getItem(
this, i18n("Select type"), i18n("Type:"), selection, 0, false, &ok); this, i18n("Select type"), i18n("Type:"), selection, 0, false, &ok);
if (!ok) if (!ok) {
qCWarning(LOG_AW) << "No type selected";
return; return;
}
qCInfo(LOG_AW) << "Selected type" << select;
FormatterClass formatter = defineFormatterClass(select); FormatterClass formatter = defineFormatterClass(select);
switch (formatter) { switch (formatter) {
case FormatterClass::DateTime: case FormatterClass::DateTime:

View File

@ -198,7 +198,7 @@ void AbstractExtItem::readConfiguration()
bool AbstractExtItem::tryDelete() const bool AbstractExtItem::tryDelete() const
{ {
bool status = QFile::remove(m_fileName); bool status = QFile::remove(m_fileName);
qCInfo(LOG_AW) << "Remove file" << m_fileName << status; qCInfo(LOG_LIB) << "Remove file" << m_fileName << status;
return status; return status;
} }

View File

@ -16,41 +16,35 @@
***************************************************************************/ ***************************************************************************/
#include "abstractextitemaggregator.h" #include "abstractextitemaggregator.h"
#include "ui_abstractextitemaggregator.h"
#include <KI18n/KLocalizedString> #include <KI18n/KLocalizedString>
#include <QFileInfo> #include <QFileInfo>
#include <QHBoxLayout>
#include <QInputDialog> #include <QInputDialog>
#include <QLineEdit> #include <QPushButton>
AbstractExtItemAggregator::AbstractExtItemAggregator(QWidget *parent, AbstractExtItemAggregator::AbstractExtItemAggregator(QWidget *parent,
const QString type) const QString type)
: QWidget(parent) : QDialog(parent)
, ui(new Ui::AbstractExtItemAggregator)
, m_type(type) , m_type(type)
{ {
qCDebug(LOG_LIB) << __PRETTY_FUNCTION__; qCDebug(LOG_LIB) << __PRETTY_FUNCTION__;
dialog = new QDialog(this); ui->setupUi(this);
widgetDialog = new QListWidget(dialog);
dialogButtons = new QDialogButtonBox(
QDialogButtonBox::Open | QDialogButtonBox::Close, Qt::Vertical, dialog);
copyButton copyButton
= dialogButtons->addButton(i18n("Copy"), QDialogButtonBox::ActionRole); = ui->buttonBox->addButton(i18n("Copy"), QDialogButtonBox::ActionRole);
createButton = dialogButtons->addButton(i18n("Create"), createButton = ui->buttonBox->addButton(i18n("Create"),
QDialogButtonBox::ActionRole); QDialogButtonBox::ActionRole);
deleteButton = dialogButtons->addButton(i18n("Remove"), deleteButton = ui->buttonBox->addButton(i18n("Remove"),
QDialogButtonBox::ActionRole); QDialogButtonBox::ActionRole);
QHBoxLayout *layout = new QHBoxLayout(dialog);
layout->addWidget(widgetDialog);
layout->addWidget(dialogButtons);
dialog->setLayout(layout);
connect(dialogButtons, SIGNAL(clicked(QAbstractButton *)), this, connect(ui->buttonBox, SIGNAL(clicked(QAbstractButton *)), this,
SLOT(editItemButtonPressed(QAbstractButton *))); SLOT(editItemButtonPressed(QAbstractButton *)));
connect(dialogButtons, SIGNAL(rejected()), dialog, SLOT(reject())); connect(ui->buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
connect(widgetDialog, SIGNAL(itemActivated(QListWidgetItem *)), this, connect(ui->listWidget, SIGNAL(itemActivated(QListWidgetItem *)), this,
SLOT(editItemActivated(QListWidgetItem *))); SLOT(editItemActivated(QListWidgetItem *)));
} }
@ -59,7 +53,7 @@ AbstractExtItemAggregator::~AbstractExtItemAggregator()
{ {
qCDebug(LOG_LIB) << __PRETTY_FUNCTION__; qCDebug(LOG_LIB) << __PRETTY_FUNCTION__;
delete dialog; delete ui;
} }
@ -133,7 +127,7 @@ QString AbstractExtItemAggregator::getName()
AbstractExtItem *AbstractExtItemAggregator::itemFromWidget() AbstractExtItem *AbstractExtItemAggregator::itemFromWidget()
{ {
QListWidgetItem *widgetItem = widgetDialog->currentItem(); QListWidgetItem *widgetItem = ui->listWidget->currentItem();
if (widgetItem == nullptr) if (widgetItem == nullptr)
return nullptr; return nullptr;
@ -155,16 +149,16 @@ AbstractExtItem *AbstractExtItemAggregator::itemFromWidget()
void AbstractExtItemAggregator::repaintList() void AbstractExtItemAggregator::repaintList()
{ {
widgetDialog->clear(); ui->listWidget->clear();
for (auto _item : items()) { for (auto _item : items()) {
QString fileName = QFileInfo(_item->fileName()).fileName(); QString fileName = QFileInfo(_item->fileName()).fileName();
QListWidgetItem *item = new QListWidgetItem(fileName, widgetDialog); QListWidgetItem *item = new QListWidgetItem(fileName, ui->listWidget);
QStringList tooltip; QStringList tooltip;
tooltip.append(i18n("Name: %1", _item->name())); tooltip.append(i18n("Name: %1", _item->name()));
tooltip.append(i18n("Comment: %1", _item->comment())); tooltip.append(i18n("Comment: %1", _item->comment()));
tooltip.append(i18n("Identity: %1", _item->uniq())); tooltip.append(i18n("Identity: %1", _item->uniq()));
item->setToolTip(tooltip.join(QChar('\n'))); item->setToolTip(tooltip.join(QChar('\n')));
widgetDialog->addItem(item); ui->listWidget->addItem(item);
} }
} }
@ -216,6 +210,6 @@ void AbstractExtItemAggregator::editItemButtonPressed(QAbstractButton *button)
return doCreateItem(); return doCreateItem();
else if (static_cast<QPushButton *>(button) == deleteButton) else if (static_cast<QPushButton *>(button) == deleteButton)
return deleteItem(); return deleteItem();
else if (dialogButtons->buttonRole(button) == QDialogButtonBox::AcceptRole) else if (ui->buttonBox->buttonRole(button) == QDialogButtonBox::AcceptRole)
return editItem(); return editItem();
} }

View File

@ -19,18 +19,20 @@
#define ABSTRACTEXTITEMAGGREGATOR_H #define ABSTRACTEXTITEMAGGREGATOR_H
#include <QDialog> #include <QDialog>
#include <QDialogButtonBox>
#include <QListWidget>
#include <QPushButton>
#include <QStandardPaths> #include <QStandardPaths>
#include <QWidget>
#include "abstractextitem.h" #include "abstractextitem.h"
#include "awdebug.h" #include "awdebug.h"
// additional class since QObject macro does not allow class templates class QAbstractButton;
class AbstractExtItemAggregator : public QWidget class QListWidgetItem;
namespace Ui
{
class AbstractExtItemAggregator;
}
class AbstractExtItemAggregator : public QDialog
{ {
Q_OBJECT Q_OBJECT
Q_PROPERTY(QVariant configArgs READ configArgs WRITE setConfigArgs) Q_PROPERTY(QVariant configArgs READ configArgs WRITE setConfigArgs)
@ -68,13 +70,6 @@ public:
AbstractExtItem *itemFromWidget(); AbstractExtItem *itemFromWidget();
void repaintList(); void repaintList();
int uniqNumber() const; int uniqNumber() const;
// ui
QDialog *dialog = nullptr;
QListWidget *widgetDialog = nullptr;
QDialogButtonBox *dialogButtons = nullptr;
QPushButton *copyButton = nullptr;
QPushButton *createButton = nullptr;
QPushButton *deleteButton = nullptr;
// get methods // get methods
QVariant configArgs() const; QVariant configArgs() const;
virtual QList<AbstractExtItem *> items() const = 0; virtual QList<AbstractExtItem *> items() const = 0;
@ -87,6 +82,12 @@ private slots:
void editItemButtonPressed(QAbstractButton *button); void editItemButtonPressed(QAbstractButton *button);
private: private:
// ui
Ui::AbstractExtItemAggregator *ui = nullptr;
QPushButton *copyButton = nullptr;
QPushButton *createButton = nullptr;
QPushButton *deleteButton = nullptr;
// properties
QVariant m_configArgs; QVariant m_configArgs;
QString m_type; QString m_type;
// ui methods // ui methods

View File

@ -0,0 +1,64 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>AbstractExtItemAggregator</class>
<widget class="QDialog" name="AbstractExtItemAggregator">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QListWidget" name="listWidget"/>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Close|QDialogButtonBox::Open</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>AbstractExtItemAggregator</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>AbstractExtItemAggregator</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -26,13 +26,13 @@ AWAbstractFormatter::AWAbstractFormatter(QWidget *parent,
const QString filePath) const QString filePath)
: AbstractExtItem(parent, filePath) : AbstractExtItem(parent, filePath)
{ {
qCDebug(LOG_AW) << __PRETTY_FUNCTION__; qCDebug(LOG_LIB) << __PRETTY_FUNCTION__;
} }
AWAbstractFormatter::~AWAbstractFormatter() AWAbstractFormatter::~AWAbstractFormatter()
{ {
qCDebug(LOG_AW) << __PRETTY_FUNCTION__; qCDebug(LOG_LIB) << __PRETTY_FUNCTION__;
} }
@ -58,7 +58,7 @@ QString AWAbstractFormatter::type() const
void AWAbstractFormatter::setType(const QString _type) void AWAbstractFormatter::setType(const QString _type)
{ {
qCDebug(LOG_AW) << "Type" << _type; qCDebug(LOG_LIB) << "Type" << _type;
m_type = _type; m_type = _type;
} }
@ -71,7 +71,7 @@ void AWAbstractFormatter::readConfiguration()
QSettings settings(fileName(), QSettings::IniFormat); QSettings settings(fileName(), QSettings::IniFormat);
settings.beginGroup(QString("Desktop Entry")); settings.beginGroup(QString("Desktop Entry"));
setType(settings.value(QString("Type"), m_type).toString()); setType(settings.value(QString("X-AW-Type"), m_type).toString());
settings.endGroup(); settings.endGroup();
} }
@ -81,10 +81,10 @@ void AWAbstractFormatter::writeConfiguration() const
AbstractExtItem::writeConfiguration(); AbstractExtItem::writeConfiguration();
QSettings settings(writtableConfig(), QSettings::IniFormat); QSettings settings(writtableConfig(), QSettings::IniFormat);
qCInfo(LOG_AW) << "Configuration file" << settings.fileName(); qCInfo(LOG_LIB) << "Configuration file" << settings.fileName();
settings.beginGroup(QString("Desktop Entry")); settings.beginGroup(QString("Desktop Entry"));
settings.setValue(QString("Type"), m_type); settings.setValue(QString("X-AW-Type"), m_type);
settings.endGroup(); settings.endGroup();
settings.sync(); settings.sync();

View File

@ -33,7 +33,7 @@ AWDateTimeFormatter::AWDateTimeFormatter(QWidget *parent,
: AWAbstractFormatter(parent, filePath) : AWAbstractFormatter(parent, filePath)
, ui(new Ui::AWDateTimeFormatter) , ui(new Ui::AWDateTimeFormatter)
{ {
qCDebug(LOG_AW) << __PRETTY_FUNCTION__; qCDebug(LOG_LIB) << __PRETTY_FUNCTION__;
readConfiguration(); readConfiguration();
ui->setupUi(this); ui->setupUi(this);
@ -45,7 +45,7 @@ AWDateTimeFormatter::AWDateTimeFormatter(const QString format, QWidget *parent)
: AWAbstractFormatter(parent) : AWAbstractFormatter(parent)
, ui(new Ui::AWDateTimeFormatter) , ui(new Ui::AWDateTimeFormatter)
{ {
qCDebug(LOG_AW) << __PRETTY_FUNCTION__; qCDebug(LOG_LIB) << __PRETTY_FUNCTION__;
setFormat(format); setFormat(format);
@ -56,7 +56,7 @@ AWDateTimeFormatter::AWDateTimeFormatter(const QString format, QWidget *parent)
AWDateTimeFormatter::~AWDateTimeFormatter() AWDateTimeFormatter::~AWDateTimeFormatter()
{ {
qCDebug(LOG_AW) << __PRETTY_FUNCTION__; qCDebug(LOG_LIB) << __PRETTY_FUNCTION__;
delete ui; delete ui;
} }
@ -64,7 +64,7 @@ AWDateTimeFormatter::~AWDateTimeFormatter()
QString AWDateTimeFormatter::convert(const QVariant &_value) const QString AWDateTimeFormatter::convert(const QVariant &_value) const
{ {
qCDebug(LOG_AW) << "Convert value" << _value; qCDebug(LOG_LIB) << "Convert value" << _value;
return _value.toDateTime().toString(m_format); return _value.toDateTime().toString(m_format);
} }
@ -93,7 +93,7 @@ QString AWDateTimeFormatter::format() const
void AWDateTimeFormatter::setFormat(const QString _format) void AWDateTimeFormatter::setFormat(const QString _format)
{ {
qCDebug(LOG_AW) << "Set format" << _format; qCDebug(LOG_LIB) << "Set format" << _format;
m_format = _format; m_format = _format;
} }
@ -106,7 +106,7 @@ void AWDateTimeFormatter::readConfiguration()
QSettings settings(fileName(), QSettings::IniFormat); QSettings settings(fileName(), QSettings::IniFormat);
settings.beginGroup(QString("Desktop Entry")); settings.beginGroup(QString("Desktop Entry"));
setFormat(settings.value(QString("Format"), m_format).toString()); setFormat(settings.value(QString("X-AW-Format"), m_format).toString());
settings.endGroup(); settings.endGroup();
} }
@ -141,7 +141,7 @@ void AWDateTimeFormatter::writeConfiguration() const
qCInfo(LOG_LIB) << "Configuration file" << settings.fileName(); qCInfo(LOG_LIB) << "Configuration file" << settings.fileName();
settings.beginGroup(QString("Desktop Entry")); settings.beginGroup(QString("Desktop Entry"));
settings.setValue(QString("Format"), m_format); settings.setValue(QString("X-AW-Format"), m_format);
settings.endGroup(); settings.endGroup();
settings.sync(); settings.sync();

View File

@ -47,7 +47,7 @@ public slots:
void writeConfiguration() const; void writeConfiguration() const;
private: private:
Ui::AWDateTimeFormatter *ui; Ui::AWDateTimeFormatter *ui = nullptr;
void translate(); void translate();
// properties // properties
QString m_format = QString(); QString m_format = QString();

View File

@ -31,7 +31,7 @@ AWFloatFormatter::AWFloatFormatter(QWidget *parent, const QString filePath)
: AWAbstractFormatter(parent, filePath) : AWAbstractFormatter(parent, filePath)
, ui(new Ui::AWFloatFormatter) , ui(new Ui::AWFloatFormatter)
{ {
qCDebug(LOG_AW) << __PRETTY_FUNCTION__; qCDebug(LOG_LIB) << __PRETTY_FUNCTION__;
readConfiguration(); readConfiguration();
ui->setupUi(this); ui->setupUi(this);
@ -46,7 +46,7 @@ AWFloatFormatter::AWFloatFormatter(const int count, const QChar fillChar,
: AWAbstractFormatter(parent) : AWAbstractFormatter(parent)
, ui(new Ui::AWFloatFormatter) , ui(new Ui::AWFloatFormatter)
{ {
qCDebug(LOG_AW) << __PRETTY_FUNCTION__; qCDebug(LOG_LIB) << __PRETTY_FUNCTION__;
setCount(count); setCount(count);
setFillChar(fillChar); setFillChar(fillChar);
@ -62,7 +62,7 @@ AWFloatFormatter::AWFloatFormatter(const int count, const QChar fillChar,
AWFloatFormatter::~AWFloatFormatter() AWFloatFormatter::~AWFloatFormatter()
{ {
qCDebug(LOG_AW) << __PRETTY_FUNCTION__; qCDebug(LOG_LIB) << __PRETTY_FUNCTION__;
delete ui; delete ui;
} }
@ -70,7 +70,7 @@ AWFloatFormatter::~AWFloatFormatter()
QString AWFloatFormatter::convert(const QVariant &_value) const QString AWFloatFormatter::convert(const QVariant &_value) const
{ {
qCDebug(LOG_AW) << "Convert value" << _value; qCDebug(LOG_LIB) << "Convert value" << _value;
return QString("%1").arg(_value.toDouble() * m_multiplier + m_summand, return QString("%1").arg(_value.toDouble() * m_multiplier + m_summand,
m_count, m_format, m_precision, m_fillChar); m_count, m_format, m_precision, m_fillChar);
@ -135,7 +135,7 @@ double AWFloatFormatter::summand() const
void AWFloatFormatter::setCount(const int _count) void AWFloatFormatter::setCount(const int _count)
{ {
qCDebug(LOG_AW) << "Set width" << _count; qCDebug(LOG_LIB) << "Set width" << _count;
m_count = _count; m_count = _count;
} }
@ -143,7 +143,7 @@ void AWFloatFormatter::setCount(const int _count)
void AWFloatFormatter::setFillChar(const QChar _fillChar) void AWFloatFormatter::setFillChar(const QChar _fillChar)
{ {
qCDebug(LOG_AW) << "Set char" << _fillChar; qCDebug(LOG_LIB) << "Set char" << _fillChar;
m_fillChar = _fillChar; m_fillChar = _fillChar;
} }
@ -151,11 +151,11 @@ void AWFloatFormatter::setFillChar(const QChar _fillChar)
void AWFloatFormatter::setFormat(char _format) void AWFloatFormatter::setFormat(char _format)
{ {
qCDebug(LOG_AW) << "Set format" << _format; qCDebug(LOG_LIB) << "Set format" << _format;
// http://doc.qt.io/qt-5/qstring.html#argument-formats // http://doc.qt.io/qt-5/qstring.html#argument-formats
if ((_format != 'e') && (_format != 'E') && (_format != 'f') if ((_format != 'e') && (_format != 'E') && (_format != 'f')
&& (_format != 'g') && (_format != 'G')) { && (_format != 'g') && (_format != 'G')) {
qCWarning(LOG_AW) << "Invalid format" << _format; qCWarning(LOG_LIB) << "Invalid format" << _format;
_format = 'f'; _format = 'f';
} }
@ -165,7 +165,7 @@ void AWFloatFormatter::setFormat(char _format)
void AWFloatFormatter::setMultiplier(const double _multiplier) void AWFloatFormatter::setMultiplier(const double _multiplier)
{ {
qCDebug(LOG_AW) << "Set multiplier" << _multiplier; qCDebug(LOG_LIB) << "Set multiplier" << _multiplier;
m_multiplier = _multiplier; m_multiplier = _multiplier;
} }
@ -173,7 +173,7 @@ void AWFloatFormatter::setMultiplier(const double _multiplier)
void AWFloatFormatter::setPrecision(const int _precision) void AWFloatFormatter::setPrecision(const int _precision)
{ {
qCDebug(LOG_AW) << "Set precision" << _precision; qCDebug(LOG_LIB) << "Set precision" << _precision;
m_precision = _precision; m_precision = _precision;
} }
@ -181,7 +181,7 @@ void AWFloatFormatter::setPrecision(const int _precision)
void AWFloatFormatter::setSummand(const double _summand) void AWFloatFormatter::setSummand(const double _summand)
{ {
qCDebug(LOG_AW) << "Set summand" << _summand; qCDebug(LOG_LIB) << "Set summand" << _summand;
m_summand = _summand; m_summand = _summand;
} }
@ -194,17 +194,18 @@ void AWFloatFormatter::readConfiguration()
QSettings settings(fileName(), QSettings::IniFormat); QSettings settings(fileName(), QSettings::IniFormat);
settings.beginGroup(QString("Desktop Entry")); settings.beginGroup(QString("Desktop Entry"));
setCount(settings.value(QString("Width"), m_count).toInt()); setCount(settings.value(QString("X-AW-Width"), m_count).toInt());
setFillChar( setFillChar(
settings.value(QString("FillChar"), m_fillChar).toString().at(0)); settings.value(QString("X-AW-FillChar"), m_fillChar).toString().at(0));
setFormat(settings.value(QString("Format"), QString(m_format)) setFormat(settings.value(QString("X-AW-Format"), QString(m_format))
.toString() .toString()
.at(0) .at(0)
.toLatin1()); .toLatin1());
setMultiplier( setMultiplier(
settings.value(QString("Multiplier"), m_multiplier).toDouble()); settings.value(QString("X-AW-Multiplier"), m_multiplier).toDouble());
setPrecision(settings.value(QString("Precision"), m_precision).toInt()); setPrecision(
setSummand(settings.value(QString("Summand"), m_summand).toDouble()); settings.value(QString("X-AW-Precision"), m_precision).toInt());
setSummand(settings.value(QString("X-AW-Summand"), m_summand).toDouble());
settings.endGroup(); settings.endGroup();
} }
@ -250,12 +251,12 @@ void AWFloatFormatter::writeConfiguration() const
qCInfo(LOG_LIB) << "Configuration file" << settings.fileName(); qCInfo(LOG_LIB) << "Configuration file" << settings.fileName();
settings.beginGroup(QString("Desktop Entry")); settings.beginGroup(QString("Desktop Entry"));
settings.setValue(QString("Width"), m_count); settings.setValue(QString("X-AW-Width"), m_count);
settings.setValue(QString("FillChar"), m_fillChar); settings.setValue(QString("X-AW-FillChar"), m_fillChar);
settings.setValue(QString("Format"), m_format); settings.setValue(QString("X-AW-Format"), m_format);
settings.setValue(QString("Multiplier"), m_multiplier); settings.setValue(QString("X-AW-Multiplier"), m_multiplier);
settings.setValue(QString("Precision"), m_precision); settings.setValue(QString("X-AW-Precision"), m_precision);
settings.setValue(QString("Summand"), m_summand); settings.setValue(QString("X-AW-Summand"), m_summand);
settings.endGroup(); settings.endGroup();
settings.sync(); settings.sync();

View File

@ -65,7 +65,7 @@ public slots:
void writeConfiguration() const; void writeConfiguration() const;
private: private:
Ui::AWFloatFormatter *ui; Ui::AWFloatFormatter *ui = nullptr;
void translate(); void translate();
// properties // properties
int m_count = 0; int m_count = 0;

View File

@ -28,7 +28,7 @@ AWNoFormatter::AWNoFormatter(QWidget *parent, const QString filePath)
: AWAbstractFormatter(parent, filePath) : AWAbstractFormatter(parent, filePath)
, ui(new Ui::AWNoFormatter) , ui(new Ui::AWNoFormatter)
{ {
qCDebug(LOG_AW) << __PRETTY_FUNCTION__; qCDebug(LOG_LIB) << __PRETTY_FUNCTION__;
readConfiguration(); readConfiguration();
ui->setupUi(this); ui->setupUi(this);
@ -40,7 +40,7 @@ AWNoFormatter::AWNoFormatter(QWidget *parent)
: AWAbstractFormatter(parent) : AWAbstractFormatter(parent)
, ui(new Ui::AWNoFormatter) , ui(new Ui::AWNoFormatter)
{ {
qCDebug(LOG_AW) << __PRETTY_FUNCTION__; qCDebug(LOG_LIB) << __PRETTY_FUNCTION__;
ui->setupUi(this); ui->setupUi(this);
translate(); translate();
@ -49,7 +49,7 @@ AWNoFormatter::AWNoFormatter(QWidget *parent)
AWNoFormatter::~AWNoFormatter() AWNoFormatter::~AWNoFormatter()
{ {
qCDebug(LOG_AW) << __PRETTY_FUNCTION__; qCDebug(LOG_LIB) << __PRETTY_FUNCTION__;
delete ui; delete ui;
} }
@ -57,7 +57,7 @@ AWNoFormatter::~AWNoFormatter()
QString AWNoFormatter::convert(const QVariant &_value) const QString AWNoFormatter::convert(const QVariant &_value) const
{ {
qCDebug(LOG_AW) << "Convert value" << _value; qCDebug(LOG_LIB) << "Convert value" << _value;
return _value.toString(); return _value.toString();
} }

View File

@ -41,7 +41,7 @@ public slots:
int showConfiguration(const QVariant args = QVariant()); int showConfiguration(const QVariant args = QVariant());
private: private:
Ui::AWNoFormatter *ui; Ui::AWNoFormatter *ui = nullptr;
void translate(); void translate();
// properties // properties
}; };

View File

@ -32,7 +32,7 @@ AWScriptFormatter::AWScriptFormatter(QWidget *parent, const QString filePath)
: AWAbstractFormatter(parent, filePath) : AWAbstractFormatter(parent, filePath)
, ui(new Ui::AWScriptFormatter) , ui(new Ui::AWScriptFormatter)
{ {
qCDebug(LOG_AW) << __PRETTY_FUNCTION__; qCDebug(LOG_LIB) << __PRETTY_FUNCTION__;
readConfiguration(); readConfiguration();
ui->setupUi(this); ui->setupUi(this);
@ -45,7 +45,7 @@ AWScriptFormatter::AWScriptFormatter(const bool appendCode, const QString code,
: AWAbstractFormatter(parent) : AWAbstractFormatter(parent)
, ui(new Ui::AWScriptFormatter) , ui(new Ui::AWScriptFormatter)
{ {
qCDebug(LOG_AW) << __PRETTY_FUNCTION__; qCDebug(LOG_LIB) << __PRETTY_FUNCTION__;
setAppendCode(appendCode); setAppendCode(appendCode);
setCode(code); setCode(code);
@ -59,7 +59,7 @@ AWScriptFormatter::AWScriptFormatter(const bool appendCode, const QString code,
AWScriptFormatter::~AWScriptFormatter() AWScriptFormatter::~AWScriptFormatter()
{ {
qCDebug(LOG_AW) << __PRETTY_FUNCTION__; qCDebug(LOG_LIB) << __PRETTY_FUNCTION__;
delete ui; delete ui;
} }
@ -67,7 +67,7 @@ AWScriptFormatter::~AWScriptFormatter()
QString AWScriptFormatter::convert(const QVariant &_value) const QString AWScriptFormatter::convert(const QVariant &_value) const
{ {
qCDebug(LOG_AW) << "Convert value" << _value; qCDebug(LOG_LIB) << "Convert value" << _value;
// init engine // init engine
QJSEngine engine; QJSEngine engine;
@ -76,9 +76,9 @@ QString AWScriptFormatter::convert(const QVariant &_value) const
QJSValue result = fn.call(args); QJSValue result = fn.call(args);
if (result.isError()) { if (result.isError()) {
qCWarning(LOG_AW) << "Uncaught exception at line" qCWarning(LOG_LIB) << "Uncaught exception at line"
<< result.property("lineNumber").toInt() << ":" << result.property("lineNumber").toInt() << ":"
<< result.toString(); << result.toString();
return QString(); return QString();
} else { } else {
return result.toString(); return result.toString();
@ -129,7 +129,7 @@ QString AWScriptFormatter::program() const
void AWScriptFormatter::setAppendCode(const bool _appendCode) void AWScriptFormatter::setAppendCode(const bool _appendCode)
{ {
qCDebug(LOG_AW) << "Set append code" << _appendCode; qCDebug(LOG_LIB) << "Set append code" << _appendCode;
m_appendCode = _appendCode; m_appendCode = _appendCode;
} }
@ -137,7 +137,7 @@ void AWScriptFormatter::setAppendCode(const bool _appendCode)
void AWScriptFormatter::setCode(const QString _code) void AWScriptFormatter::setCode(const QString _code)
{ {
qCDebug(LOG_AW) << "Set code" << _code; qCDebug(LOG_LIB) << "Set code" << _code;
m_code = _code; m_code = _code;
} }
@ -145,7 +145,7 @@ void AWScriptFormatter::setCode(const QString _code)
void AWScriptFormatter::setHasReturn(const bool _hasReturn) void AWScriptFormatter::setHasReturn(const bool _hasReturn)
{ {
qCDebug(LOG_AW) << "Set has return" << _hasReturn; qCDebug(LOG_LIB) << "Set has return" << _hasReturn;
m_hasReturn = _hasReturn; m_hasReturn = _hasReturn;
} }
@ -158,9 +158,11 @@ void AWScriptFormatter::readConfiguration()
QSettings settings(fileName(), QSettings::IniFormat); QSettings settings(fileName(), QSettings::IniFormat);
settings.beginGroup(QString("Desktop Entry")); settings.beginGroup(QString("Desktop Entry"));
setAppendCode(settings.value(QString("AppendCode"), m_appendCode).toBool()); setAppendCode(
setCode(settings.value(QString("Code"), m_code).toString()); settings.value(QString("X-AW-AppendCode"), m_appendCode).toBool());
setHasReturn(settings.value(QString("HasReturn"), m_hasReturn).toBool()); setCode(settings.value(QString("X-AW-Code"), m_code).toString());
setHasReturn(
settings.value(QString("X-AW-HasReturn"), m_hasReturn).toBool());
settings.endGroup(); settings.endGroup();
initProgram(); initProgram();
@ -204,9 +206,9 @@ void AWScriptFormatter::writeConfiguration() const
qCInfo(LOG_LIB) << "Configuration file" << settings.fileName(); qCInfo(LOG_LIB) << "Configuration file" << settings.fileName();
settings.beginGroup(QString("Desktop Entry")); settings.beginGroup(QString("Desktop Entry"));
settings.setValue(QString("AppendCode"), m_appendCode); settings.setValue(QString("X-AW-AppendCode"), m_appendCode);
settings.setValue(QString("Code"), m_code); settings.setValue(QString("X-AW-Code"), m_code);
settings.setValue(QString("HasReturn"), m_hasReturn); settings.setValue(QString("X-AW-HasReturn"), m_hasReturn);
settings.endGroup(); settings.endGroup();
settings.sync(); settings.sync();
@ -223,7 +225,7 @@ void AWScriptFormatter::initProgram()
else else
m_program = m_code; m_program = m_code;
qCInfo(LOG_AW) << "Create JS engine with code" << m_program; qCInfo(LOG_LIB) << "Create JS engine with code" << m_program;
} }

View File

@ -56,7 +56,7 @@ public slots:
void writeConfiguration() const; void writeConfiguration() const;
private: private:
Ui::AWScriptFormatter *ui; Ui::AWScriptFormatter *ui = nullptr;
void initProgram(); void initProgram();
void translate(); void translate();
// properties // properties

View File

@ -57,7 +57,7 @@ public:
void editItems() void editItems()
{ {
repaintList(); repaintList();
int ret = dialog->exec(); int ret = exec();
qCInfo(LOG_LIB) << "Dialog returns" << ret; qCInfo(LOG_LIB) << "Dialog returns" << ret;
}; };

View File

@ -58,10 +58,10 @@ private slots:
void quotesReplyReceived(QNetworkReply *reply); void quotesReplyReceived(QNetworkReply *reply);
private: private:
QNetworkAccessManager *m_manager; QNetworkAccessManager *m_manager = nullptr;
QUrl m_url; QUrl m_url;
bool isRunning = false; bool isRunning = false;
Ui::ExtQuotes *ui; Ui::ExtQuotes *ui = nullptr;
void translate(); void translate();
// properties // properties
QString m_ticker = QString("EURUSD=X"); QString m_ticker = QString("EURUSD=X");

View File

@ -73,7 +73,7 @@ private slots:
private: private:
QProcess *process = nullptr; QProcess *process = nullptr;
Ui::ExtScript *ui; Ui::ExtScript *ui = nullptr;
void translate(); void translate();
// properties // properties
QString m_executable = QString("/usr/bin/true"); QString m_executable = QString("/usr/bin/true");

View File

@ -61,7 +61,7 @@ private slots:
private: private:
QProcess *process = nullptr; QProcess *process = nullptr;
Ui::ExtUpgrade *ui; Ui::ExtUpgrade *ui = nullptr;
void translate(); void translate();
// properties // properties
QString m_executable = QString("/usr/bin/true"); QString m_executable = QString("/usr/bin/true");

View File

@ -70,10 +70,10 @@ private slots:
void weatherReplyReceived(QNetworkReply *reply); void weatherReplyReceived(QNetworkReply *reply);
private: private:
QNetworkAccessManager *m_manager; QNetworkAccessManager *m_manager = nullptr;
QUrl m_url; QUrl m_url;
bool isRunning = false; bool isRunning = false;
Ui::ExtWeather *ui; Ui::ExtWeather *ui = nullptr;
void translate(); void translate();
// properties // properties
QString m_city = QString("London"); QString m_city = QString("London");

View File

@ -105,7 +105,7 @@ private:
GraphicalItemHelper *m_helper = nullptr; GraphicalItemHelper *m_helper = nullptr;
QGraphicsScene *m_scene = nullptr; QGraphicsScene *m_scene = nullptr;
QGraphicsView *m_view = nullptr; QGraphicsView *m_view = nullptr;
Ui::GraphicalItem *ui; Ui::GraphicalItem *ui = nullptr;
void initScene(); void initScene();
void translate(); void translate();
// properties // properties

View File

@ -39,7 +39,7 @@ public:
private: private:
QStringList getSources(); QStringList getSources();
// configuration and values // configuration and values
ExtItemAggregator<ExtScript> *extScripts; ExtItemAggregator<ExtScript> *extScripts = nullptr;
QStringList m_sources; QStringList m_sources;
}; };

View File

@ -39,7 +39,7 @@ public:
private: private:
QStringList getSources(); QStringList getSources();
// configuration and values // configuration and values
ExtItemAggregator<ExtQuotes> *extQuotes; ExtItemAggregator<ExtQuotes> *extQuotes = nullptr;
QStringList m_sources; QStringList m_sources;
QVariantHash m_values; QVariantHash m_values;
}; };

View File

@ -39,7 +39,7 @@ public:
private: private:
QStringList getSources(); QStringList getSources();
// configuration and values // configuration and values
ExtItemAggregator<ExtUpgrade> *extUpgrade; ExtItemAggregator<ExtUpgrade> *extUpgrade = nullptr;
QStringList m_sources; QStringList m_sources;
}; };

View File

@ -39,7 +39,7 @@ public:
private: private:
QStringList getSources(); QStringList getSources();
// configuration and values // configuration and values
ExtItemAggregator<ExtWeather> *extWeather; ExtItemAggregator<ExtWeather> *extWeather = nullptr;
QStringList m_sources; QStringList m_sources;
QVariantHash m_values; QVariantHash m_values;
}; };