#5215 Use ui item name as a general way to start a search in the online help

This commit is contained in:
Jacob Støren 2020-02-03 16:06:37 +01:00
parent 3c05ae04e6
commit 43066bd0e5
6 changed files with 82 additions and 1 deletions

View File

@ -27,6 +27,7 @@
#include "RiuMainWindow.h"
#include "cafAboutDialog.h"
#include "cafSelectionManager.h"
#include "cafViewer.h"
#include <QAction>
@ -39,6 +40,7 @@ CAF_CMD_SOURCE_INIT( RicHelpAboutFeature, "RicHelpAboutFeature" );
CAF_CMD_SOURCE_INIT( RicHelpCommandLineFeature, "RicHelpCommandLineFeature" );
CAF_CMD_SOURCE_INIT( RicHelpSummaryCommandLineFeature, "RicHelpSummaryCommandLineFeature" );
CAF_CMD_SOURCE_INIT( RicHelpOpenUsersGuideFeature, "RicHelpOpenUsersGuideFeature" );
CAF_CMD_SOURCE_INIT( RicSearchHelpFeature, "RicSearchHelpFeature" );
//--------------------------------------------------------------------------------------------------
///
@ -251,7 +253,7 @@ void RicHelpOpenUsersGuideFeature::onActionTriggered( bool isChecked )
{
this->disableModelChangeContribution();
QString usersGuideUrl = "https://resinsight.org/getting-started/";
QString usersGuideUrl = "https://resinsight.org/getting-started/overview/";
if ( !QDesktopServices::openUrl( usersGuideUrl ) )
{
@ -267,5 +269,54 @@ void RicHelpOpenUsersGuideFeature::setupActionLook( QAction* actionToSetup )
{
actionToSetup->setText( "&Users Guide" );
// applyShortcutWithHintToAction( actionToSetup, QKeySequence::HelpContents );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicSearchHelpFeature::isCommandEnabled()
{
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicSearchHelpFeature::onActionTriggered( bool isChecked )
{
this->disableModelChangeContribution();
QString usersGuideUrl = "https://resinsight.org/getting-started/overview/";
caf::PdmUiItem* uiItem = caf::SelectionManager::instance()->selectedItem();
if ( uiItem && !uiItem->uiName().isEmpty() )
{
usersGuideUrl = "https://resinsight.org/search/?q=" + uiItem->uiName();
}
if ( !QDesktopServices::openUrl( usersGuideUrl ) )
{
QErrorMessage* errorHandler = QErrorMessage::qtHandler();
errorHandler->showMessage( "Failed open browser with the following url\n\n" + usersGuideUrl );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicSearchHelpFeature::setupActionLook( QAction* actionToSetup )
{
caf::PdmUiItem* uiItem = caf::SelectionManager::instance()->selectedItem();
if ( uiItem && !uiItem->uiName().isEmpty() )
{
actionToSetup->setText( "Search Help For: " + uiItem->uiName() );
}
else
{
actionToSetup->setText( "Search Help" );
}
applyShortcutWithHintToAction( actionToSetup, QKeySequence::HelpContents );
}

View File

@ -75,3 +75,17 @@ protected:
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
};
//==================================================================================================
///
//==================================================================================================
class RicSearchHelpFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
// Overrides
bool isCommandEnabled() override;
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
};

View File

@ -542,6 +542,9 @@ void RiuMainWindow::createMenus()
helpMenu->addAction( cmdFeatureMgr->action( "RicHelpSummaryCommandLineFeature" ) );
helpMenu->addSeparator();
helpMenu->addAction( cmdFeatureMgr->action( "RicHelpOpenUsersGuideFeature" ) );
helpMenu->addAction( cmdFeatureMgr->action( "RicSearchHelpFeature" ) );
connect( helpMenu, SIGNAL( aboutToShow() ), SLOT( slotRefreshHelpActions() ) );
}
//--------------------------------------------------------------------------------------------------

View File

@ -30,6 +30,7 @@
#include "cafPdmObject.h"
#include "cafPdmUiTreeView.h"
#include "cafCmdFeatureManager.h"
#include <QDockWidget>
#include <QMdiArea>
#include <QMdiSubWindow>
@ -390,3 +391,11 @@ void RiuMainWindowBase::addViewerToMdiArea( QMdiArea* mdiArea,
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMainWindowBase::slotRefreshHelpActions()
{
caf::CmdFeatureManager::instance()->action( "RicSearchHelpFeature" );
}

View File

@ -90,6 +90,7 @@ protected:
protected slots:
void slotDockWidgetToggleViewActionTriggered();
void addViewerToMdiArea( QMdiArea* mdiArea, QWidget* viewer, const QPoint& subWindowPos, const QSize& subWindowSize );
void slotRefreshHelpActions();
protected:
caf::PdmUiTreeView* m_projectTreeView;

View File

@ -317,6 +317,9 @@ void RiuPlotMainWindow::createMenus()
helpMenu->addAction( cmdFeatureMgr->action( "RicHelpSummaryCommandLineFeature" ) );
helpMenu->addSeparator();
helpMenu->addAction( cmdFeatureMgr->action( "RicHelpOpenUsersGuideFeature" ) );
helpMenu->addAction( cmdFeatureMgr->action( "RicSearchHelpFeature" ) );
connect( helpMenu, SIGNAL( aboutToShow() ), SLOT( slotRefreshHelpActions() ) );
}
//--------------------------------------------------------------------------------------------------