forked from qt-creator/qt-creator
Help: Option to open links in window
Task-number: QTCREATORBUG-16842 Change-Id: I420f48a00c56ebc89bade7e91ceb8ec391316e36 Reviewed-by: David Schulz <david.schulz@qt.io> Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
This commit is contained in:
@@ -198,11 +198,6 @@ void TextBrowserHelpViewer::addForwardHistoryItems(QMenu *forwardMenu)
|
||||
}
|
||||
}
|
||||
|
||||
void TextBrowserHelpViewer::setOpenInNewPageActionVisible(bool visible)
|
||||
{
|
||||
m_textBrowser->m_openInNewPageActionVisible = visible;
|
||||
}
|
||||
|
||||
bool TextBrowserHelpViewer::findText(const QString &text, Core::FindFlags flags,
|
||||
bool incremental, bool fromSearch, bool *wrapped)
|
||||
{
|
||||
@@ -305,7 +300,6 @@ TextBrowserHelpWidget::TextBrowserHelpWidget(TextBrowserHelpViewer *parent)
|
||||
: QTextBrowser(parent)
|
||||
, zoomCount(0)
|
||||
, forceFont(false)
|
||||
, m_openInNewPageActionVisible(true)
|
||||
, m_parent(parent)
|
||||
{
|
||||
installEventFilter(this);
|
||||
@@ -334,16 +328,6 @@ QString TextBrowserHelpWidget::linkAt(const QPoint &pos)
|
||||
return anchor;
|
||||
}
|
||||
|
||||
void TextBrowserHelpWidget::openLink(const QUrl &url, bool newPage)
|
||||
{
|
||||
if (url.isEmpty() || !url.isValid())
|
||||
return;
|
||||
if (newPage)
|
||||
OpenPagesManager::instance().createPage(url);
|
||||
else
|
||||
setSource(url);
|
||||
}
|
||||
|
||||
void TextBrowserHelpWidget::scaleUp()
|
||||
{
|
||||
if (zoomCount < 10) {
|
||||
@@ -373,13 +357,18 @@ void TextBrowserHelpWidget::contextMenuEvent(QContextMenuEvent *event)
|
||||
if (!link.isEmpty() && link.isValid()) {
|
||||
QAction *action = menu.addAction(tr("Open Link"));
|
||||
connect(action, &QAction::triggered, this, [this, link]() {
|
||||
openLink(link, false/*newPage*/);
|
||||
setSource(link);
|
||||
});
|
||||
if (m_openInNewPageActionVisible) {
|
||||
action = menu.addAction(QCoreApplication::translate("HelpViewer",
|
||||
"Open Link as New Page"));
|
||||
if (m_parent->isActionVisible(HelpViewer::Action::NewPage)) {
|
||||
action = menu.addAction(QCoreApplication::translate("HelpViewer", Constants::TR_OPEN_LINK_AS_NEW_PAGE));
|
||||
connect(action, &QAction::triggered, this, [this, link]() {
|
||||
openLink(link, true/*newPage*/);
|
||||
emit m_parent->newPageRequested(link);
|
||||
});
|
||||
}
|
||||
if (m_parent->isActionVisible(HelpViewer::Action::ExternalWindow)) {
|
||||
action = menu.addAction(QCoreApplication::translate("HelpViewer", Constants::TR_OPEN_LINK_IN_WINDOW));
|
||||
connect(action, &QAction::triggered, this, [this, link]() {
|
||||
emit m_parent->externalPageRequested(link);
|
||||
});
|
||||
}
|
||||
copyAnchorAction = menu.addAction(tr("Copy Link"));
|
||||
@@ -440,7 +429,7 @@ void TextBrowserHelpWidget::mouseReleaseEvent(QMouseEvent *e)
|
||||
bool controlPressed = e->modifiers() & Qt::ControlModifier;
|
||||
const QString link = linkAt(e->pos());
|
||||
if ((controlPressed || e->button() == Qt::MidButton) && link.isEmpty()) {
|
||||
openLink(link, true/*newPage*/);
|
||||
emit m_parent->newPageRequested(QUrl(link));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user