From 618a350e0dad24fe8f5c3ebf89cbb9fa400b689c Mon Sep 17 00:00:00 2001 From: Gary Wang Date: Mon, 23 Sep 2024 19:48:26 +0800 Subject: [PATCH] chore: add about dialog to make it easier to know if taglib and/or libchardet are used. --- CMakeLists.txt | 10 ++-------- mainwindow.cpp | 33 +++++++++++++++++++++++++++++++++ mainwindow.h | 1 + mainwindow.ui | 11 +++++++++++ 4 files changed, 47 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8e17ebd..cb0cb53 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -68,19 +68,13 @@ if (WIN32) endif () if (NOT TagLib_FOUND) - message (WARNING "TagLib not found!") - target_compile_definitions(${EXE_NAME} PRIVATE - NO_TAGLIB=1 - ) + target_compile_definitions(${EXE_NAME} PRIVATE NO_TAGLIB=1) else () target_link_libraries(${EXE_NAME} PRIVATE PkgConfig::TagLib) endif () if (NOT uchardet_FOUND) - message (WARNING "uchardet not found!") - target_compile_definitions(${EXE_NAME} PRIVATE - NO_UCHARDET=1 - ) + target_compile_definitions(${EXE_NAME} PRIVATE NO_UCHARDET=1) else () target_link_libraries (${EXE_NAME} PRIVATE uchardet::libuchardet) endif () diff --git a/mainwindow.cpp b/mainwindow.cpp index 942ee5b..40b3239 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -29,6 +29,8 @@ #include #include #include +#include +#include constexpr QSize miniSize(490, 160); constexpr QSize fullSize(490, 420); @@ -50,6 +52,9 @@ MainWindow::MainWindow(QWidget *parent) m_mediaPlayer->setLoops(QMediaPlayer::Infinite); ui->playlistView->setModel(m_playlistManager->model()); + ui->actionHelp->setShortcut(QKeySequence::HelpContents); + addAction(ui->actionHelp); + setWindowFlags(Qt::FramelessWindowHint | Qt::WindowSystemMenuHint | Qt::WindowMinimizeButtonHint); setAttribute(Qt::WA_TranslucentBackground, true); @@ -599,3 +604,31 @@ void MainWindow::on_lrcBtn_clicked() } } + +void MainWindow::on_actionHelp_triggered() +{ + QMessageBox infoBox(this); + infoBox.setIcon(QMessageBox::Information); + infoBox.setWindowTitle(tr("About")); + infoBox.setStandardButtons(QMessageBox::Ok); + infoBox.setText( + tr("Pineapple Music") % + "\n\n" % + tr("Based on the following free software libraries:") % + "\n\n" % + QStringLiteral("- [Qt](https://www.qt.io/) %1\n").arg(QT_VERSION_STR) % +#ifndef NO_TAGLIB + QStringLiteral("- [TagLib](https://github.com/taglib/taglib)\n") % +#endif // NO_TAGLIB +#ifndef NO_UCHARDET + QStringLiteral("- [uchardet](https://www.freedesktop.org/wiki/Software/uchardet/)\n") % +#endif // NO_TAGLIB + "\n" + "[Source Code](https://github.com/BLumia/pineapple-music)\n" + "\n" + "Copyright © 2024 [BLumia](https://github.com/BLumia/)" + ); + infoBox.setTextFormat(Qt::MarkdownText); + infoBox.exec(); +} + diff --git a/mainwindow.h b/mainwindow.h index b2f3804..a6a770b 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -75,6 +75,7 @@ private slots: void on_playListBtn_clicked(); void on_playlistView_activated(const QModelIndex &index); void on_lrcBtn_clicked(); + void on_actionHelp_triggered(); signals: void playbackModeChanged(enum PlaybackMode mode); diff --git a/mainwindow.ui b/mainwindow.ui index ca8070c..159905a 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -657,6 +657,17 @@ QListView { + + + help + + + F1 + + + QAction::MenuRole::NoRole + +