1
0
mirror of https://github.com/KDE/latte-dock.git synced 2024-12-24 17:33:50 +03:00

improvements for view templates handling

This commit is contained in:
Michail Vourlakos 2021-02-13 21:12:32 +02:00
parent 7e92a79d4c
commit ea3d913757
5 changed files with 17 additions and 6 deletions

View File

@ -57,7 +57,6 @@ Manager::Manager(QObject *parent)
m_synchronizer = new Synchronizer(this); m_synchronizer = new Synchronizer(this);
if (m_corona) { if (m_corona) {
connect(m_synchronizer, &Synchronizer::centralLayoutsChanged, this, &Manager::centralLayoutsChanged); connect(m_synchronizer, &Synchronizer::centralLayoutsChanged, this, &Manager::centralLayoutsChanged);
connect(m_synchronizer, &Synchronizer::currentLayoutIsSwitching, this, &Manager::currentLayoutIsSwitching); connect(m_synchronizer, &Synchronizer::currentLayoutIsSwitching, this, &Manager::currentLayoutIsSwitching);
} }

View File

@ -110,6 +110,7 @@ public slots:
signals: signals:
void centralLayoutsChanged(); void centralLayoutsChanged();
void syncedLaunchersChanged(); void syncedLaunchersChanged();
void viewTemplatesChanged();
void currentLayoutIsSwitching(QString layoutName); void currentLayoutIsSwitching(QString layoutName);

View File

@ -678,6 +678,8 @@ bool Storage::exportTemplate(const Layout::GenericLayout *layout, Plasma::Contai
} }
} }
copied_conts.sync();
return true; return true;
} }

View File

@ -23,6 +23,7 @@
#include "../layout/abstractlayout.h" #include "../layout/abstractlayout.h"
#include "../layout/centrallayout.h" #include "../layout/centrallayout.h"
#include "../layouts/importer.h" #include "../layouts/importer.h"
#include "../layouts/manager.h"
#include "../layouts/storage.h" #include "../layouts/storage.h"
#include "../tools/commontools.h" #include "../tools/commontools.h"
#include "../view/view.h" #include "../view/view.h"
@ -52,6 +53,8 @@ Manager::~Manager()
void Manager::init() void Manager::init()
{ {
connect(this, &Manager::viewTemplatesChanged, m_corona->layoutsManager(), &Latte::Layouts::Manager::viewTemplatesChanged);
initLayoutTemplates(); initLayoutTemplates();
initViewTemplates(); initViewTemplates();
} }

View File

@ -542,13 +542,13 @@ Loader {
onActivated: { onActivated: {
var item = actionsModel.get(index); var item = actionsModel.get(index);
if (item.actionId === "new:") { if (item && item.actionId === "new:") {
latteView.layout.newView(item.templateId); latteView.layout.newView(item.templateId);
} else if (item.actionId === "export:") { } else if (item && item.actionId === "export:") {
latteView.exportTemplate(); latteView.exportTemplate();
} else if (item.actionId === "copy:") { } else if (item && item.actionId === "copy:") {
latteView.copyView(); latteView.copyView();
} else if (item.actionId === "move:") { } else if (item && item.actionId === "move:") {
var layouts = actionsComboBtn.centralLayoutsNames; var layouts = actionsComboBtn.centralLayoutsNames;
latteView.positioner.hideDockDuringMovingToLayout(layouts[index-1]); latteView.positioner.hideDockDuringMovingToLayout(layouts[index-1]);
} }
@ -585,6 +585,11 @@ Loader {
} }
} }
Connections {
target: layoutsManager
onViewTemplatesChanged: actionsComboBtn.updateModel();
}
function updateModel() { function updateModel() {
actionsModel.clear(); actionsModel.clear();
@ -622,7 +627,8 @@ Loader {
if (viewTemplateIds.length > 1) { if (viewTemplateIds.length > 1) {
var viewTemplateNames = layoutsManager.viewTemplateNames(); var viewTemplateNames = layoutsManager.viewTemplateNames();
for(var i=1; i<viewTemplateIds.length; ++i) { for(var i=viewTemplateIds.length-1; i>=1; --i) {
//! add view templates on reverse
var viewtemplate = { var viewtemplate = {
actionId: 'new:', actionId: 'new:',
enabled: true, enabled: true,