1
0
mirror of https://github.com/KDE/latte-dock.git synced 2025-01-08 13:18:09 +03:00

Views Report Information for inactive layouts

This commit is contained in:
Michail Vourlakos 2019-07-14 23:44:16 +03:00
parent 8f50131088
commit 10939d410c
6 changed files with 111 additions and 17 deletions

View File

@ -1287,7 +1287,6 @@ QList<int> GenericLayout::containmentSystrays(Plasma::Containment *containment)
QList<int> trays;
if (m_storage->isLatteContainment(containment)) {
int systrayId = -1;
auto applets = containment->config().group("Applets");
for (const auto &applet : applets.groupList()) {
@ -1304,7 +1303,7 @@ QList<int> GenericLayout::containmentSystrays(Plasma::Containment *containment)
}
QString GenericLayout::reportHtml()
QString GenericLayout::reportHtml(const ScreenPool *screenPool)
{
//qDebug() << "DBUS CALL ::: " << identifier << " - " << value;
auto locationText = [this](const int &location) {
@ -1339,8 +1338,12 @@ QString GenericLayout::reportHtml()
report += "<table cellspacing='8'>";
report += "<tr>";
report += "<td><b>" + i18nc("active docks panels","Active:") +"</b></td>";
report += "<td><b>" + (activeViews == 0 ? "--" : QString::number(activeViews)) +"</b></td>";
report += "<td><b>" + i18nc("active docks panels","Active Views:") +"</b></td>";
if (activeViews == 0) {
report += "<td><b> -- </b></td>";
} else {
report += "<td><b><font color='blue'>" + QString::number(activeViews) +"</font></b></td>";
}
report += "</tr>";
//! latte containment ids, systrays
@ -1364,11 +1367,17 @@ QString GenericLayout::reportHtml()
orphanSystrays << containment->id();
}
}
} else {
m_storage->systraysInformation(systrays, assignedSystrays, orphanSystrays);
}
report += "<tr>";
report += "<td><b>" + i18n("Orphan Systrays:") +"</b></td>";
report += "<td><b>" + (orphanSystrays.count() == 0 ? "--" : idsLineStr(orphanSystrays)) +"</b></td>";
if (orphanSystrays.count() == 0) {
report += "<td><b> -- </b></td>";
} else {
report += "<td><b><font color='red'>" + idsLineStr(orphanSystrays) +"</font></b></td>";
}
report += "</tr>";
report += "</table>";
@ -1415,6 +1424,8 @@ QString GenericLayout::reportHtml()
viewsData << vData;
}
}
} else {
viewsData = m_storage->viewsData(systrays);
}
//! sort views data
@ -1437,7 +1448,7 @@ QString GenericLayout::reportHtml()
screenStr = "<font color='green'>" + screenStr + "</font>";
}
if (!viewsData[i].onPrimary) {
screenStr = m_corona->screenPool()->connector(viewsData[i].screenId);
screenStr = screenPool->connector(viewsData[i].screenId);
}
if(viewsData[i].active) {
screenStr = "<b>" + screenStr + "</b>";
@ -1452,14 +1463,17 @@ QString GenericLayout::reportHtml()
report += "<td align='center'>" + edgeStr + "</td>" ;
//! active
QString activeStr = "";
QString activeStr = " -- ";
if(viewsData[i].active) {
activeStr = "<b>" + i18n("Yes") + "</b>";
}
report += "<td align='center'>" + activeStr + "</td>" ;
//! systrays
QString systraysStr = idsLineStr(viewsData[i].systrays);
QString systraysStr = " -- ";
if (viewsData[i].systrays.count() > 0) {
systraysStr = idsLineStr(viewsData[i].systrays);
}
if(viewsData[i].active) {
systraysStr = "<b>" + systraysStr + "</b>";
}

View File

@ -41,6 +41,7 @@ class Types;
namespace Latte {
class Corona;
class ScreenPool;
class View;
}
@ -140,7 +141,7 @@ public:
//! that latteView
QList<Plasma::Containment *> unassignFromLayout(Latte::View *latteView);
QString reportHtml();
QString reportHtml(const ScreenPool *screenPool);
QList<int> viewsScreens();
public slots:

View File

@ -345,6 +345,77 @@ QList<Plasma::Containment *> Storage::importLayoutFile(QString file)
return importedDocks;
}
void Storage::systraysInformation(QHash<int, QList<int>> &systrays, QList<int> &assignedSystrays, QList<int> &orphanSystrays)
{
systrays.clear();
assignedSystrays.clear();
orphanSystrays.clear();
KSharedConfigPtr lFile = KSharedConfig::openConfig(m_layout->file());
KConfigGroup containmentGroups = KConfigGroup(lFile, "Containments");
//! assigned systrays
for (const auto &cId : containmentGroups.groupList()) {
if (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);
if (tSysId != -1) {
assignedSystrays << tSysId;
systrays[cId.toInt()].append(tSysId);
}
}
}
}
//! orphan systrays
for (const auto &cId : containmentGroups.groupList()) {
if (!isLatteContainment(containmentGroups.group(cId)) && !assignedSystrays.contains(cId.toInt())) {
orphanSystrays << cId.toInt();
}
}
}
QList<ViewData> Storage::viewsData(const QHash<int, QList<int>> &systrays)
{
QList<ViewData> viewsData;
KSharedConfigPtr lFile = KSharedConfig::openConfig(m_layout->file());
KConfigGroup containmentGroups = KConfigGroup(lFile, "Containments");
for (const auto &cId : containmentGroups.groupList()) {
if (isLatteContainment(containmentGroups.group(cId))) {
ViewData vData;
int id = cId.toInt();
//! id
vData.id = id;
//! active
vData.active = false;
//! onPrimary
vData.onPrimary = containmentGroups.group(cId).readEntry("onPrimary", true);
//! Screen
vData.screenId = containmentGroups.group(cId).readEntry("lastScreen", -1);
//! location
vData.location = containmentGroups.group(cId).readEntry("location", (int)Plasma::Types::BottomEdge);
//! systrays
vData.systrays = systrays[id];
viewsData << vData;
}
}
return viewsData;
}
QList<int> Storage::viewsScreens()
{
QList<int> screens;
@ -657,7 +728,7 @@ bool Storage::layoutIsBroken(QStringList &errors) const
for (int i = 0; i < ids.count(); ++i) {
for (int j = i + 1; j < ids.count(); ++j) {
if (ids[i] == ids[j]) {
QString errorStr = i18n("Applets with same id ::: ") + ids[i];
QString errorStr = i18n("Differrent applets with same id ::: ") + ids[i];
qDebug() << "Error: " << errorStr;
errors << errorStr;
}

View File

@ -52,12 +52,18 @@ public:
void copyView(Plasma::Containment *containment);
void syncToLayoutFile(bool removeLayoutId);
QList<int> viewsScreens();
/// STATIC
//! Check if an applet config group is valid or belongs to removed applet
static bool appletGroupIsValid(KConfigGroup appletGroup);
//! Functions used from Layout Reports
//! [containment id, list<systrays ids>], list<systrays ids>, list[systrays ids]
void systraysInformation(QHash<int, QList<int>> &systrays, QList<int> &assignedSystrays, QList<int> &orphanSystrays);
//! list<screens ids>
QList<int> viewsScreens();
//! list<ViewData>
QList<ViewData> viewsData(const QHash<int, QList<int>> &systrays);
private:
//! STORAGE !////
QString availableId(QStringList all, QStringList assigned, int base);

View File

@ -125,7 +125,7 @@ QString ScreenPool::reportHtml(const QList<int> &assignedScreens) const
report += "<tr>";
//! ScreenId
QString idStr = QString::number(scrId);
QString idStr = "[" + QString::number(scrId) + "]";
if (primary || secondary) {
idStr = "<b>" + idStr +"</b>";
}
@ -144,6 +144,8 @@ QString ScreenPool::reportHtml(const QList<int> &assignedScreens) const
typeStr = "<b><font color='green'>[" + i18nc("primary screen","Primary") + "]</font></b>";
} else if (secondary) {
typeStr = "<b>[" + i18nc("secondary screen","Secondary") + "]</b>";
} else {
typeStr = "<i>" + i18nc("inactive screen","inactive") + "</i>";
}
report += "<td align='center'>" + typeStr +"</td>";
@ -152,6 +154,8 @@ QString ScreenPool::reportHtml(const QList<int> &assignedScreens) const
QString notAssignedStr = "";
if (!hasViews) {
notAssignedStr = "<font color='red'><i>[" + i18nc("it has not latte docks/panels", "none") + "]</i></font>";
} else {
notAssignedStr = "";
}
report += "<td align='center'>" + notAssignedStr +"</td>";

View File

@ -1566,9 +1566,8 @@ void SettingsDialog::showLayoutInformation()
Layout::GenericLayout *generic = genericActive ? genericActive : m_layouts[id];
auto msg = new QMessageBox(this);
//msg->setIcon(QMessageBox::Information);
msg->setWindowTitle(name + " " + i18n("Layout Information"));
msg->setText(generic->reportHtml());
msg->setWindowTitle(name);
msg->setText(generic->reportHtml(m_corona->screenPool()));
msg->open();
}
@ -1594,7 +1593,6 @@ void SettingsDialog::showScreensInformation()
}
auto msg = new QMessageBox(this);
//msg->setIcon(QMessageBox::Information);
msg->setWindowTitle(i18n("Screens Information"));
msg->setText(m_corona->screenPool()->reportHtml(assignedScreens));