Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
@@ -0,0 +1,34 @@
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
# Created by Astrid Müller, SGAS, 2018-04-10
|
||||
#
|
||||
|
||||
SET(online_help_viewer_gui_SRCS
|
||||
online_help_viewer_gui_plugin.cpp
|
||||
online_help_viewer_gui_plugin.h
|
||||
online_help_viewer_dialog.cpp
|
||||
online_help_viewer_dialog.h
|
||||
logger.cpp
|
||||
)
|
||||
|
||||
NGL_WRAP_UI(online_help_viewer_gui_SRCS
|
||||
online_help_viewer_dialog.ui
|
||||
)
|
||||
|
||||
NGL_ADD_LIBRARY(WS OhpOnlineHelpViewerGuiPlugin MODULE ${online_help_viewer_gui_SRCS})
|
||||
NGL_TARGET_LINK_LIBRARIES(OhpOnlineHelpViewerGuiPlugin
|
||||
OhpOnlineHelpViewerGuiPluginInterface
|
||||
ngltranslator
|
||||
GuiPluginInterface
|
||||
Qt5::Widgets
|
||||
Qt5::WebEngineWidgets
|
||||
LtsSession
|
||||
ngltools
|
||||
NGLLogger
|
||||
)
|
||||
|
||||
NGL_INSTALL_TARGET(OhpOnlineHelpViewerGuiPlugin)
|
||||
|
||||
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Building Config - logging facility
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
#include "logger.h"
|
||||
|
||||
#include <NGLLogger/NGLLoggerBootstrap.h>
|
||||
|
||||
namespace OnlineHelp
|
||||
{
|
||||
|
||||
LOGGER_T getLogger(const char *name)
|
||||
{
|
||||
static const char ns[] = "OLH.";
|
||||
std::string loggerName;
|
||||
const size_t len = strlen(name);
|
||||
loggerName.reserve(sizeof(ns) + len);
|
||||
loggerName.append(ns, sizeof(ns) - 1);
|
||||
loggerName.append(name, len);
|
||||
|
||||
try
|
||||
{
|
||||
return NGL::NGLLoggerBootstrap::getNGLRootLogger().
|
||||
getNGLLogger(loggerName);
|
||||
}
|
||||
catch (const std::exception &ex)
|
||||
{
|
||||
fprintf(stderr, "Error retrieving logger: %s", ex.what());
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace OnlineHelp
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Logging for CentralEffectSimulation
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <NGLLogger/INGLLogger.h>
|
||||
|
||||
namespace OnlineHelp
|
||||
{
|
||||
typedef NGL::INGLLogger &LOGGER_T;
|
||||
|
||||
LOGGER_T getLogger(const char *name);
|
||||
inline LOGGER_T getLogger(const QString &loggerName)
|
||||
{
|
||||
return getLogger(loggerName.toUtf8().constData());
|
||||
}
|
||||
} // namespace OnlineHelp
|
||||
@@ -0,0 +1,117 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Online Help Viewer Dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Astrid Müller, SGAS, 2018-04-10
|
||||
*/
|
||||
|
||||
#include "online_help_viewer_dialog.h"
|
||||
#include "ui_online_help_viewer_dialog.h"
|
||||
|
||||
#include <ngltranslator/ngltranslator.h>
|
||||
#include <ngltools/ngltools_filesystem.h>
|
||||
|
||||
#include <QWebEngineView>
|
||||
#include <QWebEngineHistory>
|
||||
#include <QMenu>
|
||||
|
||||
|
||||
namespace OnlineHelp
|
||||
{
|
||||
OnlineHelpViewerDialog::OnlineHelpViewerDialog(bool isMain)
|
||||
: LtsWidgets::LtsDialog(nullptr,
|
||||
isMain ? LtsWidgets::ButtonCombination::SeamlessDialog : LtsWidgets::ButtonCombination::CloseOnly,
|
||||
!isMain /* closable if NOT main */)
|
||||
, m_ui(new Ui::OnlineHelpViewerDialog)
|
||||
, m_logger(getLogger("onlineHelp"))
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
}
|
||||
|
||||
bool OnlineHelpViewerDialog::init(const QString &fileName)
|
||||
{
|
||||
QString locale;
|
||||
|
||||
if (NGL::translationLocale() == "de_DE") // grrr..
|
||||
locale = QStringLiteral("de_DE");
|
||||
else
|
||||
locale = QStringLiteral("en_GB");
|
||||
|
||||
QString helpDir = NGL::directory(NGL::FileType::ConfigFile, QStringLiteral("help"));
|
||||
if (fileName.isEmpty())
|
||||
helpDir += (locale + QStringLiteral("/index.html"));
|
||||
else // filename given
|
||||
helpDir += (locale + QStringLiteral("/%1.html").arg(fileName));
|
||||
|
||||
INFO_LOG(m_logger) << "helpDir=" << helpDir;
|
||||
|
||||
#ifndef LTS_DEBUG
|
||||
m_ui->lblPage->setVisible(false);
|
||||
#endif
|
||||
|
||||
connect(m_ui->wevOnlineHelpViewer, &QWebEngineView::loadFinished, this, [=](bool ok)
|
||||
{
|
||||
Q_UNUSED(ok);
|
||||
QString url = m_ui->wevOnlineHelpViewer->page()->url().toString();
|
||||
m_ui->lblPage->setText(url);
|
||||
});
|
||||
|
||||
m_ui->wevOnlineHelpViewer->load(QUrl(QUrl::fromLocalFile(helpDir)));
|
||||
|
||||
m_ui->wevOnlineHelpViewer->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
connect(m_ui->wevOnlineHelpViewer, &QWebEngineView::customContextMenuRequested,
|
||||
this, &OnlineHelpViewerDialog::onContextMenuRequested);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
OnlineHelpViewerDialog::~OnlineHelpViewerDialog()
|
||||
{
|
||||
m_ui->wevOnlineHelpViewer->setParent(nullptr);
|
||||
m_ui->wevOnlineHelpViewer->hide();
|
||||
m_ui->wevOnlineHelpViewer->deleteLater();
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void OnlineHelpViewerDialog::retranslate()
|
||||
{
|
||||
translate(m_ui, tr("Online Help Viewer"));
|
||||
}
|
||||
|
||||
void OnlineHelpViewerDialog::onContextMenuRequested(const QPoint &position)
|
||||
{
|
||||
QMenu menu(m_ui->wevOnlineHelpViewer);
|
||||
QAction *action = menu.addAction(tr("Next Page"), this, &OnlineHelpViewerDialog::onContextdMenuForwardRequested);
|
||||
action->setEnabled(m_ui->wevOnlineHelpViewer->page()->history()->canGoForward());
|
||||
|
||||
action = menu.addAction(tr("Last Page"), this, &OnlineHelpViewerDialog::onContextdMenuBackRequested);
|
||||
|
||||
bool setEnable = (m_ui->wevOnlineHelpViewer->page()->history()->canGoBack()) &&
|
||||
(m_ui->wevOnlineHelpViewer->page()->history()->backItems(2).size() > 1); // *)
|
||||
// *) Die erste HistorySeite ist nach dem Aufschalten des Widgets immer leer.
|
||||
// Hiermit wird verhindert dass man in diese erste leere Seite zurueckgehen kann.
|
||||
|
||||
action->setEnabled(setEnable);
|
||||
|
||||
menu.addAction(tr("Reload Page"), this, &OnlineHelpViewerDialog::onContextdMenuReloadRequested);
|
||||
menu.exec(m_ui->wevOnlineHelpViewer->mapToGlobal(position));
|
||||
}
|
||||
|
||||
void OnlineHelpViewerDialog::onContextdMenuForwardRequested()
|
||||
{
|
||||
m_ui->wevOnlineHelpViewer->page()->triggerAction(QWebEnginePage::Forward);
|
||||
}
|
||||
|
||||
void OnlineHelpViewerDialog::onContextdMenuBackRequested()
|
||||
{
|
||||
m_ui->wevOnlineHelpViewer->page()->triggerAction(QWebEnginePage::Back);
|
||||
}
|
||||
|
||||
void OnlineHelpViewerDialog::onContextdMenuReloadRequested()
|
||||
{
|
||||
m_ui->wevOnlineHelpViewer->page()->triggerAction(QWebEnginePage::Reload);
|
||||
}
|
||||
|
||||
} // namespace OnlineHelp
|
||||
@@ -0,0 +1,45 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Online Help Viewer Add Dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Astrid Müller, SGAS, 2018-04-10
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "logger.h"
|
||||
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class OnlineHelpViewerDialog;
|
||||
}
|
||||
|
||||
namespace OnlineHelp
|
||||
{
|
||||
class OnlineHelpViewerDialog : public LtsWidgets::LtsDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit OnlineHelpViewerDialog(bool isMain = false);
|
||||
~OnlineHelpViewerDialog();
|
||||
bool init(const QString &fileName = QString());
|
||||
|
||||
private slots:
|
||||
void onContextMenuRequested(const QPoint &position);
|
||||
void onContextdMenuForwardRequested();
|
||||
void onContextdMenuBackRequested();
|
||||
void onContextdMenuReloadRequested();
|
||||
|
||||
private:
|
||||
void retranslate() override;
|
||||
|
||||
Ui::OnlineHelpViewerDialog *m_ui;
|
||||
NGL::INGLLogger &m_logger;
|
||||
};
|
||||
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>OnlineHelpViewerDialog</class>
|
||||
<widget class="QWidget" name="OnlineHelpViewerDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="lblPage">
|
||||
<property name="text">
|
||||
<string>URL</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWebEngineView" name="wevOnlineHelpViewer">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="url">
|
||||
<url>
|
||||
<string>about:blank</string>
|
||||
</url>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>QWebEngineView</class>
|
||||
<extends>QWidget</extends>
|
||||
<header location="global">QtWebEngineWidgets/QWebEngineView</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* GUI Plugin for OnlineHelpViewer
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Astrid Müller, SGAS, 2018-04-10
|
||||
*/
|
||||
|
||||
#include "online_help_viewer_gui_plugin.h"
|
||||
#include "online_help_viewer_dialog.h"
|
||||
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <NGLLogger/NGLLoggerBootstrap.h>
|
||||
|
||||
namespace OnlineHelp
|
||||
{
|
||||
|
||||
std::shared_ptr<GuiPluginBase::Interface> GuiPlugin::createGuiInterface(LtsSession::LtsSession *session)
|
||||
{
|
||||
return std::make_shared<InterfaceImpl>(session);
|
||||
}
|
||||
|
||||
|
||||
InterfaceImpl::InterfaceImpl(LtsSession::LtsSession *session)
|
||||
: GuiPluginBase::Interface(session,
|
||||
NGL::NGLLoggerBootstrap::getNGLRootLogger().getNGLLogger("OnlineHelpViewerInterface"))
|
||||
{}
|
||||
|
||||
QVector<LtsWidgets::PluginData> InterfaceImpl::getActions()
|
||||
{
|
||||
QVector<LtsWidgets::PluginData> ret;
|
||||
|
||||
if (getFlags().testFlag(LtsAppDescriptor::PluginInfo::Flag::MAIN))
|
||||
{
|
||||
LtsWidgets::PluginData plData;
|
||||
plData.layoutArea = LtsWidgets::LayoutArea::eMainTab;
|
||||
plData.createInstant = LtsWidgets::CreateInstantType::CreateInstantAndDiscardAction;
|
||||
plData.menuGroup = menuGroup();
|
||||
plData.menuText = tr("Online Help Viewer");
|
||||
plData.identifier = QLatin1String("ohpOnlineHelpViewer");
|
||||
plData.exercisePart = LtsWidgets::ExercisePart::eSpecial;
|
||||
plData.createWidgetFunc = [this](QWidget *)
|
||||
{
|
||||
return onShowOnlineHelpViewer();
|
||||
};
|
||||
ret.append(plData);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void InterfaceImpl::showHelp(const QString &fileName)
|
||||
{
|
||||
m_session->addWidget(LtsWidgets::initDialog(new OnlineHelpViewerDialog(), fileName),
|
||||
menuGroup(), QStringLiteral("OnlineHelp%1").arg(fileName), LtsWidgets::LayoutArea::eInfoTab);
|
||||
}
|
||||
|
||||
LtsWidgets::LtsDialog *InterfaceImpl::onShowOnlineHelpViewer()
|
||||
{
|
||||
return LtsWidgets::initDialog(new OnlineHelpViewerDialog(true /* is main */));
|
||||
}
|
||||
|
||||
}
|
||||
// namespace OnlineHelp
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Gui Plugin for OnlineHelpViewer
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Astrid Müller, SGAS, 2018-04-10
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <Plugins/OnlineHelp/ohp_online_help_viewer_gui_plugin_interface.h>
|
||||
|
||||
namespace OnlineHelp
|
||||
{
|
||||
|
||||
class GuiPlugin final : public QObject, public GuiPluginBase::Plugin
|
||||
{
|
||||
Q_PLUGIN_METADATA(IID "gui:3:ohp.onlinehelpviewer")
|
||||
Q_INTERFACES(GuiPluginBase::Plugin)
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit GuiPlugin() = default;
|
||||
~GuiPlugin() = default;
|
||||
|
||||
QString pluginName() override { return QStringLiteral("OnlineHelpViewerGui"); }
|
||||
std::shared_ptr<GuiPluginBase::Interface> createGuiInterface(LtsSession::LtsSession *session) override;
|
||||
bool availableInPartition(IDL::PartitionType ) const override { return true; }
|
||||
};
|
||||
|
||||
|
||||
class InterfaceImpl final : public QObject, public GuiPluginBase::Interface, public ForeignOnlineHelpViewerGuiInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit InterfaceImpl(LtsSession::LtsSession *session);
|
||||
|
||||
QVector<LtsWidgets::PluginData> getActions() override;
|
||||
QString menuGroup() const override { return tr("Online Help Viewer"); }
|
||||
void showHelp(const QString &fileName) override;
|
||||
|
||||
private:
|
||||
LtsWidgets::LtsDialog *onShowOnlineHelpViewer();
|
||||
};
|
||||
|
||||
} // namespace OnlineHelp
|
||||
Reference in new issue
Block a user