Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1134,6 +1134,7 @@ elseif (UNIX)
set(MIXXX_INSTALL_LICENSEDIR "${CMAKE_INSTALL_DOCDIR}")
endif()


if(WIN32)
target_compile_definitions(mixxx-lib PRIVATE __WINDOWS__)

Expand Down Expand Up @@ -1342,8 +1343,8 @@ install(
install(
FILES
"${CMAKE_CURRENT_SOURCE_DIR}/README"
"${CMAKE_CURRENT_SOURCE_DIR}/Mixxx-Manual.pdf"
"${CMAKE_CURRENT_SOURCE_DIR}/Mixxx-Keyboard-Shortcuts.pdf"
"${CMAKE_CURRENT_SOURCE_DIR}/res/Mixxx-Manual.pdf"
"${CMAKE_CURRENT_SOURCE_DIR}/res/Mixxx-Keyboard-Shortcuts.pdf"
DESTINATION
"${MIXXX_INSTALL_DOCDIR}"
)
Expand Down Expand Up @@ -2639,6 +2640,10 @@ if(WAVPACK)
target_link_libraries(mixxx-lib PUBLIC WavPack::wavpack)
endif()

# Configure file with build options
file(RELATIVE_PATH MIXXX_INSTALL_DOCDIR_RELATIVE_TO_DATADIR "${CMAKE_INSTALL_PREFIX}/${MIXXX_INSTALL_DATADIR}" "${CMAKE_INSTALL_PREFIX}/${MIXXX_INSTALL_DOCDIR}")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/src/config.h.in" "${CMAKE_CURRENT_BINARY_DIR}/src/config.h" @ONLY)

# Packaging
set(CPACK_PACKAGE_VENDOR "Mixxx Project")
set(CPACK_PACKAGE_CONTACT "RJ Skerry-Ryan <rryan@mixxx.org>")
Expand Down
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions src/config.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#cmakedefine MIXXX_INSTALL_DOCDIR_RELATIVE_TO_DATADIR "@MIXXX_INSTALL_DOCDIR_RELATIVE_TO_DATADIR@"
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

interesting, I wasn't aware that we can use cmake vars in the actual project code.
somehow I considered those two entirely separate 'things'

Copy link
Copy Markdown
Author

@Holzhaus Holzhaus Mar 30, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can use them via configure_file or target_compile_definitions. The #cmakedefine is like a regular #define except that it maps to undef if the variable is not set.

91 changes: 33 additions & 58 deletions src/widget/wmainmenubar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <QDesktopServices>
#include <QUrl>

#include "config.h"
#include "control/controlproxy.h"
#include "defs_urls.h"
#include "mixer/playermanager.h"
Expand Down Expand Up @@ -51,7 +52,21 @@ QString showPreferencesKeyBinding() {
#endif
}

QUrl documentationFileUrl(const QString& resourcePath, const QString& fileName) {
QDir resourceDir(resourcePath);
#if !defined(__APPLE__)
#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));
}
#endif

return QUrl();
}
} // namespace

WMainMenuBar::WMainMenuBar(QWidget* pParent, UserSettingsPointer pConfig,
Expand Down Expand Up @@ -521,7 +536,6 @@ void WMainMenuBar::initialize() {
// HELP MENU
QMenu* pHelpMenu = new QMenu(tr("&Help"), this);

QDir resourceDir(m_pConfig->getResourcePath());
QString externalLinkSuffix;
#ifndef __APPLE__
// According to Apple's Human Interface Guidelines devs are encouraged
Expand All @@ -541,80 +555,41 @@ void WMainMenuBar::initialize() {
pHelpMenu->addAction(pHelpSupport);

// User Manual
// Default to the mixxx.org hosted version of the manual.
QUrl qManualUrl(MIXXX_MANUAL_URL);
QDir manualDir(resourceDir);
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 (manualDir.exists(MIXXX_MANUAL_FILENAME)) {
qManualUrl = QUrl::fromLocalFile(
manualDir.absoluteFilePath(MIXXX_MANUAL_FILENAME));
} else {
manualSuffix = externalLinkSuffix;
QUrl manualUrl = documentationFileUrl(m_pConfig->getResourcePath(), MIXXX_MANUAL_FILENAME);
if (!manualUrl.isValid()) {
manualUrl = QUrl(MIXXX_MANUAL_URL);
}
#elif defined(__LINUX__)
// On GNU/Linux, the manual is installed to e.g. /usr/share/doc/mixxx/
if (manualDir.cd("../doc/mixxx") && manualDir.exists(MIXXX_MANUAL_FILENAME)) {
qManualUrl = QUrl::fromLocalFile(
manualDir.absoluteFilePath(MIXXX_MANUAL_FILENAME));
} else {
manualSuffix = externalLinkSuffix;
}
#else
// No idea, default to the mixxx.org hosted version.
manualSuffix = externalLinkSuffix;
#endif
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);

// Keyboard Shortcuts
QUrl qKeyboardShortcutsUrl(MIXXX_MANUAL_SHORTCUTS_URL);
QDir kbdShortcutsDir(resourceDir);
QString kbdShortcutsSuffix;
#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 shortcut PDF sits in the same folder as the 'skins' folder.
if (kbdShortcutsDir.exists(MIXXX_KBD_SHORTCUTS_FILENAME)) {
qKeyboardShortcutsUrl = QUrl::fromLocalFile(
kbdShortcutsDir.absoluteFilePath(MIXXX_KBD_SHORTCUTS_FILENAME));
} else {
kbdShortcutsSuffix = externalLinkSuffix;
QUrl keyboardShortcutsUrl = documentationFileUrl(
m_pConfig->getResourcePath(), MIXXX_KBD_SHORTCUTS_FILENAME);
if (!keyboardShortcutsUrl.isValid()) {
keyboardShortcutsUrl = QUrl(MIXXX_MANUAL_SHORTCUTS_URL);
}
#elif defined(__LINUX__)
// On GNU/Linux, the shortcut is installed to e.g. /usr/share/doc/mixxx/
if (kbdShortcutsDir.cd("../doc/mixxx") &&
kbdShortcutsDir.exists(MIXXX_KBD_SHORTCUTS_FILENAME)) {
qKeyboardShortcutsUrl = QUrl::fromLocalFile(
kbdShortcutsDir.absoluteFilePath(MIXXX_KBD_SHORTCUTS_FILENAME));
} else {
kbdShortcutsSuffix = externalLinkSuffix;
}
#else
// No idea, default to the mixxx.org hosted version.
kbdShortcutsSuffix = externalLinkSuffix;
#endif
QString shortcutsTitle = tr("&Keyboard Shortcuts") + kbdShortcutsSuffix;
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, qKeyboardShortcutsUrl] {
slotVisitUrl(qKeyboardShortcutsUrl.toString());
[this, keyboardShortcutsUrl] {
slotVisitUrl(keyboardShortcutsUrl.toString());
});
pHelpMenu->addAction(pHelpKbdShortcuts);

Expand Down