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
|
import aqt
|
||||||
from anki.collection import SearchTerm
|
from anki.collection import SearchTerm
|
||||||
from anki.decks import Deck
|
from anki.decks import Deck, DeckRenameError
|
||||||
from anki.errors import InvalidInput
|
from anki.errors import InvalidInput
|
||||||
from anki.lang import without_unicode_isolation
|
from anki.lang import without_unicode_isolation
|
||||||
from aqt import AnkiQt
|
from aqt import AnkiQt, gui_hooks
|
||||||
from aqt.qt import *
|
from aqt.qt import *
|
||||||
from aqt.theme import theme_manager
|
from aqt.theme import theme_manager
|
||||||
from aqt.utils import (
|
from aqt.utils import (
|
||||||
|
@ -65,6 +65,8 @@ class DeckConf(QDialog):
|
||||||
self.loadConf()
|
self.loadConf()
|
||||||
self.set_default_searches(self.old_deck["name"])
|
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)
|
self.set_custom_searches(search, search_2)
|
||||||
qconnect(self.form.search_button.clicked, self.on_search_button)
|
qconnect(self.form.search_button.clicked, self.on_search_button)
|
||||||
qconnect(self.form.search_button_2.clicked, self.on_search_button_2)
|
qconnect(self.form.search_button_2.clicked, self.on_search_button_2)
|
||||||
|
@ -202,6 +204,11 @@ class DeckConf(QDialog):
|
||||||
def saveConf(self):
|
def saveConf(self):
|
||||||
f = self.form
|
f = self.form
|
||||||
d = self.deck
|
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["resched"] = f.resched.isChecked()
|
||||||
d["delays"] = None
|
d["delays"] = None
|
||||||
|
|
||||||
|
@ -236,8 +243,9 @@ class DeckConf(QDialog):
|
||||||
try:
|
try:
|
||||||
self.saveConf()
|
self.saveConf()
|
||||||
except InvalidInput as err:
|
except InvalidInput as err:
|
||||||
show_invalid_search_error(err)
|
return show_invalid_search_error(err)
|
||||||
return
|
except DeckRenameError as err:
|
||||||
|
return showWarning(err.description)
|
||||||
if not self.mw.col.sched.rebuild_filtered_deck(self.deck["id"]):
|
if not self.mw.col.sched.rebuild_filtered_deck(self.deck["id"]):
|
||||||
if askUser(tr(TR.DECKS_THE_PROVIDED_SEARCH_DID_NOT_MATCH)):
|
if askUser(tr(TR.DECKS_THE_PROVIDED_SEARCH_DID_NOT_MATCH)):
|
||||||
return
|
return
|
||||||
|
|
|
@ -6,24 +6,75 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>416</width>
|
<width>757</width>
|
||||||
<height>472</height>
|
<height>589</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string notr="true">Dialog</string>
|
<string notr="true">Dialog</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<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>
|
<item>
|
||||||
<widget class="QGroupBox" name="groupBox">
|
<widget class="QGroupBox" name="groupBox">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>ACTIONS_FILTER</string>
|
<string>ACTIONS_FILTER</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<item row="2" column="0">
|
<item row="1" column="0">
|
||||||
<widget class="QLabel" name="label_5">
|
<widget class="QPushButton" name="search_button">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>SEARCH_VIEW_IN_BROWSER</string>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<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>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -56,8 +107,24 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0">
|
<item row="2" column="0">
|
||||||
<widget class="QPushButton" name="search_button">
|
<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">
|
<property name="toolTip">
|
||||||
<string>SEARCH_VIEW_IN_BROWSER</string>
|
<string>SEARCH_VIEW_IN_BROWSER</string>
|
||||||
</property>
|
</property>
|
||||||
|
@ -72,15 +139,9 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
<item row="0" column="1" colspan="4">
|
||||||
</widget>
|
<widget class="QLineEdit" name="search_2"/>
|
||||||
</item>
|
</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">
|
<item row="1" column="0">
|
||||||
<widget class="QLabel" name="label_6">
|
<widget class="QLabel" name="label_6">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
@ -88,12 +149,6 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</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">
|
<item row="1" column="1">
|
||||||
<widget class="QSpinBox" name="limit_2">
|
<widget class="QSpinBox" name="limit_2">
|
||||||
<property name="maximumSize">
|
<property name="maximumSize">
|
||||||
|
@ -110,6 +165,9 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="1" column="3" colspan="2">
|
||||||
|
<widget class="QComboBox" name="order_2"/>
|
||||||
|
</item>
|
||||||
<item row="1" column="2">
|
<item row="1" column="2">
|
||||||
<widget class="QLabel" name="label_4">
|
<widget class="QLabel" name="label_4">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
@ -117,22 +175,6 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</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>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -228,9 +270,12 @@
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<tabstops>
|
<tabstops>
|
||||||
|
<tabstop>name</tabstop>
|
||||||
|
<tabstop>search_button</tabstop>
|
||||||
<tabstop>search</tabstop>
|
<tabstop>search</tabstop>
|
||||||
<tabstop>limit</tabstop>
|
<tabstop>limit</tabstop>
|
||||||
<tabstop>order</tabstop>
|
<tabstop>order</tabstop>
|
||||||
|
<tabstop>search_button_2</tabstop>
|
||||||
<tabstop>search_2</tabstop>
|
<tabstop>search_2</tabstop>
|
||||||
<tabstop>limit_2</tabstop>
|
<tabstop>limit_2</tabstop>
|
||||||
<tabstop>order_2</tabstop>
|
<tabstop>order_2</tabstop>
|
||||||
|
|
Loading…
Reference in a new issue