22#include <QtCore/QByteArray>
23#include <QtCore/QDateTime>
24#include <QtCore/QDebug>
26#include <QtCore/QPair>
27#include <QtCore/QResource>
28#include <QtCore/QStandardPaths>
29#include <QtCore/QTextStream>
30#include <QtCore/QTimer>
31#include <QtCore/QBuffer>
32#include <QtCore/QLibraryInfo>
33#include <QtCore/QFileInfo>
36#include <QtGui/QAction>
37#include <QtGui/QFontDatabase>
38#include <QtGui/QImageReader>
39#include <QtGui/QScreen>
40#include <QtGui/QShortcut>
42#include <QtWidgets/QComboBox>
43#include <QtWidgets/QDockWidget>
44#include <QtWidgets/QFileDialog>
45#include <QtWidgets/QLabel>
46#include <QtWidgets/QLayout>
47#include <QtWidgets/QLineEdit>
48#include <QtWidgets/QMenuBar>
49#include <QtWidgets/QMessageBox>
50#include <QtWidgets/QProgressBar>
51#include <QtWidgets/QStatusBar>
52#include <QtWidgets/QToolBar>
53#include <QtWidgets/QToolButton>
55#include <QtHelp/QHelpContentModel>
56#include <QtHelp/QHelpEngineCore>
57#include <QtHelp/QHelpIndexModel>
58#include <QtHelp/QHelpSearchEngine>
59#include <QtHelp/QHelpFilterEngine>
65using namespace Qt::StringLiterals;
75 setToolButtonStyle(Qt::ToolButtonFollowStyle);
76 setDockOptions(dockOptions() | AllowNestedDocks);
78 QString collectionFile;
80 MainWindow::collectionFileDirectory(
true);
81 collectionFile = MainWindow::defaultHelpCollectionFileName();
83 collectionFile = cmdLine->collectionFile();
90 qDebug(
"Fatal error: Help engine initialization failed. "
91 "Error message was: %s\nAssistant will now exit.",
96 m_centralWidget =
new CentralWidget(
this);
97 setCentralWidget(m_centralWidget);
99 m_indexWindow =
new IndexWindow(
this);
100 QDockWidget *indexDock =
new QDockWidget(tr(
"Index"),
this);
101 indexDock->setObjectName(
"IndexWindow"_L1);
102 indexDock->setWidget(m_indexWindow);
103 addDockWidget(Qt::LeftDockWidgetArea, indexDock);
106 QDockWidget *contentDock =
new QDockWidget(tr(
"Contents"),
this);
107 contentDock->setObjectName(
"ContentWindow"_L1);
108 contentDock->setWidget(m_contentWindow);
109 addDockWidget(Qt::LeftDockWidgetArea, contentDock);
111 m_searchWindow =
new SearchWidget(helpEngineWrapper.searchEngine());
112 m_searchWindow->setFont(!helpEngineWrapper.usesBrowserFont() ? qApp->font()
113 : helpEngineWrapper.browserFont());
114 QDockWidget *searchDock =
new QDockWidget(tr(
"Search"),
this);
115 searchDock->setObjectName(
"SearchWindow"_L1);
116 searchDock->setWidget(m_searchWindow);
117 addDockWidget(Qt::LeftDockWidgetArea, searchDock);
119 QDockWidget *bookmarkDock =
new QDockWidget(tr(
"Bookmarks"),
this);
120 bookmarkDock->setObjectName(
"BookmarkWindow"_L1);
121 bookmarkDock->setWidget(m_bookmarkWidget
122 = bookMarkManager->bookmarkDockWidget());
123 addDockWidget(Qt::LeftDockWidgetArea, bookmarkDock);
125 QDockWidget *openPagesDock =
new QDockWidget(tr(
"Open Pages"),
this);
126 openPagesDock->setObjectName(
"Open Pages"_L1);
128 = OpenPagesManager::createInstance(
this, usesDefaultCollection(), m_cmdLine->url());
130 addDockWidget(Qt::LeftDockWidgetArea, openPagesDock);
132 connect(m_centralWidget, &CentralWidget::addBookmark,
133 bookMarkManager, &BookmarkManager::addBookmark);
134 connect(bookMarkManager, &BookmarkManager::escapePressed,
135 this, &MainWindow::activateCurrentCentralWidgetTab);
136 connect(bookMarkManager, &BookmarkManager::setSource,
137 m_centralWidget, &CentralWidget::setSource);
138 connect(bookMarkManager, &BookmarkManager::setSourceInNewTab,
139 openPagesManager, [openPagesManager](
const QUrl &url){ openPagesManager->createPage(url); });
142 connect(searchEngine, &QHelpSearchEngine::indexingStarted,
143 this, &MainWindow::indexingStarted);
144 connect(searchEngine, &QHelpSearchEngine::indexingFinished,
145 this, &MainWindow::indexingFinished);
147 QString defWindowTitle = tr(
"Qt Assistant");
148 setWindowTitle(defWindowTitle);
154 setupFilterToolbar();
155 setupAddressToolbar();
157 const QString windowTitle = helpEngineWrapper.windowTitle();
158 setWindowTitle(windowTitle.isEmpty() ? defWindowTitle : windowTitle);
159 QByteArray iconArray = helpEngineWrapper.applicationIcon();
160 if (iconArray.size() > 0) {
161 QBuffer buffer(&iconArray);
162 QImageReader reader(&buffer);
166 pix.convertFromImage(reader.read());
167 appIcon.addPixmap(pix);
168 }
while (reader.jumpToNextImage());
169 qApp->setWindowIcon(appIcon);
171#if !defined(Q_OS_MACOS) && !defined(Q_OS_WIN)
173 QIcon appIcon(
":/qt-project.org/assistant/images/assistant-128.png"_L1);
174 qApp->setWindowIcon(appIcon);
178 QToolBar *toolBar = addToolBar(tr(
"Bookmark Toolbar"));
179 toolBar->setObjectName(
"Bookmark Toolbar"_L1);
183 toolBarMenu()->addAction(toolBar->toggleViewAction());
185 QByteArray ba(helpEngineWrapper.mainWindow());
189 ba = helpEngineWrapper.mainWindowGeometry();
193 tabifyDockWidget(contentDock, indexDock);
194 tabifyDockWidget(indexDock, bookmarkDock);
195 tabifyDockWidget(bookmarkDock, searchDock);
196 contentDock->raise();
197 const QRect screen = QGuiApplication::primaryScreen()->geometry();
199 resize(4 * screen.width() / 5, 4 * screen.height() / 5);
201 move(screen.center() - rect().center());
207 helpEngineWrapper.setAppFont(qApp->font());
208 helpEngineWrapper.setAppWritingSystem(QFontDatabase::Latin);
209 helpEngineWrapper.setBrowserFont(qApp->font());
210 helpEngineWrapper.setBrowserWritingSystem(QFontDatabase::Latin);
212 updateApplicationFont();
215 updateAboutMenuText();
217 QTimer::singleShot(0,
this, &MainWindow::insertLastPages);
218 if (m_cmdLine->enableRemoteControl())
219 (
void)
new RemoteControl(
this);
232 showBookmarksDockWidget();
234 hideBookmarksDockWidget();
246 showBookmarksDockWidget();
248 if (!m_cmdLine->currentFilter().isEmpty()) {
249 const QString &curFilter = m_cmdLine->currentFilter();
255 QTimer::singleShot(0,
this, &MainWindow::lookForNewQtDocumentation);
259 connect(&helpEngineWrapper, &HelpEngineWrapper::documentationRemoved,
260 this, &MainWindow::documentationRemoved);
261 connect(&helpEngineWrapper, &HelpEngineWrapper::documentationUpdated,
262 this, &MainWindow::documentationUpdated);
264 setTabPosition(Qt::AllDockWidgetAreas, QTabWidget::North);
265 GlobalActions::instance()->updateActions();
273 delete m_qtDocInstaller;
279 return m_cmdLine->collectionFile().isEmpty();
288 QMainWindow::closeEvent(e);
291bool MainWindow::initHelpDB(
bool registerInternalDoc)
298 if (!registerInternalDoc && helpEngineWrapper.defaultHomePage() ==
"help"_L1)
299 helpEngineWrapper.setDefaultHomePage(
"about:blank"_L1);
305 "assistant",
"designer",
"linguist",
320 "qtgraphicaleffects",
328 "qtmultimediawidgets",
352 "qtquickcontrolsstyles",
362 const QDir docDirectory(QLibraryInfo::path(QLibraryInfo::DocumentationPath));
363 const QFileInfoList entries = docDirectory.entryInfoList(QStringList(QStringLiteral(
"*.qch")),
364 QDir::Files, QDir::Name);
365 if (!entries.isEmpty()) {
366 result.reserve(entries.size());
367 for (
const QFileInfo &fi : entries)
368 result.append(fi.baseName());
371 if (warnAboutMissingModules)
372 qWarning() <<
"No documentation found in " << QDir::toNativeSeparators(docDirectory.absolutePath());
373 const int docCount =
int(
sizeof(
docs) /
sizeof(
docs[0]));
374 result.reserve(docCount);
375 for (
int d = 0; d < docCount; ++d)
376 result.append(QLatin1StringView(
docs[d]));
385 const QStringList &docs = newQtDocumentation();
386 const int docCount = docs.size();
387 QList<QtDocInstaller::DocInfo> qtDocInfos;
388 qtDocInfos.reserve(docCount);
389 for (
const QString &doc : docs) {
390 const QtDocInstaller::DocInfo docInfo(doc, helpEngine.qtDocInfo(doc));
391 qtDocInfos.append(docInfo);
392 if (warnAboutMissingModules && (docInfo.second.isEmpty() || docInfo.second.first().isEmpty()))
393 qWarning() <<
"No documentation found for " << doc;
399 connect(m_qtDocInstaller, &QtDocInstaller::qchFileNotFound,
400 this, &MainWindow::resetQtDocInfo);
401 connect(m_qtDocInstaller, &QtDocInstaller::registerDocumentation,
402 this, &MainWindow::registerDocumentation);
403 if (helpEngine.qtDocInfo(
"qt"_L1).size() != 2)
404 statusBar()->showMessage(tr(
"Looking for Qt Documentation..."));
412 statusBar()->clearMessage();
427 if (!m_connectedInitSignals) {
428 connect(helpEngine.contentModel(), &QHelpContentModel::contentsCreated,
429 this, &MainWindow::checkInitState);
430 connect(helpEngine.indexModel(), &QHelpIndexModel::indexCreated,
431 this, &MainWindow::checkInitState);
432 m_connectedInitSignals =
true;
435 if (m_connectedInitSignals) {
454 QString resourcePath =
":/qt-project.org/assistant/images/"_L1;
456 setUnifiedTitleAndToolBarOnMac(
true);
457 resourcePath.append(
"mac"_L1);
459 resourcePath.append(
"win"_L1);
462 QMenu *menu = menuBar()->addMenu(tr(
"&File"));
464 m_newTabAction = menu->addAction(tr(
"New &Tab"),
466 m_newTabAction->setShortcut(QKeySequence::AddTab);
467 m_closeTabAction = menu->addAction(tr(
"&Close Tab"),
469 m_closeTabAction->setShortcuts(QKeySequence::Close);
476 menu->addSeparator();
478 m_pageSetupAction = menu->addAction(tr(
"Page Set&up..."),
480 m_printPreviewAction = menu->addAction(tr(
"Print Preview..."),
483 GlobalActions *globalActions = GlobalActions::instance(
this);
485 menu->addSeparator();
487 QIcon appExitIcon = QIcon::fromTheme(QIcon::ThemeIcon::ApplicationExit);
490 tmp = menu->addAction(appExitIcon, tr(
"E&xit"),
491 this, &QWidget::close);
492 tmp->setShortcut(QKeySequence(tr(
"CTRL+Q")));
494 tmp = menu->addAction(appExitIcon, tr(
"&Quit"),
495 this, &QWidget::close);
496 tmp->setShortcut(QKeySequence::Quit);
498 tmp->setMenuRole(QAction::QuitRole);
500 menu = menuBar()->addMenu(tr(
"&Edit"));
501#if QT_CONFIG(clipboard)
502 menu->addAction(globalActions->copyAction());
506 QAction *findNextAction = menu->addAction(tr(
"Find &Next"),
508 findNextAction->setShortcuts(QKeySequence::FindNext);
510 QAction *findPreviousAction = menu->addAction(tr(
"Find &Previous"),
512 findPreviousAction->setShortcuts(QKeySequence::FindPrevious);
514 menu->addSeparator();
515 tmp = menu->addAction(tr(
"Preferences..."),
517 tmp->setMenuRole(QAction::PreferencesRole);
519 m_viewMenu = menuBar()->addMenu(tr(
"&View"));
523 m_resetZoomAction = m_viewMenu->addAction(tr(
"Normal &Size"),
525 m_resetZoomAction->setPriority(QAction::LowPriority);
526 m_resetZoomAction->setIcon(QIcon(resourcePath +
"/resetzoom.png"_L1));
527 m_resetZoomAction->setShortcut(tr(
"Ctrl+0"));
529 m_viewMenu->addSeparator();
531 m_viewMenu->addAction(tr(
"Contents"), QKeySequence(tr(
"ALT+C")),
532 this, &MainWindow::showContents);
533 m_viewMenu->addAction(tr(
"Index"), QKeySequence(tr(
"ALT+I")),
535 m_viewMenu->addAction(tr(
"Bookmarks"), QKeySequence(tr(
"ALT+O")),
536 this, &MainWindow::showBookmarksDockWidget);
537 m_viewMenu->addAction(tr(
"Search"), QKeySequence(tr(
"ALT+S")),
539 m_viewMenu->addAction(tr(
"Open Pages"), QKeySequence(tr(
"ALT+P")),
542 menu = menuBar()->addMenu(tr(
"&Go"));
547 m_syncAction = menu->addAction(tr(
"Sync with Table of Contents"),
549 m_syncAction->setIconText(tr(
"Sync"));
550 m_syncAction->setIcon(QIcon(resourcePath +
"/synctoc.png"_L1));
552 menu->addSeparator();
554 tmp = menu->addAction(tr(
"Next Page"),
556 tmp->setShortcuts(QList<QKeySequence>() << QKeySequence(tr(
"Ctrl+Alt+Right"))
557 << QKeySequence(Qt::CTRL | Qt::Key_PageDown));
559 tmp = menu->addAction(tr(
"Previous Page"),
561 tmp->setShortcuts(QList<QKeySequence>() << QKeySequence(tr(
"Ctrl+Alt+Left"))
562 << QKeySequence(Qt::CTRL | Qt::Key_PageUp));
564 const Qt::Modifier modifier =
571 QShortcut *sct =
new QShortcut(QKeySequence(modifier | Qt::Key_Tab),
this);
572 connect(sct, &QShortcut::activated,
573 openPages, &OpenPagesManager::nextPageWithSwitcher);
574 sct =
new QShortcut(QKeySequence(modifier | Qt::SHIFT | Qt::Key_Tab),
this);
575 connect(sct, &QShortcut::activated,
576 openPages, &OpenPagesManager::previousPageWithSwitcher);
578 BookmarkManager::instance()->setBookmarksMenu(menuBar()->addMenu(tr(
"&Bookmarks")));
580 menu = menuBar()->addMenu(tr(
"&Help"));
581 m_aboutAction = menu->addAction(tr(
"About..."),
583 m_aboutAction->setMenuRole(QAction::AboutRole);
585#if defined(Q_OS_UNIX) && !defined(Q_OS_MAC)
586 m_resetZoomAction->setIcon(QIcon::fromTheme(
"zoom-original"_L1, m_resetZoomAction->icon()));
587 m_syncAction->setIcon(QIcon::fromTheme(QIcon::ThemeIcon::ViewRefresh,
588 m_syncAction->icon()));
591 QToolBar *navigationBar = addToolBar(tr(
"Navigation Toolbar"));
592 navigationBar->setObjectName(
"NavigationToolBar"_L1);
596 navigationBar->addAction(m_syncAction);
597 navigationBar->addSeparator();
598#if QT_CONFIG(clipboard)
599 navigationBar->addAction(globalActions->copyAction());
603 navigationBar->addSeparator();
606 navigationBar->addAction(m_resetZoomAction);
609 QMenu *windowMenu =
new QMenu(tr(
"&Window"),
this);
610 menuBar()->insertMenu(menu->menuAction(), windowMenu);
611 windowMenu->addAction(tr(
"Zoom"),
612 this, &QWidget::showMaximized);
613 windowMenu->addAction(tr(
"Minimize"), QKeySequence(tr(
"Ctrl+M")),
614 this, &QWidget::showMinimized);
618#if QT_CONFIG(clipboard)
619 connect(m_centralWidget, &CentralWidget::copyAvailable,
620 globalActions, &GlobalActions::setCopyAvailable);
622 connect(m_centralWidget, &CentralWidget::currentViewerChanged,
623 globalActions, &GlobalActions::updateActions);
624 connect(m_centralWidget, &CentralWidget::forwardAvailable,
625 globalActions, &GlobalActions::updateActions);
626 connect(m_centralWidget, &CentralWidget::backwardAvailable,
627 globalActions, &GlobalActions::updateActions);
628 connect(m_centralWidget, &CentralWidget::highlighted,
629 this, [
this](
const QUrl &link) { statusBar()->showMessage(link.toString());} );
632 connect(m_indexWindow, &IndexWindow::linkActivated,
633 m_centralWidget, &CentralWidget::setSource);
634 connect(m_indexWindow, &IndexWindow::documentsActivated,
635 this, &MainWindow::showTopicChooser);
640 connect(m_contentWindow, &ContentWindow::linkActivated,
641 m_centralWidget, &CentralWidget::setSource);
646 connect(m_searchWindow, &SearchWidget::requestShowLink,
647 CentralWidget::instance(), &CentralWidget::setSourceFromSearch);
648 connect(m_searchWindow, &
SearchWidget::requestShowLinkInNewTab,
651#if defined(QT_NO_PRINTER)
652 m_pageSetupAction->setVisible(
false);
653 m_printPreviewAction->setVisible(
false);
654 globalActions->printAction()->setVisible(
false);
661 if (!m_toolBarMenu) {
662 m_viewMenu->addSeparator();
663 m_toolBarMenu = m_viewMenu->addMenu(tr(
"Toolbars"));
665 return m_toolBarMenu;
675 m_filterCombo =
new QComboBox(
this);
676 m_filterCombo->setMinimumWidth(QFontMetrics({}).
677 horizontalAdvance(
"MakeTheComboBoxWidthEnough"_L1));
679 QToolBar *filterToolBar = addToolBar(tr(
"Filter Toolbar"));
680 filterToolBar->setObjectName(
"FilterToolBar"_L1);
681 filterToolBar->addWidget(
new QLabel(tr(
"Filtered by:").append(u' '),
683 filterToolBar->addWidget(m_filterCombo);
686 filterToolBar->hide();
687 toolBarMenu()->addAction(filterToolBar->toggleViewAction());
689 connect(&helpEngine, &HelpEngineWrapper::setupFinished,
690 this, &MainWindow::setupFilterCombo, Qt::QueuedConnection);
691 connect(m_filterCombo, &QComboBox::activated,
692 this, &MainWindow::filterDocumentation);
693 connect(helpEngine.filterEngine(), &QHelpFilterEngine::filterActivated,
694 this, &MainWindow::currentFilterChanged);
706 m_addressLineEdit =
new QLineEdit(
this);
707 QToolBar *addressToolBar = addToolBar(tr(
"Address Toolbar"));
708 addressToolBar->setObjectName(
"AddressToolBar"_L1);
709 insertToolBarBreak(addressToolBar);
711 addressToolBar->addWidget(
new QLabel(tr(
"Address:").append(QChar::Space),
713 addressToolBar->addWidget(m_addressLineEdit);
716 addressToolBar->hide();
717 toolBarMenu()->addAction(addressToolBar->toggleViewAction());
720 connect(m_addressLineEdit, &QLineEdit::returnPressed,
this, &MainWindow::gotoAddress);
721 connect(m_centralWidget, &CentralWidget::currentViewerChanged,
722 this, QOverload<>::of(&MainWindow::showNewAddress));
723 connect(m_centralWidget, &CentralWidget::sourceChanged,
724 this, QOverload<>::of(&MainWindow::showNewAddress));
730 QByteArray ba = HelpEngineWrapper::instance().aboutMenuTexts();
735 QString currentLang = QLocale::system().name();
736 int i = currentLang.indexOf(u'_');
738 currentLang = currentLang.left(i);
739 QDataStream s(&ba, QIODevice::ReadOnly);
743 if (lang ==
"default"_L1 && trStr.isEmpty()) {
745 }
else if (lang == currentLang) {
750 if (!trStr.isEmpty())
751 m_aboutAction->setText(trStr);
758 showNewAddress(m_centralWidget->currentSource());
761void MainWindow::showNewAddress(
const QUrl &url)
764 m_addressLineEdit->setText(url.toString());
770 m_centralWidget->setSource(m_addressLineEdit->text());
773void MainWindow::showTopicChooser(
const QList<QHelpLink> &documents,
774 const QString &keyword)
778 if (tc.exec() == QDialog::Accepted) {
779 m_centralWidget->setSource(tc
.link());
789 connect(&dia, &PreferencesDialog::updateBrowserFont,
790 m_centralWidget, &CentralWidget::updateBrowserFont);
799 qApp->setOverrideCursor(QCursor(Qt::WaitCursor));
800 const QUrl url = m_centralWidget->currentSource();
802 if (!m_contentWindow->syncToContent(url))
803 statusBar()->showMessage(
804 tr(
"Could not find the associated content item."), 3000);
805 qApp->restoreOverrideCursor();
813 QByteArray ba = helpEngine.aboutTexts();
817 QString currentLang = QLocale::system().name();
818 int i = currentLang.indexOf(u'_');
820 currentLang = currentLang.left(i);
821 QDataStream s(&ba, QIODevice::ReadOnly);
825 if (lang ==
"default"_L1 && contents.isEmpty()) {
827 }
else if (lang == currentLang) {
836 QByteArray iconArray;
837 if (!contents.isEmpty()) {
838 iconArray = helpEngine.aboutIcon();
839 QByteArray resources = helpEngine.aboutImages();
841 pix.loadFromData(iconArray);
842 aboutDia.setText(QString::fromUtf8(contents), resources);
844 aboutDia.setPixmap(pix);
845 aboutDia.setWindowTitle(aboutDia.documentTitle());
847 QByteArray resources;
848#if defined(BROWSER_QTWEBKIT)
849 QString browser = QStringLiteral(
"Qt WebKit");
851 QString browser = QStringLiteral(
"QTextBrowser");
854 browser = QStringLiteral(
"QLiteHtmlWidget");
855 aboutDia.setText(tr(
"<center>"
858 "<p>Browser: %3</p></center>"
859 "<p>Copyright (C) The Qt Company Ltd. and other contributors.</p>")
860 .arg(tr(
"Qt Assistant"), QLatin1String(QT_VERSION_STR), browser),
862 aboutDia.setPixmap(QString(
":/qt-project.org/assistant/images/assistant-128.png"_L1));
864 if (aboutDia.windowTitle().isEmpty())
865 aboutDia.setWindowTitle(tr(
"About %1").arg(windowTitle()));
881 activateDockWidget(m_contentWindow);
887 m_contentWindow->parentWidget()->hide();
902 activateDockWidget(m_indexWindow);
908 m_indexWindow->parentWidget()->hide();
915 showBookmarksDockWidget();
917 hideBookmarksDockWidget();
923 activateDockWidget(m_bookmarkWidget);
929 m_bookmarkWidget->parentWidget()->hide();
944 activateDockWidget(m_searchWindow);
950 activateDockWidget(OpenPagesManager::instance()->openPagesWidget());
956 m_searchWindow->parentWidget()->hide();
959void MainWindow::activateDockWidget(QWidget *w)
962 w->parentWidget()->show();
963 w->parentWidget()->raise();
970 m_indexWindow->setSearchLineEditText(str);
989 QFont font = qApp->font();
991 font = helpEngine.appFont();
993 const QWidgetList &widgets = QApplication::allWidgets();
994 for (QWidget *widget : widgets)
995 widget->setFont(font);
1002 const QString currentFilter = helpEngine.filterEngine()->activeFilter();
1003 m_filterCombo->clear();
1004 m_filterCombo->addItem(tr(
"Unfiltered"));
1005 const QStringList allFilters = helpEngine.filterEngine()->filters();
1006 if (!allFilters.isEmpty())
1007 m_filterCombo->insertSeparator(1);
1008 for (
const QString &filter : allFilters)
1009 m_filterCombo->addItem(filter, filter);
1011 int idx = m_filterCombo->findData(currentFilter);
1014 m_filterCombo->setCurrentIndex(idx);
1017void MainWindow::filterDocumentation(
int filterIndex)
1021 const QString filter = m_filterCombo->itemData(filterIndex).toString();
1028 Q_ASSERT(depth >= -1);
1035 if (!m_progressWidget) {
1036 m_progressWidget =
new QWidget();
1037 QLayout* hlayout =
new QHBoxLayout(m_progressWidget);
1039 QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum);
1041 QLabel *label =
new QLabel(tr(
"Updating search index"));
1042 label->setSizePolicy(sizePolicy);
1043 hlayout->addWidget(label);
1045 QProgressBar *progressBar =
new QProgressBar();
1046 progressBar->setRange(0, 0);
1047 progressBar->setTextVisible(
false);
1048 progressBar->setSizePolicy(sizePolicy);
1050 hlayout->setSpacing(6);
1051 hlayout->setContentsMargins(QMargins());
1052 hlayout->addWidget(progressBar);
1054 statusBar()->addPermanentWidget(m_progressWidget);
1061 statusBar()->removeWidget(m_progressWidget);
1062 delete m_progressWidget;
1063 m_progressWidget =
nullptr;
1066QString
MainWindow::collectionFileDirectory(
bool createDir,
const QString &cacheDir)
1069 QString collectionPath =
1070 QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation);
1071 if (collectionPath.isEmpty()) {
1072 if (cacheDir.isEmpty())
1073 collectionPath = QDir::homePath() + QDir::separator() +
".assistant"_L1;
1075 collectionPath = QDir::homePath() +
"/."_L1 + cacheDir;
1077 if (cacheDir.isEmpty())
1078 collectionPath = collectionPath +
"/QtProject/Assistant"_L1;
1080 collectionPath = collectionPath + QDir::separator() + cacheDir;
1084 if (!dir.exists(collectionPath))
1085 dir.mkpath(collectionPath);
1087 return collectionPath;
1094 return collectionFileDirectory(
true) + QDir::separator()
1095 + QString(
"qthelpcollection_%1.qhc"_L1).arg(QLatin1StringView(QT_VERSION_STR));
1101 int index = m_filterCombo->findData(filter);
1104 m_filterCombo->setCurrentIndex(index);
1107void MainWindow::documentationRemoved(
const QString &namespaceName)
1113void MainWindow::documentationUpdated(
const QString &namespaceName)
1119void MainWindow::resetQtDocInfo(
const QString &component)
1122 HelpEngineWrapper::instance().setQtDocInfo(component,
1123 QStringList(QDateTime().toString(Qt::ISODate)));
1126void MainWindow::registerDocumentation(
const QString &component,
1127 const QString &absFileName)
1130 QString ns = QHelpEngineCore::namespaceName(absFileName);
1135 if (helpEngine.registeredDocumentations().contains(ns))
1136 helpEngine.unregisterDocumentation(ns);
1137 if (!helpEngine.registerDocumentation(absFileName)) {
1138 QMessageBox::warning(
this, tr(
"Qt Assistant"),
1139 tr(
"Could not register file '%1': %2").
1140 arg(absFileName).arg(helpEngine.error()));
1142 QStringList docInfo;
1143 docInfo << QFileInfo(absFileName).lastModified().toString(Qt::ISODate)
1145 helpEngine.setQtDocInfo(component, docInfo);
void setBookmarksToolbar(QToolBar *toolBar)
ShowState contents() const
ShowState bookmarks() const
bool enableRemoteControl() const
bool collectionFileGiven() const
void expandToDepth(int depth)
QAction * findAction() const
QAction * zoomInAction() const
QAction * nextAction() const
QAction * homeAction() const
QAction * backAction() const
QAction * printAction() const
QAction * zoomOutAction() const
QHelpFilterEngine * filterEngine() const
QHelpSearchEngine * searchEngine() const
static HelpEngineWrapper & instance()
bool addressBarEnabled() const
bool addressBarVisible() const
void setUseBrowserFont(bool useBrowserFont)
bool hasFontSettings() const
QHelpIndexModel * indexModel() const
bool filterFunctionalityEnabled() const
void initialDocSetupDone()
bool filterToolbarVisible() const
void setUseAppFont(bool useAppFont)
QHelpContentModel * contentModel() const
void closeEvent(QCloseEvent *event) override
[21]
void setIndexString(const QString &str)
void setBookmarksVisible(bool visible)
static void activateCurrentBrowser()
void activateCurrentCentralWidgetTab()
void expandTOC(int depth)
void setIndexVisible(bool visible)
void setSearchVisible(bool visible)
void currentFilterChanged(const QString &filter)
bool usesDefaultCollection() const
QAbstractItemView * openPagesWidget() const
HelpViewer * createNewPageFromSearch(const QUrl &url)
void pageAdded(int index)
HelpViewer * createBlankPage()
static OpenPagesManager * instance()
void updateApplicationFont()
void updateUserInterface()
void docsInstalled(bool newDocsInstalled)
@ warnAboutMissingModules
static const char * docs[]
static QStringList newQtDocumentation()