Skip to content

Commit

Permalink
Issue LibreCAD#1757: pen Pallet only enabled by settings
Browse files Browse the repository at this point in the history
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
  • Loading branch information
dxli committed Apr 9, 2024
1 parent 2d40e66 commit d294244
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 16 deletions.
36 changes: 23 additions & 13 deletions librecad/src/main/qc_applicationwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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());
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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)
Expand Down
9 changes: 6 additions & 3 deletions librecad/src/ui/lc_widgetfactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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"));
}
Expand Down

0 comments on commit d294244

Please sign in to comment.