| 619 | } |
| 620 | |
| 621 | void DlgSettingsGeneral::recreatePreferencePackMenu() |
| 622 | { |
| 623 | ui->PreferencePacks->setRowCount(0); // Begin by clearing whatever is there |
| 624 | ui->PreferencePacks->horizontalHeader()->setDefaultAlignment(Qt::AlignLeft); |
| 625 | ui->PreferencePacks->setColumnCount(3); |
| 626 | ui->PreferencePacks->setSelectionMode(QAbstractItemView::SelectionMode::NoSelection); |
| 627 | ui->PreferencePacks->horizontalHeader()->setStretchLastSection(false); |
| 628 | ui->PreferencePacks->horizontalHeader()->setSectionResizeMode(0, QHeaderView::ResizeMode::Stretch); |
| 629 | ui->PreferencePacks->horizontalHeader()->setSectionResizeMode(1, QHeaderView::ResizeMode::Stretch); |
| 630 | ui->PreferencePacks->horizontalHeader()->setSectionResizeMode( |
| 631 | 2, |
| 632 | QHeaderView::ResizeMode::ResizeToContents |
| 633 | ); |
| 634 | QStringList columnHeaders; |
| 635 | columnHeaders << tr("Preference Pack Name") << tr("Tags") |
| 636 | << QString(); // for the "Load" buttons |
| 637 | ui->PreferencePacks->setHorizontalHeaderLabels(columnHeaders); |
| 638 | |
| 639 | // Populate the Preference Packs list |
| 640 | Application::Instance->prefPackManager()->rescan(); |
| 641 | auto packs = Application::Instance->prefPackManager()->preferencePacks(); |
| 642 | |
| 643 | // Remove the Themes. |
| 644 | std::vector<std::string> packsToRemove; |
| 645 | for (const auto& pack : packs) { |
| 646 | if (pack.second.metadata().type() == "Theme") { |
| 647 | packsToRemove.push_back(pack.first); // Store the keys to remove later |
| 648 | } |
| 649 | } |
| 650 | for (const auto& key : packsToRemove) { |
| 651 | packs.erase(key); // Remove the elements from the map |
| 652 | } |
| 653 | |
| 654 | ui->PreferencePacks->setRowCount(packs.size()); |
| 655 | |
| 656 | int row = 0; |
| 657 | QIcon icon = style()->standardIcon(QStyle::SP_DialogApplyButton); |
| 658 | for (const auto& pack : packs) { |
| 659 | auto name = new QTableWidgetItem(QString::fromStdString(pack.first)); |
| 660 | name->setToolTip(QString::fromStdString(pack.second.metadata().description())); |
| 661 | ui->PreferencePacks->setItem(row, 0, name); |
| 662 | auto tags = pack.second.metadata().tag(); |
| 663 | QString tagString; |
| 664 | for (const auto& tag : tags) { |
| 665 | if (tagString.isEmpty()) { |
| 666 | tagString.append(QString::fromStdString(tag)); |
| 667 | } |
| 668 | else { |
| 669 | tagString.append(QStringLiteral(", ") + QString::fromStdString(tag)); |
| 670 | } |
| 671 | } |
| 672 | auto kind = new QTableWidgetItem(tagString); |
| 673 | ui->PreferencePacks->setItem(row, 1, kind); |
| 674 | auto button = new QPushButton(icon, tr("Apply")); |
| 675 | button->setEnabled(true); |
| 676 | Gui::Document* doc = Gui::Application::Instance->activeDocument(); |
| 677 | if (doc) { |
| 678 | Gui::View3DInventor* view = qobject_cast<Gui::View3DInventor*>(doc->getActiveView()); |
nothing calls this directly
no test coverage detected