Skip to content

Commit

Permalink
show help for active mdi-child
Browse files Browse the repository at this point in the history
  • Loading branch information
Chunosov committed Jan 23, 2020
1 parent cca32e3 commit 0f00939
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 3 deletions.
23 changes: 20 additions & 3 deletions src/ProjectWindow.cpp
Expand Up @@ -166,8 +166,7 @@ void ProjectWindow::createActions()
actnWndCascade = A_(tr("Cascade"), _mdiArea, SLOT(cascadeSubWindows()));

auto help = Z::HelpSystem::instance();
// TODO: analyze top-level window and show context help if available
actnHelpContent = A_(tr("Contents"), help, SLOT(showContents()), ":/toolbar/help", QKeySequence::HelpContents);
actnHelpContent = A_(tr("Contents"), this, SLOT(showHelp()), ":/toolbar/help", QKeySequence::HelpContents);
actnHelpIndex = A_(tr("Index"), help, SLOT(showIndex()));
actnHelpBugReport = A_(tr("Send Bug Report"), help, SLOT(sendBugReport()), ":/toolbar/bug");
actnHelpUpdates = A_(tr("Check for Updates"), help, SLOT(checkUpdates()), ":/toolbar/update");
Expand Down Expand Up @@ -477,7 +476,7 @@ void ProjectWindow::showAdjustment()
}

//------------------------------------------------------------------------------
// Window action
// Window actions

void ProjectWindow::showProtocolWindow()
{
Expand All @@ -499,6 +498,24 @@ void ProjectWindow::showPumpsWindow()
_mdiArea->appendChild(PumpWindow::create(schema()));
}

//------------------------------------------------------------------------------
// Help actions

void ProjectWindow::showHelp()
{
auto activeChild = _mdiArea->activeChild();
if (activeChild)
{
QString helpTopic = activeChild->helpTopic();
if (!helpTopic.isEmpty())
{
Z::HelpSystem::instance()->showTopic(helpTopic);
return;
}
}
Z::HelpSystem::instance()->showContents();
}

//------------------------------------------------------------------------------
// Schema events

Expand Down
1 change: 1 addition & 0 deletions src/ProjectWindow.h
Expand Up @@ -116,6 +116,7 @@ private slots:
void showParamsWindow();
void showPumpsWindow();
void showAdjustment();
void showHelp();

void openSchemaExample();

Expand Down
1 change: 1 addition & 0 deletions src/PumpWindow.h
Expand Up @@ -83,6 +83,7 @@ class PumpWindow : public SchemaMdiChild,

// inherits from BasicMdiChild
QList<QMenu*> menus() override { return { _windowMenu }; }
QString helpTopic() const override { return "pumps_window.html"; }

// inherits from SchemaListener
void schemaLoaded(Schema*) override { showStatusInfo(); }
Expand Down
2 changes: 2 additions & 0 deletions src/SchemaWindows.h
Expand Up @@ -179,6 +179,8 @@ class BasicMdiChild : public QMdiSubWindow, public IAppSettingsListener
/// Function is called when application settings are changed.
void settingsChanged() override;

virtual QString helpTopic() const { return QString(); }

protected:
void closeEvent(class QCloseEvent*) override { emit closing(); }

Expand Down

0 comments on commit 0f00939

Please sign in to comment.