mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
customizable deck order, nicer layout of browser and study options
This commit is contained in:
parent
3bab1b6829
commit
b5fdca39e7
5 changed files with 271 additions and 238 deletions
|
@ -97,6 +97,7 @@ class Config(dict):
|
|||
'proxyPass': '',
|
||||
'loadLastDeck': False,
|
||||
'deckBrowserRefreshPeriod': 3600,
|
||||
'deckBrowserOrder': 0,
|
||||
}
|
||||
for (k,v) in fields.items():
|
||||
if not self.has_key(k):
|
||||
|
|
|
@ -8,6 +8,7 @@ from PyQt4.QtWebKit import QWebPage
|
|||
|
||||
import os, sys, re, types, gettext, stat, traceback, inspect
|
||||
import shutil, time, glob, tempfile, datetime, zipfile, locale
|
||||
from operator import itemgetter
|
||||
|
||||
from PyQt4.QtCore import *
|
||||
from PyQt4.QtGui import *
|
||||
|
@ -1024,17 +1025,22 @@ your deck."""))
|
|||
if ui.splash.finished:
|
||||
self.finishProgress()
|
||||
self.browserLastRefreshed = time.time()
|
||||
self.reorderBrowserDecks()
|
||||
|
||||
def reorderBrowserDecks(self):
|
||||
h = {}
|
||||
for d in self.browserDecks:
|
||||
h[d['path']] = d
|
||||
self.browserDecks = []
|
||||
for path in self.config['recentDeckPaths']:
|
||||
try:
|
||||
self.browserDecks.append(h[path])
|
||||
except:
|
||||
pass
|
||||
if self.config['deckBrowserOrder'] == 0:
|
||||
self.browserDecks.sort(key=itemgetter('mod'),
|
||||
reverse=True)
|
||||
else:
|
||||
def custcmp(a, b):
|
||||
x = cmp(not not b['due'], not not a['due'])
|
||||
if x:
|
||||
return x
|
||||
x = cmp(not not b['new'], not not a['new'])
|
||||
if x:
|
||||
return x
|
||||
return cmp(a['mod'], b['mod'])
|
||||
self.browserDecks.sort(cmp=custcmp)
|
||||
|
||||
def forceBrowserRefresh(self):
|
||||
self.browserLastRefreshed = 0
|
||||
|
@ -1058,6 +1064,7 @@ your deck."""))
|
|||
sip.delete(self.mainWin.decksFrame.layout())
|
||||
# build new layout
|
||||
layout = QGridLayout()
|
||||
layout.setSpacing(0)
|
||||
if (time.time() - self.browserLastRefreshed >
|
||||
self.config['deckBrowserRefreshPeriod']):
|
||||
self.refreshBrowserDecks()
|
||||
|
@ -1065,14 +1072,13 @@ your deck."""))
|
|||
self.reorderBrowserDecks()
|
||||
if self.browserDecks:
|
||||
layout.addWidget(QLabel(_("<b>Deck</b>")), 0, 0)
|
||||
layout.setColumnStretch(0, 1)
|
||||
l = QLabel(_("<b>Due<br>Today</b>"))
|
||||
l.setAlignment(Qt.AlignRight | Qt.AlignVCenter)
|
||||
layout.addWidget(l, 0, 1)
|
||||
l = QLabel(_("<b>New<br>Today</b>"))
|
||||
l.setAlignment(Qt.AlignRight | Qt.AlignVCenter)
|
||||
layout.addWidget(l, 0, 2)
|
||||
# space
|
||||
layout.addWidget(QLabel(" " * 4), 0, 3)
|
||||
for c, deck in enumerate(self.browserDecks):
|
||||
# name
|
||||
n = deck['name']
|
||||
|
@ -1081,9 +1087,9 @@ your deck."""))
|
|||
mod = _("%s ago") % anki.utils.fmtTimeSpan(
|
||||
time.time() - deck['mod'])
|
||||
mod = "<font size=-1>%s</font>" % mod
|
||||
layout.addWidget(QLabel(
|
||||
"%d. <b>%s</b><br> %s" %
|
||||
(c+1, n, mod)), c+1, 0)
|
||||
l = QLabel("%d. <b>%s</b><br> %s" %
|
||||
(c+1, n, mod))
|
||||
layout.addWidget(l, c+1, 0)
|
||||
# due
|
||||
col = '<b><font color=#0000ff>%s</font></b>'
|
||||
if deck['due'] > 0:
|
||||
|
@ -1100,6 +1106,7 @@ your deck."""))
|
|||
else:
|
||||
s = ""
|
||||
l = QLabel(s)
|
||||
l.setMargin(10)
|
||||
l.setMinimumWidth(50)
|
||||
l.setAlignment(Qt.AlignRight | Qt.AlignVCenter)
|
||||
layout.addWidget(l, c+1, 2)
|
||||
|
@ -1117,7 +1124,7 @@ your deck."""))
|
|||
openButton.setToolTip(_("Open this deck%s") % extra)
|
||||
self.connect(openButton, SIGNAL("clicked()"),
|
||||
lambda d=deck['path']: self.loadDeck(d))
|
||||
layout.addWidget(openButton, c+1, 4)
|
||||
layout.addWidget(openButton, c+1, 3)
|
||||
if c == 0:
|
||||
focusButton = openButton
|
||||
# more
|
||||
|
@ -1130,7 +1137,7 @@ your deck."""))
|
|||
_("Forget removes the deck from the list without deleting."))
|
||||
self.connect(moreButton, SIGNAL("currentIndexChanged(int)"),
|
||||
lambda idx, c=c: self.onDeckBrowserMore(idx, c))
|
||||
layout.addWidget(moreButton, c+1, 5)
|
||||
layout.addWidget(moreButton, c+1, 4)
|
||||
refresh = QPushButton(_("Refresh"))
|
||||
refresh.setToolTip(_("Check due counts again (Ctrl+Shift+r)"))
|
||||
refresh.setShortcut(_("Ctrl+Shift+r"))
|
||||
|
|
|
@ -142,7 +142,7 @@ class Preferences(QDialog):
|
|||
self.dialog.addZeroSpace.setChecked(self.config['addZeroSpace'])
|
||||
self.dialog.alternativeTheme.setChecked(self.config['alternativeTheme'])
|
||||
self.dialog.showProgress.setChecked(self.config['showProgress'])
|
||||
self.dialog.openLastDeck.setChecked(self.config['loadLastDeck'])
|
||||
self.dialog.deckBrowserOrder.setChecked(self.config['deckBrowserOrder'])
|
||||
|
||||
def updateAdvanced(self):
|
||||
self.config['showTrayIcon'] = self.dialog.showTray.isChecked()
|
||||
|
@ -156,6 +156,10 @@ class Preferences(QDialog):
|
|||
self.config['showProgress'] = self.dialog.showProgress.isChecked()
|
||||
self.config['preventEditUntilAnswer'] = self.dialog.preventEdits.isChecked()
|
||||
self.config['loadLastDeck'] = self.dialog.openLastDeck.isChecked()
|
||||
if self.dialog.deckBrowserOrder.isChecked():
|
||||
self.config['deckBrowserOrder'] = 1
|
||||
else:
|
||||
self.config['deckBrowserOrder'] = 0
|
||||
|
||||
def codeToIndex(self, code):
|
||||
n = 0
|
||||
|
|
|
@ -601,6 +601,12 @@
|
|||
</item>
|
||||
<item>
|
||||
<widget class="QFrame" name="studyOptionsFrame">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>400</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
|
@ -1108,6 +1114,12 @@
|
|||
</item>
|
||||
<item>
|
||||
<widget class="QFrame" name="frame_3">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>500</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Preferences</class>
|
||||
<widget class="QDialog" name="Preferences">
|
||||
|
@ -5,8 +6,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>320</width>
|
||||
<height>419</height>
|
||||
<width>332</width>
|
||||
<height>438</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
|
@ -32,7 +33,7 @@
|
|||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string><h1>Language</h1></string>
|
||||
<string><h1>Language</h1></string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>false</bool>
|
||||
|
@ -52,7 +53,7 @@
|
|||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
|
@ -61,7 +62,7 @@
|
|||
<enum>Qt::TabFocus</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string><h1>Reviewing</h1></string>
|
||||
<string><h1>Reviewing</h1></string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>false</bool>
|
||||
|
@ -165,7 +166,7 @@
|
|||
<item>
|
||||
<widget class="QLabel" name="label_16">
|
||||
<property name="text">
|
||||
<string><h1>Synchronisation</h1><a href="http://anki.ichi2.net/">Create a free account</a>.</string>
|
||||
<string><h1>Synchronisation</h1><a href="http://anki.ichi2.net/">Create a free account</a>.</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
|
@ -236,7 +237,7 @@
|
|||
<item>
|
||||
<widget class="QLabel" name="label_13">
|
||||
<property name="text">
|
||||
<string><h1>Proxy</h1></string>
|
||||
<string><h1>Proxy</h1></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -334,7 +335,7 @@
|
|||
<item>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string><h1>Autosaving</h1></string>
|
||||
<string><h1>Autosaving</h1></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -412,7 +413,7 @@
|
|||
<item>
|
||||
<widget class="QLabel" name="label_9">
|
||||
<property name="text">
|
||||
<string><h1>Backups</h1>Decks are backed up when they are opened, and only if they have been modified since the last backup.</string>
|
||||
<string><h1>Backups</h1>Decks are backed up when they are opened, and only if they have been modified since the last backup.</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
|
@ -469,7 +470,7 @@
|
|||
<item>
|
||||
<widget class="QLabel" name="openBackupFolder">
|
||||
<property name="text">
|
||||
<string><a href="backups">Open backup folder</a></string>
|
||||
<string><a href="backups">Open backup folder</a></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -508,7 +509,7 @@
|
|||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string><h1>Advanced settings</h1></string>
|
||||
<string><h1>Advanced settings</h1></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -556,7 +557,7 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="0" >
|
||||
<item row="10" column="0">
|
||||
<widget class="QCheckBox" name="addZeroSpace">
|
||||
<property name="text">
|
||||
<string>Add hidden char to text (fixes Thai on OSX)</string>
|
||||
|
@ -566,7 +567,14 @@
|
|||
<item row="8" column="0">
|
||||
<widget class="QCheckBox" name="openLastDeck">
|
||||
<property name="text">
|
||||
<string>Open last deck even when multiple decks available</string>
|
||||
<string>Always open last deck on startup</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="0">
|
||||
<widget class="QCheckBox" name="deckBrowserOrder">
|
||||
<property name="text">
|
||||
<string>Show decks with cards due first in browser</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -639,6 +647,7 @@
|
|||
<tabstop>showTray</tabstop>
|
||||
<tabstop>showStudyOptions</tabstop>
|
||||
<tabstop>openLastDeck</tabstop>
|
||||
<tabstop>deckBrowserOrder</tabstop>
|
||||
<tabstop>addZeroSpace</tabstop>
|
||||
<tabstop>buttonBox</tabstop>
|
||||
</tabstops>
|
||||
|
|
Loading…
Reference in a new issue