mirror of
https://github.com/KDE/latte-dock.git
synced 2025-01-23 10:03:43 +03:00
support different subcontainments types
--create an abstract implementation for subcontainments such as systrays and group applet in order to use the same infrastructure for all storage operations such as Multiple Layouts loading, copying views, providing important information etc. BUG:418642
This commit is contained in:
parent
46292bf7e5
commit
ac2a4cffc6
@ -82,21 +82,21 @@ void GenericLayout::unloadContainments()
|
||||
|
||||
m_unloadedContainmentsIds.clear();
|
||||
|
||||
QList<Plasma::Containment *> systrays;
|
||||
QList<Plasma::Containment *> subcontainments;
|
||||
|
||||
//!identify systrays and unload them first
|
||||
//!identify subcontainments and unload them first
|
||||
for (const auto containment : m_containments) {
|
||||
if (Plasma::Applet *parentApplet = qobject_cast<Plasma::Applet *>(containment->parent())) {
|
||||
systrays.append(containment);
|
||||
subcontainments.append(containment);
|
||||
}
|
||||
}
|
||||
|
||||
while (!systrays.isEmpty()) {
|
||||
Plasma::Containment *systray = systrays.at(0);
|
||||
m_unloadedContainmentsIds << QString::number(systray->id());
|
||||
systrays.removeFirst();
|
||||
m_containments.removeAll(systray);
|
||||
delete systray;
|
||||
while (!subcontainments.isEmpty()) {
|
||||
Plasma::Containment *sub = subcontainments.at(0);
|
||||
m_unloadedContainmentsIds << QString::number(sub->id());
|
||||
subcontainments.removeFirst();
|
||||
m_containments.removeAll(sub);
|
||||
delete sub;
|
||||
}
|
||||
|
||||
while (!m_containments.isEmpty()) {
|
||||
@ -682,14 +682,14 @@ void GenericLayout::addContainment(Plasma::Containment *containment)
|
||||
|
||||
void GenericLayout::appletCreated(Plasma::Applet *applet)
|
||||
{
|
||||
//! In Multiple Layout the orphaned systrays must be assigned to layouts
|
||||
//! In Multiple Layout the orphaned subcontainments must be assigned to layouts
|
||||
//! when the user adds them
|
||||
KConfigGroup appletSettings = applet->containment()->config().group("Applets").group(QString::number(applet->id())).group("Configuration");
|
||||
KConfigGroup appletSettings = applet->containment()->config().group("Applets").group(QString::number(applet->id()));
|
||||
|
||||
int systrayId = appletSettings.readEntry("SystrayContainmentId", -1);
|
||||
int subId = Layouts::Storage::self()->subContainmentId(appletSettings);
|
||||
|
||||
if (systrayId != -1) {
|
||||
uint sId = (uint)systrayId;
|
||||
if (subId >= 0) {
|
||||
uint sId = (uint)subId;
|
||||
|
||||
for (const auto containment : m_corona->containments()) {
|
||||
if (containment->id() == sId) {
|
||||
@ -1035,7 +1035,7 @@ void GenericLayout::assignToLayout(Latte::View *latteView, QList<Plasma::Contain
|
||||
containment->config().writeEntry("layoutId", name());
|
||||
|
||||
if (latteView->containment() != containment) {
|
||||
//! assign signals only to systrays
|
||||
//! assign signals only to subcontainments
|
||||
//! the View::setLayout() is responsible for the View::Containment signals
|
||||
connect(containment, &QObject::destroyed, this, &GenericLayout::containmentDestroyed);
|
||||
connect(containment, &Plasma::Applet::destroyedChanged, this, &GenericLayout::destroyedChanged);
|
||||
@ -1067,10 +1067,10 @@ QList<Plasma::Containment *> GenericLayout::unassignFromLayout(Latte::View *latt
|
||||
for (const auto containment : m_containments) {
|
||||
Plasma::Applet *parentApplet = qobject_cast<Plasma::Applet *>(containment->parent());
|
||||
|
||||
//! add systrays from that latteView
|
||||
//! add subcontainments from that latteView
|
||||
if (parentApplet && parentApplet->containment() && parentApplet->containment() == latteView->containment()) {
|
||||
containments << containment;
|
||||
//! unassign signals only to systrays
|
||||
//! unassign signals only to subcontainments
|
||||
//! the View::setLayout() is responsible for the View::Containment signals
|
||||
disconnect(containment, &QObject::destroyed, this, &GenericLayout::containmentDestroyed);
|
||||
disconnect(containment, &Plasma::Applet::destroyedChanged, this, &GenericLayout::destroyedChanged);
|
||||
@ -1387,24 +1387,23 @@ void GenericLayout::syncLatteViewsToScreens(Layout::ViewsMap *occupiedMap)
|
||||
qDebug() << "end of, syncLatteViewsToScreens ....";
|
||||
}
|
||||
|
||||
QList<int> GenericLayout::containmentSystrays(Plasma::Containment *containment) const
|
||||
QList<int> GenericLayout::subContainmentsOf(Plasma::Containment *containment) const
|
||||
{
|
||||
QList<int> trays;
|
||||
QList<int> subs;
|
||||
|
||||
if (Layouts::Storage::self()->isLatteContainment(containment)) {
|
||||
auto applets = containment->config().group("Applets");
|
||||
|
||||
for (const auto &applet : applets.groupList()) {
|
||||
KConfigGroup appletSettings = applets.group(applet).group("Configuration");
|
||||
int tSysId = appletSettings.readEntry("SystrayContainmentId", -1);
|
||||
int tSubId = Layouts::Storage::self()->subContainmentId(applets.group(applet));
|
||||
|
||||
if (tSysId != -1) {
|
||||
trays << tSysId;
|
||||
if (tSubId >= 0) {
|
||||
subs << tSubId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return trays;
|
||||
return subs;
|
||||
}
|
||||
|
||||
|
||||
@ -1451,37 +1450,37 @@ QString GenericLayout::reportHtml(const ScreenPool *screenPool)
|
||||
}
|
||||
report += "</tr>";
|
||||
|
||||
//! latte containment ids, systrays
|
||||
QHash<int, QList<int>> systrays;
|
||||
QList<int> assignedSystrays;
|
||||
QList<int> orphanSystrays;
|
||||
//! latte containment ids, subcontainments
|
||||
QHash<int, QList<int>> subContainments;
|
||||
QList<int> assignedSubContainments;
|
||||
QList<int> orphanSubContainments;
|
||||
|
||||
if (isActive()) {
|
||||
//! organize systrays
|
||||
//! organize subcontainments
|
||||
for (const auto containment : m_containments) {
|
||||
QList<int> trays = containmentSystrays(containment);
|
||||
if (trays.count() > 0) {
|
||||
systrays[containment->id()] = trays;
|
||||
assignedSystrays << trays;
|
||||
QList<int> subs = subContainmentsOf(containment);
|
||||
if (subs.count() > 0) {
|
||||
subContainments[containment->id()] = subs;
|
||||
assignedSubContainments << subs;
|
||||
}
|
||||
}
|
||||
|
||||
//! orphan systrays
|
||||
//! orphan subcontainments
|
||||
for (const auto containment : m_containments) {
|
||||
if (!Layouts::Storage::self()->isLatteContainment(containment) && !assignedSystrays.contains(containment->id())) {
|
||||
orphanSystrays << containment->id();
|
||||
if (!Layouts::Storage::self()->isLatteContainment(containment) && !assignedSubContainments.contains(containment->id())) {
|
||||
orphanSubContainments << containment->id();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Layouts::Storage::self()->systraysInformation(file(), systrays, assignedSystrays, orphanSystrays);
|
||||
Layouts::Storage::self()->subContainmentsInfo(file(), subContainments, assignedSubContainments, orphanSubContainments);
|
||||
}
|
||||
|
||||
report += "<tr>";
|
||||
report += "<td><b>" + i18n("Orphan Systrays:") +"</b></td>";
|
||||
if (orphanSystrays.count() == 0) {
|
||||
report += "<td><b>" + i18n("Orphan SubContainments:") +"</b></td>";
|
||||
if (orphanSubContainments.count() == 0) {
|
||||
report += "<td><b> -- </b></td>";
|
||||
} else {
|
||||
report += "<td><b><font color='red'>" + idsLineStr(orphanSystrays) +"</font></b></td>";
|
||||
report += "<td><b><font color='red'>" + idsLineStr(orphanSubContainments) +"</font></b></td>";
|
||||
}
|
||||
report += "</tr>";
|
||||
report += "</table>";
|
||||
@ -1491,7 +1490,7 @@ QString GenericLayout::reportHtml(const ScreenPool *screenPool)
|
||||
"<td align='center'><b>" + i18n("Screen") + "</b></td>" +
|
||||
"<td align='center'><b>" + i18nc("screen edge","Edge") + "</b></td>" +
|
||||
"<td align='center'><b>" + i18nc("active dock/panel","Active") + "</b></td>" +
|
||||
"<td align='center'><b>" + i18n("Systrays") + "</b></td>";
|
||||
"<td align='center'><b>" + i18n("SubContainments") + "</b></td>";
|
||||
|
||||
report += "<tr><td colspan='5'><hr></td></tr>";
|
||||
|
||||
@ -1524,13 +1523,13 @@ QString GenericLayout::reportHtml(const ScreenPool *screenPool)
|
||||
|
||||
vData.onPrimary = onPrimary;
|
||||
vData.screenId = screenId;
|
||||
vData.systrays = containmentSystrays(containment);
|
||||
vData.subContainments = subContainmentsOf(containment);
|
||||
|
||||
viewsData << vData;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
viewsData = Layouts::Storage::self()->viewsData(file(), systrays);
|
||||
viewsData = Layouts::Storage::self()->viewsData(file(), subContainments);
|
||||
}
|
||||
|
||||
//! sort views data
|
||||
@ -1582,15 +1581,15 @@ QString GenericLayout::reportHtml(const ScreenPool *screenPool)
|
||||
}
|
||||
report += "<td align='center'>" + activeStr + "</td>" ;
|
||||
|
||||
//! systrays
|
||||
QString systraysStr = " -- ";
|
||||
if (viewsData[i].systrays.count() > 0) {
|
||||
systraysStr = idsLineStr(viewsData[i].systrays);
|
||||
//! subcontainments
|
||||
QString subContainmentsStr = " -- ";
|
||||
if (viewsData[i].subContainments.count() > 0) {
|
||||
subContainmentsStr = idsLineStr(viewsData[i].subContainments);
|
||||
}
|
||||
if(viewsData[i].active) {
|
||||
systraysStr = "<b>" + systraysStr + "</b>";
|
||||
subContainmentsStr = "<b>" + subContainmentsStr + "</b>";
|
||||
}
|
||||
report += "<td align='center'>" + systraysStr + "</td>";
|
||||
report += "<td align='center'>" + subContainmentsStr + "</td>";
|
||||
|
||||
report += "</tr>";
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ struct ViewData
|
||||
bool onPrimary; //on primary
|
||||
int screenId; //explicit screen id
|
||||
int location; //edge location
|
||||
QList<int> systrays;
|
||||
QList<int> subContainments;
|
||||
};
|
||||
|
||||
//! This is views map in the following structure:
|
||||
@ -131,7 +131,7 @@ public:
|
||||
virtual QList<Plasma::Types::Location> freeEdges(QScreen *scr) const;
|
||||
virtual QList<Plasma::Types::Location> freeEdges(int screen) const;
|
||||
|
||||
//! Bind this latteView and its relevant containments(including systrays)
|
||||
//! Bind this latteView and its relevant containments(including subcontainments)
|
||||
//! to this layout. It is used for moving a Latte::View from layout to layout)
|
||||
void assignToLayout(Latte::View *latteView, QList<Plasma::Containment *> containments);
|
||||
//! Unassign that latteView from this layout (this is used for moving a latteView
|
||||
@ -196,7 +196,7 @@ private:
|
||||
|
||||
bool mapContainsId(const ViewsMap *map, uint viewId) const;
|
||||
|
||||
QList<int> containmentSystrays(Plasma::Containment *containment) const;
|
||||
QList<int> subContainmentsOf(Plasma::Containment *containment) const;
|
||||
|
||||
QList<ViewData> sortedViewsData(const QList<ViewData> &viewsData);
|
||||
|
||||
|
@ -52,12 +52,9 @@ Storage::Storage()
|
||||
SubContaimentIdentityData data;
|
||||
|
||||
//! Systray
|
||||
data.cfgGroup = "Configuration"; data.cfgGroup = "SystrayContainmentId";
|
||||
m_subIdentities << data;
|
||||
|
||||
m_subIdentities << SubContaimentIdentityData{.cfgGroup="Configuration", .cfgProperty="SystrayContainmentId"};
|
||||
//! Group applet
|
||||
data.cfgGroup = "Configuration"; data.cfgGroup = "ContainmentId";
|
||||
m_subIdentities << data;
|
||||
m_subIdentities << SubContaimentIdentityData{.cfgGroup="Configuration", .cfgProperty="ContainmentId"};
|
||||
}
|
||||
|
||||
Storage::~Storage()
|
||||
@ -118,20 +115,23 @@ bool Storage::isSubContainment(const Layout::GenericLayout *layout, const Plasma
|
||||
|
||||
bool Storage::isSubContainment(const KConfigGroup &appletGroup) const
|
||||
{
|
||||
return subContainmentId(appletGroup) > 0;
|
||||
return isValid(subContainmentId(appletGroup));
|
||||
}
|
||||
|
||||
bool Storage::isValid(const int &id)
|
||||
{
|
||||
return id >= IDBASE;
|
||||
}
|
||||
|
||||
int Storage::subContainmentId(const KConfigGroup &appletGroup) const
|
||||
{
|
||||
int subId{-1};
|
||||
|
||||
//! cycle through subcontainments identities
|
||||
for (auto subidentity : m_subIdentities) {
|
||||
KConfigGroup appletConfigGroup = appletGroup;
|
||||
|
||||
if (!subidentity.cfgGroup.isEmpty()) {
|
||||
//! if identity provides specific configuration group
|
||||
if (appletGroup.hasGroup(subidentity.cfgGroup)) {
|
||||
if (appletConfigGroup.hasGroup(subidentity.cfgGroup)) {
|
||||
appletConfigGroup = appletGroup.group(subidentity.cfgGroup);
|
||||
}
|
||||
}
|
||||
@ -139,13 +139,41 @@ int Storage::subContainmentId(const KConfigGroup &appletGroup) const
|
||||
if (!subidentity.cfgProperty.isEmpty()) {
|
||||
//! if identity provides specific property for configuration group
|
||||
if (appletConfigGroup.hasKey(subidentity.cfgProperty)) {
|
||||
subId = appletConfigGroup.readEntry(subidentity.cfgProperty, -1);
|
||||
return subId;
|
||||
return appletConfigGroup.readEntry(subidentity.cfgProperty, IDNULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return subId;
|
||||
return IDNULL;
|
||||
}
|
||||
|
||||
int Storage::subIdentityIndex(const KConfigGroup &appletGroup) const
|
||||
{
|
||||
if (!isSubContainment(appletGroup)) {
|
||||
return IDNULL;
|
||||
}
|
||||
|
||||
//! cycle through subcontainments identities
|
||||
for (int i=0; i<m_subIdentities.count(); ++i) {
|
||||
KConfigGroup appletConfigGroup = appletGroup;
|
||||
|
||||
if (!m_subIdentities[i].cfgGroup.isEmpty()) {
|
||||
//! if identity provides specific configuration group
|
||||
if (appletConfigGroup.hasGroup(m_subIdentities[i].cfgGroup)) {
|
||||
appletConfigGroup = appletGroup.group(m_subIdentities[i].cfgGroup);
|
||||
}
|
||||
}
|
||||
|
||||
if (!m_subIdentities[i].cfgProperty.isEmpty()) {
|
||||
//! if identity provides specific property for configuration group
|
||||
if (appletConfigGroup.hasKey(m_subIdentities[i].cfgProperty)) {
|
||||
int subId = appletConfigGroup.readEntry(m_subIdentities[i].cfgProperty, IDNULL);
|
||||
return isValid(subId) ? i : IDNULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return IDNULL;
|
||||
}
|
||||
|
||||
Plasma::Containment *Storage::subContainmentOf(const Layout::GenericLayout *layout, const Plasma::Applet *applet)
|
||||
@ -281,11 +309,11 @@ QString Storage::newUniqueIdsLayoutFromFile(const Layout::GenericLayout *layout,
|
||||
|
||||
QStringList toInvestigateContainmentIds;
|
||||
QStringList toInvestigateAppletIds;
|
||||
QStringList toInvestigateSystrayContIds;
|
||||
QStringList toInvestigateSubContIds;
|
||||
|
||||
//! first is the systray containment id
|
||||
QHash<QString, QString> systrayParentContainmentIds;
|
||||
QHash<QString, QString> systrayAppletIds;
|
||||
//! first is the subcontainment id
|
||||
QHash<QString, QString> subParentContainmentIds;
|
||||
QHash<QString, QString> subAppletIds;
|
||||
|
||||
//qDebug() << "Ids:" << allIds;
|
||||
|
||||
@ -304,19 +332,17 @@ QString Storage::newUniqueIdsLayoutFromFile(const Layout::GenericLayout *layout,
|
||||
auto appletsEntries = investigate_conts.group(cId).group("Applets");
|
||||
toInvestigateAppletIds << appletsEntries.groupList();
|
||||
|
||||
//! investigate for systrays
|
||||
//! investigate for subcontainments
|
||||
for (const auto &appletId : appletsEntries.groupList()) {
|
||||
KConfigGroup appletSettings = appletsEntries.group(appletId).group("Configuration");
|
||||
int subId = subContainmentId(appletsEntries.group(appletId));
|
||||
|
||||
int tSysId = appletSettings.readEntry("SystrayContainmentId", -1);
|
||||
|
||||
//! It is a systray !!!
|
||||
if (tSysId != -1) {
|
||||
QString tSysIdStr = QString::number(tSysId);
|
||||
toInvestigateSystrayContIds << tSysIdStr;
|
||||
systrayParentContainmentIds[tSysIdStr] = cId;
|
||||
systrayAppletIds[tSysIdStr] = appletId;
|
||||
qDebug() << "systray was found in the containment...";
|
||||
//! It is a subcontainment !!!
|
||||
if (isValid(subId)) {
|
||||
QString tSubIdStr = QString::number(subId);
|
||||
toInvestigateSubContIds << tSubIdStr;
|
||||
subParentContainmentIds[tSubIdStr] = cId;
|
||||
subAppletIds[tSubIdStr] = appletId;
|
||||
qDebug() << "subcontainment was found in the containment...";
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -397,11 +423,23 @@ QString Storage::newUniqueIdsLayoutFromFile(const Layout::GenericLayout *layout,
|
||||
}
|
||||
}
|
||||
|
||||
//! must update also the systray id in its applet
|
||||
for (const auto &systrayId : toInvestigateSystrayContIds) {
|
||||
KConfigGroup systrayParentContainment = investigate_conts.group(systrayParentContainmentIds[systrayId]);
|
||||
systrayParentContainment.group("Applets").group(systrayAppletIds[systrayId]).group("Configuration").writeEntry("SystrayContainmentId", assigned[systrayId]);
|
||||
systrayParentContainment.sync();
|
||||
//! must update also the sub id in its applet
|
||||
for (const auto &subId : toInvestigateSubContIds) {
|
||||
KConfigGroup subParentContainment = investigate_conts.group(subParentContainmentIds[subId]);
|
||||
KConfigGroup subAppletConfig = subParentContainment.group("Applets").group(subAppletIds[subId]);
|
||||
|
||||
int entityIndex = subIdentityIndex(subAppletConfig);
|
||||
|
||||
if (entityIndex >= 0) {
|
||||
if (!m_subIdentities[entityIndex].cfgGroup.isEmpty()) {
|
||||
subAppletConfig = subAppletConfig.group(m_subIdentities[entityIndex].cfgGroup);
|
||||
}
|
||||
|
||||
if (!m_subIdentities[entityIndex].cfgProperty.isEmpty()) {
|
||||
subAppletConfig.writeEntry(m_subIdentities[entityIndex].cfgProperty, assigned[subId]);
|
||||
subParentContainment.sync();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
investigate_conts.sync();
|
||||
@ -467,11 +505,9 @@ QList<Plasma::Containment *> Storage::importLayoutFile(const Layout::GenericLayo
|
||||
KSharedConfigPtr filePtr = KSharedConfig::openConfig(file);
|
||||
auto newContainments = layout->corona()->importLayout(KConfigGroup(filePtr, ""));
|
||||
|
||||
///Find latte and systray containments
|
||||
qDebug() << " imported containments ::: " << newContainments.length();
|
||||
|
||||
QList<Plasma::Containment *> importedDocks;
|
||||
//QList<Plasma::Containment *> systrays;
|
||||
|
||||
for (const auto containment : newContainments) {
|
||||
if (isLatteContainment(containment)) {
|
||||
@ -507,41 +543,40 @@ ViewDelayedCreationData Storage::copyView(const Layout::GenericLayout *layout, P
|
||||
|
||||
containment->config().copyTo(&copied_c1);
|
||||
|
||||
//!investigate if there multiple systray(s) in the containment to copy also
|
||||
//!investigate if there are subcontainments in the containment to copy also
|
||||
|
||||
//! systrayId, systrayAppletId
|
||||
QHash<uint, QString> systraysInfo;
|
||||
//! subId, subAppletId
|
||||
QHash<uint, QString> subInfo;
|
||||
auto applets = containment->config().group("Applets");
|
||||
|
||||
for (const auto &applet : applets.groupList()) {
|
||||
KConfigGroup appletSettings = applets.group(applet).group("Configuration");
|
||||
int tSubId = subContainmentId(applets.group(applet));
|
||||
|
||||
int tSysId = appletSettings.readEntry("SystrayContainmentId", -1);
|
||||
|
||||
if (tSysId != -1) {
|
||||
systraysInfo[tSysId] = applet;
|
||||
qDebug() << "systray with id "<< tSysId << " was found in the containment... ::: " << tSysId;
|
||||
//! It is a subcontainment !!!
|
||||
if (isValid(tSubId)) {
|
||||
subInfo[tSubId] = applet;
|
||||
qDebug() << "subcontainment with id "<< tSubId << " was found in the containment... ::: " << containment->id();
|
||||
}
|
||||
}
|
||||
|
||||
if (systraysInfo.count() > 0) {
|
||||
for(const auto systrayId : systraysInfo.keys()) {
|
||||
Plasma::Containment *systray{nullptr};
|
||||
if (subInfo.count() > 0) {
|
||||
for(const auto subId : subInfo.keys()) {
|
||||
Plasma::Containment *subcontainment{nullptr};
|
||||
|
||||
for (const auto containment : layout->corona()->containments()) {
|
||||
if (containment->id() == systrayId) {
|
||||
systray = containment;
|
||||
if (containment->id() == subId) {
|
||||
subcontainment = containment;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (systray) {
|
||||
KConfigGroup copied_systray = KConfigGroup(&copied_conts, QString::number(systray->id()));
|
||||
systray->config().copyTo(&copied_systray);
|
||||
if (subcontainment) {
|
||||
KConfigGroup copied_sub = KConfigGroup(&copied_conts, QString::number(subcontainment->id()));
|
||||
subcontainment->config().copyTo(&copied_sub);
|
||||
}
|
||||
}
|
||||
}
|
||||
//! end of systray specific code
|
||||
//! end of subcontainments specific code
|
||||
|
||||
//! update ids to unique ones
|
||||
QString temp2File = newUniqueIdsLayoutFromFile(layout, temp1File);
|
||||
@ -568,19 +603,19 @@ ViewDelayedCreationData Storage::copyView(const Layout::GenericLayout *layout, P
|
||||
|
||||
bool setOnExplicitScreen = false;
|
||||
|
||||
int dockScrId = -1;
|
||||
int copyScrId = -1;
|
||||
int dockScrId = IDNULL;
|
||||
int copyScrId = IDNULL;
|
||||
|
||||
if (dock) {
|
||||
dockScrId = dock->positioner()->currentScreenId();
|
||||
qDebug() << "COPY DOCK SCREEN ::: " << dockScrId;
|
||||
|
||||
if (dockScrId != -1 && screens.count() > 1) {
|
||||
if (isValid(dockScrId) && screens.count() > 1) {
|
||||
for (const auto scr : screens) {
|
||||
copyScrId = layout->corona()->screenPool()->id(scr->name());
|
||||
|
||||
//the screen must exist and not be the same with the original dock
|
||||
if (copyScrId > -1 && copyScrId != dockScrId) {
|
||||
if (isValid(copyScrId) && copyScrId != dockScrId) {
|
||||
QList<Plasma::Types::Location> fEdges = layout->freeEdges(copyScrId);
|
||||
|
||||
if (fEdges.contains((Plasma::Types::Location)containment->location())) {
|
||||
@ -616,7 +651,7 @@ ViewDelayedCreationData Storage::copyView(const Layout::GenericLayout *layout, P
|
||||
|
||||
ViewDelayedCreationData result;
|
||||
|
||||
if (setOnExplicitScreen && copyScrId > -1) {
|
||||
if (setOnExplicitScreen && isValid(copyScrId)) {
|
||||
qDebug() << "Copy Dock in explicit screen ::: " << copyScrId;
|
||||
result.containment = newContainment;
|
||||
result.forceOnPrimary = false;
|
||||
@ -763,41 +798,41 @@ bool Storage::isBroken(const Layout::GenericLayout *layout, QStringList &errors)
|
||||
}
|
||||
|
||||
//! Data For Reports
|
||||
void Storage::systraysInformation(const QString &file, QHash<int, QList<int>> &systrays, QList<int> &assignedSystrays, QList<int> &orphanSystrays)
|
||||
void Storage::subContainmentsInfo(const QString &file, QHash<int, QList<int>> &subContainments, QList<int> &assignedSubContainments, QList<int> &orphanSubContainments)
|
||||
{
|
||||
systrays.clear();
|
||||
assignedSystrays.clear();
|
||||
orphanSystrays.clear();
|
||||
subContainments.clear();
|
||||
assignedSubContainments.clear();
|
||||
orphanSubContainments.clear();
|
||||
|
||||
KSharedConfigPtr lFile = KSharedConfig::openConfig(file);
|
||||
KConfigGroup containmentGroups = KConfigGroup(lFile, "Containments");
|
||||
|
||||
//! assigned systrays
|
||||
//! assigned subcontainments
|
||||
for (const auto &cId : containmentGroups.groupList()) {
|
||||
if (Layouts::Storage::self()->isLatteContainment(containmentGroups.group(cId))) {
|
||||
auto applets = containmentGroups.group(cId).group("Applets");
|
||||
|
||||
for (const auto &applet : applets.groupList()) {
|
||||
KConfigGroup appletSettings = applets.group(applet).group("Configuration");
|
||||
int tSysId = appletSettings.readEntry("SystrayContainmentId", -1);
|
||||
int tSubId = appletSettings.readEntry("SystrayContainmentId", IDNULL);
|
||||
|
||||
if (tSysId != -1) {
|
||||
assignedSystrays << tSysId;
|
||||
systrays[cId.toInt()].append(tSysId);
|
||||
if (isValid(tSubId)) {
|
||||
assignedSubContainments << tSubId;
|
||||
subContainments[cId.toInt()].append(tSubId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//! orphan systrays
|
||||
//! orphan subcontainments
|
||||
for (const auto &cId : containmentGroups.groupList()) {
|
||||
if (!Layouts::Storage::self()->isLatteContainment(containmentGroups.group(cId)) && !assignedSystrays.contains(cId.toInt())) {
|
||||
orphanSystrays << cId.toInt();
|
||||
if (!Layouts::Storage::self()->isLatteContainment(containmentGroups.group(cId)) && !assignedSubContainments.contains(cId.toInt())) {
|
||||
orphanSubContainments << cId.toInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QList<Layout::ViewData> Storage::viewsData(const QString &file, const QHash<int, QList<int>> &systrays)
|
||||
QList<Layout::ViewData> Storage::viewsData(const QString &file, const QHash<int, QList<int>> &subContainments)
|
||||
{
|
||||
QList<Layout::ViewData> viewsData;
|
||||
|
||||
@ -819,13 +854,13 @@ QList<Layout::ViewData> Storage::viewsData(const QString &file, const QHash<int,
|
||||
vData.onPrimary = containmentGroups.group(cId).readEntry("onPrimary", true);
|
||||
|
||||
//! Screen
|
||||
vData.screenId = containmentGroups.group(cId).readEntry("lastScreen", -1);
|
||||
vData.screenId = containmentGroups.group(cId).readEntry("lastScreen", IDNULL);
|
||||
|
||||
//! location
|
||||
vData.location = containmentGroups.group(cId).readEntry("location", (int)Plasma::Types::BottomEdge);
|
||||
|
||||
//! systrays
|
||||
vData.systrays = systrays[id];
|
||||
//! subcontainments
|
||||
vData.subContainments = subContainments[id];
|
||||
|
||||
viewsData << vData;
|
||||
}
|
||||
@ -844,9 +879,9 @@ QList<int> Storage::viewsScreens(const QString &file)
|
||||
|
||||
for (const auto &cId : containmentGroups.groupList()) {
|
||||
if (Layouts::Storage::self()->isLatteContainment(containmentGroups.group(cId))) {
|
||||
int screenId = containmentGroups.group(cId).readEntry("lastScreen", -1);
|
||||
int screenId = containmentGroups.group(cId).readEntry("lastScreen", IDNULL);
|
||||
|
||||
if (screenId != -1 && !screens.contains(screenId)) {
|
||||
if (isValid(screenId) && !screens.contains(screenId)) {
|
||||
screens << screenId;
|
||||
}
|
||||
}
|
||||
|
@ -40,6 +40,9 @@ struct ViewData;
|
||||
namespace Latte {
|
||||
namespace Layouts {
|
||||
|
||||
#define IDBASE 0
|
||||
#define IDNULL -1
|
||||
|
||||
struct SubContaimentIdentityData
|
||||
{
|
||||
QString cfgGroup;
|
||||
@ -67,6 +70,8 @@ public:
|
||||
bool isBroken(const Layout::GenericLayout *layout, QStringList &errors) const;
|
||||
bool isSubContainment(const Layout::GenericLayout *layout, const Plasma::Applet *applet) const;
|
||||
|
||||
int subContainmentId(const KConfigGroup &appletGroup) const;
|
||||
|
||||
Plasma::Containment *subContainmentOf(const Layout::GenericLayout *layout, const Plasma::Applet *applet);
|
||||
|
||||
void lock(const Layout::GenericLayout *layout); //! make it only read-only
|
||||
@ -80,20 +85,21 @@ public:
|
||||
/// STATIC
|
||||
//! Check if an applet config group is valid or belongs to removed applet
|
||||
static bool appletGroupIsValid(const KConfigGroup &appletGroup);
|
||||
static bool isValid(const int &id);
|
||||
|
||||
//! Functions used from Layout Reports
|
||||
//! [containment id, list<systrays ids>], list<systrays ids>, list[systrays ids]
|
||||
void systraysInformation(const QString &file, QHash<int, QList<int>> &systrays, QList<int> &assignedSystrays, QList<int> &orphanSystrays);
|
||||
//! [containment id, list<subcontainment ids>], list<subcontainment ids>, list[subcontainment ids]
|
||||
void subContainmentsInfo(const QString &file, QHash<int, QList<int>> &subContainments, QList<int> &assignedSubContainments, QList<int> &orphanSubContainments);
|
||||
//! list<screens ids>
|
||||
QList<int> viewsScreens(const QString &file);
|
||||
//! list<ViewData>
|
||||
QList<Layout::ViewData> viewsData(const QString &file, const QHash<int, QList<int>> &systrays);
|
||||
QList<Layout::ViewData> viewsData(const QString &file, const QHash<int, QList<int>> &subContainments);
|
||||
|
||||
private:
|
||||
Storage();
|
||||
|
||||
bool isSubContainment(const KConfigGroup &appletGroup) const;
|
||||
int subContainmentId(const KConfigGroup &appletGroup) const;
|
||||
int subIdentityIndex(const KConfigGroup &appletGroup) const;
|
||||
|
||||
//! STORAGE !////
|
||||
QString availableId(QStringList all, QStringList assigned, int base);
|
||||
|
Loading…
x
Reference in New Issue
Block a user