mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
Use a webview to show add-on's config help (#2281)
* Use a webview to show add-on's config help This allows add-ons to embed images for example. * Improve initial size of splitter widgets * Decrease font size and margin of webview
This commit is contained in:
parent
9cb54ad797
commit
46c0c281f8
3 changed files with 23 additions and 60 deletions
|
@ -1550,6 +1550,7 @@ class ConfigEditor(QDialog):
|
|||
self.updateHelp()
|
||||
self.updateText(self.conf)
|
||||
restoreGeom(self, "addonconf")
|
||||
self.form.splitter.setSizes([2 * self.width() // 3, self.width() // 3])
|
||||
restoreSplitter(self.form.splitter, "addonconf")
|
||||
self.setWindowTitle(
|
||||
without_unicode_isolation(
|
||||
|
@ -1574,9 +1575,9 @@ class ConfigEditor(QDialog):
|
|||
def updateHelp(self) -> None:
|
||||
txt = self.mgr.addonConfigHelp(self.addon)
|
||||
if txt:
|
||||
self.form.label.setText(txt)
|
||||
self.form.help.stdHtml(txt, js=[], css=["css/addonconf.css"], context=self)
|
||||
else:
|
||||
self.form.scrollArea.setVisible(False)
|
||||
self.form.help.setVisible(False)
|
||||
|
||||
def updateText(self, conf: dict[str, Any]) -> None:
|
||||
text = json.dumps(
|
||||
|
|
7
qt/aqt/data/web/css/addonconf.scss
Normal file
7
qt/aqt/data/web/css/addonconf.scss
Normal file
|
@ -0,0 +1,7 @@
|
|||
/* Copyright: Ankitects Pty Ltd and contributors
|
||||
* License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html */
|
||||
|
||||
body {
|
||||
margin: 5px;
|
||||
font-size: 13px;
|
||||
}
|
|
@ -33,65 +33,12 @@
|
|||
<enum>QPlainTextEdit::NoWrap</enum>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QScrollArea" name="scrollArea">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
<widget class="AnkiWebView" name="help" native="true">
|
||||
<property name="url" stdset="0">
|
||||
<url>
|
||||
<string>about:blank</string>
|
||||
</url>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="widgetResizable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<widget class="QWidget" name="scrollAreaWidgetContents">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>80</width>
|
||||
<height>470</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<property name="leftMargin">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::RichText</enum>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="openExternalLinks">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -107,6 +54,14 @@
|
|||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>AnkiWebView</class>
|
||||
<extends>QWidget</extends>
|
||||
<header location="global">aqt/webview</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
|
|
Loading…
Reference in a new issue