Gary Wang
edb3338bc4
- display add time for later use - basic keyboard navigation support - remember last-used server address - show connection error when attempt to connect to server
61 lines
2.1 KiB
C++
61 lines
2.1 KiB
C++
#include <QGuiApplication>
|
|
#include <QQmlApplicationEngine>
|
|
#include <QQmlNetworkAccessManagerFactory>
|
|
#include <QNetworkAccessManager>
|
|
#include <QNetworkRequest>
|
|
|
|
#include "dataitems/libraryitem.h"
|
|
#include "dataitems/comicitem.h"
|
|
#include "dataitems/folderitem.h"
|
|
|
|
class QmlNetworkAccessManager : public QNetworkAccessManager
|
|
{
|
|
public:
|
|
QmlNetworkAccessManager(QObject *parent = nullptr) : QNetworkAccessManager(parent) {}
|
|
|
|
protected:
|
|
QNetworkReply *createRequest(Operation op, const QNetworkRequest &request, QIODevice *outgoingData = nullptr) override
|
|
{
|
|
QNetworkRequest newRequest(request);
|
|
newRequest.setRawHeader("X-Request-Id", "114514");
|
|
return QNetworkAccessManager::createRequest(op, newRequest, outgoingData);
|
|
}
|
|
};
|
|
|
|
class QmlNetworkAccessManagerFactory : public QQmlNetworkAccessManagerFactory
|
|
{
|
|
public:
|
|
inline QNetworkAccessManager *create(QObject *parent) override
|
|
{
|
|
return new QmlNetworkAccessManager(parent);
|
|
}
|
|
};
|
|
|
|
int main(int argc, char *argv[])
|
|
{
|
|
QCoreApplication::setApplicationName("Pineapple Comic Reader");
|
|
QGuiApplication app(argc, argv);
|
|
app.setOrganizationName("Chestnut Software");
|
|
app.setOrganizationDomain("blumia.net");
|
|
|
|
qputenv("QT_QUICK_CONTROLS_STYLE", QByteArray("FluentWinUI3"));
|
|
|
|
qmlRegisterUncreatableMetaObject(LibraryItem::staticMetaObject, "net.blumia.pineapple.comic.reader.libraryitem", 1, 0, "LibraryItem", "enum");
|
|
qmlRegisterUncreatableMetaObject(ComicItem::staticMetaObject, "net.blumia.pineapple.comic.reader.comicitem", 1, 0, "ComicItem", "enum");
|
|
qmlRegisterUncreatableMetaObject(FolderItem::staticMetaObject, "net.blumia.pineapple.comic.reader.folderitem", 1, 0, "FolderItem", "enum");
|
|
|
|
QmlNetworkAccessManagerFactory namFactory;
|
|
|
|
QQmlApplicationEngine engine;
|
|
engine.setNetworkAccessManagerFactory(&namFactory);
|
|
QObject::connect(
|
|
&engine,
|
|
&QQmlApplicationEngine::objectCreationFailed,
|
|
&app,
|
|
[]() { QCoreApplication::exit(-1); },
|
|
Qt::QueuedConnection);
|
|
engine.loadFromModule("net.blumia.pineapple.comic.reader", "Main");
|
|
|
|
return app.exec();
|
|
}
|