| 1 |
// SPDX-License-Identifier: LGPL-2.1-or-later |
| 2 |
/**************************************************************************** |
| 3 |
* * |
| 4 |
* Copyright (c) 2025 Kacper Donat <[email protected]> * |
| 5 |
* * |
| 6 |
* This file is part of FreeCAD. * |
| 7 |
* * |
| 8 |
* FreeCAD is free software: you can redistribute it and/or modify it * |
| 9 |
* under the terms of the GNU Lesser General Public License as * |
| 10 |
* published by the Free Software Foundation, either version 2.1 of the * |
| 11 |
* License, or (at your option) any later version. * |
| 12 |
* * |
| 13 |
* FreeCAD is distributed in the hope that it will be useful, but * |
| 14 |
* WITHOUT ANY WARRANTY; without even the implied warranty of * |
| 15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * |
| 16 |
* Lesser General Public License for more details. * |
| 17 |
* * |
| 18 |
* You should have received a copy of the GNU Lesser General Public * |
| 19 |
* License along with FreeCAD. If not, see * |
| 20 |
* <https://www.gnu.org/licenses/>. * |
| 21 |
* * |
| 22 |
***************************************************************************/ |
| 23 |
|
| 24 |
#include "FreeCADStyle.h" |
| 25 |
|
| 26 |
using namespace Gui; |
| 27 |
|
| 28 |
bool FreeCADStyle::eventFilter(QObject* obj, QEvent* event) |
| 29 |
{ |
| 30 |
// This is a hacky fix for https://github.com/FreeCAD/FreeCAD/issues/23607 |
| 31 |
// Basically after widget is shown or polished we enforce it's minimum size to at least cover |
| 32 |
// the minimum size hint - something that QSS ignores if min-width is specified |
| 33 |
if (event->type() == QEvent::Polish || event->type() == QEvent::Show) { |
| 34 |
if (auto* btn = qobject_cast<QPushButton*>(obj)) { |
| 35 |
btn->setMinimumWidth(std::max(btn->minimumSizeHint().width(), btn->minimumWidth())); |
| 36 |
} |
| 37 |
} |
| 38 |
|
| 39 |
return QObject::eventFilter(obj, event); |
| 40 |
} |