From 249e9a91a30ded82dc1018c3ebb842ce4ace014d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20Nisbl=C3=A9?= Date: Fri, 2 Mar 2018 17:43:19 +0100 Subject: [PATCH 01/25] ui: Fix Preferences shortcut (#891) --- src/libs/ui/mainwindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/ui/mainwindow.cpp b/src/libs/ui/mainwindow.cpp index 8ce2db267..9c22e2505 100644 --- a/src/libs/ui/mainwindow.cpp +++ b/src/libs/ui/mainwindow.cpp @@ -191,7 +191,7 @@ MainWindow::MainWindow(Core::Application *app, QWidget *parent) : if (QKeySequence(QKeySequence::Preferences).isEmpty()) { ui->actionPreferences->setShortcut(QStringLiteral("Ctrl+,")); } else { - ui->actionPreferences->setShortcut(QKeySequence::Quit); + ui->actionPreferences->setShortcut(QKeySequence::Preferences); } connect(ui->actionPreferences, &QAction::triggered, [this]() { From 01447079b47ee44b626801b51f0790ef30853dae Mon Sep 17 00:00:00 2001 From: Matt Sephton Date: Sat, 3 Mar 2018 10:50:01 +0000 Subject: [PATCH 02/25] ui: Fix typo in the AboutDialog (#899) --- src/libs/ui/aboutdialog.ui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/ui/aboutdialog.ui b/src/libs/ui/aboutdialog.ui index cc58ec728..06fb1254a 100644 --- a/src/libs/ui/aboutdialog.ui +++ b/src/libs/ui/aboutdialog.ui @@ -75,7 +75,7 @@ <strong>A simple offline documentation browser</strong> <br><br> -Copyright &copy; Oleg Shparber and other conributors, 2013-2018. +Copyright &copy; Oleg Shparber and other contributors, 2013-2018. <br> <a href="https://zealdocs.org">zealdocs.org</a> <br> From 30c85bb13679036e8e81b050d01be13d383cf0fe Mon Sep 17 00:00:00 2001 From: Oleg Shparber Date: Mon, 19 Mar 2018 00:16:35 +0200 Subject: [PATCH 03/25] ui: Fix default fixed font size not being saved (fixes #903) --- src/libs/ui/settingsdialog.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/ui/settingsdialog.cpp b/src/libs/ui/settingsdialog.cpp index 4499d61d6..c3d7a7522 100644 --- a/src/libs/ui/settingsdialog.cpp +++ b/src/libs/ui/settingsdialog.cpp @@ -256,7 +256,7 @@ void SettingsDialog::saveSettings() settings->fixedFontFamily = ui->fixedFontComboBox->currentText(); settings->defaultFontSize = ui->fontSizeComboBox->currentData().toInt(); - settings->defaultFixedFontSize = ui->fixedFontComboBox->currentData().toInt(); + settings->defaultFixedFontSize = ui->fixedFontSizeComboBox->currentData().toInt(); settings->minimumFontSize = ui->minFontSizeComboBox->currentData().toInt(); settings->darkModeEnabled = ui->darkModeCheckBox->isChecked(); From faf4a68bd088f5bc0df161a7e526adc6a3fd7afe Mon Sep 17 00:00:00 2001 From: Oleg Shparber Date: Sun, 15 Apr 2018 17:35:08 +0300 Subject: [PATCH 04/25] ui: Fix return by constant value --- src/libs/ui/widgets/webview.cpp | 2 +- src/libs/ui/widgets/webview.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/ui/widgets/webview.cpp b/src/libs/ui/widgets/webview.cpp index 22e1526b6..3a646454d 100644 --- a/src/libs/ui/widgets/webview.cpp +++ b/src/libs/ui/widgets/webview.cpp @@ -72,7 +72,7 @@ const QVector &WebView::availableZoomLevels() return zoomLevels; } -const int WebView::defaultZoomLevel() +const int &WebView::defaultZoomLevel() { static const int level = availableZoomLevels().indexOf(100); return level; diff --git a/src/libs/ui/widgets/webview.h b/src/libs/ui/widgets/webview.h index 72dcdbcba..03f0f3f6f 100644 --- a/src/libs/ui/widgets/webview.h +++ b/src/libs/ui/widgets/webview.h @@ -41,7 +41,7 @@ class WebView : public QWebView void setZoomLevel(int level); static const QVector &availableZoomLevels(); - static const int defaultZoomLevel(); + static const int &defaultZoomLevel(); public slots: void zoomIn(); From 2cfc8166212a2ea6943f90a27dd9c5ebb532b4c6 Mon Sep 17 00:00:00 2001 From: Oleg Shparber Date: Sun, 15 Apr 2018 17:38:43 +0300 Subject: [PATCH 05/25] ui: Fix handling of javascript: links (fixes #915) --- src/libs/ui/widgets/webview.cpp | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/libs/ui/widgets/webview.cpp b/src/libs/ui/widgets/webview.cpp index 3a646454d..50f155ace 100644 --- a/src/libs/ui/widgets/webview.cpp +++ b/src/libs/ui/widgets/webview.cpp @@ -122,14 +122,20 @@ void WebView::contextMenuEvent(QContextMenuEvent *event) const QString linkText = hitTestResult.linkText(); if (linkUrl.isValid()) { - m_contextMenu->addAction(tr("Open Link in New Tab"), this, [this]() { - triggerPageAction(QWebPage::WebAction::OpenLinkInNewWindow); - }); + const QString scheme = linkUrl.scheme(); - if (linkUrl.scheme() != QLatin1String("qrc")) { - m_contextMenu->addAction(tr("Open Link in Desktop Browser"), this, [linkUrl]() { - QDesktopServices::openUrl(linkUrl); + if (scheme != QLatin1String("javascript")) { + m_contextMenu->addAction(tr("Open Link in New Tab"), this, [this]() { + triggerPageAction(QWebPage::WebAction::OpenLinkInNewWindow); }); + } + + if (scheme != QLatin1String("qrc")) { + if (scheme != QLatin1String("javascript")) { + m_contextMenu->addAction(tr("Open Link in Desktop Browser"), this, [linkUrl]() { + QDesktopServices::openUrl(linkUrl); + }); + } m_contextMenu->addAction(pageAction(QWebPage::CopyLinkToClipboard)); } @@ -177,7 +183,7 @@ void WebView::mousePressEvent(QMouseEvent *event) case Qt::LeftButton: case Qt::MiddleButton: m_clickedLink = hitTestContent(event->pos()).linkUrl(); - if (!m_clickedLink.isValid()) { + if (!m_clickedLink.isValid() || m_clickedLink.scheme() == QLatin1String("javascript")) { break; } @@ -198,7 +204,8 @@ void WebView::mouseReleaseEvent(QMouseEvent *event) } const QUrl clickedLink = hitTestContent(event->pos()).linkUrl(); - if (!clickedLink.isValid() || clickedLink != m_clickedLink) { + if (!clickedLink.isValid() || clickedLink != m_clickedLink + || clickedLink.scheme() == QLatin1String("javascript")) { QWebView::mouseReleaseEvent(event); return; } From f127d0a7b3664f6b70d92412722c06595447011b Mon Sep 17 00:00:00 2001 From: Oleg Shparber Date: Sun, 15 Apr 2018 17:39:09 +0300 Subject: [PATCH 06/25] ui: Refactor WebView::isUrlExternal --- src/libs/ui/widgets/webview.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/libs/ui/widgets/webview.cpp b/src/libs/ui/widgets/webview.cpp index 50f155ace..dd5c227ab 100644 --- a/src/libs/ui/widgets/webview.cpp +++ b/src/libs/ui/widgets/webview.cpp @@ -306,6 +306,11 @@ QWebHitTestResult WebView::hitTestContent(const QPoint &pos) const bool WebView::isUrlExternal(const QUrl &url) { + static const QStringList localSchemes = { + QStringLiteral("file"), + QStringLiteral("qrc"), + }; + const QString scheme = url.scheme(); - return !scheme.isEmpty() && scheme != QLatin1String("file") && scheme != QLatin1String("qrc"); + return !scheme.isEmpty() && !localSchemes.contains(scheme); } From 768a8fef3872ee9756de62e3d796d563573f9346 Mon Sep 17 00:00:00 2001 From: Oleg Shparber Date: Sun, 15 Apr 2018 17:40:36 +0300 Subject: [PATCH 07/25] ui: Add Back/Forward to the webview's context menu (fixes #925) --- src/libs/ui/widgets/webview.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/libs/ui/widgets/webview.cpp b/src/libs/ui/widgets/webview.cpp index dd5c227ab..a62f8cc0f 100644 --- a/src/libs/ui/widgets/webview.cpp +++ b/src/libs/ui/widgets/webview.cpp @@ -154,6 +154,10 @@ void WebView::contextMenuEvent(QContextMenuEvent *event) m_contextMenu->addSeparator(); } + m_contextMenu->addAction(pageAction(QWebPage::Back)); + m_contextMenu->addAction(pageAction(QWebPage::Forward)); + m_contextMenu->addSeparator(); + m_contextMenu->addAction(tr("Open Page in Desktop Browser"), this, [this]() { QDesktopServices::openUrl(url()); }); From 769504b020123d81c541c088a7b68e9c53e6d589 Mon Sep 17 00:00:00 2001 From: Oleg Shparber Date: Sun, 15 Apr 2018 23:24:26 +0300 Subject: [PATCH 08/25] assets: Install app icons with ECMInstallIcons (fixes #922) (#926) --- assets/CMakeLists.txt | 18 +---------------- .../128/zeal.png => 128-apps-zeal.png} | Bin .../16/zeal.png => 16-apps-zeal.png} | Bin .../24/zeal.png => 24-apps-zeal.png} | Bin .../32/zeal.png => 32-apps-zeal.png} | Bin .../64/zeal.png => 64-apps-zeal.png} | Bin assets/freedesktop/CMakeLists.txt | 19 ++++++++++++++++++ 7 files changed, 20 insertions(+), 17 deletions(-) rename assets/freedesktop/{appicons/128/zeal.png => 128-apps-zeal.png} (100%) rename assets/freedesktop/{appicons/16/zeal.png => 16-apps-zeal.png} (100%) rename assets/freedesktop/{appicons/24/zeal.png => 24-apps-zeal.png} (100%) rename assets/freedesktop/{appicons/32/zeal.png => 32-apps-zeal.png} (100%) rename assets/freedesktop/{appicons/64/zeal.png => 64-apps-zeal.png} (100%) create mode 100644 assets/freedesktop/CMakeLists.txt diff --git a/assets/CMakeLists.txt b/assets/CMakeLists.txt index 24790bbf6..f90c5258d 100644 --- a/assets/CMakeLists.txt +++ b/assets/CMakeLists.txt @@ -1,17 +1 @@ -if(UNIX AND NOT APPLE) - find_package(ECM REQUIRED NO_MODULE) - set(CMAKE_MODULE_PATH ${ECM_KDE_MODULE_DIR}) - include(KDEInstallDirs) - - foreach(_i 16 24 32 64 128) - install(FILES "freedesktop/appicons/${_i}/zeal.png" - DESTINATION "${KDE_INSTALL_ICONDIR}/hicolor/${_i}x${_i}/apps" - # TODO: Use `RENAME zeal.png` and get rid of subdirectories. - ) - endforeach() - - # TODO: Generate via zeal.desktop.in. - install(FILES "freedesktop/zeal.desktop" - DESTINATION ${KDE_INSTALL_APPDIR} - ) -endif() +add_subdirectory(freedesktop) diff --git a/assets/freedesktop/appicons/128/zeal.png b/assets/freedesktop/128-apps-zeal.png similarity index 100% rename from assets/freedesktop/appicons/128/zeal.png rename to assets/freedesktop/128-apps-zeal.png diff --git a/assets/freedesktop/appicons/16/zeal.png b/assets/freedesktop/16-apps-zeal.png similarity index 100% rename from assets/freedesktop/appicons/16/zeal.png rename to assets/freedesktop/16-apps-zeal.png diff --git a/assets/freedesktop/appicons/24/zeal.png b/assets/freedesktop/24-apps-zeal.png similarity index 100% rename from assets/freedesktop/appicons/24/zeal.png rename to assets/freedesktop/24-apps-zeal.png diff --git a/assets/freedesktop/appicons/32/zeal.png b/assets/freedesktop/32-apps-zeal.png similarity index 100% rename from assets/freedesktop/appicons/32/zeal.png rename to assets/freedesktop/32-apps-zeal.png diff --git a/assets/freedesktop/appicons/64/zeal.png b/assets/freedesktop/64-apps-zeal.png similarity index 100% rename from assets/freedesktop/appicons/64/zeal.png rename to assets/freedesktop/64-apps-zeal.png diff --git a/assets/freedesktop/CMakeLists.txt b/assets/freedesktop/CMakeLists.txt new file mode 100644 index 000000000..0e566ef4c --- /dev/null +++ b/assets/freedesktop/CMakeLists.txt @@ -0,0 +1,19 @@ +if(UNIX AND NOT APPLE) + find_package(ECM 1.0.0 REQUIRED NO_MODULE) + set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH}) + include(ECMInstallIcons) + include(KDEInstallDirs) + + ecm_install_icons(ICONS "16-apps-zeal.png" + "24-apps-zeal.png" + "32-apps-zeal.png" + "64-apps-zeal.png" + "128-apps-zeal.png" + DESTINATION ${KDE_INSTALL_ICONDIR} + ) + + # TODO: Generate via zeal.desktop.in. + install(FILES "zeal.desktop" + DESTINATION ${KDE_INSTALL_APPDIR} + ) +endif() From 9bf296af12a8389fa6e761c327294e07d7dc79f4 Mon Sep 17 00:00:00 2001 From: htower Date: Wed, 27 Jun 2018 09:32:57 +0800 Subject: [PATCH 09/25] ui: Set background color to white by default (fixes #892) (#951) --- src/libs/ui/mainwindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/ui/mainwindow.cpp b/src/libs/ui/mainwindow.cpp index 9c22e2505..cbbd80c0a 100644 --- a/src/libs/ui/mainwindow.cpp +++ b/src/libs/ui/mainwindow.cpp @@ -879,7 +879,7 @@ void MainWindow::applySettings() removeTrayIcon(); // Content - QByteArray ba; + QByteArray ba = QByteArrayLiteral("body { background-color: white; }"); if (m_settings->darkModeEnabled) { QScopedPointer file(new QFile(DarkModeCssUrl)); if (file->open(QIODevice::ReadOnly)) { From fe31f7fffb4979a3fdae3bd753e9deb2578665ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Piotrowski?= Date: Fri, 7 Sep 2018 03:15:41 +0000 Subject: [PATCH 10/25] assets: Add appstream metadata (#911) --- .gitignore | 3 + CMakeLists.txt | 1 + assets/freedesktop/CMakeLists.txt | 12 +++- .../org.zealdocs.Zeal.appdata.xml.in | 55 +++++++++++++++++++ ...zeal.desktop => org.zealdocs.Zeal.desktop} | 0 5 files changed, 69 insertions(+), 2 deletions(-) create mode 100644 assets/freedesktop/org.zealdocs.Zeal.appdata.xml.in rename assets/freedesktop/{zeal.desktop => org.zealdocs.Zeal.desktop} (100%) diff --git a/.gitignore b/.gitignore index 6057690ce..e1ece4a09 100644 --- a/.gitignore +++ b/.gitignore @@ -30,3 +30,6 @@ Makefile* # CMake CMakeLists.txt.user + +# Linux appdata +/assets/freedesktop/org.zealdocs.Zeal.appdata.xml diff --git a/CMakeLists.txt b/CMakeLists.txt index 6c60559a2..15216ea65 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,6 +2,7 @@ cmake_minimum_required(VERSION 3.5.1) set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake") project(Zeal VERSION 0.6.0) +set(RELEASE_DATE 2018-02-18) # Project information. if(APPLE) diff --git a/assets/freedesktop/CMakeLists.txt b/assets/freedesktop/CMakeLists.txt index 0e566ef4c..6e19e095e 100644 --- a/assets/freedesktop/CMakeLists.txt +++ b/assets/freedesktop/CMakeLists.txt @@ -12,8 +12,16 @@ if(UNIX AND NOT APPLE) DESTINATION ${KDE_INSTALL_ICONDIR} ) - # TODO: Generate via zeal.desktop.in. - install(FILES "zeal.desktop" + configure_file( + org.zealdocs.Zeal.appdata.xml.in + org.zealdocs.Zeal.appdata.xml + ) + + install(FILES ${CMAKE_BINARY_DIR}/assets/freedesktop/org.zealdocs.Zeal.appdata.xml + DESTINATION ${KDE_INSTALL_METAINFODIR} + ) + + install(FILES "org.zealdocs.Zeal.desktop" DESTINATION ${KDE_INSTALL_APPDIR} ) endif() diff --git a/assets/freedesktop/org.zealdocs.Zeal.appdata.xml.in b/assets/freedesktop/org.zealdocs.Zeal.appdata.xml.in new file mode 100644 index 000000000..bec3b7ab2 --- /dev/null +++ b/assets/freedesktop/org.zealdocs.Zeal.appdata.xml.in @@ -0,0 +1,55 @@ + + + org.zealdocs.Zeal.desktop + Zeal + CC0-1.0 + GPL-3.0-only + Documentation browser + +

Zeal is a simple offline documentation browser inspired by Dash.

+
+ https://zealdocs.org/ + https://github.com/zealdocs/zeal/issues + https://zealdocs.org/usage.html + + + https://i.imgur.com/qBkZduS.png + + + + zeal.desktop + + + + + zeal@zealdocs.org + + none + none + none + none + none + none + none + none + none + none + none + none + none + none + none + none + none + none + none + none + none + none + none + none + none + none + none + +
diff --git a/assets/freedesktop/zeal.desktop b/assets/freedesktop/org.zealdocs.Zeal.desktop similarity index 100% rename from assets/freedesktop/zeal.desktop rename to assets/freedesktop/org.zealdocs.Zeal.desktop From 7060a34d0622b99951cc9836d814a55dcb13a2d6 Mon Sep 17 00:00:00 2001 From: Oleg Shparber Date: Sat, 15 Sep 2018 19:41:11 -0400 Subject: [PATCH 11/25] registry: Ignore symbols without type (fixes #980) --- src/libs/registry/docset.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/libs/registry/docset.cpp b/src/libs/registry/docset.cpp index 01f510dc8..b3086dd10 100644 --- a/src/libs/registry/docset.cpp +++ b/src/libs/registry/docset.cpp @@ -408,6 +408,13 @@ void Docset::countSymbols() while (m_db->next()) { const QString symbolTypeStr = m_db->value(0).toString(); + + // A workaround for https://github.com/zealdocs/zeal/issues/980. + if (symbolTypeStr.isEmpty()) { + qWarning("Empty symbol type in the '%s' docset, skipping...", qPrintable(m_name)); + continue; + } + const QString symbolType = parseSymbolType(symbolTypeStr); m_symbolStrings.insertMulti(symbolType, symbolTypeStr); m_symbolCounts[symbolType] += m_db->value(1).toInt(); From 9d8d5d288e2cba6331173de14bf24709e8060766 Mon Sep 17 00:00:00 2001 From: Oleg Shparber Date: Sun, 16 Sep 2018 01:18:34 -0400 Subject: [PATCH 12/25] chore(github): add config for the Lock Threads app --- .github/lock.yml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .github/lock.yml diff --git a/.github/lock.yml b/.github/lock.yml new file mode 100644 index 000000000..db310ef30 --- /dev/null +++ b/.github/lock.yml @@ -0,0 +1,6 @@ +# Configuration for the Lock Threads app - https://probot.github.io/apps/lock/ + +daysUntilLock: 180 +exemptLabels: [] +setLockReason: false +only: issues From 52cda7f2ed7c0be45758d7761d87a85fcf3616c2 Mon Sep 17 00:00:00 2001 From: Oleg Shparber Date: Sun, 16 Sep 2018 01:21:13 -0400 Subject: [PATCH 13/25] chore(git): add .vscode to .gitignore --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index e1ece4a09..9a6106133 100644 --- a/.gitignore +++ b/.gitignore @@ -31,5 +31,8 @@ Makefile* # CMake CMakeLists.txt.user +# VS Code +/.vscode + # Linux appdata /assets/freedesktop/org.zealdocs.Zeal.appdata.xml From 83c4746009ed698ef213589d189c7a6711bc5f71 Mon Sep 17 00:00:00 2001 From: Oleg Shparber Date: Sun, 16 Sep 2018 09:55:50 -0400 Subject: [PATCH 14/25] chore(github): update closing comment --- .github/lock.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/lock.yml b/.github/lock.yml index db310ef30..0b2ab57ac 100644 --- a/.github/lock.yml +++ b/.github/lock.yml @@ -1,6 +1,9 @@ # Configuration for the Lock Threads app - https://probot.github.io/apps/lock/ daysUntilLock: 180 -exemptLabels: [] +lockComment: > + This thread has been automatically locked since there has not been + any recent activity after it was closed. Please open a new issue for + related requests. setLockReason: false only: issues From 2c8fb85471d633203d4054fed41f692f7524f9f1 Mon Sep 17 00:00:00 2001 From: Oleg Shparber Date: Sun, 16 Sep 2018 10:00:44 -0400 Subject: [PATCH 15/25] chore(github): update lock comment --- .github/lock.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/lock.yml b/.github/lock.yml index 0b2ab57ac..5d12f142d 100644 --- a/.github/lock.yml +++ b/.github/lock.yml @@ -4,6 +4,6 @@ daysUntilLock: 180 lockComment: > This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for - related requests. + a related request. setLockReason: false only: issues From 55d9947be5ddfb9c27c2297d3b101dcb003e3a8f Mon Sep 17 00:00:00 2001 From: Oleg Shparber Date: Mon, 24 Sep 2018 00:47:40 -0400 Subject: [PATCH 16/25] fix(registry): make query prefix check case insensitive (fixes #957) --- src/libs/registry/searchquery.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/libs/registry/searchquery.cpp b/src/libs/registry/searchquery.cpp index 1dedf5c01..43d4320b8 100644 --- a/src/libs/registry/searchquery.cpp +++ b/src/libs/registry/searchquery.cpp @@ -105,9 +105,11 @@ bool SearchQuery::hasKeyword(const QString &keyword) const bool SearchQuery::hasKeywords(const QStringList &keywords) const { for (const QString &keyword : keywords) { - if (m_keywords.contains(keyword)) + if (m_keywords.contains(keyword, Qt::CaseInsensitive)) { return true; + } } + return false; } From cb2073f866e2e6e00bfff17ec9a0f6ec0e5f708f Mon Sep 17 00:00:00 2001 From: Oleg Shparber Date: Mon, 24 Sep 2018 00:48:58 -0400 Subject: [PATCH 17/25] refactor(registry): remove unused method from SearchQuery --- src/libs/registry/searchquery.cpp | 11 ----------- src/libs/registry/searchquery.h | 3 +-- 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/src/libs/registry/searchquery.cpp b/src/libs/registry/searchquery.cpp index 43d4320b8..99cb4e4ea 100644 --- a/src/libs/registry/searchquery.cpp +++ b/src/libs/registry/searchquery.cpp @@ -91,17 +91,6 @@ bool SearchQuery::hasKeywords() const return !m_keywords.isEmpty(); } -bool SearchQuery::hasKeyword(const QString &keyword) const -{ - // Temporary workaround for #333 - // TODO: Remove once #167 is implemented - for (const QString &kw : m_keywords) { - if (keyword.startsWith(kw, Qt::CaseInsensitive)) - return true; - } - return false; -} - bool SearchQuery::hasKeywords(const QStringList &keywords) const { for (const QString &keyword : keywords) { diff --git a/src/libs/registry/searchquery.h b/src/libs/registry/searchquery.h index 27fe9f243..4553a4cef 100644 --- a/src/libs/registry/searchquery.h +++ b/src/libs/registry/searchquery.h @@ -66,8 +66,7 @@ class SearchQuery /// Returns true if there's a docset filter for the given query bool hasKeywords() const; - /// Returns true if the docset prefix match the ones given on query - bool hasKeyword(const QString &keyword) const; + /// Returns true if one the query contains one of the @c keywords. bool hasKeywords(const QStringList &keywords) const; /// Returns the docset filter raw size for the given query From 83a8bb75fe1c4eb90ba7fc078344fefaf4feb8a2 Mon Sep 17 00:00:00 2001 From: Oleg Shparber Date: Mon, 24 Sep 2018 01:36:39 -0400 Subject: [PATCH 18/25] feat(ui): add support for the Ctrl+L shortcut (fixes #401) --- src/libs/ui/mainwindow.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/libs/ui/mainwindow.cpp b/src/libs/ui/mainwindow.cpp index cbbd80c0a..14aa20313 100644 --- a/src/libs/ui/mainwindow.cpp +++ b/src/libs/ui/mainwindow.cpp @@ -157,12 +157,19 @@ MainWindow::MainWindow(Core::Application *app, QWidget *parent) : setupTabBar(); - QShortcut *focusSearch = new QShortcut(QStringLiteral("Ctrl+K"), this); - connect(focusSearch, &QShortcut::activated, + // Setup application wide shortcuts. + // Focus search bar. + QShortcut *shortcut = new QShortcut(QStringLiteral("Ctrl+K"), this); + connect(shortcut, &QShortcut::activated, ui->lineEdit, static_cast(&SearchEdit::setFocus)); - QShortcut *duplicate = new QShortcut(QStringLiteral("Ctrl+Alt+T"), this); - connect(duplicate, &QShortcut::activated, this, [this]() { duplicateTab(m_tabBar->currentIndex()); }); + shortcut = new QShortcut(QStringLiteral("Ctrl+L"), this); + connect(shortcut, &QShortcut::activated, + ui->lineEdit, static_cast(&SearchEdit::setFocus)); + + // Duplicate current tab. + shortcut = new QShortcut(QStringLiteral("Ctrl+Alt+T"), this); + connect(shortcut, &QShortcut::activated, this, [this]() { duplicateTab(m_tabBar->currentIndex()); }); restoreGeometry(m_settings->windowGeometry); ui->splitter->restoreState(m_settings->verticalSplitterGeometry); From 00f299345c19c5b1f37e6c3aff5c4c5820b6fcf0 Mon Sep 17 00:00:00 2001 From: Oleg Shparber Date: Thu, 27 Sep 2018 21:25:39 -0400 Subject: [PATCH 19/25] feat(ui): use relative path in portable build if possible (fixes #956) Applicable only to the subdirectories within path to the executable. --- src/libs/ui/settingsdialog.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/libs/ui/settingsdialog.cpp b/src/libs/ui/settingsdialog.cpp index c3d7a7522..d7eb73a65 100644 --- a/src/libs/ui/settingsdialog.cpp +++ b/src/libs/ui/settingsdialog.cpp @@ -143,12 +143,21 @@ void SettingsDialog::chooseCustomCssFile() void SettingsDialog::chooseDocsetStoragePath() { - const QString dir = QFileDialog::getExistingDirectory(this, tr("Open Directory"), - ui->docsetStorageEdit->text()); - if (dir.isEmpty()) + QString path = QFileDialog::getExistingDirectory(this, tr("Open Directory"), + ui->docsetStorageEdit->text()); + if (path.isEmpty()) { return; + } + +#ifdef PORTABLE_BUILD + // Use relative path if selected directory is under the application binary path. + if (path.startsWith(QCoreApplication::applicationDirPath() + QLatin1String("/"))) { + const QDir appDirPath(QCoreApplication::applicationDirPath()); + path = appDirPath.relativeFilePath(path); + } +#endif - ui->docsetStorageEdit->setText(QDir::toNativeSeparators(dir)); + ui->docsetStorageEdit->setText(QDir::toNativeSeparators(path)); } void SettingsDialog::loadSettings() From 0785dd4efa506a9cad3b043b9f81baea4429655c Mon Sep 17 00:00:00 2001 From: Oleg Shparber Date: Fri, 28 Sep 2018 00:45:16 -0400 Subject: [PATCH 20/25] fix(core): replace libarchive extraction with own logic (fixes #747) On Windows this allows to properly handle paths containing non-Latin characters. --- src/libs/core/extractor.cpp | 78 +++++++++++++++++++++++++++---------- src/libs/core/extractor.h | 7 ++-- 2 files changed, 61 insertions(+), 24 deletions(-) diff --git a/src/libs/core/extractor.cpp b/src/libs/core/extractor.cpp index 5e3440dbe..76f28898a 100644 --- a/src/libs/core/extractor.cpp +++ b/src/libs/core/extractor.cpp @@ -27,6 +27,8 @@ #include #include +#include + using namespace Zeal::Core; Extractor::Extractor(QObject *parent) : @@ -34,31 +36,28 @@ Extractor::Extractor(QObject *parent) : { } -void Extractor::extract(const QString &filePath, const QString &destination, const QString &root) +void Extractor::extract(const QString &sourceFile, const QString &destination, const QString &root) { ExtractInfo info = { - this, // extractor archive_read_new(), // archiveHandle - filePath, // filePath - QFileInfo(filePath).size(), // totalBytes + sourceFile, // filePath + QFileInfo(sourceFile).size(), // totalBytes 0 // extractedBytes }; archive_read_support_filter_all(info.archiveHandle); archive_read_support_format_all(info.archiveHandle); - int r = archive_read_open_filename(info.archiveHandle, qPrintable(filePath), 10240); + int r = archive_read_open_filename(info.archiveHandle, qPrintable(sourceFile), 10240); if (r) { - emit error(filePath, QString::fromLocal8Bit(archive_error_string(info.archiveHandle))); + emit error(sourceFile, QString::fromLocal8Bit(archive_error_string(info.archiveHandle))); return; } - archive_read_extract_set_progress_callback(info.archiveHandle, &Extractor::progressCallback, - &info); - QDir destinationDir(destination); - if (!root.isEmpty()) + if (!root.isEmpty()) { destinationDir = destinationDir.filePath(root); + } // TODO: Do not strip root directory in archive if it equals to 'root' archive_entry *entry; @@ -69,25 +68,62 @@ void Extractor::extract(const QString &filePath, const QString &destination, con // TODO: Remove once https://github.com/libarchive/libarchive/issues/587 is resolved. QString pathname = QString::fromWCharArray(archive_entry_pathname_w(entry)); #endif - if (!root.isEmpty()) + + if (!root.isEmpty()) { pathname.remove(0, pathname.indexOf(QLatin1String("/")) + 1); - archive_entry_set_pathname(entry, qPrintable(destinationDir.filePath(pathname))); - archive_read_extract(info.archiveHandle, entry, 0); + } + + const QString filePath = destinationDir.absoluteFilePath(pathname); + + const auto filetype = archive_entry_filetype(entry); + if (filetype == S_IFDIR) { + QDir().mkpath(QFileInfo(filePath).absolutePath()); + continue; + } else if (filetype != S_IFREG) { + qWarning("Unsupported filetype %d for %s!", filetype, qPrintable(pathname)); + continue; + } + + QScopedPointer file(new QFile(filePath)); + if (!file->open(QIODevice::WriteOnly)) { + qWarning("Cannot open file for writing: %s", qPrintable(pathname)); + continue; + } + + const void *buffer; + size_t size; + std::int64_t offset; + for (;;) { + int rc = archive_read_data_block(info.archiveHandle, &buffer, &size, &offset); + if (rc != ARCHIVE_OK) { + if (rc == ARCHIVE_EOF) { + break; + } + + qWarning("Cannot read from archive: %s", archive_error_string(info.archiveHandle)); + emit error(sourceFile, + QString::fromLocal8Bit(archive_error_string(info.archiveHandle))); + return; + } + + file->write(static_cast(buffer), size); + } + + emitProgress(info); } - emit completed(filePath); + emit completed(sourceFile); archive_read_free(info.archiveHandle); } -void Extractor::progressCallback(void *ptr) +void Extractor::emitProgress(ExtractInfo &info) { - ExtractInfo *info = static_cast(ptr); - - const qint64 extractedBytes = archive_filter_bytes(info->archiveHandle, -1); - if (extractedBytes == info->extractedBytes) + const qint64 extractedBytes = archive_filter_bytes(info.archiveHandle, -1); + if (extractedBytes == info.extractedBytes) { return; + } - info->extractedBytes = extractedBytes; + info.extractedBytes = extractedBytes; - emit info->extractor->progress(info->filePath, extractedBytes, info->totalBytes); + emit progress(info.filePath, extractedBytes, info.totalBytes); } diff --git a/src/libs/core/extractor.h b/src/libs/core/extractor.h index 13b9befcc..aee9b675e 100644 --- a/src/libs/core/extractor.h +++ b/src/libs/core/extractor.h @@ -37,7 +37,9 @@ class Extractor : public QObject explicit Extractor(QObject *parent = nullptr); public slots: - void extract(const QString &filePath, const QString &destination, const QString &root = QString()); + void extract(const QString &sourceFile, + const QString &destination, + const QString &root = QString()); signals: void error(const QString &filePath, const QString &message); @@ -46,14 +48,13 @@ public slots: private: struct ExtractInfo { - Extractor *extractor; archive *archiveHandle; QString filePath; qint64 totalBytes; qint64 extractedBytes; }; - static void progressCallback(void *ptr); + void emitProgress(ExtractInfo &info); }; } // namespace Core From 4626bc0dd479a6c1380bd0be2eac47f6fa7f3247 Mon Sep 17 00:00:00 2001 From: Oleg Shparber Date: Fri, 28 Sep 2018 00:52:24 -0400 Subject: [PATCH 21/25] fix(cmake): make copyright string static This is required to have reproducible builds. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 15216ea65..df82c175f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,7 +12,7 @@ else() endif() set(PROJECT_COMPANY_NAME "ZealDocs") -string(TIMESTAMP PROJECT_COPYRIGHT "© 2015-%Y Oleg Shparber" UTC) +set(PROJECT_COPYRIGHT "© 2015-2018 Oleg Shparber") set(PROJECT_DESCRIPTION "A simple documentation browser.") set(PROJECT_URL "https://zealdocs.org") From 3bdb8ee0fd5b9062cdcba1d38aad2e09d2757bdd Mon Sep 17 00:00:00 2001 From: Oleg Shparber Date: Fri, 28 Sep 2018 01:21:28 -0400 Subject: [PATCH 22/25] chore(release): 0.6.1 --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index df82c175f..5f343d0d9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,8 +1,8 @@ cmake_minimum_required(VERSION 3.5.1) set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake") -project(Zeal VERSION 0.6.0) -set(RELEASE_DATE 2018-02-18) +project(Zeal VERSION 0.6.1) +set(RELEASE_DATE 2018-09-28) # Project information. if(APPLE) From b7d528bd6ee52466062f8b3a72412b0d69f298fe Mon Sep 17 00:00:00 2001 From: Oleg Shparber Date: Sun, 7 Oct 2018 00:39:58 -0400 Subject: [PATCH 23/25] chore(github): add CODEOWNERS file --- .github/CODEOWNERS | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 .github/CODEOWNERS diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 000000000..f3d4437be --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,4 @@ +# This file allows automatic assignment of pull requests. +# See https://help.github.com/articles/about-codeowners/ + +* oleg@zealdocs.org From 8bfacd75c43e6f95dbdb28fddbd779a2c5028ade Mon Sep 17 00:00:00 2001 From: Karthik Nishanth Date: Sun, 7 Oct 2018 22:35:24 +0530 Subject: [PATCH 24/25] feat(registry,ui): respect per docset JavaScript enablement (fixes #999) (#1003) --- src/libs/registry/docset.cpp | 11 ++++++++++- src/libs/registry/docset.h | 3 +++ src/libs/ui/mainwindow.cpp | 5 +++-- src/libs/ui/widgets/webviewtab.cpp | 5 +++++ src/libs/ui/widgets/webviewtab.h | 1 + 5 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/libs/registry/docset.cpp b/src/libs/registry/docset.cpp index b3086dd10..c48221a7c 100644 --- a/src/libs/registry/docset.cpp +++ b/src/libs/registry/docset.cpp @@ -57,7 +57,7 @@ const char DashDocSetPluginKeyword[] = "DashDocSetPluginKeyword"; const char DashIndexFilePath[] = "dashIndexFilePath"; const char DocSetPlatformFamily[] = "DocSetPlatformFamily"; //const char IsDashDocset[] = "isDashDocset"; -//const char IsJavaScriptEnabled[] = "isJavaScriptEnabled"; +const char IsJavaScriptEnabled[] = "isJavaScriptEnabled"; } } @@ -163,6 +163,10 @@ Docset::Docset(const QString &path) : } } + if (plist.contains(InfoPlist::IsJavaScriptEnabled)) { + m_javaScriptEnabled = plist[InfoPlist::IsJavaScriptEnabled].toBool(); + } + m_keywords.removeDuplicates(); // Prefer index path provided by the docset over metadata. @@ -682,6 +686,11 @@ void Docset::setFuzzySearchEnabled(bool enabled) m_fuzzySearchEnabled = enabled; } +bool Docset::isJavaScriptEnabled() const +{ + return m_javaScriptEnabled; +} + /** * \brief Returns score based on a substring position in a string. * \param str Original string. diff --git a/src/libs/registry/docset.h b/src/libs/registry/docset.h index 1e25d88cb..d145fc808 100644 --- a/src/libs/registry/docset.h +++ b/src/libs/registry/docset.h @@ -79,6 +79,8 @@ class Docset bool isFuzzySearchEnabled() const; void setFuzzySearchEnabled(bool enabled); + bool isJavaScriptEnabled() const; + private: enum class Type { Invalid, @@ -113,6 +115,7 @@ class Docset mutable QMap> m_symbols; Util::SQLiteDatabase *m_db = nullptr; bool m_fuzzySearchEnabled = false; + bool m_javaScriptEnabled = false; }; } // namespace Registry diff --git a/src/libs/ui/mainwindow.cpp b/src/libs/ui/mainwindow.cpp index 14aa20313..3e5450703 100644 --- a/src/libs/ui/mainwindow.cpp +++ b/src/libs/ui/mainwindow.cpp @@ -624,9 +624,10 @@ void MainWindow::attachTab(TabState *tabState) m_tabBar->setTabIcon(m_tabBar->currentIndex(), docsetIcon(name)); Registry::Docset *docset = m_application->docsetRegistry()->docset(name); - if (docset) + if (docset) { tabState->tocModel->setResults(docset->relatedLinks(url)); - + tabState->widget->setJavaScriptEnabled(docset->isJavaScriptEnabled()); + } ui->actionBack->setEnabled(tabState->widget->canGoBack()); ui->actionForward->setEnabled(tabState->widget->canGoForward()); }); diff --git a/src/libs/ui/widgets/webviewtab.cpp b/src/libs/ui/widgets/webviewtab.cpp index 921760d5f..c03b17155 100644 --- a/src/libs/ui/widgets/webviewtab.cpp +++ b/src/libs/ui/widgets/webviewtab.cpp @@ -70,6 +70,11 @@ void WebViewTab::setZoomLevel(int level) m_webView->setZoomLevel(level); } +void WebViewTab::setJavaScriptEnabled(bool enabled) +{ + m_webView->page()->settings()->setAttribute(QWebSettings::JavascriptEnabled, enabled); +} + void WebViewTab::setWebBridgeObject(const QString &name, QObject *object) { connect(m_webView->page()->mainFrame(), &QWebFrame::javaScriptWindowObjectCleared, diff --git a/src/libs/ui/widgets/webviewtab.h b/src/libs/ui/widgets/webviewtab.h index 63d9dddf5..6e4c64c12 100644 --- a/src/libs/ui/widgets/webviewtab.h +++ b/src/libs/ui/widgets/webviewtab.h @@ -52,6 +52,7 @@ class WebViewTab : public QWidget int zoomLevel() const; void setZoomLevel(int level); + void setJavaScriptEnabled(bool enabled); void setWebBridgeObject(const QString &name, QObject *object); From eed785ceb53b55c5fa101c90cf5c1007fe0bcc2c Mon Sep 17 00:00:00 2001 From: Karthik Nishanth Date: Wed, 10 Oct 2018 08:36:41 +0530 Subject: [PATCH 25/25] chore(ui): remove a completed TODO comment (#1004) QAction::triggered has the prototype triggered(bool checked=false), and QAbstractButton::animateClick has the prototype animateClick(int msec=100). In this case, we don't set the QAction checkable boolean and its by default, false. An implicit conversion of false to int occurs here. Actual signal to slot connection is also confirmed using GammaRay --- src/libs/ui/widgets/searchtoolbar.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/libs/ui/widgets/searchtoolbar.cpp b/src/libs/ui/widgets/searchtoolbar.cpp index 17f5cbf61..965c12ea8 100644 --- a/src/libs/ui/widgets/searchtoolbar.cpp +++ b/src/libs/ui/widgets/searchtoolbar.cpp @@ -60,8 +60,6 @@ SearchToolBar::SearchToolBar(QWebView *webView, QWidget *parent) // A workaround for QAbstractButton lacking support for multiple shortcuts. QAction *action = new QAction(m_findPreviousButton); action->setShortcuts(QKeySequence::FindPrevious); - // TODO: Investigate why direct connection does not work. - //connect(action, &QAction::triggered, m_findPreviousButton, &QToolButton::animateClick); connect(action, &QAction::triggered, this, [this]() { m_findPreviousButton->animateClick(); }); addAction(action);