diff --git a/CMakeLists.txt b/CMakeLists.txt index b7329ea7c..23f894156 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -63,6 +63,8 @@ set(OPENMW_VERSION_COMMITDATE "") 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) if(EXISTS ${PROJECT_SOURCE_DIR}/.git) find_package(Git) @@ -605,6 +607,7 @@ endif() # Components add_subdirectory (components) +target_compile_definitions(components PRIVATE OPENMW_DOC_BASEURL="${OPENMW_DOC_BASEURL}") # Apps and tools if (BUILD_OPENMW) diff --git a/apps/launcher/maindialog.cpp b/apps/launcher/maindialog.cpp index f69213c4a..4a2e1ba0e 100644 --- a/apps/launcher/maindialog.cpp +++ b/apps/launcher/maindialog.cpp @@ -1,6 +1,7 @@ #include "maindialog.hpp" #include +#include #include #include @@ -54,12 +55,15 @@ Launcher::MainDialog::MainDialog(QWidget *parent) iconWidget->setCurrentRow(0); iconWidget->setFlow(QListView::LeftToRight); + QPushButton *helpButton = new QPushButton(tr("Help")); QPushButton *playButton = new QPushButton(tr("Play")); buttonBox->button(QDialogButtonBox::Close)->setText(tr("Close")); + buttonBox->addButton(helpButton, QDialogButtonBox::HelpRole); buttonBox->addButton(playButton, QDialogButtonBox::AcceptRole); connect(buttonBox, SIGNAL(rejected()), this, SLOT(close())); connect(buttonBox, SIGNAL(accepted()), this, SLOT(play())); + connect(buttonBox, SIGNAL(helpRequested()), this, SLOT(help())); // Remove what's this? button setWindowFlags(this->windowFlags() & ~Qt::WindowContextHelpButtonHint); @@ -614,3 +618,8 @@ void Launcher::MainDialog::play() if (mGameInvoker->startProcess(QLatin1String("openmw"), true)) return qApp->quit(); } + +void Launcher::MainDialog::help() +{ + Misc::HelpViewer::openHelp("reference/index.html"); +} diff --git a/apps/launcher/maindialog.hpp b/apps/launcher/maindialog.hpp index 75fe5ab89..d87a43100 100644 --- a/apps/launcher/maindialog.hpp +++ b/apps/launcher/maindialog.hpp @@ -59,6 +59,7 @@ namespace Launcher public slots: void changePage(QListWidgetItem *current, QListWidgetItem *previous); void play(); + void help(); private slots: void wizardStarted(); diff --git a/apps/opencs/model/prefs/state.cpp b/apps/opencs/model/prefs/state.cpp index 89b5283a4..abd1ddfc8 100644 --- a/apps/opencs/model/prefs/state.cpp +++ b/apps/opencs/model/prefs/state.cpp @@ -271,6 +271,8 @@ void CSMPrefs::State::declare() declareShortcut ("document-file-newaddon", "New Addon", QKeySequence()); declareShortcut ("document-file-open", "Open", QKeySequence(Qt::ControlModifier | Qt::Key_O)); 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-merge", "Merge", QKeySequence()); declareShortcut ("document-file-errorlog", "Open Load Error Log", QKeySequence()); diff --git a/apps/opencs/view/doc/view.cpp b/apps/opencs/view/doc/view.cpp index dd58cbabc..ce04f6ada 100644 --- a/apps/opencs/view/doc/view.cpp +++ b/apps/opencs/view/doc/view.cpp @@ -31,6 +31,7 @@ #include "../tools/subviews.hpp" +#include #include #include "viewmanager.hpp" @@ -315,6 +316,12 @@ void CSVDoc::View::setupHelpMenu() { 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"); connect (about, SIGNAL (triggered()), this, SLOT (infoAbout())); @@ -708,6 +715,16 @@ void CSVDoc::View::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() { // Get current OpenMW version diff --git a/apps/opencs/view/doc/view.hpp b/apps/opencs/view/doc/view.hpp index 52057ab37..87c312412 100644 --- a/apps/opencs/view/doc/view.hpp +++ b/apps/opencs/view/doc/view.hpp @@ -169,6 +169,10 @@ namespace CSVDoc void exit(); + static void openHelp(); + + static void tutorial(); + void infoAbout(); void infoAboutQt(); diff --git a/apps/opencs/view/filter/editwidget.cpp b/apps/opencs/view/filter/editwidget.cpp index 600fa4f3b..6b585591f 100644 --- a/apps/opencs/view/filter/editwidget.cpp +++ b/apps/opencs/view/filter/editwidget.cpp @@ -1,12 +1,18 @@ #include "editwidget.hpp" #include +#include +#include +#include #include #include +#include + #include "../../model/world/data.hpp" #include "../../model/world/idtablebase.hpp" #include "../../model/world/columns.hpp" +#include "../../model/prefs/shortcut.hpp" CSVFilter::EditWidget::EditWidget (CSMWorld::Data& data, QWidget *parent) : 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); 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) @@ -211,3 +224,17 @@ std::string CSVFilter::EditWidget::generateFilter (std::pair< std::string, std:: 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"); +} + diff --git a/apps/opencs/view/filter/editwidget.hpp b/apps/opencs/view/filter/editwidget.hpp index 51a36969a..b47a884a3 100644 --- a/apps/opencs/view/filter/editwidget.hpp +++ b/apps/opencs/view/filter/editwidget.hpp @@ -26,6 +26,7 @@ namespace CSVFilter bool mIsEmpty; int mStateColumnIndex; int mDescColumnIndex; + QAction *mHelpAction; public: @@ -40,6 +41,7 @@ namespace CSVFilter private: std::string generateFilter(std::pair >& seekedString) const; + void contextMenuEvent (QContextMenuEvent *event) override; private slots: @@ -51,6 +53,8 @@ namespace CSVFilter void filterRowsInserted (const QModelIndex& parent, int start, int end); + static void openHelp(); + }; } diff --git a/apps/opencs/view/world/table.cpp b/apps/opencs/view/world/table.cpp index 11c2be5fc..e2bc87a72 100644 --- a/apps/opencs/view/world/table.cpp +++ b/apps/opencs/view/world/table.cpp @@ -7,6 +7,7 @@ #include #include +#include #include #include "../../model/doc/document.hpp" @@ -155,6 +156,9 @@ void CSVWorld::Table::contextMenuEvent (QContextMenuEvent *event) } } + if (mHelpAction) + menu.addAction (mHelpAction); + menu.exec (event->globalPos()); } @@ -387,6 +391,13 @@ CSVWorld::Table::Table (const CSMWorld::UniversalId& id, connect (mEditIdAction, SIGNAL (triggered()), this, SLOT (editCell())); 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)), this, SLOT (tableSizeUpdate())); @@ -561,6 +572,11 @@ void CSVWorld::Table::editCell() emit editRequest(mEditIdAction->getCurrentId(), ""); } +void CSVWorld::Table::openHelp() +{ + Misc::HelpViewer::openHelp("manuals/openmw-cs/tables.html"); +} + void CSVWorld::Table::viewRecord() { if (!(mModel->getFeatures() & CSMWorld::IdTableBase::Feature_View)) diff --git a/apps/opencs/view/world/table.hpp b/apps/opencs/view/world/table.hpp index 02f9023e7..36c423b33 100644 --- a/apps/opencs/view/world/table.hpp +++ b/apps/opencs/view/world/table.hpp @@ -65,6 +65,7 @@ namespace CSVWorld QAction *mPreviewAction; QAction *mExtendedDeleteAction; QAction *mExtendedRevertAction; + QAction *mHelpAction; TableEditIdAction *mEditIdAction; CSMWorld::IdTableProxyModel *mProxyModel; CSMWorld::IdTableBase *mModel; @@ -128,6 +129,8 @@ namespace CSVWorld void editCell(); + static void openHelp(); + void editRecord(); void cloneRecord(); diff --git a/components/CMakeLists.txt b/components/CMakeLists.txt index 8d644c6de..501960176 100644 --- a/components/CMakeLists.txt +++ b/components/CMakeLists.txt @@ -86,7 +86,7 @@ add_component_dir (esmterrain ) 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 diff --git a/components/misc/helpviewer.cpp b/components/misc/helpviewer.cpp new file mode 100644 index 000000000..0e6dadcaa --- /dev/null +++ b/components/misc/helpviewer.cpp @@ -0,0 +1,12 @@ +#include "helpviewer.hpp" + +#include +#include +#include + +void Misc::HelpViewer::openHelp(const char* url) +{ + QString link {OPENMW_DOC_BASEURL}; + link.append(url); + QDesktopServices::openUrl(QUrl(link)); +} diff --git a/components/misc/helpviewer.hpp b/components/misc/helpviewer.hpp new file mode 100644 index 000000000..7affb2c36 --- /dev/null +++ b/components/misc/helpviewer.hpp @@ -0,0 +1,7 @@ +#pragma once + +namespace Misc { + namespace HelpViewer { + void openHelp(const char* url); + } +}