Skip to content

Commit

Permalink
Merge pull request #70 from superhighfives/copy-on-pick
Browse files Browse the repository at this point in the history
Adds option to automatically copy the picked colour
  • Loading branch information
superhighfives committed Nov 22, 2021
2 parents ca89266 + d7076c5 commit 4bb13c6
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 8 deletions.
8 changes: 4 additions & 4 deletions Pika.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 21;
CURRENT_PROJECT_VERSION = 23;
DEVELOPMENT_ASSET_PATHS = "\"Pika/Preview Content\"";
DEVELOPMENT_TEAM = TGHU37N6EX;
ENABLE_HARDENED_RUNTIME = YES;
Expand All @@ -607,7 +607,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.15;
MARKETING_VERSION = 0.0.11;
MARKETING_VERSION = 0.0.12;
PRODUCT_BUNDLE_IDENTIFIER = com.superhighfives.Pika;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
Expand All @@ -623,7 +623,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 21;
CURRENT_PROJECT_VERSION = 23;
DEVELOPMENT_ASSET_PATHS = "\"Pika/Preview Content\"";
DEVELOPMENT_TEAM = TGHU37N6EX;
ENABLE_HARDENED_RUNTIME = YES;
Expand All @@ -634,7 +634,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.15;
MARKETING_VERSION = 0.0.11;
MARKETING_VERSION = 0.0.12;
PRODUCT_BUNDLE_IDENTIFIER = com.superhighfives.Pika;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
Expand Down
2 changes: 1 addition & 1 deletion Pika/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate {
if preferencesWindow == nil {
preferencesWindow = PikaWindow.createSecondaryWindow(
title: "Preferences",
size: NSRect(x: 0, y: 0, width: 550, height: 420),
size: NSRect(x: 0, y: 0, width: 550, height: 450),
styleMask: [.titled, .closable, .miniaturizable, .fullSizeContentView]
)
preferencesWindow.contentView = NSHostingView(rootView: PreferencesView())
Expand Down
Binary file modified Pika/Assets/en.lproj/Localizable.strings
Binary file not shown.
Binary file modified Pika/Assets/fr.lproj/Localizable.strings
Binary file not shown.
1 change: 1 addition & 0 deletions Pika/Constants/Defaults.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ extension Defaults.Keys {
static let colorFormat = Key<ColorFormat>("colorFormat", default: .hex)
static let viewedSplash = Key<Bool>("viewedSplash", default: false)
static let hidePikaWhilePicking = Key<Bool>("hidePikaWhilePicking", default: false)
static let copyColorOnPick = Key<Bool>("copyColorOnPick", default: false)
static let hideMenuBarIcon = Key<Bool>("hideMenuBarIcon", default: false)
static let betaUpdates = Key<Bool>("betaUpdates", default: false)
static let colorSpace = NSSecureCodingKey<NSColorSpace>(
Expand Down
11 changes: 9 additions & 2 deletions Pika/Utilities/Eyedroppers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,15 @@ class Eyedropper: ObservableObject {

if let selectedColor = selectedColor {
self.color = selectedColor.usingColorSpace(Defaults[.colorSpace])!
NSApp.sendAction(#selector(AppDelegate.showPika), to: nil, from: nil)
} else if self.forceShow {

if Defaults[.copyColorOnPick] {
NSApp.sendAction(self.type.copySelector, to: nil, from: nil)
} else {
NSApp.sendAction(#selector(AppDelegate.showPika), to: nil, from: nil)
}
}

if self.forceShow {
self.forceShow = false
NSApp.sendAction(#selector(AppDelegate.showPika), to: nil, from: nil)
}
Expand Down
1 change: 0 additions & 1 deletion Pika/Views/EyedropperButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ struct EyedropperButton: View {
@ObservedObject var eyedropper: Eyedropper
@Default(.colorFormat) var colorFormat
@Default(.hideColorNames) var hideColorNames
let pasteboard = NSPasteboard.general

@State var copyVisible: Bool = false
@State private var timerSubscription: Cancellable?
Expand Down
4 changes: 4 additions & 0 deletions Pika/Views/NavigationMenuItems.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,17 @@ struct MenuGroup<Content>: View where Content: View {

struct NavigationMenuItems: View {
@Default(.hidePikaWhilePicking) var hidePikaWhilePicking
@Default(.copyColorOnPick) var copyColorOnPick
@Default(.hideFormatOnCopy) var hideFormatOnCopy

var body: some View {
Group {
Toggle(isOn: $hidePikaWhilePicking) {
Text(NSLocalizedString("color.pick.hide", comment: "Hide Pika while picking"))
}
Toggle(isOn: $copyColorOnPick) {
Text(NSLocalizedString("color.pick.copy", comment: "Copy color when picking"))
}
}
VStack {
Divider()
Expand Down

0 comments on commit 4bb13c6

Please sign in to comment.