mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 16:56:36 -04:00
Enable renaming from dyndeck dialogue
This commit is contained in:
parent
8065e73ef8
commit
4666ba8b70
2 changed files with 95 additions and 42 deletions
|
@ -5,10 +5,10 @@ from typing import Callable, List, Optional
|
|||
|
||||
import aqt
|
||||
from anki.collection import SearchTerm
|
||||
from anki.decks import Deck
|
||||
from anki.decks import Deck, DeckRenameError
|
||||
from anki.errors import InvalidInput
|
||||
from anki.lang import without_unicode_isolation
|
||||
from aqt import AnkiQt
|
||||
from aqt import AnkiQt, gui_hooks
|
||||
from aqt.qt import *
|
||||
from aqt.theme import theme_manager
|
||||
from aqt.utils import (
|
||||
|
@ -65,6 +65,8 @@ class DeckConf(QDialog):
|
|||
self.loadConf()
|
||||
self.set_default_searches(self.old_deck["name"])
|
||||
|
||||
self.form.name.setText(self.deck["name"])
|
||||
self.form.name.setPlaceholderText(self.deck["name"])
|
||||
self.set_custom_searches(search, search_2)
|
||||
qconnect(self.form.search_button.clicked, self.on_search_button)
|
||||
qconnect(self.form.search_button_2.clicked, self.on_search_button_2)
|
||||
|
@ -202,6 +204,11 @@ class DeckConf(QDialog):
|
|||
def saveConf(self):
|
||||
f = self.form
|
||||
d = self.deck
|
||||
|
||||
if f.name.text() and d["name"] != f.name.text():
|
||||
self.mw.col.decks.rename(d, f.name.text())
|
||||
gui_hooks.sidebar_should_refresh_decks()
|
||||
|
||||
d["resched"] = f.resched.isChecked()
|
||||
d["delays"] = None
|
||||
|
||||
|
@ -236,8 +243,9 @@ class DeckConf(QDialog):
|
|||
try:
|
||||
self.saveConf()
|
||||
except InvalidInput as err:
|
||||
show_invalid_search_error(err)
|
||||
return
|
||||
return show_invalid_search_error(err)
|
||||
except DeckRenameError as err:
|
||||
return showWarning(err.description)
|
||||
if not self.mw.col.sched.rebuild_filtered_deck(self.deck["id"]):
|
||||
if askUser(tr(TR.DECKS_THE_PROVIDED_SEARCH_DID_NOT_MATCH)):
|
||||
return
|
||||
|
|
|
@ -6,24 +6,75 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>416</width>
|
||||
<height>472</height>
|
||||
<width>757</width>
|
||||
<height>589</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true">Dialog</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_3">
|
||||
<property name="title">
|
||||
<string>DECKS_DECK</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_4">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>ACTIONS_NAME</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QLineEdit" name="name">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Minimum</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>ACTIONS_FILTER</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<item row="1" column="0">
|
||||
<widget class="QPushButton" name="search_button">
|
||||
<property name="toolTip">
|
||||
<string>SEARCH_VIEW_IN_BROWSER</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>DECKS_LIMIT_TO</string>
|
||||
<string>ACTIONS_SEARCH</string>
|
||||
</property>
|
||||
<property name="autoDefault">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="flat">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -56,8 +107,24 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QPushButton" name="search_button">
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>DECKS_LIMIT_TO</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="filter2group">
|
||||
<property name="title">
|
||||
<string>DECKS_FILTER_2</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="0">
|
||||
<widget class="QPushButton" name="search_button_2">
|
||||
<property name="toolTip">
|
||||
<string>SEARCH_VIEW_IN_BROWSER</string>
|
||||
</property>
|
||||
|
@ -72,15 +139,9 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<item row="0" column="1" colspan="4">
|
||||
<widget class="QLineEdit" name="search_2"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="filter2group">
|
||||
<property name="title">
|
||||
<string>DECKS_FILTER_2</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
|
@ -88,12 +149,6 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="3" colspan="2">
|
||||
<widget class="QComboBox" name="order_2"/>
|
||||
</item>
|
||||
<item row="0" column="1" colspan="4">
|
||||
<widget class="QLineEdit" name="search_2"/>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QSpinBox" name="limit_2">
|
||||
<property name="maximumSize">
|
||||
|
@ -110,6 +165,9 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="3" colspan="2">
|
||||
<widget class="QComboBox" name="order_2"/>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
|
@ -117,22 +175,6 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QPushButton" name="search_button_2">
|
||||
<property name="toolTip">
|
||||
<string>SEARCH_VIEW_IN_BROWSER</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>ACTIONS_SEARCH</string>
|
||||
</property>
|
||||
<property name="autoDefault">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="flat">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -228,9 +270,12 @@
|
|||
</layout>
|
||||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>name</tabstop>
|
||||
<tabstop>search_button</tabstop>
|
||||
<tabstop>search</tabstop>
|
||||
<tabstop>limit</tabstop>
|
||||
<tabstop>order</tabstop>
|
||||
<tabstop>search_button_2</tabstop>
|
||||
<tabstop>search_2</tabstop>
|
||||
<tabstop>limit_2</tabstop>
|
||||
<tabstop>order_2</tabstop>
|
||||
|
|
Loading…
Reference in a new issue