-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First version to be upload to github
- Loading branch information
1 parent
9cd8d2d
commit 089f927
Showing
420 changed files
with
246,086 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
#------------------------------------------------- | ||
# | ||
# Project created by QtCreator 2021-07-30T16:28:03 | ||
# | ||
#------------------------------------------------- | ||
|
||
QT += core gui network concurrent | ||
|
||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets | ||
|
||
TARGET = ZealT | ||
TEMPLATE = app | ||
|
||
# The following define makes your compiler emit warnings if you use | ||
# any feature of Qt which has been marked as deprecated (the exact warnings | ||
# depend on your compiler). Please consult the documentation of the | ||
# deprecated API in order to know how to port your code away from it. | ||
DEFINES += QT_DEPRECATED_WARNINGS | ||
|
||
# You can also make your code fail to compile if you use deprecated APIs. | ||
# In order to do so, uncomment the following line. | ||
# You can also select to disable deprecated APIs only up to a certain version of Qt. | ||
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 | ||
|
||
|
||
SOURCES += \ | ||
core/application.cpp \ | ||
core/applicationsingleton.cpp \ | ||
core/filemanager.cpp \ | ||
core/networkaccessmanager.cpp \ | ||
core/settings.cpp \ | ||
main.cpp \ | ||
registry/docset.cpp \ | ||
registry/docsetmetadata.cpp \ | ||
registry/docsetregistry.cpp \ | ||
registry/listmodel.cpp \ | ||
registry/searchmodel.cpp \ | ||
registry/searchquery.cpp \ | ||
ui/aboutdialog.cpp \ | ||
ui/docsetlistitemdelegate.cpp \ | ||
ui/docsetsdialog.cpp \ | ||
ui/mainwindow.cpp \ | ||
ui/progressitemdelegate.cpp \ | ||
ui/qxtglobalshortcut/qxtglobalshortcut.cpp \ | ||
ui/qxtglobalshortcut/qxtglobalshortcut_win.cpp \ | ||
ui/searchitemdelegate.cpp \ | ||
ui/settingsdialog.cpp \ | ||
ui/webbridge.cpp \ | ||
ui/widgets/searchedit.cpp \ | ||
ui/widgets/searchtoolbar.cpp \ | ||
ui/widgets/shortcutedit.cpp \ | ||
ui/widgets/toolbarframe.cpp \ | ||
util/plist.cpp \ | ||
util/sqlitedatabase.cpp \ | ||
util/version.cpp | ||
|
||
HEADERS += \ | ||
core/application.h \ | ||
core/applicationsingleton.h \ | ||
core/filemanager.h \ | ||
core/networkaccessmanager.h \ | ||
core/settings.h \ | ||
registry/cancellationtoken.h \ | ||
registry/docset.h \ | ||
registry/docsetmetadata.h \ | ||
registry/docsetregistry.h \ | ||
registry/itemdatarole.h \ | ||
registry/listmodel.h \ | ||
registry/searchmodel.h \ | ||
registry/searchquery.h \ | ||
registry/searchresult.h \ | ||
ui/aboutdialog.h \ | ||
ui/docsetlistitemdelegate.h \ | ||
ui/docsetsdialog.h \ | ||
ui/mainwindow.h \ | ||
ui/progressitemdelegate.h \ | ||
ui/qxtglobalshortcut/qxtglobalshortcut.h \ | ||
ui/qxtglobalshortcut/qxtglobalshortcut_p.h \ | ||
ui/searchitemdelegate.h \ | ||
ui/settingsdialog.h \ | ||
ui/webbridge.h \ | ||
ui/widgets/searchedit.h \ | ||
ui/widgets/searchtoolbar.h \ | ||
ui/widgets/shortcutedit.h \ | ||
ui/widgets/toolbarframe.h \ | ||
util/plist.h \ | ||
util/sqlitedatabase.h \ | ||
util/version.h | ||
|
||
FORMS += \ | ||
ui/aboutdialog.ui \ | ||
ui/docsetsdialog.ui \ | ||
ui/mainwindow.ui \ | ||
ui/settingsdialog.ui | ||
|
||
RESOURCES += \ | ||
resources/zeal.qrc | ||
|
||
|
||
# LIBS += -L"$$PWD/libarchive/lib" -larchive.lib | ||
# LIBS += -l"$$PWD/libarchive/lib/archive.lib" | ||
LIBS += "$$PWD/libarchive/lib/archive.lib" | ||
# LIBS += -L"$$PWD/libarchive/lib" -larchive_static | ||
|
||
INCLUDEPATH += libarchive/include | ||
DEPENDPATH += libarchive/include | ||
|
||
# LIBS += -L"$$PWD/sqlite/lib" -lsqlite3.lib | ||
# LIBS += -l"$$PWD/sqlite/lib/sqlite3.lib" | ||
LIBS += "$$PWD/sqlite/lib/sqlite3.lib" | ||
|
||
INCLUDEPATH += sqlite/include | ||
DEPENDPATH += sqlite/include |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
add_library(Core | ||
application.cpp | ||
applicationsingleton.cpp | ||
extractor.cpp | ||
filemanager.cpp | ||
networkaccessmanager.cpp | ||
settings.cpp | ||
) | ||
|
||
target_link_libraries(Core Registry Ui) | ||
|
||
find_package(Qt5 COMPONENTS Network WebKit Widgets REQUIRED) | ||
target_link_libraries(Core Qt5::Network Qt5::WebKit Qt5::Widgets) | ||
|
||
find_package(LibArchive REQUIRED) | ||
include_directories(${LibArchive_INCLUDE_DIRS}) | ||
target_link_libraries(Core ${LibArchive_LIBRARIES}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,265 @@ | ||
/**************************************************************************** | ||
** | ||
** Copyright (C) 2015-2016 Oleg Shparber | ||
** Contact: https://go.zealdocs.org/l/contact | ||
** | ||
** This file is part of Zeal. | ||
** | ||
** Zeal is free software: you can redistribute it and/or modify | ||
** it under the terms of the GNU General Public License as published by | ||
** the Free Software Foundation, either version 3 of the License, or | ||
** (at your option) any later version. | ||
** | ||
** Zeal is distributed in the hope that it will be useful, | ||
** but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
** GNU General Public License for more details. | ||
** | ||
** You should have received a copy of the GNU General Public License | ||
** along with Zeal. If not, see <https://www.gnu.org/licenses/>. | ||
** | ||
****************************************************************************/ | ||
|
||
#include "application.h" | ||
|
||
#include "extractor.h" | ||
#include "filemanager.h" | ||
#include "networkaccessmanager.h" | ||
#include "settings.h" | ||
|
||
#include <registry/docsetregistry.h> | ||
#include <registry/searchquery.h> | ||
#include <ui/mainwindow.h> | ||
#include <util/version.h> | ||
|
||
#include <QCoreApplication> | ||
#include <QJsonArray> | ||
#include <QJsonDocument> | ||
#include <QJsonObject> | ||
#include <QMetaObject> | ||
#include <QNetworkProxy> | ||
#include <QNetworkReply> | ||
#include <QScopedPointer> | ||
#include <QSysInfo> | ||
#include <QThread> | ||
|
||
using namespace Zeal; | ||
using namespace Zeal::Core; | ||
|
||
namespace { | ||
const char ReleasesApiUrl[] = "http://api.zealdocs.org/v1/releases"; | ||
} | ||
|
||
Application *Application::m_instance = nullptr; | ||
|
||
Application::Application(QObject *parent) : | ||
QObject(parent) | ||
{ | ||
// Ensure only one instance of Application | ||
Q_ASSERT(!m_instance); | ||
m_instance = this; | ||
|
||
m_settings = new Settings(this); | ||
m_networkManager = new NetworkAccessManager(this); | ||
|
||
m_fileManager = new FileManager(this); | ||
|
||
// Extractor setup | ||
// m_extractorThread = new QThread(this); | ||
// m_extractor = new Extractor(); | ||
// m_extractor->moveToThread(m_extractorThread); | ||
// m_extractorThread->start(); | ||
// connect(m_extractor, &Extractor::completed, this, &Application::extractionCompleted); | ||
// connect(m_extractor, &Extractor::error, this, &Application::extractionError); | ||
// connect(m_extractor, &Extractor::progress, this, &Application::extractionProgress); | ||
|
||
m_docsetRegistry = new Registry::DocsetRegistry(); | ||
|
||
connect(m_settings, &Settings::updated, this, &Application::applySettings); | ||
applySettings(); | ||
|
||
m_mainWindow = new WidgetUi::MainWindow(this); | ||
|
||
if (m_settings->startMinimized) { | ||
if (m_settings->showSystrayIcon && m_settings->minimizeToSystray) | ||
return; | ||
|
||
m_mainWindow->showMinimized(); | ||
} else { | ||
m_mainWindow->show(); | ||
} | ||
} | ||
|
||
Application::~Application() | ||
{ | ||
// m_extractorThread->quit(); | ||
// m_extractorThread->wait(); | ||
// delete m_extractor; | ||
delete m_mainWindow; | ||
delete m_docsetRegistry; | ||
} | ||
|
||
/*! | ||
* \internal | ||
* \brief Returns a pointer to the Core::Application instance. | ||
* \return A pointer or \c nullptr, if no instance has been created. | ||
*/ | ||
Application *Application::instance() | ||
{ | ||
return m_instance; | ||
} | ||
|
||
WidgetUi::MainWindow *Application::mainWindow() const | ||
{ | ||
return m_mainWindow; | ||
} | ||
|
||
QNetworkAccessManager *Application::networkManager() const | ||
{ | ||
return m_networkManager; | ||
} | ||
|
||
Settings *Application::settings() const | ||
{ | ||
return m_settings; | ||
} | ||
|
||
Registry::DocsetRegistry *Application::docsetRegistry() | ||
{ | ||
return m_docsetRegistry; | ||
} | ||
|
||
FileManager *Application::fileManager() const | ||
{ | ||
return m_fileManager; | ||
} | ||
|
||
void Application::executeQuery(const Registry::SearchQuery &query, bool preventActivation) | ||
{ | ||
m_mainWindow->search(query); | ||
|
||
if (preventActivation) | ||
return; | ||
|
||
m_mainWindow->bringToFront(); | ||
} | ||
|
||
//void Application::extract(const QString &filePath, const QString &destination, const QString &root) | ||
//{ | ||
//// QMetaObject::invokeMethod(m_extractor, "extract", Qt::QueuedConnection, | ||
//// Q_ARG(QString, filePath), Q_ARG(QString, destination), | ||
//// Q_ARG(QString, root)); | ||
//} | ||
|
||
QNetworkReply *Application::download(const QUrl &url) | ||
{ | ||
static const QString ua = userAgent(); | ||
static const QByteArray uaJson = userAgentJson().toUtf8(); | ||
|
||
QNetworkRequest request(url); | ||
request.setHeader(QNetworkRequest::UserAgentHeader, ua); | ||
|
||
if (url.host().endsWith(QLatin1String(".zealdocs.org", Qt::CaseInsensitive))) | ||
request.setRawHeader("X-Zeal-User-Agent", uaJson); | ||
|
||
return m_networkManager->get(request); | ||
} | ||
|
||
/*! | ||
\internal | ||
Performs a check whether a new Zeal version is available. Setting \a quiet to true supresses | ||
error and "you are using the latest version" message boxes. | ||
*/ | ||
// void Application::checkForUpdates(bool quiet) | ||
// { | ||
// QNetworkReply *reply = download(QUrl(ReleasesApiUrl)); | ||
// connect(reply, &QNetworkReply::finished, this, [this, quiet]() { | ||
// QScopedPointer<QNetworkReply, QScopedPointerDeleteLater> reply( | ||
// qobject_cast<QNetworkReply *>(sender())); | ||
|
||
// if (reply->error() != QNetworkReply::NoError) { | ||
// if (!quiet) | ||
// emit updateCheckError(reply->errorString()); | ||
// return; | ||
// } | ||
|
||
// QJsonParseError jsonError; | ||
// const QJsonDocument jsonDoc = QJsonDocument::fromJson(reply->readAll(), &jsonError); | ||
|
||
// if (jsonError.error != QJsonParseError::NoError) { | ||
// if (!quiet) | ||
// emit updateCheckError(jsonError.errorString()); | ||
// return; | ||
// } | ||
|
||
// const QJsonObject latestVersionInfo = jsonDoc.array().first().toObject(); | ||
// const Util::Version latestVersion = latestVersionInfo[QStringLiteral("version")].toString(); | ||
// if (latestVersion > Util::Version(QCoreApplication::applicationVersion())) | ||
// emit updateCheckDone(latestVersion.toString()); | ||
// else if (!quiet) | ||
// emit updateCheckDone(); | ||
// }); | ||
// } | ||
|
||
void Application::applySettings() | ||
{ | ||
m_docsetRegistry->setStoragePath(m_settings->docsetPath); | ||
m_docsetRegistry->setFuzzySearchEnabled(m_settings->fuzzySearchEnabled); | ||
|
||
// HTTP Proxy Settings | ||
switch (m_settings->proxyType) { | ||
case Core::Settings::ProxyType::None: | ||
QNetworkProxy::setApplicationProxy(QNetworkProxy::NoProxy); | ||
break; | ||
|
||
case Core::Settings::ProxyType::System: | ||
QNetworkProxyFactory::setUseSystemConfiguration(true); | ||
break; | ||
|
||
case Core::Settings::ProxyType::UserDefined: { | ||
QNetworkProxy proxy(QNetworkProxy::HttpProxy, m_settings->proxyHost, m_settings->proxyPort); | ||
if (m_settings->proxyAuthenticate) { | ||
proxy.setUser(m_settings->proxyUserName); | ||
proxy.setPassword(m_settings->proxyPassword); | ||
} | ||
|
||
QNetworkProxy::setApplicationProxy(proxy); | ||
|
||
// Force NM to pick up changes. | ||
m_networkManager->clearAccessCache(); | ||
break; | ||
} | ||
} | ||
} | ||
|
||
QString Application::userAgent() | ||
{ | ||
return QStringLiteral("Zeal/%1").arg(QCoreApplication::applicationVersion()); | ||
} | ||
|
||
QString Application::userAgentJson() const | ||
{ | ||
QJsonObject app = { | ||
{QStringLiteral("version"), QCoreApplication::applicationVersion()}, | ||
{QStringLiteral("qt_version"), qVersion()}, | ||
{QStringLiteral("install_id"), m_settings->installId} | ||
}; | ||
|
||
QJsonObject os = { | ||
{QStringLiteral("arch"), QSysInfo::currentCpuArchitecture()}, | ||
{QStringLiteral("name"), QSysInfo::prettyProductName()}, | ||
{QStringLiteral("product_type"), QSysInfo::productType()}, | ||
{QStringLiteral("product_version"), QSysInfo::productVersion()}, | ||
{QStringLiteral("kernel_type"), QSysInfo::kernelType()}, | ||
{QStringLiteral("kernel_version"), QSysInfo::kernelVersion()}, | ||
{QStringLiteral("locale"), QLocale::system().name()} | ||
}; | ||
|
||
QJsonObject ua = { | ||
{QStringLiteral("app"), app}, | ||
{QStringLiteral("os"), os} | ||
}; | ||
|
||
return QString::fromUtf8(QJsonDocument(ua).toJson(QJsonDocument::Compact)); | ||
} |
Oops, something went wrong.