mirror of
https://github.com/KDE/latte-dock.git
synced 2024-12-23 01:33:50 +03:00
update Switch button in Layouts table
This commit is contained in:
parent
f31c698330
commit
a9774ff13f
@ -183,7 +183,7 @@ const QStringList CentralLayout::appliedActivities()
|
||||
if (isOnAllActivities() || m_corona->layoutsManager()->memoryUsage() == MemoryUsage::SingleLayout) {
|
||||
return QStringList(Data::Layout::ALLACTIVITIESID);
|
||||
} else if (isForFreeActivities()) {
|
||||
return m_corona->layoutsManager()->synchronizer()->freeActivities();
|
||||
return m_corona->layoutsManager()->synchronizer()->freeRunningActivities();
|
||||
} else {
|
||||
return m_activities;
|
||||
}
|
||||
|
@ -164,12 +164,23 @@ QStringList Synchronizer::activities()
|
||||
return m_manager->corona()->activitiesConsumer()->activities();
|
||||
}
|
||||
|
||||
QStringList Synchronizer::freeActivities()
|
||||
{
|
||||
QStringList frees = activities();
|
||||
|
||||
for(auto assigned : m_assignedLayouts.keys()) {
|
||||
frees.removeAll(assigned);
|
||||
}
|
||||
|
||||
return frees;
|
||||
}
|
||||
|
||||
QStringList Synchronizer::runningActivities()
|
||||
{
|
||||
return m_manager->corona()->activitiesConsumer()->runningActivities();
|
||||
}
|
||||
|
||||
QStringList Synchronizer::freeActivities()
|
||||
QStringList Synchronizer::freeRunningActivities()
|
||||
{
|
||||
QStringList fActivities;
|
||||
|
||||
|
@ -95,8 +95,9 @@ public:
|
||||
void setMenuLayouts(QStringList layouts);
|
||||
|
||||
QStringList activities();
|
||||
QStringList freeActivities();
|
||||
QStringList runningActivities();
|
||||
QStringList freeActivities(); //! These are activities that haven't been assigned to specific layout
|
||||
QStringList freeRunningActivities(); //! These are activities that haven't been assigned to specific layout
|
||||
|
||||
Latte::View *viewForContainment(Plasma::Containment *containment);
|
||||
Latte::View *viewForContainment(uint id);
|
||||
|
@ -166,15 +166,6 @@ bool Layouts::hasSelectedLayout() const
|
||||
return (selectedRow >= 0);
|
||||
}
|
||||
|
||||
bool Layouts::selectedLayoutIsCurrentActive() const
|
||||
{
|
||||
Latte::Data::Layout selectedLayoutCurrent = selectedLayoutCurrentData();
|
||||
Latte::Data::Layout selectedLayoutOriginal = selectedLayoutOriginalData();
|
||||
selectedLayoutOriginal = selectedLayoutOriginal.isEmpty() ? selectedLayoutCurrent : selectedLayoutOriginal;
|
||||
|
||||
return (selectedLayoutCurrent.isActive && (selectedLayoutOriginal.name == m_handler->corona()->layoutsManager()->currentLayoutName()));
|
||||
}
|
||||
|
||||
QString Layouts::colorPath(const QString color) const
|
||||
{
|
||||
QString path = m_iconsPath + color + "print.jpg";
|
||||
|
@ -71,7 +71,6 @@ public:
|
||||
void sortByColumn(int column, Qt::SortOrder order);
|
||||
|
||||
bool hasSelectedLayout() const;
|
||||
bool selectedLayoutIsCurrentActive() const;
|
||||
const Latte::Data::Layout selectedLayoutCurrentData() const;
|
||||
const Latte::Data::Layout selectedLayoutOriginalData() const;
|
||||
|
||||
|
@ -315,7 +315,47 @@ void TabLayouts::switchLayout()
|
||||
return;
|
||||
}
|
||||
|
||||
m_corona->layoutsManager()->switchToLayout(selectedLayoutOriginal.name);
|
||||
if (!m_layoutsController->inMultipleMode()) {
|
||||
m_corona->layoutsManager()->switchToLayout(selectedLayoutOriginal.name);
|
||||
} else {
|
||||
CentralLayout singleLayout(this, selectedLayoutCurrent.id);
|
||||
|
||||
QString switchToActivity;
|
||||
|
||||
if (selectedLayoutCurrent.isForFreeActivities()) {
|
||||
QStringList freerunningactivities = m_corona->layoutsManager()->synchronizer()->freeRunningActivities();
|
||||
|
||||
if (freerunningactivities.count() > 0) {
|
||||
if (freerunningactivities.contains(singleLayout.lastUsedActivity())) {
|
||||
switchToActivity = singleLayout.lastUsedActivity();
|
||||
} else {
|
||||
switchToActivity = freerunningactivities[0];
|
||||
}
|
||||
} else {
|
||||
QStringList freepausedactivities = m_corona->layoutsManager()->synchronizer()->freeActivities();
|
||||
|
||||
if (freepausedactivities.count() > 0) {
|
||||
switchToActivity = freepausedactivities[0];
|
||||
}
|
||||
}
|
||||
} else if (!selectedLayoutCurrent.activities.isEmpty()) {
|
||||
QStringList activities = m_corona->layoutsManager()->synchronizer()->activities();
|
||||
|
||||
if (selectedLayoutCurrent.activities.contains(singleLayout.lastUsedActivity())) {
|
||||
switchToActivity = singleLayout.lastUsedActivity();
|
||||
} else {
|
||||
switchToActivity = selectedLayoutCurrent.activities[0];
|
||||
}
|
||||
}
|
||||
|
||||
if (!switchToActivity.isEmpty()) {
|
||||
if (!m_corona->activitiesConsumer()->runningActivities().contains(switchToActivity)) {
|
||||
m_corona->layoutsManager()->synchronizer()->activitiesController()->startActivity(switchToActivity);
|
||||
}
|
||||
|
||||
m_corona->layoutsManager()->synchronizer()->activitiesController()->setCurrentActivity(switchToActivity);
|
||||
}
|
||||
}
|
||||
|
||||
updatePerLayoutButtonsState();
|
||||
}
|
||||
@ -356,7 +396,7 @@ void TabLayouts::updatePerLayoutButtonsState()
|
||||
Latte::Data::Layout selectedLayout = m_layoutsController->selectedLayoutCurrentData();
|
||||
|
||||
//! Switch Button
|
||||
if (m_layoutsController->selectedLayoutIsCurrentActive()) {
|
||||
if (m_layoutsController->inMultipleMode() && selectedLayout.activities.isEmpty()) {
|
||||
setTwinProperty(m_switchLayoutAction, TWINENABLED, false);
|
||||
} else {
|
||||
setTwinProperty(m_switchLayoutAction, TWINENABLED, true);
|
||||
@ -364,8 +404,7 @@ void TabLayouts::updatePerLayoutButtonsState()
|
||||
|
||||
//! Pause Button - enabled
|
||||
if (m_layoutsController->inMultipleMode()) {
|
||||
if (selectedLayout.isActive
|
||||
&& !selectedLayout.isForFreeActivities()) {
|
||||
if (selectedLayout.isActive && !selectedLayout.isForFreeActivities()) {
|
||||
setTwinProperty(m_pauseLayoutAction, TWINENABLED, true);
|
||||
} else {
|
||||
setTwinProperty(m_pauseLayoutAction, TWINENABLED, false);
|
||||
|
Loading…
Reference in New Issue
Block a user