From 365198c18d13c8e5fb392903129d56f3cb8bb3b0 Mon Sep 17 00:00:00 2001 From: Colin McEwan Date: Fri, 18 Mar 2022 15:26:45 -0700 Subject: [PATCH 1/2] Small changes for Qt 5.9.9 --- src/gui/src/HydrogenApp.cpp | 4 ++-- src/gui/src/MainForm.cpp | 4 ++-- src/gui/src/Widgets/LCDSpinBox.cpp | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/gui/src/HydrogenApp.cpp b/src/gui/src/HydrogenApp.cpp index d2c1ec7d88..c74292f5ea 100644 --- a/src/gui/src/HydrogenApp.cpp +++ b/src/gui/src/HydrogenApp.cpp @@ -385,7 +385,7 @@ bool HydrogenApp::openSong( QString sFilename) { // In case the user did open a hidden file, the baseName() // will be an empty string. QString sBaseName( fileInfo.completeBaseName() ); - if ( sBaseName.front() == "." ) { + if ( sBaseName.startsWith( "." ) ) { sBaseName.remove( 0, 1 ); } @@ -468,7 +468,7 @@ bool HydrogenApp::recoverEmptySong() { // In case the user did open a hidden file, the baseName() // will be an empty string. QString sBaseName( fileInfo.completeBaseName() ); - if ( sBaseName.front() == "." ) { + if ( sBaseName.startsWith( "." ) ) { sBaseName.remove( 0, 1 ); } diff --git a/src/gui/src/MainForm.cpp b/src/gui/src/MainForm.cpp index c17d5c2fd6..185296e464 100644 --- a/src/gui/src/MainForm.cpp +++ b/src/gui/src/MainForm.cpp @@ -613,7 +613,7 @@ void MainForm::action_file_new() // autosave file in order to start fresh. QFileInfo fileInfo( Filesystem::empty_song_path() ); QString sBaseName( fileInfo.completeBaseName() ); - if ( sBaseName.front() == "." ) { + if ( sBaseName.startsWith( "." ) ) { sBaseName.remove( 0, 1 ); } QFileInfo autoSaveFile( QString( "%1/.%2.autosave.h2song" ) @@ -2050,7 +2050,7 @@ QString MainForm::getAutoSaveFilename() // In case the user did open a hidden file, the baseName() // will be an empty string. QString sBaseName( fileInfo.completeBaseName() ); - if ( sBaseName.front() == "." ) { + if ( sBaseName.startsWith( "." ) ) { sBaseName.remove( 0, 1 ); } diff --git a/src/gui/src/Widgets/LCDSpinBox.cpp b/src/gui/src/Widgets/LCDSpinBox.cpp index ad8ec4636c..b504cb3e9e 100644 --- a/src/gui/src/Widgets/LCDSpinBox.cpp +++ b/src/gui/src/Widgets/LCDSpinBox.cpp @@ -154,7 +154,7 @@ void LCDSpinBox::keyPressEvent( QKeyEvent *ev ) { double LCDSpinBox::nextValueInPatternSizeDenominator( bool bUp, bool bAccelerated ) { // Determine the next value. - std::vector vChoices{ 1, 2, 3, 4, 6, 8, 12, 16, 24, 32, 48, 64, 96, 192 }; + std::vector< int > vChoices{ 1, 2, 3, 4, 6, 8, 12, 16, 24, 32, 48, 64, 96, 192 }; bool bContained; double fNextValue; @@ -213,8 +213,8 @@ QString LCDSpinBox::textFromValue( double fValue ) const { QValidator::State LCDSpinBox::validate( QString &text, int &pos ) const { if ( m_kind == Kind::PatternSizeDenominator ) { - std::vector vChoices{ "1", "2", "3", "4", "6", "8", "12", "16", "24", "32", "48", "64", "96", "192" }; - std::vector vCandidates1{ "1", "2", "3", "4", "6", "9" }; + std::vector< QString > vChoices{ "1", "2", "3", "4", "6", "8", "12", "16", "24", "32", "48", "64", "96", "192" }; + std::vector< QString > vCandidates1{ "1", "2", "3", "4", "6", "9" }; QString sCandidate2( "19" ); bool bContained = false; bool bIsCandidate = false; From af69c29bc06fca9033b5aa5c9ca9bb68e4731d66 Mon Sep 17 00:00:00 2001 From: Colin McEwan Date: Sat, 19 Mar 2022 22:49:56 +0000 Subject: [PATCH 2/2] Use PlistBuddy to merge Info.plist entries --- macos/CFBundleDocumentTypes.json | 21 ------------- macos/ExtraInfo.plist | 53 ++++++++++++++++++++++++++++++++ src/gui/CMakeLists.txt | 20 ++---------- 3 files changed, 56 insertions(+), 38 deletions(-) delete mode 100644 macos/CFBundleDocumentTypes.json create mode 100644 macos/ExtraInfo.plist diff --git a/macos/CFBundleDocumentTypes.json b/macos/CFBundleDocumentTypes.json deleted file mode 100644 index a5727ddaf6..0000000000 --- a/macos/CFBundleDocumentTypes.json +++ /dev/null @@ -1,21 +0,0 @@ -[ - { - "CFBundleTypeName": "Hydrogen song", - "CFBundleTypeExtensions": ["h2song"], - "CFBundleTypeRole": "Editor" - }, - { - "CFBundleTypeName": "Hydrogen drumkit", - "CFBundleTypeExtensions": ["h2drumkit"], - "CFBundleTypeRole": "Editor" - }, - { - "CFBundleTypeName": "Hydrogen playlist", - "CFBundleTypeExtensions": ["h2playlist"], - "CFBundleTypeRole": "Editor" - }, - { - "CFBundleTypeName": "Hydrogen pattern", - "CFBundleTypeExtensions": ["h2pattern"] - } -] diff --git a/macos/ExtraInfo.plist b/macos/ExtraInfo.plist new file mode 100644 index 0000000000..37eee8a6d6 --- /dev/null +++ b/macos/ExtraInfo.plist @@ -0,0 +1,53 @@ + + + + + CFBundleDocumentTypes + + + CFBundleTypeExtensions + + h2song + + CFBundleTypeName + Hydrogen song + CFBundleTypeRole + Editor + + + CFBundleTypeExtensions + + h2drumkit + + CFBundleTypeName + Hydrogen drumkit + CFBundleTypeRole + Editor + + + CFBundleTypeExtensions + + h2playlist + + CFBundleTypeName + Hydrogen playlist + CFBundleTypeRole + Editor + + + CFBundleTypeExtensions + + h2pattern + + CFBundleTypeName + Hydrogen pattern + + + + NSHighResolutionCapable + + + NSPrincipalClass + NSApplication + + diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index ae513e19e7..b48b1c6ca0 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -52,24 +52,10 @@ if(APPLE) add_custom_command( TARGET hydrogen POST_BUILD - COMMAND plutil -replace NSPrincipalClass -string NSApplication hydrogen.app/Contents/Info.plist + COMMAND /usr/libexec/PlistBuddy + -c "merge ${CMAKE_SOURCE_DIR}/macos/ExtraInfo.plist" + hydrogen.app/Contents/Info.plist ) - add_custom_command( - TARGET hydrogen - POST_BUILD - COMMAND plutil -replace NSHighResolutionCapable -bool true hydrogen.app/Contents/Info.plist - ) - add_custom_command( - TARGET hydrogen - POST_BUILD - COMMAND - plutil -extract CFBundleDocumentTypes json - -o /dev/null - hydrogen.app/Contents/Info.plist >/dev/null - || plutil -insert CFBundleDocumentTypes - -json - \"` cat ${CMAKE_SOURCE_DIR}/macos/CFBundleDocumentTypes.json `\" - hydrogen.app/Contents/Info.plist ) ADD_FILE_DEPENDENCIES(hydrogen ${CMAKE_SOURCE_DIR}/macos/CFBundleDocumentTypes.json)