diff options
author | Jan Holthuis <jan.holthuis@ruhr-uni-bochum.de> | 2021-04-05 14:05:29 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-05 14:05:29 +0200 |
commit | 40db30b6f17bef97d853c01c831fb61ec9bd358e (patch) | |
tree | db99871ee6a491794cb3c8885e53141464cc6c6e /src | |
parent | 390eeb6335be4408e2427232f2531ed2431f745c (diff) | |
parent | 237b98f958f1a8c30d1ed3974a9e2ec8e154f2b8 (diff) |
Merge pull request #3754 from ronso0/keyboard-shortcut-pdf
include keyboard shortcuts PDF, disable debian doc compression
Diffstat (limited to 'src')
-rw-r--r-- | src/config.h.in | 1 | ||||
-rw-r--r-- | src/defs_urls.h | 1 | ||||
-rw-r--r-- | src/widget/wmainmenubar.cpp | 85 |
3 files changed, 48 insertions, 39 deletions
diff --git a/src/config.h.in b/src/config.h.in new file mode 100644 index 0000000000..fdddc2985b --- /dev/null +++ b/src/config.h.in @@ -0,0 +1 @@ +#cmakedefine MIXXX_INSTALL_DOCDIR_RELATIVE_TO_DATADIR "@MIXXX_INSTALL_DOCDIR_RELATIVE_TO_DATADIR@" diff --git a/src/defs_urls.h b/src/defs_urls.h index e2419f55a2..b6af77fb8d 100644 --- a/src/defs_urls.h +++ b/src/defs_urls.h @@ -49,3 +49,4 @@ #define MIXXX_MANUAL_VINYL_TROUBLESHOOTING_URL \ MIXXX_MANUAL_URL "/chapters/vinyl_control.html#troubleshooting" #define MIXXX_MANUAL_FILENAME "Mixxx-Manual.pdf" +#define MIXXX_KBD_SHORTCUTS_FILENAME "Mixxx-Keyboard-Shortcuts.pdf" diff --git a/src/widget/wmainmenubar.cpp b/src/widget/wmainmenubar.cpp index 343fdbb0e0..3824441ef8 100644 --- a/src/widget/wmainmenubar.cpp +++ b/src/widget/wmainmenubar.cpp @@ -3,6 +3,7 @@ #include <QDesktopServices> #include <QUrl> +#include "config.h" #include "control/controlproxy.h" #include "defs_urls.h" #include "mixer/playermanager.h" @@ -51,7 +52,22 @@ QString showPreferencesKeyBinding() { #endif } - +QUrl documentationUrl( + const QString& resourcePath, const QString& fileName, const QString& docUrl) { + QDir resourceDir(resourcePath); + // Documentation PDFs are included on Windows and Linux only, + // so on macOS this always returns the web URL. +#if defined(MIXXX_INSTALL_DOCDIR_RELATIVE_TO_DATADIR) + if (!resourceDir.exists(fileName)) { + resourceDir.cd(MIXXX_INSTALL_DOCDIR_RELATIVE_TO_DATADIR); + } +#endif + if (resourceDir.exists(fileName)) { + return QUrl::fromLocalFile(resourceDir.absoluteFilePath(fileName)); + } else { + return QUrl(docUrl); + } +} } // namespace WMainMenuBar::WMainMenuBar(QWidget* pParent, UserSettingsPointer pConfig, @@ -529,6 +545,7 @@ void WMainMenuBar::initialize() { externalLinkSuffix = QChar(' ') + QChar(0x2197); // north-east arrow #endif + // Community Support QString supportTitle = tr("&Community Support") + externalLinkSuffix; QString supportText = tr("Get help with Mixxx"); auto* pHelpSupport = new QAction(supportTitle, this); @@ -538,53 +555,43 @@ void WMainMenuBar::initialize() { this, [this] { slotVisitUrl(MIXXX_SUPPORT_URL); }); pHelpMenu->addAction(pHelpSupport); - QDir resourceDir(m_pConfig->getResourcePath()); - // Default to the mixxx.org hosted version of the manual. - QUrl qManualUrl(MIXXX_MANUAL_URL); - QString manualSuffix; -#if defined(__APPLE__) - // FIXME: We don't include the PDF manual in the bundle on OSX. - // Default to the web-hosted version. -#elif defined(__WINDOWS__) - // On Windows, the manual PDF sits in the same folder as the 'skins' folder. - if (resourceDir.exists(MIXXX_MANUAL_FILENAME)) { - qManualUrl = QUrl::fromLocalFile( - resourceDir.absoluteFilePath(MIXXX_MANUAL_FILENAME)); - } else { - manualSuffix = externalLinkSuffix; - } -#elif defined(__LINUX__) - // On GNU/Linux, the manual is installed to e.g. /usr/share/doc/mixxx/ - if (resourceDir.cd("../doc/mixxx") && resourceDir.exists(MIXXX_MANUAL_FILENAME)) { - qManualUrl = QUrl::fromLocalFile( - resourceDir.absoluteFilePath(MIXXX_MANUAL_FILENAME)); - } else { - manualSuffix = externalLinkSuffix; - } -#else - // No idea, default to the mixxx.org hosted version. - manualSuffix = externalLinkSuffix; -#endif + // User Manual + QUrl manualUrl = documentationUrl(m_pConfig->getResourcePath(), + MIXXX_MANUAL_FILENAME, + MIXXX_MANUAL_URL); + QString manualSuffix = manualUrl.isLocalFile() ? QString() : externalLinkSuffix; QString manualTitle = tr("&User Manual") + manualSuffix; QString manualText = tr("Read the Mixxx user manual."); auto* pHelpManual = new QAction(manualTitle, this); pHelpManual->setStatusTip(manualText); pHelpManual->setWhatsThis(buildWhatsThis(manualTitle, manualText)); - connect(pHelpManual, &QAction::triggered, - this, [this, qManualUrl] { slotVisitUrl(qManualUrl.toString()); }); + connect(pHelpManual, &QAction::triggered, this, [this, manualUrl] { + slotVisitUrl(manualUrl.toString()); + }); pHelpMenu->addAction(pHelpManual); - QString shortcutsTitle = tr("&Keyboard Shortcuts") + externalLinkSuffix; - QString shortcutsText = tr("Speed up your workflow with keyboard shortcuts."); - auto* pHelpShortcuts = new QAction(shortcutsTitle, this); - pHelpShortcuts->setStatusTip(shortcutsText); - pHelpShortcuts->setWhatsThis(buildWhatsThis(shortcutsTitle, shortcutsText)); - connect(pHelpShortcuts, &QAction::triggered, this, [this] { - slotVisitUrl(MIXXX_MANUAL_SHORTCUTS_URL); - }); - pHelpMenu->addAction(pHelpShortcuts); + // Keyboard Shortcuts + QUrl keyboardShortcutsUrl = documentationUrl(m_pConfig->getResourcePath(), + MIXXX_KBD_SHORTCUTS_FILENAME, + MIXXX_MANUAL_SHORTCUTS_URL); + QString keyboardShortcutsSuffix = + keyboardShortcutsUrl.isLocalFile() ? QString() : externalLinkSuffix; + QString shortcutsTitle = tr("&Keyboard Shortcuts") + keyboardShortcutsSuffix; + QString shortcutsText = tr("Speed up your workflow with keyboard shortcuts."); + auto* pHelpKbdShortcuts = new QAction(shortcutsTitle, this); + pHelpKbdShortcuts->setStatusTip(shortcutsText); + pHelpKbdShortcuts->setWhatsThis(buildWhatsThis(shortcutsTitle, shortcutsText)); + connect(pHelpKbdShortcuts, + &QAction::triggered, + this, + [this, keyboardShortcutsUrl] { + slotVisitUrl(keyboardShortcutsUrl.toString()); + }); + pHelpMenu->addAction(pHelpKbdShortcuts); + + // Translate This Application QString translateTitle = tr("&Translate This Application") + externalLinkSuffix; QString translateText = tr("Help translate this application into your language."); auto* pHelpTranslation = new QAction(translateTitle, this); |