1
0

OBSUpdateDelegate.mm 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #import "OBSUpdateDelegate.h"
  2. @implementation OBSUpdateDelegate {
  3. }
  4. @synthesize branch;
  5. - (nonnull NSSet<NSString *> *)allowedChannelsForUpdater:(nonnull SPUUpdater *)updater
  6. {
  7. return [NSSet setWithObject:branch];
  8. }
  9. - (void)observeCanCheckForUpdatesWithAction:(nonnull QAction *)action;
  10. {
  11. [_updaterController.updater addObserver:self forKeyPath:NSStringFromSelector(@selector(canCheckForUpdates))
  12. options:(NSKeyValueObservingOptionInitial | NSKeyValueObservingOptionNew)
  13. context:(void *) action];
  14. }
  15. - (void)observeValueForKeyPath:(NSString *)keyPath
  16. ofObject:(id)object
  17. change:(NSDictionary<NSKeyValueChangeKey, id> *)change
  18. context:(void *)context
  19. {
  20. if ([keyPath isEqualToString:NSStringFromSelector(@selector(canCheckForUpdates))]) {
  21. QAction *menuAction = (QAction *) context;
  22. menuAction->setEnabled(_updaterController.updater.canCheckForUpdates);
  23. } else {
  24. [super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
  25. }
  26. }
  27. - (void)dealloc
  28. {
  29. @autoreleasepool {
  30. [_updaterController.updater removeObserver:self forKeyPath:NSStringFromSelector(@selector(canCheckForUpdates))];
  31. }
  32. }
  33. @end