-
Notifications
You must be signed in to change notification settings - Fork 170
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
core, add confirmation dialog on exit #208
base: master
Are you sure you want to change the base?
Changes from all commits
074da5d
c2325b3
3b1770d
496f5ed
d236012
5cf78b0
8495125
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,6 +47,9 @@ ActivityBase { | |
id: activity | ||
focus: true | ||
activityInfo: ActivityInfoTree.rootMenu | ||
// set to true when returned to home from a dialog. | ||
property bool returnFromDialog: false | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This variable is needed to handle the cases when we close a dialog. |
||
|
||
onBack: { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it should also be added there (I don't have mouse with back button but I think it will trigger this signal) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This signal is triggered only on back pressed from phones or other touch devices. Currently, back button from the mouse is not enabled. |
||
pageView.pop(to); | ||
// Restore focus that has been taken by the loaded activity | ||
|
@@ -58,17 +61,33 @@ ActivityBase { | |
if(pageView.depth === 1 && !ApplicationSettings.isKioskMode) { | ||
Core.quit(main); | ||
} | ||
else { | ||
// When a dialog box is closed. | ||
else if(returnFromDialog || !ApplicationSettings.isExitDialogEnabled) { | ||
returnFromDialog = false; | ||
pageView.pop(); | ||
// Restore focus that has been taken by the loaded activity | ||
if(pageView.currentItem == activity) | ||
focus = true; | ||
} | ||
// A confirmation dialog to quit the current activity is popped. | ||
else { | ||
Core.showMessageDialog(parent, | ||
qsTr("Do you want to leave current activity?"), | ||
qsTr("Yes"), function() { pageView.pop(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. go back to line for the function if it is not a one line function There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this code is copied/pasted 3 times, can be in a function instead |
||
// Restore focus that has been taken by the loaded activity | ||
if(pageView.currentItem == activity) | ||
focus = true; }, | ||
qsTr("No"), null, | ||
null ); | ||
} | ||
} | ||
|
||
onDisplayDialog: pageView.push(dialog) | ||
|
||
onDisplayDialog: { | ||
returnFromDialog = true; | ||
pageView.push(dialog) | ||
} | ||
onDisplayDialogs: { | ||
returnFromDialog = true; | ||
var toPush = new Array(); | ||
for (var i = 0; i < dialogs.length; i++) { | ||
toPush.push({item: dialogs[i]}); | ||
|
@@ -215,12 +234,12 @@ ActivityBase { | |
model: sections | ||
width: horizontal ? main.width : sectionCellWidth | ||
height: { | ||
if(horizontal) | ||
return sectionCellHeight | ||
else if(activity.currentTag === "search" && ApplicationSettings.isVirtualKeyboard) | ||
return sectionCellHeight * (sections.length+1) | ||
else | ||
return main.height - bar.height | ||
if(horizontal) | ||
return sectionCellHeight | ||
else if(activity.currentTag === "search" && ApplicationSettings.isVirtualKeyboard) | ||
return sectionCellHeight * (sections.length+1) | ||
else | ||
return main.height - bar.height | ||
} | ||
x: ApplicationSettings.sectionVisible ? section.initialX : -sectionCellWidth | ||
y: ApplicationSettings.sectionVisible ? section.initialY : -sectionCellHeight | ||
|
@@ -491,9 +510,9 @@ ActivityBase { | |
visible: false | ||
anchors.fill: activitiesGrid | ||
gradient: Gradient { | ||
GradientStop { position: 0.0; color: "#FFFFFFFF" } | ||
GradientStop { position: 0.92; color: "#FFFFFFFF" } | ||
GradientStop { position: 0.96; color: "#00FFFFFF"} | ||
GradientStop { position: 0.0; color: "#FFFFFFFF" } | ||
GradientStop { position: 0.92; color: "#FFFFFFFF" } | ||
GradientStop { position: 0.96; color: "#00FFFFFF"} | ||
} | ||
} | ||
layer.enabled: ApplicationInfo.useOpenGL | ||
|
@@ -622,37 +641,37 @@ ActivityBase { | |
} | ||
} | ||
function populate() { | ||
var tmplayout = []; | ||
var row = 0; | ||
var offset = 0; | ||
var cols; | ||
while(offset < letter.length-1) { | ||
if(letter.length <= 100) { | ||
cols = Math.ceil((letter.length-offset) / (3 - row)); | ||
} | ||
else { | ||
cols = background.horizontal ? (Math.ceil((letter.length-offset) / (15 - row))) | ||
:(Math.ceil((letter.length-offset) / (22 - row))) | ||
if(row == 0) { | ||
tmplayout[row] = new Array(); | ||
tmplayout[row].push({ label: keyboard.backspace }); | ||
tmplayout[row].push({ label: keyboard.space }); | ||
row ++; | ||
} | ||
} | ||
|
||
tmplayout[row] = new Array(); | ||
for (var j = 0; j < cols; j++) | ||
tmplayout[row][j] = { label: letter[j+offset] }; | ||
offset += j; | ||
row ++; | ||
} | ||
if(letter.length <= 100) { | ||
tmplayout[0].push({ label: keyboard.space }); | ||
tmplayout[row-1].push({ label: keyboard.backspace }); | ||
} | ||
keyboard.layout = tmplayout | ||
} | ||
var tmplayout = []; | ||
var row = 0; | ||
var offset = 0; | ||
var cols; | ||
while(offset < letter.length-1) { | ||
if(letter.length <= 100) { | ||
cols = Math.ceil((letter.length-offset) / (3 - row)); | ||
} | ||
else { | ||
cols = background.horizontal ? (Math.ceil((letter.length-offset) / (15 - row))) | ||
:(Math.ceil((letter.length-offset) / (22 - row))) | ||
if(row == 0) { | ||
tmplayout[row] = new Array(); | ||
tmplayout[row].push({ label: keyboard.backspace }); | ||
tmplayout[row].push({ label: keyboard.space }); | ||
row ++; | ||
} | ||
} | ||
|
||
tmplayout[row] = new Array(); | ||
for (var j = 0; j < cols; j++) | ||
tmplayout[row][j] = { label: letter[j+offset] }; | ||
offset += j; | ||
row ++; | ||
} | ||
if(letter.length <= 100) { | ||
tmplayout[0].push({ label: keyboard.space }); | ||
tmplayout[row-1].push({ label: keyboard.backspace }); | ||
} | ||
keyboard.layout = tmplayout | ||
} | ||
} | ||
|
||
Bar { | ||
|
@@ -678,6 +697,7 @@ ActivityBase { | |
dialogActivityConfig.loader.item.loadFromConfig() | ||
displayDialog(dialogActivityConfig) | ||
} | ||
onExitClicked: home() | ||
} | ||
|
||
DialogAbout { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Confirm before leaving current activity