From 31ceb5d7300c74a1d2315a2a4a79d33e6cce6013 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Mon, 18 May 2020 20:15:59 +1000 Subject: [PATCH] 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. --- qt/aqt/profiles.py | 47 +++++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/qt/aqt/profiles.py b/qt/aqt/profiles.py index 3112d0391..ea373102d 100644 --- a/qt/aqt/profiles.py +++ b/qt/aqt/profiles.py @@ -141,22 +141,18 @@ class ProfileManager: icon.addPixmap( 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}" - conformation = QMessageBox() - conformation.setIcon(QMessageBox.Warning) - conformation.setWindowIcon(icon) - conformation.setStandardButtons(QMessageBox.Ok | QMessageBox.Cancel) - conformation.setWindowTitle(window_title) - conformation.setText("Confirm Anki Collection base directory migration?") - conformation.setInformativeText( - 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}" + confirmation = QMessageBox() + confirmation.setIcon(QMessageBox.Warning) + confirmation.setWindowIcon(icon) + confirmation.setStandardButtons(QMessageBox.Ok | QMessageBox.Cancel) + confirmation.setWindowTitle(window_title) + confirmation.setText( + "Anki needs to move its data folder from Documents/Anki to a new location. Proceed?" ) - conformation.setDefaultButton(QMessageBox.Cancel) - retval = conformation.exec() + retval = confirmation.exec() if retval == QMessageBox.Ok: progress = QMessageBox() @@ -164,11 +160,10 @@ class ProfileManager: progress.setStandardButtons(QMessageBox.NoButton) progress.setWindowIcon(icon) progress.setWindowTitle(window_title) - progress.setText( - f"Please wait while your Anki collection is moved from {migration_directories}" - ) + progress.setText("Please wait...") progress.show() app.processEvents() + shutil.move(oldBase, self.base) progress.hide() @@ -177,16 +172,22 @@ class ProfileManager: completion.setStandardButtons(QMessageBox.Ok) completion.setWindowIcon(icon) completion.setWindowTitle(window_title) - completion.setText( - 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.setText("Migration complete. Please start Anki again.") completion.show() completion.exec() - raise AnkiRestart(exitcode=0) 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 ######################################################################