[Gui] Disable the ability to change themes and preference packs...

This commit is contained in:
Syres916
2024-10-09 23:16:29 +01:00
committed by Chris Hennes
parent 5aebe6d751
commit 8b53daf263
2 changed files with 53 additions and 8 deletions

View File

@@ -53,6 +53,8 @@
#include <Gui/OverlayManager.h>
#include <Gui/ParamHandler.h>
#include <Gui/PreferencePackManager.h>
#include <Gui/View3DInventor.h>
#include <Gui/View3DInventorViewer.h>
#include <Gui/Language/Translator.h>
#include "DlgSettingsGeneral.h"
@@ -82,13 +84,30 @@ DlgSettingsGeneral::DlgSettingsGeneral( QWidget* parent )
recreatePreferencePackMenu();
connect(ui->ImportConfig, &QPushButton::clicked, this, &DlgSettingsGeneral::onImportConfigClicked);
connect(ui->SaveNewPreferencePack, &QPushButton::clicked, this, &DlgSettingsGeneral::saveAsNewPreferencePack);
connect(ui->themesCombobox, qOverload<int>(&QComboBox::activated), this, &DlgSettingsGeneral::onThemeChanged);
connect(ui->moreThemesLabel, &QLabel::linkActivated, this, &DlgSettingsGeneral::onLinkActivated);
ui->ManagePreferencePacks->setToolTip(tr("Manage preference packs"));
connect(ui->ManagePreferencePacks, &QPushButton::clicked, this, &DlgSettingsGeneral::onManagePreferencePacksClicked);
ui->themesCombobox->setEnabled(true);
Gui::Document* doc = Gui::Application::Instance->activeDocument();
if (doc) {
Gui::View3DInventor* view = static_cast<Gui::View3DInventor*>(doc->getActiveView());
if (view) {
Gui::View3DInventorViewer* viewer = view->getViewer();
if (viewer->isEditing()) {
ui->ImportConfig->setEnabled(false);
ui->SaveNewPreferencePack->setEnabled(false);
ui->ManagePreferencePacks->setEnabled(false);
ui->themesCombobox->setEnabled(false);
ui->moreThemesLabel->setEnabled(false);
}
}
}
if (ui->themesCombobox->isEnabled()) {
connect(ui->ImportConfig, &QPushButton::clicked, this, &DlgSettingsGeneral::onImportConfigClicked);
connect(ui->SaveNewPreferencePack, &QPushButton::clicked, this, &DlgSettingsGeneral::saveAsNewPreferencePack);
ui->ManagePreferencePacks->setToolTip(tr("Manage preference packs"));
connect(ui->ManagePreferencePacks, &QPushButton::clicked, this, &DlgSettingsGeneral::onManagePreferencePacksClicked);
connect(ui->themesCombobox, qOverload<int>(&QComboBox::activated), this, &DlgSettingsGeneral::onThemeChanged);
connect(ui->moreThemesLabel, &QLabel::linkActivated, this, &DlgSettingsGeneral::onLinkActivated);
}
// If there are any saved config file backs, show the revert button, otherwise hide it:
const auto & backups = Application::Instance->prefPackManager()->configBackups();
@@ -643,8 +662,21 @@ void DlgSettingsGeneral::recreatePreferencePackMenu()
auto kind = new QTableWidgetItem(tagString);
ui->PreferencePacks->setItem(row, 1, kind);
auto button = new QPushButton(icon, tr("Apply"));
button->setToolTip(tr("Apply the %1 preference pack").arg(QString::fromStdString(pack.first)));
connect(button, &QPushButton::clicked, this, [this, pack]() { onLoadPreferencePackClicked(pack.first); });
button->setEnabled(true);
Gui::Document* doc = Gui::Application::Instance->activeDocument();
if (doc) {
Gui::View3DInventor* view = static_cast<Gui::View3DInventor*>(doc->getActiveView());
if (view) {
Gui::View3DInventorViewer* viewer = view->getViewer();
if (viewer->isEditing()) {
button->setEnabled(false);
}
}
}
if (button->isEnabled()) {
button->setToolTip(tr("Apply the %1 preference pack").arg(QString::fromStdString(pack.first)));
connect(button, &QPushButton::clicked, this, [this, pack]() { onLoadPreferencePackClicked(pack.first); });
}
ui->PreferencePacks->setCellWidget(row, 2, button);
++row;
}

View File

@@ -49,6 +49,8 @@
#include <Base/Tools.h>
#include <Gui/Application.h>
#include <Gui/Command.h>
#include <Gui/View3DInventor.h>
#include <Gui/View3DInventorViewer.h>
#include <gsl/pointers>
using namespace StartGui;
@@ -476,6 +478,17 @@ void StartView::firstStartWidgetDismissed()
void StartView::changeEvent(QEvent* event)
{
_openFirstStart->setEnabled(true);
Gui::Document* doc = Gui::Application::Instance->activeDocument();
if (doc) {
Gui::View3DInventor* view = static_cast<Gui::View3DInventor*>(doc->getActiveView());
if (view) {
Gui::View3DInventorViewer* viewer = view->getViewer();
if (viewer->isEditing()) {
_openFirstStart->setEnabled(false);
}
}
}
if (event->type() == QEvent::LanguageChange) {
this->retranslateUi();
}