All: Reformat according to new standard

This commit is contained in:
pre-commit-ci[bot]
2025-11-11 13:49:01 +01:00
committed by Kacper Donat
parent ef997f2259
commit 9fe130cd73
2390 changed files with 154630 additions and 115818 deletions

View File

@@ -24,29 +24,28 @@
#include <FCConfig.h>
#ifdef FC_OS_WIN32
#include <Windows.h>
# include <Windows.h>
#elif defined(Q_OS_UNIX)
# include <sys/types.h>
# include <ctime>
# include <unistd.h>
#endif
# include <sstream>
# include <QAbstractSpinBox>
# include <QByteArray>
# include <QComboBox>
# include <QTextStream>
# include <QFileInfo>
# include <QFileOpenEvent>
# include <QSessionManager>
# include <QTimer>
#include <sstream>
#include <QAbstractSpinBox>
#include <QByteArray>
#include <QComboBox>
#include <QTextStream>
#include <QFileInfo>
#include <QFileOpenEvent>
#include <QSessionManager>
#include <QTimer>
#include <QLocalServer>
#include <QLocalSocket>
#include <App/Application.h>
#include <Base/Console.h>
#include <Base/Exception.h>
@@ -59,23 +58,30 @@
using namespace Gui;
GUIApplication::GUIApplication(int & argc, char ** argv)
GUIApplication::GUIApplication(int& argc, char** argv)
: GUIApplicationNativeEventAware(argc, argv)
{
connect(this, &GUIApplication::commitDataRequest,
this, &GUIApplication::commitData, Qt::DirectConnection);
#if QT_VERSION < QT_VERSION_CHECK(6,0,0)
connect(
this,
&GUIApplication::commitDataRequest,
this,
&GUIApplication::commitData,
Qt::DirectConnection
);
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
setFallbackSessionManagementEnabled(false);
#endif
}
GUIApplication::~GUIApplication() = default;
bool GUIApplication::notify (QObject * receiver, QEvent * event)
bool GUIApplication::notify(QObject* receiver, QEvent* event)
{
if (!receiver) {
Base::Console().log("GUIApplication::notify: Unexpected null receiver, event type: %d\n",
(int)event->type());
Base::Console().log(
"GUIApplication::notify: Unexpected null receiver, event type: %d\n",
(int)event->type()
);
return false;
}
@@ -89,28 +95,40 @@ bool GUIApplication::notify (QObject * receiver, QEvent * event)
#endif
try {
if (event->type() == Spaceball::ButtonEvent::ButtonEventType ||
event->type() == Spaceball::MotionEvent::MotionEventType)
if (event->type() == Spaceball::ButtonEvent::ButtonEventType
|| event->type() == Spaceball::MotionEvent::MotionEventType) {
return processSpaceballEvent(receiver, event);
else
}
else {
return QApplication::notify(receiver, event);
}
}
catch (const Base::SystemExitException &e) {
catch (const Base::SystemExitException& e) {
caughtException.reset(new Base::SystemExitException(e));
qApp->exit(e.getExitCode());
return true;
}
catch (const Base::Exception& e) {
Base::Console().error("Unhandled Base::Exception caught in GUIApplication::notify.\n"
"The error message is: %s\n%s", e.what(), exceptionWarning);
Base::Console().error(
"Unhandled Base::Exception caught in GUIApplication::notify.\n"
"The error message is: %s\n%s",
e.what(),
exceptionWarning
);
}
catch (const std::exception& e) {
Base::Console().error("Unhandled std::exception caught in GUIApplication::notify.\n"
"The error message is: %s\n%s", e.what(), exceptionWarning);
Base::Console().error(
"Unhandled std::exception caught in GUIApplication::notify.\n"
"The error message is: %s\n%s",
e.what(),
exceptionWarning
);
}
catch (...) {
Base::Console().error("Unhandled unknown exception caught in GUIApplication::notify.\n%s",
exceptionWarning);
Base::Console().error(
"Unhandled unknown exception caught in GUIApplication::notify.\n%s",
exceptionWarning
);
}
// Print some more information to the log file (if active) to ease bug fixing
@@ -125,14 +143,16 @@ bool GUIApplication::notify (QObject * receiver, QEvent * event)
dump << "\t";
dump << w->metaObject()->className();
QString name = w->objectName();
if (!name.isEmpty())
if (!name.isEmpty()) {
dump << " (" << (const char*)name.toUtf8() << ")";
}
w = w->parentWidget();
if (w)
if (w) {
dump << " is child of\n";
}
}
std::string str = dump.str();
Base::Console().log("%s",str.c_str());
Base::Console().log("%s", str.c_str());
}
}
catch (...) {
@@ -142,7 +162,7 @@ bool GUIApplication::notify (QObject * receiver, QEvent * event)
return true;
}
void GUIApplication::commitData(QSessionManager &manager)
void GUIApplication::commitData(QSessionManager& manager)
{
if (manager.allowsInteraction()) {
if (!Gui::getMainWindow()->close()) {
@@ -159,7 +179,7 @@ void GUIApplication::commitData(QSessionManager &manager)
}
}
bool GUIApplication::event(QEvent * ev)
bool GUIApplication::event(QEvent* ev)
{
if (ev->type() == QEvent::FileOpen) {
// (macOS workaround when opening FreeCAD by opening a .FCStd file in 1.0)
@@ -190,11 +210,12 @@ bool GUIApplication::event(QEvent * ev)
// ----------------------------------------------------------------------------
class GUISingleApplication::Private {
class GUISingleApplication::Private
{
public:
explicit Private(GUISingleApplication *q_ptr)
: q_ptr(q_ptr)
, timer(new QTimer(q_ptr))
explicit Private(GUISingleApplication* q_ptr)
: q_ptr(q_ptr)
, timer(new QTimer(q_ptr))
{
timer->setSingleShot(true);
std::string exeName = App::Application::getExecutableName();
@@ -203,8 +224,9 @@ public:
~Private()
{
if (server)
if (server) {
server->close();
}
delete server;
}
@@ -224,8 +246,12 @@ public:
{
// Start a QLocalServer to listen for connections
server = new QLocalServer();
QObject::connect(server, &QLocalServer::newConnection,
q_ptr, &GUISingleApplication::receiveConnection);
QObject::connect(
server,
&QLocalServer::newConnection,
q_ptr,
&GUISingleApplication::receiveConnection
);
// first attempt
if (!server->listen(serverName)) {
if (server->serverError() == QAbstractSocket::AddressInUseError) {
@@ -242,17 +268,17 @@ public:
}
}
GUISingleApplication *q_ptr;
QTimer *timer;
QLocalServer *server{nullptr};
GUISingleApplication* q_ptr;
QTimer* timer;
QLocalServer* server {nullptr};
QString serverName;
QList<QString> messages;
bool running{false};
bool running {false};
};
GUISingleApplication::GUISingleApplication(int & argc, char ** argv)
: GUIApplication(argc, argv),
d_ptr(new Private(this))
GUISingleApplication::GUISingleApplication(int& argc, char** argv)
: GUIApplication(argc, argv)
, d_ptr(new Private(this))
{
d_ptr->setupConnection();
connect(d_ptr->timer, &QTimer::timeout, this, &GUISingleApplication::processMessages);
@@ -265,13 +291,13 @@ bool GUISingleApplication::isRunning() const
return d_ptr->running;
}
bool GUISingleApplication::sendMessage(const QString &message, int timeout)
bool GUISingleApplication::sendMessage(const QString& message, int timeout)
{
QLocalSocket socket;
bool connected = false;
for(int i = 0; i < 2; i++) {
for (int i = 0; i < 2; i++) {
socket.connectToServer(d_ptr->serverName);
connected = socket.waitForConnected(timeout/2);
connected = socket.waitForConnected(timeout / 2);
if (connected || i > 0) {
break;
}
@@ -279,7 +305,7 @@ bool GUISingleApplication::sendMessage(const QString &message, int timeout)
#if defined(Q_OS_WIN)
Sleep(DWORD(ms));
#else
usleep(ms*1000);
usleep(ms * 1000);
#endif
}
if (!connected) {
@@ -323,13 +349,12 @@ void GUISingleApplication::readFromSocket()
void GUISingleApplication::receiveConnection()
{
QLocalSocket *socket = d_ptr->server->nextPendingConnection();
QLocalSocket* socket = d_ptr->server->nextPendingConnection();
if (!socket) {
return;
}
connect(socket, &QLocalSocket::disconnected,
socket, &QLocalSocket::deleteLater);
connect(socket, &QLocalSocket::disconnected, socket, &QLocalSocket::deleteLater);
connect(socket, &QLocalSocket::readyRead, this, &GUISingleApplication::readFromSocket);
}
@@ -343,14 +368,14 @@ void GUISingleApplication::processMessages()
// ----------------------------------------------------------------------------
WheelEventFilter::WheelEventFilter(QObject* parent)
: QObject(parent)
{
}
: QObject(parent)
{}
bool WheelEventFilter::eventFilter(QObject* obj, QEvent* ev)
{
if (qobject_cast<QComboBox*>(obj) && ev->type() == QEvent::Wheel)
if (qobject_cast<QComboBox*>(obj) && ev->type() == QEvent::Wheel) {
return true;
}
auto sb = qobject_cast<QAbstractSpinBox*>(obj);
if (sb) {
if (ev->type() == QEvent::Show) {