Add sparkle
This commit is contained in:
2
.github/workflows/build.yml
vendored
2
.github/workflows/build.yml
vendored
@@ -805,6 +805,7 @@ jobs:
|
|||||||
-DICU_ROOT="${{env.prefix_path}}"
|
-DICU_ROOT="${{env.prefix_path}}"
|
||||||
-DAPPLE_DEVELOPER_ID=$(test '${{github.repository}}' = 'strawberrymusicplayer/strawberry' && test '${{github.event.pull_request.base.repo.full_name}}' = '${{github.event.pull_request.head.repo.full_name}}' && echo "383J84DVB6" || echo "")
|
-DAPPLE_DEVELOPER_ID=$(test '${{github.repository}}' = 'strawberrymusicplayer/strawberry' && test '${{github.event.pull_request.base.repo.full_name}}' = '${{github.event.pull_request.head.repo.full_name}}' && echo "383J84DVB6" || echo "")
|
||||||
-DENABLE_SPOTIFY=$(test -f "${{env.prefix_path}}/lib/gstreamer-1.0/libgstspotify.dylib" && echo "ON" || echo "OFF")
|
-DENABLE_SPOTIFY=$(test -f "${{env.prefix_path}}/lib/gstreamer-1.0/libgstspotify.dylib" && echo "ON" || echo "OFF")
|
||||||
|
-DARCH="${{env.arch}}"
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: cmake --build build --config Release --parallel 4
|
run: cmake --build build --config Release --parallel 4
|
||||||
@@ -944,6 +945,7 @@ jobs:
|
|||||||
-DICU_ROOT="${{env.prefix_path}}"
|
-DICU_ROOT="${{env.prefix_path}}"
|
||||||
-DAPPLE_DEVELOPER_ID="383J84DVB6"
|
-DAPPLE_DEVELOPER_ID="383J84DVB6"
|
||||||
-DENABLE_SPOTIFY=$(test -f "${{env.prefix_path}}/lib/gstreamer-1.0/libgstspotify.dylib" && echo "ON" || echo "OFF")
|
-DENABLE_SPOTIFY=$(test -f "${{env.prefix_path}}/lib/gstreamer-1.0/libgstspotify.dylib" && echo "ON" || echo "OFF")
|
||||||
|
-DARCH="${{env.arch}}"
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: cmake --build build --config Release --parallel 4
|
run: cmake --build build --config Release --parallel 4
|
||||||
|
|||||||
@@ -266,9 +266,10 @@ else()
|
|||||||
add_definitions(-DKDSINGLEAPPLICATION_STATIC_BUILD)
|
add_definitions(-DKDSINGLEAPPLICATION_STATIC_BUILD)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# if(APPLE)
|
if(APPLE)
|
||||||
# find_package(SPMediaKeyTap REQUIRED)
|
find_library(SPARKLE Sparkle)
|
||||||
# endif()
|
#find_package(SPMediaKeyTap REQUIRED)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
find_package(getopt-win REQUIRED)
|
find_package(getopt-win REQUIRED)
|
||||||
@@ -353,6 +354,13 @@ optional_component(EBUR128 ON "EBU R 128 loudness normalization"
|
|||||||
DEPENDS "libebur128" LIBEBUR128_FOUND
|
DEPENDS "libebur128" LIBEBUR128_FOUND
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if(APPLE)
|
||||||
|
optional_component(SPARKLE ON "Sparkle integration"
|
||||||
|
DEPENDS "macOS" APPLE
|
||||||
|
DEPENDS "Sparkle" SPARKLE
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(HAVE_SONGFINGERPRINTING OR HAVE_MUSICBRAINZ)
|
if(HAVE_SONGFINGERPRINTING OR HAVE_MUSICBRAINZ)
|
||||||
set(HAVE_CHROMAPRINT ON)
|
set(HAVE_CHROMAPRINT ON)
|
||||||
endif()
|
endif()
|
||||||
@@ -1198,6 +1206,7 @@ if(APPLE)
|
|||||||
src/osd/osdmac.h
|
src/osd/osdmac.h
|
||||||
src/device/macosdevicelister.h
|
src/device/macosdevicelister.h
|
||||||
)
|
)
|
||||||
|
optional_source(HAVE_SPARKLE SOURCES src/core/sparkleupdater.mm HEADERS src/core/sparkleupdater.h)
|
||||||
else()
|
else()
|
||||||
list(APPEND SOURCES src/systemtrayicon/qtsystemtrayicon.cpp src/widgets/searchfield_qt.cpp src/widgets/searchfield_qt_private.cpp)
|
list(APPEND SOURCES src/systemtrayicon/qtsystemtrayicon.cpp src/widgets/searchfield_qt.cpp src/widgets/searchfield_qt_private.cpp)
|
||||||
list(APPEND HEADERS src/systemtrayicon/qtsystemtrayicon.h src/widgets/searchfield_qt_private.h)
|
list(APPEND HEADERS src/systemtrayicon/qtsystemtrayicon.h src/widgets/searchfield_qt_private.h)
|
||||||
@@ -1534,6 +1543,10 @@ if(APPLE)
|
|||||||
"-framework IOKit"
|
"-framework IOKit"
|
||||||
"-framework ScriptingBridge"
|
"-framework ScriptingBridge"
|
||||||
)
|
)
|
||||||
|
if(HAVE_SPARKLE)
|
||||||
|
target_include_directories(strawberry_lib SYSTEM PRIVATE ${SPARKLE}/Headers)
|
||||||
|
target_link_libraries(strawberry_lib PRIVATE ${SPARKLE})
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_link_libraries(strawberry PUBLIC strawberry_lib)
|
target_link_libraries(strawberry PUBLIC strawberry_lib)
|
||||||
|
|||||||
4
dist/macos/Info.plist.in
vendored
4
dist/macos/Info.plist.in
vendored
@@ -35,9 +35,9 @@
|
|||||||
<key>LSMinimumSystemVersion</key>
|
<key>LSMinimumSystemVersion</key>
|
||||||
<string>@LSMinimumSystemVersion@</string>
|
<string>@LSMinimumSystemVersion@</string>
|
||||||
<key>SUFeedURL</key>
|
<key>SUFeedURL</key>
|
||||||
<string>https://www.strawberrymusicplayer.org/sparkle-macos</string>
|
<string>https://www.strawberrymusicplayer.org/sparkle-macos-@ARCH@</string>
|
||||||
<key>SUPublicEDKey</key>
|
<key>SUPublicEDKey</key>
|
||||||
<string>3IRScV8YtNVnx7zoeJAXvg28Kh1gN/Pyl2iPM467pG8=</string>
|
<string>/OydhYVfypuO2Mf7G6DUqVZWW9G19eFV74qaDCBTOUk=</string>
|
||||||
<key>CFBundleURLTypes</key>
|
<key>CFBundleURLTypes</key>
|
||||||
<array>
|
<array>
|
||||||
<dict>
|
<dict>
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
#cmakedefine HAVE_AUDIOCD
|
#cmakedefine HAVE_AUDIOCD
|
||||||
#cmakedefine HAVE_MTP
|
#cmakedefine HAVE_MTP
|
||||||
#cmakedefine HAVE_GPOD
|
#cmakedefine HAVE_GPOD
|
||||||
|
#cmakedefine HAVE_SPARKLE
|
||||||
#cmakedefine HAVE_QTSPARKLE
|
#cmakedefine HAVE_QTSPARKLE
|
||||||
#cmakedefine HAVE_SONGFINGERPRINTING
|
#cmakedefine HAVE_SONGFINGERPRINTING
|
||||||
#cmakedefine HAVE_MUSICBRAINZ
|
#cmakedefine HAVE_MUSICBRAINZ
|
||||||
|
|||||||
@@ -220,6 +220,10 @@
|
|||||||
# include "systemtrayicon/qtsystemtrayicon.h"
|
# include "systemtrayicon/qtsystemtrayicon.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_SPARKLE
|
||||||
|
#include "core/sparkleupdater.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_QTSPARKLE
|
#ifdef HAVE_QTSPARKLE
|
||||||
# include <qtsparkle-qt6/Updater>
|
# include <qtsparkle-qt6/Updater>
|
||||||
#endif // HAVE_QTSPARKLE
|
#endif // HAVE_QTSPARKLE
|
||||||
@@ -833,9 +837,9 @@ MainWindow::MainWindow(Application *app, SharedPtr<SystemTrayIcon> tray_icon, OS
|
|||||||
thumbbar_->SetActions(QList<QAction*>() << ui_->action_previous_track << ui_->action_play_pause << ui_->action_stop << ui_->action_next_track << nullptr << ui_->action_love);
|
thumbbar_->SetActions(QList<QAction*>() << ui_->action_previous_track << ui_->action_play_pause << ui_->action_stop << ui_->action_next_track << nullptr << ui_->action_love);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(HAVE_QTSPARKLE)
|
#if defined(HAVE_SPARKLE) || defined(HAVE_QTSPARKLE)
|
||||||
QAction *check_updates = ui_->menu_tools->addAction(tr("Check for updates..."));
|
QAction *action_check_updates = ui_->menu_tools->addAction(tr("Check for updates..."));
|
||||||
check_updates->setMenuRole(QAction::ApplicationSpecificRole);
|
action_check_updates->setMenuRole(QAction::ApplicationSpecificRole);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_GLOBALSHORTCUTS
|
#ifdef HAVE_GLOBALSHORTCUTS
|
||||||
@@ -1046,13 +1050,18 @@ MainWindow::MainWindow(Application *app, SharedPtr<SystemTrayIcon> tray_icon, OS
|
|||||||
app_->scrobbler()->Submit();
|
app_->scrobbler()->Submit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_SPARKLE
|
||||||
|
SparkleUpdater *sparkle_updater = new SparkleUpdater(action_check_updates, this);
|
||||||
|
QObject::connect(action_check_updates, &QAction::triggered, sparkle_updater, &SparkleUpdater::CheckForUpdates);
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_QTSPARKLE
|
#ifdef HAVE_QTSPARKLE
|
||||||
QUrl sparkle_url(QString::fromLatin1(QTSPARKLE_URL));
|
QUrl sparkle_url(QString::fromLatin1(QTSPARKLE_URL));
|
||||||
if (!sparkle_url.isEmpty()) {
|
if (!sparkle_url.isEmpty()) {
|
||||||
qLog(Debug) << "Creating Qt Sparkle updater";
|
qLog(Debug) << "Creating Qt Sparkle updater";
|
||||||
qtsparkle::Updater *updater = new qtsparkle::Updater(sparkle_url, this);
|
qtsparkle::Updater *updater = new qtsparkle::Updater(sparkle_url, this);
|
||||||
updater->SetVersion(QStringLiteral(STRAWBERRY_VERSION_PACKAGE));
|
updater->SetVersion(QStringLiteral(STRAWBERRY_VERSION_PACKAGE));
|
||||||
QObject::connect(check_updates, &QAction::triggered, updater, &qtsparkle::Updater::CheckNow);
|
QObject::connect(action_check_updates, &QAction::triggered, updater, &qtsparkle::Updater::CheckNow);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
48
src/core/sparkleupdater.h
Normal file
48
src/core/sparkleupdater.h
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
/*
|
||||||
|
* Strawberry Music Player
|
||||||
|
* Copyright 2025, Jonas Kvinge <jonas@jkvinge.net>
|
||||||
|
*
|
||||||
|
* Strawberry 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.
|
||||||
|
*
|
||||||
|
* Strawberry 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 Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SPARKLEUPDATER_H
|
||||||
|
#define SPARKLEUPDATER_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
class QAction;
|
||||||
|
|
||||||
|
#ifdef __OBJC__
|
||||||
|
@class AppUpdaterDelegate;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
class SparkleUpdater : public QObject {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit SparkleUpdater(QAction *action_check_updates, QObject *parent = nullptr);
|
||||||
|
|
||||||
|
public Q_SLOTS:
|
||||||
|
void CheckForUpdates();
|
||||||
|
|
||||||
|
private:
|
||||||
|
#ifdef __OBJC__
|
||||||
|
AppUpdaterDelegate *updater_delegate_;
|
||||||
|
#else
|
||||||
|
void *updater_delegate_;
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // SPARKLEUPDATER_H
|
||||||
79
src/core/sparkleupdater.mm
Normal file
79
src/core/sparkleupdater.mm
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
/*
|
||||||
|
* Strawberry Music Player
|
||||||
|
* Copyright 2025, Jonas Kvinge <jonas@jkvinge.net>
|
||||||
|
*
|
||||||
|
* Strawberry 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.
|
||||||
|
*
|
||||||
|
* Strawberry 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 Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#import <Sparkle/Sparkle.h>
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QAction>
|
||||||
|
|
||||||
|
#include "sparkleupdater.h"
|
||||||
|
|
||||||
|
@interface AppUpdaterDelegate : NSObject <SPUUpdaterDelegate>
|
||||||
|
|
||||||
|
@property(nonatomic, assign) SPUStandardUpdaterController *updater_controller;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation AppUpdaterDelegate
|
||||||
|
|
||||||
|
- (void)observeCanCheckForUpdatesWithAction:(QAction*)action_check_updates {
|
||||||
|
[_updater_controller.updater addObserver:self forKeyPath:NSStringFromSelector(@selector(canCheckForUpdates)) options:(NSKeyValueObservingOptionInitial | NSKeyValueObservingOptionNew) context:(void*)action_check_updates];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)observeValueForKeyPath:(NSString*)keyPath ofObject:(id)object change:(NSDictionary<NSKeyValueChangeKey, id>*)change context:(void*)context {
|
||||||
|
|
||||||
|
if ([keyPath isEqualToString:NSStringFromSelector(@selector(canCheckForUpdates))]) {
|
||||||
|
QAction *action = reinterpret_cast<QAction*>(context);
|
||||||
|
action->setEnabled(_updater_controller.updater.canCheckForUpdates);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
[super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)dealloc {
|
||||||
|
|
||||||
|
@autoreleasepool {
|
||||||
|
[_updater_controller.updater removeObserver:self forKeyPath:NSStringFromSelector(@selector(canCheckForUpdates))];
|
||||||
|
}
|
||||||
|
|
||||||
|
[super dealloc];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
SparkleUpdater::SparkleUpdater(QAction *action_check_updates, QObject *parent) : QObject(parent) {
|
||||||
|
|
||||||
|
@autoreleasepool {
|
||||||
|
updater_delegate_ = [[AppUpdaterDelegate alloc] init];
|
||||||
|
updater_delegate_.updater_controller = [[SPUStandardUpdaterController alloc] initWithStartingUpdater:YES updaterDelegate:updater_delegate_ userDriverDelegate:nil];
|
||||||
|
[updater_delegate_ observeCanCheckForUpdatesWithAction:action_check_updates];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void SparkleUpdater::CheckForUpdates() {
|
||||||
|
|
||||||
|
@autoreleasepool {
|
||||||
|
[updater_delegate_.updater_controller checkForUpdates:nil];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user