diff --git a/app/settings/settingsdialog/layoutscontroller.cpp b/app/settings/settingsdialog/layoutscontroller.cpp index 499e5feb3..1e4a7358f 100644 --- a/app/settings/settingsdialog/layoutscontroller.cpp +++ b/app/settings/settingsdialog/layoutscontroller.cpp @@ -216,36 +216,36 @@ QString Layouts::iconsPath() const return m_iconsPath; } -void Layouts::initializeSelectedLayoutViews() +const Latte::Data::ViewsTable Layouts::selectedLayoutViews() { + Latte::Data::ViewsTable views; int selectedRow = m_view->currentIndex().row(); - if (selectedRow >= 0) { - QString selectedId = m_proxyModel->data(m_proxyModel->index(selectedRow, Model::Layouts::IDCOLUMN), Qt::UserRole).toString(); - Data::Layout selectedCurrentData = m_model->currentData(selectedId); - if (!selectedCurrentData.views.isInitialized) { - Data::Layout originalSelectedData = selectedLayoutOriginalData(); - CentralLayout *central = m_handler->corona()->layoutsManager()->synchronizer()->centralLayout(originalSelectedData.name); + if (selectedRow < 0) { + return views; + } - bool islayoutactive{true}; + QString selectedId = m_proxyModel->data(m_proxyModel->index(selectedRow, Model::Layouts::IDCOLUMN), Qt::UserRole).toString(); + Data::Layout selectedCurrentData = m_model->currentData(selectedId); - if (!central) { - islayoutactive = false; - central = new CentralLayout(this, selectedCurrentData.id); - } + Data::Layout originalSelectedData = selectedLayoutOriginalData(); + CentralLayout *central = m_handler->corona()->layoutsManager()->synchronizer()->centralLayout(originalSelectedData.name); - selectedCurrentData.views = central->viewsTable(); - selectedCurrentData.views.isInitialized = true; - originalSelectedData.views = selectedCurrentData.views; + bool islayoutactive{true}; - m_model->setOriginalViewsForLayout(originalSelectedData); - m_model->setLayoutProperties(selectedCurrentData); + if (!central) { + islayoutactive = false; + central = new CentralLayout(this, selectedCurrentData.id); + } - if (!islayoutactive) { - central->deleteLater(); - } - } + selectedCurrentData.views = central->viewsTable(); + selectedCurrentData.views.isInitialized = true; + + if (!islayoutactive) { + central->deleteLater(); } + + return selectedCurrentData.views; } const Latte::Data::LayoutIcon Layouts::selectedLayoutIcon() const diff --git a/app/settings/settingsdialog/layoutscontroller.h b/app/settings/settingsdialog/layoutscontroller.h index 83a6e6232..9e0a6f2fc 100644 --- a/app/settings/settingsdialog/layoutscontroller.h +++ b/app/settings/settingsdialog/layoutscontroller.h @@ -77,6 +77,7 @@ public: const Latte::Data::Layout selectedLayoutCurrentData() const; const Latte::Data::Layout selectedLayoutOriginalData() const; const Latte::Data::LayoutIcon selectedLayoutIcon() const; + const Latte::Data::ViewsTable selectedLayoutViews(); void selectRow(const QString &id); void setLayoutProperties(const Latte::Data::Layout &layout); @@ -86,8 +87,7 @@ public: void save(); void removeSelected(); void toggleEnabledForSelected(); - void toggleLockedForSelected(); - void initializeSelectedLayoutViews(); + void toggleLockedForSelected(); QString iconsPath() const; QString colorPath(const QString color) const; diff --git a/app/settings/viewsdialog/viewshandler.cpp b/app/settings/viewsdialog/viewshandler.cpp index 056445454..ca31687fc 100644 --- a/app/settings/viewsdialog/viewshandler.cpp +++ b/app/settings/viewsdialog/viewshandler.cpp @@ -160,9 +160,8 @@ void ViewsHandler::initViewTemplatesSubMenu() void ViewsHandler::reload() { - m_dialog->layoutsController()->initializeSelectedLayoutViews(); - o_data = m_dialog->layoutsController()->selectedLayoutCurrentData(); + o_data.views = m_dialog->layoutsController()->selectedLayoutViews(); Latte::Data::LayoutIcon icon = m_dialog->layoutsController()->selectedLayoutIcon();