fix crash from layouts reset functionality

pull/11/head
Michail Vourlakos 5 years ago
parent 00e6fbba5b
commit 00f4e4cd22

@ -141,6 +141,13 @@ bool Layouts::dataAreChanged() const
|| (o_layoutsOriginalData != m_model->currentData()));
}
bool Layouts::hasSelectedLayout() const
{
int selectedRow = m_view->currentIndex().row();
return (selectedRow >= 0);
}
bool Layouts::selectedLayoutIsCurrentActive() const
{
Data::Layout selected = selectedLayout();
@ -581,6 +588,7 @@ void Layouts::reset()
{
setOriginalInMultipleMode(o_originalInMultipleMode);
m_model->setCurrentData(o_layoutsOriginalData);
m_view->selectRow(rowForName(m_corona->layoutsManager()->currentLayoutName()));
}
void Layouts::save()

@ -59,6 +59,7 @@ public:
void setOriginalInMultipleMode(bool inMultiple);
bool hasSelectedLayout() const;
bool selectedLayoutIsCurrentActive() const;
const Data::Layout &selectedLayout() const;

@ -110,7 +110,7 @@ void Layouts::clear()
if (m_layoutsTable.rowCount() > 0) {
beginRemoveRows(QModelIndex(), 0, m_layoutsTable.rowCount() - 1);
m_layoutsTable.clear();
endInsertRows();
endRemoveRows();
}
}

@ -155,7 +155,6 @@ SettingsDialog::SettingsDialog(QWidget *parent, Latte::Corona *corona)
connect(m_layoutsController, &Settings::Controller::Layouts::dataChanged, this, [&]() {
updateApplyButtonsState();
updatePerLayoutButtonsState();
updateSharedLayoutsUiElements();
});
connect(m_inMemoryButtons, static_cast<void(QButtonGroup::*)(int, bool)>(&QButtonGroup::buttonToggled),
@ -630,7 +629,6 @@ void SettingsDialog::loadSettings()
o_settingsOriginalData = currentSettings();
updateApplyButtonsState();
updateSharedLayoutsUiElements();
}
QList<int> SettingsDialog::currentSettings()
@ -722,6 +720,10 @@ void SettingsDialog::updateApplyButtonsState()
void SettingsDialog::updatePerLayoutButtonsState()
{
if (!m_layoutsController->hasSelectedLayout()) {
return;
}
Settings::Data::Layout selectedLayout = m_layoutsController->selectedLayout();
//! Switch Button
@ -763,22 +765,19 @@ void SettingsDialog::updatePerLayoutButtonsState()
ui->lockedButton->setChecked(false);
}
//! Layout Shared Button
if (selectedLayout.isShared()) {
ui->sharedButton->setChecked(true);
} else {
ui->sharedButton->setChecked(false);
}
}
void SettingsDialog::updateSharedLayoutsUiElements()
{
//! UI Elements that need to be enabled/disabled
if (m_layoutsController->inMultipleMode()) {
ui->sharedButton->setVisible(true);
} else {
ui->sharedButton->setVisible(false);
}
//! Layout Shared Button
if (selectedLayout.isShared()) {
ui->sharedButton->setChecked(true);
} else {
ui->sharedButton->setChecked(false);
}
}
bool SettingsDialog::dataAreAccepted()

@ -87,6 +87,7 @@ private slots:
void restoreDefaults();
void showLayoutInformation();
void showScreensInformation();
void updateApplyButtonsState();
void updatePerLayoutButtonsState();
private:
@ -96,9 +97,6 @@ private:
void blockDeleteOnActivityStopped();
void loadSettings();
void updateApplyButtonsState();
void updateSharedLayoutsUiElements();
void saveAllChanges();
void setCurrentFreeActivitiesLayout(const int &row);

Loading…
Cancel
Save