diff --git a/app/settings/settingsdialog/layoutscontroller.cpp b/app/settings/settingsdialog/layoutscontroller.cpp index 6ac4cb315..80b374eb0 100644 --- a/app/settings/settingsdialog/layoutscontroller.cpp +++ b/app/settings/settingsdialog/layoutscontroller.cpp @@ -313,6 +313,17 @@ void Layouts::setInMultipleMode(bool inMultiple) m_model->setInMultipleMode(inMultiple); } +CentralLayout *Layouts::centralLayout(const QString ¤tLayoutId) +{ + 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) { bool isLastModeMultiple = !m_model->inMultipleMode(); diff --git a/app/settings/settingsdialog/layoutscontroller.h b/app/settings/settingsdialog/layoutscontroller.h index 8fccad888..a6ec06dfe 100644 --- a/app/settings/settingsdialog/layoutscontroller.h +++ b/app/settings/settingsdialog/layoutscontroller.h @@ -28,6 +28,7 @@ #include "../../lattecorona.h" #include "../../data/layoutdata.h" #include "../../data/layoutstable.h" +#include "../../layout/centrallayout.h" // Qt #include @@ -110,6 +111,8 @@ public: const Latte::Data::Layout addLayoutForFile(QString file, QString layoutName = QString(), bool newTempDirectory = true); const Latte::Data::Layout addLayoutByText(QString rawLayoutText); + CentralLayout *centralLayout(const QString ¤tLayoutId); + //! import layouts from Latte versions <= v0.7.x bool importLayoutsFromV1ConfigFile(QString file); diff --git a/app/settings/settingsdialog/tablayoutshandler.cpp b/app/settings/settingsdialog/tablayoutshandler.cpp index bef381777..6b44ae69e 100644 --- a/app/settings/settingsdialog/tablayoutshandler.cpp +++ b/app/settings/settingsdialog/tablayoutshandler.cpp @@ -601,6 +601,12 @@ void TabLayouts::exportLayoutAsTemplate() Data::Layout exp_layout = o_layout; 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); exportDlg->exec(); } diff --git a/app/settings/viewsdialog/viewscontroller.cpp b/app/settings/viewsdialog/viewscontroller.cpp index c8cbce36a..1f81c7e31 100644 --- a/app/settings/viewsdialog/viewscontroller.cpp +++ b/app/settings/viewsdialog/viewscontroller.cpp @@ -417,7 +417,7 @@ void Views::onCurrentLayoutChanged() QObject::disconnect(var); } - Latte::CentralLayout *currentlayout = m_handler->centralLayout(currentlayoutdata.id); + Latte::CentralLayout *currentlayout = m_handler->layoutsController()->centralLayout(currentlayoutdata.id); if (currentlayout && currentlayout->isActive()) { m_currentLayoutConnections << connect(currentlayout, &Layout::GenericLayout::viewsCountChanged, this, [&, currentlayout](){ @@ -651,7 +651,7 @@ void Views::showDefaultInlineMessageValidator() 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()) { KSharedConfigPtr lFile = KSharedConfig::openConfig(centrallayout->file()); //! update configuration with latest changes @@ -861,7 +861,7 @@ void Views::messageForWarningOrphanedSubContainments(const Data::Warning &warnin Latte::Data::Layout currentlayout = m_handler->currentData(); 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; iremoveOrphanedSubContainment(orphaned[i]); @@ -883,7 +883,7 @@ void Views::save() Latte::Data::Layout originallayout = m_handler->originalData(); 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 Latte::Data::ViewsTable originalViews = m_model->originalViewsData(); @@ -957,7 +957,7 @@ void Views::save() //! Be Careful: Remove deprecated views from Cut->Paste Action QString origincurrentid = cuttedpastedviews[vid].originLayout(); 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); diff --git a/app/settings/viewsdialog/viewshandler.cpp b/app/settings/viewsdialog/viewshandler.cpp index 9b1a47da5..b4e460858 100644 --- a/app/settings/viewsdialog/viewshandler.cpp +++ b/app/settings/viewsdialog/viewshandler.cpp @@ -282,17 +282,6 @@ void ViewsHandler::save() } } -CentralLayout *ViewsHandler::centralLayout(const QString ¤tLayoutId) -{ - 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) { Latte::Data::View viewdata = m_viewsController->currentData(viewId); @@ -302,7 +291,7 @@ QString ViewsHandler::storedView(const QString &viewId) } if (viewdata.isCreated()) { - CentralLayout *central = centralLayout(currentData().id); + CentralLayout *central = m_dialog->layoutsController()->centralLayout(currentData().id); return central->storedView(viewdata.id.toInt()); } else if (viewdata.hasViewTemplateOrigin() || viewdata.hasLayoutOrigin()) { return viewdata.originFile(); diff --git a/app/settings/viewsdialog/viewshandler.h b/app/settings/viewsdialog/viewshandler.h index ddfe4e1fc..e1af33430 100644 --- a/app/settings/viewsdialog/viewshandler.h +++ b/app/settings/viewsdialog/viewshandler.h @@ -77,8 +77,6 @@ public: Latte::Data::Layout currentData() const; Latte::Data::Layout originalData() const; - CentralLayout *centralLayout(const QString ¤tLayoutId); - Ui::ViewsDialog *ui() const; Latte::Corona *corona() const; Settings::Controller::Layouts *layoutsController() const;