PD(hole taskpanel): Add image-based hole cut panel

* feat(PD): hole taskpanel: new image based cut panel
* fix(PD): hole taskpanel fix dynamic cut types
* refactor(PD): hole taskpanel: renames and vlayouts to keep labels closer
* fix(PD): hole diagram tweaks
This commit is contained in:
Alfredo Monclus
2025-01-20 16:50:51 -03:00
committed by Chris Hennes
parent 99df928459
commit c7e764193c
19 changed files with 2167 additions and 763 deletions

68
src/Gui/ElideCheckBox.cpp Normal file
View File

@@ -0,0 +1,68 @@
/***************************************************************************
* 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 *
* *
***************************************************************************/
// This custom widget adds the missing ellipsize functionality in QT5
#include "ElideCheckBox.h"
const int CheckboxSpacing = 25;
ElideCheckBox::ElideCheckBox(QWidget *parent)
: QCheckBox(parent) {
}
void ElideCheckBox::paintEvent(QPaintEvent *event) {
Q_UNUSED(event);
QStyleOptionButton option;
option.initFrom(this);
option.state = (isChecked() ? QStyle::State_On : QStyle::State_Off) |
(isEnabled() ? QStyle::State_Enabled : QStyle::State_ReadOnly);
QPainter painter(this);
style()->drawControl(QStyle::CE_CheckBox, &option, &painter, this);
QRect textRect = option.rect;
int padding = 4;
textRect.setX(textRect.x() + 25);
QFontMetrics fm(font());
QString elidedText = fm.elidedText(text(), Qt::ElideRight, textRect.width() - padding);
painter.setPen(palette().color(QPalette::WindowText));
painter.drawText(textRect, Qt::AlignLeft | Qt::AlignVCenter, elidedText);
}
QSize ElideCheckBox::sizeHint() const {
QFontMetrics fm(font());
int width = fm.horizontalAdvance(this->text()) + CheckboxSpacing;
int height = fm.height();
return QSize(width, height);
}
QSize ElideCheckBox::minimumSizeHint() const {
QFontMetrics fm(font());
QString minimumText = QStringLiteral("A...");
int width = fm.horizontalAdvance(minimumText) + CheckboxSpacing;
int height = fm.height();
return QSize(width, height);
}