fix Switch behavior for Multiple Layouts

pull/2/head
Michail Vourlakos 7 years ago
parent 18b94c795b
commit fa379144e9

@ -1326,6 +1326,13 @@ void DockView::setManagedLayout(Layout *layout)
}
});
connect(dockCorona->layoutManager(), &LayoutManager::layoutsChanged, this, [&]() {
if (m_managedLayout) {
m_visibility->setDockOnActivities(m_managedLayout->appliedActivities());
emit activitiesChanged();
}
});
//!IMPORTANT!!! ::: This fixes a bug when closing an Activity all docks from all Activities are
//! disappearing! With this they reappear!!!
connect(this, &QWindow::visibleChanged, this, [&]() {

@ -36,6 +36,7 @@
#include <QStandardItemModel>
#include <QTemporaryDir>
#include <KActivities/Controller>
#include <KArchive/KTar>
#include <KArchive/KArchiveEntry>
#include <KArchive/KArchiveDirectory>
@ -684,13 +685,20 @@ void LayoutConfigDialog::currentLayoutNameChanged()
QVariant value = m_model->data(nameIndex);
if (value.isValid()) {
QString name = value.toString();
QFont font;
if (m_manager->currentLayoutName() == value.toString()) {
if (m_manager->currentLayoutName() == name) {
font.setBold(true);
ui->layoutsView->selectRow(i);
} else {
font.setBold(false);
Layout *layout = m_manager->activeLayout(name);
if (layout && (m_manager->memoryUsage() == Dock::MultipleLayouts)) {
font.setBold(true);
} else {
font.setBold(false);
}
}
m_model->setData(nameIndex, font, Qt::FontRole);
@ -892,6 +900,8 @@ bool LayoutConfigDialog::saveAllChanges()
if (!switchToLayout.isNull()) {
m_manager->switchToLayout(switchToLayout);
} else if (m_manager->memoryUsage() == Dock::MultipleLayouts) {
m_manager->syncMultipleLayoutsToActivities();
}
return true;

@ -34,6 +34,10 @@ namespace Ui {
class LayoutConfigDialog;
}
namespace KActivities {
class Controller;
}
namespace Latte {
class LayoutManager;
class Layout;

@ -29,6 +29,7 @@
#include <QtDBus/QtDBus>
#include <KActivities/Consumer>
#include <KActivities/Controller>
#include <KLocalizedString>
#include <KNotification>
@ -39,7 +40,8 @@ const int MultipleLayoutsPresetId = 10;
LayoutManager::LayoutManager(QObject *parent)
: QObject(parent),
m_importer(new Importer(this)),
m_launchersSignals(new LaunchersSignals(this))
m_launchersSignals(new LaunchersSignals(this)),
m_activitiesController(new KActivities::Controller(this))
{
m_corona = qobject_cast<DockCorona *>(parent);
@ -71,6 +73,8 @@ LayoutManager::~LayoutManager()
layout->unloadDockViews();
layout->deleteLater();
}
m_activitiesController->deleteLater();
}
void LayoutManager::load()
@ -563,6 +567,20 @@ bool LayoutManager::switchToLayout(QString layoutName)
return false;
}
//! First Check If that Layout is already present
if (memoryUsage() == Dock::MultipleLayouts) {
Layout *layout = activeLayout(layoutName);
if (layout) {
QStringList appliedActivities = layout->appliedActivities();
if (!appliedActivities.contains(m_corona->activitiesConsumer()->currentActivity())) {
m_activitiesController->setCurrentActivity(appliedActivities[0]);
return true;
}
}
}
QString lPath = layoutPath(layoutName);
if (lPath.isEmpty() && layoutName == i18n("Alternative")) {
@ -570,7 +588,9 @@ bool LayoutManager::switchToLayout(QString layoutName)
}
if (!lPath.isEmpty()) {
emit currentLayoutIsChanging();
if (memoryUsage() == Dock::SingleLayout) {
emit currentLayoutIsChanging();
}
//! this code must be called asynchronously because it is called
//! also from qml (Tasks plasmoid). This change fixes a very important
@ -611,8 +631,23 @@ bool LayoutManager::switchToLayout(QString layoutName)
emit activeLayoutsChanged();
}
if (memoryUsage() == Dock::MultipleLayouts) {
syncMultipleLayoutsToActivities(layoutName);
if (memoryUsage() == Dock::MultipleLayouts) {
if (!initializingMultipleLayouts && !activeLayout(layoutName)
&& m_assignedLayouts.values().contains(layoutName)) {
//! When we are in Multiple Layouts Environment and the user activates
//! a Layout that is assigned to specific activities but this
//! layout isnt loaded (this means neither of its activities are running)
//! is such case we just activate these Activities
Layout layout(this, Importer::layoutFilePath(layoutName));
foreach (auto assignedActivity, layout.activities()) {
m_activitiesController->startActivity(assignedActivity);
}
m_activitiesController->setCurrentActivity(layout.activities()[0]);
} else {
syncMultipleLayoutsToActivities(layoutName);
}
}
m_corona->universalSettings()->setCurrentLayoutName(layoutName);

@ -37,6 +37,10 @@ class Layout;
class LayoutConfigDialog;
class LaunchersSignals;
namespace KActivities {
class Controller;
}
namespace Latte {
//! This class is responsible to manipulate all layouts.
@ -171,6 +175,8 @@ private:
Layout *m_currentLayout{nullptr};
QList<Layout *> m_activeLayouts;
KActivities::Controller *m_activitiesController;
friend class LayoutConfigDialog;
};

Loading…
Cancel
Save