convert setWindowFlags call into helper, and fix invalid variables

"type: ignore" was masking the invalid references to self in places
like showText()
This commit is contained in:
Damien Elmes 2021-01-07 14:24:49 +10:00
parent a1c17d114a
commit 94064b8230
27 changed files with 124 additions and 58 deletions

View file

@ -9,7 +9,7 @@ from anki.lang import without_unicode_isolation
from anki.utils import versionWithBuild
from aqt.addons import AddonManager, AddonMeta
from aqt.qt import *
from aqt.utils import TR, supportText, tooltip, tr
from aqt.utils import TR, disable_help_button, supportText, tooltip, tr
class ClosableQDialog(QDialog):
@ -28,7 +28,7 @@ class ClosableQDialog(QDialog):
def show(mw):
dialog = ClosableQDialog(mw)
dialog.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint) # type: ignore
disable_help_button(dialog)
mw.setupDialogGC(dialog)
abt = aqt.forms.about.Ui_About()
abt.setupUi(dialog)

View file

@ -18,6 +18,7 @@ from aqt.utils import (
TR,
addCloseShortcut,
askUser,
disable_help_button,
downArrow,
openHelp,
restoreGeom,
@ -37,7 +38,7 @@ class AddCards(QDialog):
self.form = aqt.forms.addcards.Ui_Dialog()
self.form.setupUi(self)
self.setWindowTitle(tr(TR.ACTIONS_ADD))
self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint) # type: ignore
disable_help_button(self)
self.setMinimumHeight(300)
self.setMinimumWidth(400)
self.setupChoosers()

View file

@ -30,6 +30,7 @@ from aqt.qt import *
from aqt.utils import (
TR,
askUser,
disable_help_button,
getFile,
isWin,
openFolder,
@ -705,7 +706,7 @@ class AddonsDialog(QDialog):
qconnect(self.form.addonList.itemDoubleClicked, self.onConfig)
qconnect(self.form.addonList.currentRowChanged, self._onAddonItemSelected)
self.setWindowTitle(tr(TR.ADDONS_WINDOW_TITLE))
self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint) # type: ignore
disable_help_button(self)
self.setAcceptDrops(True)
self.redrawAddons()
restoreGeom(self, "addons")
@ -918,7 +919,7 @@ class GetAddons(QDialog):
tr(TR.ADDONS_BROWSE_ADDONS), QDialogButtonBox.ActionRole
)
qconnect(b.clicked, self.onBrowse)
self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint) # type: ignore
disable_help_button(self)
restoreGeom(self, "getaddons", adjustSize=True)
self.exec_()
saveGeom(self, "getaddons")
@ -1296,7 +1297,7 @@ class ConfigEditor(QDialog):
)
)
)
self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint) # type: ignore
disable_help_button(self)
self.show()
def onRestoreDefaults(self) -> None:

View file

@ -38,6 +38,7 @@ from aqt.utils import (
MenuList,
SubMenu,
askUser,
disable_help_button,
getOnlyText,
getTag,
openHelp,
@ -1755,7 +1756,7 @@ where id in %s"""
if not cids2:
return showInfo(tr(TR.BROWSING_ONLY_NEW_CARDS_CAN_BE_REPOSITIONED))
d = QDialog(self)
d.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint) # type: ignore
disable_help_button(d)
d.setWindowModality(Qt.WindowModal)
frm = aqt.forms.reposition.Ui_Dialog()
frm.setupUi(d)
@ -1791,7 +1792,7 @@ where id in %s"""
def _reschedule(self):
d = QDialog(self)
d.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint) # type: ignore
disable_help_button(d)
d.setWindowModality(Qt.WindowModal)
frm = aqt.forms.reschedule.Ui_Dialog()
frm.setupUi(d)
@ -1891,7 +1892,7 @@ where id in %s"""
def _on_find_replace_diag(self, fields: List[str], nids: List[int]) -> None:
d = QDialog(self)
d.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint) # type: ignore
disable_help_button(d)
frm = aqt.forms.findreplace.Ui_Dialog()
frm.setupUi(d)
d.setWindowModality(Qt.WindowModal)
@ -1975,7 +1976,7 @@ where id in %s"""
frm = aqt.forms.finddupes.Ui_Dialog()
frm.setupUi(d)
restoreGeom(d, "findDupes")
d.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint) # type: ignore
disable_help_button(d)
searchHistory = restore_combo_history(frm.search, "findDupesFind")
fields = sorted(
@ -2141,7 +2142,7 @@ class ChangeModel(QDialog):
self.oldModel = browser.card.note().model()
self.form = aqt.forms.changemodel.Ui_Dialog()
self.form.setupUi(self)
self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint) # type: ignore
disable_help_button(self)
self.setWindowModality(Qt.WindowModal)
self.setup()
restoreGeom(self, "changeModel")
@ -2317,7 +2318,7 @@ class CardInfoDialog(QDialog):
def __init__(self, browser: Browser, *args, **kwargs):
super().__init__(browser, *args, **kwargs)
self.browser = browser
self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint) # type: ignore
disable_help_button(self)
def reject(self):
saveGeom(self, "revlog")

View file

@ -21,6 +21,7 @@ from aqt.theme import theme_manager
from aqt.utils import (
TR,
askUser,
disable_help_button,
downArrow,
getOnlyText,
openHelp,
@ -71,7 +72,7 @@ class CardLayout(QDialog):
tr(TR.CARD_TEMPLATES_CARD_TYPES_FOR, val=self.model["name"])
)
)
self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint) # type: ignore
disable_help_button(self)
v1 = QVBoxLayout()
v1.addWidget(self.topArea)
v1.addWidget(self.mainArea)
@ -701,7 +702,7 @@ class CardLayout(QDialog):
def onBrowserDisplay(self):
d = QDialog()
d.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint) # type: ignore
disable_help_button(d)
f = aqt.forms.browserdisp.Ui_Dialog()
f.setupUi(d)
t = self.current_template()
@ -733,7 +734,7 @@ class CardLayout(QDialog):
t = self.current_template()
d = QDialog(self)
d.setWindowTitle("Anki")
d.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint) # type: ignore
disable_help_button(d)
d.setMinimumWidth(400)
l = QVBoxLayout()
lab = QLabel(
@ -763,7 +764,7 @@ class CardLayout(QDialog):
diag = QDialog(self)
form = aqt.forms.addfield.Ui_Dialog()
form.setupUi(diag)
diag.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint) # type: ignore
disable_help_button(diag)
fields = [f["name"] for f in self.model["flds"]]
form.fields.addItems(fields)
form.fields.setCurrentRow(0)

View file

@ -4,7 +4,7 @@
import aqt
from anki.consts import *
from aqt.qt import *
from aqt.utils import TR, showInfo, showWarning, tr
from aqt.utils import TR, disable_help_button, showInfo, showWarning, tr
RADIO_NEW = 1
RADIO_REV = 2
@ -28,7 +28,7 @@ class CustomStudy(QDialog):
self.form = f = aqt.forms.customstudy.Ui_Dialog()
self.created_custom_study = False
f.setupUi(self)
self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint) # type: ignore
disable_help_button(self)
self.setWindowModality(Qt.WindowModal)
self.setupSignals()
f.radioNew.click()

View file

@ -14,6 +14,7 @@ from aqt.qt import *
from aqt.utils import (
TR,
askUser,
disable_help_button,
getOnlyText,
openHelp,
restoreGeom,
@ -48,7 +49,7 @@ class DeckConf(QDialog):
self.setWindowTitle(
without_unicode_isolation(tr(TR.ACTIONS_OPTIONS_FOR, val=self.deck["name"]))
)
self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint) # type: ignore
disable_help_button(self)
# qt doesn't size properly with altered fonts otherwise
restoreGeom(self, "deckconf", adjustSize=True)
gui_hooks.deck_conf_will_show(self)

View file

@ -6,7 +6,16 @@ from typing import List, Optional
import aqt
from anki.lang import without_unicode_isolation
from aqt.qt import *
from aqt.utils import TR, askUser, openHelp, restoreGeom, saveGeom, showWarning, tr
from aqt.utils import (
TR,
askUser,
disable_help_button,
openHelp,
restoreGeom,
saveGeom,
showWarning,
tr,
)
class DeckConf(QDialog):
@ -23,7 +32,7 @@ class DeckConf(QDialog):
label = tr(TR.ACTIONS_REBUILD)
self.ok = self.form.buttonBox.addButton(label, QDialogButtonBox.AcceptRole)
self.mw.checkpoint(tr(TR.ACTIONS_OPTIONS))
self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint) # type: ignore
disable_help_button(self)
self.setWindowModality(Qt.WindowModal)
qconnect(self.form.buttonBox.helpRequested, lambda: openHelp("filtered-decks"))
self.setWindowTitle(

View file

@ -5,7 +5,7 @@ import aqt.editor
from aqt import gui_hooks
from aqt.main import ResetReason
from aqt.qt import *
from aqt.utils import TR, restoreGeom, saveGeom, tooltip, tr
from aqt.utils import TR, disable_help_button, restoreGeom, saveGeom, tooltip, tr
class EditCurrent(QDialog):
@ -16,7 +16,7 @@ class EditCurrent(QDialog):
self.form = aqt.forms.editcurrent.Ui_Dialog()
self.form.setupUi(self)
self.setWindowTitle(tr(TR.EDITING_EDIT_CURRENT))
self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint) # type: ignore
disable_help_button(self)
self.setMinimumHeight(400)
self.setMinimumWidth(250)
self.form.buttonBox.button(QDialogButtonBox.Close).setShortcut(

View file

@ -31,6 +31,7 @@ from aqt.sound import av_player
from aqt.theme import theme_manager
from aqt.utils import (
TR,
disable_help_button,
getFile,
openHelp,
qtMenuShortcutWorkaround,
@ -555,7 +556,7 @@ class Editor:
form = aqt.forms.edithtml.Ui_Dialog()
form.setupUi(d)
restoreGeom(d, "htmlEditor")
d.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint) # type: ignore
disable_help_button(d)
qconnect(form.buttonBox.helpRequested, lambda: openHelp("editing?id=features"))
form.textEdit.setPlainText(self.note.fields[field])
d.show()

View file

@ -9,7 +9,7 @@ import aqt
from anki.backend_pb2 import EmptyCardsReport, NoteWithEmptyCards
from aqt import gui_hooks
from aqt.qt import QDialog, QDialogButtonBox, qconnect
from aqt.utils import TR, restoreGeom, saveGeom, tooltip, tr
from aqt.utils import TR, disable_help_button, restoreGeom, saveGeom, tooltip, tr
def show_empty_cards(mw: aqt.main.AnkiQt) -> None:
@ -38,7 +38,7 @@ class EmptyCardsDialog(QDialog):
self.form.setupUi(self)
restoreGeom(self, "emptycards")
self.setWindowTitle(tr(TR.EMPTY_CARDS_WINDOW_TITLE))
self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint) # type: ignore
disable_help_button(self)
self.form.keep_notes.setText(tr(TR.EMPTY_CARDS_PRESERVE_NOTES_CHECKBOX))
self.form.webview.title = "empty cards"
self.form.webview.set_bridge_command(self._on_note_link_clicked, self)

View file

@ -13,7 +13,15 @@ import aqt
from anki import hooks
from anki.exporting import Exporter, exporters
from aqt.qt import *
from aqt.utils import TR, checkInvalidFilename, getSaveFile, showWarning, tooltip, tr
from aqt.utils import (
TR,
checkInvalidFilename,
disable_help_button,
getSaveFile,
showWarning,
tooltip,
tr,
)
class ExportDialog(QDialog):
@ -30,7 +38,7 @@ class ExportDialog(QDialog):
self.frm.setupUi(self)
self.exporter: Optional[Exporter] = None
self.cids = cids
self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint) # type: ignore
disable_help_button(self)
self.setup(did)
self.exec_()

View file

@ -9,7 +9,16 @@ from anki.rsbackend import TemplateError
from aqt import AnkiQt, gui_hooks
from aqt.qt import *
from aqt.schema_change_tracker import ChangeTracker
from aqt.utils import TR, askUser, getOnlyText, openHelp, showWarning, tooltip, tr
from aqt.utils import (
TR,
askUser,
disable_help_button,
getOnlyText,
openHelp,
showWarning,
tooltip,
tr,
)
class FieldDialog(QDialog):
@ -27,7 +36,7 @@ class FieldDialog(QDialog):
self.setWindowTitle(
without_unicode_isolation(tr(TR.FIELDS_FIELDS_FOR, val=self.model["name"]))
)
self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint) # type: ignore
disable_help_button(self)
self.form.buttonBox.button(QDialogButtonBox.Help).setAutoDefault(False)
self.form.buttonBox.button(QDialogButtonBox.Cancel).setAutoDefault(False)
self.form.buttonBox.button(QDialogButtonBox.Save).setAutoDefault(False)

View file

@ -20,6 +20,7 @@ from aqt.qt import *
from aqt.utils import (
TR,
askUser,
disable_help_button,
getFile,
getOnlyText,
openHelp,
@ -38,7 +39,7 @@ class ChangeMap(QDialog):
self.model = model
self.frm = aqt.forms.changemap.Ui_ChangeMap()
self.frm.setupUi(self)
self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint) # type: ignore
disable_help_button(self)
n = 0
setCurrent = False
for field in self.model["flds"]:
@ -86,7 +87,7 @@ class ImportDialog(QDialog):
qconnect(
self.frm.buttonBox.button(QDialogButtonBox.Help).clicked, self.helpRequested
)
self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint) # type: ignore
disable_help_button(self)
self.setupMappingFrame()
self.setupOptions()
self.modelChanged()

View file

@ -50,6 +50,7 @@ from aqt.utils import (
TR,
askUser,
checkInvalidFilename,
disable_help_button,
getFile,
getOnlyText,
openHelp,
@ -1345,7 +1346,7 @@ title="%s" %s>%s</button>""" % (
d = self.debugDiag = DebugDialog()
d.silentlyClose = True
d.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint) # type: ignore
disable_help_button(d)
frm.setupUi(d)
restoreGeom(d, "DebugConsoleWindow")
restoreSplitter(frm.splitter, "DebugConsoleWindow")

View file

@ -20,7 +20,7 @@ from anki.types import assert_exhaustive
from anki.utils import intTime
from aqt import gui_hooks
from aqt.qt import QDialog, QDialogButtonBox, QPushButton, QTextCursor, QTimer, qconnect
from aqt.utils import showWarning, tr
from aqt.utils import disable_help_button, showWarning, tr
LogEntry = Union[MediaSyncProgress, str]
@ -164,7 +164,7 @@ class MediaSyncDialog(QDialog):
self.form = aqt.forms.synclog.Ui_Dialog()
self.form.setupUi(self)
self.setWindowTitle(tr(TR.SYNC_MEDIA_LOG_TITLE))
self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint) # type: ignore
disable_help_button(self)
self.abort_button = QPushButton(tr(TR.SYNC_ABORT_BUTTON))
qconnect(self.abort_button.clicked, self._on_abort)
self.abort_button.setAutoDefault(False)

View file

@ -16,6 +16,7 @@ from aqt.qt import *
from aqt.utils import (
TR,
askUser,
disable_help_button,
getText,
maybeHideClose,
openHelp,
@ -155,7 +156,7 @@ class Models(QDialog):
def onAdvanced(self) -> None:
nt = self.current_notetype()
d = QDialog(self)
d.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint) # type: ignore
disable_help_button(d)
frm = aqt.forms.modelopts.Ui_Dialog()
frm.setupUi(d)
frm.latexsvg.setChecked(nt.get("latexsvg", False))
@ -211,7 +212,7 @@ class AddModel(QDialog):
self.model = None
self.dialog = aqt.forms.addmodel.Ui_Dialog()
self.dialog.setupUi(self)
self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint) # type: ignore
disable_help_button(self)
# standard models
self.models = []
for (name, func) in stdmodels.get_stock_notetypes(self.col):

View file

@ -6,7 +6,15 @@ import aqt
from aqt import AnkiQt
from aqt.profiles import RecordingDriver, VideoDriver
from aqt.qt import *
from aqt.utils import TR, askUser, openHelp, showInfo, showWarning, tr
from aqt.utils import (
TR,
askUser,
disable_help_button,
openHelp,
showInfo,
showWarning,
tr,
)
def video_driver_name_for_platform(driver: VideoDriver) -> str:
@ -31,7 +39,7 @@ class Preferences(QDialog):
self.prof = self.mw.pm.profile
self.form = aqt.forms.preferences.Ui_Preferences()
self.form.setupUi(self)
self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint) # type: ignore
disable_help_button(self)
self.form.buttonBox.button(QDialogButtonBox.Help).setAutoDefault(False)
self.form.buttonBox.button(QDialogButtonBox.Close).setAutoDefault(False)
qconnect(self.form.buttonBox.helpRequested, lambda: openHelp("preferences"))

View file

@ -24,7 +24,7 @@ from aqt.qt import (
from aqt.reviewer import replay_audio
from aqt.sound import av_player, play_clicked_audio
from aqt.theme import theme_manager
from aqt.utils import TR, restoreGeom, saveGeom, tr
from aqt.utils import TR, disable_help_button, restoreGeom, saveGeom, tr
from aqt.webview import AnkiWebView
@ -43,7 +43,7 @@ class Previewer(QDialog):
self.mw = mw
icon = QIcon()
icon.addPixmap(QPixmap(":/icons/anki.png"), QIcon.Normal, QIcon.Off)
self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint) # type: ignore
disable_help_button(self)
self.setWindowIcon(icon)
def card(self) -> Optional[Card]:

View file

@ -26,7 +26,7 @@ from anki.rsbackend import SyncAuth
from anki.utils import intTime, isMac, isWin
from aqt import appHelpSite
from aqt.qt import *
from aqt.utils import TR, locale_dir, showWarning, tr
from aqt.utils import TR, disable_help_button, locale_dir, showWarning, tr
# Profile handling
##########################################################################
@ -542,7 +542,7 @@ create table if not exists profiles
d = self.langDiag = NoCloseDiag()
f = self.langForm = aqt.forms.setlang.Ui_Dialog()
f.setupUi(d)
d.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint) # type: ignore
disable_help_button(d)
qconnect(d.accepted, self._onLangSelected)
qconnect(d.rejected, lambda: True)
# update list

View file

@ -8,7 +8,7 @@ from typing import Optional
import aqt.forms
from aqt.qt import *
from aqt.utils import TR, tr
from aqt.utils import TR, disable_help_button, tr
# Progress info
##########################################################################
@ -211,7 +211,7 @@ class ProgressManager:
class ProgressDialog(QDialog):
def __init__(self, parent):
QDialog.__init__(self, parent)
self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint) # type: ignore
disable_help_button(self)
self.form = aqt.forms.progress.Ui_Dialog()
self.form.setupUi(self)
self._closingDown = False

View file

@ -28,7 +28,15 @@ from aqt.mpv import MPV, MPVBase, MPVCommandError
from aqt.profiles import RecordingDriver
from aqt.qt import *
from aqt.taskman import TaskManager
from aqt.utils import TR, restoreGeom, saveGeom, showWarning, startup_info, tr
from aqt.utils import (
TR,
disable_help_button,
restoreGeom,
saveGeom,
showWarning,
startup_info,
tr,
)
if TYPE_CHECKING:
from PyQt5.QtMultimedia import QAudioRecorder
@ -707,7 +715,7 @@ class RecordDialog(QDialog):
self._parent = parent
self.mw = mw
self._on_success = on_success
self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint) # type: ignore
disable_help_button(self)
self._start_recording()
self._setup_dialog()

View file

@ -12,6 +12,7 @@ from aqt.theme import theme_manager
from aqt.utils import (
TR,
addCloseShortcut,
disable_help_button,
getSaveFile,
maybeHideClose,
restoreGeom,
@ -34,7 +35,7 @@ class NewDeckStats(QDialog):
self.oldPos = None
self.wholeCollection = False
self.setMinimumWidth(700)
self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint) # type: ignore
disable_help_button(self)
f = self.form
f.setupUi(self)
f.groupBox.setVisible(False)
@ -105,7 +106,7 @@ class DeckStats(QDialog):
self.oldPos = None
self.wholeCollection = False
self.setMinimumWidth(700)
self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint) # type: ignore
disable_help_button(self)
f = self.form
if theme_manager.night_mode and not theme_manager.macos_dark_mode():
# the grouping box renders incorrectly in the fusion theme. 5.9+

View file

@ -6,6 +6,7 @@ from aqt import gui_hooks
from aqt.qt import *
from aqt.utils import (
TR,
disable_help_button,
getOnlyText,
openHelp,
restoreGeom,
@ -42,7 +43,7 @@ class StudyDeck(QDialog):
gui_hooks.state_did_reset.append(self.onReset)
self.geomKey = "studyDeck-" + geomKey
restoreGeom(self, self.geomKey)
self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint) # type: ignore
disable_help_button(self)
if not cancel:
self.form.buttonBox.removeButton(
self.form.buttonBox.button(QDialogButtonBox.Cancel)

View file

@ -32,7 +32,14 @@ from aqt.qt import (
QVBoxLayout,
qconnect,
)
from aqt.utils import askUser, askUserDialog, showText, showWarning, tr
from aqt.utils import (
askUser,
askUserDialog,
disable_help_button,
showText,
showWarning,
tr,
)
class FullSyncChoice(enum.Enum):
@ -290,7 +297,7 @@ def get_id_and_pass_from_user(
) -> Tuple[str, str]:
diag = QDialog(mw)
diag.setWindowTitle("Anki")
diag.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint) # type: ignore
disable_help_button(diag)
diag.setWindowModality(Qt.WindowModal)
vbox = QVBoxLayout()
info_label = QLabel(

View file

@ -4,7 +4,7 @@ from typing import List, Optional
import aqt
from aqt.qt import *
from aqt.utils import restoreGeom, saveGeom
from aqt.utils import disable_help_button, restoreGeom, saveGeom
class TagLimit(QDialog):
@ -16,7 +16,7 @@ class TagLimit(QDialog):
self.deck = self.parent.deck
self.dialog = aqt.forms.taglimit.Ui_Dialog()
self.dialog.setupUi(self)
self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint) # type: ignore
disable_help_button(self)
s = QShortcut(
QKeySequence("ctrl+d"), self.dialog.activeList, context=Qt.WidgetShortcut
)

View file

@ -7,7 +7,7 @@ import os
import re
import subprocess
import sys
from typing import TYPE_CHECKING, Any, List, Optional, Union
from typing import TYPE_CHECKING, Any, List, Optional, Union, cast
import anki
import aqt
@ -127,7 +127,7 @@ def showText(
parent = aqt.mw.app.activeWindow() or aqt.mw
diag = QDialog(parent)
diag.setWindowTitle(title)
diag.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint) # type: ignore
disable_help_button(diag)
layout = QVBoxLayout(diag)
diag.setLayout(layout)
text = QTextBrowser()
@ -246,7 +246,7 @@ class GetTextDialog(QDialog):
):
QDialog.__init__(self, parent)
self.setWindowTitle(title)
self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint) # type: ignore
disable_help_button(self)
self.question = question
self.help = help
self.qlabel = QLabel(question)
@ -318,7 +318,7 @@ def chooseList(prompt, choices, startrow=0, parent=None):
if not parent:
parent = aqt.mw.app.activeWindow()
d = QDialog(parent)
d.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint) # type: ignore
disable_help_button(d)
d.setWindowModality(Qt.WindowModal)
l = QVBoxLayout()
d.setLayout(l)
@ -345,6 +345,12 @@ def getTag(parent, deck, question, tags="user", **kwargs):
return ret
def disable_help_button(widget: QWidget) -> None:
"Disable the help button in the window titlebar."
flags = cast(Qt.WindowType, widget.windowFlags() & ~Qt.WindowContextHelpButtonHint)
widget.setWindowFlags(flags)
# File handling
######################################################################