PD(hole taskpanel): apply review suggestions

* refactor: change to ternary op
* refactor: apply recommendations to widgets
* refactor: use QSignalBlocker
* refactor: address some compiler complaints
* refactor: add namespace Gui to new widgets
This commit is contained in:
Alfredo Monclus
2025-02-09 15:57:14 -03:00
committed by Chris Hennes
parent 3202dde7ca
commit da4f584a50
8 changed files with 271 additions and 345 deletions

View File

@@ -1,30 +1,35 @@
/***************************************************************************
* Copyright (c) 2025 Alfredo Monclus <alfredomonclus@gmail.com> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 51 Franklin Street, *
* Fifth Floor, Boston, MA 02110-1301, USA *
* *
// SPDX-License-Identifier: LGPL-2.1-or-later
/****************************************************************************
* *
* Copyright (c) 2025 Alfredo Monclus <alfredomonclus@gmail.com> *
* *
* This file is part of FreeCAD. *
* *
* FreeCAD is free software: you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 2.1 of the *
* License, or (at your option) any later version. *
* *
* FreeCAD is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with FreeCAD. If not, see *
* <https://www.gnu.org/licenses/>. *
* *
***************************************************************************/
// This custom widget adds the missing ellipsize functionality in QT5
#include "PreCompiled.h"
#include "ElideCheckBox.h"
const int CheckboxSpacing = 25;
namespace Gui {
const int CheckboxSpacing = 18;
ElideCheckBox::ElideCheckBox(QWidget *parent)
: QCheckBox(parent) {
@@ -41,9 +46,9 @@ void ElideCheckBox::paintEvent(QPaintEvent *event) {
style()->drawControl(QStyle::CE_CheckBox, &option, &painter, this);
QRect textRect = option.rect;
int padding = 4;
textRect.setX(textRect.x() + 25);
textRect.setX(textRect.x() + CheckboxSpacing);
constexpr int padding = 4;
QFontMetrics fm(font());
QString elidedText = fm.elidedText(text(), Qt::ElideRight, textRect.width() - padding);
@@ -55,7 +60,7 @@ QSize ElideCheckBox::sizeHint() const {
QFontMetrics fm(font());
int width = fm.horizontalAdvance(this->text()) + CheckboxSpacing;
int height = fm.height();
return QSize(width, height);
return {width, height};
}
QSize ElideCheckBox::minimumSizeHint() const {
@@ -63,6 +68,9 @@ QSize ElideCheckBox::minimumSizeHint() const {
QString minimumText = QStringLiteral("A...");
int width = fm.horizontalAdvance(minimumText) + CheckboxSpacing;
int height = fm.height();
return QSize(width, height);
return {width, height};
}
} // namespace Gui
#include "moc_ElideCheckBox.cpp" // NOLINT

View File

@@ -1,23 +1,24 @@
/***************************************************************************
* Copyright (c) 2025 Alfredo Monclus <alfredomonclus@gmail.com> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 51 Franklin Street, *
* Fifth Floor, Boston, MA 02110-1301, USA *
* *
// SPDX-License-Identifier: LGPL-2.1-or-later
/****************************************************************************
* *
* Copyright (c) 2025 Alfredo Monclus <alfredomonclus@gmail.com> *
* *
* This file is part of FreeCAD. *
* *
* FreeCAD is free software: you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 2.1 of the *
* License, or (at your option) any later version. *
* *
* FreeCAD is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with FreeCAD. If not, see *
* <https://www.gnu.org/licenses/>. *
* *
***************************************************************************/
// This custom widget adds the missing ellipsize functionality in QT5
@@ -25,7 +26,6 @@
#ifndef ELIDECHECKBOX_H
#define ELIDECHECKBOX_H
#include "PreCompiled.h"
#ifndef _PreComp_
#include <QCheckBox>
#include <QPainter>
@@ -33,6 +33,9 @@
#include <QStyleOptionButton>
#endif
#include <FCGlobal.h>
namespace Gui {
class GuiExport ElideCheckBox : public QCheckBox {
Q_OBJECT
@@ -47,5 +50,7 @@ protected:
QSize minimumSizeHint() const override;
};
} // namespace Gui
#endif // ELIDECHECKBOX_H

View File

@@ -1,29 +1,34 @@
/***************************************************************************
* Copyright (c) 2025 Alfredo Monclus <alfredomonclus@gmail.com> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 51 Franklin Street, *
* Fifth Floor, Boston, MA 02110-1301, USA *
* *
// SPDX-License-Identifier: LGPL-2.1-or-later
/****************************************************************************
* *
* Copyright (c) 2025 Alfredo Monclus <alfredomonclus@gmail.com> *
* *
* This file is part of FreeCAD. *
* *
* FreeCAD is free software: you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 2.1 of the *
* License, or (at your option) any later version. *
* *
* FreeCAD is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with FreeCAD. If not, see *
* <https://www.gnu.org/licenses/>. *
* *
***************************************************************************/
// This custom widget adds the missing ellipsize functionality in QT5
#include "PreCompiled.h"
#include "ElideLabel.h"
namespace Gui {
ElideLabel::ElideLabel(QWidget *parent)
: QLabel(parent) {
}
@@ -34,20 +39,25 @@ void ElideLabel::paintEvent(QPaintEvent *event) {
painter.setPen(palette().color(QPalette::WindowText));
painter.setFont(font());
QFontMetrics fm(font());
QString text = this->text();
int availableWidth = width() - 4; // Account for padding
constexpr int padding = 4;
QFontMetrics fm(painter.fontMetrics());
QString elidedText = fm.elidedText(text, Qt::ElideRight, availableWidth);
int availableWidth = width() - padding * 2;
if (availableWidth < 0) {
return;
}
painter.drawText(2, 2, availableWidth, height(), Qt::AlignLeft | Qt::AlignVCenter, elidedText);
QString elidedText = fm.elidedText(text(), Qt::ElideRight, availableWidth);
QRect textRect = rect().adjusted(padding, 0, -padding, 0);
painter.drawText(textRect, Qt::AlignLeft | Qt::AlignVCenter, elidedText);
}
QSize ElideLabel::sizeHint() const {
QFontMetrics fm(font());
int width = fm.horizontalAdvance(this->text());
int height = fm.height();
return QSize(width, height);
return {width, height};
}
QSize ElideLabel::minimumSizeHint() const {
@@ -55,5 +65,9 @@ QSize ElideLabel::minimumSizeHint() const {
QString minimumText = QStringLiteral("A...");
int width = fm.horizontalAdvance(minimumText);
int height = fm.height();
return QSize(width, height);
return {width, height};
}
} // namespace Gui
#include "moc_ElideLabel.cpp" // NOLINT

View File

@@ -1,23 +1,24 @@
/***************************************************************************
* Copyright (c) 2025 Alfredo Monclus <alfredomonclus@gmail.com> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 51 Franklin Street, *
* Fifth Floor, Boston, MA 02110-1301, USA *
* *
// SPDX-License-Identifier: LGPL-2.1-or-later
/****************************************************************************
* *
* Copyright (c) 2025 Alfredo Monclus <alfredomonclus@gmail.com> *
* *
* This file is part of FreeCAD. *
* *
* FreeCAD is free software: you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 2.1 of the *
* License, or (at your option) any later version. *
* *
* FreeCAD is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with FreeCAD. If not, see *
* <https://www.gnu.org/licenses/>. *
* *
***************************************************************************/
// This custom widget adds the missing ellipsize functionality in QT5
@@ -25,13 +26,15 @@
#ifndef ELIDELABEL_H
#define ELIDELABEL_H
#include "PreCompiled.h"
#ifndef _PreComp_
#include <QLabel>
#include <QPainter>
#include <QFontMetrics>
#endif
#include <FCGlobal.h>
namespace Gui {
class GuiExport ElideLabel : public QLabel {
Q_OBJECT
@@ -46,4 +49,6 @@ protected:
QSize minimumSizeHint() const override;
};
} // namespace Gui
#endif // ELIDELABEL_H

View File

@@ -1,29 +1,34 @@
/***************************************************************************
* Copyright (c) 2025 Alfredo Monclus <alfredomonclus@gmail.com> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 51 Franklin Street, *
* Fifth Floor, Boston, MA 02110-1301, USA *
* *
// SPDX-License-Identifier: LGPL-2.1-or-later
/****************************************************************************
* *
* Copyright (c) 2025 Alfredo Monclus <alfredomonclus@gmail.com> *
* *
* This file is part of FreeCAD. *
* *
* FreeCAD is free software: you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 2.1 of the *
* License, or (at your option) any later version. *
* *
* FreeCAD is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with FreeCAD. If not, see *
* <https://www.gnu.org/licenses/>. *
* *
***************************************************************************/
// This custom widget scales an svg according to fonts
#include "PreCompiled.h"
#include "FontScaledSVG.h"
namespace Gui {
FontScaledSVG::FontScaledSVG(QWidget *parent)
: QWidget(parent), m_svgRenderer(new QSvgRenderer(this)) {
setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
@@ -56,10 +61,13 @@ void FontScaledSVG::updateScaledSize() {
QFontMetrics metrics(font());
qreal spacing = metrics.lineSpacing();
int baseFactor = 18;
constexpr int baseFactor = 18;
qreal scalingFactor = spacing / baseFactor;
QSize targetSize = baseSize * scalingFactor;
setFixedSize(targetSize);
}
} // namespace Gui
#include "moc_FontScaledSVG.cpp" // NOLINT

View File

@@ -1,23 +1,24 @@
/***************************************************************************
* Copyright (c) 2025 Alfredo Monclus <alfredomonclus@gmail.com> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 51 Franklin Street, *
* Fifth Floor, Boston, MA 02110-1301, USA *
* *
// SPDX-License-Identifier: LGPL-2.1-or-later
/****************************************************************************
* *
* Copyright (c) 2025 Alfredo Monclus <alfredomonclus@gmail.com> *
* *
* This file is part of FreeCAD. *
* *
* FreeCAD is free software: you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 2.1 of the *
* License, or (at your option) any later version. *
* *
* FreeCAD is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with FreeCAD. If not, see *
* <https://www.gnu.org/licenses/>. *
* *
***************************************************************************/
// This custom widget scales an svg according to fonts
@@ -25,7 +26,6 @@
#ifndef FONTSCALEDSVG_H
#define FONTSCALEDSVG_H
#include "PreCompiled.h"
#ifndef _PreComp_
#include <QWidget>
#include <QSvgRenderer>
@@ -33,6 +33,10 @@
#include <QFontMetrics>
#endif
#include <FCGlobal.h>
namespace Gui {
class GuiExport FontScaledSVG : public QWidget {
Q_OBJECT
@@ -50,4 +54,6 @@ private:
void updateScaledSize();
};
} // namespace Gui
#endif // FONTSCALEDSVG_H

View File

@@ -68,8 +68,8 @@ TaskHoleParameters::TaskHoleParameters(ViewProviderHole* HoleView, QWidget* pare
ui->ThreadType->addItem(tr("UTS extra fine"), QByteArray("UTS"));
ui->ThreadType->addItem(tr("ANSI pipes"), QByteArray("None"));
ui->ThreadType->addItem(tr("ISO/BSP pipes"), QByteArray("None"));
ui->ThreadType->addItem(tr("BSW whitworth"), QByteArray("BS"));
ui->ThreadType->addItem(tr("BSF whitworth fine"), QByteArray("BS"));
ui->ThreadType->addItem(tr("BSW whitworth"), QByteArray("None"));
ui->ThreadType->addItem(tr("BSF whitworth fine"), QByteArray("None"));
// read values from the hole properties
auto pcHole = getObject<PartDesign::Hole>();
@@ -465,9 +465,7 @@ void TaskHoleParameters::setCutDiagram()
baseFileName += "_flat";
}
ui->cutDiagram->setSvg(
QString::fromUtf8((":images/" + baseFileName + ".svg").c_str())
);
ui->cutDiagram->setSvg(QString::fromUtf8((":images/" + baseFileName + ".svg").c_str()));
}
void TaskHoleParameters::holeCutCustomValuesChanged()
@@ -794,259 +792,145 @@ void TaskHoleParameters::changedObject(const App::Document&, const App::Property
{
auto hole = getObject<PartDesign::Hole>();
if (!hole) {
// happens when aborting the command
return;
return; // happens when aborting the command
}
bool ro = Prop.isReadOnly();
Base::Console().Log("Parameter %s was updated\n", Prop.getName());
auto updateCheckable = [&](QCheckBox* widget, bool value) {
[[maybe_unused]] QSignalBlocker blocker(widget);
widget->setChecked(value);
widget->setDisabled(ro);
};
auto updateRadio = [&](QRadioButton* widget, bool value) {
[[maybe_unused]] QSignalBlocker blocker(widget);
widget->setChecked(value);
widget->setDisabled(ro);
};
auto updateComboBox = [&](QComboBox* widget, int value) {
[[maybe_unused]] QSignalBlocker blocker(widget);
widget->setCurrentIndex(value);
widget->setDisabled(ro);
};
auto updateSpinBox = [&](Gui::PrefQuantitySpinBox* widget, double value) {
[[maybe_unused]] QSignalBlocker blocker(widget);
widget->setValue(value);
widget->setDisabled(ro);
};
if (&Prop == &hole->Threaded) {
ui->Threaded->setEnabled(true);
if (ui->Threaded->isChecked() ^ hole->Threaded.getValue()) {
ui->Threaded->blockSignals(true);
ui->Threaded->setChecked(hole->Threaded.getValue());
ui->Threaded->blockSignals(false);
}
ui->Threaded->setDisabled(ro);
updateCheckable(ui->Threaded, hole->Threaded.getValue());
}
else if (&Prop == &hole->ThreadType) {
ui->ThreadType->setEnabled(true);
updateComboBox(ui->ThreadType, hole->ThreadType.getValue());
ui->ThreadSize->blockSignals(true);
ui->ThreadSize->clear();
std::vector<std::string> cursor = hole->ThreadSize.getEnumVector();
for (const auto& it : cursor) {
ui->ThreadSize->addItem(QString::fromStdString(it));
}
ui->ThreadSize->setCurrentIndex(hole->ThreadSize.getValue());
ui->ThreadSize->blockSignals(false);
// Thread type also updates related properties
auto updateComboBoxItems = [&](QComboBox* widget, const auto& values, int selected) {
QSignalBlocker blocker(widget);
widget->clear();
for (const auto& it : values) {
widget->addItem(QString::fromStdString(it));
}
widget->setCurrentIndex(selected);
};
// Thread type also updates HoleCutType and ThreadClass
ui->HoleCutType->blockSignals(true);
ui->HoleCutType->clear();
cursor = hole->HoleCutType.getEnumVector();
for (const auto& it : cursor) {
ui->HoleCutType->addItem(QString::fromStdString(it));
}
ui->HoleCutType->setCurrentIndex(hole->HoleCutType.getValue());
ui->HoleCutType->blockSignals(false);
ui->ThreadClass->blockSignals(true);
ui->ThreadClass->clear();
cursor = hole->ThreadClass.getEnumVector();
for (const auto& it : cursor) {
ui->ThreadClass->addItem(QString::fromStdString(it));
}
ui->ThreadClass->setCurrentIndex(hole->ThreadClass.getValue());
ui->ThreadClass->blockSignals(false);
if (ui->ThreadType->currentIndex() != hole->ThreadType.getValue()) {
ui->ThreadType->blockSignals(true);
ui->ThreadType->setCurrentIndex(hole->ThreadType.getValue());
ui->ThreadType->blockSignals(false);
}
ui->ThreadType->setDisabled(ro);
updateComboBoxItems(ui->ThreadSize, hole->ThreadSize.getEnumVector(), hole->ThreadSize.getValue());
updateComboBoxItems(ui->HoleCutType, hole->HoleCutType.getEnumVector(), hole->HoleCutType.getValue());
updateComboBoxItems(ui->ThreadClass, hole->ThreadClass.getEnumVector(), hole->ThreadClass.getValue());
}
else if (&Prop == &hole->ThreadSize) {
ui->ThreadSize->setEnabled(true);
if (ui->ThreadSize->currentIndex() != hole->ThreadSize.getValue()) {
ui->ThreadSize->blockSignals(true);
ui->ThreadSize->setCurrentIndex(hole->ThreadSize.getValue());
ui->ThreadSize->blockSignals(false);
}
ui->ThreadSize->setDisabled(ro);
updateComboBox(ui->ThreadSize, hole->ThreadSize.getValue());
}
else if (&Prop == &hole->ThreadClass) {
ui->ThreadClass->setEnabled(true);
if (ui->ThreadClass->currentIndex() != hole->ThreadClass.getValue()) {
ui->ThreadClass->blockSignals(true);
ui->ThreadClass->setCurrentIndex(hole->ThreadClass.getValue());
ui->ThreadClass->blockSignals(false);
}
ui->ThreadClass->setDisabled(ro);
updateComboBox(ui->ThreadClass, hole->ThreadClass.getValue());
}
else if (&Prop == &hole->ThreadFit) {
ui->ThreadFit->setEnabled(true);
if (ui->ThreadFit->currentIndex() != hole->ThreadFit.getValue()) {
ui->ThreadFit->blockSignals(true);
ui->ThreadFit->setCurrentIndex(hole->ThreadFit.getValue());
ui->ThreadFit->blockSignals(false);
}
ui->ThreadFit->setDisabled(ro);
updateComboBox(ui->ThreadFit, hole->ThreadFit.getValue());
}
else if (&Prop == &hole->Diameter) {
ui->Diameter->setEnabled(true);
if (ui->Diameter->value().getValue() != hole->Diameter.getValue()) {
ui->Diameter->blockSignals(true);
ui->Diameter->setValue(hole->Diameter.getValue());
ui->Diameter->blockSignals(false);
}
ui->Diameter->setDisabled(ro);
updateSpinBox(ui->Diameter, hole->Diameter.getValue());
}
else if (&Prop == &hole->ThreadDirection) {
ui->directionRightHand->setEnabled(true);
ui->directionLeftHand->setEnabled(true);
std::string direction(hole->ThreadDirection.getValueAsString());
if (direction == "Right" && !ui->directionRightHand->isChecked()) {
ui->directionRightHand->blockSignals(true);
ui->directionRightHand->setChecked(true);
ui->directionRightHand->blockSignals(false);
}
if (direction == "Left" && !ui->directionLeftHand->isChecked()) {
ui->directionLeftHand->blockSignals(true);
ui->directionLeftHand->setChecked(true);
ui->directionLeftHand->blockSignals(false);
}
ui->directionRightHand->setDisabled(ro);
ui->directionLeftHand->setDisabled(ro);
updateRadio(ui->directionRightHand, direction == "Right");
updateRadio(ui->directionLeftHand, direction == "Left");
}
else if (&Prop == &hole->HoleCutType) {
ui->HoleCutType->setEnabled(true);
if (ui->HoleCutType->currentIndex() != hole->HoleCutType.getValue()) {
ui->HoleCutType->blockSignals(true);
ui->HoleCutType->setCurrentIndex(hole->HoleCutType.getValue());
ui->HoleCutType->blockSignals(false);
}
ui->HoleCutType->setDisabled(ro);
updateComboBox(ui->HoleCutType, hole->HoleCutType.getValue());
}
else if (&Prop == &hole->HoleCutDiameter) {
ui->HoleCutDiameter->setEnabled(true);
if (ui->HoleCutDiameter->value().getValue() != hole->HoleCutDiameter.getValue()) {
ui->HoleCutDiameter->blockSignals(true);
ui->HoleCutDiameter->setValue(hole->HoleCutDiameter.getValue());
ui->HoleCutDiameter->blockSignals(false);
}
ui->HoleCutDiameter->setDisabled(ro);
updateSpinBox(ui->HoleCutDiameter, hole->HoleCutDiameter.getValue());
}
else if (&Prop == &hole->HoleCutDepth) {
ui->HoleCutDepth->setEnabled(true);
if (ui->HoleCutDepth->value().getValue() != hole->HoleCutDepth.getValue()) {
ui->HoleCutDepth->blockSignals(true);
ui->HoleCutDepth->setValue(hole->HoleCutDepth.getValue());
ui->HoleCutDepth->blockSignals(false);
}
ui->HoleCutDepth->setDisabled(ro);
updateSpinBox(ui->HoleCutDepth, hole->HoleCutDepth.getValue());
}
else if (&Prop == &hole->HoleCutCountersinkAngle) {
ui->HoleCutCountersinkAngle->setEnabled(true);
if (ui->HoleCutCountersinkAngle->value().getValue()
!= hole->HoleCutCountersinkAngle.getValue()) {
ui->HoleCutCountersinkAngle->blockSignals(true);
ui->HoleCutCountersinkAngle->setValue(hole->HoleCutCountersinkAngle.getValue());
ui->HoleCutCountersinkAngle->blockSignals(false);
}
ui->HoleCutCountersinkAngle->setDisabled(ro);
updateSpinBox(ui->HoleCutCountersinkAngle, hole->HoleCutCountersinkAngle.getValue());
}
else if (&Prop == &hole->DepthType) {
ui->DepthType->setEnabled(true);
if (ui->DepthType->currentIndex() != hole->DepthType.getValue()) {
ui->DepthType->blockSignals(true);
ui->DepthType->setCurrentIndex(hole->DepthType.getValue());
ui->DepthType->blockSignals(false);
}
ui->DepthType->setDisabled(ro);
updateComboBox(ui->DepthType, hole->DepthType.getValue());
}
else if (&Prop == &hole->Depth) {
ui->Depth->setEnabled(true);
if (ui->Depth->value().getValue() != hole->Depth.getValue()) {
ui->Depth->blockSignals(true);
ui->Depth->setValue(hole->Depth.getValue());
ui->Depth->blockSignals(false);
}
ui->Depth->setDisabled(ro);
updateSpinBox(ui->Depth, hole->Depth.getValue());
}
else if (&Prop == &hole->DrillPoint) {
std::string drillPoint(hole->DrillPoint.getValueAsString());
ui->DrillPointAngled->setEnabled(true);
if (ui->DrillPointAngled->isChecked() ^ (drillPoint == "Angled")) {
ui->DrillPointAngled->blockSignals(true);
ui->DrillPointAngled->setChecked(drillPoint == "Angled");
ui->DrillPointAngled->blockSignals(false);
}
ui->DrillPointAngled->setDisabled(ro);
updateCheckable(ui->DrillPointAngled, hole->DrillPoint.getValueAsString() == std::string("Angled"));
}
else if (&Prop == &hole->DrillPointAngle) {
ui->DrillPointAngle->setEnabled(true);
if (ui->DrillPointAngle->value().getValue() != hole->DrillPointAngle.getValue()) {
ui->DrillPointAngle->blockSignals(true);
ui->DrillPointAngle->setValue(hole->DrillPointAngle.getValue());
ui->DrillPointAngle->blockSignals(false);
}
ui->DrillPointAngle->setDisabled(ro);
updateSpinBox(ui->DrillPointAngle, hole->DrillPointAngle.getValue());
}
else if (&Prop == &hole->DrillForDepth) {
ui->DrillForDepth->setEnabled(true);
if (ui->DrillForDepth->isChecked() ^ hole->DrillForDepth.getValue()) {
ui->DrillForDepth->blockSignals(true);
ui->DrillForDepth->setChecked(hole->DrillForDepth.getValue());
ui->DrillForDepth->blockSignals(false);
}
ui->DrillForDepth->setDisabled(ro);
updateCheckable(ui->DrillForDepth, hole->DrillForDepth.getValue());
}
else if (&Prop == &hole->Tapered) {
ui->Tapered->setEnabled(true);
if (ui->Tapered->isChecked() ^ hole->Tapered.getValue()) {
ui->Tapered->blockSignals(true);
ui->Tapered->setChecked(hole->Tapered.getValue());
ui->Tapered->blockSignals(false);
}
ui->Tapered->setDisabled(ro);
updateCheckable(ui->Tapered, hole->Tapered.getValue());
}
else if (&Prop == &hole->TaperedAngle) {
ui->TaperedAngle->setEnabled(true);
if (ui->TaperedAngle->value().getValue() != hole->TaperedAngle.getValue()) {
ui->TaperedAngle->blockSignals(true);
ui->TaperedAngle->setValue(hole->TaperedAngle.getValue());
ui->TaperedAngle->blockSignals(false);
}
ui->TaperedAngle->setDisabled(ro);
updateSpinBox(ui->TaperedAngle, hole->TaperedAngle.getValue());
}
else if (&Prop == &hole->ModelThread) {
ui->ModelThread->setEnabled(true);
if (ui->ModelThread->isChecked() ^ hole->ModelThread.getValue()) {
ui->ModelThread->blockSignals(true);
ui->ModelThread->setChecked(hole->ModelThread.getValue());
ui->ModelThread->blockSignals(false);
}
ui->ModelThread->setDisabled(ro);
updateCheckable(ui->ModelThread, hole->ModelThread.getValue());
}
else if (&Prop == &hole->UseCustomThreadClearance) {
ui->UseCustomThreadClearance->setEnabled(true);
if (ui->UseCustomThreadClearance->isChecked() ^ hole->UseCustomThreadClearance.getValue()) {
ui->UseCustomThreadClearance->blockSignals(true);
ui->UseCustomThreadClearance->setChecked(hole->UseCustomThreadClearance.getValue());
ui->UseCustomThreadClearance->blockSignals(false);
}
ui->UseCustomThreadClearance->setDisabled(ro);
updateCheckable(ui->UseCustomThreadClearance, hole->UseCustomThreadClearance.getValue());
}
else if (&Prop == &hole->CustomThreadClearance) {
ui->CustomThreadClearance->setEnabled(true);
if (ui->CustomThreadClearance->value().getValue()
!= hole->CustomThreadClearance.getValue()) {
ui->CustomThreadClearance->blockSignals(true);
ui->CustomThreadClearance->setValue(hole->CustomThreadClearance.getValue());
ui->CustomThreadClearance->blockSignals(false);
}
ui->CustomThreadClearance->setDisabled(ro);
updateSpinBox(ui->CustomThreadClearance, hole->CustomThreadClearance.getValue());
}
else if (&Prop == &hole->ThreadDepthType) {
ui->ThreadDepthType->setEnabled(true);
if (ui->ThreadDepthType->currentIndex() != hole->ThreadDepthType.getValue()) {
ui->ThreadDepthType->blockSignals(true);
ui->ThreadDepthType->setCurrentIndex(hole->ThreadDepthType.getValue());
ui->ThreadDepthType->blockSignals(false);
}
ui->ThreadDepthType->setDisabled(ro);
updateComboBox(ui->ThreadDepthType, hole->ThreadDepthType.getValue());
}
else if (&Prop == &hole->ThreadDepth) {
ui->ThreadDepth->setEnabled(true);
if (ui->ThreadDepth->value().getValue() != hole->ThreadDepth.getValue()) {
ui->ThreadDepth->blockSignals(true);
ui->ThreadDepth->setValue(hole->ThreadDepth.getValue());
ui->ThreadDepth->blockSignals(false);
}
ui->ThreadDepth->setDisabled(ro);
updateSpinBox(ui->ThreadDepth, hole->ThreadDepth.getValue());
}
}
@@ -1149,11 +1033,7 @@ Base::Quantity TaskHoleParameters::getDepth() const
long TaskHoleParameters::getDrillPoint() const
{
if (ui->DrillPointAngled->isChecked()) {
return 1;
}
return 0;
return ui->DrillPointAngled->isChecked() ? 1 : 0;
}
Base::Quantity TaskHoleParameters::getDrillPointAngle() const

View File

@@ -38,7 +38,7 @@
<number>10</number>
</property>
<item row="2" column="0">
<widget class="ElideLabel" name="labelDepthType">
<widget class="Gui::ElideLabel" name="labelDepthType">
<property name="sizePolicy">
<sizepolicy hsizetype="Ignored" vsizetype="Preferred">
<horstretch>0</horstretch>
@@ -77,7 +77,7 @@
</widget>
</item>
<item row="0" column="0">
<widget class="ElideLabel" name="labelHeadType">
<widget class="Gui::ElideLabel" name="labelHeadType">
<property name="sizePolicy">
<sizepolicy hsizetype="Ignored" vsizetype="Preferred">
<horstretch>0</horstretch>
@@ -108,7 +108,7 @@
</layout>
</item>
<item>
<widget class="ElideCheckBox" name="HoleCutCustomValues">
<widget class="Gui::ElideCheckBox" name="HoleCutCustomValues">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
@@ -156,7 +156,7 @@
<item>
<layout class="QVBoxLayout" name="verticalLayout_13">
<item>
<widget class="ElideLabel" name="labelHoleCutDiameter">
<widget class="Gui::ElideLabel" name="labelHoleCutDiameter">
<property name="sizePolicy">
<sizepolicy hsizetype="Ignored" vsizetype="Fixed">
<horstretch>0</horstretch>
@@ -198,7 +198,7 @@
<item>
<layout class="QVBoxLayout" name="verticalLayout_12">
<item>
<widget class="ElideLabel" name="labelHoleCutDepth">
<widget class="Gui::ElideLabel" name="labelHoleCutDepth">
<property name="sizePolicy">
<sizepolicy hsizetype="Ignored" vsizetype="Fixed">
<horstretch>0</horstretch>
@@ -266,7 +266,7 @@ the screw's top below the surface</string>
<number>0</number>
</property>
<item>
<widget class="ElideCheckBox" name="DrillPointAngled">
<widget class="Gui::ElideCheckBox" name="DrillPointAngled">
<property name="sizePolicy">
<sizepolicy hsizetype="Ignored" vsizetype="Fixed">
<horstretch>0</horstretch>
@@ -298,7 +298,7 @@ the screw's top below the surface</string>
</widget>
</item>
<item>
<widget class="ElideCheckBox" name="DrillForDepth">
<widget class="Gui::ElideCheckBox" name="DrillForDepth">
<property name="sizePolicy">
<sizepolicy hsizetype="Ignored" vsizetype="Fixed">
<horstretch>0</horstretch>
@@ -320,7 +320,7 @@ account for the depth of blind holes</string>
</layout>
</item>
<item>
<widget class="FontScaledSVG" name="cutDiagram" native="true">
<widget class="Gui::FontScaledSVG" name="cutDiagram" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
@@ -355,7 +355,7 @@ account for the depth of blind holes</string>
<item>
<layout class="QVBoxLayout" name="verticalLayout_9">
<item>
<widget class="ElideLabel" name="labelHoleCutCountersinkAngle">
<widget class="Gui::ElideLabel" name="labelHoleCutCountersinkAngle">
<property name="sizePolicy">
<sizepolicy hsizetype="Ignored" vsizetype="Fixed">
<horstretch>0</horstretch>
@@ -394,7 +394,7 @@ account for the depth of blind holes</string>
<item>
<layout class="QVBoxLayout" name="verticalLayout_10">
<item>
<widget class="ElideLabel" name="labelDepth">
<widget class="Gui::ElideLabel" name="labelDepth">
<property name="sizePolicy">
<sizepolicy hsizetype="Ignored" vsizetype="Fixed">
<horstretch>0</horstretch>
@@ -430,7 +430,7 @@ account for the depth of blind holes</string>
<item>
<layout class="QVBoxLayout" name="verticalLayout_11">
<item>
<widget class="ElideLabel" name="labelDiameter">
<widget class="Gui::ElideLabel" name="labelDiameter">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
@@ -485,7 +485,7 @@ account for the depth of blind holes</string>
<number>0</number>
</property>
<item>
<widget class="ElideCheckBox" name="Reversed">
<widget class="Gui::ElideCheckBox" name="Reversed">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
@@ -561,7 +561,7 @@ over 90: larger hole radius at the bottom</string>
</widget>
</item>
<item row="2" column="0">
<widget class="ElideLabel" name="labelSize">
<widget class="Gui::ElideLabel" name="labelSize">
<property name="sizePolicy">
<sizepolicy hsizetype="Ignored" vsizetype="Preferred">
<horstretch>0</horstretch>
@@ -584,7 +584,7 @@ over 90: larger hole radius at the bottom</string>
</widget>
</item>
<item row="1" column="0">
<widget class="ElideLabel" name="labelThreadType">
<widget class="Gui::ElideLabel" name="labelThreadType">
<property name="sizePolicy">
<sizepolicy hsizetype="Ignored" vsizetype="Preferred">
<horstretch>0</horstretch>
@@ -636,7 +636,7 @@ over 90: larger hole radius at the bottom</string>
<number>0</number>
</property>
<item>
<widget class="ElideLabel" name="labelThreadClearance">
<widget class="Gui::ElideLabel" name="labelThreadClearance">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
@@ -732,7 +732,7 @@ Only available for holes without thread</string>
</widget>
</item>
<item row="0" column="0">
<widget class="ElideLabel" name="labelThreadClass">
<widget class="Gui::ElideLabel" name="labelThreadClass">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
@@ -820,7 +820,7 @@ Only available for holes without thread</string>
<number>0</number>
</property>
<item>
<widget class="ElideCheckBox" name="ModelThread">
<widget class="Gui::ElideCheckBox" name="ModelThread">
<property name="sizePolicy">
<sizepolicy hsizetype="Ignored" vsizetype="Fixed">
<horstretch>0</horstretch>
@@ -836,7 +836,7 @@ Only available for holes without thread</string>
</widget>
</item>
<item>
<widget class="ElideCheckBox" name="UpdateView">
<widget class="Gui::ElideCheckBox" name="UpdateView">
<property name="enabled">
<bool>true</bool>
</property>
@@ -887,7 +887,7 @@ Note that the calculation can take some time</string>
<number>0</number>
</property>
<item>
<widget class="ElideLabel" name="labelThreadDepthType">
<widget class="Gui::ElideLabel" name="labelThreadDepthType">
<property name="sizePolicy">
<sizepolicy hsizetype="Ignored" vsizetype="Minimum">
<horstretch>0</horstretch>
@@ -989,7 +989,7 @@ Note that the calculation can take some time</string>
<number>0</number>
</property>
<item>
<widget class="ElideCheckBox" name="UseCustomThreadClearance">
<widget class="Gui::ElideCheckBox" name="UseCustomThreadClearance">
<property name="sizePolicy">
<sizepolicy hsizetype="Ignored" vsizetype="Fixed">
<horstretch>0</horstretch>
@@ -1049,17 +1049,17 @@ Note that the calculation can take some time</string>
<header>Gui/PrefWidgets.h</header>
</customwidget>
<customwidget>
<class>ElideLabel</class>
<class>Gui::ElideLabel</class>
<extends>QLabel</extends>
<header>Gui/ElideLabel.h</header>
</customwidget>
<customwidget>
<class>ElideCheckBox</class>
<class>Gui::ElideCheckBox</class>
<extends>QCheckBox</extends>
<header>Gui/ElideCheckBox.h</header>
</customwidget>
<customwidget>
<class>FontScaledSVG</class>
<class>Gui::FontScaledSVG</class>
<extends>QWidget</extends>
<header>Gui/FontScaledSVG.h</header>
<container>1</container>