Sketcher: Remove Edit Controls from the TaskBar

This commit is contained in:
Abdullah Tahiri
2023-03-01 22:58:50 +01:00
committed by abdullahtahiriyo
parent 74f136bbac
commit 41a7b146f5
8 changed files with 3 additions and 502 deletions

View File

@@ -32,7 +32,6 @@ generate_from_xml(ViewProviderSketchGeometryExtensionPy)
set(SketcherGui_UIC_SRCS
TaskSketcherConstraints.ui
TaskSketcherElements.ui
TaskSketcherGeneral.ui
TaskSketcherMessages.ui
TaskSketcherSolverAdvanced.ui
TaskSketcherValidation.ui
@@ -100,9 +99,6 @@ SET(SketcherGui_SRCS
TaskSketcherElements.h
TaskSketcherCreateCommands.cpp
TaskSketcherCreateCommands.h
TaskSketcherGeneral.ui
TaskSketcherGeneral.cpp
TaskSketcherGeneral.h
TaskSketcherMessages.ui
TaskSketcherMessages.cpp
TaskSketcherMessages.h

View File

@@ -38,7 +38,6 @@
#include "ui_SketcherSettingsDisplay.h"
#include "ui_SketcherSettingsColors.h"
#include "ui_SketcherSettingsDisplay.h"
#include "TaskSketcherGeneral.h"
using namespace SketcherGui;
@@ -49,11 +48,6 @@ SketcherSettings::SketcherSettings(QWidget* parent)
: PreferencePage(parent), ui(new Ui_SketcherSettings)
{
ui->setupUi(this);
QGridLayout* gridLayout = new QGridLayout(ui->placeholder);
gridLayout->setSpacing(0);
gridLayout->setContentsMargins(0, 0, 0, 0);
form = new SketcherGeneralWidget(ui->placeholder);
gridLayout->addWidget(form, 0, 0, 1, 1);
}
/**
@@ -73,7 +67,6 @@ void SketcherSettings::saveSettings()
ui->checkBoxEnableEscape->onSave();
ui->checkBoxNotifyConstraintSubstitutions->onSave();
ui->checkBoxAutoRemoveRedundants->onSave();
form->saveSettings();
}
void SketcherSettings::loadSettings()
@@ -85,7 +78,6 @@ void SketcherSettings::loadSettings()
ui->checkBoxEnableEscape->onRestore();
ui->checkBoxNotifyConstraintSubstitutions->onRestore();
ui->checkBoxAutoRemoveRedundants->onRestore();
form->loadSettings();
}
/**

View File

@@ -15,13 +15,6 @@
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QGroupBox" name="placeholder">
<property name="title">
<string>Sketcher</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Task Panel Widgets</string>
@@ -67,7 +60,7 @@
</layout>
</widget>
</item>
<item row="2" column="0">
<item row="1" column="0">
<widget class="QGroupBox" name="groupBox_4">
<property name="title">
<string>Dragging performance</string>
@@ -96,7 +89,7 @@ Requires to re-enter edit mode to take effect.</string>
</layout>
</widget>
</item>
<item row="3" column="0">
<item row="2" column="0">
<widget class="QGroupBox" name="groupBox_5">
<property name="enabled">
<bool>true</bool>
@@ -189,7 +182,7 @@ Requires to re-enter edit mode to take effect.</string>
</layout>
</widget>
</item>
<item row="4" column="0">
<item row="3" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>

View File

@@ -41,7 +41,6 @@ TaskDlgEditSketch::TaskDlgEditSketch(ViewProviderSketch *sketchView)
assert(sketchView);
Constraints = new TaskSketcherConstraints(sketchView);
Elements = new TaskSketcherElements(sketchView);
General = new TaskSketcherGeneral(sketchView);
Messages = new TaskSketcherMessages(sketchView);
SolverAdvanced = new TaskSketcherSolverAdvanced(sketchView);
@@ -54,10 +53,6 @@ TaskDlgEditSketch::TaskDlgEditSketch(ViewProviderSketch *sketchView)
Content.push_back(SolverAdvanced);
}
if (hGrp->GetBool("ShowSettingsWidget", true)) {
Content.push_back(General);
}
Content.push_back(Constraints);
Content.push_back(Elements);
@@ -65,8 +60,6 @@ TaskDlgEditSketch::TaskDlgEditSketch(ViewProviderSketch *sketchView)
Messages->hideGroupBox();
if (!hGrp->GetBool("ExpandedSolverAdvancedWidget",false))
SolverAdvanced->hideGroupBox();
if (!hGrp->GetBool("ExpandedEditControlWidget",false))
General->hideGroupBox();
if (!hGrp->GetBool("ExpandedConstraintsWidget",true))
Constraints->hideGroupBox();
if (!hGrp->GetBool("ExpandedElementsWidget",true))
@@ -80,10 +73,6 @@ TaskDlgEditSketch::~TaskDlgEditSketch()
std::vector<QWidget*>::iterator it = std::find(Content.begin(), Content.end(), SolverAdvanced);
if (it == Content.end())
Content.push_back(SolverAdvanced);
// same thing for edit control panel
it = std::find(Content.begin(), Content.end(), General);
if (it == Content.end())
Content.push_back(General);
}
//==== calls from the TaskView ===============================================================
@@ -109,7 +98,6 @@ bool TaskDlgEditSketch::reject()
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
hGrp->SetBool("ExpandedMessagesWidget",Messages->isGroupVisible());
hGrp->SetBool("ExpandedSolverAdvancedWidget",SolverAdvanced->isGroupVisible());
hGrp->SetBool("ExpandedEditControlWidget",General->isGroupVisible());
hGrp->SetBool("ExpandedConstraintsWidget",Constraints->isGroupVisible());
hGrp->SetBool("ExpandedElementsWidget",Elements->isGroupVisible());

View File

@@ -29,7 +29,6 @@
#include "TaskSketcherConstraints.h"
#include "TaskSketcherElements.h"
#include "TaskSketcherGeneral.h"
#include "TaskSketcherMessages.h"
#include "TaskSketcherSolverAdvanced.h"
#include "ViewProviderSketch.h"
@@ -75,7 +74,6 @@ protected:
ViewProviderSketch *sketchView;
TaskSketcherConstraints *Constraints;
TaskSketcherElements *Elements;
TaskSketcherGeneral *General;
TaskSketcherMessages *Messages;
TaskSketcherSolverAdvanced *SolverAdvanced;
};

View File

@@ -1,245 +0,0 @@
/***************************************************************************
* Copyright (c) 2009 Jürgen Riegel <juergen.riegel@web.de> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library 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 Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#include "PreCompiled.h"
#include <QEvent>
#include <Base/Tools.h>
#include <Gui/Application.h>
#include <Gui/BitmapFactory.h>
#include <Gui/ViewProvider.h>
#include "ui_TaskSketcherGeneral.h"
#include "TaskSketcherGeneral.h"
#include "ViewProviderSketch.h"
using namespace SketcherGui;
using namespace Gui::TaskView;
namespace bp = boost::placeholders;
SketcherGeneralWidget::SketcherGeneralWidget(QWidget *parent)
: QWidget(parent), ui(new Ui_TaskSketcherGeneral)
{
ui->setupUi(this);
ui->renderingOrder->setSizeAdjustPolicy(QAbstractScrollArea::AdjustToContents);
// connecting the needed signals
connect(ui->checkBoxAutoconstraints, &QCheckBox::toggled,
this, &SketcherGeneralWidget::emitToggleAutoconstraints);
connect(ui->checkBoxRedundantAutoconstraints, &QCheckBox::toggled,
this, &SketcherGeneralWidget::emitToggleAvoidRedundant);
ui->renderingOrder->installEventFilter(this);
}
SketcherGeneralWidget::~SketcherGeneralWidget()
{
}
bool SketcherGeneralWidget::eventFilter(QObject *object, QEvent *event)
{
if (object == ui->renderingOrder && event->type() == QEvent::ChildRemoved) {
Q_EMIT emitRenderOrderChanged();
}
return false;
}
void SketcherGeneralWidget::saveSettings()
{
ui->checkBoxAutoconstraints->onSave();
ui->checkBoxRedundantAutoconstraints->onSave();
saveOrderingOrder();
}
void SketcherGeneralWidget::saveOrderingOrder()
{
int topid = ui->renderingOrder->item(0)->data(Qt::UserRole).toInt();
int midid = ui->renderingOrder->item(1)->data(Qt::UserRole).toInt();
int lowid = ui->renderingOrder->item(2)->data(Qt::UserRole).toInt();
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher/General");
hGrp->SetInt("TopRenderGeometryId",topid);
hGrp->SetInt("MidRenderGeometryId",midid);
hGrp->SetInt("LowRenderGeometryId",lowid);
}
void SketcherGeneralWidget::loadSettings()
{
ui->checkBoxAutoconstraints->onRestore();
ui->checkBoxRedundantAutoconstraints->onRestore();
loadOrderingOrder();
}
void SketcherGeneralWidget::loadOrderingOrder()
{
ParameterGrp::handle hGrpp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher/General");
// 1->Normal Geometry, 2->Construction, 3->External
int topid = hGrpp->GetInt("TopRenderGeometryId",1);
int midid = hGrpp->GetInt("MidRenderGeometryId",2);
int lowid = hGrpp->GetInt("LowRenderGeometryId",3);
{
QSignalBlocker block(ui->renderingOrder);
ui->renderingOrder->clear();
QListWidgetItem *newItem = new QListWidgetItem;
newItem->setData(Qt::UserRole, QVariant(topid));
newItem->setText( topid==1?tr("Normal Geometry"):topid==2?tr("Construction Geometry"):tr("External Geometry"));
ui->renderingOrder->insertItem(0,newItem);
newItem = new QListWidgetItem;
newItem->setData(Qt::UserRole, QVariant(midid));
newItem->setText(midid==1?tr("Normal Geometry"):midid==2?tr("Construction Geometry"):tr("External Geometry"));
ui->renderingOrder->insertItem(1,newItem);
newItem = new QListWidgetItem;
newItem->setData(Qt::UserRole, QVariant(lowid));
newItem->setText(lowid==1?tr("Normal Geometry"):lowid==2?tr("Construction Geometry"):tr("External Geometry"));
ui->renderingOrder->insertItem(2,newItem);
}
}
void SketcherGeneralWidget::checkAutoconstraints(bool on)
{
ui->checkBoxAutoconstraints->setChecked(on);
}
void SketcherGeneralWidget::checkAvoidRedundant(bool on)
{
ui->checkBoxRedundantAutoconstraints->setChecked(on);
}
void SketcherGeneralWidget::enableAvoidRedundant(bool on)
{
ui->checkBoxRedundantAutoconstraints->setEnabled(on);
}
void SketcherGeneralWidget::changeEvent(QEvent *e)
{
QWidget::changeEvent(e);
if (e->type() == QEvent::LanguageChange) {
ui->retranslateUi(this);
}
}
// ----------------------------------------------------------------------------
TaskSketcherGeneral::TaskSketcherGeneral(ViewProviderSketch *sketchView)
: TaskBox(Gui::BitmapFactory().pixmap("document-new"),tr("Edit controls"),true, nullptr)
, sketchView(sketchView)
{
// we need a separate container widget to add all controls to
widget = new SketcherGeneralWidget(this);
this->groupLayout()->addWidget(widget);
{
//Blocker probably not needed as signals aren't connected yet
QSignalBlocker block(widget);
//Load default settings to get ordering order & avoid redundant values
widget->loadSettings();
widget->checkAutoconstraints(sketchView->Autoconstraints.getValue());
widget->checkAvoidRedundant(sketchView->AvoidRedundant.getValue());
widget->enableAvoidRedundant(sketchView->Autoconstraints.getValue());
}
// connecting the needed signals
QObject::connect(
widget, &SketcherGeneralWidget::emitToggleAutoconstraints,
this , &TaskSketcherGeneral::onToggleAutoconstraints
);
QObject::connect(
widget, &SketcherGeneralWidget::emitToggleAvoidRedundant,
this , &TaskSketcherGeneral::onToggleAvoidRedundant
);
QObject::connect(
widget, &SketcherGeneralWidget::emitRenderOrderChanged,
this , &TaskSketcherGeneral::onRenderOrderChanged
);
Gui::Selection().Attach(this);
Gui::Application* app = Gui::Application::Instance;
changedSketchView = app->signalChangedObject.connect(boost::bind
(&TaskSketcherGeneral::onChangedSketchView, this, bp::_1, bp::_2));
}
TaskSketcherGeneral::~TaskSketcherGeneral()
{
Gui::Selection().Detach(this);
}
void TaskSketcherGeneral::onChangedSketchView(const Gui::ViewProvider& vp,
const App::Property& prop)
{
if (sketchView == &vp) {
if (&sketchView->Autoconstraints == &prop) {
QSignalBlocker block(widget);
widget->checkAutoconstraints(sketchView->Autoconstraints.getValue());
widget->enableAvoidRedundant(sketchView->Autoconstraints.getValue());
}
else if (&sketchView->AvoidRedundant == &prop) {
QSignalBlocker block(widget);
widget->checkAvoidRedundant(sketchView->AvoidRedundant.getValue());
}
}
}
void TaskSketcherGeneral::onToggleAutoconstraints(bool on)
{
Base::ConnectionBlocker block(changedSketchView);
sketchView->Autoconstraints.setValue(on);
widget->enableAvoidRedundant(on);
}
void TaskSketcherGeneral::onToggleAvoidRedundant(bool on)
{
Base::ConnectionBlocker block(changedSketchView);
sketchView->AvoidRedundant.setValue(on);
}
/// @cond DOXERR
void TaskSketcherGeneral::OnChange(Gui::SelectionSingleton::SubjectType &rCaller,
Gui::SelectionSingleton::MessageType Reason)
{
Q_UNUSED(rCaller);
Q_UNUSED(Reason);
//if (Reason.Type == SelectionChanges::AddSelection ||
// Reason.Type == SelectionChanges::RmvSelection ||
// Reason.Type == SelectionChanges::SetSelection ||
// Reason.Type == SelectionChanges::ClrSelection) {
//}
}
/// @endcond DOXERR
void TaskSketcherGeneral::onRenderOrderChanged()
{
widget->saveOrderingOrder();
sketchView->updateColor();
}
#include "moc_TaskSketcherGeneral.cpp"

View File

@@ -1,104 +0,0 @@
/***************************************************************************
* Copyright (c) 2009 Jürgen Riegel <juergen.riegel@web.de> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library 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 Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#ifndef GUI_TASKVIEW_TaskSketcherGerneral_H
#define GUI_TASKVIEW_TaskSketcherGerneral_H
#include <boost_signals2.hpp>
#include <Gui/Selection.h>
#include <Gui/TaskView/TaskView.h>
namespace App {
class Property;
}
namespace Gui {
class ViewProvider;
}
namespace SketcherGui {
class Ui_TaskSketcherGeneral;
class ViewProviderSketch;
class SketcherGeneralWidget : public QWidget
{
Q_OBJECT
public:
explicit SketcherGeneralWidget(QWidget *parent=nullptr);
~SketcherGeneralWidget() override;
bool eventFilter(QObject *object, QEvent *event) override;
void saveSettings();
void saveOrderingOrder();
void loadSettings();
void loadOrderingOrder();
void checkAutoconstraints(bool);
void checkAvoidRedundant(bool);
void enableAvoidRedundant(bool);
Q_SIGNALS:
void emitToggleAutoconstraints(bool);
void emitToggleAvoidRedundant(bool);
void emitRenderOrderChanged();
protected:
void changeEvent(QEvent *e) override;
private:
std::unique_ptr<Ui_TaskSketcherGeneral> ui;
};
class TaskSketcherGeneral : public Gui::TaskView::TaskBox,
public Gui::SelectionSingleton::ObserverType
{
Q_OBJECT
public:
explicit TaskSketcherGeneral(ViewProviderSketch *sketchView);
~TaskSketcherGeneral() override;
/// Observer message from the Selection
void OnChange(Gui::SelectionSingleton::SubjectType &rCaller,
Gui::SelectionSingleton::MessageType Reason) override;
public Q_SLOTS:
void onToggleAutoconstraints(bool on);
void onToggleAvoidRedundant(bool);
void onRenderOrderChanged();
private:
void onChangedSketchView(const Gui::ViewProvider&,
const App::Property&);
private:
ViewProviderSketch *sketchView;
SketcherGeneralWidget* widget;
boost::signals2::scoped_connection changedSketchView;
};
} //namespace SketcherGui
#endif // GUI_TASKVIEW_TaskSketcherGerneral_H

View File

@@ -1,117 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>SketcherGui::TaskSketcherGeneral</class>
<widget class="QWidget" name="SketcherGui::TaskSketcherGeneral">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>312</width>
<height>254</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="Gui::PrefCheckBox" name="checkBoxAutoconstraints">
<property name="enabled">
<bool>true</bool>
</property>
<property name="toolTip">
<string>Sketcher proposes automatically sensible constraints.</string>
</property>
<property name="text">
<string>Auto constraints</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>AutoConstraints</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Sketcher/General</cstring>
</property>
</widget>
</item>
<item>
<widget class="Gui::PrefCheckBox" name="checkBoxRedundantAutoconstraints">
<property name="toolTip">
<string>Sketcher tries not to propose redundant auto constraints</string>
</property>
<property name="text">
<string>Avoid redundant auto constraints</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>AvoidRedundantAutoconstraints</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Sketcher/General</cstring>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Rendering order (global):</string>
</property>
</widget>
</item>
<item>
<widget class="QListWidget" name="renderingOrder">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>12</width>
<height>60</height>
</size>
</property>
<property name="toolTip">
<string>To change, drag and drop a geometry type to top or bottom</string>
</property>
<property name="dragEnabled">
<bool>true</bool>
</property>
<property name="dragDropMode">
<enum>QAbstractItemView::InternalMove</enum>
</property>
<property name="resizeMode">
<enum>QListView::Fixed</enum>
</property>
<property name="sortingEnabled">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>Gui::QuantitySpinBox</class>
<extends>QWidget</extends>
<header>Gui/QuantitySpinBox.h</header>
</customwidget>
<customwidget>
<class>Gui::PrefCheckBox</class>
<extends>QCheckBox</extends>
<header>Gui/PrefWidgets.h</header>
</customwidget>
<customwidget>
<class>Gui::PrefQuantitySpinBox</class>
<extends>Gui::QuantitySpinBox</extends>
<header>Gui/PrefWidgets.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>