|
23 | 23 | #include "mainwindow.h" |
24 | 24 | #include "widget_resize_button.h" |
25 | 25 | #include "style.h" |
| 26 | +#include "item_tree.h" |
26 | 27 |
|
27 | 28 | #include "../vkconfig_core/configurator.h" |
28 | 29 | #include "../vkconfig_core/doc.h" |
|
34 | 35 | #include <QDesktopServices> |
35 | 36 | #include <QMessageBox> |
36 | 37 |
|
37 | | -static std::string BuildPropertiesLog(const Layer &layer) { |
38 | | - std::string description; |
39 | | - if (!layer.description.empty()) { |
40 | | - description += layer.description + "\n"; |
41 | | - } |
42 | | - description += "API Version: " + layer.api_version.str() + " - Implementation Version: " + layer.implementation_version + "\n"; |
43 | | - if (layer.platforms != 0) { |
44 | | - description += "Supported Platforms: "; |
| 38 | +static std::string BuildPlatformsLog(int platforms) { |
| 39 | + std::string log; |
45 | 40 |
|
46 | | - const std::vector<std::string> &platforms = GetPlatformTokens(layer.platforms); |
47 | | - for (std::size_t i = 0, n = platforms.size(); i < n; ++i) { |
48 | | - description += platforms[i]; |
| 41 | + if (platforms != 0) { |
| 42 | + log += "Platforms: "; |
| 43 | + |
| 44 | + const std::vector<std::string> &list = GetPlatformTokens(platforms); |
| 45 | + for (std::size_t i = 0, n = list.size(); i < n; ++i) { |
| 46 | + log += list[i]; |
49 | 47 | if (i < n - 1) { |
50 | | - description += ", "; |
| 48 | + log += ", "; |
51 | 49 | } |
52 | 50 | } |
53 | 51 |
|
54 | | - description += "\n"; |
| 52 | + log += "\n"; |
| 53 | + } |
| 54 | + |
| 55 | + return log; |
| 56 | +} |
| 57 | + |
| 58 | +static std::string BuildPropertiesLog(const Layer &layer) { |
| 59 | + std::string description; |
| 60 | + if (!layer.description.empty()) { |
| 61 | + description += layer.description + "\n"; |
55 | 62 | } |
| 63 | + description += "API Version: " + layer.api_version.str() + " - Implementation Version: " + layer.implementation_version + "\n"; |
| 64 | + description += ::BuildPlatformsLog(layer.platforms); |
56 | 65 |
|
57 | 66 | description += "\n"; |
58 | 67 | description += layer.manifest_path.AbsolutePath() + "\n"; |
@@ -457,10 +466,10 @@ bool TabConfigurations::EventFilter(QObject *target, QEvent *event) { |
457 | 466 |
|
458 | 467 | if (configurator.GetExecutableScope() == EXECUTABLE_NONE || !ui->configurations_list->isEnabled()) { |
459 | 468 | return true; |
460 | | - } else if (target == ui->configurations_list) { |
| 469 | + } else if (target == this->ui->configurations_list) { |
461 | 470 | QContextMenuEvent *right_click = dynamic_cast<QContextMenuEvent *>(event); |
462 | 471 | if (right_click) { |
463 | | - ListItem *item = static_cast<ListItem *>(ui->configurations_list->itemAt(right_click->pos())); |
| 472 | + ListItem *item = static_cast<ListItem *>(this->ui->configurations_list->itemAt(right_click->pos())); |
464 | 473 |
|
465 | 474 | std::string name; |
466 | 475 |
|
@@ -539,18 +548,18 @@ bool TabConfigurations::EventFilter(QObject *target, QEvent *event) { |
539 | 548 | this->OnContextMenuExportSettingsClicked(item); |
540 | 549 | } |
541 | 550 | } |
542 | | - } else if (target == ui->configurations_layers_list) { |
| 551 | + } else if (target == this->ui->configurations_layers_list) { |
543 | 552 | QContextMenuEvent *right_click = dynamic_cast<QContextMenuEvent *>(event); |
544 | 553 | if (right_click) { |
545 | | - ListItem *item = static_cast<ListItem *>(ui->configurations_layers_list->itemAt(right_click->pos())); |
| 554 | + ListItem *item = static_cast<ListItem *>(this->ui->configurations_layers_list->itemAt(right_click->pos())); |
546 | 555 |
|
547 | 556 | if (item != nullptr) { |
548 | 557 | const Configuration *configuration = configurator.GetActiveConfiguration(); |
549 | 558 | const Parameter *parameter = configuration->Find(item->key); |
550 | 559 |
|
551 | 560 | const Layer *layer = configurator.layers.FindFromManifest(parameter->manifest); |
552 | 561 |
|
553 | | - QMenu menu(ui->configurations_layers_list); |
| 562 | + QMenu menu(this->ui->configurations_layers_list); |
554 | 563 |
|
555 | 564 | QAction *action_description = new QAction("Open the Layer Description...", nullptr); |
556 | 565 | action_description->setEnabled(layer != nullptr); |
@@ -597,14 +606,89 @@ bool TabConfigurations::EventFilter(QObject *target, QEvent *event) { |
597 | 606 | } else if (action == export_html_action) { |
598 | 607 | const std::string path = format("%s/%s.html", AbsolutePath(Path::APPDATA).c_str(), layer->key.c_str()); |
599 | 608 | ExportHtmlDoc(*layer, path); |
600 | | - QDesktopServices::openUrl(QUrl(("file:///" + path).c_str())); |
| 609 | + std::string url = "file:///" + path; |
| 610 | + QDesktopServices::openUrl(QUrl(url.c_str())); |
601 | 611 | } else if (action == export_markdown_action) { |
602 | 612 | const std::string path = format("%s/%s.md", AbsolutePath(Path::APPDATA).c_str(), layer->key.c_str()); |
603 | 613 | ExportMarkdownDoc(*layer, path); |
604 | 614 | QDesktopServices::openUrl(QUrl(("file:///" + path).c_str())); |
605 | 615 | } |
606 | 616 | } |
607 | 617 | } |
| 618 | + } else if (target == this->ui->configurations_settings) { |
| 619 | + QContextMenuEvent *right_click = dynamic_cast<QContextMenuEvent *>(event); |
| 620 | + if (right_click) { |
| 621 | + TreeItem *item = static_cast<TreeItem *>(this->ui->configurations_settings->itemAt(right_click->pos())); |
| 622 | + |
| 623 | + const Configuration *configuration = configurator.GetActiveConfiguration(); |
| 624 | + const Parameter *parameter = configuration->GetActiveParameter(); |
| 625 | + |
| 626 | + const Layer *layer = configurator.layers.FindFromManifest(parameter->manifest); |
| 627 | + |
| 628 | + if (item != nullptr) { |
| 629 | + QMenu menu(this->ui->configurations_settings); |
| 630 | + |
| 631 | + QAction *action_description = new QAction("Open the brief Setting Description...", nullptr); |
| 632 | + action_description->setEnabled(layer != nullptr); |
| 633 | + menu.addAction(action_description); |
| 634 | + |
| 635 | + QAction *export_html_action = new QAction("Open the detailed Setting HTML Documentation...", nullptr); |
| 636 | + export_html_action->setEnabled(layer != nullptr); |
| 637 | + menu.addAction(export_html_action); |
| 638 | + |
| 639 | + QPoint point(right_click->globalX(), right_click->globalY()); |
| 640 | + QAction *action = menu.exec(point); |
| 641 | + |
| 642 | + if (action == action_description) { |
| 643 | + const SettingMeta *setting = ::FindSetting(layer->settings, item->key.c_str()); |
| 644 | + assert(layer != nullptr); |
| 645 | + |
| 646 | + std::string title = format("%s (%s)", setting->label.c_str(), setting->key.c_str()); |
| 647 | + if (setting->status != STATUS_STABLE) { |
| 648 | + title += format(" (%s)", ::GetToken(setting->status)); |
| 649 | + } |
| 650 | + |
| 651 | + std::string text = setting->description; |
| 652 | + text += "\n\n"; |
| 653 | + if (!setting->detailed.empty()) { |
| 654 | + text += setting->detailed; |
| 655 | + text += "\n\n"; |
| 656 | + } |
| 657 | + |
| 658 | + text += "VK_EXT_layer_settings name:\n"; |
| 659 | + text += format(" %s\n", setting->key.c_str()); |
| 660 | + text += "vk_layer_settings.txt variable:\n"; |
| 661 | + text += format(" %s\n", (GetLayerSettingPrefix(layer->key) + setting->key).c_str()); |
| 662 | + text += "Environment variables:\n"; |
| 663 | + std::vector<std::string> envs = BuildEnvVariablesList(layer->key.c_str(), setting->key.c_str()); |
| 664 | + if (!setting->env.empty()) { |
| 665 | + envs.push_back(setting->env); |
| 666 | + } |
| 667 | + for (std::size_t i = 0, n = envs.size(); i < n; ++i) { |
| 668 | + text += format(" %s\n", envs[i].c_str()); |
| 669 | + } |
| 670 | + text += "\n"; |
| 671 | + |
| 672 | + text += format("Type: %s\n", ::GetToken(setting->type)); |
| 673 | + text += format("Default Value: %s\n", setting->Export(EXPORT_MODE_DOC).c_str()); |
| 674 | + text += ::BuildPlatformsLog(setting->platform_flags); |
| 675 | + |
| 676 | + QMessageBox alert; |
| 677 | + alert.setWindowTitle(title.c_str()); |
| 678 | + alert.setText(text.c_str()); |
| 679 | + alert.setStandardButtons(QMessageBox::Ok); |
| 680 | + alert.setDefaultButton(QMessageBox::Ok); |
| 681 | + alert.setIcon(QMessageBox::Information); |
| 682 | + alert.exec(); |
| 683 | + } else if (action == export_html_action) { |
| 684 | + const std::string path = format("%s/%s.html", AbsolutePath(Path::APPDATA).c_str(), layer->key.c_str()); |
| 685 | + ExportHtmlDoc(*layer, path); |
| 686 | + |
| 687 | + std::string url = ConvertStandardSeparators(format("file:///%s#%s-detailed", path.c_str(), item->key.c_str())); |
| 688 | + QDesktopServices::openUrl(QUrl(url.c_str())); |
| 689 | + } |
| 690 | + } |
| 691 | + } |
608 | 692 | } |
609 | 693 |
|
610 | 694 | // Pass it on |
|
0 commit comments