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.updateHelp()
|
||||||
self.updateText(self.conf)
|
self.updateText(self.conf)
|
||||||
restoreGeom(self, "addonconf")
|
restoreGeom(self, "addonconf")
|
||||||
|
self.form.splitter.setSizes([2 * self.width() // 3, self.width() // 3])
|
||||||
restoreSplitter(self.form.splitter, "addonconf")
|
restoreSplitter(self.form.splitter, "addonconf")
|
||||||
self.setWindowTitle(
|
self.setWindowTitle(
|
||||||
without_unicode_isolation(
|
without_unicode_isolation(
|
||||||
|
@ -1574,9 +1575,9 @@ class ConfigEditor(QDialog):
|
||||||
def updateHelp(self) -> None:
|
def updateHelp(self) -> None:
|
||||||
txt = self.mgr.addonConfigHelp(self.addon)
|
txt = self.mgr.addonConfigHelp(self.addon)
|
||||||
if txt:
|
if txt:
|
||||||
self.form.label.setText(txt)
|
self.form.help.stdHtml(txt, js=[], css=["css/addonconf.css"], context=self)
|
||||||
else:
|
else:
|
||||||
self.form.scrollArea.setVisible(False)
|
self.form.help.setVisible(False)
|
||||||
|
|
||||||
def updateText(self, conf: dict[str, Any]) -> None:
|
def updateText(self, conf: dict[str, Any]) -> None:
|
||||||
text = json.dumps(
|
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>
|
<enum>QPlainTextEdit::NoWrap</enum>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QScrollArea" name="scrollArea">
|
<widget class="AnkiWebView" name="help" native="true">
|
||||||
<property name="sizePolicy">
|
<property name="url" stdset="0">
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
<url>
|
||||||
<horstretch>1</horstretch>
|
<string>about:blank</string>
|
||||||
<verstretch>0</verstretch>
|
</url>
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
</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>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -107,6 +54,14 @@
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
<customwidgets>
|
||||||
|
<customwidget>
|
||||||
|
<class>AnkiWebView</class>
|
||||||
|
<extends>QWidget</extends>
|
||||||
|
<header location="global">aqt/webview</header>
|
||||||
|
<container>1</container>
|
||||||
|
</customwidget>
|
||||||
|
</customwidgets>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections>
|
<connections>
|
||||||
<connection>
|
<connection>
|
||||||
|
|
Loading…
Reference in a new issue