Gui: add preferences tab for selection

This commit is contained in:
wmayer
2021-02-03 18:06:55 +01:00
parent 99b2cba5f1
commit d73ccbdba0
5 changed files with 208 additions and 0 deletions

View File

@@ -317,6 +317,7 @@ set(Gui_MOC_HDRS
DlgReportViewImp.h
DlgSettings3DViewImp.h
DlgSettingsNavigation.h
DlgSettingsSelection.h
DlgSettingsViewColor.h
DlgSettingsColorGradientImp.h
DlgSettingsDocumentImp.h
@@ -443,6 +444,7 @@ SET(Gui_UIC_SRCS
DlgReportView.ui
DlgSettings3DView.ui
DlgSettingsNavigation.ui
DlgSettingsSelection.ui
DlgSettingsUnits.ui
DlgSettingsViewColor.ui
DlgSettingsColorGradient.ui
@@ -673,6 +675,7 @@ SET(Dialog_Settings_CPP_SRCS
DlgReportViewImp.cpp
DlgSettings3DViewImp.cpp
DlgSettingsNavigation.cpp
DlgSettingsSelection.cpp
DlgSettingsUnitsImp.cpp
DlgSettingsViewColor.cpp
DlgSettingsColorGradientImp.cpp
@@ -688,6 +691,7 @@ SET(Dialog_Settings_HPP_SRCS
DlgReportViewImp.h
DlgSettings3DViewImp.h
DlgSettingsNavigation.h
DlgSettingsSelection.h
DlgSettingsUnitsImp.h
DlgSettingsViewColor.h
DlgSettingsColorGradientImp.h
@@ -705,6 +709,7 @@ SET(Dialog_Settings_SRCS
DlgReportView.ui
DlgSettings3DView.ui
DlgSettingsNavigation.ui
DlgSettingsSelection.ui
DlgSettingsUnits.ui
DlgSettingsViewColor.ui
DlgSettingsColorGradient.ui

View File

@@ -0,0 +1,77 @@
/***************************************************************************
* Copyright (c) 2021 Werner Mayer <wmayer[at]users.sourceforge.net> *
* *
* 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"
#ifndef _PreComp_
#endif
#include "DlgSettingsSelection.h"
#include "ui_DlgSettingsSelection.h"
#include <App/Application.h>
using namespace Gui::Dialog;
/* TRANSLATOR Gui::Dialog::DlgSettingsSelection */
DlgSettingsSelection::DlgSettingsSelection(QWidget* parent)
: PreferencePage(parent)
, ui(new Ui_DlgSettingsSelection)
{
ui->setupUi(this);
}
DlgSettingsSelection::~DlgSettingsSelection()
{
}
void DlgSettingsSelection::saveSettings()
{
auto handle = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/TreeView");
handle->SetBool("SyncView", ui->checkBoxAutoSwitch->isChecked());
handle->SetBool("SyncSelection", ui->checkBoxAutoExpand->isChecked());
handle->SetBool("PreSelection", ui->checkBoxPreselect->isChecked());
handle->SetBool("RecordSelection", ui->checkBoxRecord->isChecked());
}
void DlgSettingsSelection::loadSettings()
{
auto handle = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/TreeView");
ui->checkBoxAutoSwitch->setChecked(handle->GetBool("SyncView"));
ui->checkBoxAutoExpand->setChecked(handle->GetBool("SyncSelection"));
ui->checkBoxPreselect->setChecked(handle->GetBool("PreSelection"));
ui->checkBoxRecord->setChecked(handle->GetBool("RecordSelection"));
}
void DlgSettingsSelection::changeEvent(QEvent *e)
{
if (e->type() == QEvent::LanguageChange) {
ui->retranslateUi(this);
}
else {
QWidget::changeEvent(e);
}
}
#include "moc_DlgSettingsSelection.cpp"

View File

@@ -0,0 +1,62 @@
/***************************************************************************
* Copyright (c) 2021 Werner Mayer <wmayer[at]users.sourceforge.net> *
* *
* 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_DIALOG_DLGSETTINGSSELECTION_H
#define GUI_DIALOG_DLGSETTINGSSELECTION_H
#include "PropertyPage.h"
#include <memory>
class QDoubleSpinBox;
namespace Gui {
namespace Dialog {
class Ui_DlgSettingsSelection;
/**
* The Ui_DlgSettingsSelection class implements a preference page to change settings
* for the selection.
* \author Werner Mayer
*/
class DlgSettingsSelection : public PreferencePage
{
Q_OBJECT
public:
DlgSettingsSelection(QWidget* parent = nullptr);
~DlgSettingsSelection();
void saveSettings();
void loadSettings();
protected:
void changeEvent(QEvent *e);
private:
std::unique_ptr<Ui_DlgSettingsSelection> ui;
};
} // namespace Dialog
} // namespace Gui
#endif // GUI_DIALOG_DLGSETTINGSSELECTION_H

View File

@@ -0,0 +1,62 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Gui::Dialog::DlgSettingsSelection</class>
<widget class="QWidget" name="Gui::Dialog::DlgSettingsSelection">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>670</width>
<height>411</height>
</rect>
</property>
<property name="windowTitle">
<string>Selection</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QCheckBox" name="checkBoxAutoSwitch">
<property name="text">
<string>Auto switch to the 3D view containing the selected item</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="checkBoxAutoExpand">
<property name="text">
<string>Auto expand tree item when the corresponding object is selected in 3D view</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="checkBoxPreselect">
<property name="text">
<string>Preselect the object in 3D view when mouse over the tree item</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="checkBoxRecord">
<property name="text">
<string>Record selection in tree view in order to go back/forward using navigation button</string>
</property>
</widget>
</item>
<item row="4" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>274</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@@ -32,6 +32,7 @@
#include "DlgPreferencesImp.h"
#include "DlgSettings3DViewImp.h"
#include "DlgSettingsNavigation.h"
#include "DlgSettingsSelection.h"
#include "DlgSettingsViewColor.h"
#include "DlgGeneralImp.h"
#include "DlgEditorImp.h"
@@ -66,6 +67,7 @@ WidgetFactorySupplier::WidgetFactorySupplier()
new PrefPageProducer<DlgGeneralImp> ( QT_TRANSLATE_NOOP("QObject","General") );
//new PrefPageProducer<DlgOnlineHelpImp> ( QT_TRANSLATE_NOOP("QObject","General") );
new PrefPageProducer<DlgSettingsDocumentImp>( QT_TRANSLATE_NOOP("QObject","General") );
new PrefPageProducer<DlgSettingsSelection> ( QT_TRANSLATE_NOOP("QObject","General") );
new PrefPageProducer<DlgSettingsEditorImp> ( QT_TRANSLATE_NOOP("QObject","General") );
new PrefPageProducer<DlgReportViewImp> ( QT_TRANSLATE_NOOP("QObject","General") );
new PrefPageProducer<DlgSettingsMacroImp> ( QT_TRANSLATE_NOOP("QObject","General") );