Comments (4)
I did a little digging and found this in src/Gui/DlgPreferencesImp.cpp:
/**
* Create a new preference page called \a pageName on the group tab \a tabWidget.
*/
void DlgPreferencesImp::createPageInGroup(QTabWidget *tabWidget, const std::string &pageName)
{
PreferencePage* page = WidgetFactory().createPreferencePage(pageName.c_str());
if (page) {
tabWidget->addTab(page, page->windowTitle());
page->loadSettings();
page->setProperty("GroupName", tabWidget->property("GroupName"));
page->setProperty("PageName", QVariant(QString::fromStdString(pageName)));
}
else {
Base::Console().Warning("%s is not a preference page\n", pageName.c_str());
}
}
It appears that the only object that can be used as a preference page is a page, ie QWidget.
It also appears that this routine will add the page to tab but will not add a second page to another tab.
It would be really nice if a workbench could have multiple preference pages and if this routine would add each of them as tabs. Or if the routine could accept a QTabWidget in place of its own Tab Widget and let the user then connect his pages to the tabs on his Tab Widget.
In the mean time, the work around is to add a preference page that has tabs on it and implement them on that page. Such an implementation will appear as the window attached above.
from freecad-addons.
This the code that calls createPageInGroup:
/**
* If the dialog is currently showing and the static variable _pages changed, this function
* will rescan that list of pages and add any that are new to the current dialog. It will not
* remove any pages that are no longer in the list, and will not change the user's current
* active page.
*/
void DlgPreferencesImp::reloadPages()
{
// Make sure that pages are ready to create
GetWidgetFactorySupplier();
for (const auto &group : _pages) {
QString groupName = QString::fromStdString(group.first);
// First, does this group already exist?
QTabWidget* tabWidget = nullptr;
for (int tabNumber = 0; tabNumber < ui->tabWidgetStack->count(); ++tabNumber) {
auto thisTabWidget = qobject_cast<QTabWidget*>(ui->tabWidgetStack->widget(tabNumber));
if (thisTabWidget->property("GroupName").toString() == groupName) {
tabWidget = thisTabWidget;
break;
}
}
// This is a new tab that wasn't there when we started this instance of the dialog:
if (!tabWidget) {
tabWidget = createTabForGroup(group.first);
}
// Move on to the pages in the group to see if we need to add any
for (const auto& page : group.second) {
// Does this page already exist?
QString pageName = QString::fromStdString(page);
bool pageExists = false;
for (int pageNumber = 0; pageNumber < tabWidget->count(); ++pageNumber) {
PreferencePage* prefPage = qobject_cast<PreferencePage*>(tabWidget->widget(pageNumber));
if (prefPage && prefPage->property("PageName").toString() == pageName) {
pageExists = true;
break;
}
}
// This is a new page that wasn't there when we started this instance of the dialog:
if (!pageExists) {
createPageInGroup(tabWidget, page);
}
}
}
}
It appears that this code should add another page to the group's (CfdOF) tabWidget:
// This is a new page that wasn't there when we started this instance of the dialog:
if (!pageExists) {
createPageInGroup(tabWidget, page);
But it checks if the page already exists based not on the filename of the page (ie preferencePage1.ui, preferencePage2.ui) but on the preferencePage.PageName property.
// Does this page already exist?
QString pageName = QString::fromStdString(page);
bool pageExists = false;
for (int pageNumber = 0; pageNumber < tabWidget->count(); ++pageNumber) {
PreferencePage* prefPage = qobject_cast<PreferencePage*>(tabWidget->widget(pageNumber));
if (prefPage && prefPage->property("PageName").toString() == pageName) {
pageExists = true;
break;
}
}
If one uses the same page name for the pages being added, they will not be added.
I presume that pages are added by calling FreeCADGui.addPreferencePage("/path/to/myUiFile.ui","CfdOF") with each page.
from freecad-addons.
@linuxguy123 this is really a question for the FreeCAD Forum (https://forum.freecadweb.org) -- this issue tracker is used to manage bug reports in the software.
from freecad-addons.
I got it working. I'll update how tomorrow.
from freecad-addons.
Related Issues (20)
- Make Rembench obsolete since it causes crash HOT 6
- Drawing dimesion workbench in latest version HOT 1
- [New Addon/Workbench] Taack PLM HOT 7
- NikraDAP HOT 3
- Deprecate ModernUI HOT 4
- Deprecate freecad-slic3r-tools HOT 1
- [Feature] Expose UI Color settings to advanced users via an Addon HOT 18
- [New Addon/Workbench] freecad-pyoptools HOT 1
- [New Addon] Better Tool Library HOT 1
- [FEATURE] List Addons by Popularity HOT 3
- [Bug] Many gitmodules are without .git extension, leading to them not showing up properly HOT 6
- [New Addon/Workbench] OSAFE HOT 1
- [Bug] Addon Manager fails to install addon HOT 6
- [Bug] `pip install --user` no longer supported in debian trixie HOT 3
- Prune unmaintained addons
- [New Addon/Workbench] OpenDark preference pack HOT 9
- [FEATURE] Create "Accesories" category
- [Bug] Add protobuf in ALLOWED_PYTHON_PACKAGES.txt
- A2plus and network paths
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from freecad-addons.