add hw accel toggle to prefs

This commit is contained in:
Damien Elmes 2018-08-30 13:39:04 +10:00
parent a8ce102916
commit f699ebb370
3 changed files with 25 additions and 4 deletions

View file

@ -247,8 +247,6 @@ def setupGL(pm):
print("qt:", msg) print("qt:", msg)
qInstallMessageHandler(msgHandler) qInstallMessageHandler(msgHandler)
print("Hardware acceleration set to", mode)
if mode == "auto": if mode == "auto":
return return
elif isLin: elif isLin:

View file

@ -76,6 +76,10 @@ class Preferences(QDialog):
f = self.form f = self.form
qc = self.mw.col.conf qc = self.mw.col.conf
self._setupDayCutoff() self._setupDayCutoff()
if isMac:
f.hwAccel.setVisible(False)
else:
f.hwAccel.setChecked(self.mw.pm.glMode() != "software")
f.lrnCutoff.setValue(qc['collapseTime']/60.0) f.lrnCutoff.setValue(qc['collapseTime']/60.0)
f.timeLimit.setValue(qc['timeLim']/60.0) f.timeLimit.setValue(qc['timeLim']/60.0)
f.showEstimates.setChecked(qc['estTimes']) f.showEstimates.setChecked(qc['estTimes'])
@ -93,6 +97,17 @@ class Preferences(QDialog):
def updateCollection(self): def updateCollection(self):
f = self.form f = self.form
d = self.mw.col d = self.mw.col
if not isMac:
wasAccel = self.mw.pm.glMode() != "software"
wantAccel = f.hwAccel.isChecked()
if wasAccel != wantAccel:
if wantAccel:
self.mw.pm.setGlMode("auto")
else:
self.mw.pm.setGlMode("software")
showInfo(_("Changes will take effect when you restart Anki."))
qc = d.conf qc = d.conf
qc['dueCounts'] = f.showProgress.isChecked() qc['dueCounts'] = f.showProgress.isChecked()
qc['estTimes'] = f.showEstimates.isChecked() qc['estTimes'] = f.showEstimates.isChecked()

View file

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>405</width> <width>423</width>
<height>469</height> <height>508</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -66,6 +66,13 @@
</item> </item>
</layout> </layout>
</item> </item>
<item>
<widget class="QCheckBox" name="hwAccel">
<property name="text">
<string>Hardware acceleration (faster, may cause display issues)</string>
</property>
</widget>
</item>
<item> <item>
<widget class="QCheckBox" name="showEstimates"> <widget class="QCheckBox" name="showEstimates">
<property name="text"> <property name="text">
@ -474,6 +481,7 @@
</widget> </widget>
<tabstops> <tabstops>
<tabstop>lang</tabstop> <tabstop>lang</tabstop>
<tabstop>hwAccel</tabstop>
<tabstop>showEstimates</tabstop> <tabstop>showEstimates</tabstop>
<tabstop>showProgress</tabstop> <tabstop>showProgress</tabstop>
<tabstop>pastePNG</tabstop> <tabstop>pastePNG</tabstop>