Skip to content

Commit

Permalink
Merge branch 'feature/ISSUE2-IdleDuringFileScan'
Browse files Browse the repository at this point in the history
  • Loading branch information
gvansickle committed Dec 18, 2017
2 parents 4cc3053 + 0687842 commit 948e0bf
Show file tree
Hide file tree
Showing 16 changed files with 541 additions and 191 deletions.
76 changes: 53 additions & 23 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,13 @@ cmake_minimum_required(VERSION 3.9 FATAL_ERROR)
cmake_policy(SET CMP0053 NEW) # Use new var ref/esc seq eval
cmake_policy(SET CMP0010 NEW) # Silence warning on CMP0010.

include(cmake/GetVersionInfo.cmake)

# Basic information about project
# Note that here is where CMake determines compilers and loads any toolchain.cmake file.
# (per https://cgold.readthedocs.io/en/latest/tutorials/project.html)
project(AwesomeMediaLibraryManager
VERSION 0.0.1.0
VERSION ${GVI_VERSION_TAG_QUAD}
DESCRIPTION "The Awesome Media Library Manager"
LANGUAGES C CXX)

Expand All @@ -46,6 +48,10 @@ list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)

message(STATUS "CMake-time PATH: $ENV{PATH}")

# Prevent an in-root-of-src-tree build.
if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
message(FATAL_ERROR "Prevented in-root-of-tree build. Please create a build directory outside of the source code root directory and call cmake from there. Thank you.")
endif()

# Include some basic cmake functions.
include(GNUInstallDirs)
Expand All @@ -54,6 +60,8 @@ include(PrintTargetProperties)
include(helperfunctions)
# Include some basic Qt5-related cmake functions
include(QtCommon)
set(CMAKE_INSTALL_UCRT_LIBRARIES TRUE) # Without this, Release builds won't include the MSVC C runtime.
include(InstallRequiredSystemLibraries)

dir_summary()

Expand All @@ -66,7 +74,7 @@ set(PROJECT_AUTHOR_EMAIL "grvs@users.sourceforge.net")
set(FULL_COPYRIGHT_STRING "Copyright (c) 2017 ${PROJECT_AUTHOR} <${PROJECT_AUTHOR_EMAIL}>")

message("******************************************************************")
message("* ${PROJECT_NAME} version ${PROJECT_VERSION} (${CMAKE_BUILD_TYPE})")
message("* ${PROJECT_NAME} version ${PROJECT_VERSION}-${GVI_VERSION_COMMITS}-g${GVI_VERSION_HASH}${GVI_VERSION_DIRTY_POSTFIX} (${CMAKE_BUILD_TYPE})")
message("* ${FULL_COPYRIGHT_STRING}")
message("******************************************************************")

Expand All @@ -81,21 +89,21 @@ message("* Version: ${PROJECT_VERSION}")
message("* Version (alt): ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}.${PROJECT_VERSION_TWEAK}")
message("* Discovered tools:")
message("* CMAKE_MAKE_PROGRAM: ${CMAKE_MAKE_PROGRAM}")
message("* GIT_EXECUTABLE: ${GIT_EXECUTABLE}")

print_compilers_and_params()

# Generate the version info file.
configure_file(${PROJECT_SOURCE_DIR}/resources/VersionInfo.cpp.in
${PROJECT_BINARY_DIR}/resources/VersionInfo.cpp)

# Be nice to visual studio
set_property(GLOBAL PROPERTY USE_FOLDERS ON)

# Be nice and export compile commands by default, this is handy for clang-tidy
# and for other tools.
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

# Prevent an in-root-of-src-tree build.
if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
message(FATAL_ERROR "Prevented in-tree build. Please create a build directory outside of the source code and call cmake from there. Thank you.")
endif()

# Set default install location to dist folder in build dir
# we do not want to install to /usr by default
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
Expand Down Expand Up @@ -141,7 +149,7 @@ fix_project_version()
# Resource directory FBO QtCommon/add_project_meta().
set(RESOURCE_FOLDER resources)
# The basename of the application's icon.
set(ICON_NAME "AppIcon")
set(ICON_NAME "AMLMAppIcon")
# For the "CompanyName" field in the rc file.
set(RC_COMPANYNAME "${PROJECT_AUTHOR}")
set(RC_LEGALCOPYRIGHT "${FULL_COPYRIGHT_STRING}")
Expand All @@ -159,6 +167,7 @@ set(AMLM_TAGLIB_TARGET "")

# Use the bundled version of libcue due to this issue: https://github.com/lipnitsk/libcue/commit/e60b7b01a40009c7c71c5e154a328881a6e9ae46
set(USE_BUNDLED_LIBCUE TRUE)
set(USE_BUNDLED_QXTGLOBALSHORTCUT FALSE)

if(NOT WIN32)
find_package(PkgConfig REQUIRED)
Expand Down Expand Up @@ -229,6 +238,23 @@ else()
endif()
endif()

if(FALSE)
if(USE_BUNDLED_QXTGLOBALSHORTCUT)
message(FATAL "BUNDLED QXTGLOBALSHORTCUT NOT IMPLEMENTED")
### @todo Looks like this is the most maintained fork: https://github.com/hluk/qxtglobalshortcut
else()
find_package(PkgConfig REQUIRED)

pkg_check_modules(QXTGLOBALSHORTCUT_LIB REQUIRED qxtglobalshortcut
IMPORTED_TARGET)
if(QXTGLOBALSHORTCUT_LIB_FOUND)
set(AMLM_QXTGLOBALSHORTCUT_LIB_TARGET "PkgConfig::QXTGLOBALSHORTCUT_LIB")
# Doesn't work, this is an interface library: print_target_properties(${AMLM_QXTGLOBALSHORTCUT_LIB_TARGET})
endif()
endif()
endif()

# Main program header files.
set(HEADER_FILES
gui/CollectionDockWidget.h
gui/Experimental.h
Expand Down Expand Up @@ -276,7 +302,7 @@ set(HEADER_FILES
logic/CueSheetParser.h
gui/settings/SettingsDialog.h
gui/settings/SettingsDialogSideWidget.h
)
resources/VersionInfo.h)

# Source file list.
set(SOURCE_FILES
Expand Down Expand Up @@ -323,18 +349,19 @@ set(SOURCE_FILES
gui/settings/SettingsDialog.cpp
gui/settings/SettingsDialogPageBase.cpp gui/settings/SettingsDialogPageBase.h
gui/settings/SDPageAppearance.cpp gui/settings/SDPageAppearance.h
gui/settings/SettingsDialogSideWidget.cpp gui/settings/SDPageLibrary.cpp gui/settings/SDPageLibrary.h gui/MDINowPlayingView.cpp gui/MDINowPlayingView.h)
gui/settings/SettingsDialogSideWidget.cpp
gui/settings/SDPageLibrary.cpp
gui/settings/SDPageLibrary.h
gui/MDINowPlayingView.cpp
gui/MDINowPlayingView.h
)

# This function sets up the variable META_FILES_TO_INCLUDE to the extra files
# needed for a windows build (essentially just the configured .rc file).
add_project_meta(META_FILES_TO_INCLUDE)
cmake_print_variables(META_FILES_TO_INCLUDE)

# Qt5 Resource (qrc) files.
#set(QRC_FILES
# resources/oxygenicons.qrc
# resources/TangoIcons.qrc
# resources/AppIcon.qrc)
# RESOURCE_FILES is a list of the generated output *.cpp file names.
#qt5_add_resources(RESOURCE_FILES
# resources/oxygenicons.qrc
Expand All @@ -356,10 +383,11 @@ print_target_properties(icons_oxygen)
###
### The main executable.
###
### @note Including HEADER_FILES in here so they get check for existence.
### @note Including HEADER_FILES in here so they get checked for existence.
###
add_executable(${PROJECT_NAME} ${OS_BUNDLE} # Expands to WIN32 or MACOS_BUNDLE depending on OS
${SOURCE_FILES} ${HEADER_FILES} ${META_FILES_TO_INCLUDE} ${RESOURCE_FILES} ${QRC_FILES}
${SOURCE_FILES} ${HEADER_FILES} ${META_FILES_TO_INCLUDE} ${RESOURCE_FILES}
${PROJECT_BINARY_DIR}/resources/VersionInfo.cpp
)
# Only the Qt stuff needs AUTOMOC.
### This doesn't work: set_property(FILES ${SOURCE_FILES} ${HEADER_FILES} PROPERTY AUTOMOC ON)
Expand All @@ -368,7 +396,7 @@ set_target_properties(${PROJECT_NAME}
# The libs.
target_link_libraries(${PROJECT_NAME}
Qt5::Core Qt5::Gui Qt5::Widgets Qt5::Multimedia Qt5::Concurrent
${AMLM_TAGLIB_TARGET} ${AMLM_LIBCUE_TARGET})
${AMLM_TAGLIB_TARGET} ${AMLM_LIBCUE_TARGET} ${AMLM_QXTGLOBALSHORTCUT_LIB_TARGET})
add_dependencies(${PROJECT_NAME} icon_rccs)
# Add sanitizers.
add_sanitizers(${PROJECT_NAME})
Expand Down Expand Up @@ -417,10 +445,13 @@ endif()
set(CPACK_GENERATOR NSIS)

# Generic.
# https://cmake.org/cmake/help/v3.10/module/CPack.html
set(CPACK_PACKAGE_NAME "${PROJECT_NAME}")
set(CPACK_PACKAGE_VERSION_MAJOR "0")
set(CPACK_PACKAGE_VERSION_MINOR "0")
set(CPACK_PACKAGE_VERSION_PATCH "1")
set(CPACK_PACKAGE_VERSION ${GVI_GIT_DESCRIBE_OUTPUT}-${CMAKE_BUILD_TYPE})
# Doesn't look like we need to set these separately.
#set(CPACK_PACKAGE_VERSION_MAJOR ???)
#set(CPACK_PACKAGE_VERSION_MINOR ???)
#set(CPACK_PACKAGE_VERSION_PATCH ???)

set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${PROJECT_NAME} - ${PROJECT_DESCRIPTION}")
set(CPACK_PACKAGE_CONTACT "${PROJECT_AUTHOR} <${PROJECT_AUTHOR_EMAIL}>")
Expand All @@ -430,12 +461,9 @@ set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE)

set(CPACK_PACKAGE_EXECUTABLES "${PROJECT_NAME};${PROJECT_NAME}")

#set(CPACK_PACKAGE_VERSION "1.0.0")

# Packaging: NSIS
set(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL ON)
set(CPACK_NSIS_EXECUTABLES_DIRECTORY .)
set(CPACK_NSIS_MENU_LINKS "https://github.com/gvansickle/AwesomeMediaLibraryManager" "AwesomeMediaLibraryManager at GitHub")

set(CPACK_NSIS_PACKAGE_ARCHITECTURE "64")
set(CPACK_NSIS_INSTALL_ROOT "$PROGRAMFILES64")
Expand All @@ -444,6 +472,8 @@ set(CPACK_NSIS_PACKAGE_NAME ${CPACK_PACKAGE_NAME})
# Add a "Finished, Run the app?" page to the installer.
set(CPACK_NSIS_MUI_FINISHPAGE_RUN ${PROJECT_NAME})

set(CPACK_NSIS_MENU_LINKS "https://github.com/gvansickle/AwesomeMediaLibraryManager" "AwesomeMediaLibraryManager at GitHub")

include(CPack)
if(WIN32)
include(CpackNSIS)
Expand Down
53 changes: 53 additions & 0 deletions cmake/GetVersionInfo.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#
# Copyright 2017 Gary R. Van Sickle (grvs@users.sourceforge.net).
#
# This file is part of AwesomeMediaLibraryManager.
#
# AwesomeMediaLibraryManager is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# AwesomeMediaLibraryManager is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with AwesomeMediaLibraryManager. If not, see <http://www.gnu.org/licenses/>.
#

# Returns the following repo version info:
# - GVI_GIT_DESCRIBE_OUTPUT: The raw output from "git describe"
# - GVI_VERSION_TAG_QUAD: Four-segment version number from the last git tag, e.g. "1.2.3.4"
# - GVI_VERSION_HASH: The git SHA-1 hash returned by "git describe".
# - GVI_VERSION_COMMITS: The number of post-tag commits.
# - GVI_VERSION_DIRTY_POSTFIX: "-dirty" or "" depending on if the workspace is dirty or not.
# - GVI_VERSION_IS_DIRTY: TRUE or FALSE, depending on what git describe returns for dirty.
find_package(Git)
if(GIT_FOUND)
message(STATUS "Git found: ${GIT_EXECUTABLE}")
message(STATUS "Git version: ${GIT_VERSION_STRING}")
execute_process(
COMMAND "${GIT_EXECUTABLE}" describe --always --long --dirty
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
OUTPUT_VARIABLE GVI_GIT_DESCRIBE_OUTPUT
OUTPUT_STRIP_TRAILING_WHITESPACE
)
else()
message(STATUS "Git not found")
set(GVI_GIT_DESCRIBE_OUTPUT "0.0.0.0-0-g0000000-dirty")
endif()

string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+" GVI_VERSION_TAG_QUAD ${GVI_GIT_DESCRIBE_OUTPUT})
string(REGEX REPLACE "-([0-9]+)-g([0-9a-fA-F]+)" "\\1\\2" DUMMY ${GVI_GIT_DESCRIBE_OUTPUT})
set(GVI_VERSION_COMMITS ${CMAKE_MATCH_1})
set(GVI_VERSION_HASH ${CMAKE_MATCH_2})
if(${GVI_GIT_DESCRIBE_OUTPUT} MATCHES "-dirty")
set(GVI_VERSION_IS_DIRTY TRUE)
set(GVI_VERSION_DIRTY_POSTFIX "-dirty")
else()
set(GVI_VERSION_IS_DIRTY FALSE)
set(GVI_VERSION_DIRTY_POSTFIX "")
endif()
message(STATUS "git describe reports: ${GVI_GIT_DESCRIBE_OUTPUT} (${GVI_VERSION_TAG_QUAD}/${GVI_VERSION_COMMITS}/${GVI_VERSION_HASH}/${GVI_VERSION_DIRTY_POSTFIX})")
22 changes: 19 additions & 3 deletions cmake/windows_metafile.rc.in
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
#include "winver.h"

/*
* Handle misc info coming in from the build environment.
*/
#cmakedefine01 GVI_VERSION_IS_DIRTY

// Per https://msdn.microsoft.com/en-us/library/windows/desktop/aa381058(v=vs.85).aspx:
// "VS_FF_PRIVATEBUILD File was not built using standard release procedures. If this value is given, the StringFileInfo block must contain a PrivateBuild string."
#if GVI_VERSION_IS_DIRTY == 1
#define AMLM_FILEFLAGS VS_FF_PRIVATEBUILD
#else
#define AMLM_FILEFLAGS 0x00L
#endif

IDI_ICON1 ICON DISCARDABLE "@ICON_FILE@"

VS_VERSION_INFO VERSIONINFO
FILEVERSION @PROJECT_VERSION_MAJOR@,@PROJECT_VERSION_MINOR@,@PROJECT_VERSION_PATCH@,@PROJECT_VERSION_TWEAK@
PRODUCTVERSION @PROJECT_VERSION_MAJOR@,@PROJECT_VERSION_MINOR@,@PROJECT_VERSION_PATCH@,@PROJECT_VERSION_TWEAK@
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
FILEFLAGS 0x0L
FILEFLAGS AMLM_FILEFLAGS
FILEOS VOS_NT_WINDOWS32 /* Same for x86-64 */
FILETYPE VFT_APP
FILESUBTYPE VFT2_UNKNOWN
Expand All @@ -17,12 +30,15 @@ BEGIN
BEGIN
VALUE "CompanyName", "@RC_COMPANYNAME@"
VALUE "FileDescription", "@PROJECT_DESCRIPTION@"
VALUE "FileVersion", "@PROJECT_VERSION@"
VALUE "FileVersion", "@GVI_GIT_DESCRIBE_OUTPUT@"
VALUE "LegalCopyright", "@RC_LEGALCOPYRIGHT@"
VALUE "InternalName", "@PROJECT_NAME@"
VALUE "OriginalFilename", "@PROJECT_NAME@.exe"
VALUE "ProductName", "@PROJECT_NAME@"
VALUE "ProductVersion", "@PROJECT_VERSION@"
VALUE "ProductVersion", "@GVI_GIT_DESCRIBE_OUTPUT@"
#if GVI_VERSION_IS_DIRTY
VALUE "PrivateBuild" "File was built from a dirty working copy"
#endif
END
END
BLOCK "VarFileInfo"
Expand Down
46 changes: 26 additions & 20 deletions gui/AboutBox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,35 +22,41 @@
#include <QApplication>
#include <QHBoxLayout>
#include <QLabel>

#include <QMessageBox>

#include <utils/StringHelpers.h>
#include <resources/VersionInfo.h>


AboutBox::AboutBox(QWidget *parent, const Qt::WindowFlags &flags) : QDialog(parent, flags)
{
m_title_str = tr("About %1").arg(qApp->applicationDisplayName());

QString app_name_str = qApp->applicationDisplayName();
QString app_full_version_info = toqstr(VersionInfo::get_full_version_info_string());

m_text_str = tr("<body>"
"<h1>%1</h1>"
"<h2>The Awesome Media Library Manager</h2>"
"<h3>Because the world needs a Media Library Manager which is Awesome.</h3>"
"<h4>Copyright (c) 2017 Gary R. Van Sickle</h4>"
"<hr>"
"<p><a href=\"https://github.com/gvansickle/AwesomeMediaLibraryManager\">AwesomeMediaLibraryManager</a> is free software: you can redistribute it and/or modify"
" it under the terms of the GNU General Public License as published by"
" the Free Software Foundation, either version 3 of the License, or"
" (at your option) any later version."
"</p>"
"<p>AwesomeMediaLibraryManager is distributed in the hope that it will be useful,"
" but WITHOUT ANY WARRANTY; without even the implied warranty of"
" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the"
" GNU General Public License for more details."
"</p>"
"<p>You should have received a copy of the GNU General Public License"
" along with AwesomeMediaLibraryManager. If not, see <a href=\"http://www.gnu.org/licenses/\">http://www.gnu.org/licenses/</a>.</p>"
"</body>").arg(app_name_str);
m_text_str = tr(
"<body>"
"<h1>%1</h1>"
"<h2>The Awesome Media Library Manager</h2>"
"<h3>Because the world needs a Media Library Manager which is Awesome.</h3>"
"<h4>Version %2</h4>"
"<h4>Copyright (c) 2017 Gary R. Van Sickle</h4>"
"<hr>"
"<p><a href=\"https://github.com/gvansickle/AwesomeMediaLibraryManager\">AwesomeMediaLibraryManager</a> is free software: you can redistribute it and/or modify"
" it under the terms of the GNU General Public License as published by"
" the Free Software Foundation, either version 3 of the License, or"
" (at your option) any later version."
"</p>"
"<p>AwesomeMediaLibraryManager is distributed in the hope that it will be useful,"
" but WITHOUT ANY WARRANTY; without even the implied warranty of"
" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the"
" GNU General Public License for more details."
"</p>"
"<p>You should have received a copy of the GNU General Public License"
" along with AwesomeMediaLibraryManager. If not, see <a href=\"http://www.gnu.org/licenses/\">http://www.gnu.org/licenses/</a>.</p>"
"<hr>"
"</body>").arg(app_name_str).arg(app_full_version_info);
}

int AboutBox::exec()
Expand Down
6 changes: 2 additions & 4 deletions gui/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -401,9 +401,7 @@ void MainWindow::connectPlayerAndControls(MP2 *player, PlayerControls *controls)
connect(controls, &PlayerControls::changeRepeat, player, &MP2::repeat);
connect(controls, &PlayerControls::changeMuting, player, &MP2::setMuted);
connect(controls, &PlayerControls::changeVolume, player, &MP2::setVolume);

/// @todo This violates the encapsulation of both controls and player.
controls->m_shuffleButton->setDefaultAction(player->m_shuffleAct);
connect(controls, &PlayerControls::changeShuffle, player, &MP2::setShuffleMode);

// MP2 -> PlayerControls signals.
connect(player, &MP2::stateChanged, controls, &PlayerControls::setState);
Expand All @@ -413,7 +411,7 @@ void MainWindow::connectPlayerAndControls(MP2 *player, PlayerControls *controls)
connect(player, &MP2::positionChanged2, controls, &PlayerControls::onPositionChanged);

// Final setup.
// Set volume control to othe current player volume.
// Set volume control to the current player volume.
controls->setVolume(player->volume());
}

Expand Down
Loading

0 comments on commit 948e0bf

Please sign in to comment.