From d2942446b99a94a60994773319e289c9ec1ac170 Mon Sep 17 00:00:00 2001 From: Dongxu Li Date: Mon, 8 Apr 2024 21:04:35 -0400 Subject: [PATCH] Issue #1757: pen Pallet only enabled by settings These widgets cause some unexpected behaviors and take too much space on low resolution monitors. Temporarily disable them by default. To enable them, add a settings entry to: /CustomToolbars/UserPenPallet=1 The widges covered: PenPallet LayerTree --- librecad/src/main/qc_applicationwindow.cpp | 36 ++++++++++++++-------- librecad/src/ui/lc_widgetfactory.cpp | 9 ++++-- 2 files changed, 29 insertions(+), 16 deletions(-) diff --git a/librecad/src/main/qc_applicationwindow.cpp b/librecad/src/main/qc_applicationwindow.cpp index 36b0c374bd..baf82e5252 100644 --- a/librecad/src/main/qc_applicationwindow.cpp +++ b/librecad/src/main/qc_applicationwindow.cpp @@ -557,9 +557,11 @@ void QC_ApplicationWindow::doClose(QC_MDIWindow * w, bool activateNext) { layerWidget->setLayerList(nullptr, false); - layerTreeWidget->setLayerList(nullptr); - layerTreeWidget->set_view(nullptr); - layerTreeWidget->set_document(nullptr); + if (layerTreeWidget != nullptr) { + layerTreeWidget->setLayerList(nullptr); + layerTreeWidget->set_view(nullptr); + layerTreeWidget->set_document(nullptr); + } blockWidget->setBlockList(nullptr); @@ -1050,14 +1052,17 @@ void QC_ApplicationWindow::slotWindowActivated(QMdiSubWindow* w, bool forced) layerWidget->setLayerList(layerList,showByBlock); - layerTreeWidget->setLayerList(layerList); - layerTreeWidget->set_view(m->getGraphicView()); - layerTreeWidget->set_document(m->getDocument()); + if (layerTreeWidget != nullptr) { + layerTreeWidget->setLayerList(layerList); + layerTreeWidget->set_view(m->getGraphicView()); + layerTreeWidget->set_document(m->getDocument()); + } if (penPaletteWidget != nullptr){ penPaletteWidget->setLayerList(layerList); } + coordinateWidget->setGraphic(m->getGraphic()); blockWidget->setBlockList(m->getDocument()->getBlockList()); @@ -1579,7 +1584,7 @@ QC_MDIWindow* QC_ApplicationWindow::slotFileNew(RS_Document* doc) { penPaletteWidget->setLayerList(layerList); } - if(layerTreeWidget) { + if(layerTreeWidget != nullptr) { layerTreeWidget->setLayerList(layerList); layerTreeWidget->set_view(view); layerTreeWidget->set_document(w->getDocument()); @@ -1594,7 +1599,9 @@ QC_MDIWindow* QC_ApplicationWindow::slotFileNew(RS_Document* doc) { // Link the layer list to the layer widget graphic->addLayerListListener(layerWidget); - graphic->addLayerListListener(layerTreeWidget); + if (layerTreeWidget != nullptr) { + graphic->addLayerListListener(layerTreeWidget); + } // Link the block list to the block widget graphic->addBlockListListener(blockWidget); @@ -1643,7 +1650,8 @@ bool QC_ApplicationWindow::slotFileNewHelper(QString fileName, QC_MDIWindow* w) // link the layer widget to the new document: RS_LayerList *layerList = w->getDocument()->getLayerList(); layerWidget->setLayerList(layerList, false); - layerTreeWidget->setLayerList(layerList); + if (layerTreeWidget != nullptr) + layerTreeWidget->setLayerList(layerList); if (penPaletteWidget != nullptr){ penPaletteWidget-> setLayerList(layerList); @@ -1673,8 +1681,8 @@ bool QC_ApplicationWindow::slotFileNewHelper(QString fileName, QC_MDIWindow* w) RS_DEBUG->print("QC_ApplicationWindow::slotFileNewHelper: load Template: OK"); layerWidget->slotUpdateLayerList(); - layerTreeWidget->slotFilteringMaskChanged(); - + if (layerTreeWidget != nullptr) + layerTreeWidget->slotFilteringMaskChanged(); RS_DEBUG->print("QC_ApplicationWindow::slotFileNewHelper: update coordinate widget"); // update coordinate widget format: @@ -1864,7 +1872,8 @@ void QC_ApplicationWindow:: // link the layer widget to the new document: layerWidget->setLayerList(layerList, false); - layerTreeWidget->setLayerList(layerList); + if (layerTreeWidget) + layerTreeWidget->setLayerList(layerList); if (penPaletteWidget != nullptr){ penPaletteWidget->setLayerList(layerList); } @@ -1914,7 +1923,8 @@ void QC_ApplicationWindow:: recentFiles->add(fileName); openedFiles.push_back(fileName); layerWidget->slotUpdateLayerList(); - layerTreeWidget->slotFilteringMaskChanged(); + if (layerTreeWidget != nullptr) + layerTreeWidget->slotFilteringMaskChanged(); auto graphic = w->getGraphic(); if (graphic) diff --git a/librecad/src/ui/lc_widgetfactory.cpp b/librecad/src/ui/lc_widgetfactory.cpp index 2c1a08e691..cb85aceb58 100644 --- a/librecad/src/ui/lc_widgetfactory.cpp +++ b/librecad/src/ui/lc_widgetfactory.cpp @@ -50,7 +50,8 @@ namespace { // only enable the penpallet by settings bool usePenPallet() { - return RS_SETTINGS->readNumEntry("/CustomToolbars/UsePenPallet", 0) == 1; + auto guard= RS_SETTINGS->beginGroupGuard("/CustomToolbars"); + return RS_SETTINGS->readNumEntry("/UsePenPallet", 0) == 1; } } // namespace @@ -393,8 +394,10 @@ void LC_WidgetFactory::createRightSidebar(QG_ActionHandler* action_handler) main_window->addDockWidget(Qt::RightDockWidgetArea, dock_library); main_window->tabifyDockWidget(dock_library, dock_block); main_window->tabifyDockWidget(dock_block, dock_layer); - main_window->tabifyDockWidget(dock_layer, dock_pen_palette); - main_window->tabifyDockWidget(dock_pen_palette, dock_layer_tree); + if (dock_pen_palette != nullptr && dock_layer_tree != nullptr) { + main_window->tabifyDockWidget(dock_layer, dock_pen_palette); + main_window->tabifyDockWidget(dock_pen_palette, dock_layer_tree); + } main_window->addDockWidget(Qt::RightDockWidgetArea, dock_command); command_widget->getDockingAction()->setText(dock_command->isFloating() ? tr("Dock") : tr("Float")); }