mirror of
https://github.com/ankitects/anki.git
synced 2025-09-23 08:22:24 -04:00
if base folder can't be written, defer displaying message until qt is ready
This commit is contained in:
parent
9767b6b8a5
commit
c078cdddfd
2 changed files with 23 additions and 23 deletions
|
@ -332,11 +332,19 @@ def _run(argv=None, exec=True):
|
|||
opts, args = parseArgs(argv)
|
||||
|
||||
# profile manager
|
||||
pm = None
|
||||
try:
|
||||
pm = ProfileManager(opts.base)
|
||||
pmLoadResult = pm.setupMeta()
|
||||
except:
|
||||
# will handle below
|
||||
pass
|
||||
|
||||
if pm:
|
||||
# gl workarounds
|
||||
setupGL(pm)
|
||||
# apply user-provided scale factor
|
||||
os.environ["QT_SCALE_FACTOR"] = str(pm.uiScale())
|
||||
|
||||
# opt in to full hidpi support?
|
||||
if not os.environ.get("ANKI_NOHIGHDPI"):
|
||||
|
@ -348,9 +356,6 @@ def _run(argv=None, exec=True):
|
|||
if os.environ.get("ANKI_SOFTWAREOPENGL"):
|
||||
QCoreApplication.setAttribute(Qt.AA_UseSoftwareOpenGL)
|
||||
|
||||
# apply user-provided scale factor
|
||||
os.environ["QT_SCALE_FACTOR"] = str(pm.uiScale())
|
||||
|
||||
# create the app
|
||||
QCoreApplication.setApplicationName("Anki")
|
||||
QGuiApplication.setDesktopFileName("anki.desktop")
|
||||
|
@ -359,6 +364,16 @@ def _run(argv=None, exec=True):
|
|||
# we've signaled the primary instance, so we should close
|
||||
return
|
||||
|
||||
if not pm:
|
||||
QMessageBox.critical(
|
||||
None,
|
||||
"Error",
|
||||
"""\
|
||||
Anki could not create its data folder. Please see the File Locations \
|
||||
section of the manual, and ensure that location is not read-only.""",
|
||||
)
|
||||
return
|
||||
|
||||
# disable icons on mac; this must be done before window created
|
||||
if isMac:
|
||||
app.setAttribute(Qt.AA_DontShowIconsInMenus)
|
||||
|
|
|
@ -97,22 +97,7 @@ class ProfileManager:
|
|||
######################################################################
|
||||
|
||||
def ensureBaseExists(self):
|
||||
try:
|
||||
self._ensureExists(self.base)
|
||||
except:
|
||||
# can't translate, as lang not initialized, and qt may not be
|
||||
print("unable to create base folder")
|
||||
QMessageBox.critical(
|
||||
None,
|
||||
"Error",
|
||||
"""\
|
||||
Anki could not create the folder %s. Please ensure that location is not \
|
||||
read-only and you have permission to write to it. If you cannot fix this \
|
||||
issue, please see the documentation for information on running Anki from \
|
||||
a flash drive."""
|
||||
% self.base,
|
||||
)
|
||||
raise
|
||||
|
||||
# Folder migration
|
||||
######################################################################
|
||||
|
|
Loading…
Reference in a new issue