-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replaced default quit confirmation dialog with custom window modal
- Loading branch information
1 parent
ad06c80
commit 02b90c3
Showing
6 changed files
with
187 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
@import url("./fonts/fonts.css"); | ||
|
||
:root { | ||
user-select: none; | ||
-webkit-user-select: none; | ||
} | ||
|
||
div#window { | ||
height: 40px; | ||
width: -webkit-fill-available; | ||
display: flex; | ||
justify-content: space-between; | ||
align-items: center; | ||
-webkit-app-region: drag; | ||
flex-direction: row; | ||
flex-wrap: nowrap; | ||
} | ||
|
||
|
||
div#window>div#title>div#windowlogo { | ||
font-family: 'Montserrat'; | ||
font-size: 24px; | ||
font-weight: 700; | ||
letter-spacing: 1px; | ||
width: 30px; | ||
user-select: none; | ||
-webkit-user-select: none; | ||
padding-right: 10px; | ||
} | ||
|
||
div#window>div#title>div#windowtitle { | ||
font-family: 'Uni Sans CAPS', 'Montserrat'; | ||
font-size: 14px; | ||
font-weight: 700; | ||
user-select: none; | ||
-webkit-user-select: none; | ||
text-transform: uppercase; | ||
} | ||
|
||
body { | ||
margin: 0; | ||
} | ||
|
||
div#title { | ||
display: flex; | ||
align-items: center; | ||
flex-direction: row; | ||
justify-content: center; | ||
width: -webkit-fill-available; | ||
} | ||
|
||
html { | ||
color: white; | ||
animation: updateBackground 5s both infinite alternate; | ||
} | ||
|
||
@keyframes updateBackground { | ||
0% { | ||
background-color: #6495ed; | ||
} | ||
100% { | ||
background-color: #404; | ||
} | ||
} | ||
|
||
div#quitConfirm { | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
align-content: space-around; | ||
justify-content: space-evenly; | ||
flex-wrap: wrap; | ||
height: calc(100% - 40px); | ||
font-family: 'Montserrat'; | ||
font-weight: 700; | ||
} | ||
|
||
div#choices { | ||
height: 50px; | ||
width: 90%; | ||
display: flex; | ||
flex-direction: row; | ||
justify-content: space-around; | ||
} | ||
|
||
div.choice { | ||
height: calc(100% - 5px); | ||
width: 45%; | ||
border: 2.5px white solid; | ||
border-radius: 16px; | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
justify-content: center; | ||
transition: background-color 0.125s ease-in-out; | ||
} | ||
|
||
div.choice:hover { | ||
cursor: pointer; | ||
background-color: rgba(255, 255, 255, 0.404); | ||
} | ||
|
||
div#quitmessage { | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
text-align: center; | ||
white-space: pre; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<html> | ||
<head> | ||
<link rel="stylesheet" href="askToQuit.css"> | ||
<title>are you sure you want to quit?</title> | ||
</head> | ||
<body> | ||
<div id="window"> | ||
<div id="title"> | ||
<div id="windowlogo">××</div><div id="windowtitle">deadforge</div></div> | ||
</div> | ||
</div> | ||
<div id="quitConfirm"> | ||
<div id="quitmessage">Are you sure you want to quit? </div> | ||
<div id="choices"> | ||
<div class="choice" id="choiceyes" onclick="quitConfirm()">Yes</div> | ||
<div class="choice" id="choiceno" onclick="quitCancel()">No</div> | ||
</div> | ||
</div> | ||
</body> | ||
<script src="askToQuit.js"></script> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
const { BrowserWindow } = require('@electron/remote'); | ||
const { ipcRenderer } = require('electron'); | ||
|
||
ipcRenderer.on('askToQuit', (event, downloads) => { | ||
let questionString = '\nThere '; questionString += Object.keys(downloads).length == 1 ? 'is ' : 'are currently '; questionString += Object.keys(downloads).length; questionString += Object.keys(downloads).length == 1 ? ' item being downloaded:\n\n' : ' downloads being downloaded:\n\n'; questionString += downloads.map(item => { const key = Object.keys(item)[0]; const value = item[key]; return `${value.string} ${value.version}`; }).join('\n'); | ||
document.querySelector('div#quitmessage').textContent += questionString; | ||
}) | ||
|
||
function quitConfirm() { | ||
ipcRenderer.send('quitConfirmation', true); | ||
} | ||
|
||
function quitCancel() { | ||
ipcRenderer.send('quitConfirmation', false); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters