move views between Active/SharedLayouts

--the move to layout option under View Settings
window now can enable the user to move view
between Active and Shared Layouts
pull/5/head
Michail Vourlakos
parent e417a8d4ba
commit 913c35523f

@ -340,6 +340,18 @@ QStringList LayoutManager::activeLayoutsNames()
}
QStringList LayoutManager::sharedLayoutsNames()
{
QStringList names;
for (int i = 0; i < m_sharedLayouts.size(); ++i) {
SharedLayout *layout = m_sharedLayouts.at(i);
names << layout->name();
}
return names;
}
Layout::GenericLayout *LayoutManager::layout(QString id) const
{
Layout::GenericLayout *l = activeLayout(id);
@ -404,7 +416,7 @@ bool LayoutManager::assignActiveToSharedLayout(ActiveLayout *active, QString id)
if (layout->name() == id) {
layout->addActiveLayout(active);
// syncLatteViewsToScreens();
// syncLatteViewsToScreens();
return true;
}
}
@ -413,7 +425,7 @@ bool LayoutManager::assignActiveToSharedLayout(ActiveLayout *active, QString id)
SharedLayout *top = new SharedLayout(active, this, Importer::layoutFilePath(id));
m_sharedLayouts.append(top);
top->importToCorona();
// syncLatteViewsToScreens();
// syncLatteViewsToScreens();
return true;
}
@ -736,7 +748,7 @@ bool LayoutManager::switchToLayout(QString layoutName, int previousMemoryUsage)
if (!lPath.isEmpty()) {
if (memoryUsage() == Types::SingleLayout) {
// emit currentLayoutIsSwitching(currentLayoutName());
// emit currentLayoutIsSwitching(currentLayoutName());
} else if (memoryUsage() == Types::MultipleLayouts && layoutName != Layout::AbstractLayout::MultipleLayoutsName) {
ActiveLayout toLayout(this, lPath);

@ -136,6 +136,7 @@ public slots:
Q_INVOKABLE QString newLayout(QString layoutName, QString preset = i18n("Default"));
Q_INVOKABLE QStringList activeLayoutsNames();
Q_INVOKABLE QStringList sharedLayoutsNames();
signals:
void activeLayoutsChanged();

@ -872,7 +872,7 @@ void View::moveToLayout(QString layoutName)
Latte::Corona *latteCorona = qobject_cast<Latte::Corona *>(this->corona());
if (latteCorona && containments.size() > 0) {
Layout::GenericLayout *newLayout = latteCorona->layoutManager()->activeLayout(layoutName);
Layout::GenericLayout *newLayout = latteCorona->layoutManager()->layout(layoutName);
if (newLayout) {
newLayout->assignToLayout(this, containments);

@ -552,6 +552,7 @@ FocusScope {
comboBoxMinimumPopUpWidth: actionsModel.count > 1 ? dialog.width / 2 : 150
property var activeLayoutsNames;
property var sharedLayoutsNames;
Component.onCompleted: {
comboBox.model = actionsModel;
@ -574,7 +575,9 @@ FocusScope {
if (index==0) {
latteView.copyView();
} else if (index>=1) {
latteView.positioner.hideDockDuringMovingToLayout(activeLayoutsNames[index-1]);
var layouts = actionsComboBtn.sharedLayoutsNames.concat(actionsComboBtn.activeLayoutsNames);
latteView.positioner.hideDockDuringMovingToLayout(layouts[index-1]);
}
actionsComboBtn.comboBox.currentIndex = -1;
@ -609,16 +612,35 @@ FocusScope {
updateCopyText();
var tempActiveLayouts = layoutManager.activeLayoutsNames();
var currentLayoutIndex = tempActiveLayouts.indexOf(latteView.managedLayout.name);
var tempSharedLayouts = layoutManager.sharedLayoutsNames();
if (tempSharedLayouts.length > 0) {
var curIndex = tempSharedLayouts.indexOf(latteView.managedLayout.name);
if (curIndex >=0) {
tempSharedLayouts.splice(curIndex,1);
}
sharedLayoutsNames = tempSharedLayouts;
var icon = "document-share";
for(var i=0; i<sharedLayoutsNames.length; ++i) {
var layout = {actionId: 'move:', enabled: true, name: i18n("Move to: %0").arg(sharedLayoutsNames[i]), icon: icon};
actionsModel.append(layout);
}
}
tempActiveLayouts.splice(currentLayoutIndex,1);
if (tempActiveLayouts.length > 0) {
var curIndex = tempActiveLayouts.indexOf(latteView.managedLayout.name);
if (curIndex >=0) {
tempActiveLayouts.splice(curIndex,1);
}
activeLayoutsNames = tempActiveLayouts;
var iconArrow = Qt.application.layoutDirection === Qt.RightToLeft ? 'arrow-left' : 'arrow-right';
for(var i=0; i<activeLayoutsNames.length; ++i) {
var layout = {actionId: 'move:', name: i18n("Move to: %0").arg(activeLayoutsNames[i]), icon: iconArrow};
var layout = {actionId: 'move:', enabled: true, name: i18n("Move to: %0").arg(activeLayoutsNames[i]), icon: iconArrow};
actionsModel.append(layout);
}
}

Loading…
Cancel
Save