fix export layout template for active layouts

--newly created docks and panels in active layouts
must first be synced into their original file before
being exported
pull/22/head
Michail Vourlakos 4 years ago
parent 4017eb599c
commit a03dca9d02

@ -313,6 +313,17 @@ void Layouts::setInMultipleMode(bool inMultiple)
m_model->setInMultipleMode(inMultiple); m_model->setInMultipleMode(inMultiple);
} }
CentralLayout *Layouts::centralLayout(const QString &currentLayoutId)
{
Data::Layout originlayoutdata = originalData(currentLayoutId);
auto activelayout = isLayoutOriginal(currentLayoutId) ?
m_handler->corona()->layoutsManager()->synchronizer()->centralLayout(originlayoutdata.name) : nullptr;
Latte::CentralLayout *centrallayout = activelayout ? activelayout : new Latte::CentralLayout(this, currentLayoutId);
return centrallayout;
}
void Layouts::applyColumnWidths(bool storeValues) void Layouts::applyColumnWidths(bool storeValues)
{ {
bool isLastModeMultiple = !m_model->inMultipleMode(); bool isLastModeMultiple = !m_model->inMultipleMode();

@ -28,6 +28,7 @@
#include "../../lattecorona.h" #include "../../lattecorona.h"
#include "../../data/layoutdata.h" #include "../../data/layoutdata.h"
#include "../../data/layoutstable.h" #include "../../data/layoutstable.h"
#include "../../layout/centrallayout.h"
// Qt // Qt
#include <QAbstractItemModel> #include <QAbstractItemModel>
@ -110,6 +111,8 @@ public:
const Latte::Data::Layout addLayoutForFile(QString file, QString layoutName = QString(), bool newTempDirectory = true); const Latte::Data::Layout addLayoutForFile(QString file, QString layoutName = QString(), bool newTempDirectory = true);
const Latte::Data::Layout addLayoutByText(QString rawLayoutText); const Latte::Data::Layout addLayoutByText(QString rawLayoutText);
CentralLayout *centralLayout(const QString &currentLayoutId);
//! import layouts from Latte versions <= v0.7.x //! import layouts from Latte versions <= v0.7.x
bool importLayoutsFromV1ConfigFile(QString file); bool importLayoutsFromV1ConfigFile(QString file);

@ -601,6 +601,12 @@ void TabLayouts::exportLayoutAsTemplate()
Data::Layout exp_layout = o_layout; Data::Layout exp_layout = o_layout;
exp_layout.name = c_layout.name; exp_layout.name = c_layout.name;
CentralLayout *central = m_layoutsController->centralLayout(c_layout.id);
if (central->isActive()) {
central->syncToLayoutFile();
}
Dialog::ExportTemplateDialog *exportDlg = new Dialog::ExportTemplateDialog(m_parentDialog, exp_layout); Dialog::ExportTemplateDialog *exportDlg = new Dialog::ExportTemplateDialog(m_parentDialog, exp_layout);
exportDlg->exec(); exportDlg->exec();
} }

@ -417,7 +417,7 @@ void Views::onCurrentLayoutChanged()
QObject::disconnect(var); QObject::disconnect(var);
} }
Latte::CentralLayout *currentlayout = m_handler->centralLayout(currentlayoutdata.id); Latte::CentralLayout *currentlayout = m_handler->layoutsController()->centralLayout(currentlayoutdata.id);
if (currentlayout && currentlayout->isActive()) { if (currentlayout && currentlayout->isActive()) {
m_currentLayoutConnections << connect(currentlayout, &Layout::GenericLayout::viewsCountChanged, this, [&, currentlayout](){ m_currentLayoutConnections << connect(currentlayout, &Layout::GenericLayout::viewsCountChanged, this, [&, currentlayout](){
@ -651,7 +651,7 @@ void Views::showDefaultInlineMessageValidator()
connect(validateaction, &QAction::triggered, this, [&, currentlayout]() { connect(validateaction, &QAction::triggered, this, [&, currentlayout]() {
auto centrallayout = m_handler->centralLayout(currentlayout.id); auto centrallayout = m_handler->layoutsController()->centralLayout(currentlayout.id);
if (centrallayout && !centrallayout->isActive()) { if (centrallayout && !centrallayout->isActive()) {
KSharedConfigPtr lFile = KSharedConfig::openConfig(centrallayout->file()); KSharedConfigPtr lFile = KSharedConfig::openConfig(centrallayout->file());
//! update configuration with latest changes //! update configuration with latest changes
@ -861,7 +861,7 @@ void Views::messageForWarningOrphanedSubContainments(const Data::Warning &warnin
Latte::Data::Layout currentlayout = m_handler->currentData(); Latte::Data::Layout currentlayout = m_handler->currentData();
connect(repairlayoutaction, &QAction::triggered, this, [&, currentlayout, orphaned]() { connect(repairlayoutaction, &QAction::triggered, this, [&, currentlayout, orphaned]() {
auto centrallayout = m_handler->centralLayout(currentlayout.id); auto centrallayout = m_handler->layoutsController()->centralLayout(currentlayout.id);
for (int i=0; i<orphaned.count(); ++i) { for (int i=0; i<orphaned.count(); ++i) {
centrallayout->removeOrphanedSubContainment(orphaned[i]); centrallayout->removeOrphanedSubContainment(orphaned[i]);
@ -883,7 +883,7 @@ void Views::save()
Latte::Data::Layout originallayout = m_handler->originalData(); Latte::Data::Layout originallayout = m_handler->originalData();
Latte::Data::Layout currentlayout = m_handler->currentData(); Latte::Data::Layout currentlayout = m_handler->currentData();
Latte::CentralLayout *central = m_handler->centralLayout(currentlayout.id); Latte::CentralLayout *central = m_handler->layoutsController()->centralLayout(currentlayout.id);
//! views in model //! views in model
Latte::Data::ViewsTable originalViews = m_model->originalViewsData(); Latte::Data::ViewsTable originalViews = m_model->originalViewsData();
@ -957,7 +957,7 @@ void Views::save()
//! Be Careful: Remove deprecated views from Cut->Paste Action //! Be Careful: Remove deprecated views from Cut->Paste Action
QString origincurrentid = cuttedpastedviews[vid].originLayout(); QString origincurrentid = cuttedpastedviews[vid].originLayout();
Data::Layout originlayout = m_handler->layoutsController()->originalData(origincurrentid); Data::Layout originlayout = m_handler->layoutsController()->originalData(origincurrentid);
Latte::CentralLayout *origin = m_handler->centralLayout(originlayout.id); Latte::CentralLayout *origin = m_handler->layoutsController()->centralLayout(originlayout.id);
Data::ViewsTable originviews = Latte::Layouts::Storage::self()->views(origin); Data::ViewsTable originviews = Latte::Layouts::Storage::self()->views(origin);

@ -282,17 +282,6 @@ void ViewsHandler::save()
} }
} }
CentralLayout *ViewsHandler::centralLayout(const QString &currentLayoutId)
{
Data::Layout originlayoutdata = layoutsController()->originalData(currentLayoutId);
auto activelayout = layoutsController()->isLayoutOriginal(currentLayoutId) ?
corona()->layoutsManager()->synchronizer()->centralLayout(originlayoutdata.name) : nullptr;
Latte::CentralLayout *centrallayout = activelayout ? activelayout : new Latte::CentralLayout(this, currentLayoutId);
return centrallayout;
}
QString ViewsHandler::storedView(const QString &viewId) QString ViewsHandler::storedView(const QString &viewId)
{ {
Latte::Data::View viewdata = m_viewsController->currentData(viewId); Latte::Data::View viewdata = m_viewsController->currentData(viewId);
@ -302,7 +291,7 @@ QString ViewsHandler::storedView(const QString &viewId)
} }
if (viewdata.isCreated()) { if (viewdata.isCreated()) {
CentralLayout *central = centralLayout(currentData().id); CentralLayout *central = m_dialog->layoutsController()->centralLayout(currentData().id);
return central->storedView(viewdata.id.toInt()); return central->storedView(viewdata.id.toInt());
} else if (viewdata.hasViewTemplateOrigin() || viewdata.hasLayoutOrigin()) { } else if (viewdata.hasViewTemplateOrigin() || viewdata.hasLayoutOrigin()) {
return viewdata.originFile(); return viewdata.originFile();

@ -77,8 +77,6 @@ public:
Latte::Data::Layout currentData() const; Latte::Data::Layout currentData() const;
Latte::Data::Layout originalData() const; Latte::Data::Layout originalData() const;
CentralLayout *centralLayout(const QString &currentLayoutId);
Ui::ViewsDialog *ui() const; Ui::ViewsDialog *ui() const;
Latte::Corona *corona() const; Latte::Corona *corona() const;
Settings::Controller::Layouts *layoutsController() const; Settings::Controller::Layouts *layoutsController() const;

Loading…
Cancel
Save