Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare QS to include Swift #3023

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ on:

jobs:
build:
runs-on: macos-12
runs-on: macos-latest
env:
QS_DONT_SIGN: 1
steps:
Expand Down Expand Up @@ -52,7 +52,7 @@ jobs:

sign:
needs: build
runs-on: macos-12
runs-on: macos-latest
if: startsWith(github.ref, 'refs/tags/v')
env:
MACOS_CERTIFICATE: ${{ secrets.MACOS_CERTIFICATE }}
Expand Down
8 changes: 4 additions & 4 deletions Quicksilver/Code-App/QSController.m
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ + (void)initialize {
if (![NSApplication isMavericks]) {
NSBundle *appBundle = [NSBundle mainBundle];

NSString *minimumVersionString = @"macOS 10.9+";
NSString *oldVersionsString = @"10.3–10.8";
NSString *minimumVersionString = @"macOS 10.14+";
NSString *oldVersionsString = @"10.14";

NSAlert *alert = [[NSAlert alloc] init];
alert.messageText = [NSString stringWithFormat:
Expand All @@ -60,7 +60,7 @@ + (void)initialize {
minimumVersionString
];
alert.informativeText = [NSString stringWithFormat:
NSLocalizedString(@"Recent versions of Quicksilver require %@. Older %@ compatible versions are available from the http://qsapp.com/download.php", @"macOS version required alert message"),
NSLocalizedString(@"Recent versions of Quicksilver require %@. Older %@ compatible versions are available from the https://qsapp.com/download.php", @"macOS version required alert message"),
minimumVersionString,
oldVersionsString];
[alert addButtonWithTitle:NSLocalizedString(@"OK", nil)];
Expand All @@ -86,7 +86,7 @@ + (void)initialize {
[QSVoyeur sharedInstance];

#ifdef DEBUG
if (defaultBool(@"verbose") )
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"verbose"])
setenv("verbose", "1", YES);
#endif

Expand Down
6 changes: 5 additions & 1 deletion Quicksilver/Code-App/QSHelpersPrefPane.m
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,11 @@ - (NSString *)mainNibName { return @"QSHelpersPrefPane"; }

- (void)reloadHelpersList:(id)sender {
NSMutableArray *helpers = [NSMutableArray array];
foreachkey(key, header, [QSReg tableNamed:@"QSRegistryHeaders"]) {

id header = nil;
NSString *key = nil;
NSEnumerator *kEnum = [[QSReg tableNamed:@"QSRegistryHeaders"] keyEnumerator];
while((key = [kEnum nextObject]) && (header = [[QSReg tableNamed:@"QSRegistryHeaders"] objectForKey:key]) ) {
if ([[header objectForKey:@"type"] isEqual:@"mediator"]) {
NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithObject:header forKey:INFO];
NSMenu *menu = [self menuForTable:key includeDefault:[[header objectForKey:@"allowDefault"] boolValue]];
Expand Down
5 changes: 4 additions & 1 deletion Quicksilver/Code-App/QSMainPreferencePanes.m
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,10 @@ - (void)updateGroups {
break;
}
case 1: {
foreachkey(pluginId, plugin, [[QSPlugInManager sharedInstance] loadedPlugIns]) {
id plugin = nil;
NSString *pluginId = nil;
NSEnumerator *kEnum = [[[QSPlugInManager sharedInstance] loadedPlugIns] keyEnumerator];
while((pluginId = [kEnum nextObject]) && (plugin = [[[QSPlugInManager sharedInstance] loadedPlugIns] objectForKey:pluginId]) ) {
NSString *name = [plugin shortName];
if (!name) name = [plugin identifier];
NSArray *actionsArray = [QSExec getArrayForSource:[plugin identifier]];
Expand Down
2 changes: 1 addition & 1 deletion Quicksilver/Code-App/QSPreferencesController.m
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ - (void)windowDidLoad {
// [toolbar performSelector:@selector(setSelectedItemIdentifier:) withObject:[[toolbarTabView selectedTabViewItem] identifier]];

[win setToolbar:toolbar];
if (defaultBool(@"QSSkipGuide") ) {
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"QSSkipGuide"] ) {
[self selectPaneWithIdentifier:@"QSSettingsPanePlaceholder"];
} else {
[toolbar setSelectedItemIdentifier:@"QSMainMenuPrefPane"];
Expand Down
2 changes: 1 addition & 1 deletion Quicksilver/Code-App/QSSetupAssistant.m
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ - (void)run:(id)sender {
}

- (BOOL)windowShouldClose:(id)sender {
if (!defaultBool(@"QSAgreementAccepted") ) {
if (![[NSUserDefaults standardUserDefaults] boolForKey:@"QSAgreementAccepted"] ) {
QSAlertResponse response = [NSAlert runAlertWithTitle:NSLocalizedString(@"Cancel Setup", @"Setup assistant - Cancel alert title")
message:NSLocalizedString(@"Would you like to stop setup and quit Quicksilver?", @"Setup assistant - Cancel alert message")
buttons:@[NSLocalizedString(@"Quit", nil), NSLocalizedString(@"Cancel", nil)]
Expand Down
2 changes: 1 addition & 1 deletion Quicksilver/Code-QuickStepCore/QSCatalogEntry.m
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,7 @@ - (NSMutableDictionary *)sourceSettings {


// Backward-compatibility
- (BOOL)deletable QS_DEPRECATED { return self.canBeDeleted; }
- (BOOL)deletable __attribute__((deprecated)) { return self.canBeDeleted; }

@end

Expand Down
2 changes: 1 addition & 1 deletion Quicksilver/Code-QuickStepCore/QSCatalogEntry_Private.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@
@end

@interface QSCatalogEntry (OldStyleSourceSupport)
- (id)objectForKey:(NSString *)key QS_DEPRECATED_MSG("Sources now get QSCatalogEntry objects. Please use those");
- (id)objectForKey:(NSString *)key __attribute__((deprecated("Sources now get QSCatalogEntry objects. Please use those")));
@end
5 changes: 3 additions & 2 deletions Quicksilver/Code-QuickStepCore/QSLibrarian.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#import <Foundation/Foundation.h>
#import "QSCatalogEntry.h"
#import "QSThreadSafeMutableDictionary.h"

#define kCustomCatalogID @"QSCatalogCustom"

Expand Down Expand Up @@ -85,15 +86,15 @@ extern QSLibrarian *QSLib; // Shared Instance
- (void)startThreadedAndForcedScan;
- (IBAction)forceScanCatalog:(id)sender;
- (IBAction)scanCatalog:(id)sender;
- (void)scanCatalogWithDelay:(id)sender QS_DEPRECATED;
- (void)scanCatalogWithDelay:(id)sender __attribute__((deprecated));
- (BOOL)itemIsOmitted:(QSBasicObject *)item;
- (void)setItem:(QSBasicObject *)item isOmitted:(BOOL)omit;
#ifdef DEBUG
- (CGFloat) estimatedTimeForSearchInSet:(id)set;
- (NSMutableArray *)scoreTest:(id)sender;
#endif
- (NSMutableArray *)scoredArrayForString:(NSString *)string;
- (NSMutableArray *)scoredArrayForString:(NSString *)string inNamedSet:(NSString *)setName QS_DEPRECATED;
- (NSMutableArray *)scoredArrayForString:(NSString *)string inNamedSet:(NSString *)setName __attribute__((deprecated));
- (NSMutableArray *)scoredArrayForString:(NSString *)searchString inSet:(id)set;
- (NSMutableArray *)scoredArrayForString:(NSString *)searchString inSet:(NSArray *)set mnemonicsOnly:(BOOL)mnemonicsOnly;
- (NSMutableArray *)shelfNamed:(NSString *)shelfName;
Expand Down
7 changes: 3 additions & 4 deletions Quicksilver/Code-QuickStepCore/QSObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@

#import <QSCore/QSBasicObject.h>
#import <QSCore/QSObjectHandler.h>
#import "QSThreadSafeMutableDictionary.h"

@class QSObject, QSBasicObject;

extern NSSize QSMaxIconSize;

#define itemForKey(k) [data objectForKey:k]

// meta dictionary keys
#define kQSObjectPrimaryName @"QSObjectName"
#define kQSObjectAlternateName @"QSObjectLabel"
Expand Down Expand Up @@ -73,7 +72,7 @@ typedef struct _QSObjectFlags {
+ (void)interfaceChanged;

+ (id)objectWithName:(NSString *)aName;
+ (id)objectWithIdentifier:(NSString *)anIdentifier QS_DEPRECATED;
+ (id)objectWithIdentifier:(NSString *)anIdentifier __attribute__((deprecated));
+ (id)makeObjectWithIdentifier:(NSString *)anIdentifier;
+ (id)objectByMergingObjects:(NSArray *)objects;
+ (id)objectByMergingObjects:(NSArray *)objects withObject:(QSObject *)object;
Expand Down Expand Up @@ -119,7 +118,7 @@ typedef struct _QSObjectFlags {
- (BOOL)unloadIcon;
- (NSImage *)icon;
- (void)setIcon:(NSImage *)newIcon;
- (void)updateIcon:(NSImage *)newIcon QS_DEPRECATED_MSG("Use -setIcon:");
- (void)updateIcon:(NSImage *)newIcon __attribute__((deprecated("Use -setIcon:")));
@end

@interface QSObject (Hierarchy)
Expand Down
8 changes: 5 additions & 3 deletions Quicksilver/Code-QuickStepCore/QSObject.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#import "QSDebug.h"
#import "QSObjectHandler.h"

#import <QSCore/QSCore-Swift.h>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this used?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not at the moment, but I intentionally left it in to help ensure that the remainder of the swift compilation continued to work. There seem to be a few fiddly bits with the xcode config in this PR, so I wanted to make sure that work wasn't lost (or at least that the breakage was loud) if there were changes in the interim, prior to real Swift work.

I could add a comment to that effect.


static NSMutableSet *iconLoadedSet;
static NSMutableSet *childLoadedSet;

Expand Down Expand Up @@ -396,14 +398,14 @@ - (NSString *)details {
[self setObject:details forMeta:kQSObjectDetails];
} else if ([self stringValue]) {
details = [self stringValue];
} else if ([itemForKey([self primaryType]) isKindOfClass:[NSString class]]) {
details = itemForKey([self primaryType]);
} else if ([[data objectForKey:[self primaryType]] isKindOfClass:[NSString class]]) {
details = [data objectForKey:[self primaryType]];
}

return details;
}

- (id)primaryObject {return itemForKey([self primaryType]);}
- (id)primaryObject {return [data objectForKey:[self primaryType]];}
//- (id)objectForKey:(id)aKey {return [data objectForKey:aKey];}
//- (void)setObject:(id)object forKey:(id)aKey {[data setObject:object forKey:aKey];}

Expand Down
2 changes: 1 addition & 1 deletion Quicksilver/Code-QuickStepCore/QSObjectHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

- (NSAppleEventDescriptor *)AEDescriptorForObject:(QSObject *)object;

- (QSObject *)initFileObject:(QSObject *)object ofType:(NSString *)type QS_DEPRECATED NS_RETURNS_NOT_RETAINED;
- (QSObject *)initFileObject:(QSObject *)object ofType:(NSString *)type __attribute__((deprecated)) NS_RETURNS_NOT_RETAINED;
@end


2 changes: 1 addition & 1 deletion Quicksilver/Code-QuickStepCore/QSObjectRanker.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ extern NSString *QSRankingIncludeOmitted; // BOOL. Specifies whether the ranke
- (NSString*)matchedStringForAbbreviation:(NSString*)anAbbreviation hitmask:(NSIndexSet **)hitmask inContext:(NSString *)context;

@optional
- (QSRankedObject *)rankedObject:(QSBasicObject *)object forAbbreviation:(NSString*)anAbbreviation inContext:(NSString *)context withMnemonics:(NSArray *)mnemonics mnemonicsOnly:(BOOL)mnemonicsOnly QS_DEPRECATED;
- (QSRankedObject *)rankedObject:(QSBasicObject *)object forAbbreviation:(NSString*)anAbbreviation inContext:(NSString *)context withMnemonics:(NSArray *)mnemonics mnemonicsOnly:(BOOL)mnemonicsOnly __attribute__((deprecated));
@end


Expand Down
6 changes: 3 additions & 3 deletions Quicksilver/Code-QuickStepCore/QSObjectSource.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
/* The following is deprecated because it duplicates -selection.
* But it can't be removed because dyld will notice and plugins will fail to load
*/
NSMutableDictionary *currentEntry QS_DEPRECATED;
NSMutableDictionary *currentEntry __attribute__((deprecated));
}

- (void)invalidateSelf;
Expand All @@ -102,7 +102,7 @@
// Please use -selectedEntry instead of those
// The rational being that between -currentEntry, -selection and direct Ivar
// everything can go wrong.
@property (retain) NSMutableDictionary *currentEntry QS_DEPRECATED;
@property (retain) QSCatalogEntry *selection QS_DEPRECATED;
@property (retain) NSMutableDictionary *currentEntry __attribute__((deprecated));
@property (retain) QSCatalogEntry *selection __attribute__((deprecated));

@end
8 changes: 4 additions & 4 deletions Quicksilver/Code-QuickStepCore/QSObject_Pasteboard.m
Original file line number Diff line number Diff line change
Expand Up @@ -166,14 +166,14 @@ - (id)initWithClipping:(NSString *)clippingFile {
}

- (void)guessName {
if (itemForKey(QSFilePathType) ) {
if ([data objectForKey:QSFilePathType]) {
[self setPrimaryType:QSFilePathType];
[self getNameFromFiles];
} else {
NSString *textString = itemForKey(QSTextType);
NSString *textString = [data objectForKey:QSTextType];
// some objects (images from the web) don't have a text string but have a URL
if (!textString) {
textString = itemForKey(NSURLPboardType);
textString = [data objectForKey:NSURLPboardType];
}
textString = [textString stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];

Expand Down Expand Up @@ -206,7 +206,7 @@ - (void)guessName {
}

for (NSString *key in keys) {
if (itemForKey(key) ) {
if ([data objectForKey:key] ) {
if ([key isEqualToString:QSTextType]) {
[self setDetails:nil];
} else {
Expand Down
5 changes: 4 additions & 1 deletion Quicksilver/Code-QuickStepCore/QSPlugIn.m
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,10 @@ - (BOOL)_registerPlugIn {
id value;
id handler;

foreachkey(key, handlerClass, [QSReg tableNamed:kQSPlugInInfoHandlers]) {
id handlerClass = nil;
NSString *key = nil;
NSEnumerator *kEnum = [[QSReg tableNamed:kQSPlugInInfoHandlers] keyEnumerator];
while((key = [kEnum nextObject]) && (handlerClass = [[QSReg tableNamed:kQSPlugInInfoHandlers] objectForKey:key]) ) {
value = [bundle dictionaryForFileOrPlistKey:key];
if (!value) continue;
//NSLog(@"----> Registering %@ for %@", key, [self name]);
Expand Down
5 changes: 3 additions & 2 deletions Quicksilver/Code-QuickStepCore/QSProcessMonitor.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@


#import <Foundation/Foundation.h>
#import <Carbon/Carbon.h>

#define kQSShowBackgroundProcesses @"QSShowBackgroundProcesses"

Expand All @@ -24,8 +25,8 @@
- (NSArray *)backgroundProcesses; /* QSObjects */

/* Deprecated, equivalent to the above without KVO */
- (NSArray *)getAllProcesses QS_DEPRECATED_MSG("Use -allProcesses");
- (NSArray *)getVisibleProcesses QS_DEPRECATED_MSG("Use -visibleProcesses");
- (NSArray *)getAllProcesses __attribute__((deprecated("Use -allProcesses")));
- (NSArray *)getVisibleProcesses __attribute__((deprecated("Use -visibleProcesses")));

- (QSObject *)imbuedFileProcessForDict:(NSDictionary *)dict;
- (BOOL)handleProcessEvent:(NSEvent *)theEvent;
Expand Down
8 changes: 8 additions & 0 deletions Quicksilver/Code-QuickStepCore/QSSwiftObj.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//
// QSSwiftObj.swift
// QuickStep Core
//
// Created by Nathan Henrie on 2024-11-08.
//

import Foundation
3 changes: 2 additions & 1 deletion Quicksilver/Code-QuickStepCore/QSTrigger.m
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,8 @@ - (BOOL)execute {
[self setEnabled:NO];
}
};
if (defaultBool(kExecuteInThread) && [cmd canThread]) {
// defaultBool(x) [[NSUserDefaults standardUserDefaults] boolForKey:x]
if ([[NSUserDefaults standardUserDefaults] boolForKey:kExecuteInThread] && [cmd canThread]) {
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), block);
} else {
block();
Expand Down
5 changes: 4 additions & 1 deletion Quicksilver/Code-QuickStepCore/QSTriggerCenter.m
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,10 @@ - (NSArray *)triggersWithIDs:(NSArray *)idents {

- (NSArray *)triggersWithParentID:(NSString *)ident {
NSMutableArray *array = [NSMutableArray array];
foreachkey(key, trigger, triggersDict) {
id trigger = nil;
NSString *key = nil;
NSEnumerator *kEnum = [triggersDict keyEnumerator];
while((key = [kEnum nextObject]) && (trigger = [triggersDict objectForKey:key]) ) {
if ([[trigger parentID] isEqualToString:ident])
[array addObject:trigger];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ NSComparisonResult prefixCompare(NSString *aString, NSString *bString);

@interface NSString (Replacement)
- (NSArray *)lines;
- (NSString *)stringByReplacing:(NSString *)search with:(NSString *)replacement QS_DEPRECATED;
- (NSString *)stringByReplacing:(NSString *)search with:(NSString *)replacement __attribute__((deprecated));

@end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
- (void)reopenApplication:(NSDictionary *)theApp;
- (void)quitApplication:(NSDictionary *)theApp;
- (void)quitOtherApplications:(NSArray *)theApps;
- (NSDictionary *)dictForApplicationIdentifier:(NSString *)ident QS_DEPRECATED;
- (NSDictionary *)dictForApplicationIdentifier:(NSString *)ident __attribute__((deprecated));
- (NSString *)commentForFile:(NSString *)path;
- (BOOL)setComment:(NSString*)comment forFile:(NSString *)path;
- (BOOL)openFileInBackground:(NSString *)fullPath;
Expand Down
4 changes: 2 additions & 2 deletions Quicksilver/Code-QuickStepFoundation/QSGCD.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ inline void QSGCDDelayed(NSTimeInterval delay, void (^block)(void))

// Remove those when the plugins are call-free
// Don't forget to remove definitions in .m file
void runOnMainQueueSync(void (^block)(void)) QS_DEPRECATED_MSG("Use QSGCDMainSync");
void runOnQueueSync(dispatch_queue_t queue, void (^block)(void)) QS_DEPRECATED_MSG("Use QSGCDQueueSync");
void runOnMainQueueSync(void (^block)(void)) __attribute__((deprecated("Use QSGCDMainSync")));
void runOnQueueSync(dispatch_queue_t queue, void (^block)(void)) __attribute__((deprecated("Use QSGCDQueueSync")));

#endif // __QSGCD__
6 changes: 3 additions & 3 deletions Quicksilver/Code-QuickStepInterface/QSDockingWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@
@result YES if window is hidden into the screen edge, otherwise NO
*/
- (BOOL)isDocked;
- (BOOL)canFade QS_DEPRECATED_MSG("Use -isDockedInstead");
- (BOOL)canFade __attribute__((deprecated("Use -isDockedInstead")));

- (NSString *)autosaveName QS_DEPRECATED_MSG("Use -NSWindow frameAutosaveName or -NSWindowController windowFrameAutosaveName");
- (void)setAutosaveName:(NSString *)newAutosaveName QS_DEPRECATED_MSG("Use -NSWindow frameAutosaveName or -NSWindowController windowFrameAutosaveName");;
- (NSString *)autosaveName __attribute__((deprecated("Use -NSWindow frameAutosaveName or -NSWindowController windowFrameAutosaveName")));
- (void)setAutosaveName:(NSString *)newAutosaveName __attribute__((deprecated("Use -NSWindow frameAutosaveName or -NSWindowController windowFrameAutosaveName")));;
- (void)resignKeyWindowNow;
- (IBAction)orderFrontHidden:(id)sender;
- (void)saveFrame;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
BOOL expanded;
}
- (void)firstResponderChanged:(NSResponder *)aResponder;
- (void)resetAdjustTimer QS_DEPRECATED_MSG("Use -adjustWindow:");
- (void)resetAdjustTimer __attribute__((deprecated("Use -adjustWindow:")));
- (void)expandWindow:(id)sender;
- (void)contractWindow:(id)sender;

Expand Down
2 changes: 1 addition & 1 deletion Quicksilver/Code-QuickStepInterface/QSSearchObjectView.m
Original file line number Diff line number Diff line change
Expand Up @@ -1485,7 +1485,7 @@ - (IBAction)dropClipboard:(id)sender {
#pragma mark NSResponder Key Bindings
- (void)deleteBackward:(id)sender {
if ([[self partialString] length] > 0 || matchedString) {
if (defaultBool(kDoubleDeleteClearsObject)) {
if ([[NSUserDefaults standardUserDefaults] boolForKey:kDoubleDeleteClearsObject]) {
// option to have delete clear the entire search string
[self clearSearch];
[self clearTextView];
Expand Down
Loading