forked from qt-creator/qt-creator
Disable help search widget while indexing documentation
If you try to search while indexing, in the best case you'd get incomplete results (though with a warning that that is the case), and in the worst case it crashes because of QTBUG-66816. So just disable the search widget with info and progress indicator in that case. Task-number: QTCREATORBUG-20295 Change-Id: Ibec602b1bc0e98f6fef029c6f10c0cdc5197294c Reviewed-by: Robert Loehning <robert.loehning@qt.io>
This commit is contained in:
@@ -32,6 +32,7 @@
|
|||||||
#include <coreplugin/coreconstants.h>
|
#include <coreplugin/coreconstants.h>
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
#include <coreplugin/progressmanager/progressmanager.h>
|
#include <coreplugin/progressmanager/progressmanager.h>
|
||||||
|
#include <utils/progressindicator.h>
|
||||||
#include <utils/styledbar.h>
|
#include <utils/styledbar.h>
|
||||||
#include <utils/utilsicons.h>
|
#include <utils/utilsicons.h>
|
||||||
|
|
||||||
@@ -43,6 +44,7 @@
|
|||||||
#include <QHelpSearchResultWidget>
|
#include <QHelpSearchResultWidget>
|
||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
#include <QLayout>
|
#include <QLayout>
|
||||||
|
#include <QLabel>
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QRegExp>
|
#include <QRegExp>
|
||||||
@@ -112,11 +114,14 @@ void SearchWidget::showEvent(QShowEvent *event)
|
|||||||
|
|
||||||
Utils::StyledBar *toolbar = new Utils::StyledBar(this);
|
Utils::StyledBar *toolbar = new Utils::StyledBar(this);
|
||||||
toolbar->setSingleRow(false);
|
toolbar->setSingleRow(false);
|
||||||
QHelpSearchQueryWidget *queryWidget = searchEngine->queryWidget();
|
m_queryWidget = searchEngine->queryWidget();
|
||||||
QLayout *tbLayout = new QVBoxLayout();
|
QLayout *tbLayout = new QVBoxLayout();
|
||||||
tbLayout->setSpacing(6);
|
tbLayout->setSpacing(6);
|
||||||
tbLayout->setMargin(4);
|
tbLayout->setMargin(4);
|
||||||
tbLayout->addWidget(queryWidget);
|
tbLayout->addWidget(m_queryWidget);
|
||||||
|
m_indexingDocumentationLabel = new QLabel(tr("Indexing Documentation"), toolbar);
|
||||||
|
m_indexingDocumentationLabel->hide();
|
||||||
|
tbLayout->addWidget(m_indexingDocumentationLabel);
|
||||||
toolbar->setLayout(tbLayout);
|
toolbar->setLayout(tbLayout);
|
||||||
|
|
||||||
Utils::StyledBar *toolbar2 = new Utils::StyledBar(this);
|
Utils::StyledBar *toolbar2 = new Utils::StyledBar(this);
|
||||||
@@ -127,12 +132,17 @@ void SearchWidget::showEvent(QShowEvent *event)
|
|||||||
tbLayout->addWidget(resultWidget = searchEngine->resultWidget());
|
tbLayout->addWidget(resultWidget = searchEngine->resultWidget());
|
||||||
toolbar2->setLayout(tbLayout);
|
toolbar2->setLayout(tbLayout);
|
||||||
|
|
||||||
|
m_indexingIndicator = new Utils::ProgressIndicator(Utils::ProgressIndicatorSize::Medium,
|
||||||
|
resultWidget);
|
||||||
|
m_indexingIndicator->attachToWidget(resultWidget);
|
||||||
|
m_indexingIndicator->hide();
|
||||||
|
|
||||||
vLayout->addWidget(toolbar);
|
vLayout->addWidget(toolbar);
|
||||||
vLayout->addWidget(toolbar2);
|
vLayout->addWidget(toolbar2);
|
||||||
|
|
||||||
setFocusProxy(queryWidget);
|
setFocusProxy(m_queryWidget);
|
||||||
|
|
||||||
connect(queryWidget, &QHelpSearchQueryWidget::search, this, &SearchWidget::search);
|
connect(m_queryWidget, &QHelpSearchQueryWidget::search, this, &SearchWidget::search);
|
||||||
connect(resultWidget, &QHelpSearchResultWidget::requestShowLink, this,
|
connect(resultWidget, &QHelpSearchResultWidget::requestShowLink, this,
|
||||||
[this](const QUrl &url) {
|
[this](const QUrl &url) {
|
||||||
emit linkActivated(url, currentSearchTerms(), false/*newPage*/);
|
emit linkActivated(url, currentSearchTerms(), false/*newPage*/);
|
||||||
@@ -205,6 +215,10 @@ void SearchWidget::indexingStarted()
|
|||||||
m_watcher.setFuture(m_progress->future());
|
m_watcher.setFuture(m_progress->future());
|
||||||
connect(&m_watcher, &QFutureWatcherBase::canceled,
|
connect(&m_watcher, &QFutureWatcherBase::canceled,
|
||||||
searchEngine, &QHelpSearchEngine::cancelIndexing);
|
searchEngine, &QHelpSearchEngine::cancelIndexing);
|
||||||
|
|
||||||
|
m_queryWidget->hide();
|
||||||
|
m_indexingDocumentationLabel->show();
|
||||||
|
m_indexingIndicator->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SearchWidget::indexingFinished()
|
void SearchWidget::indexingFinished()
|
||||||
@@ -213,6 +227,10 @@ void SearchWidget::indexingFinished()
|
|||||||
|
|
||||||
delete m_progress;
|
delete m_progress;
|
||||||
m_progress = NULL;
|
m_progress = NULL;
|
||||||
|
|
||||||
|
m_queryWidget->show();
|
||||||
|
m_indexingDocumentationLabel->hide();
|
||||||
|
m_indexingIndicator->hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SearchWidget::eventFilter(QObject *o, QEvent *e)
|
bool SearchWidget::eventFilter(QObject *o, QEvent *e)
|
||||||
|
@@ -33,10 +33,13 @@
|
|||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QHelpSearchEngine;
|
class QHelpSearchEngine;
|
||||||
|
class QHelpSearchQueryWidget;
|
||||||
class QHelpSearchResultWidget;
|
class QHelpSearchResultWidget;
|
||||||
class QUrl;
|
class QUrl;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
namespace Utils { class ProgressIndicator; }
|
||||||
|
|
||||||
namespace Help {
|
namespace Help {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
@@ -93,6 +96,9 @@ private:
|
|||||||
|
|
||||||
QHelpSearchEngine *searchEngine;
|
QHelpSearchEngine *searchEngine;
|
||||||
QHelpSearchResultWidget *resultWidget;
|
QHelpSearchResultWidget *resultWidget;
|
||||||
|
QHelpSearchQueryWidget *m_queryWidget;
|
||||||
|
QWidget *m_indexingDocumentationLabel;
|
||||||
|
Utils::ProgressIndicator *m_indexingIndicator;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
Reference in New Issue
Block a user