Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add manual help viewer based on Qt Help Framework #3047

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
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
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -894,6 +894,8 @@ add_library(mixxx-lib STATIC EXCLUDE_FROM_ALL
src/waveform/widgets/softwarewaveformwidget.cpp
src/waveform/widgets/waveformwidgetabstract.cpp
src/widget/controlwidgetconnection.cpp
src/widget/helpbrowser.cpp
src/widget/helpviewer.cpp
src/widget/hexspinbox.cpp
src/widget/paintable.cpp
src/widget/wanalysislibrarytableview.cpp
Expand Down Expand Up @@ -1957,6 +1959,7 @@ find_package(Qt5
Concurrent
Core
Gui
Help
Network
OpenGL
Qml
Expand All @@ -1971,6 +1974,7 @@ target_link_libraries(mixxx-lib PUBLIC
Qt5::Concurrent
Qt5::Core
Qt5::Gui
Qt5::Help
Qt5::Network
Qt5::OpenGL
Qt5::Qml
Expand Down
26 changes: 21 additions & 5 deletions src/controllers/dlgprefcontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,22 @@ DlgPrefController::DlgPrefController(
QDesktopServices::openUrl(QUrl::fromLocalFile(path));
});

// Open mapping support links
connect(m_ui.labelLoadedMappingSupportLinks,
&QLabel::linkActivated,
[this](const QString& link) {
const QUrl url(link);
qWarning() << url.scheme() << url.path();
VERIFY_OR_DEBUG_ASSERT(url.isValid()) {
return;
}
if (url.scheme() == "manual") {
emit showHelp(url.path());
return;
}
QDesktopServices::openUrl(url);
});

// Input mappings
connect(m_ui.btnAddInputMapping,
&QAbstractButton::clicked,
Expand Down Expand Up @@ -319,12 +335,12 @@ QString DlgPrefController::mappingSupportLinks(
wikiLink);
}

QString manualLink = pMapping->manualLink();
if (!manualLink.isEmpty()) {
QString helpDocument = pMapping->manualDocument();
if (!helpDocument.isEmpty()) {
linkList << coloredLinkString(
m_pLinkColor,
"Mixxx Manual",
manualLink);
QStringLiteral("manual://") + helpDocument);
}

// There is always at least one support link.
Expand Down Expand Up @@ -530,8 +546,8 @@ void DlgPrefController::slotApply() {
setDirty(false);
}

QUrl DlgPrefController::helpUrl() const {
return QUrl(MIXXX_MANUAL_CONTROLLERS_URL);
QString DlgPrefController::helpDocument() const {
return QString(MIXXX_MANUAL_CONTROLLERS_PATH);
}

QString DlgPrefController::mappingPathFromIndex(int index) const {
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/dlgprefcontroller.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class DlgPrefController : public DlgPreferencePage {
UserSettingsPointer pConfig);
virtual ~DlgPrefController();

QUrl helpUrl() const override;
QString helpDocument() const override;

public slots:
/// Called when the preference dialog (not this page) is shown to the user.
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/dlgprefcontrollerdlg.ui
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@
<string notr="true">(forum link for mapping goes here)</string>
</property>
<property name="openExternalLinks">
<bool>true</bool>
<bool>false</bool>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse</set>
Expand Down
4 changes: 2 additions & 2 deletions src/controllers/dlgprefcontrollers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ void DlgPrefControllers::slotResetToDefaults() {
}
}

QUrl DlgPrefControllers::helpUrl() const {
return QUrl(MIXXX_MANUAL_CONTROLLERS_URL);
QString DlgPrefControllers::helpDocument() const {
return QString(MIXXX_MANUAL_CONTROLLERS_PATH);
}

bool DlgPrefControllers::handleTreeItemClick(QTreeWidgetItem* clickedItem) {
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/dlgprefcontrollers.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class DlgPrefControllers : public DlgPreferencePage, public Ui::DlgPrefControlle
virtual ~DlgPrefControllers();

bool handleTreeItemClick(QTreeWidgetItem* clickedItem);
QUrl helpUrl() const override;
QString helpDocument() const override;

public slots:
/// Called when the preference dialog (not this page) is shown to the user.
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/legacycontrollermapping.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ class LegacyControllerMapping {
return m_manualPage;
}

QString manualLink() const {
QString manualDocument() const {
QString page = manualPage();
if (page.isEmpty()) {
return {};
Expand Down
41 changes: 20 additions & 21 deletions src/defs_urls.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,34 +32,33 @@
#define MIXXX_MANUAL_URL \
"https://manual.mixxx.org/" TO_VERSION_STR( \
MIXXX_VERSION_MAJOR, MIXXX_VERSION_MINOR)
#define MIXXX_MANUAL_SHORTCUTS_URL \
MIXXX_MANUAL_URL "/chapters/controlling_mixxx.html#using-a-keyboard"
#define MIXXX_MANUAL_INDEX_PATH "/index.html"
#define MIXXX_MANUAL_COMMANDLINEOPTIONS_URL \
MIXXX_MANUAL_URL "/chapters/appendix.html#command-line-options"
#define MIXXX_MANUAL_CONTROLLERS_URL \
MIXXX_MANUAL_URL "/chapters/controlling_mixxx.html#using-midi-hid-controllers"
#define MIXXX_MANUAL_SHORTCUTS_PATH \
"/chapters/controlling_mixxx.html#using-a-keyboard"
#define MIXXX_MANUAL_CONTROLLERS_PATH \
"/chapters/controlling_mixxx.html#using-midi-hid-controllers"
#define MIXXX_MANUAL_CONTROLLERMANUAL_PREFIX \
MIXXX_MANUAL_URL "/hardware/controllers/"
"/hardware/controllers/"
#define MIXXX_MANUAL_CONTROLLERMANUAL_SUFFIX ".html"
#define MIXXX_MANUAL_CONTROLS_URL \
MIXXX_MANUAL_URL "/chapters/advanced_topics.html#mixxx-controls"
#define MIXXX_MANUAL_SOUND_URL \
MIXXX_MANUAL_URL "/chapters/preferences.html#sound-hardware"
#define MIXXX_MANUAL_LIBRARY_URL \
MIXXX_MANUAL_URL "/chapters/preferences.html#library"
#define MIXXX_MANUAL_SOUND_PATH \
"/chapters/preferences.html#sound-hardware"
#define MIXXX_MANUAL_LIBRARY_PATH \
"/chapters/preferences.html#library"
#define MIXXX_MANUAL_CUE_MODES_URL \
MIXXX_MANUAL_URL "/chapters/user_interface.html#using-cue-modes"
#define MIXXX_MANUAL_BEATS_URL \
MIXXX_MANUAL_URL "/chapters/preferences.html#beat-detection"
#define MIXXX_MANUAL_KEY_URL \
MIXXX_MANUAL_URL "/chapters/preferences.html#key-detection"
#define MIXXX_MANUAL_EQ_URL \
MIXXX_MANUAL_URL "/chapters/preferences.html#equalizers"
#define MIXXX_MANUAL_BROADCAST_URL \
MIXXX_MANUAL_URL "/chapters/livebroadcasting.html#configuring-mixxx"
#define MIXXX_MANUAL_VINYL_URL \
MIXXX_MANUAL_URL "/chapters/vinyl_control.html#configuring-vinyl-control"
#define MIXXX_MANUAL_BEATS_PATH \
"/chapters/preferences.html#beat-detection"
#define MIXXX_MANUAL_KEY_PATH \
"/chapters/preferences.html#key-detection"
#define MIXXX_MANUAL_EQ_PATH \
"/chapters/preferences.html#equalizers"
#define MIXXX_MANUAL_BROADCAST_PATH \
"/chapters/livebroadcasting.html#configuring-mixxx"
#define MIXXX_MANUAL_VINYL_PATH \
"/chapters/vinyl_control.html#configuring-vinyl-control"
#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"
23 changes: 21 additions & 2 deletions src/mixxx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
#include "waveform/sharedglcontext.h"
#include "waveform/visualsmanager.h"
#include "waveform/waveformwidgetfactory.h"
#include "widget/helpviewer.h"
#include "widget/wmainmenubar.h"

#ifdef __VINYLCONTROL__
Expand Down Expand Up @@ -107,6 +108,8 @@ MixxxMainWindow::MixxxMainWindow(
DEBUG_ASSERT(pCoreServices);
m_pCoreServices->initializeSettings();
m_pCoreServices->initializeKeyboard();

m_pHelpViewer = new mixxx::HelpViewer(pCoreServices->getSettings());
// These depend on the settings
createMenuBar();
m_pMenuBar->hide();
Expand Down Expand Up @@ -225,6 +228,10 @@ MixxxMainWindow::MixxxMainWindow(
m_pCoreServices->getLibrary());
m_pPrefDlg->setWindowIcon(QIcon(":/images/mixxx_icon.svg"));
m_pPrefDlg->setHidden(true);
connect(m_pPrefDlg,
&DlgPreferences::showHelp,
this,
&MixxxMainWindow::slotHelpShowManual);

// Connect signals to the menubar. Should be done before emit newSkinLoaded.
connectMenuBar();
Expand Down Expand Up @@ -623,8 +630,10 @@ void MixxxMainWindow::slotUpdateWindowTitle(TrackPointer pTrack) {
void MixxxMainWindow::createMenuBar() {
ScopedTimer t("MixxxMainWindow::createMenuBar");
DEBUG_ASSERT(m_pCoreServices->getKeyboardConfig());
m_pMenuBar = make_parented<WMainMenuBar>(
this, m_pCoreServices->getSettings(), m_pCoreServices->getKeyboardConfig().get());
m_pMenuBar = make_parented<WMainMenuBar>(this,
m_pCoreServices->getSettings(),
m_pCoreServices->getKeyboardConfig().get(),
m_pHelpViewer->hasLocalHelp());
if (m_pCentralWidget) {
m_pMenuBar->setStyleSheet(m_pCentralWidget->styleSheet());
}
Expand Down Expand Up @@ -686,6 +695,12 @@ void MixxxMainWindow::connectMenuBar() {
Qt::UniqueConnection);

// Help
connect(m_pMenuBar,
&WMainMenuBar::showManual,
this,
&MixxxMainWindow::slotHelpShowManual,
Qt::UniqueConnection);

connect(m_pMenuBar,
&WMainMenuBar::showAbout,
this,
Expand Down Expand Up @@ -973,6 +988,10 @@ void MixxxMainWindow::slotChangedPlayingDeck(int deck) {
}
}

void MixxxMainWindow::slotHelpShowManual(const QString& documentPath) {
m_pHelpViewer->open(documentPath);
}

void MixxxMainWindow::slotHelpAbout() {
DlgAbout* about = new DlgAbout(this);
about->show();
Expand Down
8 changes: 6 additions & 2 deletions src/mixxx.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,12 @@ class VinylControlManager;
class VisualsManager;
class WMainMenuBar;

#ifdef __ENGINEPRIME__
namespace mixxx {
#ifdef __ENGINEPRIME__
class LibraryExporter;
} // namespace mixxx
#endif
class HelpViewer;
} // namespace mixxx

/// This Class is the base class for Mixxx.
/// It sets up the main window providing a menubar.
Expand Down Expand Up @@ -72,6 +73,8 @@ class MixxxMainWindow : public QMainWindow {
void slotFileLoadSongPlayer(int deck);
/// show the preferences dialog
void slotOptionsPreferences();
/// show the manual
void slotHelpShowManual(const QString& documentPath);
/// show the about dialog
void slotHelpAbout();
// show keywheel
Expand Down Expand Up @@ -132,6 +135,7 @@ class MixxxMainWindow : public QMainWindow {

parented_ptr<WMainMenuBar> m_pMenuBar;

mixxx::HelpViewer* m_pHelpViewer;
DlgDeveloperTools* m_pDeveloperToolsDlg;

DlgPreferences* m_pPrefDlg;
Expand Down
4 changes: 2 additions & 2 deletions src/preferences/dialog/dlgprefbeats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ DlgPrefBeats::DlgPrefBeats(QWidget* parent, UserSettingsPointer pConfig)
DlgPrefBeats::~DlgPrefBeats() {
}

QUrl DlgPrefBeats::helpUrl() const {
return QUrl(MIXXX_MANUAL_BEATS_URL);
QString DlgPrefBeats::helpDocument() const {
return QString(MIXXX_MANUAL_BEATS_PATH);
}

void DlgPrefBeats::loadSettings() {
Expand Down
2 changes: 1 addition & 1 deletion src/preferences/dialog/dlgprefbeats.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class DlgPrefBeats : public DlgPreferencePage, public Ui::DlgBeatsDlg {
DlgPrefBeats(QWidget *parent, UserSettingsPointer _config);
virtual ~DlgPrefBeats();

QUrl helpUrl() const override;
QString helpDocument() const override;

public slots:
// Apply changes to widget
Expand Down
4 changes: 2 additions & 2 deletions src/preferences/dialog/dlgprefbroadcast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,8 @@ void DlgPrefBroadcast::slotUpdate() {
btnDisconnectAll->setEnabled(enabled);
}

QUrl DlgPrefBroadcast::helpUrl() const {
return QUrl(MIXXX_MANUAL_BROADCAST_URL);
QString DlgPrefBroadcast::helpDocument() const {
return QString(MIXXX_MANUAL_BROADCAST_PATH);
}

void DlgPrefBroadcast::applyModel() {
Expand Down
2 changes: 1 addition & 1 deletion src/preferences/dialog/dlgprefbroadcast.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class DlgPrefBroadcast : public DlgPreferencePage, public Ui::DlgPrefBroadcastDl
BroadcastSettingsPointer pBroadcastSettings);
virtual ~DlgPrefBroadcast();

QUrl helpUrl() const override;
QString helpDocument() const override;

public slots:
/** Apply changes to widget */
Expand Down
4 changes: 2 additions & 2 deletions src/preferences/dialog/dlgprefeq.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,8 @@ void DlgPrefEQ::slotSingleEqChecked(int checked) {
applySelections();
}

QUrl DlgPrefEQ::helpUrl() const {
return QUrl(MIXXX_MANUAL_EQ_URL);
QString DlgPrefEQ::helpDocument() const {
return QString(MIXXX_MANUAL_EQ_PATH);
}

void DlgPrefEQ::loadSettings() {
Expand Down
2 changes: 1 addition & 1 deletion src/preferences/dialog/dlgprefeq.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class DlgPrefEQ : public DlgPreferencePage, public Ui::DlgPrefEQDlg {
UserSettingsPointer _config);
virtual ~DlgPrefEQ();

QUrl helpUrl() const override;
QString helpDocument() const override;

QString getEQEffectGroupForDeck(int deck) const;
QString getQuickEffectGroupForDeck(int deck) const;
Expand Down
4 changes: 2 additions & 2 deletions src/preferences/dialog/dlgpreferencepage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ DlgPreferencePage::DlgPreferencePage(QWidget* pParent)
DlgPreferencePage::~DlgPreferencePage() {
}

QUrl DlgPreferencePage::helpUrl() const {
return QUrl();
QString DlgPreferencePage::helpDocument() const {
return QString();
}
9 changes: 6 additions & 3 deletions src/preferences/dialog/dlgpreferencepage.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,16 @@ class DlgPreferencePage : public QWidget {
DlgPreferencePage(QWidget* pParent);
virtual ~DlgPreferencePage();

/// Returns the help URL for the current page.
/// Returns the help document for the current page.
/// Subclasses can provide a path to the appropriate manual page by
/// overriding this. The default implementation returns an invalid QUrl.
virtual QUrl helpUrl() const;
/// overriding this. The default implementation returns an empty QString.
virtual QString helpDocument() const;

QColor m_pLinkColor;

signals:
void showHelp(const QString& documentPath);

public slots:
/// Called when the preference dialog is shown to the user (not necessarily
/// when this PreferencePage is shown to the user). At this point, the
Expand Down
8 changes: 4 additions & 4 deletions src/preferences/dialog/dlgpreferences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -401,9 +401,7 @@ void DlgPreferences::slotButtonPressed(QAbstractButton* pButton) {
break;
case QDialogButtonBox::HelpRole:
if (pCurrentPage) {
QUrl helpUrl = pCurrentPage->helpUrl();
DEBUG_ASSERT(helpUrl.isValid());
QDesktopServices::openUrl(helpUrl);
emit showHelp(pCurrentPage->helpDocument());
}
break;
default:
Expand Down Expand Up @@ -431,6 +429,8 @@ void DlgPreferences::addPageWidget(PreferencesPage page,
page.pDlg,
&DlgPreferencePage::slotResetToDefaults);

connect(page.pDlg, &DlgPreferencePage::showHelp, this, &DlgPreferences::showHelp);

// Add a new scroll area to the stacked pages widget containing the page
QScrollArea* sa = new QScrollArea(pagesWidget);
sa->setWidgetResizable(true);
Expand Down Expand Up @@ -475,7 +475,7 @@ void DlgPreferences::switchToPage(DlgPreferencePage* pWidget) {
return;
}

if (pWidget->helpUrl().isValid()) {
if (!pWidget->helpDocument().isEmpty()) {
pButton->show();
} else {
pButton->hide();
Expand Down
1 change: 1 addition & 0 deletions src/preferences/dialog/dlgpreferences.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ class DlgPreferences : public QDialog, public Ui::DlgPreferencesDlg {
signals:
void closeDlg();
void showDlg();
void showHelp(const QString& documentPath);

// Emitted just after the user clicks Apply or OK.
void applyPreferences();
Expand Down
Loading