[TechDraw] Fixes for TaskFillTemplateFields finding Draft/Arch/Image views and keeping message boxes and dialogs on top (#25342)
* [TechDraw] fix dialog to be ontop, clear the keyLst and save mouse movement between messagebox and dialog * [TechDraw] change from setWindowFlags to setWindowFlag * [TechDraw] handle BIM and Draft as first available views... .... also increase the possible scale values such as 5 : 2 or 7 : 3 * [TechDraw] fix 1:1 scale regression * [TechDraw] remove unnecessary line of code * TD: Simplify code Address comments from review. Co-authored-by: WandererFan <wandererfan@gmail.com> * [TechDraw] enable use of Fraction for scale... ... conversion --------- Co-authored-by: Chris Hennes <chennes@pioneerlibrarysystem.org> Co-authored-by: WandererFan <wandererfan@gmail.com>
This commit is contained in:
@@ -35,6 +35,7 @@ import datetime
|
||||
from datetime import date
|
||||
import csv
|
||||
import codecs
|
||||
from fractions import Fraction
|
||||
import os.path
|
||||
|
||||
CreatedByChkLst = []
|
||||
@@ -56,7 +57,6 @@ listofkeys = [
|
||||
"LastModifiedDateChkLst",
|
||||
]
|
||||
|
||||
|
||||
"""Run the following code when the command is activated (button press)."""
|
||||
file_path = App.getResourceDir() + "Mod/TechDraw/CSVdata/FillTemplateFields.csv"
|
||||
|
||||
@@ -112,17 +112,15 @@ class TaskFillTemplateFields:
|
||||
)
|
||||
msgBox.setText(msg)
|
||||
msgBox.setWindowTitle(msgTitle)
|
||||
msgBox.setWindowFlag(QtCore.Qt.WindowStaysOnTopHint, True)
|
||||
msgBox.exec_()
|
||||
break
|
||||
|
||||
projgrp_view = None
|
||||
for pageObj in obj.Views:
|
||||
if (
|
||||
pageObj.isDerivedFrom("TechDraw::DrawViewPart")
|
||||
or pageObj.isDerivedFrom("TechDraw::DrawProjGroup")
|
||||
):
|
||||
if hasattr(pageObj, "Scale"):
|
||||
# use the scale from the first DVP or DPG encountered to fill the template's
|
||||
# Scale editable text.
|
||||
# Scale editable text.
|
||||
projgrp_view = pageObj
|
||||
break
|
||||
|
||||
@@ -174,7 +172,9 @@ class TaskFillTemplateFields:
|
||||
self.checkBoxList.append(self.cb1)
|
||||
self.lineTextList.append(self.s1)
|
||||
self.cb1.clicked.connect(self.on_cb1_clicked)
|
||||
longestText = max(longestText, len(App.ActiveDocument.CreatedBy))
|
||||
longestText = max(
|
||||
longestText, len(App.ActiveDocument.CreatedBy)
|
||||
)
|
||||
dialogRow += 1
|
||||
if str(key).lower() in ScaleChkLst and projgrp_view:
|
||||
t2 = QtGui.QLabel(value)
|
||||
@@ -197,9 +197,30 @@ class TaskFillTemplateFields:
|
||||
self.lineTextList.append(self.s2)
|
||||
self.cb2.clicked.connect(self.on_cb2_clicked)
|
||||
if projgrp_view.Scale < 1:
|
||||
self.s2.setText("1 : " + str(int(1 / projgrp_view.Scale)))
|
||||
else:
|
||||
fracScale = Fraction(projgrp_view.Scale).limit_denominator()
|
||||
self.s2.setText(
|
||||
str(fracScale.numerator)
|
||||
+ " : "
|
||||
+ str(fracScale.denominator)
|
||||
)
|
||||
elif int(projgrp_view.Scale) == 1 or (
|
||||
projgrp_view.Scale > 1
|
||||
and int(projgrp_view.Scale) == projgrp_view.Scale
|
||||
):
|
||||
self.s2.setText(str(int(projgrp_view.Scale)) + " : 1")
|
||||
else: # must be something like 2.5 = 5 : 2
|
||||
for x in range(2, 10):
|
||||
if (
|
||||
int(projgrp_view.Scale * x)
|
||||
== projgrp_view.Scale * x
|
||||
):
|
||||
fracScale = Fraction(projgrp_view.Scale)
|
||||
self.s2.setText(
|
||||
str(fracScale.numerator)
|
||||
+ " : "
|
||||
+ str(fracScale.denominator)
|
||||
)
|
||||
break
|
||||
dialogRow += 1
|
||||
if str(key).lower() in LabelChkLst:
|
||||
t3 = QtGui.QLabel(value)
|
||||
@@ -429,11 +450,12 @@ class TaskFillTemplateFields:
|
||||
self.button.setEnabled(True)
|
||||
self.dialog.resize(600 + longestText, dialogRow * 50 + 75)
|
||||
self.dialog.move(400, 200 * (400 / (dialogRow * 50 + 75)))
|
||||
self.dialog.setWindowFlag(QtCore.Qt.WindowStaysOnTopHint, True)
|
||||
QtCore.QMetaObject.connectSlotsByName(self.dialog)
|
||||
self.dialog.show()
|
||||
self.dialog.exec_()
|
||||
|
||||
# App.setActiveTransaction("Fill template fields")
|
||||
# App.setActiveTransaction("Fill template fields")
|
||||
else:
|
||||
msgBox = QtGui.QMessageBox()
|
||||
msgTitle = QtCore.QT_TRANSLATE_NOOP(
|
||||
@@ -445,8 +467,10 @@ class TaskFillTemplateFields:
|
||||
"There were no corresponding fields found in "
|
||||
+ self.page.Label,
|
||||
)
|
||||
msgBox.setWindowFlag(QtCore.Qt.WindowStaysOnTopHint, True)
|
||||
msgBox.setText(msg)
|
||||
msgBox.setWindowTitle(msgTitle)
|
||||
msgBox.move(400, 450)
|
||||
msgBox.exec_()
|
||||
|
||||
def on_cbAll_clicked(self):
|
||||
@@ -524,7 +548,9 @@ class TaskFillTemplateFields:
|
||||
self.button.setEnabled(False)
|
||||
|
||||
def proceed(self):
|
||||
transactionName = QtCore.QT_TRANSLATE_NOOP("Techdraw_FillTemplateFields", "Fill template fields")
|
||||
transactionName = QtCore.QT_TRANSLATE_NOOP(
|
||||
"Techdraw_FillTemplateFields", "Fill template fields"
|
||||
)
|
||||
App.setActiveTransaction(transactionName)
|
||||
i = 0
|
||||
for cb in self.checkBoxList:
|
||||
@@ -539,4 +565,5 @@ class TaskFillTemplateFields:
|
||||
|
||||
def close(self):
|
||||
self.dialog.hide()
|
||||
keyLst.clear()
|
||||
return True
|
||||
|
||||
Reference in New Issue
Block a user