mirror of
https://github.com/KDE/latte-dock.git
synced 2025-01-11 13:18:13 +03:00
simplify code for switch button-single layout
This commit is contained in:
parent
0724124f63
commit
748ca87bb8
@ -72,6 +72,11 @@ Synchronizer::~Synchronizer()
|
||||
m_activitiesController->deleteLater();
|
||||
}
|
||||
|
||||
KActivities::Controller *Synchronizer::activitiesController() const
|
||||
{
|
||||
return m_activitiesController;
|
||||
}
|
||||
|
||||
bool Synchronizer::latteViewExists(Latte::View *view) const
|
||||
{
|
||||
for (const auto layout : m_centralLayouts) {
|
||||
|
@ -111,6 +111,8 @@ public:
|
||||
SharedLayout *sharedLayout(QString id) const;
|
||||
Layout::GenericLayout *layout(QString id) const;
|
||||
|
||||
KActivities::Controller *activitiesController() const;
|
||||
|
||||
signals:
|
||||
void centralLayoutsChanged();
|
||||
void currentLayoutNameChanged();
|
||||
|
@ -654,12 +654,30 @@ void SettingsDialog::on_switchButton_clicked()
|
||||
|
||||
if (!m_layoutsController->selectedLayoutIsCurrentActive()) {
|
||||
bool appliedShared = m_layoutsController->inMultipleMode() && selectedLayout.isShared();
|
||||
bool freeActivitiesLayoutUpdated{false};
|
||||
|
||||
if (!appliedShared && selectedLayout.activities.isEmpty()) {
|
||||
m_layoutsController->setLayoutNameForFreeActivities(selectedLayout.currentName(), true);
|
||||
freeActivitiesLayoutUpdated = true;
|
||||
}
|
||||
|
||||
m_corona->layoutsManager()->switchToLayout(selectedLayout.originalName());
|
||||
if (m_layoutsController->inMultipleMode()) {
|
||||
m_corona->layoutsManager()->switchToLayout(selectedLayout.originalName());
|
||||
} else {
|
||||
if (freeActivitiesLayoutUpdated) {
|
||||
m_corona->layoutsManager()->switchToLayout(selectedLayout.originalName());
|
||||
} else {
|
||||
CentralLayout singleLayout(this, selectedLayout.id);
|
||||
|
||||
QString switchToActivity = selectedLayout.isForFreeActivities() ? singleLayout.lastUsedActivity() : selectedLayout.activities[0];
|
||||
|
||||
if (!m_corona->activitiesConsumer()->runningActivities().contains(switchToActivity)) {
|
||||
m_corona->layoutsManager()->synchronizer()->activitiesController()->startActivity(switchToActivity);
|
||||
}
|
||||
|
||||
m_corona->layoutsManager()->synchronizer()->activitiesController()->setCurrentActivity(switchToActivity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
updatePerLayoutButtonsState();
|
||||
|
Loading…
Reference in New Issue
Block a user