From 4e31cb14128b8f3d3172e25525ef44543733388e Mon Sep 17 00:00:00 2001 From: Paddle Date: Fri, 24 Mar 2023 13:04:01 +0100 Subject: [PATCH] Preferences: Remove Customize Workbenches dialog. --- src/Gui/CMakeLists.txt | 4 - src/Gui/DlgWorkbenches.ui | 289 ---------------------------------- src/Gui/DlgWorkbenchesImp.cpp | 273 -------------------------------- src/Gui/DlgWorkbenchesImp.h | 79 ---------- src/Gui/resource.cpp | 2 - 5 files changed, 647 deletions(-) delete mode 100644 src/Gui/DlgWorkbenches.ui delete mode 100644 src/Gui/DlgWorkbenchesImp.cpp delete mode 100644 src/Gui/DlgWorkbenchesImp.h diff --git a/src/Gui/CMakeLists.txt b/src/Gui/CMakeLists.txt index f01bd764b8..13fd302545 100644 --- a/src/Gui/CMakeLists.txt +++ b/src/Gui/CMakeLists.txt @@ -331,7 +331,6 @@ SET(Gui_UIC_SRCS DlgSettingsPythonConsole.ui DlgCheckableMessageBox.ui DlgToolbars.ui - DlgWorkbenches.ui DlgTreeWidget.ui DlgLocationAngle.ui DlgLocationPos.ui @@ -526,7 +525,6 @@ SET(Dialog_Customize_CPP_SRCS DlgCustomizeSpNavSettings.cpp DlgKeyboardImp.cpp DlgToolbarsImp.cpp - DlgWorkbenchesImp.cpp QListWidgetCustom.cpp QListWidgetDragBugFix.cpp ) @@ -538,7 +536,6 @@ SET(Dialog_Customize_HPP_SRCS DlgCustomizeSpNavSettings.h DlgKeyboardImp.h DlgToolbarsImp.h - DlgWorkbenchesImp.h QListWidgetCustom.h QListWidgetDragBugFix.h ) @@ -551,7 +548,6 @@ SET(Dialog_Customize_SRCS DlgCustomizeSpNavSettings.ui DlgKeyboard.ui DlgToolbars.ui - DlgWorkbenches.ui ) SOURCE_GROUP("Dialog\\Customize" FILES ${Dialog_Customize_SRCS}) diff --git a/src/Gui/DlgWorkbenches.ui b/src/Gui/DlgWorkbenches.ui deleted file mode 100644 index 328f7d9fa3..0000000000 --- a/src/Gui/DlgWorkbenches.ui +++ /dev/null @@ -1,289 +0,0 @@ - - - Gui::Dialog::DlgWorkbenches - - - - 0 - 0 - 421 - 354 - - - - Workbenches - - - - 9 - - - 6 - - - - - 6 - - - 0 - - - - - Disabled workbenches - - - - - - - - - - - - 6 - - - 0 - - - - - Enabled workbenches - - - - - - - - - - - - true - - - - 30 - 30 - - - - Move right - - - <html><head/><body><p><span style=" font-weight:600;">Move the selected workbench to enabled workbenches.</span></p></body></html> - - - - - - - :/icons/button_right.svg:/icons/button_right.svg - - - - - - - true - - - - 30 - 30 - - - - Move up - - - <html><head/><body><p><span style=" font-weight:600;">Move the selected item up.</span></p><p>The item will be moved up.</p></body></html> - - - - - - - :/icons/button_up.svg:/icons/button_up.svg - - - - - - - true - - - - 30 - 30 - - - - Add all to enabled workbenches - - - <html><head/><body><p><span style=" font-weight:600;">Remove the selected workbench from enabled workbenches</span></p></body></html> - - - - - - - :/icons/button_add_all.svg:/icons/button_add_all.svg - - - true - - - false - - - - - - - true - - - - 30 - 30 - - - - Sort enabled workbenches - - - <p>Sort enabled workbenches</p> - - - - - - - :/icons/button_sort.svg:/icons/button_sort.svg - - - true - - - - - - - true - - - - 30 - 30 - - - - Move left - - - <html><head/><body><p><span style=" font-weight:600;">Remove the selected workbench from enabled workbenches</span></p></body></html> - - - - - - - :/icons/button_left.svg:/icons/button_left.svg - - - true - - - false - - - - - - - true - - - - 30 - 30 - - - - Move down - - - <html><head/><body><p><span style=" font-weight:600;">Move the selected item down.</span></p><p>The item will be moved down</p></body></html> - - - - - - - :/icons/button_down.svg:/icons/button_down.svg - - - true - - - - - - - Qt::Vertical - - - QSizePolicy::Expanding - - - - 33 - 57 - - - - - - - - Qt::Vertical - - - QSizePolicy::Expanding - - - - 33 - 57 - - - - - - - - <html><head/><body><p><span style=" font-size:8pt; font-weight:600;">Note:</span><span style=" font-family:'MS Shell Dlg 2'; font-size:8pt;"> The changes become active the next time you start the application</span></p></body></html> - - - - - - - - QListWidgetCustom - QListWidget -
QListWidgetCustom.h
-
-
- - - - -
diff --git a/src/Gui/DlgWorkbenchesImp.cpp b/src/Gui/DlgWorkbenchesImp.cpp deleted file mode 100644 index 45da472f35..0000000000 --- a/src/Gui/DlgWorkbenchesImp.cpp +++ /dev/null @@ -1,273 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2015 FreeCAD Developers * - * Author: Przemo Firszt * - * * - * 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 * - * * - ***************************************************************************/ - -// Based on DlgToolbars.cpp - -#include "PreCompiled.h" - -#ifndef _PreComp_ -# include -# include -#endif - -#include "DlgWorkbenchesImp.h" -#include "ui_DlgWorkbenches.h" -#include "Application.h" -#include "QListWidgetCustom.h" - - -using namespace Gui::Dialog; - -const QString DlgWorkbenchesImp::all_workbenches = QString::fromLatin1("ALL"); - -/* TRANSLATOR Gui::Dialog::DlgWorkbenchesImp */ - -DlgWorkbenchesImp::DlgWorkbenchesImp(QWidget* parent) - : CustomizeActionPage(parent) - , ui(new Ui_DlgWorkbenches) -{ - ui->setupUi(this); - set_lw_properties(ui->lw_enabled_workbenches); - set_lw_properties(ui->lw_disabled_workbenches); - ui->lw_disabled_workbenches->setProperty("OnlyAcceptFrom", - QStringList() << ui->lw_enabled_workbenches->objectName()); - ui->lw_disabled_workbenches->setSortingEnabled(true); - - ui->lw_enabled_workbenches->setProperty("OnlyAcceptFrom", - QStringList() << ui->lw_enabled_workbenches->objectName() - << ui->lw_disabled_workbenches->objectName()); - - QStringList enabled_wbs_list = load_enabled_workbenches(); - QStringList disabled_wbs_list = load_disabled_workbenches(); - QStringList workbenches = Application::Instance->workbenches(); - - for (QStringList::Iterator it = enabled_wbs_list.begin(); it != enabled_wbs_list.end(); ++it) { - if (workbenches.contains(*it)) { - add_workbench(ui->lw_enabled_workbenches, *it); - } else { - qDebug() << "Ignoring unknown" << *it << "workbench found in user preferences."; - } - } - for (QStringList::Iterator it = workbenches.begin(); it != workbenches.end(); ++it) { - if (disabled_wbs_list.contains(*it)){ - add_workbench(ui->lw_disabled_workbenches, *it); - } else if (!enabled_wbs_list.contains(*it)){ - qDebug() << "Adding unknown " << *it << "workbench."; - add_workbench(ui->lw_enabled_workbenches, *it); - } - } - ui->lw_enabled_workbenches->setCurrentRow(0); - ui->lw_disabled_workbenches->setCurrentRow(0); -} - -/** Destroys the object and frees any allocated resources */ -DlgWorkbenchesImp::~DlgWorkbenchesImp() -{ -} - -void DlgWorkbenchesImp::set_lw_properties(QListWidgetCustom *lw) -{ - lw->setDragDropMode(QAbstractItemView::DragDrop); - lw->setSelectionMode(QAbstractItemView::SingleSelection); - lw->viewport()->setAcceptDrops(true); - lw->setDropIndicatorShown(true); - lw->setDragEnabled(true); - lw->setDefaultDropAction(Qt::MoveAction); -} - -void DlgWorkbenchesImp::add_workbench(QListWidgetCustom *lw, const QString& it) -{ - QPixmap px = Application::Instance->workbenchIcon(it); - QString mt = Application::Instance->workbenchMenuText(it); - auto wi = (new QListWidgetItem(QIcon(px), mt)); - wi->setData(Qt::UserRole, QVariant(it)); - lw->addItem(wi); -} - -void DlgWorkbenchesImp::changeEvent(QEvent *e) -{ - if (e->type() == QEvent::LanguageChange) { - ui->retranslateUi(this); - } - else { - QWidget::changeEvent(e); - } -} - -void DlgWorkbenchesImp::hideEvent(QHideEvent * event) -{ - Q_UNUSED(event); - save_workbenches(); -} - -void DlgWorkbenchesImp::onAddMacroAction(const QByteArray& macro) -{ - Q_UNUSED(macro); -} - -void DlgWorkbenchesImp::onRemoveMacroAction(const QByteArray& macro) -{ - Q_UNUSED(macro); -} - -void DlgWorkbenchesImp::onModifyMacroAction(const QByteArray& macro) -{ - Q_UNUSED(macro); -} - -void DlgWorkbenchesImp::move_workbench(QListWidgetCustom *lwc_dest, - QListWidgetItem *wi) -{ - QListWidgetItem* item = wi->clone(); - lwc_dest->addItem(item); - lwc_dest->setCurrentItem(item); - delete wi; -} - -void DlgWorkbenchesImp::on_add_to_enabled_workbenches_btn_clicked() -{ - QListWidgetItem* ci = ui->lw_disabled_workbenches->currentItem(); - if (ci) { - move_workbench(ui->lw_enabled_workbenches, ci); - } -} - -void DlgWorkbenchesImp::on_remove_from_enabled_workbenches_btn_clicked() -{ - QListWidgetItem* ci = ui->lw_enabled_workbenches->currentItem(); - if (ci) { - move_workbench(ui->lw_disabled_workbenches, ci); - } -} - -void DlgWorkbenchesImp::shift_workbench(bool up) -{ - int direction; - if (up){ - direction = -1; - } else { - direction = 1; - } - if (ui->lw_enabled_workbenches->currentItem()) { - int index = ui->lw_enabled_workbenches->currentRow(); - QListWidgetItem *item = ui->lw_enabled_workbenches->takeItem(index); - ui->lw_enabled_workbenches->insertItem(index + direction, item); - ui->lw_enabled_workbenches->setCurrentRow(index + direction); - } -} - -void DlgWorkbenchesImp::on_shift_workbench_up_btn_clicked() -{ - shift_workbench(true); -} - -void DlgWorkbenchesImp::on_shift_workbench_down_btn_clicked() -{ - shift_workbench(false); -} - -void DlgWorkbenchesImp::on_sort_enabled_workbenches_btn_clicked() -{ - ui->lw_enabled_workbenches->sortItems(); -} - -void DlgWorkbenchesImp::on_add_all_to_enabled_workbenches_btn_clicked() -{ - while (ui->lw_disabled_workbenches->count() > 0) { - QListWidgetItem* item = ui->lw_disabled_workbenches->item(0); - move_workbench(ui->lw_enabled_workbenches, item); - } -} - -QStringList DlgWorkbenchesImp::load_enabled_workbenches() -{ - QString enabled_wbs; - QStringList enabled_wbs_list; - ParameterGrp::handle hGrp; - - hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Workbenches"); - enabled_wbs = QString::fromStdString(hGrp->GetASCII("Enabled", all_workbenches.toStdString().c_str()).c_str()); -#if QT_VERSION >= QT_VERSION_CHECK(5,15,0) - enabled_wbs_list = enabled_wbs.split(QLatin1String(","), Qt::SkipEmptyParts); -#else - enabled_wbs_list = enabled_wbs.split(QLatin1String(","), QString::SkipEmptyParts); -#endif - - if (enabled_wbs_list.at(0) == all_workbenches) { - enabled_wbs_list.removeFirst(); - QStringList workbenches = Application::Instance->workbenches(); - for (QStringList::Iterator it = workbenches.begin(); it != workbenches.end(); ++it) { - enabled_wbs_list.append(*it); - } - enabled_wbs_list.sort(); - } - return enabled_wbs_list; -} - -QStringList DlgWorkbenchesImp::load_disabled_workbenches() -{ - QString disabled_wbs; - QStringList disabled_wbs_list; - ParameterGrp::handle hGrp; - - hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Workbenches"); - disabled_wbs = QString::fromStdString(hGrp->GetASCII("Disabled", "")); -#if QT_VERSION >= QT_VERSION_CHECK(5,15,0) - disabled_wbs_list = disabled_wbs.split(QLatin1String(","), Qt::SkipEmptyParts); -#else - disabled_wbs_list = disabled_wbs.split(QLatin1String(","), QString::SkipEmptyParts); -#endif - - return disabled_wbs_list; -} - -void DlgWorkbenchesImp::save_workbenches() -{ - QString enabled_wbs; - QString disabled_wbs; - ParameterGrp::handle hGrp; - - hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Workbenches"); - hGrp->Clear(); - - if (ui->lw_enabled_workbenches->count() == 0) { - enabled_wbs.append(QString::fromLatin1("NoneWorkbench")); - } else { - for (int i = 0; i < ui->lw_enabled_workbenches->count(); i++) { - QVariant item_data = ui->lw_enabled_workbenches->item(i)->data(Qt::UserRole); - QString name = item_data.toString(); - enabled_wbs.append(name + QString::fromLatin1(",")); - } - } - hGrp->SetASCII("Enabled", enabled_wbs.toLatin1()); - - for (int i = 0; i < ui->lw_disabled_workbenches->count(); i++) { - QVariant item_data = ui->lw_disabled_workbenches->item(i)->data(Qt::UserRole); - QString name = item_data.toString(); - disabled_wbs.append(name + QString::fromLatin1(",")); - } - hGrp->SetASCII("Disabled", disabled_wbs.toLatin1()); -} - -#include "moc_DlgWorkbenchesImp.cpp" - diff --git a/src/Gui/DlgWorkbenchesImp.h b/src/Gui/DlgWorkbenchesImp.h deleted file mode 100644 index dc3cf907e3..0000000000 --- a/src/Gui/DlgWorkbenchesImp.h +++ /dev/null @@ -1,79 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2015 FreeCAD Developers * - * Author: Przemo Firszt * - * * - * 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 * - * * - ***************************************************************************/ - -// Based on DlgToolbars.h file - - -#ifndef GUI_DIALOG_DLGWORKBENCHES_IMP_H -#define GUI_DIALOG_DLGWORKBENCHES_IMP_H - -#include "PropertyPage.h" -#include - -class QListWidgetCustom; -class QListWidgetItem; - -namespace Gui { -namespace Dialog { -class Ui_DlgWorkbenches; - -class DlgWorkbenchesImp : public CustomizeActionPage -{ - Q_OBJECT - -public: - explicit DlgWorkbenchesImp(QWidget* parent = nullptr); - ~DlgWorkbenchesImp() override; - static QStringList load_enabled_workbenches(); - static QStringList load_disabled_workbenches(); - static const QString all_workbenches; - -protected: - void changeEvent(QEvent *e) override; - void hideEvent(QHideEvent * event) override; - -protected Q_SLOTS: - void onAddMacroAction(const QByteArray&) override; - void onRemoveMacroAction(const QByteArray&) override; - void onModifyMacroAction(const QByteArray&) override; - void on_add_to_enabled_workbenches_btn_clicked(); - void on_remove_from_enabled_workbenches_btn_clicked(); - void on_shift_workbench_up_btn_clicked(); - void on_shift_workbench_down_btn_clicked(); - void on_sort_enabled_workbenches_btn_clicked(); - void on_add_all_to_enabled_workbenches_btn_clicked(); - -private: - void set_lw_properties(QListWidgetCustom *lw); - void add_workbench(QListWidgetCustom *lw, const QString& it); - void move_workbench(QListWidgetCustom *lwc_dest, - QListWidgetItem *wi); - void save_workbenches(); - void shift_workbench(bool up); - -private: - std::unique_ptr ui; -}; - -} // namespace Dialog -} // namespace Gui - -#endif // GUI_DIALOG_DLGWORKBENCHES_IMP_H diff --git a/src/Gui/resource.cpp b/src/Gui/resource.cpp index 8e84edf1e2..1572bbab5f 100644 --- a/src/Gui/resource.cpp +++ b/src/Gui/resource.cpp @@ -45,7 +45,6 @@ #include "DlgSettingsLazyLoadedImp.h" #include "DlgToolbarsImp.h" -#include "DlgWorkbenchesImp.h" #include "DlgActionsImp.h" #include "DlgCommandsImp.h" #include "DlgKeyboardImp.h" @@ -87,7 +86,6 @@ WidgetFactorySupplier::WidgetFactorySupplier() // new CustomPageProducer; new CustomPageProducer; - new CustomPageProducer; new CustomPageProducer; new CustomPageProducer; new CustomPageProducer;