Commit 2078a309 authored by Ronan Abhamon's avatar Ronan Abhamon

feat(app): clean some pieces of code and improve build (providers)

parent b05e003d
...@@ -20,8 +20,8 @@ ...@@ -20,8 +20,8 @@
* Author: Ronan Abhamon * Author: Ronan Abhamon
*/ */
#include "../../utils/Utils.hpp" #include "app/paths/Paths.hpp"
#include "../paths/Paths.hpp" #include "utils/Utils.hpp"
#include "AvatarProvider.hpp" #include "AvatarProvider.hpp"
...@@ -32,8 +32,8 @@ const QString AvatarProvider::PROVIDER_ID = "avatar"; ...@@ -32,8 +32,8 @@ const QString AvatarProvider::PROVIDER_ID = "avatar";
AvatarProvider::AvatarProvider () : QQuickImageProvider( AvatarProvider::AvatarProvider () : QQuickImageProvider(
QQmlImageProviderBase::Image, QQmlImageProviderBase::Image,
QQmlImageProviderBase::ForceAsynchronousImageLoading QQmlImageProviderBase::ForceAsynchronousImageLoading
) { ) {
mAvatarsPath = ::Utils::coreStringToAppString(Paths::getAvatarsDirPath()); mAvatarsPath = Utils::coreStringToAppString(Paths::getAvatarsDirPath());
} }
QImage AvatarProvider::requestImage (const QString &id, QSize *size, const QSize &) { QImage AvatarProvider::requestImage (const QString &id, QSize *size, const QSize &) {
......
...@@ -25,14 +25,14 @@ ...@@ -25,14 +25,14 @@
#include <QPainter> #include <QPainter>
#include <QSvgRenderer> #include <QSvgRenderer>
#include "../App.hpp" #include "app/App.hpp"
#include "ImageProvider.hpp" #include "ImageProvider.hpp"
using namespace std;
// ============================================================================= // =============================================================================
using namespace std;
namespace { namespace {
// Max image size in bytes. (100Kb) // Max image size in bytes. (100Kb)
constexpr qint64 cMaxImageSize = 102400; constexpr qint64 cMaxImageSize = 102400;
...@@ -72,8 +72,8 @@ static QByteArray parseFillAndStroke (QXmlStreamAttributes &readerAttributes, co ...@@ -72,8 +72,8 @@ static QByteArray parseFillAndStroke (QXmlStreamAttributes &readerAttributes, co
continue; continue;
} }
::removeAttribute(readerAttributes, list[2]); removeAttribute(readerAttributes, list[2]);
attributes.append(::buildByteArrayAttribute(list[2].toLatin1(), colorValue.value<QColor>().name().toLatin1())); attributes.append(buildByteArrayAttribute(list[2].toLatin1(), colorValue.value<QColor>().name().toLatin1()));
} }
return attributes; return attributes;
...@@ -115,7 +115,7 @@ static QByteArray parseStyle (QXmlStreamAttributes &readerAttributes, const Colo ...@@ -115,7 +115,7 @@ static QByteArray parseStyle (QXmlStreamAttributes &readerAttributes, const Colo
} }
} }
::removeAttribute(readerAttributes, "style"); removeAttribute(readerAttributes, "style");
if (attribute.length() > 0) { if (attribute.length() > 0) {
attribute.prepend("style=\""); attribute.prepend("style=\"");
...@@ -128,8 +128,8 @@ static QByteArray parseStyle (QXmlStreamAttributes &readerAttributes, const Colo ...@@ -128,8 +128,8 @@ static QByteArray parseStyle (QXmlStreamAttributes &readerAttributes, const Colo
static QByteArray parseAttributes (const QXmlStreamReader &reader, const Colors &colors) { static QByteArray parseAttributes (const QXmlStreamReader &reader, const Colors &colors) {
QXmlStreamAttributes readerAttributes = reader.attributes(); QXmlStreamAttributes readerAttributes = reader.attributes();
QByteArray attributes = ::parseFillAndStroke(readerAttributes, colors); QByteArray attributes = parseFillAndStroke(readerAttributes, colors);
attributes.append(::parseStyle(readerAttributes, colors)); attributes.append(parseStyle(readerAttributes, colors));
for (const auto &attribute : readerAttributes) { for (const auto &attribute : readerAttributes) {
const QByteArray prefix = attribute.prefix().toLatin1(); const QByteArray prefix = attribute.prefix().toLatin1();
...@@ -139,7 +139,7 @@ static QByteArray parseAttributes (const QXmlStreamReader &reader, const Colors ...@@ -139,7 +139,7 @@ static QByteArray parseAttributes (const QXmlStreamReader &reader, const Colors
} }
attributes.append( attributes.append(
::buildByteArrayAttribute(attribute.name().toLatin1(), attribute.value().toLatin1()) buildByteArrayAttribute(attribute.name().toLatin1(), attribute.value().toLatin1())
); );
} }
...@@ -177,9 +177,9 @@ static QByteArray parseStartElement (const QXmlStreamReader &reader, const Color ...@@ -177,9 +177,9 @@ static QByteArray parseStartElement (const QXmlStreamReader &reader, const Color
QByteArray startElement = "<"; QByteArray startElement = "<";
startElement.append(reader.name().toLatin1()); startElement.append(reader.name().toLatin1());
startElement.append(" "); startElement.append(" ");
startElement.append(::parseAttributes(reader, colors)); startElement.append(parseAttributes(reader, colors));
startElement.append(" "); startElement.append(" ");
startElement.append(::parseDeclarations(reader)); startElement.append(parseDeclarations(reader));
startElement.append(">"); startElement.append(">");
return startElement; return startElement;
} }
...@@ -209,15 +209,15 @@ static QByteArray computeContent (QFile &file) { ...@@ -209,15 +209,15 @@ static QByteArray computeContent (QFile &file) {
break; break;
case QXmlStreamReader::StartDocument: case QXmlStreamReader::StartDocument:
content.append(::parseStartDocument(reader)); content.append(parseStartDocument(reader));
break; break;
case QXmlStreamReader::StartElement: case QXmlStreamReader::StartElement:
content.append(::parseStartElement(reader, *colors)); content.append(parseStartElement(reader, *colors));
break; break;
case QXmlStreamReader::EndElement: case QXmlStreamReader::EndElement:
content.append(::parseEndElement(reader)); content.append(parseEndElement(reader));
break; break;
case QXmlStreamReader::Characters: case QXmlStreamReader::Characters:
...@@ -239,7 +239,7 @@ const QString ImageProvider::PROVIDER_ID = "internal"; ...@@ -239,7 +239,7 @@ const QString ImageProvider::PROVIDER_ID = "internal";
ImageProvider::ImageProvider () : QQuickImageProvider( ImageProvider::ImageProvider () : QQuickImageProvider(
QQmlImageProviderBase::Image, QQmlImageProviderBase::Image,
QQmlImageProviderBase::ForceAsynchronousImageLoading QQmlImageProviderBase::ForceAsynchronousImageLoading
) {} ) {}
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
......
...@@ -20,8 +20,8 @@ ...@@ -20,8 +20,8 @@
* Author: Ronan Abhamon * Author: Ronan Abhamon
*/ */
#include "../../utils/Utils.hpp" #include "app/paths/Paths.hpp"
#include "../paths/Paths.hpp" #include "utils/Utils.hpp"
#include "ThumbnailProvider.hpp" #include "ThumbnailProvider.hpp"
...@@ -32,8 +32,8 @@ const QString ThumbnailProvider::PROVIDER_ID = "thumbnail"; ...@@ -32,8 +32,8 @@ const QString ThumbnailProvider::PROVIDER_ID = "thumbnail";
ThumbnailProvider::ThumbnailProvider () : QQuickImageProvider( ThumbnailProvider::ThumbnailProvider () : QQuickImageProvider(
QQmlImageProviderBase::Image, QQmlImageProviderBase::Image,
QQmlImageProviderBase::ForceAsynchronousImageLoading QQmlImageProviderBase::ForceAsynchronousImageLoading
) { ) {
mThumbnailsPath = ::Utils::coreStringToAppString(Paths::getThumbnailsDirPath()); mThumbnailsPath = Utils::coreStringToAppString(Paths::getThumbnailsDirPath());
} }
QImage ThumbnailProvider::requestImage (const QString &id, QSize *size, const QSize &) { QImage ThumbnailProvider::requestImage (const QString &id, QSize *size, const QSize &) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment