FreeCAD WebAssembly development snapshot
Some checks failed
FreeCAD master CI / Prepare (push) Has been cancelled
FreeCAD master CI / Pixi (push) Has been cancelled
FreeCAD master CI / Ubuntu (push) Has been cancelled
FreeCAD master CI / Windows (push) Has been cancelled
FreeCAD master CI / Lint (push) Has been cancelled
FreeCAD master CI / WrapUp (push) Has been cancelled
CodeQL Advanced / Analyze (actions) (push) Has been cancelled
CodeQL Advanced / Analyze (python) (push) Has been cancelled
Scorecard supply-chain security / Scorecard analysis (push) Has been cancelled
Stale Issues / stale (push) Has been cancelled

This commit is contained in:
2026-08-20 07:00:53 +08:00
commit b5a086fda5
12718 changed files with 7841410 additions and 0 deletions

62
src/Gui/SplitButton.cpp Normal file
View File

@@ -0,0 +1,62 @@
// SPDX-License-Identifier: LGPL-2.1-or-later
/****************************************************************************
* *
* Copyright (c) 2025 Kacper Donat <kacper@kadet.net> *
* *
* 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/>. *
* *
***************************************************************************/
#include "SplitButton.h"
#include <QHBoxLayout>
using namespace Gui;
SplitButton::SplitButton(QWidget* parent)
: SplitButton(QStringLiteral(""), parent)
{}
SplitButton::SplitButton(const QString& text, QWidget* parent)
: QWidget(parent)
, m_main(new QPushButton(text, this))
, m_menuButton(new QToolButton(this))
, m_menu(new QMenu(this))
{
auto* layout = new QHBoxLayout(this);
layout->setContentsMargins(0, 0, 0, 0);
layout->setSpacing(0);
layout->addWidget(m_main);
layout->addWidget(m_menuButton);
// Behavior
m_main->setAutoDefault(false);
m_main->setDefault(false);
m_menuButton->setMenu(m_menu);
m_menuButton->setPopupMode(QToolButton::InstantPopup);
m_menuButton->setArrowType(Qt::DownArrow);
m_menuButton->setToolButtonStyle(Qt::ToolButtonIconOnly);
connect(m_main, &QPushButton::clicked, this, &SplitButton::defaultClicked);
connect(m_menu, &QMenu::triggered, this, &SplitButton::triggered);
// Styling to make it look like a single split button
m_main->setProperty("splitRole", QLatin1String("main"));
m_menuButton->setProperty("splitRole", QLatin1String("menu"));
}