mirror of
https://github.com/KDE/latte-dock.git
synced 2024-12-23 13:33:50 +03:00
settings:initialize and set views in layouts model
--this action may be costly so it is executed only once when Views dialog is requesting data for specific layout
This commit is contained in:
parent
f255de4ce6
commit
1348863b57
@ -205,12 +205,46 @@ QString Layouts::iconsPath() const
|
||||
return m_iconsPath;
|
||||
}
|
||||
|
||||
void Layouts::initializeSelectedLayoutViews()
|
||||
{
|
||||
int selectedRow = m_view->currentIndex().row();
|
||||
if (selectedRow >= 0) {
|
||||
QString selectedId = m_proxyModel->data(m_proxyModel->index(selectedRow, Model::Layouts::IDCOLUMN), Qt::UserRole).toString();
|
||||
Latte::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);
|
||||
|
||||
bool islayoutactive{true};
|
||||
|
||||
if (!central) {
|
||||
islayoutactive = false;
|
||||
central = new CentralLayout(this, originalSelectedData.id);
|
||||
}
|
||||
|
||||
selectedCurrentData.views = central->viewsTable();
|
||||
selectedCurrentData.views.isInitialized = true;
|
||||
originalSelectedData.views = selectedCurrentData.views;
|
||||
|
||||
m_model->setOriginalViewsForLayout(originalSelectedData);
|
||||
m_model->setLayoutProperties(selectedCurrentData);
|
||||
|
||||
qDebug() << "Views For Original Layout :: " << originalSelectedData.name;
|
||||
selectedCurrentData.views.print();
|
||||
|
||||
if (!islayoutactive) {
|
||||
central->deleteLater();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const Latte::Data::Layout Layouts::selectedLayoutCurrentData() const
|
||||
{
|
||||
int selectedRow = m_view->currentIndex().row();
|
||||
if (selectedRow >= 0) {
|
||||
QString selectedId = m_proxyModel->data(m_proxyModel->index(selectedRow, Model::Layouts::IDCOLUMN), Qt::UserRole).toString();
|
||||
|
||||
return m_model->currentData(selectedId);
|
||||
} else {
|
||||
return Latte::Data::Layout();
|
||||
|
@ -85,6 +85,7 @@ public:
|
||||
void removeSelected();
|
||||
void toggleEnabledForSelected();
|
||||
void toggleLockedForSelected();
|
||||
void initializeSelectedLayoutViews();
|
||||
|
||||
QString iconsPath() const;
|
||||
QString colorPath(const QString color) const;
|
||||
|
@ -678,6 +678,13 @@ void Layouts::setOriginalActivitiesForLayout(const Latte::Data::Layout &layout)
|
||||
}
|
||||
}
|
||||
|
||||
void Layouts::setOriginalViewsForLayout(const Latte::Data::Layout &layout)
|
||||
{
|
||||
if (o_layoutsTable.containsId(layout.id) && m_layoutsTable.containsId(layout.id)) {
|
||||
o_layoutsTable[layout.id].views = layout.views;
|
||||
}
|
||||
}
|
||||
|
||||
void Layouts::setActivities(const int &row, const QStringList &activities)
|
||||
{
|
||||
if (!m_layoutsTable.rowExists(row) || m_layoutsTable[row].activities == activities) {
|
||||
|
@ -143,6 +143,7 @@ public:
|
||||
void setOriginalData(Latte::Data::LayoutsTable &data);
|
||||
|
||||
void setOriginalActivitiesForLayout(const Latte::Data::Layout &layout);
|
||||
void setOriginalViewsForLayout(const Latte::Data::Layout &layout);
|
||||
|
||||
signals:
|
||||
void inMultipleModeChanged();
|
||||
|
@ -79,35 +79,12 @@ void ViewsHandler::init()
|
||||
|
||||
void ViewsHandler::reload()
|
||||
{
|
||||
m_dialog->layoutsController()->initializeSelectedLayoutViews();
|
||||
|
||||
o_data = m_dialog->layoutsController()->selectedLayoutCurrentData();
|
||||
|
||||
bool islayoutalreadyloaded{o_data == c_data};
|
||||
|
||||
c_data = o_data;
|
||||
|
||||
m_ui->layoutsCmb->setCurrentText(o_data.name);
|
||||
|
||||
loadLayout(c_data);
|
||||
|
||||
if (!islayoutalreadyloaded) {
|
||||
//! Views
|
||||
Data::Layout originalSelectedData = m_dialog->layoutsController()->selectedLayoutOriginalData();
|
||||
CentralLayout *central = m_dialog->corona()->layoutsManager()->synchronizer()->centralLayout(originalSelectedData.name);
|
||||
|
||||
bool islayoutactive{true};
|
||||
|
||||
if (!central) {
|
||||
islayoutactive = false;
|
||||
central = new CentralLayout(this, originalSelectedData.id);
|
||||
}
|
||||
|
||||
qDebug() << "Views For Original Layout :: " << originalSelectedData.name;
|
||||
central->viewsTable().print();
|
||||
|
||||
if (!islayoutactive) {
|
||||
central->deleteLater();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ViewsHandler::loadLayout(const Latte::Data::Layout &data)
|
||||
|
Loading…
Reference in New Issue
Block a user