mirror of
https://github.com/ankitects/anki.git
synced 2025-09-21 07:22:23 -04:00
Merge branch 'master' of https://github.com/hssm/anki
This commit is contained in:
commit
380080416f
6 changed files with 110 additions and 22 deletions
100
aqt/browser.py
100
aqt/browser.py
|
@ -513,6 +513,9 @@ class Browser(QMainWindow):
|
||||||
self.setTabOrder(self.form.searchEdit, self.form.tableView)
|
self.setTabOrder(self.form.searchEdit, self.form.tableView)
|
||||||
self.form.searchEdit.setCompleter(None)
|
self.form.searchEdit.setCompleter(None)
|
||||||
self.form.searchEdit.addItems(self.mw.pm.profile['searchHistory'])
|
self.form.searchEdit.addItems(self.mw.pm.profile['searchHistory'])
|
||||||
|
self.connect(self.form.searchEdit.lineEdit(),
|
||||||
|
SIGNAL("returnPressed()"),
|
||||||
|
self.onSearch)
|
||||||
|
|
||||||
def onSearch(self, reset=True):
|
def onSearch(self, reset=True):
|
||||||
"Careful: if reset is true, the current note is saved."
|
"Careful: if reset is true, the current note is saved."
|
||||||
|
@ -753,6 +756,7 @@ by clicking on one on the left."""))
|
||||||
self.form.tree.clear()
|
self.form.tree.clear()
|
||||||
root = self.form.tree
|
root = self.form.tree
|
||||||
self._systemTagTree(root)
|
self._systemTagTree(root)
|
||||||
|
self._favTree(root)
|
||||||
self._decksTree(root)
|
self._decksTree(root)
|
||||||
self._modelTree(root)
|
self._modelTree(root)
|
||||||
self._userTagTree(root)
|
self._userTagTree(root)
|
||||||
|
@ -815,6 +819,18 @@ by clicking on one on the left."""))
|
||||||
item.setIcon(0, QIcon(":/icons/" + icon))
|
item.setIcon(0, QIcon(":/icons/" + icon))
|
||||||
return root
|
return root
|
||||||
|
|
||||||
|
def _favTree(self, root):
|
||||||
|
saved = self.col.conf.get('savedFilters', [])
|
||||||
|
if not saved:
|
||||||
|
# Don't add favourites to tree if none saved
|
||||||
|
return
|
||||||
|
root = self.CallbackItem(root, _("My Searches"), None)
|
||||||
|
root.setExpanded(True)
|
||||||
|
root.setIcon(0, QIcon(":/icons/emblem-favorite-dark.png"))
|
||||||
|
for name, filt in saved.items():
|
||||||
|
item = self.CallbackItem(root, name, lambda s=filt: self.setFilter(s))
|
||||||
|
item.setIcon(0, QIcon(":/icons/emblem-favorite-dark.png"))
|
||||||
|
|
||||||
def _userTagTree(self, root):
|
def _userTagTree(self, root):
|
||||||
for t in sorted(self.col.tags.all()):
|
for t in sorted(self.col.tags.all()):
|
||||||
if t.lower() == "marked" or t.lower() == "leech":
|
if t.lower() == "marked" or t.lower() == "leech":
|
||||||
|
@ -1723,3 +1739,87 @@ a { margin-right: 1em; }
|
||||||
self.browser.addTags()
|
self.browser.addTags()
|
||||||
elif l == "deletetag":
|
elif l == "deletetag":
|
||||||
self.browser.deleteTags()
|
self.browser.deleteTags()
|
||||||
|
|
||||||
|
|
||||||
|
# Favourites button
|
||||||
|
######################################################################
|
||||||
|
class FavouritesLineEdit(QLineEdit):
|
||||||
|
buttonClicked = pyqtSignal(bool)
|
||||||
|
|
||||||
|
def __init__(self, mw, browser, parent=None):
|
||||||
|
super(FavouritesLineEdit, self).__init__(parent)
|
||||||
|
self.mw = mw
|
||||||
|
self.browser = browser
|
||||||
|
# add conf if missing
|
||||||
|
if not self.mw.col.conf.has_key('savedFilters'):
|
||||||
|
self.mw.col.conf['savedFilters'] = {}
|
||||||
|
self.button = QToolButton(self)
|
||||||
|
self.button.setStyleSheet('border: 0px;')
|
||||||
|
self.button.setCursor(Qt.ArrowCursor)
|
||||||
|
self.button.clicked.connect(self.buttonClicked.emit)
|
||||||
|
self.setIcon(':/icons/emblem-favorite-off.png')
|
||||||
|
# flag to raise save or delete dialog on button click
|
||||||
|
self.doSave = True
|
||||||
|
# name of current saved filter (if query matches)
|
||||||
|
self.name = None
|
||||||
|
self.buttonClicked.connect(self.onClicked)
|
||||||
|
self.connect(self, SIGNAL("textEdited(QString)"), self.updateButton)
|
||||||
|
|
||||||
|
def resizeEvent(self, event):
|
||||||
|
buttonSize = self.button.sizeHint()
|
||||||
|
frameWidth = self.style().pixelMetric(QStyle.PM_DefaultFrameWidth)
|
||||||
|
self.button.move(self.rect().right() - frameWidth - buttonSize.width(),
|
||||||
|
(self.rect().bottom() - buttonSize.height() + 1) / 2)
|
||||||
|
super(FavouritesLineEdit, self).resizeEvent(event)
|
||||||
|
|
||||||
|
def setIcon(self, path):
|
||||||
|
self.button.setIcon(QIcon(path))
|
||||||
|
|
||||||
|
def setText(self, txt):
|
||||||
|
super(FavouritesLineEdit, self).setText(txt)
|
||||||
|
self.updateButton()
|
||||||
|
|
||||||
|
def updateButton(self, reset=True):
|
||||||
|
# If search text is a saved query, switch to the delete button.
|
||||||
|
# Otherwise show save button.
|
||||||
|
txt = unicode(self.text()).strip()
|
||||||
|
for key, value in self.mw.col.conf['savedFilters'].items():
|
||||||
|
if txt == value:
|
||||||
|
self.doSave = False
|
||||||
|
self.name = key
|
||||||
|
self.setIcon(QIcon(":/icons/emblem-favorite.png"))
|
||||||
|
return
|
||||||
|
self.doSave = True
|
||||||
|
self.setIcon(QIcon(":/icons/emblem-favorite-off.png"))
|
||||||
|
|
||||||
|
def onClicked(self):
|
||||||
|
if self.doSave:
|
||||||
|
self.saveClicked()
|
||||||
|
else:
|
||||||
|
self.deleteClicked()
|
||||||
|
|
||||||
|
def saveClicked(self):
|
||||||
|
txt = unicode(self.text()).strip()
|
||||||
|
dlg = QInputDialog(self)
|
||||||
|
dlg.setInputMode(QInputDialog.TextInput)
|
||||||
|
dlg.setLabelText(_("The current search terms will be added as a new "
|
||||||
|
"item in the sidebar.\n"
|
||||||
|
"Search name:"))
|
||||||
|
dlg.setWindowTitle(_("Save search"))
|
||||||
|
ok = dlg.exec_()
|
||||||
|
name = dlg.textValue()
|
||||||
|
if ok:
|
||||||
|
self.mw.col.conf['savedFilters'][name] = txt
|
||||||
|
|
||||||
|
self.updateButton()
|
||||||
|
self.browser.setupTree()
|
||||||
|
|
||||||
|
def deleteClicked(self):
|
||||||
|
msg = _('Remove "%s" from your saved searches?') % self.name
|
||||||
|
ok = QMessageBox.question(self, _('Remove search'),
|
||||||
|
msg, QMessageBox.Yes, QMessageBox.No)
|
||||||
|
|
||||||
|
if ok == QMessageBox.Yes:
|
||||||
|
self.mw.col.conf['savedFilters'].pop(self.name, None)
|
||||||
|
self.updateButton()
|
||||||
|
self.browser.setupTree()
|
||||||
|
|
|
@ -79,6 +79,9 @@ class ImportDialog(QDialog):
|
||||||
self.updateDelimiterButtonText()
|
self.updateDelimiterButtonText()
|
||||||
self.frm.allowHTML.setChecked(self.mw.pm.profile.get('allowHTML', True))
|
self.frm.allowHTML.setChecked(self.mw.pm.profile.get('allowHTML', True))
|
||||||
self.frm.importMode.setCurrentIndex(self.mw.pm.profile.get('importMode', 1))
|
self.frm.importMode.setCurrentIndex(self.mw.pm.profile.get('importMode', 1))
|
||||||
|
# import button
|
||||||
|
b = QPushButton(_("Import"))
|
||||||
|
self.frm.buttonBox.addButton(b, QDialogButtonBox.AcceptRole)
|
||||||
self.exec_()
|
self.exec_()
|
||||||
|
|
||||||
def setupOptions(self):
|
def setupOptions(self):
|
||||||
|
@ -87,8 +90,6 @@ class ImportDialog(QDialog):
|
||||||
self.mw, self.frm.modelArea, label=False)
|
self.mw, self.frm.modelArea, label=False)
|
||||||
self.deck = aqt.deckchooser.DeckChooser(
|
self.deck = aqt.deckchooser.DeckChooser(
|
||||||
self.mw, self.frm.deckArea, label=False)
|
self.mw, self.frm.deckArea, label=False)
|
||||||
self.connect(self.frm.importButton, SIGNAL("clicked()"),
|
|
||||||
self.doImport)
|
|
||||||
|
|
||||||
def modelChanged(self):
|
def modelChanged(self):
|
||||||
self.importer.model = self.mw.col.models.current()
|
self.importer.model = self.mw.col.models.current()
|
||||||
|
@ -139,7 +140,7 @@ you can enter it here. Use \\t to represent tab."""),
|
||||||
txt = _("Fields separated by: %s") % d
|
txt = _("Fields separated by: %s") % d
|
||||||
self.frm.autoDetect.setText(txt)
|
self.frm.autoDetect.setText(txt)
|
||||||
|
|
||||||
def doImport(self, update=False):
|
def accept(self):
|
||||||
self.importer.mapping = self.mapping
|
self.importer.mapping = self.mapping
|
||||||
if not self.importer.mappingOk():
|
if not self.importer.mappingOk():
|
||||||
showWarning(
|
showWarning(
|
||||||
|
@ -249,7 +250,7 @@ you can enter it here. Use \\t to represent tab."""),
|
||||||
QDialog.reject(self)
|
QDialog.reject(self)
|
||||||
|
|
||||||
def helpRequested(self):
|
def helpRequested(self):
|
||||||
openHelp("FileImport")
|
openHelp("importing")
|
||||||
|
|
||||||
|
|
||||||
def showUnicodeWarning():
|
def showUnicodeWarning():
|
||||||
|
|
|
@ -35,6 +35,8 @@
|
||||||
<file>icons/editclear.png</file>
|
<file>icons/editclear.png</file>
|
||||||
<file>icons/view-statistics.png</file>
|
<file>icons/view-statistics.png</file>
|
||||||
<file>icons/emblem-favorite.png</file>
|
<file>icons/emblem-favorite.png</file>
|
||||||
|
<file>icons/emblem-favorite-dark.png</file>
|
||||||
|
<file>icons/emblem-favorite-off.png</file>
|
||||||
<file>icons/view-pim-calendar.png</file>
|
<file>icons/view-pim-calendar.png</file>
|
||||||
<file>icons/anki-tag.png</file>
|
<file>icons/anki-tag.png</file>
|
||||||
<file>icons/edit-redo.png</file>
|
<file>icons/edit-redo.png</file>
|
||||||
|
|
BIN
designer/icons/emblem-favorite-dark.png
Normal file
BIN
designer/icons/emblem-favorite-dark.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.3 KiB |
BIN
designer/icons/emblem-favorite-off.png
Normal file
BIN
designer/icons/emblem-favorite-off.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.1 KiB |
|
@ -94,20 +94,6 @@
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
<item>
|
<item>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<item row="0" column="1">
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="importButton">
|
|
||||||
<property name="text">
|
|
||||||
<string>&Import</string>
|
|
||||||
</property>
|
|
||||||
<property name="default">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QScrollArea" name="mappingArea">
|
<widget class="QScrollArea" name="mappingArea">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
|
@ -133,8 +119,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>402</width>
|
<width>529</width>
|
||||||
<height>206</height>
|
<height>251</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
|
@ -158,7 +144,6 @@
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<tabstops>
|
<tabstops>
|
||||||
<tabstop>importButton</tabstop>
|
|
||||||
<tabstop>buttonBox</tabstop>
|
<tabstop>buttonBox</tabstop>
|
||||||
</tabstops>
|
</tabstops>
|
||||||
<resources/>
|
<resources/>
|
||||||
|
|
Loading…
Reference in a new issue