1
0
mirror of https://github.com/KDE/latte-dock.git synced 2025-01-11 13:18:13 +03:00

fix switch button for single layout mode

This commit is contained in:
Michail Vourlakos 2020-08-30 17:14:20 +03:00
parent 9428027aff
commit 5101a1314e
5 changed files with 60 additions and 17 deletions

View File

@ -158,6 +158,21 @@ bool Layouts::dataAreChanged() const
return m_model->dataAreChanged();
}
bool Layouts::layoutsAreChanged() const
{
return m_model->layoutsAreChanged();
}
bool Layouts::modeIsChanged() const
{
return m_model-modeIsChanged();
}
void Layouts::setOriginalInMultipleMode(const bool &inmultiple)
{
m_model->setOriginalInMultipleMode(inmultiple);
}
bool Layouts::hasSelectedLayout() const
{
int selectedRow = m_view->currentIndex().row();
@ -382,7 +397,8 @@ void Layouts::initLayouts()
}
//! Send original loaded data to model
m_model->setOriginalData(layouts, inMultiple);
m_model->setOriginalInMultipleMode(inMultiple);
m_model->setOriginalData(layouts);
QStringList currentLayoutNames = m_handler->corona()->layoutsManager()->currentLayoutsNames();
if (currentLayoutNames.count() > 0) {

View File

@ -65,6 +65,8 @@ public:
QTableView *view() const;
bool dataAreChanged() const;
bool layoutsAreChanged() const;
bool modeIsChanged() const;
bool inMultipleMode() const;
void setInMultipleMode(bool inMultiple);
@ -89,6 +91,8 @@ public:
QString layoutNameForFreeActivities() const;
void setOriginalLayoutForFreeActivities(const QString &id);
void setOriginalInMultipleMode(const bool &inmultiple);
void copySelectedLayout();
const Latte::Data::Layout addLayoutForFile(QString file, QString layoutName = QString(), bool newTempDirectory = true);
const Latte::Data::Layout addLayoutByText(QString rawLayoutText);

View File

@ -309,16 +309,20 @@ void TabLayouts::switchLayout()
Latte::Data::Layout selectedLayoutOriginal = m_layoutsController->selectedLayoutOriginalData();
selectedLayoutOriginal = selectedLayoutOriginal.isEmpty() ? selectedLayoutCurrent : selectedLayoutOriginal;
if (m_layoutsController->dataAreChanged()) {
if (m_layoutsController->layoutsAreChanged()) {
showInlineMessage(i18nc("settings:not permitted switching layout","You need to <b>apply</b> your changes first to switch layout..."),
KMessageWidget::Warning);
return;
}
if (!m_layoutsController->inMultipleMode()) {
m_corona->layoutsManager()->switchToLayout(selectedLayoutOriginal.name);
m_corona->layoutsManager()->switchToLayout(selectedLayoutOriginal.name, MemoryUsage::SingleLayout);
m_layoutsController->setOriginalInMultipleMode(false);
} else {
CentralLayout singleLayout(this, selectedLayoutCurrent.id);
m_corona->layoutsManager()->switchToLayout(selectedLayoutOriginal.name, MemoryUsage::MultipleLayouts);
m_layoutsController->setOriginalInMultipleMode(true);
/*CentralLayout singleLayout(this, selectedLayoutCurrent.id);
QString switchToActivity;
@ -354,7 +358,7 @@ void TabLayouts::switchLayout()
}
m_corona->layoutsManager()->synchronizer()->activitiesController()->setCurrentActivity(switchToActivity);
}
}*/
}
updatePerLayoutButtonsState();

View File

@ -73,7 +73,17 @@ bool Layouts::containsCurrentName(const QString &name) const
bool Layouts::dataAreChanged() const
{
return ((o_inMultipleMode != m_inMultipleMode) || (o_layoutsTable != m_layoutsTable));
return modeIsChanged() || layoutsAreChanged();
}
bool Layouts::modeIsChanged() const
{
return o_inMultipleMode != m_inMultipleMode;
}
bool Layouts::layoutsAreChanged() const
{
return o_layoutsTable != m_layoutsTable;
}
bool Layouts::inMultipleMode() const
@ -151,7 +161,8 @@ void Layouts::applyData()
void Layouts::resetData()
{
clear();
setOriginalData(o_layoutsTable, o_inMultipleMode);
setOriginalInMultipleMode(o_inMultipleMode);
setOriginalData(o_layoutsTable);
}
void Layouts::removeLayout(const QString &id)
@ -779,23 +790,27 @@ const Latte::Data::LayoutsTable &Layouts::currentLayoutsData()
return m_layoutsTable;
}
void Layouts::setOriginalData(Latte::Data::LayoutsTable &data, const bool &inmultiple)
void Layouts::setOriginalInMultipleMode(const bool &inmultiple)
{
setInMultipleMode(inmultiple);
if (o_inMultipleMode == inmultiple) {
return;
}
o_inMultipleMode = inmultiple;
emit inMultipleModeChanged();
}
void Layouts::setOriginalData(Latte::Data::LayoutsTable &data)
{
clear();
beginInsertRows(QModelIndex(), 0, data.rowCount() - 1);
o_inMultipleMode = inmultiple;
o_layoutsTable = data;
m_layoutsTable = data;
for(int i=0; i<m_layoutsTable.rowCount(); ++i) {
m_layoutsTable[i].isActive = m_corona->layoutsManager()->synchronizer()->layout(originalData(m_layoutsTable[i].id).name);
}
endInsertRows();
setInMultipleMode(inmultiple);
emit rowsInserted();
}

View File

@ -87,6 +87,8 @@ public:
bool containsCurrentName(const QString &name) const;
bool dataAreChanged() const;
bool layoutsAreChanged() const;
bool modeIsChanged() const;
bool inMultipleMode() const;
void setInMultipleMode(bool inMultiple);
@ -129,7 +131,9 @@ public:
const Latte::Data::LayoutsTable &currentLayoutsData();
const Latte::Data::LayoutsTable &originalLayoutsData();
void setOriginalData(Latte::Data::LayoutsTable &data, const bool &inmultiple);
void setOriginalInMultipleMode(const bool &inmultiple);
void setOriginalData(Latte::Data::LayoutsTable &data);
signals:
void inMultipleModeChanged();