2018-11-01 18:15:05 +01:00
|
|
|
#include <QStandardPaths>
|
2018-10-29 00:11:23 +01:00
|
|
|
#include "pbfplugin.h"
|
|
|
|
#include "pbfhandler.h"
|
|
|
|
#include "style.h"
|
|
|
|
|
|
|
|
|
|
|
|
PBFPlugin::PBFPlugin()
|
|
|
|
{
|
2018-11-01 08:19:23 +01:00
|
|
|
_style = new Style(this);
|
2018-10-29 00:11:23 +01:00
|
|
|
|
2018-11-01 18:15:05 +01:00
|
|
|
QString style(QStandardPaths::locate(QStandardPaths::AppDataLocation,
|
|
|
|
"style/style.json"));
|
|
|
|
|
|
|
|
if (style.isEmpty() || !_style->load(style)) {
|
|
|
|
Q_INIT_RESOURCE(pbfplugin);
|
|
|
|
_style->load(":/style/style.json");
|
|
|
|
}
|
2018-10-29 00:11:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
QImageIOPlugin::Capabilities PBFPlugin::capabilities(QIODevice *device,
|
|
|
|
const QByteArray &format) const
|
|
|
|
{
|
|
|
|
if (device == 0)
|
2019-02-26 22:20:12 +01:00
|
|
|
return (format == "mvt") ? Capabilities(CanRead) : Capabilities();
|
2018-10-29 00:11:23 +01:00
|
|
|
else
|
|
|
|
return (device->isReadable() && PBFHandler::canRead(device))
|
|
|
|
? Capabilities(CanRead) : Capabilities();
|
|
|
|
}
|
|
|
|
|
|
|
|
QImageIOHandler *PBFPlugin::create(QIODevice *device,
|
|
|
|
const QByteArray &format) const
|
|
|
|
{
|
|
|
|
QImageIOHandler *handler = new PBFHandler(_style);
|
|
|
|
handler->setDevice(device);
|
|
|
|
handler->setFormat(format);
|
|
|
|
return handler;
|
|
|
|
}
|