diff --git a/ankiqt/config.py b/ankiqt/config.py
index 81bfbce6a..3638a94a4 100644
--- a/ankiqt/config.py
+++ b/ankiqt/config.py
@@ -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):
diff --git a/ankiqt/ui/main.py b/ankiqt/ui/main.py
index 10470d3de..60d440dd0 100644
--- a/ankiqt/ui/main.py
+++ b/ankiqt/ui/main.py
@@ -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(_("Deck")), 0, 0)
+ layout.setColumnStretch(0, 1)
l = QLabel(_("Due
Today"))
l.setAlignment(Qt.AlignRight | Qt.AlignVCenter)
layout.addWidget(l, 0, 1)
l = QLabel(_("New
Today"))
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 = "%s" % mod
- layout.addWidget(QLabel(
- "%d. %s
%s" %
- (c+1, n, mod)), c+1, 0)
+ l = QLabel("%d. %s
%s" %
+ (c+1, n, mod))
+ layout.addWidget(l, c+1, 0)
# due
col = '%s'
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"))
diff --git a/ankiqt/ui/preferences.py b/ankiqt/ui/preferences.py
index 3da366ecf..17a8570ce 100644
--- a/ankiqt/ui/preferences.py
+++ b/ankiqt/ui/preferences.py
@@ -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
diff --git a/designer/main.ui b/designer/main.ui
index a8a341ec6..8e8638fcf 100644
--- a/designer/main.ui
+++ b/designer/main.ui
@@ -601,6 +601,12 @@
-
+
+
+ 400
+ 16777215
+
+
QFrame::StyledPanel
@@ -1108,6 +1114,12 @@
-
+
+
+ 500
+ 16777215
+
+
QFrame::StyledPanel
diff --git a/designer/preferences.ui b/designer/preferences.ui
index 30ae28302..dde8413fd 100644
--- a/designer/preferences.ui
+++ b/designer/preferences.ui
@@ -1,47 +1,48 @@
-
+
+
Preferences
-
-
+
+
0
0
- 320
- 419
+ 332
+ 438
-
+
Preferences
-
+
-
-
-
+
+
Qt::StrongFocus
-
+
0
-
-
+
+
Display
-
-
+
+
6
-
-
-
- <h1>Language</h1>
+
+
+ <h1>Language</h1>
-
+
false
-
-
-
+
+
300
0
@@ -50,65 +51,65 @@
-
-
-
-
+
+
+
0
0
-
+
Qt::TabFocus
-
- <h1>Reviewing</h1>
+
+ <h1>Reviewing</h1>
-
+
false
-
-
-
+
+
Show divider between question and answer
-
-
-
+
+
Put space between question and answer
-
-
-
+
+
Show next time before answer
-
-
-
+
+
Show due count and progress during review
-
-
-
+
+
Prevent edits until answer shown
-
-
-
+
+
Qt::Vertical
-
+
20
0
@@ -117,112 +118,112 @@
-
-
-
+
+
Some settings will take effect after you restart Anki.
-
+
Qt::AlignCenter
-
-
+
+
Network
-
-
+
+
10
-
-
-
+
+
10
-
+
0
-
-
-
+
+
6
-
+
0
-
-
-
+
+
0
-
+
6
-
-
-
- <h1>Synchronisation</h1><a href="http://anki.ichi2.net/">Create a free account</a>.
+
+
+ <h1>Synchronisation</h1><a href="http://anki.ichi2.net/">Create a free account</a>.
-
+
true
-
+
true
-
-
-
+
+
0
-
+
6
-
-
-
-
+
-
+
+
Password
- -
-
-
+
-
+
+
Username
- -
-
+
-
+
- -
-
-
+
-
+
+
Sync on close
-
+
true
- -
-
-
+
-
+
+
QLineEdit::Password
- -
-
-
+
-
+
+
Sync on open
-
+
true
@@ -234,61 +235,61 @@
-
-
-
- <h1>Proxy</h1>
+
+
+ <h1>Proxy</h1>
-
-
-
+
+
6
-
-
-
-
+
-
+
+
Host
- -
-
+
-
+
- -
-
-
+
-
+
+
Username
- -
-
+
-
+
- -
-
-
+
-
+
+
Password
- -
-
-
+
-
+
+
QLineEdit::Password
- -
-
-
+
-
+
+
Port
- -
-
-
+
-
+
+
60
0
@@ -299,11 +300,11 @@
-
-
-
+
+
Qt::Vertical
-
+
20
40
@@ -312,50 +313,50 @@
-
-
-
+
+
Some settings will take effect after you restart Anki.
-
+
Qt::AlignCenter
-
-
+
+
Saving
-
-
+
+
10
-
-
-
- <h1>Autosaving</h1>
+
+
+ <h1>Autosaving</h1>
-
-
-
+
+
6
-
-
-
-
+
-
+
+
Save after answering
-
+
true
- -
-
-
+
-
+
+
60
16777215
@@ -363,19 +364,19 @@
- -
-
-
+
-
+
+
Save after adding
-
+
true
- -
-
-
+
-
+
+
60
16777215
@@ -383,26 +384,26 @@
- -
-
-
+
-
+
+
Save when closing
-
+
true
- -
-
-
+
-
+
+
cards
- -
-
-
+
-
+
+
facts
@@ -410,33 +411,33 @@
-
-
-
- <h1>Backups</h1>Decks are backed up when they are opened, and only if they have been modified since the last backup.
+
+
+ <h1>Backups</h1>Decks are backed up when they are opened, and only if they have been modified since the last backup.
-
+
true
-
-
-
-
-
-
+
+
-
+
+
Keep
- -
-
-
+
-
+
+
60
0
-
+
60
16777215
@@ -444,19 +445,19 @@
- -
-
-
+
-
+
+
backups of each deck
- -
-
-
+
-
+
+
Qt::Horizontal
-
+
40
20
@@ -467,18 +468,18 @@
-
-
-
- <a href="backups">Open backup folder</a>
+
+
+ <a href="backups">Open backup folder</a>
-
-
-
+
+
Qt::Vertical
-
+
20
59
@@ -487,47 +488,47 @@
-
-
-
+
+
Some settings will take effect after you restart Anki.
-
+
Qt::AlignCenter
-
-
+
+
Advanced
-
+
-
-
-
-
-
-
- <h1>Advanced settings</h1>
+
+
-
+
+
+ <h1>Advanced settings</h1>
- -
-
-
+
-
+
+
Show timer
- -
-
-
+
-
+
+
Qt::Vertical
-
+
QSizePolicy::Fixed
-
+
20
10
@@ -535,38 +536,45 @@
- -
-
-
+
-
+
+
Alternative theme
- -
-
-
+
-
+
+
Show study options on deck load
- -
-
-
+
-
+
+
Show tray icon
- -
-
-
+
-
+
+
Add hidden char to text (fixes Thai on OSX)
- -
-
-
- Open last deck even when multiple decks available
+
-
+
+
+ Always open last deck on startup
+
+
+
+ -
+
+
+ Show decks with cards due first in browser
@@ -574,10 +582,10 @@
-
-
+
Qt::Vertical
-
+
20
40
@@ -586,11 +594,11 @@
-
-
-
+
+
Some settings will take effect after you restart Anki.
-
+
Qt::AlignCenter
@@ -600,11 +608,11 @@
-
-
-
+
+
Qt::Horizontal
-
+
QDialogButtonBox::Close|QDialogButtonBox::Help
@@ -639,6 +647,7 @@
showTray
showStudyOptions
openLastDeck
+ deckBrowserOrder
addZeroSpace
buttonBox
@@ -650,11 +659,11 @@
Preferences
accept()
-
+
270
412
-
+
157
274
@@ -666,11 +675,11 @@
Preferences
reject()
-
+
317
412
-
+
286
274