forked from qt-creator/qt-creator
Read from install-wide settings for registering documentation.
Installers can write a semicolon separated list of files and directories to the install-wide settings for the key "Help/InstalledDocumentation". Qt Creator will look for *.qch files in directories mentioned there (*not* traversing subdirectories). Change-Id: I0f9b92caee3e2c72b3876573b9a050f7aea24a1a Reviewed-by: Karsten Heimrich <karsten.heimrich@nokia.com> Reviewed-by: Tim Jenssen <tim.jenssen@nokia.com> Reviewed-by: Niels Weber <niels.2.weber@nokia.com>
This commit is contained in:
@@ -56,6 +56,8 @@ struct HelpManagerPrivate
|
|||||||
m_needsSetup(true), m_helpEngine(0), m_collectionWatcher(0)
|
m_needsSetup(true), m_helpEngine(0), m_collectionWatcher(0)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
QStringList documentationFromInstaller();
|
||||||
|
|
||||||
bool m_needsSetup;
|
bool m_needsSetup;
|
||||||
QHelpEngineCore *m_helpEngine;
|
QHelpEngineCore *m_helpEngine;
|
||||||
Utils::FileSystemWatcher *m_collectionWatcher;
|
Utils::FileSystemWatcher *m_collectionWatcher;
|
||||||
@@ -408,13 +410,7 @@ void HelpManager::setupHelpManager()
|
|||||||
d->m_nameSpacesToUnregister.clear();
|
d->m_nameSpacesToUnregister.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
// this might come from the installer
|
d->m_filesToRegister << d->documentationFromInstaller();
|
||||||
const QLatin1String key("AddedDocs");
|
|
||||||
const QString addedDocs = d->m_helpEngine->customValue(key).toString();
|
|
||||||
if (!addedDocs.isEmpty()) {
|
|
||||||
d->m_helpEngine->removeCustomValue(key);
|
|
||||||
d->m_filesToRegister += addedDocs.split(QLatin1Char(';'));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!d->m_filesToRegister.isEmpty()) {
|
if (!d->m_filesToRegister.isEmpty()) {
|
||||||
registerDocumentation(d->m_filesToRegister);
|
registerDocumentation(d->m_filesToRegister);
|
||||||
@@ -425,25 +421,9 @@ void HelpManager::setupHelpManager()
|
|||||||
for (it = d->m_customValues.constBegin(); it != d->m_customValues.constEnd(); ++it)
|
for (it = d->m_customValues.constBegin(); it != d->m_customValues.constEnd(); ++it)
|
||||||
setCustomValue(it.key(), it.value());
|
setCustomValue(it.key(), it.value());
|
||||||
|
|
||||||
d->m_collectionWatcher = new Utils::FileSystemWatcher(this);
|
|
||||||
d->m_collectionWatcher->setObjectName(QLatin1String("HelpCollectionWatcher"));
|
|
||||||
d->m_collectionWatcher->addFile(collectionFilePath(), Utils::FileSystemWatcher::WatchAllChanges);
|
|
||||||
connect(d->m_collectionWatcher, SIGNAL(fileChanged(QString)), this,
|
|
||||||
SLOT(collectionFileModified()));
|
|
||||||
|
|
||||||
emit setupFinished();
|
emit setupFinished();
|
||||||
}
|
}
|
||||||
|
|
||||||
void HelpManager::collectionFileModified()
|
|
||||||
{
|
|
||||||
const QLatin1String key("AddedDocs");
|
|
||||||
const QString addedDocs = d->m_helpEngine->customValue(key).toString();
|
|
||||||
if (!addedDocs.isEmpty()) {
|
|
||||||
d->m_helpEngine->removeCustomValue(key);
|
|
||||||
registerDocumentation(addedDocs.split(QLatin1Char(';')));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// -- private
|
// -- private
|
||||||
|
|
||||||
void HelpManager::verifyDocumenation()
|
void HelpManager::verifyDocumenation()
|
||||||
@@ -455,4 +435,25 @@ void HelpManager::verifyDocumenation()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QStringList HelpManagerPrivate::documentationFromInstaller()
|
||||||
|
{
|
||||||
|
QSettings *installSettings = Core::ICore::instance()->settings(QSettings::SystemScope);
|
||||||
|
QStringList documentationPaths = installSettings->value(QLatin1String("Help/InstalledDocumentation"))
|
||||||
|
.toString().split(QLatin1Char(';'), QString::SkipEmptyParts);
|
||||||
|
QStringList documentationFiles;
|
||||||
|
foreach (const QString &path, documentationPaths) {
|
||||||
|
QFileInfo pathInfo(path);
|
||||||
|
if (pathInfo.isFile() && pathInfo.isReadable()) {
|
||||||
|
documentationFiles << pathInfo.absoluteFilePath();
|
||||||
|
} else if (pathInfo.isDir()) {
|
||||||
|
QDir dir(path);
|
||||||
|
foreach (const QFileInfo &fileInfo, dir.entryInfoList(QStringList() << "*.qch",
|
||||||
|
QDir::Files | QDir::Readable)) {
|
||||||
|
documentationFiles << fileInfo.absoluteFilePath();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return documentationFiles;
|
||||||
|
}
|
||||||
|
|
||||||
} // Core
|
} // Core
|
||||||
|
|||||||
@@ -93,7 +93,6 @@ signals:
|
|||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void setupHelpManager();
|
void setupHelpManager();
|
||||||
void collectionFileModified();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void verifyDocumenation();
|
void verifyDocumenation();
|
||||||
|
|||||||
Reference in New Issue
Block a user