mirror of
https://github.com/KDE/latte-dock.git
synced 2025-01-03 09:17:50 +03:00
REFACTOR:Drop Shared Layouts infrastructure
--Move in a simpler layouts approach. --Single Layout mode loads ONLY ONE Layout for ALL Activities --Multiple Layouts mode loads any combination of Layouts based on the following settings: -- OnAllActivities -- ForFreeActivities -- SpecificActivities
This commit is contained in:
parent
63bfc444c4
commit
caf9bf7b78
@ -43,7 +43,6 @@ Layout::Layout(Layout &&o)
|
|||||||
isTemplate(o.isTemplate),
|
isTemplate(o.isTemplate),
|
||||||
hasDisabledBorders(o.hasDisabledBorders),
|
hasDisabledBorders(o.hasDisabledBorders),
|
||||||
activities(o.activities),
|
activities(o.activities),
|
||||||
shares(o.shares),
|
|
||||||
backgroundStyle(o.backgroundStyle)
|
backgroundStyle(o.backgroundStyle)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -60,7 +59,6 @@ Layout::Layout(const Layout &o)
|
|||||||
isTemplate(o.isTemplate),
|
isTemplate(o.isTemplate),
|
||||||
hasDisabledBorders(o.hasDisabledBorders),
|
hasDisabledBorders(o.hasDisabledBorders),
|
||||||
activities(o.activities),
|
activities(o.activities),
|
||||||
shares(o.shares),
|
|
||||||
backgroundStyle(o.backgroundStyle)
|
backgroundStyle(o.backgroundStyle)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -79,7 +77,6 @@ Layout &Layout::operator=(Layout &&rhs)
|
|||||||
isTemplate = rhs.isTemplate;
|
isTemplate = rhs.isTemplate;
|
||||||
hasDisabledBorders = rhs.hasDisabledBorders;
|
hasDisabledBorders = rhs.hasDisabledBorders;
|
||||||
activities = rhs.activities;
|
activities = rhs.activities;
|
||||||
shares = rhs.shares;
|
|
||||||
backgroundStyle = rhs.backgroundStyle;
|
backgroundStyle = rhs.backgroundStyle;
|
||||||
|
|
||||||
return (*this);
|
return (*this);
|
||||||
@ -99,7 +96,6 @@ Layout &Layout::operator=(const Layout &rhs)
|
|||||||
isTemplate = rhs.isTemplate;
|
isTemplate = rhs.isTemplate;
|
||||||
hasDisabledBorders = rhs.hasDisabledBorders;
|
hasDisabledBorders = rhs.hasDisabledBorders;
|
||||||
activities = rhs.activities;
|
activities = rhs.activities;
|
||||||
shares = rhs.shares;
|
|
||||||
backgroundStyle = rhs.backgroundStyle;
|
backgroundStyle = rhs.backgroundStyle;
|
||||||
|
|
||||||
return (*this);
|
return (*this);
|
||||||
@ -119,7 +115,6 @@ bool Layout::operator==(const Layout &rhs) const
|
|||||||
&& (isTemplate == rhs.isTemplate)
|
&& (isTemplate == rhs.isTemplate)
|
||||||
&& (hasDisabledBorders == rhs.hasDisabledBorders)
|
&& (hasDisabledBorders == rhs.hasDisabledBorders)
|
||||||
&& (activities == rhs.activities)
|
&& (activities == rhs.activities)
|
||||||
&& (shares == rhs.shares)
|
|
||||||
&& (backgroundStyle == rhs.backgroundStyle);
|
&& (backgroundStyle == rhs.backgroundStyle);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -153,11 +148,6 @@ bool Layout::isNull() const
|
|||||||
return (id.isEmpty() && name.isEmpty());
|
return (id.isEmpty() && name.isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Layout::isShared() const
|
|
||||||
{
|
|
||||||
return !shares.isEmpty();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Layout::isSystemTemplate() const
|
bool Layout::isSystemTemplate() const
|
||||||
{
|
{
|
||||||
return isTemplate && !id.startsWith(QDir::tempPath()) && !id.startsWith(QDir::homePath());
|
return isTemplate && !id.startsWith(QDir::tempPath()) && !id.startsWith(QDir::homePath());
|
||||||
|
@ -54,12 +54,10 @@ public:
|
|||||||
bool isTemplate{false};
|
bool isTemplate{false};
|
||||||
bool hasDisabledBorders{false};
|
bool hasDisabledBorders{false};
|
||||||
QStringList activities;
|
QStringList activities;
|
||||||
QStringList shares;
|
|
||||||
|
|
||||||
Latte::Layout::BackgroundStyle backgroundStyle{Latte::Layout::ColorBackgroundStyle};
|
Latte::Layout::BackgroundStyle backgroundStyle{Latte::Layout::ColorBackgroundStyle};
|
||||||
|
|
||||||
//! Functionality
|
//! Functionality
|
||||||
bool isShared() const;
|
|
||||||
bool isOnAllActivities() const;
|
bool isOnAllActivities() const;
|
||||||
bool isForFreeActivities() const;
|
bool isForFreeActivities() const;
|
||||||
bool isTemporary() const;
|
bool isTemporary() const;
|
||||||
|
@ -72,59 +72,6 @@ LayoutsTable LayoutsTable::subtracted(const LayoutsTable &rhs) const
|
|||||||
return subtract;
|
return subtract;
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList LayoutsTable::allSharesIds() const
|
|
||||||
{
|
|
||||||
QStringList sharesIds;
|
|
||||||
|
|
||||||
for(int i=0; i<m_list.count(); ++i) {
|
|
||||||
if (m_list[i].isShared()) {
|
|
||||||
for(int j=0; j<m_list[i].shares.count(); ++j) {
|
|
||||||
sharesIds << m_list[i].shares[j];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return sharesIds;
|
|
||||||
}
|
|
||||||
|
|
||||||
QStringList LayoutsTable::allSharesNames() const
|
|
||||||
{
|
|
||||||
QStringList sharesNames;
|
|
||||||
|
|
||||||
for(int i=0; i<m_list.count(); ++i) {
|
|
||||||
if (m_list[i].isShared()) {
|
|
||||||
for(int j=0; j<m_list[i].shares.count(); ++j) {
|
|
||||||
QString shareId = m_list[i].shares[j];
|
|
||||||
int sid = indexOf(shareId);
|
|
||||||
sharesNames << m_list[sid].name;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return sharesNames;
|
|
||||||
}
|
|
||||||
|
|
||||||
Latte::Layouts::SharesMap LayoutsTable::sharesMap() const
|
|
||||||
{
|
|
||||||
Latte::Layouts::SharesMap map;
|
|
||||||
|
|
||||||
for(int i=0; i<m_list.count(); ++i) {
|
|
||||||
if (m_list[i].isShared()) {
|
|
||||||
QStringList sharesNames;
|
|
||||||
|
|
||||||
for(int j=0; j<m_list[i].shares.count(); ++j) {
|
|
||||||
QString shareId = m_list[i].shares[j];
|
|
||||||
int sid = indexOf(shareId);
|
|
||||||
sharesNames << m_list[sid].name;
|
|
||||||
}
|
|
||||||
|
|
||||||
map[m_list[i].name] = sharesNames;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return map;
|
|
||||||
}
|
|
||||||
|
|
||||||
void LayoutsTable::setLayoutForFreeActivities(const QString &id)
|
void LayoutsTable::setLayoutForFreeActivities(const QString &id)
|
||||||
{
|
{
|
||||||
int row = indexOf(id);
|
int row = indexOf(id);
|
||||||
|
@ -45,10 +45,6 @@ public:
|
|||||||
LayoutsTable &operator=(LayoutsTable &&rhs);
|
LayoutsTable &operator=(LayoutsTable &&rhs);
|
||||||
LayoutsTable subtracted(const LayoutsTable &rhs) const;
|
LayoutsTable subtracted(const LayoutsTable &rhs) const;
|
||||||
|
|
||||||
QStringList allSharesIds() const;
|
|
||||||
QStringList allSharesNames() const;
|
|
||||||
Latte::Layouts::SharesMap sharesMap() const;
|
|
||||||
|
|
||||||
void setLayoutForFreeActivities(const QString &id);
|
void setLayoutForFreeActivities(const QString &id);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -31,7 +31,6 @@
|
|||||||
#include "layout/abstractlayout.h"
|
#include "layout/abstractlayout.h"
|
||||||
#include "layout/centrallayout.h"
|
#include "layout/centrallayout.h"
|
||||||
#include "layout/genericlayout.h"
|
#include "layout/genericlayout.h"
|
||||||
#include "layout/sharedlayout.h"
|
|
||||||
#include "layouts/importer.h"
|
#include "layouts/importer.h"
|
||||||
#include "layouts/manager.h"
|
#include "layouts/manager.h"
|
||||||
#include "layouts/synchronizer.h"
|
#include "layouts/synchronizer.h"
|
||||||
@ -517,16 +516,6 @@ CentralLayout *Corona::centralLayout(QString name) const
|
|||||||
} else {
|
} else {
|
||||||
CentralLayout *tempCentral = m_layoutsManager->synchronizer()->centralLayout(name);
|
CentralLayout *tempCentral = m_layoutsManager->synchronizer()->centralLayout(name);
|
||||||
|
|
||||||
if (!tempCentral) {
|
|
||||||
//! Identify best active layout to be used for metrics calculations.
|
|
||||||
//! Active layouts are always take into account their shared layouts for their metrics
|
|
||||||
SharedLayout *sharedLayout = m_layoutsManager->synchronizer()->sharedLayout(name);
|
|
||||||
|
|
||||||
if (sharedLayout) {
|
|
||||||
tempCentral = sharedLayout->currentCentralLayout();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tempCentral) {
|
if (tempCentral) {
|
||||||
result = tempCentral;
|
result = tempCentral;
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,5 @@ set(lattedock-app_SRCS
|
|||||||
${CMAKE_CURRENT_SOURCE_DIR}/abstractlayout.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/abstractlayout.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/centrallayout.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/centrallayout.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/genericlayout.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/genericlayout.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/sharedlayout.cpp
|
|
||||||
PARENT_SCOPE
|
PARENT_SCOPE
|
||||||
)
|
)
|
||||||
|
@ -22,7 +22,6 @@
|
|||||||
|
|
||||||
// local
|
// local
|
||||||
#include <coretypes.h>
|
#include <coretypes.h>
|
||||||
#include "sharedlayout.h"
|
|
||||||
#include "../apptypes.h"
|
#include "../apptypes.h"
|
||||||
#include "../lattecorona.h"
|
#include "../lattecorona.h"
|
||||||
#include "../screenpool.h"
|
#include "../screenpool.h"
|
||||||
@ -52,21 +51,10 @@ CentralLayout::~CentralLayout()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void CentralLayout::unloadContainments()
|
|
||||||
{
|
|
||||||
Layout::GenericLayout::unloadContainments();
|
|
||||||
|
|
||||||
if (m_sharedLayout) {
|
|
||||||
disconnectSharedConnections();
|
|
||||||
m_sharedLayout->removeCentralLayout(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CentralLayout::init()
|
void CentralLayout::init()
|
||||||
{
|
{
|
||||||
connect(this, &CentralLayout::activitiesChanged, this, &CentralLayout::saveConfig);
|
connect(this, &CentralLayout::activitiesChanged, this, &CentralLayout::saveConfig);
|
||||||
connect(this, &CentralLayout::disableBordersForMaximizedWindowsChanged, this, &CentralLayout::saveConfig);
|
connect(this, &CentralLayout::disableBordersForMaximizedWindowsChanged, this, &CentralLayout::saveConfig);
|
||||||
connect(this, &CentralLayout::sharedLayoutNameChanged, this, &CentralLayout::saveConfig);
|
|
||||||
connect(this, &CentralLayout::showInMenuChanged, this, &CentralLayout::saveConfig);
|
connect(this, &CentralLayout::showInMenuChanged, this, &CentralLayout::saveConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,13 +79,6 @@ void CentralLayout::initToCorona(Latte::Corona *corona)
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Request the SharedLayout in case there is one and Latte is functioning in MultipleLayouts mode
|
|
||||||
if (m_corona->layoutsManager()->memoryUsage() == MemoryUsage::MultipleLayouts && !m_sharedLayoutName.isEmpty()) {
|
|
||||||
if (m_corona->layoutsManager()->synchronizer()->registerAtSharedLayout(this, m_sharedLayoutName)) {
|
|
||||||
setSharedLayout(m_corona->layoutsManager()->synchronizer()->sharedLayout(m_sharedLayoutName));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -182,85 +163,6 @@ void CentralLayout::setActivities(QStringList activities)
|
|||||||
emit activitiesChanged();
|
emit activitiesChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CentralLayout::sharedLayoutName() const
|
|
||||||
{
|
|
||||||
return m_sharedLayoutName;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CentralLayout::setSharedLayoutName(QString name)
|
|
||||||
{
|
|
||||||
if (m_sharedLayoutName == name || (!Layouts::Importer::layoutExists(name) && !name.isEmpty())) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_sharedLayoutName = name;
|
|
||||||
emit sharedLayoutNameChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
SharedLayout *CentralLayout::sharedLayout() const
|
|
||||||
{
|
|
||||||
return m_sharedLayout;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CentralLayout::setSharedLayout(SharedLayout *layout)
|
|
||||||
{
|
|
||||||
if (m_sharedLayout == layout) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
disconnectSharedConnections();
|
|
||||||
|
|
||||||
m_sharedLayout = layout;
|
|
||||||
|
|
||||||
if (layout) {
|
|
||||||
setSharedLayoutName(m_sharedLayout->name());
|
|
||||||
|
|
||||||
//! attach new signals
|
|
||||||
m_sharedConnections << connect(m_sharedLayout, &Layout::GenericLayout::viewsCountChanged, this, &Layout::GenericLayout::viewsCountChanged);
|
|
||||||
m_sharedConnections << connect(m_sharedLayout, &Layout::AbstractLayout::nameChanged, this, [this]() {
|
|
||||||
setSharedLayoutName(m_sharedLayout->name());
|
|
||||||
});
|
|
||||||
m_sharedConnections << connect(m_sharedLayout, &Layout::GenericLayout::viewEdgeChanged, this, [this]() {
|
|
||||||
syncLatteViewsToScreens();
|
|
||||||
});
|
|
||||||
|
|
||||||
m_sharedConnections << connect(m_sharedLayout, &GenericLayout::lastConfigViewForChanged, this, &GenericLayout::lastConfigViewForChanged);
|
|
||||||
} else {
|
|
||||||
setSharedLayoutName(QString());
|
|
||||||
}
|
|
||||||
|
|
||||||
syncLatteViewsToScreens();
|
|
||||||
emit viewsCountChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
void CentralLayout::disconnectSharedConnections()
|
|
||||||
{
|
|
||||||
//! drop old signals
|
|
||||||
for (const auto &sc : m_sharedConnections) {
|
|
||||||
QObject::disconnect(sc);
|
|
||||||
}
|
|
||||||
|
|
||||||
m_sharedConnections.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
void CentralLayout::setLastConfigViewFor(Latte::View *view)
|
|
||||||
{
|
|
||||||
if (m_sharedLayout) {
|
|
||||||
m_sharedLayout->setLastConfigViewFor(view);
|
|
||||||
} else {
|
|
||||||
GenericLayout::setLastConfigViewFor(view);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Latte::View *CentralLayout::lastConfigViewFor()
|
|
||||||
{
|
|
||||||
if (m_sharedLayout) {
|
|
||||||
return m_sharedLayout->lastConfigViewFor();
|
|
||||||
} else {
|
|
||||||
return GenericLayout::lastConfigViewFor();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Data::Layout CentralLayout::data() const
|
Data::Layout CentralLayout::data() const
|
||||||
{
|
{
|
||||||
Data::Layout cdata;
|
Data::Layout cdata;
|
||||||
@ -286,12 +188,6 @@ void CentralLayout::loadConfig()
|
|||||||
m_showInMenu = m_layoutGroup.readEntry("showInMenu", false);
|
m_showInMenu = m_layoutGroup.readEntry("showInMenu", false);
|
||||||
m_activities = m_layoutGroup.readEntry("activities", QStringList());
|
m_activities = m_layoutGroup.readEntry("activities", QStringList());
|
||||||
|
|
||||||
QString sharedLayoutName = m_layoutGroup.readEntry("sharedLayout", QString());
|
|
||||||
|
|
||||||
if (Layouts::Importer::layoutExists(sharedLayoutName)) {
|
|
||||||
m_sharedLayoutName = sharedLayoutName;
|
|
||||||
}
|
|
||||||
|
|
||||||
emit activitiesChanged();
|
emit activitiesChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -300,24 +196,11 @@ void CentralLayout::saveConfig()
|
|||||||
qDebug() << "CENTRAL layout is saving... for layout:" << m_layoutName;
|
qDebug() << "CENTRAL layout is saving... for layout:" << m_layoutName;
|
||||||
m_layoutGroup.writeEntry("showInMenu", m_showInMenu);
|
m_layoutGroup.writeEntry("showInMenu", m_showInMenu);
|
||||||
m_layoutGroup.writeEntry("disableBordersForMaximizedWindows", m_disableBordersForMaximizedWindows);
|
m_layoutGroup.writeEntry("disableBordersForMaximizedWindows", m_disableBordersForMaximizedWindows);
|
||||||
m_layoutGroup.writeEntry("sharedLayout", m_sharedLayoutName);
|
|
||||||
m_layoutGroup.writeEntry("activities", m_activities);
|
m_layoutGroup.writeEntry("activities", m_activities);
|
||||||
}
|
}
|
||||||
|
|
||||||
//! OVERRIDES
|
//! OVERRIDES
|
||||||
|
|
||||||
void CentralLayout::addView(Plasma::Containment *containment, bool forceOnPrimary, int explicitScreen, Layout::ViewsMap *occupied)
|
|
||||||
{
|
|
||||||
if (m_sharedLayout) {
|
|
||||||
//! consider already occupied edges from SharedLayout
|
|
||||||
Layout::ViewsMap ocMap = m_sharedLayout->validViewsMap();
|
|
||||||
qDebug() << " HIGH PRIORITY ALREADY OCCUPIED EDGES :: " << ocMap;
|
|
||||||
Layout::GenericLayout::addView(containment, forceOnPrimary, explicitScreen, &ocMap);
|
|
||||||
} else {
|
|
||||||
Layout::GenericLayout::addView(containment, forceOnPrimary, explicitScreen, occupied);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const QStringList CentralLayout::appliedActivities()
|
const QStringList CentralLayout::appliedActivities()
|
||||||
{
|
{
|
||||||
if (!m_corona) {
|
if (!m_corona) {
|
||||||
@ -331,149 +214,6 @@ const QStringList CentralLayout::appliedActivities()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<Latte::View *> CentralLayout::latteViews()
|
|
||||||
{
|
|
||||||
if (m_sharedLayout) {
|
|
||||||
QList<Latte::View *> views = Layout::GenericLayout::latteViews();
|
|
||||||
views << m_sharedLayout->latteViews();
|
|
||||||
|
|
||||||
return views;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Layout::GenericLayout::latteViews();
|
|
||||||
}
|
|
||||||
|
|
||||||
int CentralLayout::viewsCount(int screen) const
|
|
||||||
{
|
|
||||||
if (!m_corona) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int views = Layout::GenericLayout::viewsCount(screen);
|
|
||||||
|
|
||||||
if (m_sharedLayout) {
|
|
||||||
QScreen *scr = m_corona->screenPool()->screenForId(screen);
|
|
||||||
|
|
||||||
for (const auto view : m_sharedLayout->latteViews()) {
|
|
||||||
if (view && view->screen() == scr && !view->containment()->destroyed()) {
|
|
||||||
++views;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return views;
|
|
||||||
}
|
|
||||||
|
|
||||||
int CentralLayout::viewsCount(QScreen *screen) const
|
|
||||||
{
|
|
||||||
if (!m_corona) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int views = Layout::GenericLayout::viewsCount(screen);
|
|
||||||
|
|
||||||
if (m_sharedLayout) {
|
|
||||||
for (const auto view : m_sharedLayout->latteViews()) {
|
|
||||||
if (view && view->screen() == screen && !view->containment()->destroyed()) {
|
|
||||||
++views;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return views;
|
|
||||||
}
|
|
||||||
|
|
||||||
int CentralLayout::viewsCount() const
|
|
||||||
{
|
|
||||||
if (!m_corona) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int views = Layout::GenericLayout::viewsCount();
|
|
||||||
|
|
||||||
if (m_sharedLayout) {
|
|
||||||
for (const auto view : m_sharedLayout->latteViews()) {
|
|
||||||
if (view && view->containment() && !view->containment()->destroyed()) {
|
|
||||||
++views;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return views;
|
|
||||||
}
|
|
||||||
|
|
||||||
QList<Plasma::Types::Location> CentralLayout::availableEdgesForView(QScreen *scr, Latte::View *forView) const
|
|
||||||
{
|
|
||||||
using Plasma::Types;
|
|
||||||
QList<Types::Location> edges{Types::BottomEdge, Types::LeftEdge,
|
|
||||||
Types::TopEdge, Types::RightEdge};
|
|
||||||
|
|
||||||
if (!m_corona) {
|
|
||||||
return edges;
|
|
||||||
}
|
|
||||||
|
|
||||||
edges = Layout::GenericLayout::availableEdgesForView(scr, forView);
|
|
||||||
|
|
||||||
if (m_sharedLayout) {
|
|
||||||
for (const auto view : m_sharedLayout->latteViews()) {
|
|
||||||
//! make sure that availabe edges takes into account only views that should be excluded,
|
|
||||||
//! this is why the forView should not be excluded
|
|
||||||
if (view && view != forView && view->positioner()->currentScreenName() == scr->name()) {
|
|
||||||
edges.removeOne(view->location());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return edges;
|
|
||||||
}
|
|
||||||
|
|
||||||
QList<Plasma::Types::Location> CentralLayout::freeEdges(QScreen *scr) const
|
|
||||||
{
|
|
||||||
using Plasma::Types;
|
|
||||||
QList<Types::Location> edges{Types::BottomEdge, Types::LeftEdge,
|
|
||||||
Types::TopEdge, Types::RightEdge};
|
|
||||||
|
|
||||||
if (!m_corona) {
|
|
||||||
return edges;
|
|
||||||
}
|
|
||||||
|
|
||||||
edges = Layout::GenericLayout::freeEdges(scr);
|
|
||||||
|
|
||||||
if (m_sharedLayout) {
|
|
||||||
for (const auto view : m_sharedLayout->latteViews()) {
|
|
||||||
if (view && view->positioner()->currentScreenName() == scr->name()) {
|
|
||||||
edges.removeOne(view->location());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return edges;
|
|
||||||
}
|
|
||||||
|
|
||||||
QList<Plasma::Types::Location> CentralLayout::freeEdges(int screen) const
|
|
||||||
{
|
|
||||||
using Plasma::Types;
|
|
||||||
QList<Types::Location> edges{Types::BottomEdge, Types::LeftEdge,
|
|
||||||
Types::TopEdge, Types::RightEdge};
|
|
||||||
|
|
||||||
if (!m_corona) {
|
|
||||||
return edges;
|
|
||||||
}
|
|
||||||
|
|
||||||
edges = Layout::GenericLayout::freeEdges(screen);
|
|
||||||
QScreen *scr = m_corona->screenPool()->screenForId(screen);
|
|
||||||
|
|
||||||
if (m_sharedLayout) {
|
|
||||||
for (const auto view : m_sharedLayout->latteViews()) {
|
|
||||||
if (view && scr && view->positioner()->currentScreenName() == scr->name()) {
|
|
||||||
edges.removeOne(view->location());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return edges;
|
|
||||||
}
|
|
||||||
|
|
||||||
Types::ViewType CentralLayout::latteViewType(uint containmentId) const
|
Types::ViewType CentralLayout::latteViewType(uint containmentId) const
|
||||||
{
|
{
|
||||||
for (const auto view : m_latteViews) {
|
for (const auto view : m_latteViews) {
|
||||||
@ -482,39 +222,7 @@ Types::ViewType CentralLayout::latteViewType(uint containmentId) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_sharedLayout) {
|
|
||||||
return m_sharedLayout->latteViewType(containmentId);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Types::DockView;
|
return Types::DockView;
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<Latte::View *> CentralLayout::sortedLatteViews(QList<Latte::View *> views)
|
|
||||||
{
|
|
||||||
QList<Latte::View *> vws = latteViews();
|
|
||||||
|
|
||||||
return Layout::GenericLayout::sortedLatteViews(vws);
|
|
||||||
}
|
|
||||||
|
|
||||||
QList<Latte::View *> CentralLayout::viewsWithPlasmaShortcuts()
|
|
||||||
{
|
|
||||||
QList<Latte::View *> combined = Layout::GenericLayout::viewsWithPlasmaShortcuts();
|
|
||||||
|
|
||||||
if (m_sharedLayout) {
|
|
||||||
combined << m_sharedLayout->viewsWithPlasmaShortcuts();
|
|
||||||
}
|
|
||||||
|
|
||||||
return combined;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CentralLayout::syncLatteViewsToScreens(Layout::ViewsMap *occupiedMap)
|
|
||||||
{
|
|
||||||
if (m_sharedLayout) {
|
|
||||||
Layout::ViewsMap map = m_sharedLayout->validViewsMap();
|
|
||||||
Layout::GenericLayout::syncLatteViewsToScreens(&map);
|
|
||||||
} else {
|
|
||||||
Layout::GenericLayout::syncLatteViewsToScreens();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -30,20 +30,18 @@
|
|||||||
|
|
||||||
namespace Latte {
|
namespace Latte {
|
||||||
class Corona;
|
class Corona;
|
||||||
class SharedLayout;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Latte {
|
namespace Latte {
|
||||||
|
|
||||||
//! CentralLayout is a very IMPORTANT layout that is responsible for specific Activities or not
|
//! CentralLayout is a layout that is assigned to ALL Activities, FREE Activities or SPRECIFIC Activities.
|
||||||
//! and it is used for all memory modes (SINGLE/MULTIPLE) at all times.
|
//! It is a real running layout instance.
|
||||||
//!
|
//!
|
||||||
//! It holds all the important settings in order to provide specific
|
//! It holds all the important settings in order to provide specific
|
||||||
//! behavior for the Activities is assigned at.
|
//! behavior for the Activities is assigned at.
|
||||||
//! for example: activities for which its views should be shown,
|
//! for example: activities for which its views should be shown,
|
||||||
//! if the maximized windows will be borderless,
|
//! if the maximized windows will be borderless,
|
||||||
//! if the layout will be shown at user layout contextmenu,
|
//! if the layout will be shown at user layout contextmenu.
|
||||||
//! which shared layout will be used on top of that layout.
|
|
||||||
//!
|
//!
|
||||||
|
|
||||||
class CentralLayout : public Layout::GenericLayout
|
class CentralLayout : public Layout::GenericLayout
|
||||||
@ -65,51 +63,21 @@ public:
|
|||||||
bool isForFreeActivities() const;
|
bool isForFreeActivities() const;
|
||||||
bool isOnAllActivities() const;
|
bool isOnAllActivities() const;
|
||||||
|
|
||||||
QString sharedLayoutName() const;
|
|
||||||
void setSharedLayoutName(QString name);
|
|
||||||
|
|
||||||
QStringList activities() const;
|
QStringList activities() const;
|
||||||
void setActivities(QStringList activities);
|
void setActivities(QStringList activities);
|
||||||
|
|
||||||
SharedLayout *sharedLayout() const;
|
|
||||||
void setSharedLayout(SharedLayout *layout);
|
|
||||||
|
|
||||||
//! OVERRIDE GeneralLayout implementations
|
|
||||||
void addView(Plasma::Containment *containment, bool forceOnPrimary = false, int explicitScreen = -1, Layout::ViewsMap *occupied = nullptr) override;
|
|
||||||
void syncLatteViewsToScreens(Layout::ViewsMap *occupiedMap = nullptr) override;
|
|
||||||
void unloadContainments() override;
|
|
||||||
const QStringList appliedActivities() override;
|
const QStringList appliedActivities() override;
|
||||||
Types::ViewType latteViewType(uint containmentId) const override;
|
Types::ViewType latteViewType(uint containmentId) const override;
|
||||||
QList<Latte::View *> latteViews() override;
|
|
||||||
|
|
||||||
int viewsCount(int screen) const override;
|
|
||||||
int viewsCount(QScreen *screen) const override;
|
|
||||||
int viewsCount() const override;
|
|
||||||
|
|
||||||
Layout::Type type() const override;
|
Layout::Type type() const override;
|
||||||
Data::Layout data() const;
|
Data::Layout data() const;
|
||||||
|
|
||||||
void setLastConfigViewFor(Latte::View *view) override;
|
|
||||||
Latte::View *lastConfigViewFor() override;
|
|
||||||
|
|
||||||
//! Available edges for specific view in that screen
|
|
||||||
QList<Plasma::Types::Location> availableEdgesForView(QScreen *scr, Latte::View *forView) const override;
|
|
||||||
//! All free edges in that screen
|
|
||||||
QList<Plasma::Types::Location> freeEdges(QScreen *scr) const override;
|
|
||||||
QList<Plasma::Types::Location> freeEdges(int screen) const override;
|
|
||||||
|
|
||||||
QList<Latte::View *> sortedLatteViews(QList<Latte::View *> views = QList<Latte::View *>()) override;
|
|
||||||
QList<Latte::View *> viewsWithPlasmaShortcuts() override;
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void activitiesChanged();
|
void activitiesChanged();
|
||||||
void disableBordersForMaximizedWindowsChanged();
|
void disableBordersForMaximizedWindowsChanged();
|
||||||
void showInMenuChanged();
|
void showInMenuChanged();
|
||||||
void sharedLayoutNameChanged();
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void disconnectSharedConnections();
|
|
||||||
|
|
||||||
void loadConfig();
|
void loadConfig();
|
||||||
void saveConfig();
|
void saveConfig();
|
||||||
|
|
||||||
@ -123,14 +91,7 @@ private:
|
|||||||
private:
|
private:
|
||||||
bool m_disableBordersForMaximizedWindows{false};
|
bool m_disableBordersForMaximizedWindows{false};
|
||||||
bool m_showInMenu{false};
|
bool m_showInMenu{false};
|
||||||
QString m_sharedLayoutName;
|
|
||||||
QStringList m_activities;
|
QStringList m_activities;
|
||||||
|
|
||||||
QPointer<Latte::View> m_lastSettingsView;
|
|
||||||
|
|
||||||
QPointer<SharedLayout> m_sharedLayout;
|
|
||||||
|
|
||||||
QList<QMetaObject::Connection> m_sharedConnections;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,263 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2019 Michail Vourlakos <mvourlakos@gmail.com>
|
|
||||||
*
|
|
||||||
* This file is part of Latte-Dock
|
|
||||||
*
|
|
||||||
* Latte-Dock is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU General Public License as
|
|
||||||
* published by the Free Software Foundation; either version 2 of
|
|
||||||
* the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Latte-Dock is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "sharedlayout.h"
|
|
||||||
|
|
||||||
// local
|
|
||||||
#include "centrallayout.h"
|
|
||||||
#include "../lattecorona.h"
|
|
||||||
#include "../screenpool.h"
|
|
||||||
#include "../layouts/manager.h"
|
|
||||||
#include "../view/view.h"
|
|
||||||
|
|
||||||
namespace Latte {
|
|
||||||
|
|
||||||
SharedLayout::SharedLayout(CentralLayout *assigned, QObject *parent, QString layoutFile, QString layoutName)
|
|
||||||
: Layout::GenericLayout (parent, layoutFile, layoutName)
|
|
||||||
{
|
|
||||||
initToCorona(assigned->corona());
|
|
||||||
|
|
||||||
connect(m_corona->layoutsManager(), &Layouts::Manager::currentLayoutNameChanged, this, &SharedLayout::updateLastUsedCentralLayout);
|
|
||||||
|
|
||||||
addCentralLayout(assigned);
|
|
||||||
updateLastUsedCentralLayout();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
SharedLayout::~SharedLayout()
|
|
||||||
{
|
|
||||||
qDebug() << " SHARED LAYOUT destroying ::: " << name();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool SharedLayout::contains(const QString &layoutName)
|
|
||||||
{
|
|
||||||
for (const auto &layout : m_centralLayouts) {
|
|
||||||
if (layout->name() == layoutName) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool SharedLayout::isCurrent() const
|
|
||||||
{
|
|
||||||
for (const auto &layout : m_centralLayouts) {
|
|
||||||
if (layout->isCurrent()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
Layout::Type SharedLayout::type() const
|
|
||||||
{
|
|
||||||
return Layout::Type::Shared;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const QStringList SharedLayout::appliedActivities()
|
|
||||||
{
|
|
||||||
if (!m_corona) {
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
QStringList activities;
|
|
||||||
|
|
||||||
for (const auto &layout : m_centralLayouts) {
|
|
||||||
activities << layout->appliedActivities();
|
|
||||||
}
|
|
||||||
|
|
||||||
return activities;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SharedLayout::updateLastUsedCentralLayout()
|
|
||||||
{
|
|
||||||
for (const auto &layout : m_centralLayouts) {
|
|
||||||
if (layout->isCurrent()) {
|
|
||||||
m_lastUsedCentralLayout = layout->name();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
CentralLayout *SharedLayout::currentCentralLayout() const
|
|
||||||
{
|
|
||||||
//! first the current active one
|
|
||||||
for (const auto &layout : m_centralLayouts) {
|
|
||||||
if (layout->isCurrent()) {
|
|
||||||
return layout;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//! the last used
|
|
||||||
for (const auto &layout : m_centralLayouts) {
|
|
||||||
if (layout->name() == m_lastUsedCentralLayout) {
|
|
||||||
return layout;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SharedLayout::addCentralLayout(CentralLayout *layout)
|
|
||||||
{
|
|
||||||
if (layout != nullptr && !m_centralLayouts.contains(layout)) {
|
|
||||||
m_centralLayouts.append(layout);
|
|
||||||
|
|
||||||
qDebug() << " ADDING Central : " << layout->name() << " at Shared: " << name();
|
|
||||||
connect(layout, &GenericLayout::activitiesChanged, this, &GenericLayout::activitiesChanged);
|
|
||||||
emit activitiesChanged();
|
|
||||||
emit viewsCountChanged();
|
|
||||||
|
|
||||||
updateLastUsedActivity();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void SharedLayout::removeCentralLayout(CentralLayout *layout)
|
|
||||||
{
|
|
||||||
if (m_centralLayouts.contains(layout)) {
|
|
||||||
qDebug() << "SHAREDLAYOUT <" << name() << "> : Removing active layout, " << layout->name();
|
|
||||||
m_centralLayouts.removeAll(layout);
|
|
||||||
|
|
||||||
disconnect(layout, &GenericLayout::activitiesChanged, this, &GenericLayout::activitiesChanged);
|
|
||||||
|
|
||||||
if (m_centralLayouts.count() > 0) {
|
|
||||||
emit activitiesChanged();
|
|
||||||
} else {
|
|
||||||
//! all assigned layouts have been unloaded so the shared layout should be destroyed also
|
|
||||||
emit layoutDestroyed(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
//! viewsCount signal is not needed to be trigerred here because
|
|
||||||
//! in such case the views number has not been changed for the rest
|
|
||||||
//! active layouts
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//! OVERRIDE
|
|
||||||
int SharedLayout::viewsCount(int screen) const
|
|
||||||
{
|
|
||||||
if (!m_corona) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
CentralLayout *current = currentCentralLayout();
|
|
||||||
|
|
||||||
if (current) {
|
|
||||||
return current->viewsCount(screen);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Layout::GenericLayout::viewsCount(screen);
|
|
||||||
}
|
|
||||||
|
|
||||||
int SharedLayout::viewsCount(QScreen *screen) const
|
|
||||||
{
|
|
||||||
if (!m_corona) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
CentralLayout *current = currentCentralLayout();
|
|
||||||
|
|
||||||
if (current) {
|
|
||||||
return current->viewsCount(screen);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Layout::GenericLayout::viewsCount(screen);;
|
|
||||||
}
|
|
||||||
|
|
||||||
int SharedLayout::viewsCount() const
|
|
||||||
{
|
|
||||||
if (!m_corona) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
CentralLayout *current = currentCentralLayout();
|
|
||||||
|
|
||||||
if (current) {
|
|
||||||
return current->viewsCount();
|
|
||||||
}
|
|
||||||
|
|
||||||
return Layout::GenericLayout::viewsCount();
|
|
||||||
}
|
|
||||||
|
|
||||||
QList<Plasma::Types::Location> SharedLayout::availableEdgesForView(QScreen *scr, Latte::View *forView) const
|
|
||||||
{
|
|
||||||
/* using Plasma::Types;
|
|
||||||
QList<Types::Location> edges{Types::BottomEdge, Types::LeftEdge,
|
|
||||||
Types::TopEdge, Types::RightEdge};
|
|
||||||
|
|
||||||
if (!m_corona) {
|
|
||||||
return edges;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
return Layout::GenericLayout::availableEdgesForView(scr, forView);
|
|
||||||
}
|
|
||||||
|
|
||||||
QList<Plasma::Types::Location> SharedLayout::freeEdges(QScreen *scr) const
|
|
||||||
{
|
|
||||||
/* using Plasma::Types;
|
|
||||||
QList<Types::Location> edges{Types::BottomEdge, Types::LeftEdge,
|
|
||||||
Types::TopEdge, Types::RightEdge};
|
|
||||||
|
|
||||||
if (!m_corona) {
|
|
||||||
return edges;
|
|
||||||
}
|
|
||||||
|
|
||||||
CentralLayout *current = currentCentralLayout();
|
|
||||||
|
|
||||||
if (current) {
|
|
||||||
return current->freeEdges(scr);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
return Layout::GenericLayout::freeEdges(scr);
|
|
||||||
}
|
|
||||||
|
|
||||||
QList<Plasma::Types::Location> SharedLayout::freeEdges(int screen) const
|
|
||||||
{
|
|
||||||
/* using Plasma::Types;
|
|
||||||
QList<Types::Location> edges{Types::BottomEdge, Types::LeftEdge,
|
|
||||||
Types::TopEdge, Types::RightEdge};
|
|
||||||
|
|
||||||
if (!m_corona) {
|
|
||||||
return edges;
|
|
||||||
}
|
|
||||||
|
|
||||||
CentralLayout *current = currentCentralLayout();
|
|
||||||
|
|
||||||
if (current) {
|
|
||||||
return current->freeEdges(screen);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
return Layout::GenericLayout::freeEdges(screen);
|
|
||||||
}
|
|
||||||
|
|
||||||
QList<Latte::View *> SharedLayout::sortedLatteViews(QList<Latte::View *> views)
|
|
||||||
{
|
|
||||||
CentralLayout *current = currentCentralLayout();
|
|
||||||
|
|
||||||
if (current) {
|
|
||||||
return current->sortedLatteViews();
|
|
||||||
}
|
|
||||||
|
|
||||||
return Layout::GenericLayout::sortedLatteViews();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,91 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2019 Michail Vourlakos <mvourlakos@gmail.com>
|
|
||||||
*
|
|
||||||
* This file is part of Latte-Dock
|
|
||||||
*
|
|
||||||
* Latte-Dock is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU General Public License as
|
|
||||||
* published by the Free Software Foundation; either version 2 of
|
|
||||||
* the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Latte-Dock is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef SHAREDLAYOUT_H
|
|
||||||
#define SHAREDLAYOUT_H
|
|
||||||
|
|
||||||
// local
|
|
||||||
#include "genericlayout.h"
|
|
||||||
|
|
||||||
// Qt
|
|
||||||
#include <QObject>
|
|
||||||
|
|
||||||
namespace Latte {
|
|
||||||
class CentralLayout;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
namespace Latte {
|
|
||||||
|
|
||||||
//! SharedLayout is a layout that exists only as long as it belongs to one or
|
|
||||||
//! more CentralLayout(s). It is a layer above a central or more layouts and can
|
|
||||||
//! be used from CentralLayouts to share Latte:View(s) . Much of its functionality
|
|
||||||
//! is provided by the CentralLayouts it belongs to. For example the activities
|
|
||||||
//! that its views should be shown is identified only from the central layouts
|
|
||||||
//! it belongs to
|
|
||||||
|
|
||||||
class SharedLayout : public Layout::GenericLayout
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
SharedLayout(CentralLayout *assigned, QObject *parent, QString layoutFile, QString layoutName = QString());
|
|
||||||
~SharedLayout() override;
|
|
||||||
|
|
||||||
const QStringList appliedActivities() override;
|
|
||||||
CentralLayout *currentCentralLayout() const;
|
|
||||||
|
|
||||||
//! OVERRIDE GeneralLayout implementations
|
|
||||||
bool isCurrent() const override;
|
|
||||||
bool contains(const QString &layoutName);
|
|
||||||
|
|
||||||
int viewsCount(int screen) const override;
|
|
||||||
int viewsCount(QScreen *screen) const override;
|
|
||||||
int viewsCount() const override;
|
|
||||||
|
|
||||||
Layout::Type type() const override;
|
|
||||||
|
|
||||||
//! Available edges for specific view in that screen
|
|
||||||
QList<Plasma::Types::Location> availableEdgesForView(QScreen *scr, Latte::View *forView) const override;
|
|
||||||
//! All free edges in that screen
|
|
||||||
QList<Plasma::Types::Location> freeEdges(QScreen *scr) const override;
|
|
||||||
QList<Plasma::Types::Location> freeEdges(int screen) const override;
|
|
||||||
|
|
||||||
QList<Latte::View *> sortedLatteViews(QList<Latte::View *> views = QList<Latte::View *>()) override;
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
void addCentralLayout(CentralLayout *layout);
|
|
||||||
void removeCentralLayout(CentralLayout *layout);
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void layoutDestroyed(SharedLayout *layout);
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void updateLastUsedCentralLayout();
|
|
||||||
|
|
||||||
private:
|
|
||||||
QString m_lastUsedCentralLayout;
|
|
||||||
|
|
||||||
QList<CentralLayout *> m_centralLayouts;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif //SHAREDLAYOUT_H
|
|
@ -178,16 +178,6 @@ QStringList Manager::centralLayoutsNames()
|
|||||||
return m_synchronizer->centralLayoutsNames();
|
return m_synchronizer->centralLayoutsNames();
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList Manager::sharedLayoutsNames()
|
|
||||||
{
|
|
||||||
return m_synchronizer->sharedLayoutsNames();
|
|
||||||
}
|
|
||||||
|
|
||||||
QStringList Manager::storedSharedLayouts() const
|
|
||||||
{
|
|
||||||
return m_synchronizer->storedSharedLayouts();
|
|
||||||
}
|
|
||||||
|
|
||||||
CentralLayout *Manager::currentLayout() const
|
CentralLayout *Manager::currentLayout() const
|
||||||
{
|
{
|
||||||
return m_synchronizer->currentLayout();
|
return m_synchronizer->currentLayout();
|
||||||
|
@ -93,7 +93,6 @@ public:
|
|||||||
|
|
||||||
QStringList layouts() const;
|
QStringList layouts() const;
|
||||||
QStringList menuLayouts() const;
|
QStringList menuLayouts() const;
|
||||||
QStringList storedSharedLayouts() const;
|
|
||||||
|
|
||||||
MemoryUsage::LayoutsMemory memoryUsage() const;
|
MemoryUsage::LayoutsMemory memoryUsage() const;
|
||||||
void setMemoryUsage(MemoryUsage::LayoutsMemory memoryUsage);
|
void setMemoryUsage(MemoryUsage::LayoutsMemory memoryUsage);
|
||||||
@ -113,7 +112,6 @@ public slots:
|
|||||||
Q_INVOKABLE bool switchToLayout(QString layoutName, int previousMemoryUsage = -1);
|
Q_INVOKABLE bool switchToLayout(QString layoutName, int previousMemoryUsage = -1);
|
||||||
|
|
||||||
Q_INVOKABLE QStringList centralLayoutsNames();
|
Q_INVOKABLE QStringList centralLayoutsNames();
|
||||||
Q_INVOKABLE QStringList sharedLayoutsNames();
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void centralLayoutsChanged();
|
void centralLayoutsChanged();
|
||||||
|
@ -26,7 +26,6 @@
|
|||||||
#include "../lattecorona.h"
|
#include "../lattecorona.h"
|
||||||
#include "../layout/centrallayout.h"
|
#include "../layout/centrallayout.h"
|
||||||
#include "../layout/genericlayout.h"
|
#include "../layout/genericlayout.h"
|
||||||
#include "../layout/sharedlayout.h"
|
|
||||||
#include "../settings/universalsettings.h"
|
#include "../settings/universalsettings.h"
|
||||||
#include "../templates/templatesmanager.h"
|
#include "../templates/templatesmanager.h"
|
||||||
#include "../view/view.h"
|
#include "../view/view.h"
|
||||||
@ -104,51 +103,12 @@ bool Synchronizer::layoutIsAssigned(QString layoutName)
|
|||||||
return m_assignedLayouts.values().contains(layoutName);
|
return m_assignedLayouts.values().contains(layoutName);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Synchronizer::mapHasRecord(const QString &record, SharesMap &map)
|
|
||||||
{
|
|
||||||
for (SharesMap::iterator i=map.begin(); i!=map.end(); ++i) {
|
|
||||||
if (i.value().contains(record)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Synchronizer::registerAtSharedLayout(CentralLayout *central, QString id)
|
|
||||||
{
|
|
||||||
if (m_manager->memoryUsage() == MemoryUsage::SingleLayout || centralLayout(id)) {
|
|
||||||
//! if memory is functioning to SINGLE mode OR shared layout has already
|
|
||||||
//! been loaded as CentralLayout
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < m_sharedLayouts.size(); ++i) {
|
|
||||||
SharedLayout *layout = m_sharedLayouts.at(i);
|
|
||||||
|
|
||||||
if (layout->name() == id) {
|
|
||||||
layout->addCentralLayout(central);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//! If SharedLayout was not found, we must create it
|
|
||||||
SharedLayout *top = new SharedLayout(central, this, Importer::layoutUserFilePath(id));
|
|
||||||
m_sharedLayouts.append(top);
|
|
||||||
top->importToCorona();
|
|
||||||
|
|
||||||
connect(top, &SharedLayout::layoutDestroyed, this, &Synchronizer::unloadSharedLayout);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
int Synchronizer::centralLayoutPos(QString id) const
|
int Synchronizer::centralLayoutPos(QString id) const
|
||||||
{
|
{
|
||||||
for (int i = 0; i < m_centralLayouts.size(); ++i) {
|
for (int i = 0; i < m_centralLayouts.size(); ++i) {
|
||||||
CentralLayout *layout = m_centralLayouts.at(i);
|
CentralLayout *layout = m_centralLayouts.at(i);
|
||||||
|
|
||||||
if (layout->name() == id) {
|
if (layout->name() == id) {
|
||||||
|
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -279,23 +239,6 @@ QString Synchronizer::shouldSwitchToLayout(QString activityId)
|
|||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList Synchronizer::sharedLayoutsNames()
|
|
||||||
{
|
|
||||||
QStringList names;
|
|
||||||
|
|
||||||
for (int i = 0; i < m_sharedLayouts.size(); ++i) {
|
|
||||||
SharedLayout *layout = m_sharedLayouts.at(i);
|
|
||||||
names << layout->name();
|
|
||||||
}
|
|
||||||
|
|
||||||
return names;
|
|
||||||
}
|
|
||||||
|
|
||||||
QStringList Synchronizer::storedSharedLayouts() const
|
|
||||||
{
|
|
||||||
return m_sharedLayoutIds;
|
|
||||||
}
|
|
||||||
|
|
||||||
QStringList Synchronizer::validActivities(QStringList currentList)
|
QStringList Synchronizer::validActivities(QStringList currentList)
|
||||||
{
|
{
|
||||||
QStringList validIds;
|
QStringList validIds;
|
||||||
@ -348,26 +291,9 @@ Layout::GenericLayout *Synchronizer::layout(QString id) const
|
|||||||
{
|
{
|
||||||
Layout::GenericLayout *l = centralLayout(id);
|
Layout::GenericLayout *l = centralLayout(id);
|
||||||
|
|
||||||
if (!l) {
|
|
||||||
l = sharedLayout(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
|
|
||||||
SharedLayout *Synchronizer::sharedLayout(QString id) const
|
|
||||||
{
|
|
||||||
for (int i = 0; i < m_sharedLayouts.size(); ++i) {
|
|
||||||
SharedLayout *layout = m_sharedLayouts.at(i);
|
|
||||||
|
|
||||||
if (layout->name() == id) {
|
|
||||||
return layout;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
Latte::View *Synchronizer::viewForContainment(Plasma::Containment *containment)
|
Latte::View *Synchronizer::viewForContainment(Plasma::Containment *containment)
|
||||||
{
|
{
|
||||||
for (auto layout : m_centralLayouts) {
|
for (auto layout : m_centralLayouts) {
|
||||||
@ -378,14 +304,6 @@ Latte::View *Synchronizer::viewForContainment(Plasma::Containment *containment)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto layout : m_sharedLayouts) {
|
|
||||||
Latte::View *view = layout->viewForContainment(containment);
|
|
||||||
|
|
||||||
if (view) {
|
|
||||||
return view;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -397,31 +315,6 @@ void Synchronizer::addLayout(CentralLayout *layout)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Synchronizer::clearSharedLayoutsFromCentralLists()
|
|
||||||
{
|
|
||||||
QStringList unassign;
|
|
||||||
|
|
||||||
for(const QString &name : m_sharedLayoutIds) {
|
|
||||||
//! remove from ContextMenu
|
|
||||||
m_menuLayouts.removeAll(name);
|
|
||||||
|
|
||||||
//! remove from layouts assigned to activities
|
|
||||||
QHashIterator<const QString, QString> i(m_assignedLayouts);
|
|
||||||
|
|
||||||
while (i.hasNext()) {
|
|
||||||
i.next();
|
|
||||||
|
|
||||||
if (i.value() == name) {
|
|
||||||
unassign << i.key();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for(const QString &activity : unassign) {
|
|
||||||
m_assignedLayouts.remove(activity);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Synchronizer::confirmDynamicSwitch()
|
void Synchronizer::confirmDynamicSwitch()
|
||||||
{
|
{
|
||||||
QString tempShouldSwitch = shouldSwitchToLayout(m_manager->corona()->activitiesConsumer()->currentActivity());
|
QString tempShouldSwitch = shouldSwitchToLayout(m_manager->corona()->activitiesConsumer()->currentActivity());
|
||||||
@ -495,19 +388,11 @@ void Synchronizer::syncActiveLayoutsToOriginalFiles()
|
|||||||
for (const auto layout : m_centralLayouts) {
|
for (const auto layout : m_centralLayouts) {
|
||||||
layout->syncToLayoutFile();
|
layout->syncToLayoutFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const auto layout : m_sharedLayouts) {
|
|
||||||
layout->syncToLayoutFile();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Synchronizer::syncLatteViewsToScreens()
|
void Synchronizer::syncLatteViewsToScreens()
|
||||||
{
|
{
|
||||||
for (const auto layout : m_sharedLayouts) {
|
|
||||||
layout->syncLatteViewsToScreens();
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const auto layout : m_centralLayouts) {
|
for (const auto layout : m_centralLayouts) {
|
||||||
layout->syncLatteViewsToScreens();
|
layout->syncLatteViewsToScreens();
|
||||||
}
|
}
|
||||||
@ -535,28 +420,11 @@ void Synchronizer::unloadCentralLayout(CentralLayout *layout)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Synchronizer::unloadSharedLayout(SharedLayout *layout)
|
|
||||||
{
|
|
||||||
if (m_sharedLayouts.contains(layout)) {
|
|
||||||
emit currentLayoutIsSwitching(layout->name());
|
|
||||||
disconnect(layout, &SharedLayout::layoutDestroyed, this, &Synchronizer::unloadSharedLayout);
|
|
||||||
int pos = m_sharedLayouts.indexOf(layout);
|
|
||||||
SharedLayout *shared = m_sharedLayouts.takeAt(pos);
|
|
||||||
shared->syncToLayoutFile(true);
|
|
||||||
shared->unloadLatteViews();
|
|
||||||
shared->unloadContainments();
|
|
||||||
m_manager->clearUnloadedContainmentsFromLinkedFile(shared->unloadedContainmentsIds(), true);
|
|
||||||
|
|
||||||
delete layout;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Synchronizer::loadLayouts()
|
void Synchronizer::loadLayouts()
|
||||||
{
|
{
|
||||||
m_layouts.clear();
|
m_layouts.clear();
|
||||||
m_menuLayouts.clear();
|
m_menuLayouts.clear();
|
||||||
m_assignedLayouts.clear();
|
m_assignedLayouts.clear();
|
||||||
m_sharedLayoutIds.clear();
|
|
||||||
|
|
||||||
QDir layoutDir(Layouts::Importer::layoutUserDir());
|
QDir layoutDir(Layouts::Importer::layoutUserDir());
|
||||||
QStringList filter;
|
QStringList filter;
|
||||||
@ -573,9 +441,6 @@ void Synchronizer::loadLayouts()
|
|||||||
onLayoutAdded(layoutpath);
|
onLayoutAdded(layoutpath);
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Shared Layouts should not be used for Activities->Layouts assignments or published lists
|
|
||||||
clearSharedLayoutsFromCentralLists();
|
|
||||||
|
|
||||||
m_layouts.sort(Qt::CaseInsensitive);
|
m_layouts.sort(Qt::CaseInsensitive);
|
||||||
m_menuLayouts.sort(Qt::CaseInsensitive);
|
m_menuLayouts.sort(Qt::CaseInsensitive);
|
||||||
|
|
||||||
@ -605,12 +470,6 @@ void Synchronizer::onLayoutAdded(const QString &layout)
|
|||||||
m_menuLayouts.append(centralLayout.name());
|
m_menuLayouts.append(centralLayout.name());
|
||||||
}
|
}
|
||||||
|
|
||||||
QString sharedName = centralLayout.sharedLayoutName();
|
|
||||||
|
|
||||||
if (!sharedName.isEmpty() && !m_sharedLayoutIds.contains(sharedName)) {
|
|
||||||
m_sharedLayoutIds << sharedName;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_isLoaded) {
|
if (m_isLoaded) {
|
||||||
m_layouts.sort(Qt::CaseInsensitive);
|
m_layouts.sort(Qt::CaseInsensitive);
|
||||||
m_menuLayouts.sort(Qt::CaseInsensitive);
|
m_menuLayouts.sort(Qt::CaseInsensitive);
|
||||||
@ -688,10 +547,6 @@ bool Synchronizer::switchToLayout(QString layoutName, int previousMemoryUsage)
|
|||||||
for (const auto layout : m_centralLayouts) {
|
for (const auto layout : m_centralLayouts) {
|
||||||
emit currentLayoutIsSwitching(layout->name());
|
emit currentLayoutIsSwitching(layout->name());
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const auto layout : m_sharedLayouts) {
|
|
||||||
emit currentLayoutIsSwitching(layout->name());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString lPath = layoutPath(layoutName);
|
QString lPath = layoutPath(layoutName);
|
||||||
@ -854,11 +709,8 @@ void Synchronizer::syncMultipleLayoutsToActivities(QString layoutForFreeActiviti
|
|||||||
//! discover layouts that are needed based on running activities
|
//! discover layouts that are needed based on running activities
|
||||||
for (const auto &activity : runningActivities()) {
|
for (const auto &activity : runningActivities()) {
|
||||||
if (KWindowSystem::isPlatformWayland() && (m_activitiesController->currentActivity() != activity)){
|
if (KWindowSystem::isPlatformWayland() && (m_activitiesController->currentActivity() != activity)){
|
||||||
//! Wayland Protection: Plasma wayland does not support yet Activities but on the other hand that
|
//! Wayland Protection: Plasma wayland does not support yet Activities for windows
|
||||||
//! does not mean that Central layouts can not be accompanied by their relevant shared layout.
|
//! but we can load the layouts that belong OnAllActivities + (ForFreeActivities OR SpecificActivity)
|
||||||
//! The optimal behavior is that only ONE central layout and ONE shared layout can be loaded each time.
|
|
||||||
//! If the user changes in an activity that needs a different central layout then in that case
|
|
||||||
//! the new central layout is loaded and the old one is unloaded.
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -906,9 +758,8 @@ void Synchronizer::syncMultipleLayoutsToActivities(QString layoutForFreeActiviti
|
|||||||
|
|
||||||
//! Add Layout for free activities
|
//! Add Layout for free activities
|
||||||
if (layoutForFreeActivitiesIsNeeded) {
|
if (layoutForFreeActivitiesIsNeeded) {
|
||||||
if (!centralLayout(layoutForFreeActivities) && !sharedLayout(layoutForFreeActivities)) {
|
if (!centralLayout(layoutForFreeActivities)) {
|
||||||
//! CENTRAL Layout for FreeActivities is not loaded and at the same time
|
//! CENTRAL Layout for FreeActivities is not loaded
|
||||||
//! that layout is not already configured as SHARED for other CENTRAL layouts
|
|
||||||
CentralLayout *newLayout = new CentralLayout(this, layoutPath(layoutForFreeActivities), layoutForFreeActivities);
|
CentralLayout *newLayout = new CentralLayout(this, layoutPath(layoutForFreeActivities), layoutForFreeActivities);
|
||||||
|
|
||||||
if (newLayout) {
|
if (newLayout) {
|
||||||
@ -940,90 +791,5 @@ void Synchronizer::syncMultipleLayoutsToActivities(QString layoutForFreeActiviti
|
|||||||
emit centralLayoutsChanged();
|
emit centralLayoutsChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Synchronizer::syncActiveShares(SharesMap &sharesMap, QStringList &deprecatedShares)
|
|
||||||
{
|
|
||||||
if (m_manager->memoryUsage() != MemoryUsage::MultipleLayouts) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
qDebug() << " CURRENT SHARES MAP :: " << sharesMap;
|
|
||||||
qDebug() << " DEPRECATED SHARES :: " << deprecatedShares;
|
|
||||||
|
|
||||||
QHash<CentralLayout *, SharedLayout *> unassign;
|
|
||||||
|
|
||||||
//! CENTRAL (inactive) layouts that must update their SharedLayoutName because they
|
|
||||||
//! were unassigned from a Shared Layout
|
|
||||||
for (const auto &share : deprecatedShares) {
|
|
||||||
CentralLayout *central = centralLayout(share);
|
|
||||||
if (!central) {
|
|
||||||
//! Central Layout is not loaded
|
|
||||||
CentralLayout centralInStorage(this, Importer::layoutUserFilePath(share));
|
|
||||||
centralInStorage.setSharedLayoutName(QString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//! CENTRAL (active) layouts that will become SHARED must be unloaded first
|
|
||||||
for (SharesMap::iterator i=sharesMap.begin(); i!=sharesMap.end(); ++i) {
|
|
||||||
CentralLayout *central = centralLayout(i.key());
|
|
||||||
if (central) {
|
|
||||||
unloadCentralLayout(central);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//! CENTRAL (active) layouts that update their (active) SHARED layouts
|
|
||||||
//! AND load SHARED layouts that are NOT ACTIVE
|
|
||||||
for (SharesMap::iterator i=sharesMap.begin(); i!=sharesMap.end(); ++i) {
|
|
||||||
SharedLayout *shared = sharedLayout(i.key());
|
|
||||||
qDebug() << " SHARED :: " << i.key();
|
|
||||||
for (const auto ¢ralName : i.value()) {
|
|
||||||
CentralLayout *central = centralLayout(centralName);
|
|
||||||
qDebug() << " CENTRAL NAME :: " << centralName;
|
|
||||||
if (central) {
|
|
||||||
//! Assign this Central Layout at a different Shared Layout
|
|
||||||
SharedLayout *oldShared = central->sharedLayout();
|
|
||||||
|
|
||||||
if (!shared) {
|
|
||||||
//Shared not loaded and it must be loaded before proceed
|
|
||||||
registerAtSharedLayout(central, i.key());
|
|
||||||
shared = sharedLayout(i.key());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (shared != oldShared) {
|
|
||||||
shared->addCentralLayout(central);
|
|
||||||
central->setSharedLayout(shared);
|
|
||||||
if (oldShared) {
|
|
||||||
//! CENTRAL layout that changed from one ACTIVESHARED layout to another
|
|
||||||
unassign[central] = oldShared;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
//! Central Layout is not loaded
|
|
||||||
CentralLayout centralInStorage(this, Importer::layoutUserFilePath(centralName));
|
|
||||||
centralInStorage.setSharedLayoutName(i.key());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//! CENTRAL Layouts that wont have any SHARED Layout any more
|
|
||||||
for (const auto ¢ralName : centralLayoutsNames()) {
|
|
||||||
if (!mapHasRecord(centralName, sharesMap)) {
|
|
||||||
CentralLayout *central = centralLayout(centralName);
|
|
||||||
if (central && central->sharedLayout()) {
|
|
||||||
central->sharedLayout()->removeCentralLayout(central);
|
|
||||||
central->setSharedLayoutName(QString());
|
|
||||||
central->setSharedLayout(nullptr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//! Unassing from Shared Layouts Central ones that are not assigned any more
|
|
||||||
//! IMPORTANT: This must be done after all the ASSIGNMENTS in order to avoid
|
|
||||||
//! to unload a SharedLayout that it should not
|
|
||||||
for (QHash<CentralLayout *, SharedLayout *>::iterator i=unassign.begin(); i!=unassign.end(); ++i) {
|
|
||||||
qDebug() << " REMOVING CENTRAL :: " << i.key()->name() << " FROM :: " << i.value()->name();
|
|
||||||
i.value()->removeCentralLayout(i.key());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
} // end of namespace
|
} // end of namespace
|
||||||
|
@ -28,7 +28,6 @@
|
|||||||
|
|
||||||
namespace Latte {
|
namespace Latte {
|
||||||
class CentralLayout;
|
class CentralLayout;
|
||||||
class SharedLayout;
|
|
||||||
class View;
|
class View;
|
||||||
namespace Layout{
|
namespace Layout{
|
||||||
class GenericLayout;
|
class GenericLayout;
|
||||||
@ -49,10 +48,9 @@ class Controller;
|
|||||||
namespace Latte {
|
namespace Latte {
|
||||||
namespace Layouts {
|
namespace Layouts {
|
||||||
|
|
||||||
//! This is a Shares map in the following structure:
|
//! This is a Layouts map in the following structure:
|
||||||
//! SHARED LAYOUT NAME -> CENTRAL LAYOUT NAMES acting as SHARES
|
//! ACTIVITY ID -> Layout Names for that activity
|
||||||
typedef QHash<const QString, QStringList> SharesMap;
|
typedef QHash<const QString, QStringList> AssignedLayoutsHash;
|
||||||
|
|
||||||
|
|
||||||
//! Layouts::Synchronizer is a very IMPORTANT class which is responsible
|
//! Layouts::Synchronizer is a very IMPORTANT class which is responsible
|
||||||
//! for all ACTIVE layouts, meaning layouts that have been loaded
|
//! for all ACTIVE layouts, meaning layouts that have been loaded
|
||||||
@ -78,12 +76,9 @@ public:
|
|||||||
void syncActiveLayoutsToOriginalFiles();
|
void syncActiveLayoutsToOriginalFiles();
|
||||||
void syncLatteViewsToScreens();
|
void syncLatteViewsToScreens();
|
||||||
void syncMultipleLayoutsToActivities(QString layoutForFreeActivities = QString());
|
void syncMultipleLayoutsToActivities(QString layoutForFreeActivities = QString());
|
||||||
void syncActiveShares(SharesMap &sharesMap, QStringList &deprecatedShares);
|
|
||||||
|
|
||||||
bool latteViewExists(Latte::View *view) const;
|
bool latteViewExists(Latte::View *view) const;
|
||||||
bool layoutExists(QString layoutName) const;
|
bool layoutExists(QString layoutName) const;
|
||||||
bool mapHasRecord(const QString &record, SharesMap &map);
|
|
||||||
bool registerAtSharedLayout(CentralLayout *central, QString id);
|
|
||||||
//! switch to specified layout, default previousMemoryUsage means that it didn't change
|
//! switch to specified layout, default previousMemoryUsage means that it didn't change
|
||||||
bool switchToLayout(QString layoutName, int previousMemoryUsage = -1);
|
bool switchToLayout(QString layoutName, int previousMemoryUsage = -1);
|
||||||
|
|
||||||
@ -100,8 +95,6 @@ public:
|
|||||||
QStringList layouts() const;
|
QStringList layouts() const;
|
||||||
QStringList menuLayouts() const;
|
QStringList menuLayouts() const;
|
||||||
void setMenuLayouts(QStringList layouts);
|
void setMenuLayouts(QStringList layouts);
|
||||||
QStringList sharedLayoutsNames();
|
|
||||||
QStringList storedSharedLayouts() const;
|
|
||||||
|
|
||||||
QStringList activities();
|
QStringList activities();
|
||||||
QStringList runningActivities();
|
QStringList runningActivities();
|
||||||
@ -111,7 +104,6 @@ public:
|
|||||||
|
|
||||||
CentralLayout *currentLayout() const;
|
CentralLayout *currentLayout() const;
|
||||||
CentralLayout *centralLayout(QString id) const;
|
CentralLayout *centralLayout(QString id) const;
|
||||||
SharedLayout *sharedLayout(QString id) const;
|
|
||||||
Layout::GenericLayout *layout(QString id) const;
|
Layout::GenericLayout *layout(QString id) const;
|
||||||
|
|
||||||
KActivities::Controller *activitiesController() const;
|
KActivities::Controller *activitiesController() const;
|
||||||
@ -135,11 +127,8 @@ private slots:
|
|||||||
void onLayoutAdded(const QString &layoutpath);
|
void onLayoutAdded(const QString &layoutpath);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void clearSharedLayoutsFromCentralLists();
|
|
||||||
|
|
||||||
void addLayout(CentralLayout *layout);
|
void addLayout(CentralLayout *layout);
|
||||||
void unloadCentralLayout(CentralLayout *layout);
|
void unloadCentralLayout(CentralLayout *layout);
|
||||||
void unloadSharedLayout(SharedLayout *layout);
|
|
||||||
|
|
||||||
bool layoutIsAssigned(QString layoutName);
|
bool layoutIsAssigned(QString layoutName);
|
||||||
|
|
||||||
@ -156,14 +145,12 @@ private:
|
|||||||
|
|
||||||
QStringList m_layouts;
|
QStringList m_layouts;
|
||||||
QStringList m_menuLayouts;
|
QStringList m_menuLayouts;
|
||||||
QStringList m_sharedLayoutIds;
|
|
||||||
|
|
||||||
QHash<const QString, QString> m_assignedLayouts;
|
QHash<const QString, QString> m_assignedLayouts;
|
||||||
|
|
||||||
QTimer m_dynamicSwitchTimer;
|
QTimer m_dynamicSwitchTimer;
|
||||||
|
|
||||||
QList<CentralLayout *> m_centralLayouts;
|
QList<CentralLayout *> m_centralLayouts;
|
||||||
QList<SharedLayout *> m_sharedLayouts;
|
|
||||||
|
|
||||||
Layouts::Manager *m_manager;
|
Layouts::Manager *m_manager;
|
||||||
KActivities::Controller *m_activitiesController;
|
KActivities::Controller *m_activitiesController;
|
||||||
|
@ -28,13 +28,11 @@
|
|||||||
#include "../delegates/backgrounddelegate.h"
|
#include "../delegates/backgrounddelegate.h"
|
||||||
#include "../delegates/checkboxdelegate.h"
|
#include "../delegates/checkboxdelegate.h"
|
||||||
#include "../delegates/layoutnamedelegate.h"
|
#include "../delegates/layoutnamedelegate.h"
|
||||||
#include "../delegates/shareddelegate.h"
|
|
||||||
#include "../handlers/tablayoutshandler.h"
|
#include "../handlers/tablayoutshandler.h"
|
||||||
#include "../tools/settingstools.h"
|
#include "../tools/settingstools.h"
|
||||||
#include "../../data/uniqueidinfo.h"
|
#include "../../data/uniqueidinfo.h"
|
||||||
#include "../../layout/genericlayout.h"
|
#include "../../layout/genericlayout.h"
|
||||||
#include "../../layout/centrallayout.h"
|
#include "../../layout/centrallayout.h"
|
||||||
#include "../../layout/sharedlayout.h"
|
|
||||||
#include "../../layouts/importer.h"
|
#include "../../layouts/importer.h"
|
||||||
#include "../../layouts/manager.h"
|
#include "../../layouts/manager.h"
|
||||||
#include "../../layouts/synchronizer.h"
|
#include "../../layouts/synchronizer.h"
|
||||||
@ -152,7 +150,6 @@ void Layouts::initView()
|
|||||||
m_view->setItemDelegateForColumn(Model::Layouts::MENUCOLUMN, new Settings::Layout::Delegate::CheckBox(this));
|
m_view->setItemDelegateForColumn(Model::Layouts::MENUCOLUMN, new Settings::Layout::Delegate::CheckBox(this));
|
||||||
m_view->setItemDelegateForColumn(Model::Layouts::BORDERSCOLUMN, new Settings::Layout::Delegate::CheckBox(this));
|
m_view->setItemDelegateForColumn(Model::Layouts::BORDERSCOLUMN, new Settings::Layout::Delegate::CheckBox(this));
|
||||||
m_view->setItemDelegateForColumn(Model::Layouts::ACTIVITYCOLUMN, new Settings::Layout::Delegate::Activities(this));
|
m_view->setItemDelegateForColumn(Model::Layouts::ACTIVITYCOLUMN, new Settings::Layout::Delegate::Activities(this));
|
||||||
m_view->setItemDelegateForColumn(Model::Layouts::SHAREDCOLUMN, new Settings::Layout::Delegate::Shared(this));
|
|
||||||
|
|
||||||
connect(m_view, &QObject::destroyed, this, &Controller::Layouts::storeColumnWidths);
|
connect(m_view, &QObject::destroyed, this, &Controller::Layouts::storeColumnWidths);
|
||||||
}
|
}
|
||||||
@ -227,14 +224,10 @@ void Layouts::setInMultipleMode(bool inMultiple)
|
|||||||
void Layouts::updateLastColumnWidth()
|
void Layouts::updateLastColumnWidth()
|
||||||
{
|
{
|
||||||
if (m_model->inMultipleMode()) {
|
if (m_model->inMultipleMode()) {
|
||||||
m_view->setColumnHidden(Model::Layouts::SHAREDCOLUMN, false);
|
|
||||||
|
|
||||||
//! column widths
|
//! column widths
|
||||||
if (m_viewColumnWidths.count()>=5) {
|
if (m_viewColumnWidths.count()>=5) {
|
||||||
m_view->setColumnWidth(Model::Layouts::ACTIVITYCOLUMN, m_viewColumnWidths[4].toInt());
|
m_view->setColumnWidth(Model::Layouts::ACTIVITYCOLUMN, m_viewColumnWidths[4].toInt());
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
m_view->setColumnHidden(Model::Layouts::SHAREDCOLUMN, true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -324,41 +317,6 @@ void Layouts::toggleLockedForSelected()
|
|||||||
m_proxyModel->setData(m_proxyModel->index(m_view->currentIndex().row(), Model::Layouts::NAMECOLUMN), !selected.isLocked, Settings::Model::Layouts::ISLOCKEDROLE);
|
m_proxyModel->setData(m_proxyModel->index(m_view->currentIndex().row(), Model::Layouts::NAMECOLUMN), !selected.isLocked, Settings::Model::Layouts::ISLOCKEDROLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Layouts::toggleSharedForSelected()
|
|
||||||
{
|
|
||||||
if (!hasSelectedLayout()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
int row = m_view->currentIndex().row();
|
|
||||||
|
|
||||||
Latte::Data::Layout selected = selectedLayoutCurrentData();
|
|
||||||
|
|
||||||
if (selected.isShared()) {
|
|
||||||
m_proxyModel->setData(m_proxyModel->index(row, Model::Layouts::SHAREDCOLUMN), QStringList(), Qt::UserRole);
|
|
||||||
} else {
|
|
||||||
QStringList assignedIds;
|
|
||||||
QStringList availableShareIds = m_model->availableShareIdsFor(selected.id);
|
|
||||||
|
|
||||||
for (const auto &id : availableShareIds) {
|
|
||||||
Latte::Data::Layout iLayoutCurrent = m_model->currentData(id);
|
|
||||||
Latte::Data::Layout iLayoutOriginal = m_model->originalData(id);
|
|
||||||
iLayoutOriginal = iLayoutOriginal.isEmpty() ? iLayoutCurrent : iLayoutOriginal;
|
|
||||||
|
|
||||||
if (m_handler->corona()->layoutsManager()->synchronizer()->layout(iLayoutOriginal.name)) {
|
|
||||||
assignedIds << id;
|
|
||||||
m_proxyModel->setData(m_proxyModel->index(row, Model::Layouts::SHAREDCOLUMN), assignedIds, Qt::UserRole);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (assignedIds.isEmpty() && availableShareIds.count()>0) {
|
|
||||||
assignedIds << availableShareIds[0];
|
|
||||||
m_proxyModel->setData(m_proxyModel->index(row, Model::Layouts::SHAREDCOLUMN), assignedIds, Qt::UserRole);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Layouts::selectRow(const QString &id)
|
void Layouts::selectRow(const QString &id)
|
||||||
{
|
{
|
||||||
m_view->selectRow(rowForId(id));
|
m_view->selectRow(rowForId(id));
|
||||||
@ -386,11 +344,6 @@ void Layouts::loadLayouts()
|
|||||||
bool inMultiple{m_handler->corona()->layoutsManager()->memoryUsage() == MemoryUsage::MultipleLayouts};
|
bool inMultiple{m_handler->corona()->layoutsManager()->memoryUsage() == MemoryUsage::MultipleLayouts};
|
||||||
setInMultipleMode(inMultiple);
|
setInMultipleMode(inMultiple);
|
||||||
|
|
||||||
//! The shares map needs to be constructed for start/scratch.
|
|
||||||
//! We start feeding information with layout_names and during the process
|
|
||||||
//! we update them to valid layout_ids
|
|
||||||
Latte::Layouts::SharesMap sharesMap;
|
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
QStringList brokenLayouts;
|
QStringList brokenLayouts;
|
||||||
|
|
||||||
@ -420,12 +373,6 @@ void Layouts::loadLayouts()
|
|||||||
|
|
||||||
m_layouts[original.id] = central;
|
m_layouts[original.id] = central;
|
||||||
|
|
||||||
//! create initial SHARES maps
|
|
||||||
QString shared = central->sharedLayoutName();
|
|
||||||
if (!shared.isEmpty()) {
|
|
||||||
sharesMap[shared].append(original.id);
|
|
||||||
}
|
|
||||||
|
|
||||||
layoutsBuffer << original;
|
layoutsBuffer << original;
|
||||||
|
|
||||||
qDebug() << "counter:" << i << " total:" << m_model->rowCount();
|
qDebug() << "counter:" << i << " total:" << m_model->rowCount();
|
||||||
@ -439,33 +386,6 @@ void Layouts::loadLayouts()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//! update SHARES map keys in order to use the #settingsid(s)
|
|
||||||
QStringList tempSharedNames;
|
|
||||||
|
|
||||||
//! remove these records after updating
|
|
||||||
for (QHash<const QString, QStringList>::iterator i=sharesMap.begin(); i!=sharesMap.end(); ++i) {
|
|
||||||
tempSharedNames << i.key();
|
|
||||||
}
|
|
||||||
|
|
||||||
//! update keys
|
|
||||||
for (QHash<const QString, QStringList>::iterator i=sharesMap.begin(); i!=sharesMap.end(); ++i) {
|
|
||||||
QString shareid = layoutsBuffer.idForName(i.key());
|
|
||||||
if (!shareid.isEmpty()) {
|
|
||||||
sharesMap[shareid] = i.value();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//! remove deprecated keys
|
|
||||||
for (const auto &key : tempSharedNames) {
|
|
||||||
sharesMap.remove(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
qDebug() << "SHARES MAP ::: " << sharesMap;
|
|
||||||
|
|
||||||
for (QHash<const QString, QStringList>::iterator i=sharesMap.begin(); i!=sharesMap.end(); ++i) {
|
|
||||||
layoutsBuffer[i.key()].shares = i.value();
|
|
||||||
}
|
|
||||||
|
|
||||||
//! Send original loaded data to model
|
//! Send original loaded data to model
|
||||||
m_model->setOriginalData(layoutsBuffer, inMultiple);
|
m_model->setOriginalData(layoutsBuffer, inMultiple);
|
||||||
m_model->setOriginalLayoutForFreeActivities(layoutsBuffer.idForName(m_handler->corona()->universalSettings()->lastNonAssignedLayoutName()));
|
m_model->setOriginalLayoutForFreeActivities(layoutsBuffer.idForName(m_handler->corona()->universalSettings()->lastNonAssignedLayoutName()));
|
||||||
@ -608,7 +528,6 @@ void Layouts::copySelectedLayout()
|
|||||||
copied.isActive = false;
|
copied.isActive = false;
|
||||||
copied.isLocked = false;
|
copied.isLocked = false;
|
||||||
copied.activities = QStringList();
|
copied.activities = QStringList();
|
||||||
copied.shares = QStringList();
|
|
||||||
|
|
||||||
QFile(selectedLayoutCurrent.id).copy(copied.id);
|
QFile(selectedLayoutCurrent.id).copy(copied.id);
|
||||||
QFileInfo newFileInfo(copied.id);
|
QFileInfo newFileInfo(copied.id);
|
||||||
@ -619,7 +538,6 @@ void Layouts::copySelectedLayout()
|
|||||||
|
|
||||||
CentralLayout *settings = new CentralLayout(this, copied.id);
|
CentralLayout *settings = new CentralLayout(this, copied.id);
|
||||||
settings->clearLastUsedActivity();
|
settings->clearLastUsedActivity();
|
||||||
settings->setSharedLayoutName("");
|
|
||||||
settings->setActivities(QStringList());
|
settings->setActivities(QStringList());
|
||||||
|
|
||||||
m_layouts[copied.id] = settings;
|
m_layouts[copied.id] = settings;
|
||||||
@ -680,15 +598,6 @@ bool Layouts::importLayoutsFromV1ConfigFile(QString file)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Layouts::onSharedToInEditChanged(const QString &id, const bool &inEdit)
|
|
||||||
{
|
|
||||||
int row = m_model->rowForId(id);
|
|
||||||
|
|
||||||
if (row >= 0) {
|
|
||||||
m_model->setData(m_model->index(row, Model::Layouts::SHAREDCOLUMN), inEdit, Model::Layouts::SHAREDTOINEDITROLE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Layouts::reset()
|
void Layouts::reset()
|
||||||
{
|
{
|
||||||
m_model->resetData();
|
m_model->resetData();
|
||||||
@ -845,9 +754,6 @@ void Layouts::save()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//! update SharedLayouts that are Active
|
|
||||||
syncActiveShares();
|
|
||||||
|
|
||||||
//! reload layouts in layoutsmanager
|
//! reload layouts in layoutsmanager
|
||||||
m_handler->corona()->layoutsManager()->synchronizer()->loadLayouts();
|
m_handler->corona()->layoutsManager()->synchronizer()->loadLayouts();
|
||||||
|
|
||||||
@ -879,38 +785,6 @@ void Layouts::save()
|
|||||||
emit dataChanged();
|
emit dataChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Layouts::syncActiveShares()
|
|
||||||
{
|
|
||||||
if (m_handler->corona()->layoutsManager()->memoryUsage() != MemoryUsage::MultipleLayouts) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Latte::Data::LayoutsTable currentLayoutsData = m_model->currentLayoutsData();
|
|
||||||
Latte::Data::LayoutsTable originalLayoutsData = m_model->originalLayoutsData();
|
|
||||||
|
|
||||||
Latte::Layouts::SharesMap currentSharesNamesMap = currentLayoutsData.sharesMap();
|
|
||||||
QStringList originalSharesIds = originalLayoutsData.allSharesIds();
|
|
||||||
QStringList currentSharesIds = currentLayoutsData.allSharesIds();
|
|
||||||
|
|
||||||
QStringList deprecatedSharesIds = Latte::subtracted(originalSharesIds, currentSharesIds);
|
|
||||||
QStringList deprecatedSharesNames;
|
|
||||||
|
|
||||||
for(int i=0; i<deprecatedSharesIds.count(); ++i) {
|
|
||||||
QString shareId = deprecatedSharesIds[i];
|
|
||||||
|
|
||||||
if (currentLayoutsData.containsId(shareId)) {
|
|
||||||
deprecatedSharesNames << currentLayoutsData[shareId].name;
|
|
||||||
} else if (originalLayoutsData.containsId(shareId)) {
|
|
||||||
deprecatedSharesNames << originalLayoutsData[shareId].name;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
qDebug() << " CURRENT SHARES NAMES MAP :: " << currentSharesNamesMap;
|
|
||||||
qDebug() << " DEPRECATED SHARES ::";
|
|
||||||
|
|
||||||
m_handler->corona()->layoutsManager()->synchronizer()->syncActiveShares(currentSharesNamesMap, deprecatedSharesNames);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Layouts::storeColumnWidths()
|
void Layouts::storeColumnWidths()
|
||||||
{
|
{
|
||||||
//! save column widths
|
//! save column widths
|
||||||
|
@ -83,7 +83,6 @@ public:
|
|||||||
void loadLayouts();
|
void loadLayouts();
|
||||||
void removeSelected();
|
void removeSelected();
|
||||||
void toggleLockedForSelected();
|
void toggleLockedForSelected();
|
||||||
void toggleSharedForSelected();
|
|
||||||
|
|
||||||
QString iconsPath() const;
|
QString iconsPath() const;
|
||||||
QString colorPath(const QString color) const;
|
QString colorPath(const QString color) const;
|
||||||
@ -101,10 +100,6 @@ public:
|
|||||||
signals:
|
signals:
|
||||||
void dataChanged();
|
void dataChanged();
|
||||||
|
|
||||||
public slots:
|
|
||||||
//! needed for Delegate::Shared
|
|
||||||
void onSharedToInEditChanged(const QString &row, const bool &inEdit);
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void loadConfig();
|
void loadConfig();
|
||||||
void saveConfig();
|
void saveConfig();
|
||||||
@ -115,7 +110,6 @@ private slots:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void initView();
|
void initView();
|
||||||
void syncActiveShares();
|
|
||||||
|
|
||||||
int rowForId(QString id) const;
|
int rowForId(QString id) const;
|
||||||
int rowForName(QString layoutName) const;
|
int rowForName(QString layoutName) const;
|
||||||
|
@ -6,7 +6,6 @@ set(lattedock-app_SRCS
|
|||||||
${CMAKE_CURRENT_SOURCE_DIR}/checkboxdelegate.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/checkboxdelegate.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/layoutcmbitemdelegate.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/layoutcmbitemdelegate.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/layoutnamedelegate.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/layoutnamedelegate.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/shareddelegate.cpp
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/persistentmenu.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/persistentmenu.cpp
|
||||||
PARENT_SCOPE
|
PARENT_SCOPE
|
||||||
)
|
)
|
||||||
|
@ -203,12 +203,6 @@ bool Activities::editorEvent(QEvent *event, QAbstractItemModel *model, const QSt
|
|||||||
Q_ASSERT(event);
|
Q_ASSERT(event);
|
||||||
Q_ASSERT(model);
|
Q_ASSERT(model);
|
||||||
|
|
||||||
bool isSharedCapable = index.data(Model::Layouts::ISSHAREDROLE).toBool() && index.data(Model::Layouts::INMULTIPLELAYOUTSROLE).toBool();
|
|
||||||
|
|
||||||
if (isSharedCapable) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return QStyledItemDelegate::editorEvent(event, model, option, index);
|
return QStyledItemDelegate::editorEvent(event, model, option, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -219,114 +213,55 @@ void Activities::paint(QPainter *painter, const QStyleOptionViewItem &option, co
|
|||||||
myOptions.state = (myOptions.state & ~QStyle::State_HasFocus);
|
myOptions.state = (myOptions.state & ~QStyle::State_HasFocus);
|
||||||
|
|
||||||
bool isLayoutActive = index.data(Model::Layouts::ISACTIVEROLE).toBool();
|
bool isLayoutActive = index.data(Model::Layouts::ISACTIVEROLE).toBool();
|
||||||
bool isSharedCapable = index.data(Model::Layouts::ISSHAREDROLE).toBool() && index.data(Model::Layouts::INMULTIPLELAYOUTSROLE).toBool();
|
|
||||||
|
|
||||||
if (!isSharedCapable) {
|
painter->save();
|
||||||
painter->save();
|
|
||||||
|
|
||||||
QList<Latte::Data::Activity> assignedActivities;
|
QList<Latte::Data::Activity> assignedActivities;
|
||||||
QStringList assignedIds = index.model()->data(index, Qt::UserRole).toStringList();
|
QStringList assignedIds = index.model()->data(index, Qt::UserRole).toStringList();
|
||||||
QStringList assignedOriginalIds = index.model()->data(index, Model::Layouts::ORIGINALASSIGNEDACTIVITIESROLE).toStringList();
|
QStringList assignedOriginalIds = index.model()->data(index, Model::Layouts::ORIGINALASSIGNEDACTIVITIESROLE).toStringList();
|
||||||
|
|
||||||
Latte::Data::ActivitiesMap allActivitiesData = index.data(Model::Layouts::ALLACTIVITIESDATAROLE).value<Latte::Data::ActivitiesMap>();
|
Latte::Data::ActivitiesMap allActivitiesData = index.data(Model::Layouts::ALLACTIVITIESDATAROLE).value<Latte::Data::ActivitiesMap>();
|
||||||
|
|
||||||
for (int i=0; i<assignedIds.count(); ++i) {
|
for (int i=0; i<assignedIds.count(); ++i) {
|
||||||
assignedActivities << allActivitiesData[assignedIds[i]];
|
assignedActivities << allActivitiesData[assignedIds[i]];
|
||||||
}
|
|
||||||
|
|
||||||
if (assignedActivities.count() > 0) {
|
|
||||||
myOptions.text = joinedActivities(assignedActivities, assignedOriginalIds, isLayoutActive);
|
|
||||||
|
|
||||||
QTextDocument doc;
|
|
||||||
QString css;
|
|
||||||
QString activitiesText = myOptions.text;
|
|
||||||
|
|
||||||
QPalette::ColorRole applyColor = Latte::isSelected(option) ? QPalette::HighlightedText : QPalette::Text;
|
|
||||||
QBrush nBrush = option.palette.brush(Latte::colorGroup(option), applyColor);
|
|
||||||
|
|
||||||
css = QString("body { color : %1; }").arg(nBrush.color().name());
|
|
||||||
|
|
||||||
doc.setDefaultStyleSheet(css);
|
|
||||||
doc.setHtml("<body>" + myOptions.text + "</body>");
|
|
||||||
|
|
||||||
myOptions.text = "";
|
|
||||||
myOptions.widget->style()->drawControl(QStyle::CE_ItemViewItem, &myOptions, painter);
|
|
||||||
|
|
||||||
//we need an offset to be in the same vertical center of TextEdit
|
|
||||||
int offsetY = ((myOptions.rect.height() - doc.size().height()) / 2);
|
|
||||||
|
|
||||||
if ((qApp->layoutDirection() == Qt::RightToLeft) && !activitiesText.isEmpty()) {
|
|
||||||
int textWidth = doc.size().width();
|
|
||||||
|
|
||||||
painter->translate(qMax(myOptions.rect.left(), myOptions.rect.right() - textWidth), myOptions.rect.top() + offsetY + 1);
|
|
||||||
} else {
|
|
||||||
painter->translate(myOptions.rect.left(), myOptions.rect.top() + offsetY + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
QRect clip(0, 0, myOptions.rect.width(), myOptions.rect.height());
|
|
||||||
doc.drawContents(painter, clip);
|
|
||||||
} else {
|
|
||||||
QApplication::style()->drawControl(QStyle::CE_ItemViewItem, &myOptions, painter);
|
|
||||||
}
|
|
||||||
|
|
||||||
painter->restore();
|
|
||||||
} else {
|
|
||||||
bool sharedInEdit = index.data(Model::Layouts::SHAREDTOINEDITROLE).toBool();
|
|
||||||
|
|
||||||
// Disabled
|
|
||||||
bool isSelected{Latte::isSelected(option)};
|
|
||||||
QPalette::ColorRole backColorRole = isSelected ? QPalette::Highlight : QPalette::Base;
|
|
||||||
QPalette::ColorRole textColorRole = isSelected ? QPalette::HighlightedText : QPalette::Text;
|
|
||||||
|
|
||||||
//! draw background
|
|
||||||
//! HIDDENTEXTCOLUMN is just needed to draw empty background rectangles properly based on states
|
|
||||||
QStyledItemDelegate::paint(painter, option, index.model()->index(index.row(), Model::Layouts::HIDDENTEXTCOLUMN));
|
|
||||||
|
|
||||||
// text
|
|
||||||
QPen pen(Qt::DotLine);
|
|
||||||
QColor textColor = option.palette.brush(Latte::colorGroup(option), textColorRole).color();
|
|
||||||
|
|
||||||
pen.setWidth(2); pen.setColor(textColor);
|
|
||||||
int y = option.rect.y()+option.rect.height()/2;
|
|
||||||
|
|
||||||
int space = option.rect.height() / 2;
|
|
||||||
|
|
||||||
painter->setPen(pen);
|
|
||||||
|
|
||||||
if (sharedInEdit) {
|
|
||||||
//! shareto cell is in edit mode so circle indicator is moved inside
|
|
||||||
//! the activities cell
|
|
||||||
if (qApp->layoutDirection() == Qt::LeftToRight) {
|
|
||||||
painter->drawLine(option.rect.x(), y, option.rect.x()+option.rect.width() - space, y);
|
|
||||||
|
|
||||||
int xm = option.rect.x() + option.rect.width() - space;
|
|
||||||
int thick = option.rect.height() / 2;
|
|
||||||
int ym = option.rect.y() + ((option.rect.height() - thick) / 2);
|
|
||||||
|
|
||||||
pen.setStyle(Qt::SolidLine);
|
|
||||||
painter->setPen(pen);
|
|
||||||
painter->setBrush(textColor);
|
|
||||||
|
|
||||||
//! draw ending cirlce
|
|
||||||
painter->drawEllipse(QPoint(xm, ym + thick/2), thick/4, thick/4);
|
|
||||||
} else {
|
|
||||||
painter->drawLine(option.rect.x() + space, y, option.rect.x() + option.rect.width(), y);
|
|
||||||
|
|
||||||
int xm = option.rect.x() + space;
|
|
||||||
int thick = option.rect.height() / 2;
|
|
||||||
int ym = option.rect.y() + ((option.rect.height() - thick) / 2);
|
|
||||||
|
|
||||||
pen.setStyle(Qt::SolidLine);
|
|
||||||
painter->setPen(pen);
|
|
||||||
painter->setBrush(textColor);
|
|
||||||
|
|
||||||
//! draw ending cirlce
|
|
||||||
painter->drawEllipse(QPoint(xm, ym + thick/2), thick/4, thick/4);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
painter->drawLine(option.rect.x(), y, option.rect.x()+option.rect.width(), y);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (assignedActivities.count() > 0) {
|
||||||
|
myOptions.text = joinedActivities(assignedActivities, assignedOriginalIds, isLayoutActive);
|
||||||
|
|
||||||
|
QTextDocument doc;
|
||||||
|
QString css;
|
||||||
|
QString activitiesText = myOptions.text;
|
||||||
|
|
||||||
|
QPalette::ColorRole applyColor = Latte::isSelected(option) ? QPalette::HighlightedText : QPalette::Text;
|
||||||
|
QBrush nBrush = option.palette.brush(Latte::colorGroup(option), applyColor);
|
||||||
|
|
||||||
|
css = QString("body { color : %1; }").arg(nBrush.color().name());
|
||||||
|
|
||||||
|
doc.setDefaultStyleSheet(css);
|
||||||
|
doc.setHtml("<body>" + myOptions.text + "</body>");
|
||||||
|
|
||||||
|
myOptions.text = "";
|
||||||
|
myOptions.widget->style()->drawControl(QStyle::CE_ItemViewItem, &myOptions, painter);
|
||||||
|
|
||||||
|
//we need an offset to be in the same vertical center of TextEdit
|
||||||
|
int offsetY = ((myOptions.rect.height() - doc.size().height()) / 2);
|
||||||
|
|
||||||
|
if ((qApp->layoutDirection() == Qt::RightToLeft) && !activitiesText.isEmpty()) {
|
||||||
|
int textWidth = doc.size().width();
|
||||||
|
|
||||||
|
painter->translate(qMax(myOptions.rect.left(), myOptions.rect.right() - textWidth), myOptions.rect.top() + offsetY + 1);
|
||||||
|
} else {
|
||||||
|
painter->translate(myOptions.rect.left(), myOptions.rect.top() + offsetY + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
QRect clip(0, 0, myOptions.rect.width(), myOptions.rect.height());
|
||||||
|
doc.drawContents(painter, clip);
|
||||||
|
} else {
|
||||||
|
QApplication::style()->drawControl(QStyle::CE_ItemViewItem, &myOptions, painter);
|
||||||
|
}
|
||||||
|
|
||||||
|
painter->restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Activities::joinedActivities(const QList<Latte::Data::Activity> &activities, const QStringList &originalIds, bool isActive, bool formatText) const
|
QString Activities::joinedActivities(const QList<Latte::Data::Activity> &activities, const QStringList &originalIds, bool isActive, bool formatText) const
|
||||||
|
@ -52,100 +52,42 @@ void CheckBox::paint(QPainter *painter, const QStyleOptionViewItem &option, cons
|
|||||||
adjustedOption.state = (adjustedOption.state & ~QStyle::State_HasFocus);
|
adjustedOption.state = (adjustedOption.state & ~QStyle::State_HasFocus);
|
||||||
adjustedOption.displayAlignment = Qt::AlignHCenter | Qt::AlignVCenter;
|
adjustedOption.displayAlignment = Qt::AlignHCenter | Qt::AlignVCenter;
|
||||||
|
|
||||||
bool isSharedCapable = index.data(Model::Layouts::ISSHAREDROLE).toBool() && index.data(Model::Layouts::INMULTIPLELAYOUTSROLE).toBool();
|
bool originalChecked{false};
|
||||||
|
bool currentChecked = index.data(Qt::UserRole).toBool();
|
||||||
|
|
||||||
if (!isSharedCapable) {
|
if (index.column() == Model::Layouts::MENUCOLUMN) {
|
||||||
bool originalChecked{false};
|
originalChecked = index.data(Model::Layouts::ORIGINALISSHOWNINMENUROLE).toBool();
|
||||||
bool currentChecked = index.data(Qt::UserRole).toBool();
|
} else if (index.column() == Model::Layouts::BORDERSCOLUMN) {
|
||||||
|
originalChecked = index.data(Model::Layouts::ORIGINALHASBORDERSROLE).toBool();
|
||||||
if (index.column() == Model::Layouts::MENUCOLUMN) {
|
|
||||||
originalChecked = index.data(Model::Layouts::ORIGINALISSHOWNINMENUROLE).toBool();
|
|
||||||
} else if (index.column() == Model::Layouts::BORDERSCOLUMN) {
|
|
||||||
originalChecked = index.data(Model::Layouts::ORIGINALHASBORDERSROLE).toBool();
|
|
||||||
} else {
|
|
||||||
originalChecked = currentChecked;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isChanged = (originalChecked != currentChecked);
|
|
||||||
|
|
||||||
if (isChanged) {
|
|
||||||
adjustedOption.font.setPointSize(adjustedOption.font.pointSize() + 2);
|
|
||||||
adjustedOption.font.setBold(true);
|
|
||||||
} else {
|
|
||||||
// normal appearance
|
|
||||||
}
|
|
||||||
|
|
||||||
if (currentChecked) {
|
|
||||||
adjustedOption.text = isChanged ? HeavyCheckMark : CheckMark;
|
|
||||||
} else {
|
|
||||||
adjustedOption.text = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QStyledItemDelegate::paint(painter, adjustedOption, index);
|
|
||||||
} else {
|
} else {
|
||||||
// Disabled
|
originalChecked = currentChecked;
|
||||||
bool isSelected{Latte::isSelected(option)};
|
|
||||||
QPalette::ColorRole backColorRole = isSelected ? QPalette::Highlight : QPalette::Base;
|
|
||||||
QPalette::ColorRole textColorRole = isSelected ? QPalette::HighlightedText : QPalette::Text;
|
|
||||||
|
|
||||||
//! draw background
|
|
||||||
//! HIDDENTEXTCOLUMN is just needed to draw empty background rectangles properly based on states
|
|
||||||
QStyledItemDelegate::paint(painter, option, index.model()->index(index.row(), Model::Layouts::HIDDENTEXTCOLUMN));
|
|
||||||
|
|
||||||
// text
|
|
||||||
QPen pen(Qt::DotLine);
|
|
||||||
pen.setWidth(2); pen.setColor(option.palette.brush(Latte::colorGroup(option), textColorRole).color());
|
|
||||||
int y = option.rect.y()+option.rect.height()/2;
|
|
||||||
|
|
||||||
bool inMenu = (index.column() == Model::Layouts::MENUCOLUMN);
|
|
||||||
int space = inMenu ? option.rect.height() / 2 : 0;
|
|
||||||
|
|
||||||
painter->setPen(pen);
|
|
||||||
|
|
||||||
if (qApp->layoutDirection() == Qt::LeftToRight) {
|
|
||||||
painter->drawLine(option.rect.x() + space, y,
|
|
||||||
option.rect.x() + option.rect.width(), y);
|
|
||||||
|
|
||||||
if (inMenu) {
|
|
||||||
int xm = option.rect.x() + space;
|
|
||||||
int thick = option.rect.height() / 2;
|
|
||||||
int ym = option.rect.y() + ((option.rect.height() - thick) / 2);
|
|
||||||
|
|
||||||
pen.setStyle(Qt::SolidLine);
|
|
||||||
painter->setPen(pen);
|
|
||||||
painter->drawLine(xm, ym, xm, ym + thick);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
painter->drawLine(option.rect.x(), y,
|
|
||||||
option.rect.x()+option.rect.width() - space, y);
|
|
||||||
|
|
||||||
if (inMenu) {
|
|
||||||
int xm = option.rect.x() + option.rect.width() - space;
|
|
||||||
int thick = option.rect.height() / 2;
|
|
||||||
int ym = option.rect.y() + ((option.rect.height() - thick) / 2);
|
|
||||||
|
|
||||||
pen.setStyle(Qt::SolidLine);
|
|
||||||
painter->setPen(pen);
|
|
||||||
painter->drawLine(xm, ym, xm, ym + thick);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isChanged = (originalChecked != currentChecked);
|
||||||
|
|
||||||
|
if (isChanged) {
|
||||||
|
adjustedOption.font.setPointSize(adjustedOption.font.pointSize() + 2);
|
||||||
|
adjustedOption.font.setBold(true);
|
||||||
|
} else {
|
||||||
|
// normal appearance
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentChecked) {
|
||||||
|
adjustedOption.text = isChanged ? HeavyCheckMark : CheckMark;
|
||||||
|
} else {
|
||||||
|
adjustedOption.text = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QStyledItemDelegate::paint(painter, adjustedOption, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CheckBox::editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option,
|
bool CheckBox::editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option,
|
||||||
const QModelIndex &index)
|
const QModelIndex &index)
|
||||||
{
|
{
|
||||||
Q_ASSERT(event);
|
Q_ASSERT(event);
|
||||||
Q_ASSERT(model);
|
Q_ASSERT(model);
|
||||||
|
|
||||||
bool isSharedCapable = index.data(Model::Layouts::ISSHAREDROLE).toBool() && index.data(Model::Layouts::INMULTIPLELAYOUTSROLE).toBool();
|
|
||||||
|
|
||||||
if (isSharedCapable) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (event->type() == QEvent::MouseButtonDblClick) {
|
if (event->type() == QEvent::MouseButtonDblClick) {
|
||||||
if (!option.rect.contains(static_cast<QMouseEvent *>(event)->pos()))
|
if (!option.rect.contains(static_cast<QMouseEvent *>(event)->pos()))
|
||||||
return false;
|
return false;
|
||||||
|
@ -76,7 +76,6 @@ void LayoutName::paint(QPainter *painter, const QStyleOptionViewItem &option, co
|
|||||||
bool inMultiple = index.data(Model::Layouts::INMULTIPLELAYOUTSROLE).toBool();
|
bool inMultiple = index.data(Model::Layouts::INMULTIPLELAYOUTSROLE).toBool();
|
||||||
|
|
||||||
bool isLocked = index.data(Model::Layouts::ISLOCKEDROLE).toBool();
|
bool isLocked = index.data(Model::Layouts::ISLOCKEDROLE).toBool();
|
||||||
bool isShared = inMultiple && index.data(Model::Layouts::ISSHAREDROLE).toBool();
|
|
||||||
bool isActive = index.data(Model::Layouts::ISACTIVEROLE).toBool();
|
bool isActive = index.data(Model::Layouts::ISACTIVEROLE).toBool();
|
||||||
|
|
||||||
bool isNewLayout = index.data(Model::Layouts::ISNEWLAYOUTROLE).toBool();
|
bool isNewLayout = index.data(Model::Layouts::ISNEWLAYOUTROLE).toBool();
|
||||||
@ -86,8 +85,6 @@ void LayoutName::paint(QPainter *painter, const QStyleOptionViewItem &option, co
|
|||||||
|
|
||||||
bool isChanged = (isNewLayout || hasChanges);
|
bool isChanged = (isNewLayout || hasChanges);
|
||||||
|
|
||||||
bool showTwoIcons = isLocked && isShared;
|
|
||||||
|
|
||||||
QStyleOptionViewItem adjustedOption = option;
|
QStyleOptionViewItem adjustedOption = option;
|
||||||
|
|
||||||
//! Remove the focus dotted lines
|
//! Remove the focus dotted lines
|
||||||
@ -96,7 +93,7 @@ void LayoutName::paint(QPainter *painter, const QStyleOptionViewItem &option, co
|
|||||||
|
|
||||||
painter->setRenderHint(QPainter::Antialiasing, true);
|
painter->setRenderHint(QPainter::Antialiasing, true);
|
||||||
|
|
||||||
if (isLocked || isShared) {
|
if (isLocked) {
|
||||||
QStandardItemModel *model = (QStandardItemModel *) index.model();
|
QStandardItemModel *model = (QStandardItemModel *) index.model();
|
||||||
|
|
||||||
|
|
||||||
@ -110,7 +107,7 @@ void LayoutName::paint(QPainter *painter, const QStyleOptionViewItem &option, co
|
|||||||
QFontMetrics fm(option.font);
|
QFontMetrics fm(option.font);
|
||||||
int textWidth = fm.boundingRect(name).width();
|
int textWidth = fm.boundingRect(name).width();
|
||||||
int thick = option.rect.height();
|
int thick = option.rect.height();
|
||||||
int length = showTwoIcons ? (2 * thick + 2) : thick;
|
int length = thick;
|
||||||
|
|
||||||
int startWidth = (qApp->layoutDirection() == Qt::RightToLeft) ? length : 0;
|
int startWidth = (qApp->layoutDirection() == Qt::RightToLeft) ? length : 0;
|
||||||
int endWidth = (qApp->layoutDirection() == Qt::RightToLeft) ? 0 : length;
|
int endWidth = (qApp->layoutDirection() == Qt::RightToLeft) ? 0 : length;
|
||||||
@ -137,24 +134,15 @@ void LayoutName::paint(QPainter *painter, const QStyleOptionViewItem &option, co
|
|||||||
QStyledItemDelegate::paint(painter, myOptionS, model->index(index.row(), Model::Layouts::HIDDENTEXTCOLUMN));
|
QStyledItemDelegate::paint(painter, myOptionS, model->index(index.row(), Model::Layouts::HIDDENTEXTCOLUMN));
|
||||||
QStyledItemDelegate::paint(painter, myOptionE, model->index(index.row(), Model::Layouts::HIDDENTEXTCOLUMN));
|
QStyledItemDelegate::paint(painter, myOptionE, model->index(index.row(), Model::Layouts::HIDDENTEXTCOLUMN));
|
||||||
|
|
||||||
//! Lock Icon
|
|
||||||
QIcon firstIcon = isLocked && !showTwoIcons ? QIcon::fromTheme("object-locked") : QIcon::fromTheme("document-share");
|
|
||||||
|
|
||||||
QIcon::Mode mode = ((active && (selected || focused)) ? QIcon::Selected : QIcon::Normal);
|
QIcon::Mode mode = ((active && (selected || focused)) ? QIcon::Selected : QIcon::Normal);
|
||||||
|
|
||||||
if (qApp->layoutDirection() == Qt::RightToLeft) {
|
if (isLocked) {
|
||||||
painter->drawPixmap(QRect(option.rect.x(), option.rect.y(), thick, thick), firstIcon.pixmap(thick, thick, mode));
|
QIcon lockIcon = QIcon::fromTheme("object-locked");
|
||||||
|
|
||||||
if (showTwoIcons) {
|
if (qApp->layoutDirection() == Qt::RightToLeft) {
|
||||||
QIcon secondIcon = QIcon::fromTheme("object-locked");
|
painter->drawPixmap(QRect(option.rect.x(), option.rect.y(), thick, thick), lockIcon.pixmap(thick, thick, mode));
|
||||||
painter->drawPixmap(QRect(option.rect.x() + thick + 2, option.rect.y(), thick, thick), secondIcon.pixmap(thick, thick, mode));
|
} else {
|
||||||
}
|
painter->drawPixmap(QRect(option.rect.x() + option.rect.width() - endWidth, option.rect.y(), thick, thick), lockIcon.pixmap(thick, thick, mode));
|
||||||
} else {
|
|
||||||
painter->drawPixmap(QRect(option.rect.x() + option.rect.width() - endWidth, option.rect.y(), thick, thick), firstIcon.pixmap(thick, thick, mode));
|
|
||||||
|
|
||||||
if (showTwoIcons) {
|
|
||||||
QIcon secondIcon = QIcon::fromTheme("object-locked");
|
|
||||||
painter->drawPixmap(QRect(option.rect.x() + option.rect.width() - thick, option.rect.y(), thick, thick), secondIcon.pixmap(thick, thick, mode));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,342 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2019 Michail Vourlakos <mvourlakos@gmail.com>
|
|
||||||
*
|
|
||||||
* This file is part of Latte-Dock
|
|
||||||
*
|
|
||||||
* Latte-Dock is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU General Public License as
|
|
||||||
* published by the Free Software Foundation; either version 2 of
|
|
||||||
* the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Latte-Dock is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "shareddelegate.h"
|
|
||||||
|
|
||||||
// local
|
|
||||||
#include "persistentmenu.h"
|
|
||||||
#include "../models/layoutsmodel.h"
|
|
||||||
#include "../tools/settingstools.h"
|
|
||||||
#include "../../data/layoutdata.h"
|
|
||||||
|
|
||||||
// Qt
|
|
||||||
#include <QAction>
|
|
||||||
#include <QApplication>
|
|
||||||
#include <QComboBox>
|
|
||||||
#include <QDebug>
|
|
||||||
#include <QDialogButtonBox>
|
|
||||||
#include <QMenu>
|
|
||||||
#include <QModelIndex>
|
|
||||||
#include <QPainter>
|
|
||||||
#include <QPushButton>
|
|
||||||
#include <QString>
|
|
||||||
#include <QTextDocument>
|
|
||||||
#include <QWidgetAction>
|
|
||||||
|
|
||||||
#define OKPRESSED "OKPRESSED"
|
|
||||||
|
|
||||||
namespace Latte {
|
|
||||||
namespace Settings {
|
|
||||||
namespace Layout {
|
|
||||||
namespace Delegate {
|
|
||||||
|
|
||||||
|
|
||||||
Shared::Shared(Controller::Layouts *parent)
|
|
||||||
: QStyledItemDelegate(parent),
|
|
||||||
m_controller(parent)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
QWidget *Shared::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const
|
|
||||||
{
|
|
||||||
bool inMultiple = index.data(Model::Layouts::INMULTIPLELAYOUTSROLE).toBool();
|
|
||||||
|
|
||||||
QString layoutId = index.data(Model::Layouts::IDROLE).toString();
|
|
||||||
Latte::Data::LayoutsTable allLayouts = qvariant_cast<Latte::Data::LayoutsTable>(index.data(Model::Layouts::ALLLAYOUTSROLE));
|
|
||||||
QStringList assignedShares = index.data(Qt::UserRole).toStringList();
|
|
||||||
|
|
||||||
QPushButton *button = new QPushButton(parent);
|
|
||||||
PersistentMenu *menu = new PersistentMenu(button);
|
|
||||||
button->setMenu(menu);
|
|
||||||
|
|
||||||
menu->setMinimumWidth(option.rect.width());
|
|
||||||
|
|
||||||
for (int i = 0; i < allLayouts.rowCount(); ++i) {
|
|
||||||
if ((inMultiple && allLayouts[i].isShared()) || (allLayouts[i].id == layoutId)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
QAction *action = new QAction(allLayouts[i].name);
|
|
||||||
action->setData(allLayouts[i].id);
|
|
||||||
action->setCheckable(true);
|
|
||||||
action->setChecked(assignedShares.contains(allLayouts[i].id));
|
|
||||||
|
|
||||||
if (allLayouts[i].isActive) {
|
|
||||||
QFont font = action->font();
|
|
||||||
font.setBold(true);
|
|
||||||
action->setFont(font);
|
|
||||||
}
|
|
||||||
|
|
||||||
menu->addAction(action);
|
|
||||||
|
|
||||||
connect(action, &QAction::toggled, this, [this, button, index]() {
|
|
||||||
updateButtonText(button, index);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
updateButtonText(button, index);
|
|
||||||
|
|
||||||
m_controller->onSharedToInEditChanged(layoutId, true);
|
|
||||||
|
|
||||||
//! Ok, Apply Buttons behavior
|
|
||||||
menu->addSeparator();
|
|
||||||
|
|
||||||
QDialogButtonBox *menuDialogButtons = new QDialogButtonBox(menu);
|
|
||||||
menuDialogButtons->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
|
||||||
menuDialogButtons->setContentsMargins(3, 0, 3, 3);
|
|
||||||
|
|
||||||
QWidgetAction* menuDialogButtonsWidgetAction = new QWidgetAction(menu);
|
|
||||||
menuDialogButtonsWidgetAction->setDefaultWidget(menuDialogButtons);
|
|
||||||
|
|
||||||
menu->addAction(menuDialogButtonsWidgetAction);
|
|
||||||
|
|
||||||
connect(menuDialogButtons->button(QDialogButtonBox::Ok), &QPushButton::clicked, [this, menu, button]() {
|
|
||||||
button->setProperty(OKPRESSED, true);
|
|
||||||
menu->hide();
|
|
||||||
});
|
|
||||||
|
|
||||||
connect(menuDialogButtons->button(QDialogButtonBox::Cancel), &QPushButton::clicked, menu, &QMenu::hide);
|
|
||||||
connect(menu, &QMenu::aboutToHide, button, &QWidget::clearFocus);
|
|
||||||
|
|
||||||
return button;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Shared::setEditorData(QWidget *editor, const QModelIndex &index) const
|
|
||||||
{
|
|
||||||
Latte::Data::LayoutsTable allLayouts = qvariant_cast<Latte::Data::LayoutsTable>(index.data(Model::Layouts::ALLLAYOUTSROLE));
|
|
||||||
updateButtonText(editor, index);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Shared::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
|
|
||||||
{
|
|
||||||
QPushButton *button = static_cast<QPushButton *>(editor);
|
|
||||||
|
|
||||||
QString layoutId = index.data(Model::Layouts::IDROLE).toString();
|
|
||||||
|
|
||||||
if (button->property(OKPRESSED).isNull() || !button->property(OKPRESSED).toBool()) {
|
|
||||||
m_controller->onSharedToInEditChanged(layoutId, false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
QStringList assignedLayouts;
|
|
||||||
foreach (QAction *action, button->menu()->actions()) {
|
|
||||||
if (action->isChecked()) {
|
|
||||||
assignedLayouts << action->data().toString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
model->setData(index, assignedLayouts, Qt::UserRole);
|
|
||||||
|
|
||||||
m_controller->onSharedToInEditChanged(layoutId, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Shared::updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const
|
|
||||||
{
|
|
||||||
Q_UNUSED(index)
|
|
||||||
|
|
||||||
editor->setGeometry(option.rect);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Shared::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
|
|
||||||
{
|
|
||||||
bool sharedInEdit = index.data(Model::Layouts::SHAREDTOINEDITROLE).toBool();
|
|
||||||
Latte::Data::LayoutsTable allLayouts = qvariant_cast<Latte::Data::LayoutsTable>(index.data(Model::Layouts::ALLLAYOUTSROLE));
|
|
||||||
QStringList assignedIds = index.data(Qt::UserRole).toStringList();
|
|
||||||
QStringList originalIds = index.data(Model::Layouts::ORIGINALSHARESROLE).toStringList();
|
|
||||||
|
|
||||||
Latte::Data::LayoutsTable assignedLayouts;
|
|
||||||
|
|
||||||
for (const auto &id : assignedIds) {
|
|
||||||
if (allLayouts.containsId(id)) {
|
|
||||||
assignedLayouts << allLayouts[id];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QStyleOptionViewItem myOptions = option;
|
|
||||||
//! Remove the focus dotted lines
|
|
||||||
myOptions.state = (myOptions.state & ~QStyle::State_HasFocus);
|
|
||||||
painter->save();
|
|
||||||
|
|
||||||
if (assignedLayouts.rowCount() > 0 && !sharedInEdit) {
|
|
||||||
//! indicator
|
|
||||||
if (!sharedInEdit) {
|
|
||||||
paintSharedToIndicator(painter, myOptions, index);
|
|
||||||
}
|
|
||||||
|
|
||||||
//! Text code
|
|
||||||
myOptions.text = joined(assignedLayouts, originalIds);
|
|
||||||
|
|
||||||
int thick = option.rect.height();
|
|
||||||
|
|
||||||
if (qApp->layoutDirection() == Qt::LeftToRight) {
|
|
||||||
myOptions.rect = QRect(myOptions.rect.x() + thick, myOptions.rect.y(), myOptions.rect.width() - thick, myOptions.rect.height());
|
|
||||||
} else {
|
|
||||||
myOptions.rect = QRect(myOptions.rect.x(), myOptions.rect.y(), myOptions.rect.width() - thick, myOptions.rect.height());
|
|
||||||
}
|
|
||||||
|
|
||||||
QTextDocument doc;
|
|
||||||
QString css;
|
|
||||||
QString sharesText = myOptions.text;
|
|
||||||
|
|
||||||
QPalette::ColorRole applyColor = Latte::isSelected(option) ? QPalette::HighlightedText : QPalette::Text;
|
|
||||||
QBrush nBrush = option.palette.brush(Latte::colorGroup(option), applyColor);
|
|
||||||
|
|
||||||
css = QString("body { color : %1; }").arg(nBrush.color().name());
|
|
||||||
|
|
||||||
doc.setDefaultStyleSheet(css);
|
|
||||||
doc.setHtml("<body>" + myOptions.text + "</body>");
|
|
||||||
|
|
||||||
myOptions.text = "";
|
|
||||||
myOptions.widget->style()->drawControl(QStyle::CE_ItemViewItem, &myOptions, painter);
|
|
||||||
|
|
||||||
//we need an offset to be in the same vertical center of TextEdit
|
|
||||||
int offsetY = ((myOptions.rect.height() - doc.size().height()) / 2);
|
|
||||||
|
|
||||||
if ((qApp->layoutDirection() == Qt::RightToLeft) && !sharesText.isEmpty()) {
|
|
||||||
int textWidth = doc.size().width();
|
|
||||||
|
|
||||||
painter->translate(qMax(myOptions.rect.left(), myOptions.rect.right() - textWidth), myOptions.rect.top() + offsetY + 1);
|
|
||||||
} else {
|
|
||||||
painter->translate(myOptions.rect.left(), myOptions.rect.top() + offsetY + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
QRect clip(0, 0, myOptions.rect.width(), myOptions.rect.height());
|
|
||||||
doc.drawContents(painter, clip);
|
|
||||||
} else {
|
|
||||||
QApplication::style()->drawControl(QStyle::CE_ItemViewItem, &myOptions, painter);
|
|
||||||
}
|
|
||||||
|
|
||||||
painter->restore();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Shared::paintSharedToIndicator(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
|
|
||||||
{
|
|
||||||
// Disabled
|
|
||||||
bool isSelected{Latte::isSelected(option)};
|
|
||||||
QPalette::ColorRole backColorRole = isSelected ? QPalette::Highlight : QPalette::Base;
|
|
||||||
QPalette::ColorRole textColorRole = isSelected ? QPalette::HighlightedText : QPalette::Text;
|
|
||||||
|
|
||||||
int space = option.rect.height() / 2;
|
|
||||||
|
|
||||||
//! draw background below icons
|
|
||||||
//! HIDDENTEXTCOLUMN is just needed to draw empty background rectangles properly based on states
|
|
||||||
QStyleOptionViewItem backOptions = option;
|
|
||||||
if (qApp->layoutDirection() == Qt::LeftToRight) {
|
|
||||||
backOptions.rect = QRect(option.rect.x(), option.rect.y(), 2 * space, 2 * space);
|
|
||||||
} else {
|
|
||||||
backOptions.rect = QRect(option.rect.x() + option.rect.width() - (2*space), option.rect.y(), 2 * space, 2 * space);
|
|
||||||
}
|
|
||||||
|
|
||||||
QStyledItemDelegate::paint(painter, backOptions, index.model()->index(index.row(), Model::Layouts::HIDDENTEXTCOLUMN));
|
|
||||||
|
|
||||||
// text
|
|
||||||
QPen pen(Qt::DotLine);
|
|
||||||
QColor textColor = option.palette.brush(Latte::colorGroup(option), textColorRole).color();
|
|
||||||
|
|
||||||
pen.setWidth(2); pen.setColor(textColor);
|
|
||||||
int y = option.rect.y()+option.rect.height()/2;
|
|
||||||
|
|
||||||
painter->setPen(pen);
|
|
||||||
|
|
||||||
if (qApp->layoutDirection() == Qt::LeftToRight) {
|
|
||||||
int xStart = option.rect.x();
|
|
||||||
painter->drawLine(xStart, y, xStart + space, y);
|
|
||||||
|
|
||||||
int xm = option.rect.x() + space;
|
|
||||||
int thick = option.rect.height() / 2;
|
|
||||||
int ym = option.rect.y() + ((option.rect.height() - thick) / 2);
|
|
||||||
|
|
||||||
pen.setStyle(Qt::SolidLine);
|
|
||||||
painter->setPen(pen);
|
|
||||||
painter->setBrush(textColor);
|
|
||||||
|
|
||||||
//! draw ending cirlce
|
|
||||||
painter->drawEllipse(QPoint(xm, ym + thick/2), thick/4, thick/4);
|
|
||||||
} else {
|
|
||||||
int xEnd = option.rect.x() + option.rect.width();
|
|
||||||
painter->drawLine(xEnd, y, xEnd-space, y);
|
|
||||||
|
|
||||||
int xm = option.rect.x() + option.rect.width() - space;
|
|
||||||
int thick = option.rect.height() / 2;
|
|
||||||
int ym = option.rect.y() + ((option.rect.height() - thick) / 2);
|
|
||||||
|
|
||||||
pen.setStyle(Qt::SolidLine);
|
|
||||||
painter->setPen(pen);
|
|
||||||
painter->setBrush(textColor);
|
|
||||||
|
|
||||||
//! draw ending cirlce
|
|
||||||
painter->drawEllipse(QPoint(xm, ym + thick/2), thick/4, thick/4);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Shared::updateButtonText(QWidget *editor, const QModelIndex &index) const
|
|
||||||
{
|
|
||||||
if (!editor) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Latte::Data::LayoutsTable allLayouts = qvariant_cast<Latte::Data::LayoutsTable>(index.data(Model::Layouts::ALLLAYOUTSROLE));
|
|
||||||
|
|
||||||
QPushButton *button = static_cast<QPushButton *>(editor);
|
|
||||||
Latte::Data::LayoutsTable assignedLayouts;
|
|
||||||
|
|
||||||
foreach (QAction *action, button->menu()->actions()) {
|
|
||||||
if (action->isChecked()) {
|
|
||||||
QString id = action->data().toString();
|
|
||||||
if (allLayouts.containsId(id)) {
|
|
||||||
assignedLayouts << allLayouts[action->data().toString()];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
button->setText(joined(assignedLayouts, QStringList(), false));
|
|
||||||
}
|
|
||||||
|
|
||||||
QString Shared::joined(const Latte::Data::LayoutsTable &layouts, const QStringList &originalIds, bool formatText) const
|
|
||||||
{
|
|
||||||
QString finalText;
|
|
||||||
|
|
||||||
for (int i = 0; i < layouts.rowCount(); ++i) {
|
|
||||||
if (i > 0) {
|
|
||||||
finalText += ", ";
|
|
||||||
}
|
|
||||||
|
|
||||||
bool bold = layouts[i].isActive;
|
|
||||||
bool italic = !originalIds.contains(layouts[i].id);
|
|
||||||
|
|
||||||
QString name = layouts[i].name;
|
|
||||||
|
|
||||||
if (bold && formatText) {
|
|
||||||
name = "<b>" + name + "</b>";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (italic && formatText) {
|
|
||||||
name = "<i>" + name + "</i>";
|
|
||||||
}
|
|
||||||
|
|
||||||
finalText += name;
|
|
||||||
}
|
|
||||||
|
|
||||||
return finalText;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,66 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2019 Michail Vourlakos <mvourlakos@gmail.com>
|
|
||||||
*
|
|
||||||
* This file is part of Latte-Dock
|
|
||||||
*
|
|
||||||
* Latte-Dock is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU General Public License as
|
|
||||||
* published by the Free Software Foundation; either version 2 of
|
|
||||||
* the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Latte-Dock is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef SHAREDDELEGATE_H
|
|
||||||
#define SHAREDDELEGATE_H
|
|
||||||
|
|
||||||
// local
|
|
||||||
#include "../controllers/layoutscontroller.h"
|
|
||||||
#include "../../data/layoutstable.h"
|
|
||||||
|
|
||||||
// Qt
|
|
||||||
#include <QStyledItemDelegate>
|
|
||||||
|
|
||||||
class QModelIndex;
|
|
||||||
class QWidget;
|
|
||||||
|
|
||||||
namespace Latte {
|
|
||||||
namespace Settings {
|
|
||||||
namespace Layout {
|
|
||||||
namespace Delegate {
|
|
||||||
|
|
||||||
class Shared : public QStyledItemDelegate
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
Shared(Controller::Layouts *parent);
|
|
||||||
|
|
||||||
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
|
|
||||||
void setEditorData(QWidget *editor, const QModelIndex &index) const override;
|
|
||||||
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override;
|
|
||||||
void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
|
|
||||||
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
void paintSharedToIndicator(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
|
|
||||||
void updateButtonText(QWidget *editor, const QModelIndex &index) const;
|
|
||||||
|
|
||||||
QString joined(const Latte::Data::LayoutsTable &layouts, const QStringList &originalIds, bool formatText = true) const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
// we need it in order to send to the model the information when the SHARETO cell is edited
|
|
||||||
Controller::Layouts *m_controller{nullptr};
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
@ -29,7 +29,7 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QTabWidget" name="tabWidget">
|
<widget class="QTabWidget" name="tabWidget">
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>1</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="layoutsTab">
|
<widget class="QWidget" name="layoutsTab">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
@ -287,20 +287,6 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="sharedButton">
|
|
||||||
<property name="text">
|
|
||||||
<string notr="true">Shared</string>
|
|
||||||
</property>
|
|
||||||
<property name="icon">
|
|
||||||
<iconset theme="document-share">
|
|
||||||
<normaloff>.</normaloff>.</iconset>
|
|
||||||
</property>
|
|
||||||
<property name="checkable">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
<item>
|
||||||
<spacer name="verticalSpacer_12">
|
<spacer name="verticalSpacer_12">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
|
@ -165,14 +165,6 @@ void TabLayouts::initLayoutMenu()
|
|||||||
connectActionWithButton(m_ui->lockedButton, m_lockedLayoutAction);
|
connectActionWithButton(m_ui->lockedButton, m_lockedLayoutAction);
|
||||||
connect(m_lockedLayoutAction, &QAction::triggered, this, &TabLayouts::lockLayout);
|
connect(m_lockedLayoutAction, &QAction::triggered, this, &TabLayouts::lockLayout);
|
||||||
|
|
||||||
m_sharedLayoutAction = m_layoutMenu->addAction(i18nc("shared layout", "Sha&red"));
|
|
||||||
m_sharedLayoutAction->setToolTip(i18n("Share selected layout with other central layouts"));
|
|
||||||
m_sharedLayoutAction->setIcon(QIcon::fromTheme("document-share"));
|
|
||||||
m_sharedLayoutAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_R));
|
|
||||||
m_sharedLayoutAction->setCheckable(true);
|
|
||||||
connectActionWithButton(m_ui->sharedButton, m_sharedLayoutAction);
|
|
||||||
connect(m_sharedLayoutAction, &QAction::triggered, this, &TabLayouts::shareLayout);
|
|
||||||
|
|
||||||
m_detailsAction = m_layoutMenu->addAction(i18nc("layout details", "De&tails..."));
|
m_detailsAction = m_layoutMenu->addAction(i18nc("layout details", "De&tails..."));
|
||||||
m_detailsAction->setToolTip(i18n("Show selected layout details"));
|
m_detailsAction->setToolTip(i18n("Show selected layout details"));
|
||||||
m_detailsAction->setIcon(QIcon::fromTheme("view-list-details"));
|
m_detailsAction->setIcon(QIcon::fromTheme("view-list-details"));
|
||||||
@ -311,10 +303,9 @@ void TabLayouts::switchLayout()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!m_layoutsController->selectedLayoutIsCurrentActive()) {
|
if (!m_layoutsController->selectedLayoutIsCurrentActive()) {
|
||||||
bool appliedShared = m_layoutsController->inMultipleMode() && selectedLayoutCurrent.isShared();
|
|
||||||
bool freeActivitiesLayoutUpdated{false};
|
bool freeActivitiesLayoutUpdated{false};
|
||||||
|
|
||||||
if (!appliedShared && selectedLayoutCurrent.activities.isEmpty()) {
|
if (selectedLayoutCurrent.activities.isEmpty()) {
|
||||||
m_layoutsController->setOriginalLayoutForFreeActivities(selectedLayoutOriginal.id);
|
m_layoutsController->setOriginalLayoutForFreeActivities(selectedLayoutOriginal.id);
|
||||||
freeActivitiesLayoutUpdated = true;
|
freeActivitiesLayoutUpdated = true;
|
||||||
}
|
}
|
||||||
@ -362,13 +353,6 @@ void TabLayouts::updatePerLayoutButtonsState()
|
|||||||
{
|
{
|
||||||
//! UI Elements that need to be enabled/disabled
|
//! UI Elements that need to be enabled/disabled
|
||||||
|
|
||||||
//! Shared Button - visible
|
|
||||||
if (m_layoutsController->inMultipleMode()) {
|
|
||||||
setTwinProperty(m_sharedLayoutAction, TWINVISIBLE, true);
|
|
||||||
} else {
|
|
||||||
setTwinProperty(m_sharedLayoutAction, TWINVISIBLE, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
//! Pause Button - visible
|
//! Pause Button - visible
|
||||||
if (!m_layoutsController->inMultipleMode()) {
|
if (!m_layoutsController->inMultipleMode()) {
|
||||||
//! Single Layout mode
|
//! Single Layout mode
|
||||||
@ -384,8 +368,7 @@ void TabLayouts::updatePerLayoutButtonsState()
|
|||||||
Latte::Data::Layout selectedLayout = m_layoutsController->selectedLayoutCurrentData();
|
Latte::Data::Layout selectedLayout = m_layoutsController->selectedLayoutCurrentData();
|
||||||
|
|
||||||
//! Switch Button
|
//! Switch Button
|
||||||
if ((m_layoutsController->inMultipleMode() && selectedLayout.isShared())
|
if (m_layoutsController->selectedLayoutIsCurrentActive()) {
|
||||||
|| m_layoutsController->selectedLayoutIsCurrentActive()) {
|
|
||||||
setTwinProperty(m_switchLayoutAction, TWINENABLED, false);
|
setTwinProperty(m_switchLayoutAction, TWINENABLED, false);
|
||||||
} else {
|
} else {
|
||||||
setTwinProperty(m_switchLayoutAction, TWINENABLED, true);
|
setTwinProperty(m_switchLayoutAction, TWINENABLED, true);
|
||||||
@ -394,8 +377,7 @@ void TabLayouts::updatePerLayoutButtonsState()
|
|||||||
//! Pause Button - enabled
|
//! Pause Button - enabled
|
||||||
if (m_layoutsController->inMultipleMode()) {
|
if (m_layoutsController->inMultipleMode()) {
|
||||||
if (selectedLayout.isActive
|
if (selectedLayout.isActive
|
||||||
&& !selectedLayout.isForFreeActivities()
|
&& !selectedLayout.isForFreeActivities()) {
|
||||||
&& !selectedLayout.isShared()) {
|
|
||||||
setTwinProperty(m_pauseLayoutAction, TWINENABLED, true);
|
setTwinProperty(m_pauseLayoutAction, TWINENABLED, true);
|
||||||
} else {
|
} else {
|
||||||
setTwinProperty(m_pauseLayoutAction, TWINENABLED, false);
|
setTwinProperty(m_pauseLayoutAction, TWINENABLED, false);
|
||||||
@ -416,13 +398,6 @@ void TabLayouts::updatePerLayoutButtonsState()
|
|||||||
setTwinProperty(m_lockedLayoutAction, TWINCHECKED, false);
|
setTwinProperty(m_lockedLayoutAction, TWINCHECKED, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Layout Shared Button
|
|
||||||
if (selectedLayout.isShared()) {
|
|
||||||
setTwinProperty(m_sharedLayoutAction, TWINCHECKED, true);
|
|
||||||
} else {
|
|
||||||
setTwinProperty(m_sharedLayoutAction, TWINCHECKED, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
setTwinProperty(m_detailsAction, TWINENABLED, true);
|
setTwinProperty(m_detailsAction, TWINENABLED, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -529,19 +504,6 @@ void TabLayouts::lockLayout()
|
|||||||
updatePerLayoutButtonsState();
|
updatePerLayoutButtonsState();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TabLayouts::shareLayout()
|
|
||||||
{
|
|
||||||
qDebug() << Q_FUNC_INFO;
|
|
||||||
|
|
||||||
if (!isCurrentTab() || !m_sharedLayoutAction->isEnabled()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_layoutsController->toggleSharedForSelected();
|
|
||||||
|
|
||||||
updatePerLayoutButtonsState();
|
|
||||||
}
|
|
||||||
|
|
||||||
void TabLayouts::importLayout()
|
void TabLayouts::importLayout()
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
qDebug() << Q_FUNC_INFO;
|
||||||
|
@ -99,7 +99,6 @@ private slots:
|
|||||||
void exportLayoutAsTemplate();
|
void exportLayoutAsTemplate();
|
||||||
void lockLayout();
|
void lockLayout();
|
||||||
void removeLayout();
|
void removeLayout();
|
||||||
void shareLayout();
|
|
||||||
void detailsLayout();
|
void detailsLayout();
|
||||||
|
|
||||||
void onCurrentPageChanged(int page);
|
void onCurrentPageChanged(int page);
|
||||||
@ -137,7 +136,6 @@ private:
|
|||||||
QAction *m_copyLayoutAction{nullptr};
|
QAction *m_copyLayoutAction{nullptr};
|
||||||
QAction *m_removeLayoutAction{nullptr};
|
QAction *m_removeLayoutAction{nullptr};
|
||||||
QAction *m_lockedLayoutAction{nullptr};
|
QAction *m_lockedLayoutAction{nullptr};
|
||||||
QAction *m_sharedLayoutAction{nullptr};
|
|
||||||
QAction *m_importLayoutAction{nullptr};
|
QAction *m_importLayoutAction{nullptr};
|
||||||
QAction *m_exportLayoutAction{nullptr};
|
QAction *m_exportLayoutAction{nullptr};
|
||||||
QAction *m_downloadLayoutAction{nullptr};
|
QAction *m_downloadLayoutAction{nullptr};
|
||||||
|
@ -53,10 +53,9 @@ Layouts::Layouts(QObject *parent, Latte::Corona *corona)
|
|||||||
QVector<int> roles;
|
QVector<int> roles;
|
||||||
roles << Qt::DisplayRole;
|
roles << Qt::DisplayRole;
|
||||||
roles << Qt::UserRole;
|
roles << Qt::UserRole;
|
||||||
roles << ISSHAREDROLE;
|
|
||||||
roles << INMULTIPLELAYOUTSROLE;
|
roles << INMULTIPLELAYOUTSROLE;
|
||||||
|
|
||||||
emit dataChanged(index(0, NAMECOLUMN), index(rowCount()-1, SHAREDCOLUMN), roles);
|
emit dataChanged(index(0, NAMECOLUMN), index(rowCount()-1, ACTIVITYCOLUMN), roles);
|
||||||
});
|
});
|
||||||
|
|
||||||
connect(this, &Layouts::inMultipleModeChanged, this, &Layouts::updateActiveStates);
|
connect(this, &Layouts::inMultipleModeChanged, this, &Layouts::updateActiveStates);
|
||||||
@ -115,7 +114,7 @@ int Layouts::columnCount(const QModelIndex &parent) const
|
|||||||
{
|
{
|
||||||
Q_UNUSED(parent);
|
Q_UNUSED(parent);
|
||||||
|
|
||||||
return SHAREDCOLUMN+1;
|
return ACTIVITYCOLUMN+1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Layouts::clear()
|
void Layouts::clear()
|
||||||
@ -147,7 +146,7 @@ void Layouts::applyData()
|
|||||||
o_inMultipleMode = m_inMultipleMode;
|
o_inMultipleMode = m_inMultipleMode;
|
||||||
o_layoutsTable = m_layoutsTable;
|
o_layoutsTable = m_layoutsTable;
|
||||||
|
|
||||||
emit dataChanged(index(0, BACKGROUNDCOLUMN), index(rowCount()-1,SHAREDCOLUMN), roles);
|
emit dataChanged(index(0, BACKGROUNDCOLUMN), index(rowCount()-1, ACTIVITYCOLUMN), roles);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Layouts::resetData()
|
void Layouts::resetData()
|
||||||
@ -174,7 +173,7 @@ void Layouts::setLayoutProperties(const Latte::Data::Layout &layout)
|
|||||||
QVector<int> roles;
|
QVector<int> roles;
|
||||||
roles << Qt::DisplayRole;
|
roles << Qt::DisplayRole;
|
||||||
roles << Qt::UserRole;
|
roles << Qt::UserRole;
|
||||||
emit dataChanged(index(dataRow, IDCOLUMN), index(dataRow, SHAREDCOLUMN), roles);
|
emit dataChanged(index(dataRow, IDCOLUMN), index(dataRow, ACTIVITYCOLUMN), roles);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -248,28 +247,6 @@ void Layouts::setOriginalLayoutForFreeActivities(const QString &id)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList Layouts::assignedActivitiesFromShared(const int &row) const
|
|
||||||
{
|
|
||||||
QStringList assigns;
|
|
||||||
|
|
||||||
if (!m_layoutsTable.rowExists(row)) {
|
|
||||||
return assigns;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_layoutsTable[row].isShared()) {
|
|
||||||
for (int i=0; i<m_layoutsTable[row].shares.count(); ++i) {
|
|
||||||
QString shareId = m_layoutsTable[row].shares[i];
|
|
||||||
int shareRow = rowForId(shareId);
|
|
||||||
|
|
||||||
if (shareRow>=0 && !m_layoutsTable[shareRow].activities.isEmpty()) {
|
|
||||||
assigns << m_layoutsTable[shareRow].activities;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return assigns;
|
|
||||||
}
|
|
||||||
|
|
||||||
QVariant Layouts::headerData(int section, Qt::Orientation orientation, int role) const
|
QVariant Layouts::headerData(int section, Qt::Orientation orientation, int role) const
|
||||||
{
|
{
|
||||||
if (orientation != Qt::Horizontal) {
|
if (orientation != Qt::Horizontal) {
|
||||||
@ -332,15 +309,6 @@ QVariant Layouts::headerData(int section, Qt::Orientation orientation, int role)
|
|||||||
return QVariant::fromValue(Qt::AlignLeft | Qt::AlignVCenter);
|
return QVariant::fromValue(Qt::AlignLeft | Qt::AlignVCenter);
|
||||||
}*/
|
}*/
|
||||||
break;
|
break;
|
||||||
case SHAREDCOLUMN:
|
|
||||||
if (role == Qt::DisplayRole) {
|
|
||||||
return QString(i18nc("column for shared layout to show which layouts is assigned to", "Shared To"));
|
|
||||||
} else if (role == Qt::DecorationRole) {
|
|
||||||
return QIcon::fromTheme("document-share");
|
|
||||||
}/* else if (role == Qt::TextAlignmentRole ){
|
|
||||||
return QVariant::fromValue(Qt::AlignLeft | Qt::AlignVCenter);
|
|
||||||
}*/
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
};
|
};
|
||||||
@ -360,8 +328,7 @@ Qt::ItemFlags Layouts::flags(const QModelIndex &index) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (column == ACTIVITYCOLUMN
|
if (column == ACTIVITYCOLUMN
|
||||||
|| column == NAMECOLUMN
|
|| column == NAMECOLUMN) {
|
||||||
|| column == SHAREDCOLUMN) {
|
|
||||||
flags |= Qt::ItemIsEditable;
|
flags |= Qt::ItemIsEditable;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -441,56 +408,9 @@ QList<Latte::Data::LayoutIcon> Layouts::iconsForCentralLayout(const int &row) co
|
|||||||
return icons;
|
return icons;
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<Latte::Data::LayoutIcon> Layouts::iconsForSharedLayout(const int &row) const
|
|
||||||
{
|
|
||||||
//! SHARED layout case
|
|
||||||
QList<Latte::Data::LayoutIcon> icons;
|
|
||||||
|
|
||||||
if (!m_layoutsTable[row].icon.isEmpty()) {
|
|
||||||
//! if there is specific icon set from the user for this layout
|
|
||||||
//! we draw only that icon
|
|
||||||
Latte::Data::LayoutIcon icon;
|
|
||||||
icon.name = m_layoutsTable[row].icon;
|
|
||||||
icon.isFreeActivities = false;
|
|
||||||
icon.isBackgroundFile = false;
|
|
||||||
icons << icon;
|
|
||||||
return icons;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i=0; i<m_layoutsTable[row].shares.count(); ++i) {
|
|
||||||
QString shareId = m_layoutsTable[row].shares[i];
|
|
||||||
int shareRow = rowForId(shareId);
|
|
||||||
|
|
||||||
if (shareRow>=0) {
|
|
||||||
icons << iconsForCentralLayout(shareRow);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int freeActivitiesPos = -1;
|
|
||||||
|
|
||||||
for (int i=0; i<icons.count(); ++i) {
|
|
||||||
if (icons[i].isFreeActivities) {
|
|
||||||
freeActivitiesPos = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (freeActivitiesPos >= 0) {
|
|
||||||
//! Put FreeActivities icon on top of the rest icons
|
|
||||||
Latte::Data::LayoutIcon freeActsData = icons.takeAt(freeActivitiesPos);
|
|
||||||
icons << freeActsData;
|
|
||||||
}
|
|
||||||
|
|
||||||
return icons;
|
|
||||||
}
|
|
||||||
|
|
||||||
QList<Latte::Data::LayoutIcon> Layouts::icons(const int &row) const
|
QList<Latte::Data::LayoutIcon> Layouts::icons(const int &row) const
|
||||||
{
|
{
|
||||||
if (!m_layoutsTable[row].isShared()) {
|
return iconsForCentralLayout(row);
|
||||||
return iconsForCentralLayout(row);
|
|
||||||
} else {
|
|
||||||
return iconsForSharedLayout(row);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Layouts::sortableText(const int &priority, const int &row) const
|
QString Layouts::sortableText(const int &priority, const int &row) const
|
||||||
@ -545,14 +465,10 @@ QVariant Layouts::data(const QModelIndex &index, int role) const
|
|||||||
return m_layoutsTable[row].isActive;
|
return m_layoutsTable[row].isActive;
|
||||||
} else if (role == ISLOCKEDROLE) {
|
} else if (role == ISLOCKEDROLE) {
|
||||||
return m_layoutsTable[row].isLocked;
|
return m_layoutsTable[row].isLocked;
|
||||||
} else if (role == ISSHAREDROLE) {
|
|
||||||
return m_layoutsTable[row].isShared();
|
|
||||||
} else if (role == INMULTIPLELAYOUTSROLE) {
|
} else if (role == INMULTIPLELAYOUTSROLE) {
|
||||||
return inMultipleMode();
|
return inMultipleMode();
|
||||||
} else if (role == ASSIGNEDACTIVITIESROLE) {
|
} else if (role == ASSIGNEDACTIVITIESROLE) {
|
||||||
return m_layoutsTable[row].activities;
|
return m_layoutsTable[row].activities;
|
||||||
} else if (role == ASSIGNEDACTIVITIESFROMSHAREDROLE) {
|
|
||||||
return assignedActivitiesFromShared(row);
|
|
||||||
} else if (role == ALLACTIVITIESSORTEDROLE) {
|
} else if (role == ALLACTIVITIESSORTEDROLE) {
|
||||||
QStringList activities;
|
QStringList activities;
|
||||||
activities << QString(Latte::Data::Layout::FREEACTIVITIESID);
|
activities << QString(Latte::Data::Layout::FREEACTIVITIESID);
|
||||||
@ -566,8 +482,6 @@ QVariant Layouts::data(const QModelIndex &index, int role) const
|
|||||||
QVariant layouts;
|
QVariant layouts;
|
||||||
layouts.setValue(m_layoutsTable);
|
layouts.setValue(m_layoutsTable);
|
||||||
return layouts;
|
return layouts;
|
||||||
} else if (role == SHAREDTOINEDITROLE) {
|
|
||||||
return (m_sharedToInEditRow == row);
|
|
||||||
} else if (role == ISNEWLAYOUTROLE) {
|
} else if (role == ISNEWLAYOUTROLE) {
|
||||||
return isNewLayout;
|
return isNewLayout;
|
||||||
} else if (role == LAYOUTHASCHANGESROLE) {
|
} else if (role == LAYOUTHASCHANGESROLE) {
|
||||||
@ -612,9 +526,7 @@ QVariant Layouts::data(const QModelIndex &index, int role) const
|
|||||||
break;
|
break;
|
||||||
case MENUCOLUMN:
|
case MENUCOLUMN:
|
||||||
if (role == SORTINGROLE) {
|
if (role == SORTINGROLE) {
|
||||||
if ((m_inMultipleMode && m_layoutsTable[row].isShared())) {
|
if (m_layoutsTable[row].isShownInMenu) {
|
||||||
return sortingPriority(MEDIUMPRIORITY, row);
|
|
||||||
} else if (m_layoutsTable[row].isShownInMenu) {
|
|
||||||
return sortingPriority(HIGHESTPRIORITY, row);
|
return sortingPriority(HIGHESTPRIORITY, row);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -631,9 +543,7 @@ QVariant Layouts::data(const QModelIndex &index, int role) const
|
|||||||
break;
|
break;
|
||||||
case BORDERSCOLUMN:
|
case BORDERSCOLUMN:
|
||||||
if (role == SORTINGROLE) {
|
if (role == SORTINGROLE) {
|
||||||
if ((m_inMultipleMode && m_layoutsTable[row].isShared())) {
|
if (m_layoutsTable[row].hasDisabledBorders) {
|
||||||
return sortingPriority(MEDIUMPRIORITY, row);
|
|
||||||
} else if (m_layoutsTable[row].hasDisabledBorders) {
|
|
||||||
return sortingPriority(HIGHESTPRIORITY, row);
|
return sortingPriority(HIGHESTPRIORITY, row);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -650,9 +560,7 @@ QVariant Layouts::data(const QModelIndex &index, int role) const
|
|||||||
break;
|
break;
|
||||||
case ACTIVITYCOLUMN:
|
case ACTIVITYCOLUMN:
|
||||||
if (role == SORTINGROLE) {
|
if (role == SORTINGROLE) {
|
||||||
if ((m_inMultipleMode && m_layoutsTable[row].isShared())) {
|
if (m_layoutsTable[row].activities.count() > 0) {
|
||||||
return sortingPriority(MEDIUMPRIORITY, row) + m_layoutsTable[row].shares.count();
|
|
||||||
} else if (m_layoutsTable[row].activities.count() > 0) {
|
|
||||||
if (m_layoutsTable[row].activities.contains(Latte::Data::Layout::FREEACTIVITIESID)) {
|
if (m_layoutsTable[row].activities.contains(Latte::Data::Layout::FREEACTIVITIESID)) {
|
||||||
return sortingPriority(HIGHESTPRIORITY, row);
|
return sortingPriority(HIGHESTPRIORITY, row);
|
||||||
} else {
|
} else {
|
||||||
@ -671,29 +579,6 @@ QVariant Layouts::data(const QModelIndex &index, int role) const
|
|||||||
return m_layoutsTable[row].activities;
|
return m_layoutsTable[row].activities;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SHAREDCOLUMN:
|
|
||||||
if (role == SORTINGROLE) {
|
|
||||||
if (m_layoutsTable[row].shares.count() > 0) {
|
|
||||||
//! highest priority based on number of shares
|
|
||||||
return HIGHESTPRIORITY + m_layoutsTable[row].shares.count();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_layoutsTable[row].activities.contains(Latte::Data::Layout::FREEACTIVITIESID)) {
|
|
||||||
//! high activity priority
|
|
||||||
return HIGHPRIORITY;
|
|
||||||
}
|
|
||||||
|
|
||||||
return NORMALPRIORITY;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (role == ORIGINALSHARESROLE) {
|
|
||||||
return isNewLayout ? QStringList() : original.shares;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (role == Qt::UserRole) {
|
|
||||||
return m_layoutsTable[row].shares;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
return QVariant{};
|
return QVariant{};
|
||||||
};
|
};
|
||||||
@ -728,7 +613,6 @@ void Layouts::assignFreeActivitiesLayoutAt(const QString &layoutName)
|
|||||||
|
|
||||||
int row = m_layoutsTable.indexOf(reqId);
|
int row = m_layoutsTable.indexOf(reqId);
|
||||||
setActivities(row, QStringList(Latte::Data::Layout::FREEACTIVITIESID));
|
setActivities(row, QStringList(Latte::Data::Layout::FREEACTIVITIESID));
|
||||||
setShares(row, QStringList());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Layouts::autoAssignFreeActivitiesLayout()
|
void Layouts::autoAssignFreeActivitiesLayout()
|
||||||
@ -741,7 +625,7 @@ void Layouts::autoAssignFreeActivitiesLayout()
|
|||||||
QString activeCurrentId = o_layoutsTable.idForName(m_corona->layoutsManager()->currentLayoutName());
|
QString activeCurrentId = o_layoutsTable.idForName(m_corona->layoutsManager()->currentLayoutName());
|
||||||
int row = m_layoutsTable.indexOf(activeCurrentId);
|
int row = m_layoutsTable.indexOf(activeCurrentId);
|
||||||
|
|
||||||
if (row>=0 && !(m_inMultipleMode && m_layoutsTable[row].isShared()) && m_layoutsTable[row].activities.isEmpty()) {
|
if (row>=0 && m_layoutsTable[row].activities.isEmpty()) {
|
||||||
m_layoutsTable[row].activities << Latte::Data::Layout::FREEACTIVITIESID;
|
m_layoutsTable[row].activities << Latte::Data::Layout::FREEACTIVITIESID;
|
||||||
emit dataChanged(index(row,BACKGROUNDCOLUMN), index(row,ACTIVITYCOLUMN), roles);
|
emit dataChanged(index(row,BACKGROUNDCOLUMN), index(row,ACTIVITYCOLUMN), roles);
|
||||||
return;
|
return;
|
||||||
@ -749,7 +633,7 @@ void Layouts::autoAssignFreeActivitiesLayout()
|
|||||||
|
|
||||||
//! Active layouts with no activities have mid priority
|
//! Active layouts with no activities have mid priority
|
||||||
for(int i=0; i<rowCount(); ++i) {
|
for(int i=0; i<rowCount(); ++i) {
|
||||||
if (m_layoutsTable[i].isActive && m_layoutsTable[i].activities.isEmpty() && !(m_inMultipleMode && m_layoutsTable[i].isShared())) {
|
if (m_layoutsTable[i].isActive && m_layoutsTable[i].activities.isEmpty()) {
|
||||||
m_layoutsTable[i].activities << Latte::Data::Layout::FREEACTIVITIESID;
|
m_layoutsTable[i].activities << Latte::Data::Layout::FREEACTIVITIESID;
|
||||||
emit dataChanged(index(i,BACKGROUNDCOLUMN), index(i,ACTIVITYCOLUMN), roles);
|
emit dataChanged(index(i,BACKGROUNDCOLUMN), index(i,ACTIVITYCOLUMN), roles);
|
||||||
return;
|
return;
|
||||||
@ -758,7 +642,7 @@ void Layouts::autoAssignFreeActivitiesLayout()
|
|||||||
|
|
||||||
//! Inactive layouts with no activities have lowest priority
|
//! Inactive layouts with no activities have lowest priority
|
||||||
for(int i=0; i<rowCount(); ++i) {
|
for(int i=0; i<rowCount(); ++i) {
|
||||||
if (!m_layoutsTable[i].isActive && m_layoutsTable[i].activities.isEmpty() && !(m_inMultipleMode && m_layoutsTable[i].isShared())) {
|
if (!m_layoutsTable[i].isActive && m_layoutsTable[i].activities.isEmpty()) {
|
||||||
m_layoutsTable[i].activities << Latte::Data::Layout::FREEACTIVITIESID;
|
m_layoutsTable[i].activities << Latte::Data::Layout::FREEACTIVITIESID;
|
||||||
emit dataChanged(index(i,BACKGROUNDCOLUMN), index(i,ACTIVITYCOLUMN), roles);
|
emit dataChanged(index(i,BACKGROUNDCOLUMN), index(i,ACTIVITYCOLUMN), roles);
|
||||||
return;
|
return;
|
||||||
@ -817,78 +701,6 @@ void Layouts::setId(const int &row, const QString &newId)
|
|||||||
QString oldId = m_layoutsTable[row].id;
|
QString oldId = m_layoutsTable[row].id;
|
||||||
m_layoutsTable[row].id = newId;
|
m_layoutsTable[row].id = newId;
|
||||||
emit dataChanged(index(row, NAMECOLUMN), index(row,NAMECOLUMN), roles);
|
emit dataChanged(index(row, NAMECOLUMN), index(row,NAMECOLUMN), roles);
|
||||||
|
|
||||||
for(int i=0; i<rowCount(); ++i) {
|
|
||||||
if (i == row) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
int pos = m_layoutsTable[i].shares.indexOf(oldId);
|
|
||||||
|
|
||||||
if (pos >= 0) {
|
|
||||||
m_layoutsTable[i].shares[pos] = newId;
|
|
||||||
emit dataChanged(index(i, NAMECOLUMN), index(i, NAMECOLUMN), roles);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Layouts::shareIsAvailable(const QString id) const
|
|
||||||
{
|
|
||||||
for(int i=0; i<rowCount(); ++i) {
|
|
||||||
if (m_layoutsTable[i].isShared() && m_layoutsTable[i].shares.contains(id)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
QStringList Layouts::availableShareIdsFor(const QString id) const
|
|
||||||
{
|
|
||||||
QStringList shares;
|
|
||||||
|
|
||||||
for(int i=0; i<rowCount(); ++i) {
|
|
||||||
if (m_layoutsTable[i].id == id || m_layoutsTable[i].isShared() || !shareIsAvailable(m_layoutsTable[i].id)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
shares << m_layoutsTable[i].id;
|
|
||||||
}
|
|
||||||
|
|
||||||
return shares;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Layouts::setShares(const int &row, const QStringList &shares)
|
|
||||||
{
|
|
||||||
if (!m_layoutsTable.rowExists(row) || m_layoutsTable[row].shares == shares) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
QVector<int> roles;
|
|
||||||
roles << Qt::DisplayRole;
|
|
||||||
roles << Qt::UserRole;
|
|
||||||
|
|
||||||
m_layoutsTable[row].shares = shares;
|
|
||||||
emit dataChanged(index(row,IDCOLUMN), index(row,SHAREDCOLUMN), roles);
|
|
||||||
|
|
||||||
for(int i=0; i<rowCount(); ++i) {
|
|
||||||
if (i == row) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto cleaned = cleanStrings(m_layoutsTable[i].shares, shares);
|
|
||||||
if (cleaned != m_layoutsTable[i].shares) {
|
|
||||||
m_layoutsTable[i].shares = cleaned;
|
|
||||||
emit dataChanged(index(i,IDCOLUMN), index(i,SHAREDCOLUMN), roles);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_layoutsTable[row].activities.contains(Latte::Data::Layout::FREEACTIVITIESID)
|
|
||||||
&& m_inMultipleMode
|
|
||||||
&& m_layoutsTable[row].isShared()) {
|
|
||||||
//! we need to remove the free_activities flag in such case
|
|
||||||
setActivities(row, QStringList());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Layouts::setData(const QModelIndex &index, const QVariant &value, int role)
|
bool Layouts::setData(const QModelIndex &index, const QVariant &value, int role)
|
||||||
@ -896,7 +708,7 @@ bool Layouts::setData(const QModelIndex &index, const QVariant &value, int role)
|
|||||||
const int row = index.row();
|
const int row = index.row();
|
||||||
const int column = index.column();
|
const int column = index.column();
|
||||||
|
|
||||||
if (!m_layoutsTable.rowExists(row) || column<0 || column > SHAREDCOLUMN) {
|
if (!m_layoutsTable.rowExists(row) || column<0 || column > ACTIVITYCOLUMN) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -906,7 +718,7 @@ bool Layouts::setData(const QModelIndex &index, const QVariant &value, int role)
|
|||||||
//! common roles for all row cells
|
//! common roles for all row cells
|
||||||
if (role == ISLOCKEDROLE) {
|
if (role == ISLOCKEDROLE) {
|
||||||
m_layoutsTable[row].isLocked = value.toBool();
|
m_layoutsTable[row].isLocked = value.toBool();
|
||||||
emit dataChanged(this->index(row,0), this->index(row,SHAREDCOLUMN), roles);
|
emit dataChanged(this->index(row,0), this->index(row, ACTIVITYCOLUMN), roles);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -974,22 +786,6 @@ bool Layouts::setData(const QModelIndex &index, const QVariant &value, int role)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SHAREDCOLUMN:
|
|
||||||
if (role == Qt::UserRole) {
|
|
||||||
setShares(row, value.toStringList());
|
|
||||||
emit dataChanged(this->index(row, NAMECOLUMN), this->index(row,NAMECOLUMN), roles);
|
|
||||||
return true;
|
|
||||||
} else if (role == SHAREDTOINEDITROLE) {
|
|
||||||
bool inEdit = value.toBool();
|
|
||||||
m_sharedToInEditRow = inEdit ? row : -1;
|
|
||||||
roles << Qt::DisplayRole;
|
|
||||||
roles << Qt::UserRole;
|
|
||||||
roles << SHAREDTOINEDITROLE;
|
|
||||||
emit dataChanged(this->index(row, ACTIVITYCOLUMN), this->index(row, SHAREDCOLUMN), roles);
|
|
||||||
emit dataChanged(this->index(row, NAMECOLUMN), this->index(row,NAMECOLUMN), roles);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -1013,7 +809,7 @@ void Layouts::updateActiveStates()
|
|||||||
if (m_layoutsTable[i].isActive != iActive) {
|
if (m_layoutsTable[i].isActive != iActive) {
|
||||||
m_layoutsTable[i].isActive = iActive;
|
m_layoutsTable[i].isActive = iActive;
|
||||||
|
|
||||||
emit dataChanged(index(i, BACKGROUNDCOLUMN), index(i,SHAREDCOLUMN), roles);
|
emit dataChanged(index(i, BACKGROUNDCOLUMN), index(i,ACTIVITYCOLUMN), roles);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -51,8 +51,7 @@ public:
|
|||||||
NAMECOLUMN,
|
NAMECOLUMN,
|
||||||
MENUCOLUMN,
|
MENUCOLUMN,
|
||||||
BORDERSCOLUMN,
|
BORDERSCOLUMN,
|
||||||
ACTIVITYCOLUMN,
|
ACTIVITYCOLUMN
|
||||||
SHAREDCOLUMN
|
|
||||||
};
|
};
|
||||||
|
|
||||||
enum LayoutUserRoles
|
enum LayoutUserRoles
|
||||||
@ -60,22 +59,18 @@ public:
|
|||||||
IDROLE = Qt::UserRole + 1,
|
IDROLE = Qt::UserRole + 1,
|
||||||
ISACTIVEROLE,
|
ISACTIVEROLE,
|
||||||
ISLOCKEDROLE,
|
ISLOCKEDROLE,
|
||||||
ISSHAREDROLE,
|
|
||||||
INMULTIPLELAYOUTSROLE,
|
INMULTIPLELAYOUTSROLE,
|
||||||
BACKGROUNDUSERROLE,
|
BACKGROUNDUSERROLE,
|
||||||
ASSIGNEDACTIVITIESROLE,
|
ASSIGNEDACTIVITIESROLE,
|
||||||
ASSIGNEDACTIVITIESFROMSHAREDROLE,
|
|
||||||
ALLACTIVITIESSORTEDROLE,
|
ALLACTIVITIESSORTEDROLE,
|
||||||
ALLACTIVITIESDATAROLE,
|
ALLACTIVITIESDATAROLE,
|
||||||
ALLLAYOUTSROLE,
|
ALLLAYOUTSROLE,
|
||||||
SHAREDTOINEDITROLE,
|
|
||||||
SORTINGROLE,
|
SORTINGROLE,
|
||||||
ISNEWLAYOUTROLE,
|
ISNEWLAYOUTROLE,
|
||||||
LAYOUTHASCHANGESROLE,
|
LAYOUTHASCHANGESROLE,
|
||||||
ORIGINALISSHOWNINMENUROLE,
|
ORIGINALISSHOWNINMENUROLE,
|
||||||
ORIGINALHASBORDERSROLE,
|
ORIGINALHASBORDERSROLE,
|
||||||
ORIGINALASSIGNEDACTIVITIESROLE,
|
ORIGINALASSIGNEDACTIVITIESROLE,
|
||||||
ORIGINALSHARESROLE
|
|
||||||
};
|
};
|
||||||
|
|
||||||
enum SortingPriority
|
enum SortingPriority
|
||||||
@ -129,9 +124,6 @@ public:
|
|||||||
|
|
||||||
void setIconsPath(QString iconsPath);
|
void setIconsPath(QString iconsPath);
|
||||||
|
|
||||||
bool shareIsAvailable(const QString id) const;
|
|
||||||
QStringList availableShareIdsFor(const QString id) const;
|
|
||||||
|
|
||||||
QList<Latte::Data::Layout> alteredLayouts() const;
|
QList<Latte::Data::Layout> alteredLayouts() const;
|
||||||
|
|
||||||
const Latte::Data::LayoutsTable ¤tLayoutsData();
|
const Latte::Data::LayoutsTable ¤tLayoutsData();
|
||||||
@ -160,25 +152,16 @@ private:
|
|||||||
|
|
||||||
void setActivities(const int &row, const QStringList &activities);
|
void setActivities(const int &row, const QStringList &activities);
|
||||||
void setId(const int &row, const QString &newId);
|
void setId(const int &row, const QString &newId);
|
||||||
void setShares(const int &row, const QStringList &shares);
|
|
||||||
|
|
||||||
QString sortingPriority(const SortingPriority &priority, const int &row) const;
|
QString sortingPriority(const SortingPriority &priority, const int &row) const;
|
||||||
QString sortableText(const int &priority, const int &row) const;
|
QString sortableText(const int &priority, const int &row) const;
|
||||||
|
|
||||||
QStringList cleanStrings(const QStringList &original, const QStringList &occupied);
|
QStringList cleanStrings(const QStringList &original, const QStringList &occupied);
|
||||||
|
|
||||||
QStringList assignedActivitiesFromShared(const int &row) const;
|
|
||||||
|
|
||||||
QList<Latte::Data::LayoutIcon> icons(const int &row) const;
|
QList<Latte::Data::LayoutIcon> icons(const int &row) const;
|
||||||
QList<Latte::Data::LayoutIcon> iconsForCentralLayout(const int &row) const;
|
QList<Latte::Data::LayoutIcon> iconsForCentralLayout(const int &row) const;
|
||||||
QList<Latte::Data::LayoutIcon> iconsForSharedLayout(const int &row) const;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//! break MVC only when a SharedTo editor is created
|
|
||||||
//! because we want to move the dot indicator in the Activities delegate
|
|
||||||
//! when that happens
|
|
||||||
int m_sharedToInEditRow;
|
|
||||||
|
|
||||||
QString m_iconsPath;
|
QString m_iconsPath;
|
||||||
|
|
||||||
Latte::Data::ActivitiesMap m_activitiesMap;
|
Latte::Data::ActivitiesMap m_activitiesMap;
|
||||||
|
@ -27,7 +27,6 @@
|
|||||||
#include "../lattecorona.h"
|
#include "../lattecorona.h"
|
||||||
#include "../screenpool.h"
|
#include "../screenpool.h"
|
||||||
#include "../layout/centrallayout.h"
|
#include "../layout/centrallayout.h"
|
||||||
#include "../layout/sharedlayout.h"
|
|
||||||
#include "../layouts/manager.h"
|
#include "../layouts/manager.h"
|
||||||
#include "../settings/universalsettings.h"
|
#include "../settings/universalsettings.h"
|
||||||
#include "../wm/abstractwindowinterface.h"
|
#include "../wm/abstractwindowinterface.h"
|
||||||
@ -1026,10 +1025,10 @@ void Positioner::hideDockDuringMovingToLayout(QString layoutName)
|
|||||||
auto layout = m_view->layout();
|
auto layout = m_view->layout();
|
||||||
|
|
||||||
auto central = qobject_cast<CentralLayout *>(layout);
|
auto central = qobject_cast<CentralLayout *>(layout);
|
||||||
auto shared = qobject_cast<SharedLayout *>(layout);
|
|
||||||
|
|
||||||
bool inVisibleWorkarea = ((central && central->sharedLayout() && central->sharedLayout()->name() == layoutName)
|
//! Needs to be updated; when the next layout is in the same Visible Workarea
|
||||||
|| (shared && shared->contains(layoutName) && m_corona->layoutsManager()->currentLayoutName() == layoutName));
|
//! with the old one changing layouts should be instant
|
||||||
|
bool inVisibleWorkarea{true};
|
||||||
|
|
||||||
if (inVisibleWorkarea) {
|
if (inVisibleWorkarea) {
|
||||||
m_view->moveToLayout(layoutName);
|
m_view->moveToLayout(layoutName);
|
||||||
|
Loading…
Reference in New Issue
Block a user