mirror of
https://github.com/kiwix/kiwix-desktop.git
synced 2025-09-22 03:26:05 -04:00
Merge pull request #16 from kiwix/windows
Make kiwix-desktop work on Windows.
This commit is contained in:
commit
4c8996d95b
@ -57,7 +57,6 @@ INSTALLS += target
|
||||
|
||||
static {
|
||||
PKGCONFIG_OPTION = "--static"
|
||||
QMAKE_LFLAGS += "-static-libstdc++ --static"
|
||||
}
|
||||
|
||||
unix {
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "kiwixapp.h"
|
||||
#include "zim/error.h"
|
||||
|
||||
KiwixApp::KiwixApp(int& argc, char *argv[])
|
||||
: QApplication(argc, argv),
|
||||
@ -21,7 +22,12 @@ void KiwixApp::openZimFile(const QString &zimfile)
|
||||
std::cout << "Opening " << zimfile_ << std::endl;
|
||||
try {
|
||||
reader = new kiwix::Reader(zimfile_);
|
||||
} catch (...) {
|
||||
} catch (const zim::ZimFileFormatError& e) {
|
||||
std::cout << "Cannot open " << zimfile_ << std::endl;
|
||||
std::cout << e.what() << std::endl;
|
||||
reader = nullptr;
|
||||
} catch (const std::exception& e) {
|
||||
std::cout << "oup" << e.what() << std::endl;
|
||||
reader = nullptr;
|
||||
}
|
||||
}
|
||||
|
@ -14,10 +14,12 @@ void KiwixRequestInterceptor::interceptRequest(QWebEngineUrlRequestInfo &info)
|
||||
{
|
||||
std::cout << "Intercept request" << std::endl;
|
||||
auto url = info.requestUrl();
|
||||
std::cout << " - " << url.toString().toUtf8().constData() << std::endl;
|
||||
url.setScheme("zim");
|
||||
std::cout << " + " << url.toString().toUtf8().constData() << std::endl;
|
||||
info.redirect(url);
|
||||
|
||||
auto urlString = url.toString();
|
||||
std::cout << " - " << urlString.toUtf8().constData() << std::endl;
|
||||
if (urlString.startsWith("http://")) {
|
||||
urlString.replace(0, 7, "zim://");
|
||||
}
|
||||
std::cout << " + " << urlString.toUtf8().constData() << std::endl;
|
||||
info.redirect(QUrl(urlString));
|
||||
}
|
||||
|
||||
|
@ -44,10 +44,9 @@ KiwixSchemeHandler::requestStarted(QWebEngineUrlRequestJob *request)
|
||||
request->fail(QWebEngineUrlRequestJob::UrlNotFound);
|
||||
return;
|
||||
}
|
||||
|
||||
BlobBuffer* buffer = new BlobBuffer(entry.getBlob());
|
||||
std::cout << " mimetype : " << entry.getMimetype() << std::endl;
|
||||
auto mimeType = QByteArray::fromRawData(entry.getMimetype().data(), entry.getMimetype().size());
|
||||
std::cout << " mimetype : '" << entry.getMimetype() << "'" << std::endl;
|
||||
auto mimeType = QByteArray::fromStdString(entry.getMimetype());
|
||||
connect(buffer, &QIODevice::aboutToClose, buffer, &QObject::deleteLater);
|
||||
request->reply(mimeType, buffer);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user