diff --git a/SpotMenu/AppDelegate/AppDelegate.swift b/SpotMenu/AppDelegate/AppDelegate.swift index 8c31806..9d97e19 100644 --- a/SpotMenu/AppDelegate/AppDelegate.swift +++ b/SpotMenu/AppDelegate/AppDelegate.swift @@ -54,6 +54,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate { view.translatesAutoresizingMaskIntoConstraints = false view.icon = chooseIcon(musicPlayerName: MusicPlayerName(rawValue: UserPreferences.lastMusicPlayer)!) view.lengthHandler = handleLength + view.speed = UserPreferences.scrollText ? 4 : 0 return view }() diff --git a/SpotMenu/Preferences/Tabs/GeneralPreferences.storyboard b/SpotMenu/Preferences/Tabs/GeneralPreferences.storyboard index 298a57c..f12708e 100644 --- a/SpotMenu/Preferences/Tabs/GeneralPreferences.storyboard +++ b/SpotMenu/Preferences/Tabs/GeneralPreferences.storyboard @@ -1,8 +1,8 @@ - + - + @@ -11,11 +11,11 @@ - + - + @@ -63,7 +63,7 @@ - + @@ -89,7 +89,7 @@ + - + @@ -135,7 +145,7 @@ - + @@ -153,8 +163,10 @@ + + @@ -179,6 +191,7 @@ + @@ -189,7 +202,7 @@ - + diff --git a/SpotMenu/Preferences/Tabs/GeneralPreferencesVC.swift b/SpotMenu/Preferences/Tabs/GeneralPreferencesVC.swift index daa6ba9..43b9375 100644 --- a/SpotMenu/Preferences/Tabs/GeneralPreferencesVC.swift +++ b/SpotMenu/Preferences/Tabs/GeneralPreferencesVC.swift @@ -26,6 +26,7 @@ final class GeneralPreferencesVC: NSViewController { @IBOutlet fileprivate var openAtLoginButton: HoverButton! @IBOutlet fileprivate var enableKeyboardShortcutButton: HoverButton! @IBOutlet fileprivate var hideTextWhenPausedButton: HoverButton! + @IBOutlet fileprivate var scrollTextButton: HoverButton! @IBOutlet fileprivate var moreInformation: NSTextField! @IBOutlet private var withLoveFromKmikiyText: NSTextField! @@ -54,6 +55,7 @@ final class GeneralPreferencesVC: NSViewController { openAtLoginButton.title = NSLocalizedString("Open at login", comment: "") enableKeyboardShortcutButton.title = NSLocalizedString("Enable keyboard shortcut", comment: "") hideTextWhenPausedButton.title = NSLocalizedString("Hide text when paused", comment: "") + scrollTextButton.title = NSLocalizedString("Scroll text", comment: "") withLoveFromKmikiyText.stringValue = NSLocalizedString("with ♥ from kmikiy", comment: "") } @@ -67,6 +69,7 @@ final class GeneralPreferencesVC: NSViewController { openAtLoginButton.state = NSControl.StateValue(rawValue: applicationIsInStartUpItems().asState) enableKeyboardShortcutButton.state = NSControl.StateValue(rawValue: UserPreferences.keyboardShortcutEnabled.asState) hideTextWhenPausedButton.state = NSControl.StateValue(rawValue: UserPreferences.hideTitleArtistWhenPaused.asState) + scrollTextButton.state = NSControl.StateValue(rawValue: UserPreferences.scrollText.asState) } private func initButtonHovers() { @@ -94,6 +97,9 @@ final class GeneralPreferencesVC: NSViewController { hideTextWhenPausedButton.mouseEnteredFunc = hoverHideTitleWhenPaused hideTextWhenPausedButton.mouseExitedFunc = hoverAway + scrollTextButton.mouseEnteredFunc = hoverScrollText + scrollTextButton.mouseExitedFunc = hoverAway + enableKeyboardShortcutButton.mouseEnteredFunc = hoverEnableKeyboardShortcut enableKeyboardShortcutButton.mouseExitedFunc = hoverAway } @@ -133,6 +139,10 @@ final class GeneralPreferencesVC: NSViewController { UserPreferences.hideTitleArtistWhenPaused = hideTextWhenPausedButton.state.asBool } + @IBAction func toggleScrollText(_: Any) { + UserPreferences.scrollText = scrollTextButton.state.asBool + } + @IBAction func toggleEnableKeyboardShortcut(_: Any) { UserPreferences.keyboardShortcutEnabled = enableKeyboardShortcutButton.state.asBool let appDelegate = NSApplication.shared.delegate as! AppDelegate @@ -184,6 +194,10 @@ extension GeneralPreferencesVC { moreInformation.stringValue = NSLocalizedString("Omits the current song artist and title from the menu bar when the music is paused.", comment: "") } + fileprivate func hoverScrollText() { + moreInformation.stringValue = NSLocalizedString("Scroll the current song artist and title in the menu bar.", comment: "") + } + fileprivate func hoverAway() { moreInformation.stringValue = defaultMoreInformationText } diff --git a/SpotMenu/Preferences/UserPreferences.swift b/SpotMenu/Preferences/UserPreferences.swift index 634a515..91c1022 100644 --- a/SpotMenu/Preferences/UserPreferences.swift +++ b/SpotMenu/Preferences/UserPreferences.swift @@ -25,6 +25,7 @@ struct UserPreferences { static let keyboardShortcutEnabled = "keyboardShortcutEnabled" static let hideTitleArtistWhenPaused = "hideTitleArtistWhenPaused" static let lastMusicPlayer = "lastMusicPlayer" + static let scrollText = "scrollText" } // MARK: - Properties @@ -113,6 +114,15 @@ struct UserPreferences { } } + static var scrollText: Bool { + get { + return UserPreferences.readSetting(key: Keys.scrollText) + } + set { + UserPreferences.setSetting(key: Keys.scrollText, value: newValue) + } + } + // MARK: - Public methods static func clearAllSettings() { @@ -161,7 +171,8 @@ struct UserPreferences { UserPreferences.showSpotMenuIcon || UserPreferences.fixPopoverToTheRight || UserPreferences.keyboardShortcutEnabled || - UserPreferences.hideTitleArtistWhenPaused { + UserPreferences.hideTitleArtistWhenPaused || + UserPreferences.scrollText { return } @@ -175,6 +186,7 @@ struct UserPreferences { UserPreferences.showSpotMenuIcon = true UserPreferences.keyboardShortcutEnabled = true UserPreferences.hideTitleArtistWhenPaused = true + UserPreferences.scrollText = true } }