Rebased
This commit is contained in:
parent
315c4014a7
commit
10de9fc0c1
|
@ -1,4 +1,4 @@
|
|||
import NimQml, chronicles, os, strformat, times
|
||||
import NimQml, chronicles, os, strformat, times, md5
|
||||
|
||||
import app/chat/core as chat
|
||||
import app/wallet/v1/core as wallet
|
||||
|
@ -66,6 +66,12 @@ proc mainProc() =
|
|||
"/../resources.rcc"
|
||||
QResource.registerResource(app.applicationDirPath & resources)
|
||||
|
||||
let singleInstance = newSingleInstance($toMD5(getAppDir()))
|
||||
defer: singleInstance.delete()
|
||||
if singleInstance.secondInstance():
|
||||
info "Terminating the app as the second instance"
|
||||
quit()
|
||||
|
||||
let statusAppIcon =
|
||||
if defined(production):
|
||||
if defined(macosx):
|
||||
|
@ -207,6 +213,7 @@ proc mainProc() =
|
|||
|
||||
engine.setRootContextProperty("loginModel", login.variant)
|
||||
engine.setRootContextProperty("onboardingModel", onboarding.variant)
|
||||
engine.setRootContextProperty("singleInstance", newQVariant(singleInstance))
|
||||
|
||||
let isExperimental = if getEnv("EXPERIMENTAL") == "1": "1" else: "0" # value explicity passed to avoid trusting input
|
||||
let experimentalFlag = newQVariant(isExperimental)
|
||||
|
|
12
ui/main.qml
12
ui/main.qml
|
@ -120,6 +120,18 @@ StatusWindow {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: singleInstance
|
||||
|
||||
onSecondInstanceDetected: {
|
||||
console.log("User attempted to run the second instance of the application")
|
||||
// activating this instance to give user visual feedback
|
||||
applicationWindow.show()
|
||||
applicationWindow.raise()
|
||||
applicationWindow.requestActivate()
|
||||
}
|
||||
}
|
||||
|
||||
// The easiest way to get current system theme (is it light or dark) without using
|
||||
// OS native methods is to check lightness (0 - 1.0) of the window color.
|
||||
|
|
Loading…
Reference in New Issue