diff --git a/sleepyhead/daily.cpp b/sleepyhead/daily.cpp index cbfdfbb9..460876f2 100644 --- a/sleepyhead/daily.cpp +++ b/sleepyhead/daily.cpp @@ -1276,15 +1276,13 @@ QString Daily::getSleepTime(Day * day) QVariant MyTextBrowser::loadResource(int type, const QUrl &url) { - if (type == QTextDocument::ImageResource - && url.scheme().compare(QLatin1String("data"), Qt::CaseInsensitive) == 0) - { - static QRegularExpression re("^image/[^;]+;base64,.+={0,2}$"); - QRegularExpressionMatch match = re.match(url.path()); - if (match.hasMatch()) - return QVariant(); - } - return QTextBrowser::loadResource(type, url); + if (type == QTextDocument::ImageResource && url.scheme().compare(QLatin1String("data"), Qt::CaseInsensitive) == 0) { + static QRegularExpression re("^image/[^;]+;base64,.+={0,2}$"); + QRegularExpressionMatch match = re.match(url.path()); + if (match.hasMatch()) + return QVariant(); + } + return QTextBrowser::loadResource(type, url); } diff --git a/sleepyhead/help.cpp b/sleepyhead/help.cpp index 2a9a7844..dfc76eae 100644 --- a/sleepyhead/help.cpp +++ b/sleepyhead/help.cpp @@ -41,7 +41,13 @@ Help::Help(QWidget *parent) : tabWidget->addTab(helpEngine->contentWidget(), tr("Contents")); tabWidget->addTab(helpEngine->indexWidget(), tr("Index")); - tabWidget->addTab(helpEngine->searchEngine()->resultWidget(), tr("Search")); + + resultWidget = new MyTextBrowser(this); + resultWidget->setOpenLinks(false); + tabWidget->addTab(resultWidget, tr("Search")); + resultWidget->setStyleSheet("a:link, a:visited { color: inherit; text-decoration: none; font-weight: normal;}" + "a:hover { background-color: inherit; color: #ff8888; text-decoration:underline; font-weight: normal; }"); + helpBrowser = new HelpBrowser(helpEngine); @@ -60,13 +66,15 @@ Help::Help(QWidget *parent) : QTimer::singleShot(50,this, SLOT(startup())); - connect(helpEngine->contentWidget(), SIGNAL(linkActivated(QUrl)), helpBrowser, SLOT(setSource(QUrl))); - connect(helpEngine->indexWidget(), SIGNAL(linkActivated(QUrl, QString)), helpBrowser, SLOT(setSource(QUrl))); connect(helpBrowser, SIGNAL(forwardAvailable(bool)), this, SLOT(forwardAvailable(bool))); connect(helpBrowser, SIGNAL(backwardAvailable(bool)), this, SLOT(backwardAvailable(bool))); + connect(helpEngine->contentWidget(), SIGNAL(linkActivated(QUrl)), helpBrowser, SLOT(setSource(QUrl))); + connect(helpEngine->indexWidget(), SIGNAL(linkActivated(QUrl, QString)), helpBrowser, SLOT(setSource(QUrl))); + connect(helpEngine->searchEngine(), SIGNAL(searchingFinished(int)), this, SLOT(on_searchComplete(int))); connect(helpEngine->searchEngine(), SIGNAL(indexingFinished()), this, SLOT(indexingFinished())); - connect(helpEngine->searchEngine()->resultWidget(), SIGNAL(requestShowLink(QUrl)), this, SLOT(requestShowLink(QUrl))); + + connect(resultWidget, SIGNAL(anchorClicked(QUrl)), this, SLOT(requestShowLink(QUrl))); ui->forwardButton->setEnabled(false); ui->backButton->setEnabled(false); @@ -80,7 +88,7 @@ Help::Help(QWidget *parent) : Help::~Help() { - disconnect(helpEngine->searchEngine()->resultWidget(), SIGNAL(requestShowLink(QUrl)), this, SLOT(requestShowLink(QUrl))); + disconnect(resultWidget, SIGNAL(anchorClicked(QUrl)), this, SLOT(requestShowLink(QUrl))); disconnect(helpEngine->searchEngine(), SIGNAL(indexingFinished()), this, SLOT(indexingFinished())); disconnect(helpEngine->searchEngine(), SIGNAL(searchingFinished(int)), this, SLOT(on_searchComplete(int))); @@ -111,8 +119,7 @@ QVariant HelpBrowser::loadResource(int type, const QUrl &name) QByteArray bytes = helpEngine->fileData(urlstr); if (bytes.size()>0) return QVariant(bytes); - if (type == QTextDocument::ImageResource - && name.scheme().compare(QLatin1String("data"), Qt::CaseInsensitive) == 0) { + if (type == QTextDocument::ImageResource && name.scheme().compare(QLatin1String(""), Qt::CaseInsensitive) == 0) { static QRegularExpression re("^image/[^;]+;base64,.+={0,2}$"); QRegularExpressionMatch match = re.match(name.path()); if (match.hasMatch()) @@ -136,7 +143,7 @@ void Help::on_homeButton_clicked() QByteArray index = helpEngine->fileData(QUrl("qthelp://jedimark.net.sleepyhead.1.1/doc/help_en/index.html")); helpBrowser->setHtml(index); } -void Help::on_searchComplete(int) +void Help::on_searchComplete(int count) { if (!searchReady) { QString html = "
Title: %2
%3
").arg(result.url().toString()).arg(result.title()).arg(result.snippet());
+ QString title = result.url().toString().section("/",-1);
+ html += QString("