mirror of
https://github.com/zealdocs/zeal.git
synced 2024-11-27 11:44:56 +03:00
ui: Implement interactive welcome page (fixes #323)
This commit is contained in:
parent
ab1c1a2bae
commit
f85b902fc7
File diff suppressed because one or more lines are too long
@ -12,38 +12,36 @@
|
||||
|
||||
<body class="is-unselectable">
|
||||
<section class="hero is-fullheight">
|
||||
<div class="hero-head">
|
||||
<header class="navbar is-transparent" role="navigation">
|
||||
<div class="navbar-brand">
|
||||
<a class="navbar-item" href="https://zealdocs.org/">zealdocs.org</a>
|
||||
</div>
|
||||
<div class="navbar-menu">
|
||||
<div class="navbar-end">
|
||||
<a class="navbar-item" href="https://go.zealdocs.org/l/gitter">
|
||||
<span class="icon">
|
||||
<i class="fab fa-gitter"></i>
|
||||
</span>
|
||||
<span>Gitter</span>
|
||||
</a>
|
||||
<a class="navbar-item" href="https://go.zealdocs.org/l/github">
|
||||
<span class="icon">
|
||||
<i class="fab fa-github"></i>
|
||||
</span>
|
||||
<span>GitHub</span>
|
||||
</a>
|
||||
<div class="hero-body">
|
||||
<div class="container">
|
||||
<div class="columns is-vcentered">
|
||||
<div class="column has-text-centered">
|
||||
<p class="title">Zeal
|
||||
<span id="version" class="has-text-weight-light is-size-5"></span>
|
||||
</p>
|
||||
<p class="subtitle">Docs for everyone</p>
|
||||
</div>
|
||||
<div class="column">
|
||||
<p class="subtitle is-5">Customize</p>
|
||||
<div class="command-block" onclick="zAppBridge.triggerAction('openDocsetManager')">
|
||||
<p class="title is-6">Docsets</p>
|
||||
<p class="subtitle is-6">Install and update docsets</p>
|
||||
</div>
|
||||
<div class="command-block" onclick="zAppBridge.triggerAction('openPreferences')">
|
||||
<p class="title is-6">Preferences</p>
|
||||
<p class="subtitle is-6">Adjust application settings</p>
|
||||
</div>
|
||||
<p class="subtitle is-5">Get in touch</p>
|
||||
<div class="command-block" onclick="zAppBridge.openShortUrl('gitter')">
|
||||
<p class="title is-6">Gitter</p>
|
||||
<p class="subtitle is-6">Chat with developers and other users</p>
|
||||
</div>
|
||||
<div class="command-block" onclick="zAppBridge.openShortUrl('github')">
|
||||
<p class="title is-6">GitHub</p>
|
||||
<p class="subtitle is-6">Contribute to the project</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
</div>
|
||||
|
||||
<div class="hero-body">
|
||||
<div class="container has-text-centered">
|
||||
<h1 class="title">
|
||||
Zeal
|
||||
</h1>
|
||||
<h2 class="subtitle">
|
||||
Docs for everyone
|
||||
</h2>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -51,18 +49,18 @@
|
||||
<div class="container">
|
||||
<div class="content has-text-centered">
|
||||
<p>
|
||||
<a class="icon" href="https://go.zealdocs.org/l/github">
|
||||
<a class="icon" onclick="zAppBridge.openShortUrl('github')">
|
||||
<i class="fab fa-github"></i>
|
||||
</a>
|
||||
<a class="icon" href="https://go.zealdocs.org/l/gitter">
|
||||
<a class="icon" onclick="zAppBridge.openShortUrl('gitter')">
|
||||
<i class="fab fa-gitter"></i>
|
||||
</a>
|
||||
<a class="icon" href="https://go.zealdocs.org/l/twitter">
|
||||
<a class="icon" onclick="zAppBridge.openShortUrl('twiter')">
|
||||
<i class="fab fa-twitter"></i>
|
||||
</a>
|
||||
</p>
|
||||
<p>
|
||||
<a class="is-size-7" href="https://go.zealdocs.org/l/report-bug">
|
||||
<a class="is-size-7" onclick="zAppBridge.openShortUrl('report-bug')">
|
||||
<span class="icon">
|
||||
<i class="fas fa-bug"></i>
|
||||
</span>
|
||||
@ -74,6 +72,10 @@
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<script>
|
||||
document.getElementById("version").textContent = zAppBridge.AppVersion;
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
@ -12,63 +12,61 @@
|
||||
|
||||
<body class="is-unselectable">
|
||||
<section class="hero is-fullheight">
|
||||
<div class="hero-head">
|
||||
<header class="navbar is-transparent" role="navigation">
|
||||
<div class="navbar-brand">
|
||||
<a class="navbar-item" href="https://zealdocs.org/">zealdocs.org</a>
|
||||
</div>
|
||||
<div class="navbar-menu">
|
||||
<div class="navbar-end">
|
||||
<a class="navbar-item" href="https://go.zealdocs.org/l/gitter">
|
||||
<span class="icon">
|
||||
<i class="fab fa-gitter"></i>
|
||||
</span>
|
||||
<span>Gitter</span>
|
||||
</a>
|
||||
<a class="navbar-item" href="https://go.zealdocs.org/l/github">
|
||||
<span class="icon">
|
||||
<i class="fab fa-github"></i>
|
||||
</span>
|
||||
<span>GitHub</span>
|
||||
</a>
|
||||
<div class="hero-body">
|
||||
<div class="container">
|
||||
<div class="columns is-vcentered">
|
||||
<div class="column has-text-centered">
|
||||
<p class="title">Zeal
|
||||
<span id="version" class="has-text-weight-light is-size-5"></span>
|
||||
</p>
|
||||
<p class="subtitle">Docs for everyone</p>
|
||||
<div id="carboncontainer" style="margin-top: 75px;">
|
||||
<div id="carbon" class="box">
|
||||
<script async type="text/javascript" src="https://cdn.carbonads.com/carbon.js?zoneid=1673&serve=C6AILKT&placement=zealdocsforwindowsorg"
|
||||
onerror="document.getElementById('carboncontainer').style.display = 'none';" id="_carbonads_js"></script>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="column">
|
||||
<p class="subtitle is-5">Customize</p>
|
||||
<div class="command-block" onclick="zAppBridge.triggerAction('openDocsetManager')">
|
||||
<p class="title is-6">Docsets</p>
|
||||
<p class="subtitle is-6">Install and update docsets</p>
|
||||
</div>
|
||||
<div class="command-block" onclick="zAppBridge.triggerAction('openPreferences')">
|
||||
<p class="title is-6">Preferences</p>
|
||||
<p class="subtitle is-6">Adjust application settings</p>
|
||||
</div>
|
||||
<p class="subtitle is-5">Get in touch</p>
|
||||
<div class="command-block" onclick="zAppBridge.openShortUrl('gitter')">
|
||||
<p class="title is-6">Gitter</p>
|
||||
<p class="subtitle is-6">Chat with developers and other users</p>
|
||||
</div>
|
||||
<div class="command-block" onclick="zAppBridge.openShortUrl('github')">
|
||||
<p class="title is-6">GitHub</p>
|
||||
<p class="subtitle is-6">Contribute to the project</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
</div>
|
||||
|
||||
<div class="hero-body">
|
||||
<div class="container has-text-centered">
|
||||
<h1 class="title">
|
||||
Zeal
|
||||
</h1>
|
||||
<h2 class="subtitle">
|
||||
Docs for everyone
|
||||
</h2>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="hero-foot">
|
||||
<div class="container">
|
||||
<div class="content has-text-centered">
|
||||
<div id="carboncontainer">
|
||||
<div id="carbon" class="box">
|
||||
<script async type="text/javascript" src="https://cdn.carbonads.com/carbon.js?zoneid=1673&serve=C6AILKT&placement=zealdocsforwindowsorg"
|
||||
onerror="document.getElementById('carboncontainer').style.display = 'none';" id="_carbonads_js"></script>
|
||||
</div>
|
||||
</div>
|
||||
<p>
|
||||
<a class="icon" href="https://go.zealdocs.org/l/github">
|
||||
<a class="icon" onclick="zAppBridge.openShortUrl('github')">
|
||||
<i class="fab fa-github"></i>
|
||||
</a>
|
||||
<a class="icon" href="https://go.zealdocs.org/l/gitter">
|
||||
<a class="icon" onclick="zAppBridge.openShortUrl('gitter')">
|
||||
<i class="fab fa-gitter"></i>
|
||||
</a>
|
||||
<a class="icon" href="https://go.zealdocs.org/l/twitter">
|
||||
<a class="icon" onclick="zAppBridge.openShortUrl('twiter')">
|
||||
<i class="fab fa-twitter"></i>
|
||||
</a>
|
||||
</p>
|
||||
<p>
|
||||
<a class="is-size-7" href="https://go.zealdocs.org/l/report-bug">
|
||||
<a class="is-size-7" onclick="zAppBridge.openShortUrl('report-bug')">
|
||||
<span class="icon">
|
||||
<i class="fas fa-bug"></i>
|
||||
</span>
|
||||
@ -80,6 +78,10 @@
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<script>
|
||||
document.getElementById("version").textContent = zAppBridge.AppVersion;
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
@ -24,6 +24,7 @@ add_library(Ui
|
||||
progressitemdelegate.cpp
|
||||
searchitemdelegate.cpp
|
||||
settingsdialog.cpp
|
||||
webbridge.cpp
|
||||
${Widgets_SOURCES}
|
||||
${Ui_FORMS} # For Qt Creator.
|
||||
)
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include "docsetsdialog.h"
|
||||
#include "searchitemdelegate.h"
|
||||
#include "settingsdialog.h"
|
||||
#include "webbridge.h"
|
||||
#include "qxtglobalshortcut/qxtglobalshortcut.h"
|
||||
#include "widgets/webviewtab.h"
|
||||
|
||||
@ -312,6 +313,17 @@ MainWindow::MainWindow(Core::Application *app, QWidget *parent) :
|
||||
m_settings->tocSplitterState = ui->tocSplitter->saveState();
|
||||
});
|
||||
|
||||
|
||||
m_webBridge = new WebBridge(this);
|
||||
connect(m_webBridge, &WebBridge::actionTriggered, this, [this](const QString &action) {
|
||||
// TODO: In the future connect directly to the ActionManager.
|
||||
if (action == "openDocsetManager") {
|
||||
ui->actionDocsets->trigger();
|
||||
} else if (action == "openPreferences") {
|
||||
ui->actionPreferences->trigger();
|
||||
}
|
||||
});
|
||||
|
||||
createTab();
|
||||
|
||||
connect(ui->treeView, &QTreeView::clicked, this, &MainWindow::openDocset);
|
||||
@ -520,6 +532,7 @@ WebViewTab *MainWindow::createTab(int index)
|
||||
index = m_tabStates.size();
|
||||
|
||||
TabState *newState = new TabState();
|
||||
newState->widget->setWebBridgeObject("zAppBridge", m_webBridge);
|
||||
newState->goToStartPage();
|
||||
|
||||
m_tabStates.insert(index, newState);
|
||||
@ -541,6 +554,7 @@ void MainWindow::duplicateTab(int index)
|
||||
syncTabState(tabState);
|
||||
|
||||
TabState *newState = new TabState(*tabState);
|
||||
newState->widget->setWebBridgeObject("zAppBridge", m_webBridge);
|
||||
|
||||
++index;
|
||||
m_tabStates.insert(index, newState);
|
||||
|
@ -51,6 +51,7 @@ namespace Ui {
|
||||
class MainWindow;
|
||||
} // namespace Ui
|
||||
|
||||
class WebBridge;
|
||||
class WebViewTab;
|
||||
|
||||
struct TabState;
|
||||
@ -110,6 +111,8 @@ private:
|
||||
Core::Settings *m_settings = nullptr;
|
||||
Registry::ListModel *m_zealListModel = nullptr;
|
||||
|
||||
WebBridge *m_webBridge = nullptr;
|
||||
|
||||
QMenu *m_backMenu = nullptr;
|
||||
QMenu *m_forwardMenu = nullptr;
|
||||
|
||||
|
49
src/libs/ui/webbridge.cpp
Normal file
49
src/libs/ui/webbridge.cpp
Normal file
@ -0,0 +1,49 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2018 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 "webbridge.h"
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QDesktopServices>
|
||||
#include <QUrl>
|
||||
|
||||
using namespace Zeal::WidgetUi;
|
||||
|
||||
WebBridge::WebBridge(QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
}
|
||||
|
||||
void WebBridge::openShortUrl(const QString &key)
|
||||
{
|
||||
QDesktopServices::openUrl(QUrl(QStringLiteral("https://go.zealdocs.org/l/") + key));
|
||||
}
|
||||
|
||||
void WebBridge::triggerAction(const QString &action)
|
||||
{
|
||||
emit actionTriggered(action);
|
||||
}
|
||||
|
||||
QString WebBridge::appVersion() const
|
||||
{
|
||||
return QCoreApplication::applicationVersion();
|
||||
}
|
52
src/libs/ui/webbridge.h
Normal file
52
src/libs/ui/webbridge.h
Normal file
@ -0,0 +1,52 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2018 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/>.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef ZEAL_WIDGETUI_WEBBRIDGE_H
|
||||
#define ZEAL_WIDGETUI_WEBBRIDGE_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
namespace Zeal {
|
||||
namespace WidgetUi {
|
||||
|
||||
class WebBridge : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QString AppVersion READ appVersion CONSTANT)
|
||||
public:
|
||||
explicit WebBridge(QObject *parent = nullptr);
|
||||
|
||||
signals:
|
||||
void actionTriggered(const QString &action);
|
||||
|
||||
public slots:
|
||||
Q_INVOKABLE void openShortUrl(const QString &key);
|
||||
Q_INVOKABLE void triggerAction(const QString &action);
|
||||
|
||||
private:
|
||||
QString appVersion() const;
|
||||
};
|
||||
|
||||
} // namespace WidgetUi
|
||||
} // namespace Zeal
|
||||
|
||||
#endif // ZEAL_WIDGETUI_WEBBRIDGE_H
|
@ -70,6 +70,14 @@ void WebViewTab::setZoomLevel(int level)
|
||||
m_webView->setZoomLevel(level);
|
||||
}
|
||||
|
||||
void WebViewTab::setWebBridgeObject(const QString &name, QObject *object)
|
||||
{
|
||||
connect(m_webView->page()->mainFrame(), &QWebFrame::javaScriptWindowObjectCleared,
|
||||
this, [=]() {
|
||||
m_webView->page()->mainFrame()->addToJavaScriptWindowObject(name, object);
|
||||
});
|
||||
}
|
||||
|
||||
void WebViewTab::load(const QUrl &url)
|
||||
{
|
||||
m_webView->load(url);
|
||||
|
@ -53,6 +53,8 @@ public:
|
||||
int zoomLevel() const;
|
||||
void setZoomLevel(int level);
|
||||
|
||||
void setWebBridgeObject(const QString &name, QObject *object);
|
||||
|
||||
signals:
|
||||
void titleChanged(const QString &title);
|
||||
void urlChanged(const QUrl &url);
|
||||
|
Loading…
Reference in New Issue
Block a user