The musredit help system is using now the system default web-browser. This simplifies things, especially the qtwebengine package is not needed anymore.
This commit is contained in:
parent
e5404d1370
commit
56917d3fec
@ -1,28 +1,12 @@
|
||||
#--- musredit for Qt > 5.0 ----------------------------------------------------
|
||||
|
||||
#--- check if Qt5WebEngine or Qt5WebKit is present ----------------------------
|
||||
find_package(Qt5WebEngine QUIET)
|
||||
find_package(Qt5WebKit QUIET)
|
||||
#find_package(Qt5WebEngine QUIET)
|
||||
#find_package(Qt5WebKit QUIET)
|
||||
|
||||
set(qt_libs Qt5::Core Qt5::Widgets Qt5::Network Qt5::Xml Qt5::Svg Qt5::PrintSupport)
|
||||
set(Qt5NoWeb 0)
|
||||
if (Qt5WebEngine_FOUND)
|
||||
message("-- Qt5WebEngine is present.")
|
||||
find_package(Qt5WebEngineWidgets QUIET CONFIG REQUIRED)
|
||||
set(qt_libs ${qt_libs} Qt5::WebEngine Qt5::WebEngineWidgets)
|
||||
# unset a potentially found Qt5Webkit
|
||||
unset(Qt5WebKit_FOUND)
|
||||
elseif (Qt5WebKit_FOUND)
|
||||
message("-- Qt5WebKit is present.")
|
||||
find_package(Qt5WebKitWidgets QUIET CONFIG REQUIRED)
|
||||
set(qt_libs ${qt_libs} Qt5::WebKit Qt5::WebKitWidgets)
|
||||
else (Qt5WebEngine_FOUND)
|
||||
message("-- Neither Qt5WebEngine nor Qt5WebKit found.")
|
||||
set(Qt5NoWeb 1)
|
||||
endif (Qt5WebEngine_FOUND)
|
||||
|
||||
set(musredit_src
|
||||
PHelp.cpp
|
||||
PTextEdit.cpp
|
||||
PSubTextEdit.cpp
|
||||
PAdmin.cpp
|
||||
|
@ -31,8 +31,8 @@
|
||||
#include <QValidator>
|
||||
#include <QComboBox>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include "PHelp.h"
|
||||
#include <QDesktopServices>
|
||||
#include <QUrl>
|
||||
|
||||
#include "PGetAsymmetryRunBlockDialog.h"
|
||||
|
||||
@ -284,12 +284,14 @@ void PGetAsymmetryRunBlockDialog::helpContent()
|
||||
if (fHelpUrl.isEmpty()) {
|
||||
QMessageBox::information(this, "**INFO**", "Will eventually show a help window");
|
||||
} else {
|
||||
#ifdef _WIN32GCC
|
||||
QMessageBox::information(this, "**INFO**", "If a newer Qt version was available, a help window would be shown!");
|
||||
#else
|
||||
PHelp *help = new PHelp(fHelpUrl);
|
||||
help->show();
|
||||
#endif // _WIN32GCC
|
||||
bool ok = QDesktopServices::openUrl(QUrl(fHelpUrl, QUrl::TolerantMode));
|
||||
if (!ok) {
|
||||
QString msg = QString("<p>Sorry: Couldn't open default web-browser for the help.<br>Please try: <a href=\"%1\">musrfit docu</a> in your web-browser.").arg(fHelpUrl);
|
||||
QMessageBox::critical( nullptr,
|
||||
tr("Fatal Error"),
|
||||
msg,
|
||||
tr("Quit") );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -33,8 +33,8 @@
|
||||
#include <QLineEdit>
|
||||
#include <QPushButton>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include "PHelp.h"
|
||||
#include <QDesktopServices>
|
||||
#include <QUrl>
|
||||
|
||||
#include "PGetFourierBlockDialog.h"
|
||||
|
||||
@ -132,12 +132,14 @@ void PGetFourierBlockDialog::helpContent()
|
||||
if (fHelpUrl.isEmpty()) {
|
||||
QMessageBox::information(this, "**INFO**", "Will eventually show a help window");
|
||||
} else {
|
||||
#ifdef _WIN32GCC
|
||||
QMessageBox::information(this, "**INFO**", "If a newer Qt version was available, a help window would be shown!");
|
||||
#else
|
||||
PHelp *help = new PHelp(fHelpUrl);
|
||||
help->show();
|
||||
#endif // _WIN32GCC
|
||||
bool ok = QDesktopServices::openUrl(QUrl(fHelpUrl, QUrl::TolerantMode));
|
||||
if (!ok) {
|
||||
QString msg = QString("<p>Sorry: Couldn't open default web-browser for the help.<br>Please try: <a href=\"%1\">musrfit docu</a> in your web-browser.").arg(fHelpUrl);
|
||||
QMessageBox::critical( nullptr,
|
||||
tr("Fatal Error"),
|
||||
msg,
|
||||
tr("Quit") );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -32,11 +32,11 @@
|
||||
#include <QMessageBox>
|
||||
#include <QRegExp>
|
||||
#include <QEvent>
|
||||
#include <QDesktopServices>
|
||||
#include <QUrl>
|
||||
|
||||
#include <QtDebug>
|
||||
|
||||
#include "PHelp.h"
|
||||
|
||||
#include "PGetFunctionsBlockDialog.h"
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
@ -108,12 +108,14 @@ void PGetFunctionsBlockDialog::helpContent()
|
||||
if (fHelpUrl.isEmpty()) {
|
||||
QMessageBox::information(this, "**INFO**", "Will eventually show a help window");
|
||||
} else {
|
||||
#ifdef _WIN32GCC
|
||||
QMessageBox::information(this, "**INFO**", "If a newer Qt version was available, a help window would be shown!");
|
||||
#else
|
||||
PHelp *help = new PHelp(fHelpUrl);
|
||||
help->show();
|
||||
#endif // _WIN32GCC
|
||||
bool ok = QDesktopServices::openUrl(QUrl(fHelpUrl, QUrl::TolerantMode));
|
||||
if (!ok) {
|
||||
QString msg = QString("<p>Sorry: Couldn't open default web-browser for the help.<br>Please try: <a href=\"%1\">musrfit docu</a> in your web-browser.").arg(fHelpUrl);
|
||||
QMessageBox::critical( nullptr,
|
||||
tr("Fatal Error"),
|
||||
msg,
|
||||
tr("Quit") );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -31,8 +31,9 @@
|
||||
#include <QValidator>
|
||||
#include <QComboBox>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include "PHelp.h"
|
||||
#include <QDesktopServices>
|
||||
#include <QUrl>
|
||||
#include <QFileDialog>
|
||||
|
||||
#include "PGetMusrFTOptionsDialog.h"
|
||||
|
||||
@ -586,11 +587,13 @@ void PGetMusrFTOptionsDialog::helpContent()
|
||||
if (fHelpUrl.isEmpty()) {
|
||||
QMessageBox::information(this, "**INFO**", "Will eventually show a help window");
|
||||
} else {
|
||||
#ifdef _WIN32GCC
|
||||
QMessageBox::information(this, "**INFO**", "If a newer Qt version was available, a help window would be shown!");
|
||||
#else
|
||||
PHelp *help = new PHelp(fHelpUrl);
|
||||
help->show();
|
||||
#endif // _WIN32GCC
|
||||
bool ok = QDesktopServices::openUrl(QUrl(fHelpUrl, QUrl::TolerantMode));
|
||||
if (!ok) {
|
||||
QString msg = QString("<p>Sorry: Couldn't open default web-browser for the help.<br>Please try: <a href=\"%1\">musrfit docu</a> in your web-browser.").arg(fHelpUrl);
|
||||
QMessageBox::critical( nullptr,
|
||||
tr("Fatal Error"),
|
||||
msg,
|
||||
tr("Quit") );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -31,8 +31,9 @@
|
||||
#include <QValidator>
|
||||
#include <QComboBox>
|
||||
#include <QMessageBox>
|
||||
#include <QDesktopServices>
|
||||
#include <QUrl>
|
||||
|
||||
#include "PHelp.h"
|
||||
#include "PGetNonMusrRunBlockDialog.h"
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
@ -156,12 +157,14 @@ void PGetNonMusrRunBlockDialog::helpContent()
|
||||
if (fHelpUrl.isEmpty()) {
|
||||
QMessageBox::information(this, "**INFO**", "Will eventually show a help window");
|
||||
} else {
|
||||
#ifdef _WIN32GCC
|
||||
QMessageBox::information(this, "**INFO**", "If a newer Qt version was available, a help window would be shown!");
|
||||
#else
|
||||
PHelp *help = new PHelp(fHelpUrl);
|
||||
help->show();
|
||||
#endif // _WIN32GCC
|
||||
bool ok = QDesktopServices::openUrl(QUrl(fHelpUrl, QUrl::TolerantMode));
|
||||
if (!ok) {
|
||||
QString msg = QString("<p>Sorry: Couldn't open default web-browser for the help.<br>Please try: <a href=\"%1\">musrfit docu</a> in your web-browser.").arg(fHelpUrl);
|
||||
QMessageBox::critical( nullptr,
|
||||
tr("Fatal Error"),
|
||||
msg,
|
||||
tr("Quit") );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -34,8 +34,9 @@
|
||||
#include <QTextEdit>
|
||||
#include <QPushButton>
|
||||
#include <QEvent>
|
||||
#include <QDesktopServices>
|
||||
#include <QUrl>
|
||||
|
||||
#include "PHelp.h"
|
||||
#include "PGetParameterBlockDialog.h"
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
@ -219,12 +220,14 @@ void PGetParameterBlockDialog::helpContent()
|
||||
if (fHelpUrl.isEmpty()) {
|
||||
QMessageBox::information(this, "**INFO**", "Will eventually show a help window");
|
||||
} else {
|
||||
#ifdef _WIN32GCC
|
||||
QMessageBox::information(this, "**INFO**", "If a newer Qt version was available, a help window would be shown!");
|
||||
#else
|
||||
PHelp *help = new PHelp(fHelpUrl);
|
||||
help->show();
|
||||
#endif // _WIN32GCC
|
||||
bool ok = QDesktopServices::openUrl(QUrl(fHelpUrl, QUrl::TolerantMode));
|
||||
if (!ok) {
|
||||
QString msg = QString("<p>Sorry: Couldn't open default web-browser for the help.<br>Please try: <a href=\"%1\">musrfit docu</a> in your web-browser.").arg(fHelpUrl);
|
||||
QMessageBox::critical( nullptr,
|
||||
tr("Fatal Error"),
|
||||
msg,
|
||||
tr("Quit") );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -33,8 +33,9 @@
|
||||
#include <QSpinBox>
|
||||
#include <QTextEdit>
|
||||
#include <QComboBox>
|
||||
#include <QDesktopServices>
|
||||
#include <QUrl>
|
||||
|
||||
#include "PHelp.h"
|
||||
#include "PGetPlotBlockDialog.h"
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
@ -160,12 +161,14 @@ void PGetPlotBlockDialog::helpContent()
|
||||
if (fHelpUrl.isEmpty()) {
|
||||
QMessageBox::information(this, "**INFO**", "Will eventually show a help window");
|
||||
} else {
|
||||
#ifdef _WIN32GCC
|
||||
QMessageBox::information(this, "**INFO**", "If a newer Qt version was available, a help window would be shown!");
|
||||
#else
|
||||
PHelp *help = new PHelp(fHelpUrl);
|
||||
help->show();
|
||||
#endif // _WIN32GCC
|
||||
bool ok = QDesktopServices::openUrl(QUrl(fHelpUrl, QUrl::TolerantMode));
|
||||
if (!ok) {
|
||||
QString msg = QString("<p>Sorry: Couldn't open default web-browser for the help.<br>Please try: <a href=\"%1\">musrfit docu</a> in your web-browser.").arg(fHelpUrl);
|
||||
QMessageBox::critical( nullptr,
|
||||
tr("Fatal Error"),
|
||||
msg,
|
||||
tr("Quit") );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -32,8 +32,9 @@
|
||||
#include <QComboBox>
|
||||
#include <QCheckBox>
|
||||
#include <QMessageBox>
|
||||
#include <QDesktopServices>
|
||||
#include <QUrl>
|
||||
|
||||
#include "PHelp.h"
|
||||
#include "PGetSingleHistoRunBlockDialog.h"
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
@ -282,12 +283,14 @@ void PGetSingleHistoRunBlockDialog::helpContent()
|
||||
if (fHelpUrl.isEmpty()) {
|
||||
QMessageBox::information(this, "**INFO**", "Will eventually show a help window");
|
||||
} else {
|
||||
#ifdef _WIN32GCC
|
||||
QMessageBox::information(this, "**INFO**", "If a newer Qt version was available, a help window would be shown!");
|
||||
#else
|
||||
PHelp *help = new PHelp(fHelpUrl);
|
||||
help->show();
|
||||
#endif // _WIN32GCC
|
||||
bool ok = QDesktopServices::openUrl(QUrl(fHelpUrl, QUrl::TolerantMode));
|
||||
if (!ok) {
|
||||
QString msg = QString("<p>Sorry: Couldn't open default web-browser for the help.<br>Please try: <a href=\"%1\">musrfit docu</a> in your web-browser.").arg(fHelpUrl);
|
||||
QMessageBox::critical( nullptr,
|
||||
tr("Fatal Error"),
|
||||
msg,
|
||||
tr("Quit") );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -32,10 +32,11 @@
|
||||
#include <QComboBox>
|
||||
#include <QPixmap>
|
||||
#include <QImage>
|
||||
#include <QDesktopServices>
|
||||
#include <QUrl>
|
||||
|
||||
#include <QtDebug>
|
||||
|
||||
#include "PHelp.h"
|
||||
#include "PGetTheoryBlockDialog.h"
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
@ -126,12 +127,14 @@ void PGetTheoryBlockDialog::helpContent()
|
||||
if (fHelpUrl.isEmpty()) {
|
||||
QMessageBox::information(this, "**INFO**", "Will eventually show a help window");
|
||||
} else {
|
||||
#ifdef _WIN32GCC
|
||||
QMessageBox::information(this, "**INFO**", "If a newer Qt version was available, a help window would be shown!");
|
||||
#else
|
||||
PHelp *help = new PHelp(fHelpUrl);
|
||||
help->show();
|
||||
#endif // _WIN32GCC
|
||||
bool ok = QDesktopServices::openUrl(QUrl(fHelpUrl, QUrl::TolerantMode));
|
||||
if (!ok) {
|
||||
QString msg = QString("<p>Sorry: Couldn't open default web-browser for the help.<br>Please try: <a href=\"%1\">musrfit docu</a> in your web-browser.").arg(fHelpUrl);
|
||||
QMessageBox::critical( nullptr,
|
||||
tr("Fatal Error"),
|
||||
msg,
|
||||
tr("Quit") );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -28,8 +28,9 @@
|
||||
***************************************************************************/
|
||||
|
||||
#include <QMessageBox>
|
||||
#include <QDesktopServices>
|
||||
#include <QUrl>
|
||||
|
||||
#include "PHelp.h"
|
||||
#include "PGetTitleBlockDialog.h"
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
@ -54,12 +55,14 @@ void PGetTitleBlockDialog::helpContent()
|
||||
if (fHelpUrl.isEmpty()) {
|
||||
QMessageBox::information(this, "**INFO**", "Will eventually show a help window");
|
||||
} else {
|
||||
#ifdef _WIN32GCC
|
||||
QMessageBox::information(this, "**INFO**", "If a newer Qt version was available, a help window would be shown!");
|
||||
#else
|
||||
PHelp *help = new PHelp(fHelpUrl);
|
||||
help->show();
|
||||
#endif // _WIN32GCC
|
||||
bool ok = QDesktopServices::openUrl(QUrl(fHelpUrl, QUrl::TolerantMode));
|
||||
if (!ok) {
|
||||
QString msg = QString("<p>Sorry: Couldn't open default web-browser for the help.<br>Please try: <a href=\"%1\">musrfit docu</a> in your web-browser.").arg(fHelpUrl);
|
||||
QMessageBox::critical( nullptr,
|
||||
tr("Fatal Error"),
|
||||
msg,
|
||||
tr("Quit") );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,202 +0,0 @@
|
||||
/****************************************************************************
|
||||
|
||||
PHelp.cpp
|
||||
|
||||
Author: Andreas Suter
|
||||
e-mail: andreas.suter@psi.ch
|
||||
|
||||
*****************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2010-2019 by Andreas Suter *
|
||||
* andreas.suter@psi.ch *
|
||||
* *
|
||||
* This program 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 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program 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 this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
|
||||
#include <QtWidgets>
|
||||
#ifdef HAVE_QT_WEB_ENGINE
|
||||
#include <QWebEngineView>
|
||||
#endif
|
||||
#ifdef HAVE_QT_WEB_KIT
|
||||
#include <QtWebKitWidgets>
|
||||
#endif
|
||||
#ifdef HAVE_QT_NO_WEB
|
||||
#include <QPlainTextEdit>
|
||||
#endif
|
||||
#include <QNetworkProxyFactory>
|
||||
|
||||
#include <QtDebug>
|
||||
|
||||
#include "PHelp.h"
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
/**
|
||||
* <p>Constructor.
|
||||
*
|
||||
* \param url help url
|
||||
*/
|
||||
PHelp::PHelp(const QString &url, const bool isDarkTheme) :
|
||||
fDarkTheme(isDarkTheme)
|
||||
{
|
||||
fProgress = 0;
|
||||
|
||||
QString iconName("");
|
||||
if (fDarkTheme)
|
||||
iconName = QString(":/icons/musrfit-help-dark.svg");
|
||||
else
|
||||
iconName = QString(":/icons/musrfit-help-plain.svg");
|
||||
setWindowIcon( QIcon( QPixmap(iconName) ) );
|
||||
|
||||
QNetworkProxyFactory::setUseSystemConfiguration(true);
|
||||
|
||||
#ifdef HAVE_QT_WEB_ENGINE
|
||||
fView = new QWebEngineView(this);
|
||||
#endif
|
||||
#ifdef HAVE_QT_WEB_KIT
|
||||
fView = new QWebView(this);
|
||||
#endif
|
||||
#ifdef HAVE_QT_NO_WEB
|
||||
fView = new QPlainTextEdit(this);
|
||||
#endif
|
||||
#ifndef HAVE_QT_NO_WEB
|
||||
fView->load(QUrl(url));
|
||||
connect(fView, SIGNAL(loadFinished(bool)), SLOT(adjustLocation()));
|
||||
connect(fView, SIGNAL(titleChanged(QString)), SLOT(adjustTitle()));
|
||||
connect(fView, SIGNAL(loadProgress(int)), SLOT(setProgress(int)));
|
||||
connect(fView, SIGNAL(loadFinished(bool)), SLOT(finishLoading(bool)));
|
||||
#else
|
||||
fView->setPlainText("Within the current setup there is NO Help available.");
|
||||
fView->appendPlainText("The necessary Qt web libs where not found when setting up musredit.");
|
||||
fView->setReadOnly(true);
|
||||
#endif
|
||||
|
||||
fLocationEdit = new QLineEdit(this);
|
||||
fLocationEdit->setSizePolicy(QSizePolicy::Expanding, fLocationEdit->sizePolicy().verticalPolicy());
|
||||
connect(fLocationEdit, SIGNAL(returnPressed()), SLOT(changeLocation()));
|
||||
|
||||
QToolBar *toolBar = addToolBar(tr("Navigation"));
|
||||
#ifdef HAVE_QT_WEB_ENGINE
|
||||
toolBar->addAction(fView->pageAction(QWebEnginePage::Back));
|
||||
toolBar->addAction(fView->pageAction(QWebEnginePage::Forward));
|
||||
toolBar->addAction(fView->pageAction(QWebEnginePage::Reload));
|
||||
toolBar->addAction(fView->pageAction(QWebEnginePage::Stop));
|
||||
#endif
|
||||
#ifdef HAVE_QT_WEB_KIT
|
||||
toolBar->addAction(fView->pageAction(QWebPage::Back));
|
||||
toolBar->addAction(fView->pageAction(QWebPage::Forward));
|
||||
toolBar->addAction(fView->pageAction(QWebPage::Reload));
|
||||
toolBar->addAction(fView->pageAction(QWebPage::Stop));
|
||||
#endif
|
||||
toolBar->addWidget(fLocationEdit);
|
||||
|
||||
QMenu *exitMenu = menuBar()->addMenu(tr("&File"));
|
||||
exitMenu->addAction("&Exit", this, SLOT(done()), QKeySequence(tr("Ctrl+Q")));
|
||||
|
||||
setCentralWidget(fView);
|
||||
setUnifiedTitleAndToolBarOnMac(true);
|
||||
setMinimumSize(800, 700);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
/**
|
||||
* <p>Destructor
|
||||
*/
|
||||
PHelp::~PHelp()
|
||||
{
|
||||
if (fView) {
|
||||
delete fView;
|
||||
fView = 0;
|
||||
}
|
||||
|
||||
if (fLocationEdit) {
|
||||
delete fLocationEdit;
|
||||
fLocationEdit = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
/**
|
||||
* <p>Called on exit (SLOT). Closes the web-browser help GUI.
|
||||
*/
|
||||
void PHelp::done()
|
||||
{
|
||||
close();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
/**
|
||||
* <p>Called after an url is loaded (SLOT). Adjusts the url address.
|
||||
*/
|
||||
void PHelp::adjustLocation()
|
||||
{
|
||||
#ifndef HAVE_QT_NO_WEB
|
||||
fLocationEdit->setText(fView->url().toString());
|
||||
#endif
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
/**
|
||||
* <p>Called when the url address in the line edit changed (SLOT). Will execute
|
||||
* the load of the new url.
|
||||
*/
|
||||
void PHelp::changeLocation()
|
||||
{
|
||||
QUrl url = QUrl(fLocationEdit->text());
|
||||
#ifndef HAVE_QT_NO_WEB
|
||||
fView->load(url);
|
||||
fView->setFocus();
|
||||
#endif
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
/**
|
||||
* <p>Called when the title changed (SLOT). Will change the window title according
|
||||
* to the state of the web-browser.
|
||||
*/
|
||||
void PHelp::adjustTitle()
|
||||
{
|
||||
#ifndef HAVE_QT_NO_WEB
|
||||
if (fProgress <= 0 || fProgress >= 100)
|
||||
setWindowTitle(fView->title());
|
||||
else
|
||||
setWindowTitle(QString("%1 (%2%)").arg(fView->title()).arg(fProgress));
|
||||
#endif
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
/**
|
||||
* <p>Adjusts the progess value while loading an url. Also calls adjustTitle().
|
||||
*/
|
||||
void PHelp::setProgress(int p)
|
||||
{
|
||||
fProgress = p;
|
||||
adjustTitle();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
/**
|
||||
* <p>Ajusts the title when an url has been loaded.
|
||||
*/
|
||||
void PHelp::finishLoading(bool)
|
||||
{
|
||||
fProgress = 100;
|
||||
adjustTitle();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// end
|
||||
//---------------------------------------------------------------------------
|
@ -1,81 +0,0 @@
|
||||
/****************************************************************************
|
||||
|
||||
PHelp.h
|
||||
|
||||
Author: Andreas Suter
|
||||
e-mail: andreas.suter@psi.ch
|
||||
|
||||
*****************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2010-2019 by Andreas Suter *
|
||||
* andreas.suter@psi.ch *
|
||||
* *
|
||||
* This program 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 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program 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 this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef _PHELP_H_
|
||||
#define _PHELP_H_
|
||||
|
||||
#include <QtWidgets>
|
||||
|
||||
#ifdef HAVE_QT_WEB_ENGINE
|
||||
class QWebEngineView;
|
||||
#endif
|
||||
#ifdef HAVE_QT_WEB_KIT
|
||||
class QWebView;
|
||||
#endif
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QLineEdit;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
/**
|
||||
* <p>Class providing the help interface for the user. It opens the wiki docu
|
||||
* pages such that a user has the chance to read.
|
||||
*/
|
||||
class PHelp : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
PHelp(const QString &url, const bool isDarkTheme=false);
|
||||
virtual ~PHelp();
|
||||
|
||||
protected slots:
|
||||
void done();
|
||||
void adjustLocation();
|
||||
void changeLocation();
|
||||
void adjustTitle();
|
||||
void setProgress(int p);
|
||||
void finishLoading(bool);
|
||||
|
||||
private:
|
||||
bool fDarkTheme;
|
||||
#ifdef HAVE_QT_WEB_ENGINE
|
||||
QWebEngineView *fView; ///< web viewer
|
||||
#endif
|
||||
#ifdef HAVE_QT_WEB_KIT
|
||||
QWebView *fView; ///< web viewer
|
||||
#endif
|
||||
#ifdef HAVE_QT_NO_WEB
|
||||
QPlainTextEdit *fView; ///< dialog stating that there is NO web viewer
|
||||
#endif
|
||||
QLineEdit *fLocationEdit; ///< url address line edit
|
||||
int fProgress; ///< progress value (0-100) while loading an url
|
||||
};
|
||||
|
||||
#endif // _PHELP_H_
|
@ -32,8 +32,8 @@
|
||||
#include <QMessageBox>
|
||||
#include <QTextEdit>
|
||||
#include <QCheckBox>
|
||||
|
||||
#include "PHelp.h"
|
||||
#include <QDesktopServices>
|
||||
#include <QUrl>
|
||||
|
||||
#include "PMsr2DataDialog.h"
|
||||
|
||||
@ -224,12 +224,14 @@ void PMsr2DataDialog::helpContent()
|
||||
if (fHelpUrl.isEmpty()) {
|
||||
QMessageBox::information(this, "**INFO**", "Will eventually show a help window");
|
||||
} else {
|
||||
#ifdef _WIN32GCC
|
||||
QMessageBox::information(this, "**INFO**", "If a newer Qt version was available, a help window would be shown!");
|
||||
#else
|
||||
PHelp *help = new PHelp(fHelpUrl);
|
||||
help->show();
|
||||
#endif // _WIN32GCC
|
||||
bool ok = QDesktopServices::openUrl(QUrl(fHelpUrl, QUrl::TolerantMode));
|
||||
if (!ok) {
|
||||
QString msg = QString("<p>Sorry: Couldn't open default web-browser for the help.<br>Please try: <a href=\"%1\">musrfit docu</a> in your web-browser.").arg(fHelpUrl);
|
||||
QMessageBox::critical( nullptr,
|
||||
tr("Fatal Error"),
|
||||
msg,
|
||||
tr("Quit") );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -58,11 +58,13 @@
|
||||
#include <QTextDocumentFragment>
|
||||
#include <QTextList>
|
||||
#include <QProcess>
|
||||
#include <QFileSystemWatcher>
|
||||
#include <QDesktopServices>
|
||||
#include <QUrl>
|
||||
|
||||
#include <QtDebug>
|
||||
|
||||
#include "PTextEdit.h"
|
||||
#include "PHelp.h"
|
||||
#include "PSubTextEdit.h"
|
||||
#include "PAdmin.h"
|
||||
#include "PFindDialog.h"
|
||||
@ -2967,8 +2969,14 @@ void PTextEdit::mupp()
|
||||
*/
|
||||
void PTextEdit::helpContents()
|
||||
{
|
||||
PHelp *help = new PHelp(fAdmin->getHelpUrl("main"), fDarkMenuIcon);
|
||||
help->show();
|
||||
bool ok = QDesktopServices::openUrl(QUrl(fAdmin->getHelpUrl("main"), QUrl::TolerantMode));
|
||||
if (!ok) {
|
||||
QString msg = QString("<p>Sorry: Couldn't open default web-browser for the help.<br>Please try: <a href=\"%1\">musrfit docu</a> in your web-browser.").arg(fAdmin->getHelpUrl("main"));
|
||||
QMessageBox::critical( nullptr,
|
||||
tr("Fatal Error"),
|
||||
msg,
|
||||
tr("Quit") );
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
|
Loading…
x
Reference in New Issue
Block a user