mirror of
https://github.com/QuasarApp/DocsSite.git
synced 2025-04-27 12:34:32 +00:00
added supprot GET requests
This commit is contained in:
parent
2318a08054
commit
adc41cc058
@ -12,6 +12,8 @@ set(BUILD_SHARED_LIBS ON)
|
|||||||
include(Site/QuasarAppLib/CMake/ccache.cmake)
|
include(Site/QuasarAppLib/CMake/ccache.cmake)
|
||||||
include(Site/QuasarAppLib/CMake/crossplatform/crossplatform.cmake)
|
include(Site/QuasarAppLib/CMake/crossplatform/crossplatform.cmake)
|
||||||
|
|
||||||
|
project(DocsSite)
|
||||||
|
|
||||||
# Add sub directories
|
# Add sub directories
|
||||||
add_subdirectory(Site)
|
add_subdirectory(Site)
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
#include <QQmlApplicationEngine>
|
#include <QQmlApplicationEngine>
|
||||||
#include <QQmlContext>
|
#include <QQmlContext>
|
||||||
|
#include <correnthostimageprovider.h>
|
||||||
|
|
||||||
bool BaseFront::init(QQmlApplicationEngine *engine) {
|
bool BaseFront::init(QQmlApplicationEngine *engine) {
|
||||||
if (!engine)
|
if (!engine)
|
||||||
@ -18,6 +19,9 @@ bool BaseFront::init(QQmlApplicationEngine *engine) {
|
|||||||
auto root = engine->rootContext();
|
auto root = engine->rootContext();
|
||||||
if (!root)
|
if (!root)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
engine->addImageProvider(QLatin1String("curhost"), new CorrentHostImageProvider);
|
||||||
|
|
||||||
engine->addImportPath(":/");
|
engine->addImportPath(":/");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
75
Site/BaseFront/Front/src/correnthostimageprovider.cpp
Normal file
75
Site/BaseFront/Front/src/correnthostimageprovider.cpp
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
#include "correnthostimageprovider.h"
|
||||||
|
#include <string>
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
|
#ifdef WASM32_BUILD
|
||||||
|
#include <emscripten/fetch.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace BaseFront {
|
||||||
|
|
||||||
|
CorrentHostImageProvider::CorrentHostImageProvider() {
|
||||||
|
}
|
||||||
|
|
||||||
|
CorrentHostImageProvider::~CorrentHostImageProvider() {
|
||||||
|
}
|
||||||
|
|
||||||
|
QQuickImageResponse *CorrentHostImageProvider::requestImageResponse(
|
||||||
|
const QString &id, const QSize &requestedSize) {
|
||||||
|
|
||||||
|
AsyncImageResponse *response = new AsyncImageResponse(id, requestedSize);
|
||||||
|
|
||||||
|
response->run();
|
||||||
|
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
AsyncImageResponse::AsyncImageResponse(const QString &id, const QSize &requestedSize)
|
||||||
|
: m_id(id), m_requestedSize(requestedSize) {
|
||||||
|
setAutoDelete(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
QQuickTextureFactory *AsyncImageResponse::textureFactory() const {
|
||||||
|
return QQuickTextureFactory::textureFactoryForImage(m_image);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef WASM32_BUILD
|
||||||
|
static void * tmpPTR = nullptr;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void AsyncImageResponse::run() {
|
||||||
|
#ifdef WASM32_BUILD
|
||||||
|
tmpPTR = this;
|
||||||
|
auto downloadSucceeded = [](emscripten_fetch_t *fetch){
|
||||||
|
auto resp = reinterpret_cast<AsyncImageResponse*>(tmpPTR);
|
||||||
|
resp->m_image = QImage::fromData(reinterpret_cast<const unsigned char *>(fetch->data), fetch->numBytes);
|
||||||
|
|
||||||
|
if (resp->m_requestedSize.isValid())
|
||||||
|
resp->m_image = resp->m_image.scaled(resp->m_requestedSize);
|
||||||
|
|
||||||
|
emit resp->finished();
|
||||||
|
|
||||||
|
emscripten_fetch_close(fetch); // Free data associated with the fetch.
|
||||||
|
};
|
||||||
|
|
||||||
|
auto downloadFailed = [](emscripten_fetch_t *fetch){
|
||||||
|
emscripten_fetch_close(fetch); // Also free data on failure.
|
||||||
|
};
|
||||||
|
|
||||||
|
emscripten_fetch_attr_t attr;
|
||||||
|
emscripten_fetch_attr_init(&attr);
|
||||||
|
strcpy(attr.requestMethod, "GET");
|
||||||
|
attr.attributes = EMSCRIPTEN_FETCH_LOAD_TO_MEMORY;
|
||||||
|
attr.onsuccess = downloadSucceeded;
|
||||||
|
attr.onerror = downloadFailed;
|
||||||
|
auto stdString = m_id.toStdString();
|
||||||
|
emscripten_fetch(&attr, stdString.c_str());
|
||||||
|
#else
|
||||||
|
cancel();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
35
Site/BaseFront/Front/src/correnthostimageprovider.h
Normal file
35
Site/BaseFront/Front/src/correnthostimageprovider.h
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
#ifndef CORRENTHOSTIMAGEPROVIDER_H
|
||||||
|
#define CORRENTHOSTIMAGEPROVIDER_H
|
||||||
|
|
||||||
|
#include <QQuickAsyncImageProvider>
|
||||||
|
#include <QRunnable>
|
||||||
|
#include "BaseFront_global.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace BaseFront {
|
||||||
|
|
||||||
|
class BASEFRONT_LIBRARYSHARED_EXPORT AsyncImageResponse : public QQuickImageResponse, public QRunnable
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
AsyncImageResponse(const QString &id, const QSize &requestedSize);
|
||||||
|
|
||||||
|
QQuickTextureFactory *textureFactory() const;
|
||||||
|
|
||||||
|
void run();
|
||||||
|
|
||||||
|
QString m_id;
|
||||||
|
QSize m_requestedSize;
|
||||||
|
QImage m_image;
|
||||||
|
};
|
||||||
|
|
||||||
|
class BASEFRONT_LIBRARYSHARED_EXPORT CorrentHostImageProvider: public QQuickAsyncImageProvider
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CorrentHostImageProvider();
|
||||||
|
~CorrentHostImageProvider();
|
||||||
|
|
||||||
|
QQuickImageResponse *requestImageResponse(const QString &id, const QSize &requestedSize) override;
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
|
#endif // CORRENTHOSTIMAGEPROVIDER_H
|
@ -1 +1 @@
|
|||||||
Subproject commit f84faab0ddfda32f165633a9c18df4898434f0c4
|
Subproject commit f873269780d00e9dfe2f56a7d6a9702f49d35508
|
@ -18,5 +18,5 @@ QObject * AbstractPage::makeBlok() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
QString AbstractPage::resourcesPath() const {
|
QString AbstractPage::resourcesPath() const {
|
||||||
return QuasarAppUtils::Params::getCurrentExecutableDir() + "/plugins/images";
|
return "image://curhost/plugins/images";
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,8 @@
|
|||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
QuasarAppUtils::Params::parseParams(argc, argv);
|
||||||
|
|
||||||
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||||
|
|
||||||
QGuiApplication app(argc, argv);
|
QGuiApplication app(argc, argv);
|
||||||
|
@ -57,24 +57,29 @@
|
|||||||
<translation type="vanished">Поддерживаемые платформы</translation>
|
<translation type="vanished">Поддерживаемые платформы</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../Models/mainmodel.cpp" line="109"/>
|
|
||||||
<source>At the moment, we can offer support for our solutions for the following platforms:<br><br></source>
|
<source>At the moment, we can offer support for our solutions for the following platforms:<br><br></source>
|
||||||
<translation>На данный момент мы можем предложить поддержку наших решений для следующих платформ: <br> <br></translation>
|
<translation type="vanished">На данный момент мы можем предложить поддержку наших решений для следующих платформ: <br> <br></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../Models/mainmodel.cpp" line="111"/>
|
|
||||||
<source>- <i> Linux </i><br>- <i> Windows </i><br>- <i> Android </i><br>- <i> Web </i></source>
|
|
||||||
<translation></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../Models/mainmodel.cpp" line="122"/>
|
|
||||||
<source>Order a project.</source>
|
<source>Order a project.</source>
|
||||||
<translation>Заказать проект.</translation>
|
<translation type="vanished">Заказать проект.</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../Models/mainmodel.cpp" line="124"/>
|
|
||||||
<source>We are always happy to help you realize your best and most fantastic ideas.<br><br>If you have an idea for the application, then you can leave a request to create a project with us on GitHub. All that is required of you is a detailed description of what needs to be done. Further, our specialists will decide when work will begin on the project and how much resources will be allocated to the project.<br><br>That how many resources will be allocated for the development depends on how much this project will collect cash donations.<br><br>You can also request a private project exclusively for you, but such a project can no longer be free.</source>
|
<source>We are always happy to help you realize your best and most fantastic ideas.<br><br>If you have an idea for the application, then you can leave a request to create a project with us on GitHub. All that is required of you is a detailed description of what needs to be done. Further, our specialists will decide when work will begin on the project and how much resources will be allocated to the project.<br><br>That how many resources will be allocated for the development depends on how much this project will collect cash donations.<br><br>You can also request a private project exclusively for you, but such a project can no longer be free.</source>
|
||||||
<translation>Мы всегда рады помочь вам реализовать ваши лучшие и самые фантастические идеи. <br> <br> Если у вас есть идея для приложения, вы можете оставить заявку на создание проекта у нас на GitHub. Все, что от вас требуется, - это подробное описание того, что нужно сделать. Далее наши специалисты решат, когда начнется работа над проектом и сколько ресурсов будет выделено для проекта. <br> <br> То, сколько ресурсов будет выделено на разработку, зависит от того, сколько этот проект собирет денежными пожертвованиями. . <br> <br> Вы также можете запросить частный проект исключительно для вас, но такой проект больше не может быть бесплатным.</translation>
|
<translation type="vanished">Мы всегда рады помочь вам реализовать ваши лучшие и самые фантастические идеи. <br> <br> Если у вас есть идея для приложения, вы можете оставить заявку на создание проекта у нас на GitHub. Все, что от вас требуется, - это подробное описание того, что нужно сделать. Далее наши специалисты решат, когда начнется работа над проектом и сколько ресурсов будет выделено для проекта. <br> <br> То, сколько ресурсов будет выделено на разработку, зависит от того, сколько этот проект собирет денежными пожертвованиями. . <br> <br> Вы также можете запросить частный проект исключительно для вас, но такой проект больше не может быть бесплатным.</translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
|
<context>
|
||||||
|
<name>QasarAppOrder</name>
|
||||||
|
<message>
|
||||||
|
<location filename="../Models/qasarapporder.cpp" line="9"/>
|
||||||
|
<source>We are always happy to help you realize your best and most fantastic ideas.<br><br>If you have an idea for the application, then you can leave a request to create a project with us on GitHub. All that is required of you is a detailed description of what needs to be done. Further, our specialists will decide when work will begin on the project and how much resources will be allocated to the project.<br><br>That how many resources will be allocated for the development depends on how much this project will collect cash donations.<br><br>You can also request a private project exclusively for you, but such a project can no longer be free.</source>
|
||||||
|
<translation type="unfinished">Мы всегда рады помочь вам реализовать ваши лучшие и самые фантастические идеи. <br> <br> Если у вас есть идея для приложения, вы можете оставить заявку на создание проекта у нас на GitHub. Все, что от вас требуется, - это подробное описание того, что нужно сделать. Далее наши специалисты решат, когда начнется работа над проектом и сколько ресурсов будет выделено для проекта. <br> <br> То, сколько ресурсов будет выделено на разработку, зависит от того, сколько этот проект собирет денежными пожертвованиями. . <br> <br> Вы также можете запросить частный проект исключительно для вас, но такой проект больше не может быть бесплатным.</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../Models/qasarapporder.cpp" line="23"/>
|
||||||
|
<source>Order a project.</source>
|
||||||
|
<translation type="unfinished">Заказать проект.</translation>
|
||||||
</message>
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user