2929
3030#include " moc_PluginManagerWindow.cpp"
3131
32+ extern bool safe_mode;
33+
3234namespace OBS {
3335
3436PluginManagerWindow::PluginManagerWindow (std::vector<ModuleInfo> const &modules, QWidget *parent)
@@ -73,29 +75,37 @@ PluginManagerWindow::PluginManagerWindow(std::vector<ModuleInfo> const &modules,
7375 return aName < bName;
7476 });
7577
78+ std::sort (modules_.begin (), modules_.end (), [](const ModuleInfo &a, const ModuleInfo &b) {
79+ bool missingA = !obs_get_module (a.module_name .c_str ()) &&
80+ !obs_get_disabled_module (a.module_name .c_str ());
81+ bool missingB = !obs_get_module (b.module_name .c_str ()) &&
82+ !obs_get_disabled_module (b.module_name .c_str ());
83+
84+ return !missingA && missingB;
85+ });
86+
7687 int row = 0 ;
88+ int missingIndex = -1 ;
7789 for (auto &metadata : modules_) {
7890 std::string id = metadata.module_name ;
7991 // Check if the module is missing:
8092 bool missing = !obs_get_module (id.c_str ()) && !obs_get_disabled_module (id.c_str ());
8193
8294 QString name = !metadata.display_name .empty () ? metadata.display_name .c_str ()
8395 : metadata.module_name .c_str ();
84- if (missing) {
85- name += " " + QTStr (" PluginManager.MissingPlugin" );
96+
97+ if (missing && missingIndex == -1 ) {
98+ missingIndex = row;
8699 }
87100
88101 auto item = new QCheckBox (name);
89102 item->setSizePolicy (QSizePolicy::Minimum, QSizePolicy::Fixed);
90103 item->setChecked (metadata.enabled );
91104
92- if (!metadata.enabledAtLaunch ) {
105+ if (!metadata.enabledAtLaunch || missing ) {
93106 item->setProperty (" class" , " text-muted" );
94107 }
95108
96- if (missing) {
97- item->setEnabled (false );
98- }
99109 ui->modulesList ->layout ()->addWidget (item);
100110
101111 connect (item, &QCheckBox::toggled, this , [this , row](bool checked) {
@@ -106,6 +116,24 @@ PluginManagerWindow::PluginManagerWindow(std::vector<ModuleInfo> const &modules,
106116 row++;
107117 }
108118
119+ QVBoxLayout *layout = qobject_cast<QVBoxLayout *>(ui->modulesList ->layout ());
120+ if (safe_mode) {
121+ QLabel *safeModeLabel = new QLabel (ui->modulesList );
122+ safeModeLabel->setText (QTStr (" PluginManager.SafeMode" ));
123+ safeModeLabel->setProperty (" class" , " text-muted text-italic" );
124+ safeModeLabel->setIndent (0 );
125+
126+ layout->insertWidget (0 , safeModeLabel);
127+ } else if (missingIndex != -1 ) {
128+ QLabel *missingLabel = new QLabel (ui->modulesList );
129+ missingLabel->setText (QTStr (" PluginManager.MissingPlugin" ));
130+ missingLabel->setProperty (" class" , " text-warning text-bold" );
131+ missingLabel->setIndent (0 );
132+
133+ layout->insertWidget (missingIndex, new QLabel (" " , ui->modulesList ));
134+ layout->insertWidget (missingIndex + 1 , missingLabel);
135+ }
136+
109137 ui->modulesList ->adjustSize ();
110138 ui->modulesListContents ->adjustSize ();
111139
0 commit comments