generate pyqt6 forms

This commit is contained in:
Damien Elmes 2021-10-05 13:18:43 +10:00
parent dfcefaebe3
commit b0272f0336
90 changed files with 341 additions and 61 deletions

View file

@ -1,17 +1,48 @@
load("@rules_python//python:defs.bzl", "py_binary")
load("compile.bzl", "compile_all")
py_binary(
name = "build_ui_qt5",
srcs = ["build_ui_qt5.py"],
legacy_create_init = False,
deps = ["@pyqt5//:pkg"],
)
py_binary(
name = "build_ui_qt6",
srcs = ["build_ui_qt6.py"],
legacy_create_init = False,
deps = ["@pyqt6//:pkg"],
)
compile_all(
name = "forms_qt5",
srcs = glob(["*.ui"]),
group = "forms",
builder = "build_ui_qt5",
suffix = "_qt5",
)
compile_all(
name = "forms_qt6",
srcs = glob(["*.ui"]),
builder = "build_ui_qt6",
suffix = "_qt6",
)
filegroup(
name = "forms",
srcs = glob(
["*.py"],
exclude = [
"*_qt5.py",
"*_qt6.py",
"build_ui*.py",
],
) + [
":forms_qt6",
":forms_qt5",
],
visibility = [
"//qt/aqt:__pkg__",
],
)
py_binary(
name = "build_ui",
srcs = ["build_ui.py"],
legacy_create_init = False,
deps = ["@pyqt5//:pkg"],
)

View file

@ -0,0 +1 @@
../../../bazel-bin/qt/aqt/forms/__init___qt6.py

View file

@ -1 +0,0 @@
../../../bazel-bin/qt/aqt/forms/about.py

5
qt/aqt/forms/about.py Normal file
View file

@ -0,0 +1,5 @@
from aqt.qt import qtmajor
if qtmajor > 5:
from .about_qt6 import *
else:
from .about_qt5 import * # type: ignore

1
qt/aqt/forms/about_qt6.py Symbolic link
View file

@ -0,0 +1 @@
../../../bazel-bin/qt/aqt/forms/about_qt6.py

View file

@ -1 +0,0 @@
../../../bazel-bin/qt/aqt/forms/addcards.py

5
qt/aqt/forms/addcards.py Normal file
View file

@ -0,0 +1,5 @@
from aqt.qt import qtmajor
if qtmajor > 5:
from .addcards_qt6 import *
else:
from .addcards_qt5 import * # type: ignore

View file

@ -0,0 +1 @@
../../../bazel-bin/qt/aqt/forms/addcards_qt6.py

View file

@ -1 +0,0 @@
../../../bazel-bin/qt/aqt/forms/addfield.py

5
qt/aqt/forms/addfield.py Normal file
View file

@ -0,0 +1,5 @@
from aqt.qt import qtmajor
if qtmajor > 5:
from .addfield_qt6 import *
else:
from .addfield_qt5 import * # type: ignore

View file

@ -0,0 +1 @@
../../../bazel-bin/qt/aqt/forms/addfield_qt6.py

View file

@ -1 +0,0 @@
../../../bazel-bin/qt/aqt/forms/addmodel.py

5
qt/aqt/forms/addmodel.py Normal file
View file

@ -0,0 +1,5 @@
from aqt.qt import qtmajor
if qtmajor > 5:
from .addmodel_qt6 import *
else:
from .addmodel_qt5 import * # type: ignore

View file

@ -0,0 +1 @@
../../../bazel-bin/qt/aqt/forms/addmodel_qt6.py

View file

@ -1 +0,0 @@
../../../bazel-bin/qt/aqt/forms/addonconf.py

View file

@ -0,0 +1,5 @@
from aqt.qt import qtmajor
if qtmajor > 5:
from .addonconf_qt6 import *
else:
from .addonconf_qt5 import * # type: ignore

View file

@ -0,0 +1 @@
../../../bazel-bin/qt/aqt/forms/addonconf_qt6.py

View file

@ -1 +0,0 @@
../../../bazel-bin/qt/aqt/forms/addons.py

5
qt/aqt/forms/addons.py Normal file
View file

@ -0,0 +1,5 @@
from aqt.qt import qtmajor
if qtmajor > 5:
from .addons_qt6 import *
else:
from .addons_qt5 import * # type: ignore

1
qt/aqt/forms/addons_qt6.py Symbolic link
View file

@ -0,0 +1 @@
../../../bazel-bin/qt/aqt/forms/addons_qt6.py

View file

@ -1 +0,0 @@
../../../bazel-bin/qt/aqt/forms/browser.py

5
qt/aqt/forms/browser.py Normal file
View file

@ -0,0 +1,5 @@
from aqt.qt import qtmajor
if qtmajor > 5:
from .browser_qt6 import *
else:
from .browser_qt5 import * # type: ignore

1
qt/aqt/forms/browser_qt6.py Symbolic link
View file

@ -0,0 +1 @@
../../../bazel-bin/qt/aqt/forms/browser_qt6.py

View file

@ -1 +0,0 @@
../../../bazel-bin/qt/aqt/forms/browserdisp.py

View file

@ -0,0 +1,5 @@
from aqt.qt import qtmajor
if qtmajor > 5:
from .browserdisp_qt6 import *
else:
from .browserdisp_qt5 import * # type: ignore

View file

@ -0,0 +1 @@
../../../bazel-bin/qt/aqt/forms/browserdisp_qt6.py

View file

@ -1 +0,0 @@
../../../bazel-bin/qt/aqt/forms/browseropts.py

View file

@ -0,0 +1,5 @@
from aqt.qt import qtmajor
if qtmajor > 5:
from .browseropts_qt6 import *
else:
from .browseropts_qt5 import * # type: ignore

View file

@ -0,0 +1 @@
../../../bazel-bin/qt/aqt/forms/browseropts_qt6.py

View file

@ -0,0 +1 @@
../../../bazel-bin/qt/aqt/forms/build_ui_qt5_qt6.py

View file

@ -0,0 +1,39 @@
import re
import sys
import io
from PyQt6.uic import compileUi
ui_file = sys.argv[1]
py_file = sys.argv[2]
buf = io.StringIO()
compileUi(open(ui_file), buf)
outdata = buf.getvalue()
outdata = outdata.replace(
"from PyQt6 import QtCore, QtGui, QtWidgets",
"from PyQt6 import QtCore, QtGui, QtWidgets\nfrom aqt.utils import tr\n"
)
outdata = re.sub(
r'(?:QtGui\.QApplication\.)?_?translate\(".*?", "(.*?)"', "tr.\\1(", outdata
)
outlines = []
qt_bad_types = [
".connect(",
]
for line in outdata.splitlines():
for substr in qt_bad_types:
if substr in line:
line = line + " # type: ignore"
break
if line == "from . import icons_rc":
continue
line = line.replace(":/icons/", "icons:")
line = line.replace("QAction.PreferencesRole", "QAction.MenuRole.PreferencesRole")
line = line.replace("QAction.AboutRole", "QAction.MenuRole.AboutRole")
line = line.replace("QComboBox.AdjustToMinimumContentsLength", "QComboBox.SizeAdjustPolicy.AdjustToMinimumContentsLength")
outlines.append(line)
with open(py_file, "w") as file:
file.write("\n".join(outlines))

View file

@ -0,0 +1 @@
../../../bazel-bin/qt/aqt/forms/build_ui_qt6_qt6.py

View file

@ -1 +0,0 @@
../../../bazel-bin/qt/aqt/forms/changemap.py

View file

@ -0,0 +1,5 @@
from aqt.qt import qtmajor
if qtmajor > 5:
from .changemap_qt6 import *
else:
from .changemap_qt5 import * # type: ignore

View file

@ -0,0 +1 @@
../../../bazel-bin/qt/aqt/forms/changemap_qt6.py

View file

@ -1 +0,0 @@
../../../bazel-bin/qt/aqt/forms/changemodel.py

View file

@ -0,0 +1,5 @@
from aqt.qt import qtmajor
if qtmajor > 5:
from .changemodel_qt6 import *
else:
from .changemodel_qt5 import * # type: ignore

View file

@ -0,0 +1 @@
../../../bazel-bin/qt/aqt/forms/changemodel_qt6.py

View file

@ -1 +0,0 @@
../../../bazel-bin/qt/aqt/forms/clayout_top.py

View file

@ -0,0 +1,5 @@
from aqt.qt import qtmajor
if qtmajor > 5:
from .clayout_top_qt6 import *
else:
from .clayout_top_qt5 import * # type: ignore

View file

@ -0,0 +1 @@
../../../bazel-bin/qt/aqt/forms/clayout_top_qt6.py

View file

@ -1,28 +1,28 @@
def compile(name, ui_file, py_file):
def compile(name, ui_file, py_file, builder):
native.genrule(
name = name,
srcs = [ui_file],
outs = [py_file],
cmd = "$(location build_ui) $(location {ui_file}) $(location {py_file})".format(
cmd = "$(location {builder}) $(location {ui_file}) $(location {py_file})".format(
builder = builder,
ui_file = ui_file,
py_file = py_file,
),
tools = [
"build_ui",
builder,
],
message = "Building UI",
)
def compile_all(group, srcs, visibility):
def compile_all(name, builder, srcs, suffix):
py_files = []
for ui_file in srcs:
name = ui_file.replace(".ui", "")
py_file = name + ".py"
fname = ui_file.replace(".ui", "") + suffix
py_file = fname + ".py"
py_files.append(py_file)
compile(name, ui_file, py_file)
compile(fname, ui_file, py_file, builder)
native.filegroup(
name = group,
srcs = py_files + ["__init__.py"],
visibility = visibility,
name = name,
srcs = py_files,
)

View file

@ -1 +0,0 @@
../../../bazel-bin/qt/aqt/forms/customstudy.py

View file

@ -0,0 +1,5 @@
from aqt.qt import qtmajor
if qtmajor > 5:
from .customstudy_qt6 import *
else:
from .customstudy_qt5 import * # type: ignore

View file

@ -0,0 +1 @@
../../../bazel-bin/qt/aqt/forms/customstudy_qt6.py

View file

@ -1 +0,0 @@
../../../bazel-bin/qt/aqt/forms/dconf.py

5
qt/aqt/forms/dconf.py Normal file
View file

@ -0,0 +1,5 @@
from aqt.qt import qtmajor
if qtmajor > 5:
from .dconf_qt6 import *
else:
from .dconf_qt5 import * # type: ignore

1
qt/aqt/forms/dconf_qt6.py Symbolic link
View file

@ -0,0 +1 @@
../../../bazel-bin/qt/aqt/forms/dconf_qt6.py

View file

@ -1 +0,0 @@
../../../bazel-bin/qt/aqt/forms/debug.py

5
qt/aqt/forms/debug.py Normal file
View file

@ -0,0 +1,5 @@
from aqt.qt import qtmajor
if qtmajor > 5:
from .debug_qt6 import *
else:
from .debug_qt5 import * # type: ignore

1
qt/aqt/forms/debug_qt6.py Symbolic link
View file

@ -0,0 +1 @@
../../../bazel-bin/qt/aqt/forms/debug_qt6.py

View file

@ -1 +0,0 @@
../../../bazel-bin/qt/aqt/forms/editaddon.py

View file

@ -0,0 +1,5 @@
from aqt.qt import qtmajor
if qtmajor > 5:
from .editaddon_qt6 import *
else:
from .editaddon_qt5 import * # type: ignore

View file

@ -0,0 +1 @@
../../../bazel-bin/qt/aqt/forms/editaddon_qt6.py

View file

@ -1 +0,0 @@
../../../bazel-bin/qt/aqt/forms/editcurrent.py

View file

@ -0,0 +1,5 @@
from aqt.qt import qtmajor
if qtmajor > 5:
from .editcurrent_qt6 import *
else:
from .editcurrent_qt5 import * # type: ignore

View file

@ -0,0 +1 @@
../../../bazel-bin/qt/aqt/forms/editcurrent_qt6.py

View file

@ -1 +0,0 @@
../../../bazel-bin/qt/aqt/forms/edithtml.py

5
qt/aqt/forms/edithtml.py Normal file
View file

@ -0,0 +1,5 @@
from aqt.qt import qtmajor
if qtmajor > 5:
from .edithtml_qt6 import *
else:
from .edithtml_qt5 import * # type: ignore

View file

@ -0,0 +1 @@
../../../bazel-bin/qt/aqt/forms/edithtml_qt6.py

View file

@ -1 +0,0 @@
../../../bazel-bin/qt/aqt/forms/emptycards.py

View file

@ -0,0 +1,5 @@
from aqt.qt import qtmajor
if qtmajor > 5:
from .emptycards_qt6 import *
else:
from .emptycards_qt5 import * # type: ignore

View file

@ -0,0 +1 @@
../../../bazel-bin/qt/aqt/forms/emptycards_qt6.py

View file

@ -1 +0,0 @@
../../../bazel-bin/qt/aqt/forms/exporting.py

View file

@ -0,0 +1,5 @@
from aqt.qt import qtmajor
if qtmajor > 5:
from .exporting_qt6 import *
else:
from .exporting_qt5 import * # type: ignore

View file

@ -0,0 +1 @@
../../../bazel-bin/qt/aqt/forms/exporting_qt6.py

View file

@ -1 +0,0 @@
../../../bazel-bin/qt/aqt/forms/fields.py

5
qt/aqt/forms/fields.py Normal file
View file

@ -0,0 +1,5 @@
from aqt.qt import qtmajor
if qtmajor > 5:
from .fields_qt6 import *
else:
from .fields_qt5 import * # type: ignore

1
qt/aqt/forms/fields_qt6.py Symbolic link
View file

@ -0,0 +1 @@
../../../bazel-bin/qt/aqt/forms/fields_qt6.py

View file

@ -1 +0,0 @@
../../../bazel-bin/qt/aqt/forms/filtered_deck.py

View file

@ -0,0 +1,5 @@
from aqt.qt import qtmajor
if qtmajor > 5:
from .filtered_deck_qt6 import *
else:
from .filtered_deck_qt5 import * # type: ignore

View file

@ -0,0 +1 @@
../../../bazel-bin/qt/aqt/forms/filtered_deck_qt6.py

View file

@ -1 +0,0 @@
../../../bazel-bin/qt/aqt/forms/finddupes.py

View file

@ -0,0 +1,5 @@
from aqt.qt import qtmajor
if qtmajor > 5:
from .finddupes_qt6 import *
else:
from .finddupes_qt5 import * # type: ignore

View file

@ -0,0 +1 @@
../../../bazel-bin/qt/aqt/forms/finddupes_qt6.py

View file

@ -1 +0,0 @@
../../../bazel-bin/qt/aqt/forms/findreplace.py

View file

@ -0,0 +1,5 @@
from aqt.qt import qtmajor
if qtmajor > 5:
from .findreplace_qt6 import *
else:
from .findreplace_qt5 import * # type: ignore

View file

@ -0,0 +1 @@
../../../bazel-bin/qt/aqt/forms/findreplace_qt6.py

View file

@ -1 +0,0 @@
../../../bazel-bin/qt/aqt/forms/getaddons.py

View file

@ -0,0 +1,5 @@
from aqt.qt import qtmajor
if qtmajor > 5:
from .getaddons_qt6 import *
else:
from .getaddons_qt5 import * # type: ignore

View file

@ -0,0 +1 @@
../../../bazel-bin/qt/aqt/forms/getaddons_qt6.py

View file

@ -1 +0,0 @@
../../../bazel-bin/qt/aqt/forms/importing.py

View file

@ -0,0 +1,5 @@
from aqt.qt import qtmajor
if qtmajor > 5:
from .importing_qt6 import *
else:
from .importing_qt5 import * # type: ignore

View file

@ -0,0 +1 @@
../../../bazel-bin/qt/aqt/forms/importing_qt6.py

View file

@ -1 +0,0 @@
../../../bazel-bin/qt/aqt/forms/main.py

5
qt/aqt/forms/main.py Normal file
View file

@ -0,0 +1,5 @@
from aqt.qt import qtmajor
if qtmajor > 5:
from .main_qt6 import *
else:
from .main_qt5 import * # type: ignore

1
qt/aqt/forms/main_qt6.py Symbolic link
View file

@ -0,0 +1 @@
../../../bazel-bin/qt/aqt/forms/main_qt6.py

View file

@ -1 +0,0 @@
../../../bazel-bin/qt/aqt/forms/modelopts.py

View file

@ -0,0 +1,5 @@
from aqt.qt import qtmajor
if qtmajor > 5:
from .modelopts_qt6 import *
else:
from .modelopts_qt5 import * # type: ignore

View file

@ -0,0 +1 @@
../../../bazel-bin/qt/aqt/forms/modelopts_qt6.py

View file

@ -1 +0,0 @@
../../../bazel-bin/qt/aqt/forms/models.py

5
qt/aqt/forms/models.py Normal file
View file

@ -0,0 +1,5 @@
from aqt.qt import qtmajor
if qtmajor > 5:
from .models_qt6 import *
else:
from .models_qt5 import * # type: ignore

1
qt/aqt/forms/models_qt6.py Symbolic link
View file

@ -0,0 +1 @@
../../../bazel-bin/qt/aqt/forms/models_qt6.py

View file

@ -1 +0,0 @@
../../../bazel-bin/qt/aqt/forms/preferences.py

View file

@ -0,0 +1,5 @@
from aqt.qt import qtmajor
if qtmajor > 5:
from .preferences_qt6 import *
else:
from .preferences_qt5 import * # type: ignore

View file

@ -0,0 +1 @@
../../../bazel-bin/qt/aqt/forms/preferences_qt6.py

View file

@ -1 +0,0 @@
../../../bazel-bin/qt/aqt/forms/preview.py

5
qt/aqt/forms/preview.py Normal file
View file

@ -0,0 +1,5 @@
from aqt.qt import qtmajor
if qtmajor > 5:
from .preview_qt6 import *
else:
from .preview_qt5 import * # type: ignore

1
qt/aqt/forms/preview_qt6.py Symbolic link
View file

@ -0,0 +1 @@
../../../bazel-bin/qt/aqt/forms/preview_qt6.py

Some files were not shown because too many files have changed in this diff Show more