Skip to content

Commit

Permalink
Merge pull request #354 from swiftDialog/dev_2.4.2
Browse files Browse the repository at this point in the history
swiftDialog 2.4.2
  • Loading branch information
bartreardon committed Feb 28, 2024
2 parents fe273a0 + 27e4845 commit 940f2c6
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 19 deletions.
4 changes: 2 additions & 2 deletions dialog.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -899,7 +899,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 12.0;
MARKETING_VERSION = 2.4.1;
MARKETING_VERSION = 2.4.2;
PRODUCT_BUNDLE_IDENTIFIER = au.csiro.dialog;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down Expand Up @@ -928,7 +928,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 12.0;
MARKETING_VERSION = 2.4.1;
MARKETING_VERSION = 2.4.2;
PRODUCT_BUNDLE_IDENTIFIER = au.csiro.dialog;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down
2 changes: 1 addition & 1 deletion dialog/App Processing/AppVariables.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import SwiftUI

struct AppVariables {

var cliversion = "2.4.1"
var cliversion = "2.4.2"
let launchTime = Date.now
// message default strings
let titleDefault = String("default-title".localized)
Expand Down
6 changes: 4 additions & 2 deletions dialog/Functions/Notifications.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent noti
completionHandler([.banner, .sound])
}

func checkNotificationAuthorisation() {
func checkNotificationAuthorisation(notificationPresent: Bool) {
UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .badge, .sound]) { _, error in
if let error = error {
writeLog(error.localizedDescription, logLevel: .error)
if notificationPresent {
writeLog(error.localizedDescription, logLevel: .error)
}
return
}
}
Expand Down
6 changes: 3 additions & 3 deletions dialog/Updatable Content/DialogUpdatableContent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class FileReader {
case "position:":
(observedData.appProperties.windowPositionVertical,
observedData.appProperties.windowPositionHorozontal) = windowPosition(line.replacingOccurrences(of: "position: ", with: ""))
placeWindow(observedData.mainWindow!, size: CGSize(width: observedData.appProperties.windowWidth, height: observedData.appProperties.windowHeight+28),
placeWindow(observedData.mainWindow ?? NSApp.windows[0], size: CGSize(width: observedData.appProperties.windowWidth, height: observedData.appProperties.windowHeight+28),
vertical: observedData.appProperties.windowPositionVertical,
horozontal: observedData.appProperties.windowPositionHorozontal,
offset: observedData.args.positionOffset.value.floatValue())
Expand All @@ -120,7 +120,7 @@ class FileReader {
let tempWidth = line.replacingOccurrences(of: "width: ", with: "")
if tempWidth.isNumeric {
observedData.appProperties.windowWidth = CGFloat((tempWidth as NSString).floatValue)
placeWindow(observedData.mainWindow!, size: CGSize(width: observedData.appProperties.windowWidth, height: observedData.appProperties.windowHeight+28),
placeWindow(observedData.mainWindow ?? NSApp.windows[0], size: CGSize(width: observedData.appProperties.windowWidth, height: observedData.appProperties.windowHeight+28),
vertical: observedData.appProperties.windowPositionVertical,
horozontal: observedData.appProperties.windowPositionHorozontal,
offset: observedData.args.positionOffset.value.floatValue())
Expand All @@ -130,7 +130,7 @@ class FileReader {
let tempHeight = line.replacingOccurrences(of: "height: ", with: "")
if tempHeight.isNumeric {
observedData.appProperties.windowHeight = CGFloat((tempHeight as NSString).floatValue)
placeWindow(observedData.mainWindow!, size: CGSize(width: observedData.appProperties.windowWidth, height: observedData.appProperties.windowHeight+28),
placeWindow(observedData.mainWindow ?? NSApp.windows[0], size: CGSize(width: observedData.appProperties.windowWidth, height: observedData.appProperties.windowHeight+28),
vertical: observedData.appProperties.windowPositionVertical,
horozontal: observedData.appProperties.windowPositionHorozontal,
offset: observedData.args.positionOffset.value.floatValue())
Expand Down
3 changes: 2 additions & 1 deletion dialog/Views/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ struct ContentView: View {
TitleView(observedData: observedData)
.border(observedData.appProperties.debugBorderColour, width: 2)
.padding(.top, titlePadding)
.frame(minWidth: observedData.args.windowWidth.value.floatValue(), minHeight: observedData.appProperties.titleHeight, alignment: .center)
//.frame(minWidth: observedData.args.windowWidth.value.floatValue(), minHeight: observedData.appProperties.titleHeight, alignment: .center)
.frame(minHeight: observedData.appProperties.titleHeight, alignment: .center)

// Horozontal Line
Divider()
Expand Down
2 changes: 1 addition & 1 deletion dialog/Views/MessageContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ struct MessageContent: View {
if !observedData.args.messageVerticalAlignment.present || ["centre", "center", "top"].contains(observedData.args.messageVerticalAlignment.value) {
Spacer()
}
}
}

Group {
TextFileView(logFilePath: observedData.args.logFileToTail.value)
Expand Down
27 changes: 18 additions & 9 deletions dialog/dialogApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDele
blurredScreen[index].loadWindow()
blurredScreen[index].showWindow(self)
}
NSApp.windows[0].level = NSWindow.Level(rawValue: Int(CGWindowLevelForKey(.maximumWindow) + 1))
window.level = NSWindow.Level(rawValue: Int(CGWindowLevelForKey(.maximumWindow) + 1))
} else if appArguments.forceOnTop.present {
NSApp.windows[0].level = NSWindow.Level(rawValue: Int(CGWindowLevelForKey(.maximumWindow) + 1))
window.level = NSWindow.Level(rawValue: Int(CGWindowLevelForKey(.maximumWindow) + 1))
} else {
background.close()
}
Expand All @@ -90,7 +90,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDele
NSApp.activate(ignoringOtherApps: true)
}

placeWindow(window, size: CGSize(width: appvars.windowWidth, height: appvars.windowHeight+28),
placeWindow(window, size: window.frame.size,
vertical: appvars.windowPositionVertical,
horozontal: appvars.windowPositionHorozontal,
offset: appvars.windowPositionOffset)
Expand All @@ -116,7 +116,7 @@ struct dialogApp: App {
for argument in CommandLine.arguments {
writeLog(argument, logLevel: .info)
}
checkNotificationAuthorisation()

// Ensure the singleton NSApplication exists.
// required for correct determination of screen dimentions for the screen in use in multi screen scenarios
_ = NSApplication.shared
Expand All @@ -130,6 +130,8 @@ struct dialogApp: App {
// get all the command line option values
processCLOptionValues()

checkNotificationAuthorisation(notificationPresent: appArguments.notification.present)

// check if we are sending a notification
if checkForDialogNotificationMode(appArguments) {
writeLog("Notification sent")
Expand Down Expand Up @@ -192,11 +194,18 @@ struct dialogApp: App {
MiniView(observedDialogContent: observedData)
.frame(width: observedData.appProperties.windowWidth, height: observedData.appProperties.windowHeight)
} else {
ContentView(observedDialogContent: observedData)
.frame(width: observedData.appProperties.windowWidth, height: observedData.appProperties.windowHeight)
.sheet(isPresented: $observedData.showSheet, content: {
ErrorView(observedContent: observedData)
})
if appArguments.windowResizable.present {
ContentView(observedDialogContent: observedData)
.sheet(isPresented: $observedData.showSheet, content: {
ErrorView(observedContent: observedData)
})
} else {
ContentView(observedDialogContent: observedData)
.frame(width: observedData.appProperties.windowWidth, height: observedData.appProperties.windowHeight)
.sheet(isPresented: $observedData.showSheet, content: {
ErrorView(observedContent: observedData)
})
}
}
}
}
Expand Down

0 comments on commit 940f2c6

Please sign in to comment.