drop currentLayoutName as signal from synchronizer

pull/20/head
Michail Vourlakos 4 years ago
parent a9774ff13f
commit 7393ac02eb

@ -1082,7 +1082,7 @@ void Corona::addViewForLayout(QString layoutName)
void Corona::loadDefaultLayout()
{
addViewForLayout(m_layoutsManager->currentLayoutName());
// addViewForLayout(m_layoutsManager->currentLayoutsNames());
}
QStringList Corona::containmentsIds()
@ -1203,7 +1203,7 @@ QStringList Corona::contextMenuData()
}
data << QString::number((int)m_layoutsManager->memoryUsage());
data << m_layoutsManager->currentLayoutName();
data << m_layoutsManager->synchronizer()->currentLayoutsNames().join(";;");
data << QString::number((int)viewType);
for(const auto &layoutName : m_layoutsManager->menuLayouts()) {

@ -172,7 +172,7 @@ bool GenericLayout::isCurrent()
return false;
}
return name() == m_corona->layoutsManager()->currentLayoutName();
return m_corona->layoutsManager()->currentLayoutsNames().contains(name());
}
QString GenericLayout::background() const

@ -56,10 +56,8 @@ Manager::Manager(QObject *parent)
m_synchronizer = new Synchronizer(this);
if (m_corona) {
connect(m_corona->universalSettings(), &UniversalSettings::currentLayoutNameChanged, this, &Manager::currentLayoutNameChanged);
connect(m_synchronizer, &Synchronizer::centralLayoutsChanged, this, &Manager::centralLayoutsChanged);
connect(m_synchronizer, &Synchronizer::currentLayoutNameChanged, this, &Manager::currentLayoutNameChanged);
connect(m_synchronizer, &Synchronizer::currentLayoutIsSwitching, this, &Manager::currentLayoutIsSwitching);
connect(m_synchronizer, &Synchronizer::layoutsChanged, this, &Manager::layoutsChanged);
connect(m_synchronizer, &Synchronizer::menuLayoutsChanged, this, &Manager::menuLayoutsChanged);
@ -143,11 +141,6 @@ Synchronizer *Manager::synchronizer() const
return m_synchronizer;
}
QString Manager::currentLayoutName() const
{
return m_synchronizer->currentLayoutName();
}
QStringList Manager::layouts() const
{
return m_synchronizer->layouts();
@ -178,6 +171,11 @@ QStringList Manager::centralLayoutsNames()
return m_synchronizer->centralLayoutsNames();
}
QStringList Manager::currentLayoutsNames() const
{
return m_synchronizer->currentLayoutsNames();
}
QList<CentralLayout *> Manager::currentLayouts() const
{
return m_synchronizer->currentLayouts();

@ -70,8 +70,6 @@ class Manager : public QObject
{
Q_OBJECT
Q_PROPERTY(QString currentLayoutName READ currentLayoutName NOTIFY currentLayoutNameChanged)
Q_PROPERTY(QStringList layouts READ layouts NOTIFY layoutsChanged)
Q_PROPERTY(QStringList menuLayouts READ menuLayouts NOTIFY menuLayoutsChanged)
@ -89,10 +87,9 @@ public:
void showInfoWindow(QString info, int duration, QStringList activities = {"0"});
void unload();
QString currentLayoutName() const;
QStringList layouts() const;
QStringList menuLayouts() const;
QStringList currentLayoutsNames() const;
MemoryUsage::LayoutsMemory memoryUsage() const;
void setMemoryUsage(MemoryUsage::LayoutsMemory memoryUsage);
@ -116,7 +113,6 @@ public slots:
signals:
void centralLayoutsChanged();
void currentLayoutChanged();
void currentLayoutNameChanged();
void launchersSignalsChanged();
void layoutsChanged();
void menuLayoutsChanged();

@ -122,32 +122,6 @@ int Synchronizer::centralLayoutPos(QString id) const
return -1;
}
QString Synchronizer::currentLayoutName() const
{
if (m_manager->memoryUsage() == MemoryUsage::SingleLayout) {
return m_manager->corona()->universalSettings()->currentLayoutName();
} else if (m_manager->memoryUsage() == MemoryUsage::MultipleLayouts) {
return currentLayoutNameInMultiEnvironment();
}
return QString();
}
QString Synchronizer::currentLayoutNameInMultiEnvironment() const
{
return m_currentLayoutNameInMultiEnvironment;
}
void Synchronizer::setCurrentLayoutNameInMultiEnvironment(const QString &name)
{
if (m_currentLayoutNameInMultiEnvironment == name) {
return;
}
m_currentLayoutNameInMultiEnvironment = name;
emit currentLayoutNameChanged();
}
QString Synchronizer::layoutPath(QString layoutName)
{
QString path = Layouts::Importer::layoutUserFilePath(layoutName);
@ -209,6 +183,19 @@ QStringList Synchronizer::centralLayoutsNames()
return names;
}
QStringList Synchronizer::currentLayoutsNames() const
{
QList<CentralLayout *> currents = currentLayouts();
QStringList currentNames;
for (int i = 0; i < currents.size(); ++i) {
CentralLayout *layout = currents.at(i);
currentNames << layout->name();
}
return currentNames;
}
QStringList Synchronizer::layouts() const
{
return m_layouts;
@ -218,15 +205,9 @@ QStringList Synchronizer::menuLayouts() const
{
QStringList fixedMenuLayouts = m_menuLayouts;
//! in case the current layout isnt checked to be shown in the menus
//! we must add it on top
if (!fixedMenuLayouts.contains(currentLayoutName()) && m_manager->memoryUsage() == MemoryUsage::SingleLayout) {
fixedMenuLayouts.prepend(currentLayoutName());
} else if (m_manager->memoryUsage() == MemoryUsage::MultipleLayouts) {
for (const auto layout : m_centralLayouts) {
if (!fixedMenuLayouts.contains(layout->name())) {
fixedMenuLayouts.prepend(layout->name());
}
for (const auto layout : m_centralLayouts) {
if (!fixedMenuLayouts.contains(layout->name())) {
fixedMenuLayouts.prepend(layout->name());
}
}
@ -374,7 +355,6 @@ void Synchronizer::addLayout(CentralLayout *layout)
void Synchronizer::onCurrentActivityChanged(const QString &id)
{
if (m_manager->memoryUsage() == MemoryUsage::MultipleLayouts) {
updateCurrentLayoutNameInMultiEnvironment();
updateKWinDisabledBorders();
}
}
@ -516,29 +496,14 @@ void Synchronizer::unloadLayouts()
m_multipleModeInitialized = false;
}
void Synchronizer::updateCurrentLayoutNameInMultiEnvironment()
{
for (const auto layout : m_centralLayouts) {
if (layout->activities().contains(m_manager->corona()->activitiesConsumer()->currentActivity())) {
setCurrentLayoutNameInMultiEnvironment(layout->name());
return;
}
}
for (const auto layout : m_centralLayouts) {
if (layout->activities().isEmpty()) {
setCurrentLayoutNameInMultiEnvironment(layout->name());
return;
}
}
}
bool Synchronizer::switchToLayout(QString layoutName, int previousMemoryUsage)
{
if (m_centralLayouts.size() > 0 && currentLayoutName() == layoutName && previousMemoryUsage == -1) {
if (m_centralLayouts.size() > 0 && previousMemoryUsage == -1) {
return false;
}
qDebug() << " >>>>> SWITCHING >> " << layoutName << " __ " << previousMemoryUsage;
//! First Check If that Layout is already present and in that case
//! we can just switch to the proper Activity
if (m_manager->memoryUsage() == MemoryUsage::MultipleLayouts && previousMemoryUsage == -1) {
@ -554,6 +519,8 @@ bool Synchronizer::switchToLayout(QString layoutName, int previousMemoryUsage)
return true;
}
}
} else if (m_manager->memoryUsage() == MemoryUsage::SingleLayout && m_centralLayouts.size()>0 && m_centralLayouts[0]->name() == layoutName) {
return false;
}
//! When going from memory usage to different memory usage we first
@ -569,7 +536,7 @@ bool Synchronizer::switchToLayout(QString layoutName, int previousMemoryUsage)
if ((m_manager->memoryUsage() == MemoryUsage::SingleLayout && !lPath.isEmpty()) || m_manager->memoryUsage() == MemoryUsage::MultipleLayouts) {
if (m_manager->memoryUsage() == MemoryUsage::SingleLayout) {
emit currentLayoutIsSwitching(currentLayoutName());
emit currentLayoutIsSwitching(m_centralLayouts[0]->name());
} else if (m_manager->memoryUsage() == MemoryUsage::MultipleLayouts && layoutName != Layout::MULTIPLELAYOUTSHIDDENNAME) {
//! do nothing
}
@ -609,12 +576,9 @@ bool Synchronizer::switchToLayout(QString layoutName, int previousMemoryUsage)
if (m_manager->memoryUsage() == MemoryUsage::MultipleLayouts) {
syncMultipleLayoutsToActivities();
}
m_manager->corona()->universalSettings()->setCurrentLayoutName(layoutName);
if (!isAssigned(layoutName)) {
m_manager->corona()->universalSettings()->setLastNonAssignedLayoutName(layoutName);
} else {
//! single layout
m_manager->corona()->universalSettings()->setCurrentLayoutName(layoutName);
}
});
} else {
@ -722,8 +686,6 @@ void Synchronizer::syncMultipleLayoutsToActivities()
qSort(currents);
qSort(layoutsToLoad);
updateCurrentLayoutNameInMultiEnvironment();
if (currents != layoutsToLoad) {
emit centralLayoutsChanged();
}

@ -84,12 +84,8 @@ public:
int centralLayoutPos(QString id) const;
QString currentLayoutName() const;
QString currentLayoutNameInMultiEnvironment() const;
void setCurrentLayoutNameInMultiEnvironment(const QString &name);
QStringList centralLayoutsNames();
QStringList currentLayoutsNames() const;
QStringList layouts() const;
QStringList menuLayouts() const;
void setMenuLayouts(QStringList layouts);
@ -120,7 +116,6 @@ public slots:
signals:
void centralLayoutsChanged();
void currentLayoutNameChanged();
void layoutsChanged();
void menuLayoutsChanged();
void runningActicitiesChanged();
@ -128,10 +123,7 @@ signals:
void currentLayoutIsSwitching(QString layoutName);
private slots:
void updateCurrentLayoutNameInMultiEnvironment();
void onCurrentActivityChanged(const QString &id);
void onLayoutAdded(const QString &layoutpath);
private:
@ -146,8 +138,6 @@ private:
bool m_multipleModeInitialized{false};
bool m_isLoaded{false};
QString m_currentLayoutNameInMultiEnvironment;
QStringList m_layouts;
QStringList m_menuLayouts;

@ -75,7 +75,7 @@ void ScreenGeometries::init()
connect(m_corona, &Latte::Corona::availableScreenRectChangedFrom, this, &ScreenGeometries::availableScreenGeometryChangedFrom);
connect(m_corona, &Latte::Corona::availableScreenRegionChangedFrom, this, &ScreenGeometries::availableScreenGeometryChangedFrom);
connect(m_corona->layoutsManager(), &Latte::Layouts::Manager::currentLayoutNameChanged, this, [&]() {
connect(m_corona->layoutsManager()->synchronizer(), &Latte::Layouts::Synchronizer::centralLayoutsChanged, this, [&]() {
m_publishTimer.start();
});

@ -414,7 +414,10 @@ void Layouts::loadLayouts()
m_model->setOriginalData(layoutsBuffer, inMultiple);
m_model->setOriginalLayoutForFreeActivities(layoutsBuffer.idForName(m_handler->corona()->universalSettings()->lastNonAssignedLayoutName()));
m_view->selectRow(rowForName(m_handler->corona()->layoutsManager()->currentLayoutName()));
QStringList currentLayoutNames = m_handler->corona()->layoutsManager()->currentLayoutsNames();
if (currentLayoutNames.count() > 0) {
m_view->selectRow(rowForName(currentLayoutNames[0]));
}
applyColumnWidths();
@ -609,7 +612,10 @@ bool Layouts::importLayoutsFromV1ConfigFile(QString file)
void Layouts::reset()
{
m_model->resetData();
m_view->selectRow(rowForName(m_handler->corona()->layoutsManager()->currentLayoutName()));
QStringList currentLayoutNames = m_handler->corona()->layoutsManager()->currentLayoutsNames();
if (currentLayoutNames.count() > 0) {
m_view->selectRow(rowForName(currentLayoutNames[0]));
}
}
void Layouts::save()
@ -687,10 +693,6 @@ void Layouts::save()
QString tempFile = layoutTempDir.path() + "/" + QString(generic->name() + ".layout.latte");
qDebug() << "new temp file ::: " << tempFile;
if ((m_handler->corona()->layoutsManager()->memoryUsage() == MemoryUsage::SingleLayout) && (generic->name() == m_handler->corona()->layoutsManager()->currentLayoutName())) {
switchToLayout = iLayoutCurrentData.name;
}
generic = m_layouts.take(iLayoutCurrentData.id);
delete generic;
@ -756,26 +758,25 @@ void Layouts::save()
//! reload layouts in layoutsmanager
m_handler->corona()->layoutsManager()->synchronizer()->loadLayouts();
if (!m_model->layoutNameForFreeActivities().isEmpty() || inMultipleMode()) {
//! make sure that there is a layout for free activities
//! send to layout manager in which layout to switch
MemoryUsage::LayoutsMemory inMemoryOption = Latte::MemoryUsage::SingleLayout;
if (inMultipleMode()) {
inMemoryOption = Latte::MemoryUsage::MultipleLayouts;
}
//! make sure that there is a layout for free activities
//! send to layout manager in which layout to switch
MemoryUsage::LayoutsMemory inMemoryOption = inMultipleMode() ? Latte::MemoryUsage::MultipleLayouts : Latte::MemoryUsage::SingleLayout;
if (m_handler->corona()->layoutsManager()->memoryUsage() != inMemoryOption) {
MemoryUsage::LayoutsMemory previousMemoryUsage = m_handler->corona()->layoutsManager()->memoryUsage();
m_handler->corona()->layoutsManager()->setMemoryUsage(inMemoryOption);
if (m_handler->corona()->layoutsManager()->memoryUsage() != inMemoryOption) {
MemoryUsage::LayoutsMemory previousMemoryUsage = m_handler->corona()->layoutsManager()->memoryUsage();
m_handler->corona()->layoutsManager()->setMemoryUsage(inMemoryOption);
m_handler->corona()->layoutsManager()->switchToLayout(m_model->layoutNameForFreeActivities(), previousMemoryUsage);
if (m_handler->corona()->layoutsManager()->memoryUsage() == MemoryUsage::SingleLayout) {
m_handler->corona()->layoutsManager()->switchToLayout(m_handler->corona()->universalSettings()->currentLayoutName(), previousMemoryUsage);
} else {
if (m_handler->corona()->layoutsManager()->memoryUsage() == MemoryUsage::MultipleLayouts) {
m_handler->corona()->layoutsManager()->synchronizer()->syncMultipleLayoutsToActivities();
} else {
m_handler->corona()->layoutsManager()->switchToLayout(m_model->layoutNameForFreeActivities());
}
m_handler->corona()->layoutsManager()->switchToLayout("", previousMemoryUsage);
}
} else {
if (m_handler->corona()->layoutsManager()->memoryUsage() == MemoryUsage::MultipleLayouts) {
m_handler->corona()->layoutsManager()->synchronizer()->syncMultipleLayoutsToActivities();
} else {
m_handler->corona()->layoutsManager()->switchToLayout(m_handler->corona()->universalSettings()->currentLayoutName());
}
}

@ -58,8 +58,6 @@ Layouts::Layouts(QObject *parent, Latte::Corona *corona)
emit dataChanged(index(0, NAMECOLUMN), index(rowCount()-1, ACTIVITYCOLUMN), roles);
});
connect(this, &Layouts::inMultipleModeChanged, this, &Layouts::updateActiveStates);
connect(m_corona->layoutsManager(), &Latte::Layouts::Manager::currentLayoutNameChanged, this, &Layouts::updateActiveStates);
connect(m_corona->layoutsManager(), &Latte::Layouts::Manager::centralLayoutsChanged, this, &Layouts::updateActiveStates);
}
@ -509,7 +507,10 @@ QVariant Layouts::data(const QModelIndex &index, int role) const
break;
case NAMECOLUMN:
if (role == SORTINGROLE) {
if (m_layoutsTable[row].isActive) {
if ((inMultipleMode() && m_layoutsTable[row].isActive)
|| (!inMultipleMode()
&& !original.name.isEmpty()
&& original.name == m_corona->universalSettings()->currentLayoutName())) {
return sortingPriority(HIGHESTPRIORITY, row);
}
@ -724,8 +725,7 @@ void Layouts::updateActiveStates()
for(int i=0; i<rowCount(); ++i) {
bool iActive{false};
if (m_inMultipleMode && m_corona->layoutsManager()->synchronizer()->layout(m_layoutsTable[i].name)
|| (!m_inMultipleMode && originalData(m_layoutsTable[i].id).name == m_corona->layoutsManager()->currentLayoutName())) {
if (m_corona->layoutsManager()->synchronizer()->layout(m_layoutsTable[i].name)) {
iActive = true;
}

@ -203,14 +203,14 @@ void Menu::populateLayouts()
if (m_data.size() > LAYOUTSPOS + 1) {
//when there are more than 1 layouts present
LayoutsMemoryUsage memoryUsage = static_cast<LayoutsMemoryUsage>((m_data[0]).toInt());
QString currentName = m_data[1];
QStringList currentNames = m_data[1].split(";;");
for (int i = LAYOUTSPOS; i < m_data.size(); ++i) {
bool isActive = m_data[i].startsWith("0") ? false : true;
QString layout = m_data[i].right(m_data[i].length() - 2);
QString currentText = (memoryUsage == MultipleLayouts && layout == currentName) ?
QString currentText = (memoryUsage == MultipleLayouts && currentNames.contains(layout)) ?
(" " + i18nc("current layout", "(Current)")) : "";
QString layoutName = layout + currentText;

Loading…
Cancel
Save