Add link to opencs documentation on readthedocs, available through

context menu.
The documentation opens in default browser.

There are 3 contexts:
- global: opens the OpenMW CS User Manual main page
- when a record is selected: opens the "Tables" page
- when the filter field is selected: opens the "Record Filters" page

There is also a link to the OpenCS tutorial in the help menu.
pull/578/head
Frederic Chardon 5 years ago committed by Bret Curtis
parent b42d097739
commit 513ac8986d

@ -63,6 +63,8 @@ set(OPENMW_VERSION_COMMITDATE "")
set(OPENMW_VERSION "${OPENMW_VERSION_MAJOR}.${OPENMW_VERSION_MINOR}.${OPENMW_VERSION_RELEASE}") set(OPENMW_VERSION "${OPENMW_VERSION_MAJOR}.${OPENMW_VERSION_MINOR}.${OPENMW_VERSION_RELEASE}")
set(OPENMW_DOC_BASEURL "https://openmw.readthedocs.io/en/master/")
set(GIT_CHECKOUT FALSE) set(GIT_CHECKOUT FALSE)
if(EXISTS ${PROJECT_SOURCE_DIR}/.git) if(EXISTS ${PROJECT_SOURCE_DIR}/.git)
find_package(Git) find_package(Git)
@ -605,6 +607,7 @@ endif()
# Components # Components
add_subdirectory (components) add_subdirectory (components)
target_compile_definitions(components PRIVATE OPENMW_DOC_BASEURL="${OPENMW_DOC_BASEURL}")
# Apps and tools # Apps and tools
if (BUILD_OPENMW) if (BUILD_OPENMW)

@ -1,6 +1,7 @@
#include "maindialog.hpp" #include "maindialog.hpp"
#include <components/version/version.hpp> #include <components/version/version.hpp>
#include <components/misc/helpviewer.hpp>
#include <QDate> #include <QDate>
#include <QMessageBox> #include <QMessageBox>
@ -54,12 +55,15 @@ Launcher::MainDialog::MainDialog(QWidget *parent)
iconWidget->setCurrentRow(0); iconWidget->setCurrentRow(0);
iconWidget->setFlow(QListView::LeftToRight); iconWidget->setFlow(QListView::LeftToRight);
QPushButton *helpButton = new QPushButton(tr("Help"));
QPushButton *playButton = new QPushButton(tr("Play")); QPushButton *playButton = new QPushButton(tr("Play"));
buttonBox->button(QDialogButtonBox::Close)->setText(tr("Close")); buttonBox->button(QDialogButtonBox::Close)->setText(tr("Close"));
buttonBox->addButton(helpButton, QDialogButtonBox::HelpRole);
buttonBox->addButton(playButton, QDialogButtonBox::AcceptRole); buttonBox->addButton(playButton, QDialogButtonBox::AcceptRole);
connect(buttonBox, SIGNAL(rejected()), this, SLOT(close())); connect(buttonBox, SIGNAL(rejected()), this, SLOT(close()));
connect(buttonBox, SIGNAL(accepted()), this, SLOT(play())); connect(buttonBox, SIGNAL(accepted()), this, SLOT(play()));
connect(buttonBox, SIGNAL(helpRequested()), this, SLOT(help()));
// Remove what's this? button // Remove what's this? button
setWindowFlags(this->windowFlags() & ~Qt::WindowContextHelpButtonHint); setWindowFlags(this->windowFlags() & ~Qt::WindowContextHelpButtonHint);
@ -614,3 +618,8 @@ void Launcher::MainDialog::play()
if (mGameInvoker->startProcess(QLatin1String("openmw"), true)) if (mGameInvoker->startProcess(QLatin1String("openmw"), true))
return qApp->quit(); return qApp->quit();
} }
void Launcher::MainDialog::help()
{
Misc::HelpViewer::openHelp("reference/index.html");
}

@ -59,6 +59,7 @@ namespace Launcher
public slots: public slots:
void changePage(QListWidgetItem *current, QListWidgetItem *previous); void changePage(QListWidgetItem *current, QListWidgetItem *previous);
void play(); void play();
void help();
private slots: private slots:
void wizardStarted(); void wizardStarted();

@ -271,6 +271,8 @@ void CSMPrefs::State::declare()
declareShortcut ("document-file-newaddon", "New Addon", QKeySequence()); declareShortcut ("document-file-newaddon", "New Addon", QKeySequence());
declareShortcut ("document-file-open", "Open", QKeySequence(Qt::ControlModifier | Qt::Key_O)); declareShortcut ("document-file-open", "Open", QKeySequence(Qt::ControlModifier | Qt::Key_O));
declareShortcut ("document-file-save", "Save", QKeySequence(Qt::ControlModifier | Qt::Key_S)); declareShortcut ("document-file-save", "Save", QKeySequence(Qt::ControlModifier | Qt::Key_S));
declareShortcut ("document-help-help", "Help", QKeySequence(Qt::Key_F1));
declareShortcut ("document-help-tutorial", "Tutorial", QKeySequence());
declareShortcut ("document-file-verify", "Verify", QKeySequence()); declareShortcut ("document-file-verify", "Verify", QKeySequence());
declareShortcut ("document-file-merge", "Merge", QKeySequence()); declareShortcut ("document-file-merge", "Merge", QKeySequence());
declareShortcut ("document-file-errorlog", "Open Load Error Log", QKeySequence()); declareShortcut ("document-file-errorlog", "Open Load Error Log", QKeySequence());

@ -31,6 +31,7 @@
#include "../tools/subviews.hpp" #include "../tools/subviews.hpp"
#include <components/misc/helpviewer.hpp>
#include <components/version/version.hpp> #include <components/version/version.hpp>
#include "viewmanager.hpp" #include "viewmanager.hpp"
@ -315,6 +316,12 @@ void CSVDoc::View::setupHelpMenu()
{ {
QMenu *help = menuBar()->addMenu (tr ("Help")); QMenu *help = menuBar()->addMenu (tr ("Help"));
QAction* helpInfo = createMenuEntry("Help", ":/info.png", help, "document-help-help");
connect (helpInfo, SIGNAL (triggered()), this, SLOT (openHelp()));
QAction* tutorial = createMenuEntry("Tutorial", ":/info.png", help, "document-help-tutorial");
connect (tutorial, SIGNAL (triggered()), this, SLOT (tutorial()));
QAction* about = createMenuEntry("About OpenMW-CS", ":./info.png", help, "document-help-about"); QAction* about = createMenuEntry("About OpenMW-CS", ":./info.png", help, "document-help-about");
connect (about, SIGNAL (triggered()), this, SLOT (infoAbout())); connect (about, SIGNAL (triggered()), this, SLOT (infoAbout()));
@ -708,6 +715,16 @@ void CSVDoc::View::save()
mDocument->save(); mDocument->save();
} }
void CSVDoc::View::openHelp()
{
Misc::HelpViewer::openHelp("manuals/openmw-cs/index.html");
}
void CSVDoc::View::tutorial()
{
Misc::HelpViewer::openHelp("manuals/openmw-cs/tour.html");
}
void CSVDoc::View::infoAbout() void CSVDoc::View::infoAbout()
{ {
// Get current OpenMW version // Get current OpenMW version

@ -169,6 +169,10 @@ namespace CSVDoc
void exit(); void exit();
static void openHelp();
static void tutorial();
void infoAbout(); void infoAbout();
void infoAboutQt(); void infoAboutQt();

@ -1,12 +1,18 @@
#include "editwidget.hpp" #include "editwidget.hpp"
#include <QAbstractItemModel> #include <QAbstractItemModel>
#include <QAction>
#include <QContextMenuEvent>
#include <QMenu>
#include <QString> #include <QString>
#include <QApplication> #include <QApplication>
#include <components/misc/helpviewer.hpp>
#include "../../model/world/data.hpp" #include "../../model/world/data.hpp"
#include "../../model/world/idtablebase.hpp" #include "../../model/world/idtablebase.hpp"
#include "../../model/world/columns.hpp" #include "../../model/world/columns.hpp"
#include "../../model/prefs/shortcut.hpp"
CSVFilter::EditWidget::EditWidget (CSMWorld::Data& data, QWidget *parent) CSVFilter::EditWidget::EditWidget (CSMWorld::Data& data, QWidget *parent)
: QLineEdit (parent), mParser (data), mIsEmpty(true) : QLineEdit (parent), mParser (data), mIsEmpty(true)
@ -29,6 +35,13 @@ CSVFilter::EditWidget::EditWidget (CSMWorld::Data& data, QWidget *parent)
mStateColumnIndex = model->findColumnIndex(CSMWorld::Columns::ColumnId_Modification); mStateColumnIndex = model->findColumnIndex(CSMWorld::Columns::ColumnId_Modification);
mDescColumnIndex = model->findColumnIndex(CSMWorld::Columns::ColumnId_Description); mDescColumnIndex = model->findColumnIndex(CSMWorld::Columns::ColumnId_Description);
mHelpAction = new QAction (tr ("Help"), this);
connect (mHelpAction, SIGNAL (triggered()), this, SLOT (openHelp()));
mHelpAction->setIcon(QIcon(":/info.png"));
addAction (mHelpAction);
auto* openHelpShortcut = new CSMPrefs::Shortcut("help", this);
openHelpShortcut->associateAction(mHelpAction);
} }
void CSVFilter::EditWidget::textChanged (const QString& text) void CSVFilter::EditWidget::textChanged (const QString& text)
@ -211,3 +224,17 @@ std::string CSVFilter::EditWidget::generateFilter (std::pair< std::string, std::
return ss.str(); return ss.str();
} }
void CSVFilter::EditWidget::contextMenuEvent(QContextMenuEvent *event)
{
QMenu *menu = createStandardContextMenu();
menu->addAction(mHelpAction);
menu->exec(event->globalPos());
delete menu;
}
void CSVFilter::EditWidget::openHelp()
{
Misc::HelpViewer::openHelp("manuals/openmw-cs/record-filters.html");
}

@ -26,6 +26,7 @@ namespace CSVFilter
bool mIsEmpty; bool mIsEmpty;
int mStateColumnIndex; int mStateColumnIndex;
int mDescColumnIndex; int mDescColumnIndex;
QAction *mHelpAction;
public: public:
@ -40,6 +41,7 @@ namespace CSVFilter
private: private:
std::string generateFilter(std::pair<std::string, std::vector<std::string> >& seekedString) const; std::string generateFilter(std::pair<std::string, std::vector<std::string> >& seekedString) const;
void contextMenuEvent (QContextMenuEvent *event) override;
private slots: private slots:
@ -51,6 +53,8 @@ namespace CSVFilter
void filterRowsInserted (const QModelIndex& parent, int start, int end); void filterRowsInserted (const QModelIndex& parent, int start, int end);
static void openHelp();
}; };
} }

@ -7,6 +7,7 @@
#include <QString> #include <QString>
#include <QtCore/qnamespace.h> #include <QtCore/qnamespace.h>
#include <components/misc/helpviewer.hpp>
#include <components/misc/stringops.hpp> #include <components/misc/stringops.hpp>
#include "../../model/doc/document.hpp" #include "../../model/doc/document.hpp"
@ -155,6 +156,9 @@ void CSVWorld::Table::contextMenuEvent (QContextMenuEvent *event)
} }
} }
if (mHelpAction)
menu.addAction (mHelpAction);
menu.exec (event->globalPos()); menu.exec (event->globalPos());
} }
@ -387,6 +391,13 @@ CSVWorld::Table::Table (const CSMWorld::UniversalId& id,
connect (mEditIdAction, SIGNAL (triggered()), this, SLOT (editCell())); connect (mEditIdAction, SIGNAL (triggered()), this, SLOT (editCell()));
addAction (mEditIdAction); addAction (mEditIdAction);
mHelpAction = new QAction (tr ("Help"), this);
connect (mHelpAction, SIGNAL (triggered()), this, SLOT (openHelp()));
mHelpAction->setIcon(QIcon(":/info.png"));
addAction (mHelpAction);
CSMPrefs::Shortcut* openHelpShortcut = new CSMPrefs::Shortcut("help", this);
openHelpShortcut->associateAction(mHelpAction);
connect (mProxyModel, SIGNAL (rowsRemoved (const QModelIndex&, int, int)), connect (mProxyModel, SIGNAL (rowsRemoved (const QModelIndex&, int, int)),
this, SLOT (tableSizeUpdate())); this, SLOT (tableSizeUpdate()));
@ -561,6 +572,11 @@ void CSVWorld::Table::editCell()
emit editRequest(mEditIdAction->getCurrentId(), ""); emit editRequest(mEditIdAction->getCurrentId(), "");
} }
void CSVWorld::Table::openHelp()
{
Misc::HelpViewer::openHelp("manuals/openmw-cs/tables.html");
}
void CSVWorld::Table::viewRecord() void CSVWorld::Table::viewRecord()
{ {
if (!(mModel->getFeatures() & CSMWorld::IdTableBase::Feature_View)) if (!(mModel->getFeatures() & CSMWorld::IdTableBase::Feature_View))

@ -65,6 +65,7 @@ namespace CSVWorld
QAction *mPreviewAction; QAction *mPreviewAction;
QAction *mExtendedDeleteAction; QAction *mExtendedDeleteAction;
QAction *mExtendedRevertAction; QAction *mExtendedRevertAction;
QAction *mHelpAction;
TableEditIdAction *mEditIdAction; TableEditIdAction *mEditIdAction;
CSMWorld::IdTableProxyModel *mProxyModel; CSMWorld::IdTableProxyModel *mProxyModel;
CSMWorld::IdTableBase *mModel; CSMWorld::IdTableBase *mModel;
@ -128,6 +129,8 @@ namespace CSVWorld
void editCell(); void editCell();
static void openHelp();
void editRecord(); void editRecord();
void cloneRecord(); void cloneRecord();

@ -86,7 +86,7 @@ add_component_dir (esmterrain
) )
add_component_dir (misc add_component_dir (misc
gcd constants utf8stream stringops resourcehelpers rng messageformatparser weakcache gcd constants utf8stream stringops resourcehelpers rng messageformatparser weakcache helpviewer
) )
add_component_dir (debug add_component_dir (debug

@ -0,0 +1,12 @@
#include "helpviewer.hpp"
#include <QString>
#include <QDesktopServices>
#include <QUrl>
void Misc::HelpViewer::openHelp(const char* url)
{
QString link {OPENMW_DOC_BASEURL};
link.append(url);
QDesktopServices::openUrl(QUrl(link));
}

@ -0,0 +1,7 @@
#pragma once
namespace Misc {
namespace HelpViewer {
void openHelp(const char* url);
}
}
Loading…
Cancel
Save