simplify the migration popup

Avoid presenting the user with a wall of text they may not understand,
default to proceeding, and quit if the user cancels.
This commit is contained in:
Damien Elmes 2020-05-18 20:15:59 +10:00
parent a53aac40f8
commit 31ceb5d730

View file

@ -141,22 +141,18 @@ class ProfileManager:
icon.addPixmap( icon.addPixmap(
QtGui.QPixmap(":/icons/anki.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off, QtGui.QPixmap(":/icons/anki.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off,
) )
window_title = "Anki Base Directory Migration" window_title = "Data Folder Migration"
migration_directories = f"\n\n {oldBase}\n\nto\n\n {self.base}" migration_directories = f"\n\n {oldBase}\n\nto\n\n {self.base}"
conformation = QMessageBox() confirmation = QMessageBox()
conformation.setIcon(QMessageBox.Warning) confirmation.setIcon(QMessageBox.Warning)
conformation.setWindowIcon(icon) confirmation.setWindowIcon(icon)
conformation.setStandardButtons(QMessageBox.Ok | QMessageBox.Cancel) confirmation.setStandardButtons(QMessageBox.Ok | QMessageBox.Cancel)
conformation.setWindowTitle(window_title) confirmation.setWindowTitle(window_title)
conformation.setText("Confirm Anki Collection base directory migration?") confirmation.setText(
conformation.setInformativeText( "Anki needs to move its data folder from Documents/Anki to a new location. Proceed?"
f"The Anki Collection directory should be migrated from {migration_directories}\n\n"
f"If you would like to keep using the old location, consult the Startup Options "
f"on the Anki documentation on website\n\n{appHelpSite}"
) )
conformation.setDefaultButton(QMessageBox.Cancel) retval = confirmation.exec()
retval = conformation.exec()
if retval == QMessageBox.Ok: if retval == QMessageBox.Ok:
progress = QMessageBox() progress = QMessageBox()
@ -164,11 +160,10 @@ class ProfileManager:
progress.setStandardButtons(QMessageBox.NoButton) progress.setStandardButtons(QMessageBox.NoButton)
progress.setWindowIcon(icon) progress.setWindowIcon(icon)
progress.setWindowTitle(window_title) progress.setWindowTitle(window_title)
progress.setText( progress.setText("Please wait...")
f"Please wait while your Anki collection is moved from {migration_directories}"
)
progress.show() progress.show()
app.processEvents() app.processEvents()
shutil.move(oldBase, self.base) shutil.move(oldBase, self.base)
progress.hide() progress.hide()
@ -177,16 +172,22 @@ class ProfileManager:
completion.setStandardButtons(QMessageBox.Ok) completion.setStandardButtons(QMessageBox.Ok)
completion.setWindowIcon(icon) completion.setWindowIcon(icon)
completion.setWindowTitle(window_title) completion.setWindowTitle(window_title)
completion.setText( completion.setText("Migration complete. Please start Anki again.")
f"Your Anki Collection was successfully moved from {migration_directories}\n\n"
f"Now Anki needs to restart.\n\n"
f"Click OK to exit Anki and open it again."
)
completion.show() completion.show()
completion.exec() completion.exec()
raise AnkiRestart(exitcode=0)
else: else:
self.base = oldBase diag = QMessageBox()
diag.setIcon(QMessageBox.Warning)
diag.setWindowIcon(icon)
diag.setStandardButtons(QMessageBox.Ok)
diag.setWindowTitle(window_title)
diag.setText(
"Migration aborted. If you would like to keep the old folder location, please "
"see the Startup Options section of the manual. Anki will now quit."
)
diag.exec()
raise AnkiRestart(exitcode=0)
# Profile load/save # Profile load/save
###################################################################### ######################################################################