Skip to content

Commit

Permalink
Replace 'check for updates' dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
SaifAqqad committed Dec 25, 2021
1 parent 22e5d6b commit a11c041
Show file tree
Hide file tree
Showing 7 changed files with 194 additions and 135 deletions.
13 changes: 7 additions & 6 deletions src/MicMute.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ Global A_startupTime:= A_TickCount
, osd_wnd
, overlay_wnd
, A_log:=""
, updater_obj:= new Updater(A_ScriptDir)
, updater_obj:= new Updater(A_ScriptDir, Func("util_log"))
, updater_UI:=""

; parse cli args
Expand Down Expand Up @@ -99,10 +99,10 @@ OnExit(Func("exitMicMute"))
OnMessage(WM_SETTINGCHANGE, "updateSysTheme")
; listen for window changes
registerWindowHook()
; run the update checker once, 5 seconds after launching
; run the update checker once, 10 seconds after launching
if(A_IsCompiled && !arg_reload && config_obj.AllowUpdateChecker=1){
cfunc:= ObjBindMethod(updater_obj, "CheckForUpdates")
SetTimer, % cfunc, -5000
SetTimer, % cfunc, -10000
}
A_startupTime:= A_TickCount - A_startupTime
util_log("[Main] MicMute startup took " A_startupTime "ms")
Expand Down Expand Up @@ -147,13 +147,11 @@ initilizeMicMute(default_profile:=""){
;initilize tray
tray_init()
if(config_obj.AllowUpdateChecker==-1){
MsgBox, 35, MicMute, Allow MicMute to connect to the internet and check for updates on startup?
MsgBox, 36, MicMute, Allow MicMute to connect to the internet and check for updates on startup?
IfMsgBox, Yes
config_obj.AllowUpdateChecker:= 1
IfMsgBox, No
config_obj.AllowUpdateChecker:= 0
IfMsgBox, Cancel
config_obj.AllowUpdateChecker:= -1
}
;on first launch -> immediately call editConfig()
if(isFirstLaunch){
Expand Down Expand Up @@ -426,6 +424,9 @@ configMsg(err){
}

runUpdater(){
if(!A_IsCompiled)
return
util_log("[Main] Restarting MicMute in updater mode")
FileCopy, %A_ScriptFullPath%, %A_Temp%\MicMuteUpdater.exe, 1
Run, "%A_Temp%\MicMuteUpdater.exe" "/updater=1" "/installPath=%A_ScriptDir%"
ExitApp, 1
Expand Down
2 changes: 1 addition & 1 deletion src/UI/Tray.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ tray_Reload(){
}

tray_checkForUpdates(){
updater_obj.CheckForUpdates(1)
UI_showAbout("",1)
}

tray_noFunc(){
Expand Down
32 changes: 28 additions & 4 deletions src/UI/config/UI.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -778,10 +778,12 @@ UI_createAbout(){
about_obj.Gui("-Resize")
}

UI_showAbout(neutron:=""){
UI_showAbout(neutron:="", isCheckingForUpdates:=0){
util_log("[UI] Showing 'about' window")
tray_defaults()
about_obj.show(Format("Center w{:i} h{:i}",500*UI_scale,300*UI_scale),"About MicMute")
if(isCheckingForUpdates)
UI_checkForUpdates(neutron)
about_obj.show(Format("Center w{:i} h{:i}", 500*UI_scale, 300*UI_scale), "About MicMute")
about_obj.doc.focus()
}

Expand All @@ -791,12 +793,34 @@ UI_exitAbout(neutron){
UI_createAbout()
}

UI_checkForUpdates(neutron:=""){
refreshButton:= about_obj.doc.getElementById("refresh_button")
refreshButton.classList.add("is-loading")
latestVersion:= updater_obj.getLatestVersion()
if(latestVersion){
about_obj.doc.getElementById("latest_version").innerText:= latestVersion
refreshButton.classList.add("push-right")
if(latestVersion > A_Version){
about_obj.doc.getElementById("update_button").classList.remove("is-hidden")
}
}
refreshButton.classList.remove("is-loading")
refreshButton.blur()
}

UI_launchUpdater(neutron:=""){
MsgBox, 65, MicMute, % "This will restart MicMute in updater mode"
IfMsgBox, OK
runUpdater()
about_obj.doc.getElementById("update_button").blur()
}

UI_launchURL(neutron:="", url:=""){
Run, %url%, %A_Desktop%
}

UI_launchReleasePage(neutron:=""){
url:= "https://github.com/SaifAqqad/AHK_MicMute/releases/tag/" . A_Version
UI_launchReleasePage(neutron:="", version:=""){
url:= "https://github.com/SaifAqqad/AHK_MicMute/releases/tag/" . (version? version : A_Version)
Run, %url%, %A_Desktop%
}

Expand Down
2 changes: 1 addition & 1 deletion src/UI/config/UpdaterUI.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class UpdaterUI extends NeutronWindow{
show(){
this.setUIState("pre-update")
this.resetDetail()
this.appendDetail("Current version: <span class='has-text-primary'>" A_Version "</span>")
this.appendDetail("Installed version: <span class='has-text-primary'>" A_Version "</span>")
this.appendDetail("Latest version: <span class='has-text-primary'>" updater_obj.getLatestVersion() "</span>")
this.appendDetail("Installation method: <span class='has-text-primary'>" updater_obj.installationMethod "</span>")
base.Gui("+LabelUpdaterUI_ +MinSize780x510 -Resize")
Expand Down
3 changes: 2 additions & 1 deletion src/UI/config/css/dark.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ body {
scrollbar-shadow-color: #4E4E4E;
}

.title-bar-header {
.title-bar-header ,
.modal-card-head{
color: #d9d9d9 !important;
background: #272727 !important;
}
Expand Down
221 changes: 137 additions & 84 deletions src/UI/config/html/about.html
Original file line number Diff line number Diff line change
@@ -1,92 +1,145 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<style>
header {
height: 30px;
}

body {
overflow: hidden;
font-family: 'Segoe UI Variable Display', 'Segoe UI';
}


#MicMute_icon {
width: 38px;
height: 38px;
border-radius: 23%;
box-shadow: 0 0.5em 1em -0.125em rgba(10, 10, 10, 0.1), 0 0 0 1px rgba(10, 10, 10, 0.02);
transition: box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

img#MicMute_icon:hover,
label:hover>img#MicMute_icon {
box-shadow: 0px 11px 15px -7px rgba(0, 0, 0, 0.055), 0px 0px 20px 0px rgba(255, 87, 45, 0.63), 0px 9px 46px 8px rgba(0, 0, 0, 0.055);
}

#info {
position: absolute;
top: 40%;
left: 80px;
transform: translateY(-50%);
margin-right: 100px;
}

#label {
font-size: 2rem;
font-weight: 600;
cursor: default;
}

#stats {
margin-top: 3px;
font-size: 14px;
}

#license {
left: 90px;
margin-right: 50px;
position: fixed;
bottom: 20px;
font-size: 11px;
}
</style>
</head>

<body class="noselect" oncontextmenu="return false">
<header class="title-bar-header">
<span class="title-bar" onmousedown="neutron.DragTitleBar()"></span>
<span class="title-btn title-btn-close" onclick="ahk.UI_exitAbout()">r</span>
</header>
<div id='info'>
<div>
<label id='label' tabindex=0 onkeydown="switch(event.keyCode){case 32:case 13:this.click()}"
onclick="ahk.UI_launchURL('https://github.com/SaifAqqad/AHK_MicMute')"><img id='MicMute_icon' src='' />
MicMute</label>
</div>
<div id='stats'>
<div>Version: <a id="version" tabindex=0 onkeydown="switch(event.keyCode){case 32:case 13:this.click()}"
onclick="ahk.UI_launchReleasePage()"></a>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<style>
header {
height: 30px;
}

body {
overflow: hidden;
font-family: 'Segoe UI Variable Display', 'Segoe UI';
}


#MicMute_icon {
width: 38px;
height: 38px;
border-radius: 23%;
box-shadow: 0 0.5em 1em -0.125em rgba(10, 10, 10, 0.1), 0 0 0 1px rgba(10, 10, 10, 0.02);
transition: box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

img#MicMute_icon:hover,
label:hover>img#MicMute_icon {
box-shadow: 0px 11px 15px -7px rgba(0, 0, 0, 0.055), 0px 0px 20px 0px rgba(255, 87, 45, 0.63), 0px 9px 46px 8px rgba(0, 0, 0, 0.055);
}

#info {
position: absolute;
top: 40%;
left: 80px;
transform: translateY(-50%);
margin-right: 100px;
}

#label {
font-size: 2rem;
font-weight: 600;
cursor: pointer !important;
}

#stats {
margin-top: 3px;
font-size: 14px;
}

#license {
left: 90px;
margin-right: 50px;
position: fixed;
bottom: 20px;
font-size: 11px;
}

.status-row {
margin-top: 0.4em;
}

.status-row>a {
margin-left: 0.2em;
}

#refresh_button {
margin-left: 0em;
height: 1.8em;
width: 1.6em;
}

#update_button {
height: 1.8em;
}

.push-right {
margin-left: 1em !important;
}

div.has-addons.is-grouped {
display: inline-flex;
}

.field.has-addons :not(:last-child).control {
margin-right: -1px !important;
}
</style>
</head>

<body class="noselect" oncontextmenu="return false">
<header class="title-bar-header">
<span class="title-bar" onmousedown="neutron.DragTitleBar()"></span>
<span class="title-btn title-btn-close" onclick="ahk.UI_exitAbout()">r</span>
</header>
<div id='info'>
<div>
<label id='label' tabindex=0 onkeydown="switch(event.keyCode){case 32:case 13:this.click()}"
onclick="ahk.UI_launchURL('https://github.com/SaifAqqad/AHK_MicMute')"><img id='MicMute_icon' src='../../../resources/MicMute.png' />
MicMute</label>
</div>

<div id='stats'>
<div class="status-row">Installed version: <a id="version" tabindex=0 onkeydown="switch(event.keyCode){case 32:case 13:this.click()}"
onclick="ahk.UI_launchReleasePage()"></a>
</div>
<div class="status-row">Latest version:
<a id="latest_version" tabindex=0 onkeydown="switch(event.keyCode){case 32:case 13:this.click()}"
onclick="ahk.UI_launchReleasePage(this.innerText)"></a>
<div class="field has-addons is-grouped">
<p class="control">
<button type="button" class="button is-small is-primary is-outlined" id="refresh_button"
onclick="ahk.UI_checkForUpdates()">
<span class="icon is-small">
<svg style="width:16px;height:16px" focusable="false" viewBox="0 0 24 24">
<path fill="currentColor"
d="M17.65,6.35C16.2,4.9 14.21,4 12,4A8,8 0 0,0 4,12A8,8 0 0,0 12,20C15.73,20 18.84,17.45 19.73,14H17.65C16.83,16.33 14.61,18 12,18A6,6 0 0,1 6,12A6,6 0 0,1 12,6C13.66,6 15.14,6.69 16.22,7.78L13,11H20V4L17.65,6.35Z" />
</svg>
</span>
</button>
</p>
<p class="control">
<button type="button" class="button is-small is-primary is-outlined is-hidden" id="update_button" onclick="ahk.UI_launchUpdater()">
<svg style="width:14px;height:14px" viewBox="10 0 24 24">
<path fill="currentColor" d="M5,20H19V18H5M19,9H15V3H9V9H5L12,16L19,9Z" />
</svg> Update
</button>
</p>
</div>
</div>
<div class="status-row">Author: <a tabindex=0 onkeydown="switch(event.keyCode){case 32:case 13:this.click()}"
onclick="ahk.UI_launchURL('https://github.com/SaifAqqad')">Saif Aqqad</a></div>
</div>
<div>Author: <a tabindex=0 onkeydown="switch(event.keyCode){case 32:case 13:this.click()}"
onclick="ahk.UI_launchURL('https://github.com/SaifAqqad')">Saif Aqqad</a></div>
</div>
</div>
<div id="license">
<div> MicMute's code is public domain and is licensed under <a tabindex=0
onkeydown="switch(event.keyCode){case 32:case 13:this.click()}"
onclick="ahk.UI_launchURL('https://github.com/SaifAqqad/AHK_MicMute/blob/master/LICENSE')">The
Unlicense</a>.
</div>
<div>
MicMute uses several libraries, each with their own <a tabindex=0
onkeydown="switch(event.keyCode){case 32:case 13:this.click()}"
onclick="ahk.UI_launchURL('https://github.com/SaifAqqad/AHK_MicMute#libraries-and-resources-used')">license</a>.
<div id="license">
<div> MicMute's code is public domain and is licensed under <a tabindex=0 onkeydown="switch(event.keyCode){case 32:case 13:this.click()}"
onclick="ahk.UI_launchURL('https://github.com/SaifAqqad/AHK_MicMute/blob/master/LICENSE')">The
Unlicense</a>.
</div>
<div>
MicMute uses several libraries, each with their own <a tabindex=0 onkeydown="switch(event.keyCode){case 32:case 13:this.click()}"
onclick="ahk.UI_launchURL('https://github.com/SaifAqqad/AHK_MicMute#libraries-and-resources-used')">license</a>.
</div>
</div>
</div>
</body>
</body>

</html>
Loading

0 comments on commit a11c041

Please sign in to comment.