OpenToonz - An open-source full-featured 2D animation creation software
C
style(ui): match clang-format 14 used by CI
Ahl76a656cf86927e
diff --git a/toonz/sources/toonz/custompanelmanager.cpp b/toonz/sources/toonz/custompanelmanager.cppindex 1ac96372b..1368d135e 100644--- a/toonz/sources/toonz/custompanelmanager.cpp+++ b/toonz/sources/toonz/custompanelmanager.cpp@@ -54,8 +54,9 @@ QString relativePanelId(const TFilePath& file, const TFilePath& rootFolder) {}TFilePath panelFilePath(const QString& panelId) {- TFilePath path = customPaneFolderPath();- const QStringList parts = normalizePanelId(panelId).split('/', Qt::SkipEmptyParts);+ TFilePath path = customPaneFolderPath();+ const QStringList parts =+ normalizePanelId(panelId).split('/', Qt::SkipEmptyParts);for (int i = 0; i < parts.size(); ++i) {if (i == parts.size() - 1)path = path + TFilePath(parts[i] + ".ui");@@ -83,14 +84,14 @@ void collectUiPanelIds(const TFilePath& folder, const TFilePath& rootFolder,std::sort(dirs.begin(), dirs.end(),[](const TFilePath& a, const TFilePath& b) {return QString::compare(QString::fromStdString(a.getName()),- QString::fromStdString(b.getName()),- Qt::CaseInsensitive) < 0;+ QString::fromStdString(b.getName()),+ Qt::CaseInsensitive) < 0;});std::sort(files.begin(), files.end(),[](const TFilePath& a, const TFilePath& b) {return QString::compare(QString::fromStdString(a.getName()),- QString::fromStdString(b.getName()),- Qt::CaseInsensitive) < 0;+ QString::fromStdString(b.getName()),+ Qt::CaseInsensitive) < 0;});if (depth < kMaxCustomPanelFolderDepth) {@@ -120,20 +121,19 @@ void populateCustomPanelMenu(QMenu* menu, const TFilePath& folder, int depth,std::sort(dirs.begin(), dirs.end(),[](const TFilePath& a, const TFilePath& b) {return QString::compare(QString::fromStdString(a.getName()),- QString::fromStdString(b.getName()),- Qt::CaseInsensitive) < 0;+ QString::fromStdString(b.getName()),+ Qt::CaseInsensitive) < 0;});std::sort(files.begin(), files.end(),[](const TFilePath& a, const TFilePath& b) {return QString::compare(QString::fromStdString(a.getName()),- QString::fromStdString(b.getName()),- Qt::CaseInsensitive) < 0;+ QString::fromStdString(b.getName()),+ Qt::CaseInsensitive) < 0;});if (depth < kMaxCustomPanelFolderDepth) {for (const auto& dir : dirs) {- QMenu* subMenu =- new QMenu(QString::fromStdString(dir.getName()), menu);+ QMenu* subMenu = new QMenu(QString::fromStdString(dir.getName()), menu);populateCustomPanelMenu(subMenu, dir, depth + 1, menuPanelIds);if (subMenu->isEmpty()) {delete subMenu;@@ -145,10 +145,10 @@ void populateCustomPanelMenu(QMenu* menu, const TFilePath& folder, int depth,for (const auto& file : files) {// Proxy menu actions (not the CommandManager actions): a QAction can only- // belong to one menu, and command actions must stay available for shortcuts.+ // belong to one menu, and command actions must stay available for+ // shortcuts.QString panelId = relativePanelId(file, customPaneFolderPath());- QAction* leaf =- menu->addAction(QString::fromStdString(file.getName()));+ QAction* leaf = menu->addAction(QString::fromStdString(file.getName()));leaf->setData(menuPanelIds.size());menuPanelIds.append(panelId);}@@ -275,7 +275,8 @@ TPanel* CustomPanelManager::createCustomPanel(const QString panelName,initializeControl(customWidget);- panel->setWindowTitle(QFileInfo(customPanelsFp.getQString()).completeBaseName());+ panel->setWindowTitle(+ QFileInfo(customPanelsFp.getQString()).completeBaseName());panel->setWidget(customWidget);// Enable room binding feature (handled by TPanel base class)@@ -289,7 +290,7 @@ TPanel* CustomPanelManager::createCustomPanel(const QString panelName,void CustomPanelManager::initializeControl(QWidget* customWidget) {// Update checked states before initializing controlsToolPresetCommandManager::instance()->updateCheckedStates();-+// connect buttons and commandsQList<QAbstractButton*> allButtons =customWidget->findChildren<QAbstractButton*>();@@ -304,31 +305,33 @@ void CustomPanelManager::initializeControl(QWidget* customWidget) {if (QToolButton* tb = dynamic_cast<QToolButton*>(button)) {tb->setDefaultAction(action);tb->setObjectName("CustomPanelButton");-+// Build stylesheet with visible checked stateQString styleSheet;-+if (tb->toolButtonStyle() == Qt::ToolButtonTextUnderIcon) {int padding = (tb->height() - button->iconSize().height() -tb->font().pointSize() * 1.33) /3;if (padding > 0) {- styleSheet = QString("QToolButton#CustomPanelButton { padding-top: %1; }").arg(padding);+ styleSheet =+ QString("QToolButton#CustomPanelButton { padding-top: %1; }")+ .arg(padding);}}-+// Add checked state styles ONLY for new commands// (Brush Presets and Universal Sizes)- std::string cmdId = button->objectName().toStdString();- bool isBrushPreset = (cmdId.find("MI_BrushPreset_") == 0);+ std::string cmdId = button->objectName().toStdString();+ bool isBrushPreset = (cmdId.find("MI_BrushPreset_") == 0);bool isUniversalSize = (cmdId.find("MI_ToolSize_") == 0);-- // No custom stylesheet - let buttons inherit colors from the application theme- // This ensures proper adaptation when the user switches themes++ // No custom stylesheet - let buttons inherit colors from the application+ // theme This ensures proper adaptation when the user switches themesif (!styleSheet.isEmpty()) {tb->setStyleSheet(styleSheet);}-+continue;}@@ -346,7 +349,7 @@ void CustomPanelManager::initializeControl(QWidget* customWidget) {if (!button->text().isEmpty()) button->setText(action->text());button->setIcon(action->icon());-+// No custom stylesheet for checked buttons - let them inherit from theme// button->addAction(action);}@@ -396,7 +399,8 @@ void CustomPanelManager::registerCustomPanelCommands() {m_registeredPanelIds.clear();- MainWindow* mainWindow = dynamic_cast<MainWindow*>(TApp::instance()->getMainWindow());+ MainWindow* mainWindow =+ dynamic_cast<MainWindow*>(TApp::instance()->getMainWindow());if (!mainWindow) return;for (const QString& panelId : currentPanels) {@@ -423,12 +427,11 @@ void CustomPanelManager::registerCustomPanelCommands() {CommandManager::instance()->define(commandId.toStdString().c_str(),CustomPanelCommandType, // Custom Panels subcategory under Windows- "",- action,- "");+ "", action, "");class CustomPanelHandler : public CommandHandlerInterface {QString m_panelId;+public:CustomPanelHandler(const QString& id) : m_panelId(id) {}void execute() override {@@ -442,18 +445,19 @@ void CustomPanelManager::registerCustomPanelCommands() {}};- CommandManager::instance()->setHandler(- commandId.toStdString().c_str(),- new CustomPanelHandler(panelId));+ CommandManager::instance()->setHandler(commandId.toStdString().c_str(),+ new CustomPanelHandler(panelId));m_registeredPanelIds.append(commandId);}// Notify ShortcutPopup to refresh if it's currently open- // This allows new custom panel commands to appear immediately without restarting+ // This allows new custom panel commands to appear immediately without+ // restartingShortcutPopup::refreshIfOpen();- TFilePath shortcutsFile = ToonzFolder::getMyModuleDir() + TFilePath("shortcuts.ini");+ TFilePath shortcutsFile =+ ToonzFolder::getMyModuleDir() + TFilePath("shortcuts.ini");if (!TFileStatus(shortcutsFile).doesExist()) return;QSettings settings(toQString(shortcutsFile), QSettings::IniFormat);diff --git a/toonz/sources/toonz/mainwindow.cpp b/toonz/sources/toonz/mainwindow.cppindex c12d6e11f..55b94c515 100644--- a/toonz/sources/toonz/mainwindow.cpp+++ b/toonz/sources/toonz/mainwindow.cpp@@ -429,8 +429,8 @@ void Room::load(const TFilePath &fp, RoomLoadParams ¶ms) {// Store layout state for deferred re-apply after the first show.// Without this, TMainWindow::resizeEvent → redistribute() recalculates// panel sizes before the window has reached its final geometry.- m_pendingLayoutState = state;- m_hasPendingLayoutRestore = true;+ m_pendingLayoutState = state;+ m_hasPendingLayoutRestore = true;m_initialized = true;}@@ -441,7 +441,7 @@ void Room::showEvent(QShowEvent *event) {TMainWindow::showEvent(event);if (m_hasPendingLayoutRestore) {- m_hasPendingLayoutRestore = false;+ m_hasPendingLayoutRestore = false;DockLayout::State savedState = m_pendingLayoutState;DockLayout *layout = dockLayout();QTimer::singleShot(0, this, [layout, savedState]() {@@ -1423,17 +1423,18 @@ void MainWindow::registerRoomCommands() {for (int i = 0; i < m_stackedWidget->count(); i++) {Room *room = getRoom(i);if (!room) continue;- QString roomName = room->getName();+ QString roomName = room->getName();QString commandId = "MI_Room_" + roomName;currentRoomIds.append(commandId);}-+// Disable old room commands that no longer exist// We can't actually remove them from CommandManager, but we can hide them- // by removing them from m_registeredRoomIds and their actions from the main window- for (const QString& oldId : m_registeredRoomIds) {+ // by removing them from m_registeredRoomIds and their actions from the main+ // window+ for (const QString &oldId : m_registeredRoomIds) {if (!currentRoomIds.contains(oldId)) {- QAction* oldAction = CommandManager::instance()->getAction(+ QAction *oldAction = CommandManager::instance()->getAction(oldId.toStdString().c_str(), false);if (oldAction) {// Remove the action from this widget to prevent it from being triggered@@ -1443,19 +1444,19 @@ void MainWindow::registerRoomCommands() {}}}-+m_registeredRoomIds.clear();-+// Iterate through all existing roomsfor (int i = 0; i < m_stackedWidget->count(); i++) {Room *room = getRoom(i);if (!room) continue;-- QString roomName = room->getName();++ QString roomName = room->getName();QString commandId = "MI_Room_" + roomName;-+// Check if command already exists- QAction* existingAction = CommandManager::instance()->getAction(+ QAction *existingAction = CommandManager::instance()->getAction(commandId.toStdString().c_str(), false);if (existingAction) {// Make sure it's visible and added to this widget@@ -1466,41 +1467,38 @@ void MainWindow::registerRoomCommands() {m_registeredRoomIds.append(commandId);continue;}-+// Clean up room name for better display// Replace underscores and hyphens with spaces for readabilityQString cleanName = roomName;cleanName.replace('_', ' ');cleanName.replace('-', ' ');-+// Create display name with [Room] prefixQString displayName = "[Room] " + cleanName;-- QAction* action = new DVAction(displayName, this);++ QAction *action = new DVAction(displayName, this);addAction(action);-+// Define command with RoomCommandType for proper categorization- CommandManager::instance()->define(- commandId.toStdString().c_str(),- RoomCommandType,- "",- action,- "");-+ CommandManager::instance()->define(commandId.toStdString().c_str(),+ RoomCommandType, "", action, "");+// Create handler that switches to this room when shortcut is triggeredclass RoomSwitchHandler : public CommandHandlerInterface {QString m_roomName;- MainWindow* m_mainWindow;+ MainWindow *m_mainWindow;+public:- RoomSwitchHandler(const QString& name, MainWindow* mainWin)- : m_roomName(name), m_mainWindow(mainWin) {}-+ RoomSwitchHandler(const QString &name, MainWindow *mainWin)+ : m_roomName(name), m_mainWindow(mainWin) {}+void execute() override {if (!m_mainWindow) return;-+// Find room by name and switch to itfor (int i = 0; i < m_mainWindow->getRoomCount(); i++) {- Room* room = m_mainWindow->getRoom(i);+ Room *room = m_mainWindow->getRoom(i);if (room && room->getName() == m_roomName) {m_mainWindow->m_topBar->getRoomTabWidget()->setCurrentIndex(i);return;@@ -1508,38 +1506,38 @@ void MainWindow::registerRoomCommands() {}}};-+CommandManager::instance()->setHandler(- commandId.toStdString().c_str(),- new RoomSwitchHandler(roomName, this));-+ commandId.toStdString().c_str(), new RoomSwitchHandler(roomName, this));+m_registeredRoomIds.append(commandId);}-+// Load saved shortcuts for room commands- TFilePath shortcutsFile = ToonzFolder::getMyModuleDir() + TFilePath("shortcuts.ini");+ TFilePath shortcutsFile =+ ToonzFolder::getMyModuleDir() + TFilePath("shortcuts.ini");if (!TFileStatus(shortcutsFile).doesExist()) {// Refresh ShortcutPopup if it's open to show new room commandsShortcutPopup::refreshIfOpen();return;}-+QSettings settings(toQString(shortcutsFile), QSettings::IniFormat);settings.beginGroup("shortcuts");-- for (const QString& commandId : m_registeredRoomIds) {++ for (const QString &commandId : m_registeredRoomIds) {QString savedShortcut = settings.value(commandId, "").toString();if (!savedShortcut.isEmpty()) {- QAction* action = CommandManager::instance()->getAction(+ QAction *action = CommandManager::instance()->getAction(commandId.toStdString().c_str(), false);if (action) {action->setShortcut(QKeySequence(savedShortcut));}}}-+settings.endGroup();-+// Refresh ShortcutPopup if it's open to show new room commandsShortcutPopup::refreshIfOpen();}@@ -1549,23 +1547,24 @@ void MainWindow::registerRoomCommands() {void MainWindow::unregisterRoomCommand(const QString &roomName) {QString commandId = "MI_Room_" + roomName;-+// Remove from registered listm_registeredRoomIds.removeAll(commandId);-+// Note: We don't actually remove the command from CommandManager// as Qt doesn't provide a clean way to unregister QActions// The command will simply do nothing if triggered after room deletion-+// Clear the shortcut from settings file- TFilePath shortcutsFile = ToonzFolder::getMyModuleDir() + TFilePath("shortcuts.ini");+ TFilePath shortcutsFile =+ ToonzFolder::getMyModuleDir() + TFilePath("shortcuts.ini");if (TFileStatus(shortcutsFile).doesExist()) {QSettings settings(toQString(shortcutsFile), QSettings::IniFormat);settings.beginGroup("shortcuts");settings.remove(commandId);settings.endGroup();}-+// Refresh ShortcutPopup if it's openShortcutPopup::refreshIfOpen();}@@ -1573,19 +1572,21 @@ void MainWindow::unregisterRoomCommand(const QString &roomName) {//-----------------------------------------------------------------------------// Update a room shortcut command when a room is renamed-void MainWindow::updateRoomCommand(const QString &oldName, const QString &newName) {+void MainWindow::updateRoomCommand(const QString &oldName,+ const QString &newName) {QString oldCommandId = "MI_Room_" + oldName;QString newCommandId = "MI_Room_" + newName;-+// Save and migrate the old shortcut if it exists- TFilePath shortcutsFile = ToonzFolder::getMyModuleDir() + TFilePath("shortcuts.ini");+ TFilePath shortcutsFile =+ ToonzFolder::getMyModuleDir() + TFilePath("shortcuts.ini");QString oldShortcut;-+if (TFileStatus(shortcutsFile).doesExist()) {QSettings settings(toQString(shortcutsFile), QSettings::IniFormat);settings.beginGroup("shortcuts");oldShortcut = settings.value(oldCommandId, "").toString();-+// Migrate the shortcut to the new command IDif (oldCommandId != newCommandId) {settings.remove(oldCommandId);@@ -1595,11 +1596,11 @@ void MainWindow::updateRoomCommand(const QString &oldName, const QString &newNam}settings.endGroup();}-+// Re-register all room commands// This will clean up the old command and create the new oneregisterRoomCommands();-+// The shortcut was already saved in shortcuts.ini above,// so registerRoomCommands() will load it automatically}@@ -1623,7 +1624,7 @@ void MainWindow::insertNewRoom() {// Finally, old room index is increased by 1m_oldRoomIndex++;-+// Register shortcut for the newly created roomregisterRoomCommands();}@@ -1632,7 +1633,7 @@ void MainWindow::insertNewRoom() {void MainWindow::deleteRoom(int index) {Room *room = getRoom(index);-+// Store room name before deletion for unregistering the shortcutQString roomName = room->getName();@@ -1656,7 +1657,7 @@ void MainWindow::deleteRoom(int index) {m_stackedWidget->removeWidget(room);delete room;-+// Unregister shortcut for the deleted roomunregisterRoomCommand(roomName);}@@ -3278,15 +3279,15 @@ void MainWindow::defineActions() {ToolCommandType);/*-- Edit Assistants tool + type switching shortcuts --*/- createAction(MI_AssistantNextType,- QT_TR_NOOP("Assistant Type - Cycle"), "", ToolCommandType);+ createAction(MI_AssistantNextType, QT_TR_NOOP("Assistant Type - Cycle"), "",+ ToolCommandType);createAction(MI_AssistantLine, QT_TR_NOOP("Assistant Type - Line"), "",ToolCommandType, "assistant_line");createAction(MI_AssistantEllipse, QT_TR_NOOP("Assistant Type - Ellipse"), "",ToolCommandType, "assistant_ellipse");createAction(MI_AssistantPerspective,- QT_TR_NOOP("Assistant Type - Perspective"), "",- ToolCommandType, "assistant_perspective");+ QT_TR_NOOP("Assistant Type - Perspective"), "", ToolCommandType,+ "assistant_perspective");createAction(MI_AssistantVanishingPoint,QT_TR_NOOP("Assistant Type - Vanishing Point"), "",ToolCommandType, "assistant_vanishingpoint");@@ -3421,9 +3422,8 @@ void MainWindow::defineActions() {QT_TR_NOOP("Assistant Type - Ellipse"), "");createToolOptionsAction("A_ToolOption_AssistantType:assistantPerspective",QT_TR_NOOP("Assistant Type - Perspective"), "");- createToolOptionsAction(- "A_ToolOption_AssistantType:assistantVanishingPoint",- QT_TR_NOOP("Assistant Type - Vanishing Point"), "");+ createToolOptionsAction("A_ToolOption_AssistantType:assistantVanishingPoint",+ QT_TR_NOOP("Assistant Type - Vanishing Point"), "");createToolOptionsAction("A_ToolOption_AssistantType:assistantFisheye",QT_TR_NOOP("Assistant Type - Fisheye"), "");createToolOptionsAction("A_ToolOption_AssistantType:replicatorStar",diff --git a/toonz/sources/toonz/pane.h b/toonz/sources/toonz/pane.hindex 23da9680e..1fd7cb4ff 100644--- a/toonz/sources/toonz/pane.h+++ b/toonz/sources/toonz/pane.h@@ -214,9 +214,7 @@ public:}QPixmap getFloatBorderPixmap() const { return m_floatBorderPm; }- void setFloatBorderPixmap(const QPixmap &pixmap) {- m_floatBorderPm = pixmap;- }+ void setFloatBorderPixmap(const QPixmap &pixmap) { m_floatBorderPm = pixmap; }QPixmap getFloatActiveBorderPixmap() const { return m_floatActiveBorderPm; }void setFloatActiveBorderPixmap(const QPixmap &pixmap) {@@ -331,7 +329,8 @@ protected:void enterEvent(QEvent *) override;void leaveEvent(QEvent *) override;- // BTR grip visibility follows floating/docked state (dock + workspace restore).+ // BTR grip visibility follows floating/docked state (dock + workspace+ // restore).void setFloatingAppearance() override;void setDockedAppearance() override;diff --git a/toonz/sources/toonz/preferencespopup.cpp b/toonz/sources/toonz/preferencespopup.cppindex 19787a42e..cd33a8475 100644--- a/toonz/sources/toonz/preferencespopup.cpp+++ b/toonz/sources/toonz/preferencespopup.cpp@@ -294,7 +294,7 @@ PreferencesPopup::AdditionalStyleEdit::AdditionalStyleEdit(setModal(true);setMinimumWidth(460);- m_edit = new QTextEdit(this);+ m_edit = new QTextEdit(this);QPushButton* loadButton = new QPushButton(tr("Load..."), this);QPushButton* saveButton = new QPushButton(tr("Save..."), this);QPushButton* okButton = new QPushButton(tr("OK"), this);@@ -319,7 +319,8 @@ PreferencesPopup::AdditionalStyleEdit::AdditionalStyleEdit(connect(loadButton, &QPushButton::pressed, this, [this]() {const QString filter =- tr("Style Sheets (*.qss *.css *.theme);;Theme Files (*.qss *.css *.theme *.txt);;All Files (*)");+ tr("Style Sheets (*.qss *.css *.theme);;Theme Files (*.qss *.css "+ "*.theme *.txt);;All Files (*)");const QString fileName = QFileDialog::getOpenFileName(this, tr("Load Style Sheet"), QString(), filter);if (fileName.isEmpty()) return;@@ -334,10 +335,10 @@ PreferencesPopup::AdditionalStyleEdit::AdditionalStyleEdit(});connect(saveButton, &QPushButton::pressed, this, [this]() {const QString filter =- tr("Style Sheets (*.qss *.css *.theme);;Theme Files (*.qss *.css *.theme *.txt);;All Files (*)");+ tr("Style Sheets (*.qss *.css *.theme);;Theme Files (*.qss *.css "+ "*.theme *.txt);;All Files (*)");const QString fileName = QFileDialog::getSaveFileName(- this, tr("Save Style Sheet"), tr("additional-style-sheet.qss"),- filter);+ this, tr("Save Style Sheet"), tr("additional-style-sheet.qss"), filter);if (fileName.isEmpty()) return;QFile file(fileName);@@ -432,7 +433,7 @@ PreferencesPopup::Display30bitChecker::Display30bitChecker(GLView* view10bit = new GLView(this, true);QPushButton* closeBtn = new QPushButton(tr("Close"), this);QString infoLabel = tr(- "If the lower gradient looks smooth and has no banding compared to the upper gradient,\n\+ "If the lower gradient looks smooth and has no banding compared to the upper gradient,\n\30bit display is available in the current configuration.");QVBoxLayout* lay = new QVBoxLayout();@@ -1768,7 +1769,7 @@ PreferencesPopup::PreferencesPopup()&QStackedWidget::setCurrentIndex);connect(m_pref, &Preferences::fillOnlySaveboxChanged, this,[this](bool enabled) {- CheckBox *saveboxCheck = getUI<CheckBox *>(FillOnlysavebox);+ CheckBox* saveboxCheck = getUI<CheckBox*>(FillOnlysavebox);if (!saveboxCheck || saveboxCheck->isChecked() == enabled) return;QSignalBlocker blocker(saveboxCheck);saveboxCheck->setChecked(enabled);