plenty of fixes for TopLayouts and multi-screen(s)

pull/5/head
Michail Vourlakos 6 years ago
parent 6620cf54bd
commit 0cb2bb38af

@ -30,6 +30,7 @@
#include "indicator/factory.h"
#include "layout/activelayout.h"
#include "layout/genericlayout.h"
#include "layout/toplayout.h"
#include "shortcuts/globalshortcuts.h"
#include "package/lattepackage.h"
#include "plasma/extended/screenpool.h"
@ -473,8 +474,24 @@ QRegion Corona::availableScreenRegionWithCriteria(int id, QString forLayout) con
Latte::ActiveLayout *currentLayout = m_layoutManager->currentLayout();
views = currentLayout->latteViews();
} else {
Latte::ActiveLayout *activeLayout = m_layoutManager->activeLayout(forLayout);
views = activeLayout->latteViews();
Layout::GenericLayout *generic = m_layoutManager->activeLayout(forLayout);
if (!generic) {
//! identify best active layout to be used for metrics
//! active layouts are always considering their top layouts
//! for their metrics
TopLayout *topLayout = m_layoutManager->topLayout(forLayout);
if (topLayout) {
generic = topLayout->currentActiveLayout();
}
}
if (!generic) {
generic = m_layoutManager->currentLayout();
}
views = generic->latteViews();
}
QRegion available(screen->geometry());

@ -421,13 +421,9 @@ QList<Plasma::Types::Location> ActiveLayout::freeEdges(int screen) const
QList<Latte::View *> ActiveLayout::sortedLatteViews(QList<Latte::View *> views)
{
QList<Latte::View *> combined = latteViews();
QList<Latte::View *> vws = latteViews();
if (m_topLayout) {
combined << m_topLayout->latteViews();
}
return Layout::GenericLayout::sortedLatteViews(combined);
return Layout::GenericLayout::sortedLatteViews(vws);
}
QList<Latte::View *> ActiveLayout::viewsWithPlasmaShortcuts()

@ -22,6 +22,7 @@
// local
#include "activelayout.h"
#include "../lattecorona.h"
#include "../layoutmanager.h"
#include "../screenpool.h"
#include "../view/view.h"
@ -31,7 +32,11 @@ TopLayout::TopLayout(ActiveLayout *assigned, QObject *parent, QString layoutFile
: Layout::GenericLayout (parent, layoutFile, layoutName)
{
initToCorona(assigned->corona());
connect(m_corona->layoutManager(), &LayoutManager::currentLayoutNameChanged, this, &TopLayout::updateLastUsedActiveLayout);
addActiveLayout(assigned);
updateLastUsedActiveLayout();
}
@ -65,14 +70,32 @@ const QStringList TopLayout::appliedActivities()
return activities;
}
void TopLayout::updateLastUsedActiveLayout()
{
for (const auto &layout : m_activeLayouts) {
if (layout->isCurrent()) {
m_lastUsedActiveLayout = layout->name();
break;
}
}
}
ActiveLayout *TopLayout::currentActiveLayout() const
{
//! first the current active one
for (const auto &layout : m_activeLayouts) {
if (layout->isCurrent()) {
return layout;
}
}
//! the last used
for (const auto &layout : m_activeLayouts) {
if (layout->name() == m_lastUsedActiveLayout) {
return layout;
}
}
return nullptr;
}
@ -204,12 +227,10 @@ QList<Plasma::Types::Location> TopLayout::freeEdges(int screen) const
QList<Latte::View *> TopLayout::sortedLatteViews(QList<Latte::View *> views)
{
QList<Latte::View *> combined = latteViews();
ActiveLayout *current = currentActiveLayout();
if (current) {
return current->latteViews();
return current->sortedLatteViews();
}
return Layout::GenericLayout::sortedLatteViews();

@ -47,6 +47,7 @@ public:
~TopLayout() override;
const QStringList appliedActivities();
ActiveLayout *currentActiveLayout() const;
//! OVERRIDE GeneralLayout implementations
bool isCurrent() const override;
@ -67,10 +68,12 @@ public slots:
void addActiveLayout(ActiveLayout *layout);
void removeActiveLayout(ActiveLayout *layout);
private:
ActiveLayout *currentActiveLayout() const;
private slots:
void updateLastUsedActiveLayout();
private:
QString m_lastUsedActiveLayout;
QList<ActiveLayout *> m_activeLayouts;
};

@ -479,7 +479,7 @@ FocusScope {
function updateEnabled() {
var screenFreeEdges = latteView.managedLayout.qmlFreeEdges(latteView.positioner.currentScreenId);
actionsComboBtn.buttonEnabled = latteView.managedLayout.viewsCount<4 && screenFreeEdges.length > 0
actionsComboBtn.buttonEnabled = screenFreeEdges.length > 0;
if (actionsModel.count > 0) {
actionsModel.get(0).enabled = actionsComboBtn.buttonEnabled;
}

Loading…
Cancel
Save