Commit c76f1443 authored by Marco Martin's avatar Marco Martin
Browse files

List "unknown" screens as well

There is also the possibility that the screen mapping by screenpool gets
lost or partially lost ( like removal of plasmashellrc but not
appletsrc)
In this case if it was a multimonitor setup there will be containments
assigned to a screen number which doesn't have a known connector.
List them as well, marked as "Unknown 1" "Unknown 2" etc.
This is an edge case of the edge case but it well possible it happens so
it should be managed as well

![Screenshot_20220125_143614](/uploads/6fc1d1cde79543dca634acc5fd350ba4/Screenshot_20220125_143614.png)
parent 1b1e962c
Pipeline #136114 passed with stage
in 5 minutes and 45 seconds
......@@ -86,8 +86,13 @@ void ScreenPoolModel::load()
qDeleteAll(m_containments);
m_containments.clear();
QSet<int> unknownScreenIds;
for (auto *cont : m_corona->containments()) {
unknownScreenIds.insert(cont->lastScreen());
}
for (auto &knownId : m_corona->screenPool()->knownIds()) {
Data d;
unknownScreenIds.remove(knownId);
d.id = knownId;
d.name = m_corona->screenPool()->connector(knownId);
d.primary = knownId == 0;
......@@ -112,6 +117,23 @@ void ScreenPoolModel::load()
delete conts;
}
}
QList sortedIds = unknownScreenIds.values();
std::sort(sortedIds.begin(), sortedIds.end());
int i = 1;
for (int id : sortedIds) {
Data d;
d.id = id;
d.name = i18n("Unknown %1", i);
d.primary = id == 0;
d.enabled = false;
auto *conts = new ShellContainmentModel(m_corona, id, this);
conts->load();
m_containments.push_back(conts);
m_screens.push_back(d);
i++;
}
endResetModel();
}
......
......@@ -240,18 +240,11 @@ void ShellCorona::init()
setEditMode(false);
});
auto updateManageContainmentsVisiblility = [this, manageContainmentsAction]() {
const auto screenIds = m_screenPool->knownIds();
if (screenIds.count() < 2) {
manageContainmentsAction->setVisible(false);
return;
}
int populatedScreens = 0;
for (auto id : screenIds) {
if (containmentForScreen(id, m_activityController->currentActivity(), QString())) {
populatedScreens++;
}
QSet<int> allScreenIds;
for (auto *cont : containments()) {
allScreenIds.insert(cont->lastScreen());
}
manageContainmentsAction->setVisible(populatedScreens > 1);
manageContainmentsAction->setVisible(allScreenIds.count() > 1);
};
connect(this, &ShellCorona::containmentAdded, this, updateManageContainmentsVisiblility);
connect(this, &ShellCorona::screenRemoved, this, updateManageContainmentsVisiblility);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment