diff --git a/src/Gui/DlgCreateNewPreferencePack.ui b/src/Gui/DlgCreateNewPreferencePack.ui
index 5165aeffe1..98f4589f0e 100644
--- a/src/Gui/DlgCreateNewPreferencePack.ui
+++ b/src/Gui/DlgCreateNewPreferencePack.ui
@@ -36,6 +36,9 @@
-
+
+ 1
+
50
@@ -50,11 +53,6 @@
Property group templates
-
-
- Template Type
-
-
-
diff --git a/src/Gui/DlgCreateNewPreferencePackImp.cpp b/src/Gui/DlgCreateNewPreferencePackImp.cpp
index 74bcfb752f..47c6bda8f0 100644
--- a/src/Gui/DlgCreateNewPreferencePackImp.cpp
+++ b/src/Gui/DlgCreateNewPreferencePackImp.cpp
@@ -81,11 +81,6 @@ void DlgCreateNewPreferencePackImp::setPreferencePackTemplates(const std::vector
QStringList itemColumns;
itemColumns.push_back(QString::fromStdString(t.name));
- switch (t.type) {
- case Gui::PreferencePack::Type::Appearance: itemColumns.push_back(tr("Appearance")); break;
- case Gui::PreferencePack::Type::Behavior: itemColumns.push_back(tr("Behavior")); break;
- case Gui::PreferencePack::Type::Combination: itemColumns.push_back(tr("Combination")); break;
- }
auto newItem = new QTreeWidgetItem(group, itemColumns);
newItem->setCheckState(0, Qt::Checked);
if (group->checkState(0) != newItem->checkState(0))
diff --git a/src/Gui/DlgGeneralImp.cpp b/src/Gui/DlgGeneralImp.cpp
index 697c263213..a1053da4dd 100644
--- a/src/Gui/DlgGeneralImp.cpp
+++ b/src/Gui/DlgGeneralImp.cpp
@@ -102,10 +102,13 @@ DlgGeneralImp::DlgGeneralImp( QWidget* parent )
auto savedPreferencePacksDirectory = fs::path(App::Application::getUserAppDataDir()) / "SavedPreferencePacks";
// If that directory hasn't been created yet, just send the user to the preferences directory
- if (!(fs::exists(savedPreferencePacksDirectory) && fs::is_directory(savedPreferencePacksDirectory)))
+ if (!(fs::exists(savedPreferencePacksDirectory) && fs::is_directory(savedPreferencePacksDirectory))) {
savedPreferencePacksDirectory = fs::path(App::Application::getUserAppDataDir());
+ ui->ManagePreferencePacks->hide();
+ }
QString pathToSavedPacks(QString::fromStdString(savedPreferencePacksDirectory.string()));
+ ui->ManagePreferencePacks->setToolTip(tr("Open the directory of saved user preference packs"));
connect(ui->ManagePreferencePacks, &QPushButton::clicked, this, [pathToSavedPacks]() { QDesktopServices::openUrl(QUrl::fromLocalFile(pathToSavedPacks)); });
}
@@ -336,56 +339,46 @@ void DlgGeneralImp::recreatePreferencePackMenu()
ui->PreferencePacks->horizontalHeader()->setSectionResizeMode(2, QHeaderView::ResizeMode::ResizeToContents);
QStringList columnHeaders;
columnHeaders << tr("Preference Pack Name")
- << tr("Type", "Whether a preference pack sets appearance, behavior, or both")
+ << tr("Tags")
<< QString(); // for the "Load" buttons
ui->PreferencePacks->setHorizontalHeaderLabels(columnHeaders);
// Populate the Preference Packs list
- std::map> packNames;
- packNames[PreferencePack::Type::Appearance] = Application::Instance->prefPackManager()->preferencePackNames(PreferencePack::Type::Appearance);
- packNames[PreferencePack::Type::Behavior] = Application::Instance->prefPackManager()->preferencePackNames(PreferencePack::Type::Behavior);
- packNames[PreferencePack::Type::Combination] = Application::Instance->prefPackManager()->preferencePackNames(PreferencePack::Type::Combination);
+ auto packs = Application::Instance->prefPackManager()->preferencePacks();
- ui->PreferencePacks->setRowCount(
- packNames[PreferencePack::Type::Appearance].size() +
- packNames[PreferencePack::Type::Behavior].size() +
- packNames[PreferencePack::Type::Combination].size());
+ ui->PreferencePacks->setRowCount(packs.size());
int row = 0;
QIcon icon = style()->standardIcon(QStyle::SP_DialogApplyButton);
- for (const auto& packGroup : packNames) {
- for (const auto& pack : packGroup.second) {
- auto name = new QTableWidgetItem(QString::fromStdString(pack));
- ui->PreferencePacks->setItem(row, 0, name);
- QTableWidgetItem* kind;
- switch (packGroup.first) {
- case PreferencePack::Type::Appearance: kind = new QTableWidgetItem(tr("Appearance")); break;
- case PreferencePack::Type::Behavior: kind = new QTableWidgetItem(tr("Behavior")); break;
- case PreferencePack::Type::Combination: kind = new QTableWidgetItem(tr("Combination")); break;
- default: kind = new QTableWidgetItem(QString::fromUtf8("[ERR: UNKNOWN TYPE]")); break;
- }
- 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)));
- connect(button, &QPushButton::clicked, this, [this, pack]() { onLoadPreferencePackClicked(pack); });
- ui->PreferencePacks->setCellWidget(row, 2, button);
- ++row;
+ for (const auto& pack : packs) {
+ auto name = new QTableWidgetItem(QString::fromStdString(pack.first));
+ name->setToolTip(QString::fromStdString(pack.second.metadata().description()));
+ ui->PreferencePacks->setItem(row, 0, name);
+ auto tags = pack.second.metadata().tag();
+ QString tagString;
+ for (const auto& tag : tags) {
+ if (tagString.isEmpty())
+ tagString.append(QString::fromStdString(tag));
+ else
+ tagString.append(QStringLiteral(", ") + QString::fromStdString(tag));
}
+ QTableWidgetItem* 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); });
+ ui->PreferencePacks->setCellWidget(row, 2, button);
+ ++row;
}
}
void DlgGeneralImp::saveAsNewPreferencePack()
{
// Create and run a modal New PreferencePack dialog box
- auto appearancePacks = Application::Instance->prefPackManager()->preferencePackNames(PreferencePack::Type::Appearance);
- auto behaviorPacks = Application::Instance->prefPackManager()->preferencePackNames(PreferencePack::Type::Behavior);
- auto combinationPacks = Application::Instance->prefPackManager()->preferencePackNames(PreferencePack::Type::Combination);
- auto allPacks = appearancePacks;
- allPacks.insert(allPacks.end(), behaviorPacks.begin(), behaviorPacks.end());
- allPacks.insert(allPacks.end(), combinationPacks.begin(), combinationPacks.end());
+ auto packs = Application::Instance->prefPackManager()->preferencePackNames();
newPreferencePackDialog = std::make_unique(this);
newPreferencePackDialog->setPreferencePackTemplates(Application::Instance->prefPackManager()->templateFiles());
- newPreferencePackDialog->setPreferencePackNames(allPacks);
+ newPreferencePackDialog->setPreferencePackNames(packs);
connect(newPreferencePackDialog.get(), &DlgCreateNewPreferencePackImp::accepted, this, &DlgGeneralImp::newPreferencePackDialogAccepted);
newPreferencePackDialog->open();
}
diff --git a/src/Gui/PreferencePackManager.cpp b/src/Gui/PreferencePackManager.cpp
index cb4e8e2a5b..3bb79c2c5e 100644
--- a/src/Gui/PreferencePackManager.cpp
+++ b/src/Gui/PreferencePackManager.cpp
@@ -113,19 +113,10 @@ bool PreferencePack::apply() const
return true;
}
-PreferencePack::Type PreferencePack::type() const
-{
- auto typeList = _metadata["type"];
- if (typeList.empty())
- return Type::Combination;
- auto typeString = typeList.front().contents;
- if (typeString == "appearance")
- return Type::Appearance;
- else if (typeString == "behavior" || typeString == "behaviour")
- return Type::Behavior;
- else
- return Type::Combination;
+App::Metadata Gui::PreferencePack::metadata() const
+{
+ return _metadata;
}
void PreferencePack::applyConfigChanges() const
@@ -191,16 +182,20 @@ void Gui::PreferencePackManager::FindPreferencePacksInPackage(const fs::path& mo
}
}
-std::vector PreferencePackManager::preferencePackNames(PreferencePack::Type type) const
+std::vector PreferencePackManager::preferencePackNames() const
{
std::lock_guard lock(_mutex);
std::vector names;
for (const auto& preferencePack : _preferencePacks)
- if (preferencePack.second.type() == type)
- names.push_back(preferencePack.first);
+ names.push_back(preferencePack.first);
return names;
}
+std::map Gui::PreferencePackManager::preferencePacks() const
+{
+ return _preferencePacks;
+}
+
bool PreferencePackManager::apply(const std::string& preferencePackName) const
{
std::lock_guard lock(_mutex);
@@ -320,21 +315,6 @@ void PreferencePackManager::save(const std::string& name, const std::vectoraddContentItem("preferencepack", newPreferencePackMetadata);
metadata->write(savedPreferencePacksDirectory / "package.xml");
@@ -383,28 +363,19 @@ std::vector scanForTemplateFiles(const std:
auto templateFolders = scanForTemplateFolders(groupName, entry);
std::vector templateFiles;
- for (const auto& dir : templateFolders) {
- auto templateDirs = std::vector>({
- std::make_pair(dir / "Appearance", PreferencePack::Type::Appearance),
- std::make_pair(dir / "appearance", PreferencePack::Type::Appearance),
- std::make_pair(dir / "Behavior", PreferencePack::Type::Behavior),
- std::make_pair(dir / "behavior", PreferencePack::Type::Behavior),
- std::make_pair(dir / "Behaviour", PreferencePack::Type::Behavior),
- std::make_pair(dir / "behaviour", PreferencePack::Type::Behavior) });
- for (const auto& templateDir : templateDirs) {
- if (!fs::exists(templateDir.first) || !fs::is_directory(templateDir.first))
- continue;
- for (const auto& entry : fs::directory_iterator(templateDir.first)) {
- if (entry.path().extension() == ".cfg") {
- auto name = entry.path().filename().stem().string();
- std::replace(name.begin(), name.end(), '_', ' ');
- // Make sure we don't insert the same thing twice...
- if (std::find_if(templateFiles.begin(), templateFiles.end(), [groupName, name](const auto &rhs)->bool {
- return groupName == rhs.group && name == rhs.name;
- } ) != templateFiles.end())
- continue;
- templateFiles.push_back({ groupName, name, entry, templateDir.second });
- }
+ for (const auto& templateDir : templateFolders) {
+ if (!fs::exists(templateDir) || !fs::is_directory(templateDir))
+ continue;
+ for (const auto& entry : fs::directory_iterator(templateDir)) {
+ if (entry.path().extension() == ".cfg") {
+ auto name = entry.path().filename().stem().string();
+ std::replace(name.begin(), name.end(), '_', ' ');
+ // Make sure we don't insert the same thing twice...
+ if (std::find_if(templateFiles.begin(), templateFiles.end(), [groupName, name](const auto &rhs)->bool {
+ return groupName == rhs.group && name == rhs.name;
+ } ) != templateFiles.end())
+ continue;
+ templateFiles.push_back({ groupName, name, entry });
}
}
}
diff --git a/src/Gui/PreferencePackManager.h b/src/Gui/PreferencePackManager.h
index 33bc43bdf6..78fd80c236 100644
--- a/src/Gui/PreferencePackManager.h
+++ b/src/Gui/PreferencePackManager.h
@@ -20,8 +20,8 @@
* *
***************************************************************************/
-#ifndef BASE_THEMEMANAGER_H
-#define BASE_THEMEMANAGER_H
+#ifndef BASE_PREFERENCEPACKMANAGER_H
+#define BASE_PREFERENCEPACKMANAGER_H
#include
#include
@@ -59,16 +59,10 @@ namespace Gui {
*/
bool apply() const;
- enum class Type {
- Appearance,
- Behavior,
- Combination
- };
-
/**
- * Get the type of PreferencePack (appearance, behavior, or a combination of the two)
+ * Get the complete metadata object for this preference pack
*/
- Type type() const;
+ App::Metadata metadata() const;
private:
@@ -100,9 +94,14 @@ namespace Gui {
void rescan();
/**
- * Get an alphabetical list of names of all installed PreferencePacks of a given type
+ * Get an alphabetical list of names of all installed PreferencePacks
*/
- std::vector preferencePackNames(PreferencePack::Type type) const;
+ std::vector preferencePackNames() const;
+
+ /**
+ * Get a map of all installed PreferencePack names and their associated packs
+ */
+ std::map preferencePacks() const;
/**
* Apply the named preferencePack
@@ -142,7 +141,7 @@ namespace Gui {
* templates that only affect appearance, and those that affect behavior.
*
* The base FreeCAD installation includes default templates in:
- * $INSTALL_DIR/data/Gui/PreferencePackTemplates/(Appearance|Behavior)/
+ * $INSTALL_DIR/data/Gui/PreferencePackTemplates/
*
* External add-ons are also searched for any directory called PreferencePackTemplates or
* preference_pack_templates -- either of which is expected to contain appearance and/or
@@ -154,7 +153,6 @@ namespace Gui {
std::string group; // Generally the Add-On/Mod/Package name
std::string name;
boost::filesystem::path path;
- PreferencePack::Type type;
};
/**
diff --git a/src/Gui/PreferencePackTemplates/Appearance/CMakeLists.txt b/src/Gui/PreferencePackTemplates/Appearance/CMakeLists.txt
deleted file mode 100644
index 8a88548d5e..0000000000
--- a/src/Gui/PreferencePackTemplates/Appearance/CMakeLists.txt
+++ /dev/null
@@ -1,27 +0,0 @@
-
-SET(PreferencePackTemplates_Files
- Arch_Colors.cfg
- Console_Colors.cfg
- Draft_Colors.cfg
- Editor_Colors.cfg
- Editor_Font.cfg
- Path_Colors.cfg
- Sketcher_Colors.cfg
- Start_Colors.cfg
- TechDraw_Colors.cfg
- Window_Colors.cfg
-)
-
-ADD_CUSTOM_TARGET(PreferencePackTemplates_data ALL
- SOURCES ${PreferencePackTemplates_Files}
-)
-
-fc_copy_sources(PreferencePackTemplates_data "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_DATADIR}/Gui/PreferencePackTemplates/Appearance"
- ${PreferencePackTemplates_Files})
-
-INSTALL(
- FILES
- ${PreferencePackTemplates_Files}
- DESTINATION
- ${CMAKE_INSTALL_DATADIR}/Gui/PreferencePackTemplates/Appearance
-)
\ No newline at end of file
diff --git a/src/Gui/PreferencePackTemplates/Appearance/Arch_Colors.cfg b/src/Gui/PreferencePackTemplates/Arch_Colors.cfg
similarity index 100%
rename from src/Gui/PreferencePackTemplates/Appearance/Arch_Colors.cfg
rename to src/Gui/PreferencePackTemplates/Arch_Colors.cfg
diff --git a/src/Gui/PreferencePackTemplates/Behavior/CMakeLists.txt b/src/Gui/PreferencePackTemplates/Behavior/CMakeLists.txt
deleted file mode 100644
index 7a6174cc9e..0000000000
--- a/src/Gui/PreferencePackTemplates/Behavior/CMakeLists.txt
+++ /dev/null
@@ -1,18 +0,0 @@
-
-SET(PreferencePackBehaviorTemplates_Files
- Main_window_layout.cfg
-)
-
-ADD_CUSTOM_TARGET(PreferencePackBehaviorTemplates_data ALL
- SOURCES ${PreferencePackBehaviorTemplates_Files}
-)
-
-fc_copy_sources(PreferencePackBehaviorTemplates_data "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_DATADIR}/Gui/PreferencePackTemplates/Behavior"
- ${PreferencePackBehaviorTemplates_Files})
-
-INSTALL(
- FILES
- ${PreferencePackBehaviorTemplates_Files}
- DESTINATION
- ${CMAKE_INSTALL_DATADIR}/Gui/PreferencePackTemplates/Behavior
-)
\ No newline at end of file
diff --git a/src/Gui/PreferencePackTemplates/CMakeLists.txt b/src/Gui/PreferencePackTemplates/CMakeLists.txt
index b5c71577cf..e9023ab237 100644
--- a/src/Gui/PreferencePackTemplates/CMakeLists.txt
+++ b/src/Gui/PreferencePackTemplates/CMakeLists.txt
@@ -1,2 +1,28 @@
-add_subdirectory(Appearance)
-add_subdirectory(Behavior)
\ No newline at end of file
+
+SET(PreferencePackTemplates_Files
+ Arch_Colors.cfg
+ Console_Colors.cfg
+ Draft_Colors.cfg
+ Editor_Colors.cfg
+ Editor_Font.cfg
+ Main_window_layout.cfg
+ Path_Colors.cfg
+ Sketcher_Colors.cfg
+ Start_Colors.cfg
+ TechDraw_Colors.cfg
+ Window_Colors.cfg
+)
+
+ADD_CUSTOM_TARGET(PreferencePackTemplates_data ALL
+ SOURCES ${PreferencePackTemplates_Files}
+)
+
+fc_copy_sources(PreferencePackTemplates_data "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_DATADIR}/Gui/PreferencePackTemplates"
+ ${PreferencePackTemplates_Files})
+
+INSTALL(
+ FILES
+ ${PreferencePackTemplates_Files}
+ DESTINATION
+ ${CMAKE_INSTALL_DATADIR}/Gui/PreferencePackTemplates
+)
diff --git a/src/Gui/PreferencePackTemplates/Appearance/Console_Colors.cfg b/src/Gui/PreferencePackTemplates/Console_Colors.cfg
similarity index 100%
rename from src/Gui/PreferencePackTemplates/Appearance/Console_Colors.cfg
rename to src/Gui/PreferencePackTemplates/Console_Colors.cfg
diff --git a/src/Gui/PreferencePackTemplates/Appearance/Draft_Colors.cfg b/src/Gui/PreferencePackTemplates/Draft_Colors.cfg
similarity index 100%
rename from src/Gui/PreferencePackTemplates/Appearance/Draft_Colors.cfg
rename to src/Gui/PreferencePackTemplates/Draft_Colors.cfg
diff --git a/src/Gui/PreferencePackTemplates/Appearance/Editor_Colors.cfg b/src/Gui/PreferencePackTemplates/Editor_Colors.cfg
similarity index 100%
rename from src/Gui/PreferencePackTemplates/Appearance/Editor_Colors.cfg
rename to src/Gui/PreferencePackTemplates/Editor_Colors.cfg
diff --git a/src/Gui/PreferencePackTemplates/Appearance/Editor_Font.cfg b/src/Gui/PreferencePackTemplates/Editor_Font.cfg
similarity index 100%
rename from src/Gui/PreferencePackTemplates/Appearance/Editor_Font.cfg
rename to src/Gui/PreferencePackTemplates/Editor_Font.cfg
diff --git a/src/Gui/PreferencePackTemplates/Behavior/Main_window_layout.cfg b/src/Gui/PreferencePackTemplates/Main_window_layout.cfg
similarity index 100%
rename from src/Gui/PreferencePackTemplates/Behavior/Main_window_layout.cfg
rename to src/Gui/PreferencePackTemplates/Main_window_layout.cfg
diff --git a/src/Gui/PreferencePackTemplates/Appearance/Path_Colors.cfg b/src/Gui/PreferencePackTemplates/Path_Colors.cfg
similarity index 100%
rename from src/Gui/PreferencePackTemplates/Appearance/Path_Colors.cfg
rename to src/Gui/PreferencePackTemplates/Path_Colors.cfg
diff --git a/src/Gui/PreferencePackTemplates/Appearance/Sketcher_Colors.cfg b/src/Gui/PreferencePackTemplates/Sketcher_Colors.cfg
similarity index 100%
rename from src/Gui/PreferencePackTemplates/Appearance/Sketcher_Colors.cfg
rename to src/Gui/PreferencePackTemplates/Sketcher_Colors.cfg
diff --git a/src/Gui/PreferencePackTemplates/Appearance/Start_Colors.cfg b/src/Gui/PreferencePackTemplates/Start_Colors.cfg
similarity index 100%
rename from src/Gui/PreferencePackTemplates/Appearance/Start_Colors.cfg
rename to src/Gui/PreferencePackTemplates/Start_Colors.cfg
diff --git a/src/Gui/PreferencePackTemplates/Appearance/TechDraw_Colors.cfg b/src/Gui/PreferencePackTemplates/TechDraw_Colors.cfg
similarity index 100%
rename from src/Gui/PreferencePackTemplates/Appearance/TechDraw_Colors.cfg
rename to src/Gui/PreferencePackTemplates/TechDraw_Colors.cfg
diff --git a/src/Gui/PreferencePackTemplates/Appearance/Window_Colors.cfg b/src/Gui/PreferencePackTemplates/Window_Colors.cfg
similarity index 100%
rename from src/Gui/PreferencePackTemplates/Appearance/Window_Colors.cfg
rename to src/Gui/PreferencePackTemplates/Window_Colors.cfg
diff --git a/src/Gui/PreferencePacks/package.xml b/src/Gui/PreferencePacks/package.xml
index 4791afca43..42ae04e8ca 100644
--- a/src/Gui/PreferencePacks/package.xml
+++ b/src/Gui/PreferencePacks/package.xml
@@ -12,7 +12,8 @@
FreeCAD Classic Colors
FreeCAD default colors for core app and included Mods.
1.0.0
- appearance
+ built-in
+ colors