From 71a6ffde359dc64e5d5516dbd82b8c8fc46155bb Mon Sep 17 00:00:00 2001 From: wmayer Date: Mon, 21 Feb 2022 17:49:27 +0100 Subject: [PATCH] Gui: move Python console specific settings to its own tab because General is quite overloaded --- src/Gui/CMakeLists.txt | 4 + src/Gui/DlgGeneral.ui | 65 ---------------- src/Gui/DlgGeneralImp.cpp | 4 - src/Gui/DlgSettingsPythonConsole.cpp | 70 +++++++++++++++++ src/Gui/DlgSettingsPythonConsole.h | 60 +++++++++++++++ src/Gui/DlgSettingsPythonConsole.ui | 108 +++++++++++++++++++++++++++ src/Gui/resource.cpp | 2 + 7 files changed, 244 insertions(+), 69 deletions(-) create mode 100644 src/Gui/DlgSettingsPythonConsole.cpp create mode 100644 src/Gui/DlgSettingsPythonConsole.h create mode 100644 src/Gui/DlgSettingsPythonConsole.ui diff --git a/src/Gui/CMakeLists.txt b/src/Gui/CMakeLists.txt index 75ad98f3de..0f9dd088c0 100644 --- a/src/Gui/CMakeLists.txt +++ b/src/Gui/CMakeLists.txt @@ -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}) diff --git a/src/Gui/DlgGeneral.ui b/src/Gui/DlgGeneral.ui index 9298ba9a3e..87429f066b 100644 --- a/src/Gui/DlgGeneral.ui +++ b/src/Gui/DlgGeneral.ui @@ -567,69 +567,6 @@ after FreeCAD launches - - - - Python console - - - - 11 - - - 11 - - - 11 - - - 11 - - - 6 - - - - - Words will be wrapped when they exceed available -horizontal space in Python console - - - Enable word wrap - - - true - - - PythonWordWrap - - - General - - - - - - - The cursor shape will be a block - - - Enable block cursor - - - false - - - PythonBlockCursor - - - General - - - - - - @@ -653,8 +590,6 @@ horizontal space in Python console RecentFiles EnableCursorBlinking SplashScreen - PythonWordWrap - PythonBlockCursor diff --git a/src/Gui/DlgGeneralImp.cpp b/src/Gui/DlgGeneralImp.cpp index 270ec4debf..98d1a6d086 100644 --- a/src/Gui/DlgGeneralImp.cpp +++ b/src/Gui/DlgGeneralImp.cpp @@ -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(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"); diff --git a/src/Gui/DlgSettingsPythonConsole.cpp b/src/Gui/DlgSettingsPythonConsole.cpp new file mode 100644 index 0000000000..69bf6aa8d3 --- /dev/null +++ b/src/Gui/DlgSettingsPythonConsole.cpp @@ -0,0 +1,70 @@ +/*************************************************************************** + * Copyright (c) 2022 Werner Mayer * + * * + * 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 + +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" diff --git a/src/Gui/DlgSettingsPythonConsole.h b/src/Gui/DlgSettingsPythonConsole.h new file mode 100644 index 0000000000..84b507a3b2 --- /dev/null +++ b/src/Gui/DlgSettingsPythonConsole.h @@ -0,0 +1,60 @@ +/*************************************************************************** + * Copyright (c) 2022 Werner Mayer * + * * + * 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 + +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; +}; + +} // namespace Dialog +} // namespace Gui + +#endif // GUI_DIALOG_DLGSETTINGSPYTHONCONSOLE_H diff --git a/src/Gui/DlgSettingsPythonConsole.ui b/src/Gui/DlgSettingsPythonConsole.ui new file mode 100644 index 0000000000..979f7e4fdd --- /dev/null +++ b/src/Gui/DlgSettingsPythonConsole.ui @@ -0,0 +1,108 @@ + + + Gui::Dialog::DlgSettingsPythonConsole + + + + 0 + 0 + 654 + 259 + + + + Python console + + + + + + Settings + + + + + + Words will be wrapped when they exceed available +horizontal space in Python console + + + Enable word wrap + + + true + + + PythonWordWrap + + + General + + + + + + + The cursor shape will be a block + + + Enable block cursor + + + false + + + PythonBlockCursor + + + General + + + + + + + Saves Python history across sessions + + + Save history + + + false + + + SavePythonHistory + + + General + + + + + + + + + + Qt::Vertical + + + + 20 + 63 + + + + + + + + + Gui::PrefCheckBox + QCheckBox +
Gui/PrefWidgets.h
+
+
+ + +
diff --git a/src/Gui/resource.cpp b/src/Gui/resource.cpp index 76bc18813d..45bdb4bb2e 100644 --- a/src/Gui/resource.cpp +++ b/src/Gui/resource.cpp @@ -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 ( QT_TRANSLATE_NOOP("QObject","General") ); new PrefPageProducer( QT_TRANSLATE_NOOP("QObject","General") ); new PrefPageProducer ( QT_TRANSLATE_NOOP("QObject","General") ); + new PrefPageProducer ( QT_TRANSLATE_NOOP("QObject","General") ); new PrefPageProducer ( QT_TRANSLATE_NOOP("QObject","General") ); new PrefPageProducer ( QT_TRANSLATE_NOOP("QObject","General") ); new PrefPageProducer ( QT_TRANSLATE_NOOP("QObject","General") );