Gui: move Python console specific settings to its own tab because General is quite overloaded

This commit is contained in:
wmayer
2022-02-21 17:49:27 +01:00
parent 39c03863b5
commit 71a6ffde35
7 changed files with 244 additions and 69 deletions

View File

@@ -340,6 +340,7 @@ SET(Gui_UIC_SRCS
DlgSettingsImage.ui
DlgSettingsLazyLoaded.ui
DlgSettingsMacro.ui
DlgSettingsPythonConsole.ui
DlgCheckableMessageBox.ui
DlgToolbars.ui
DlgWorkbenches.ui
@@ -582,6 +583,7 @@ SET(Dialog_Settings_CPP_SRCS
DlgSettingsImageImp.cpp
DlgSettingsLazyLoadedImp.cpp
DlgSettingsMacroImp.cpp
DlgSettingsPythonConsole.cpp
)
SET(Dialog_Settings_HPP_SRCS
DlgEditorImp.h
@@ -600,6 +602,7 @@ SET(Dialog_Settings_HPP_SRCS
DlgSettingsImageImp.h
DlgSettingsLazyLoadedImp.h
DlgSettingsMacroImp.h
DlgSettingsPythonConsole.h
)
SET(Dialog_Settings_SRCS
${Dialog_Settings_CPP_SRCS}
@@ -620,6 +623,7 @@ SET(Dialog_Settings_SRCS
DlgSettingsImage.ui
DlgSettingsLazyLoaded.ui
DlgSettingsMacro.ui
DlgSettingsPythonConsole.ui
)
SOURCE_GROUP("Dialog\\Settings" FILES ${Dialog_Settings_SRCS})

View File

@@ -567,69 +567,6 @@ after FreeCAD launches</string>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="GroupBox11">
<property name="title">
<string>Python console</string>
</property>
<layout class="QGridLayout" name="_4">
<property name="leftMargin">
<number>11</number>
</property>
<property name="topMargin">
<number>11</number>
</property>
<property name="rightMargin">
<number>11</number>
</property>
<property name="bottomMargin">
<number>11</number>
</property>
<property name="spacing">
<number>6</number>
</property>
<item row="0" column="0">
<widget class="Gui::PrefCheckBox" name="PythonWordWrap">
<property name="toolTip">
<string>Words will be wrapped when they exceed available
horizontal space in Python console</string>
</property>
<property name="text">
<string>Enable word wrap</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>PythonWordWrap</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>General</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="Gui::PrefCheckBox" name="PythonBlockCursor">
<property name="toolTip">
<string>The cursor shape will be a block</string>
</property>
<property name="text">
<string>Enable block cursor</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>PythonBlockCursor</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>General</cstring>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
@@ -653,8 +590,6 @@ horizontal space in Python console</string>
<tabstop>RecentFiles</tabstop>
<tabstop>EnableCursorBlinking</tabstop>
<tabstop>SplashScreen</tabstop>
<tabstop>PythonWordWrap</tabstop>
<tabstop>PythonBlockCursor</tabstop>
</tabstops>
<resources/>
<connections/>

View File

@@ -139,8 +139,6 @@ void DlgGeneralImp::saveSettings()
ui->RecentFiles->onSave();
ui->EnableCursorBlinking->onSave();
ui->SplashScreen->onSave();
ui->PythonWordWrap->onSave();
ui->PythonBlockCursor->onSave();
QWidget* pc = DockWindowManager::instance()->getDockWindow("Python console");
PythonConsole *pcPython = qobject_cast<PythonConsole*>(pc);
@@ -209,8 +207,6 @@ void DlgGeneralImp::loadSettings()
ui->RecentFiles->onRestore();
ui->EnableCursorBlinking->onRestore();
ui->SplashScreen->onRestore();
ui->PythonWordWrap->onRestore();
ui->PythonBlockCursor->onRestore();
// search for the language files
ParameterGrp::handle hGrp = WindowParameter::getDefaultParameter()->GetGroup("General");

View File

@@ -0,0 +1,70 @@
/***************************************************************************
* Copyright (c) 2022 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 "DlgSettingsPythonConsole.h"
#include "ui_DlgSettingsPythonConsole.h"
#include <App/Application.h>
using namespace Gui::Dialog;
/* TRANSLATOR Gui::Dialog::DlgSettingsPythonConsole */
DlgSettingsPythonConsole::DlgSettingsPythonConsole(QWidget* parent)
: PreferencePage(parent)
, ui(new Ui_DlgSettingsPythonConsole)
{
ui->setupUi(this);
}
DlgSettingsPythonConsole::~DlgSettingsPythonConsole()
{
}
void DlgSettingsPythonConsole::saveSettings()
{
ui->PythonWordWrap->onSave();
ui->PythonBlockCursor->onSave();
ui->PythonSaveHistory->onSave();
}
void DlgSettingsPythonConsole::loadSettings()
{
ui->PythonWordWrap->onRestore();
ui->PythonBlockCursor->onRestore();
ui->PythonSaveHistory->onRestore();
}
void DlgSettingsPythonConsole::changeEvent(QEvent *e)
{
if (e->type() == QEvent::LanguageChange) {
ui->retranslateUi(this);
}
QWidget::changeEvent(e);
}
#include "moc_DlgSettingsPythonConsole.cpp"

View File

@@ -0,0 +1,60 @@
/***************************************************************************
* Copyright (c) 2022 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_DLGSETTINGSPYTHONCONSOLE_H
#define GUI_DIALOG_DLGSETTINGSPYTHONCONSOLE_H
#include "PropertyPage.h"
#include <memory>
namespace Gui {
namespace Dialog {
class Ui_DlgSettingsPythonConsole;
/**
* The DlgSettingsPythonConsole class implements a preference page to change settings
* for the Python console.
* @author Werner Mayer
*/
class DlgSettingsPythonConsole : public PreferencePage
{
Q_OBJECT
public:
DlgSettingsPythonConsole(QWidget* parent = nullptr);
~DlgSettingsPythonConsole();
void saveSettings();
void loadSettings();
protected:
void changeEvent(QEvent *e);
private:
std::unique_ptr<Ui_DlgSettingsPythonConsole> ui;
};
} // namespace Dialog
} // namespace Gui
#endif // GUI_DIALOG_DLGSETTINGSPYTHONCONSOLE_H

View File

@@ -0,0 +1,108 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Gui::Dialog::DlgSettingsPythonConsole</class>
<widget class="QWidget" name="Gui::Dialog::DlgSettingsPythonConsole">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>654</width>
<height>259</height>
</rect>
</property>
<property name="windowTitle">
<string>Python console</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QGroupBox" name="GroupBox11">
<property name="title">
<string>Settings</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="Gui::PrefCheckBox" name="PythonWordWrap">
<property name="toolTip">
<string>Words will be wrapped when they exceed available
horizontal space in Python console</string>
</property>
<property name="text">
<string>Enable word wrap</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>PythonWordWrap</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>General</cstring>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="Gui::PrefCheckBox" name="PythonBlockCursor">
<property name="toolTip">
<string>The cursor shape will be a block</string>
</property>
<property name="text">
<string>Enable block cursor</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>PythonBlockCursor</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>General</cstring>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="Gui::PrefCheckBox" name="PythonSaveHistory">
<property name="toolTip">
<string>Saves Python history across sessions</string>
</property>
<property name="text">
<string>Save history</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>SavePythonHistory</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>General</cstring>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>63</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>Gui::PrefCheckBox</class>
<extends>QCheckBox</extends>
<header>Gui/PrefWidgets.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@@ -36,6 +36,7 @@
#include "DlgSettingsViewColor.h"
#include "DlgGeneralImp.h"
#include "DlgEditorImp.h"
#include "DlgSettingsPythonConsole.h"
#include "DlgSettingsMacroImp.h"
#include "DlgSettingsUnitsImp.h"
#include "DlgSettingsDocumentImp.h"
@@ -72,6 +73,7 @@ WidgetFactorySupplier::WidgetFactorySupplier()
new PrefPageProducer<DlgSettingsSelection> ( QT_TRANSLATE_NOOP("QObject","General") );
new PrefPageProducer<DlgSettingsCacheDirectory>( QT_TRANSLATE_NOOP("QObject","General") );
new PrefPageProducer<DlgSettingsEditorImp> ( QT_TRANSLATE_NOOP("QObject","General") );
new PrefPageProducer<DlgSettingsPythonConsole> ( QT_TRANSLATE_NOOP("QObject","General") );
new PrefPageProducer<DlgReportViewImp> ( QT_TRANSLATE_NOOP("QObject","General") );
new PrefPageProducer<DlgSettingsMacroImp> ( QT_TRANSLATE_NOOP("QObject","General") );
new PrefPageProducer<DlgSettingsUnitsImp> ( QT_TRANSLATE_NOOP("QObject","General") );