mirror of
https://github.com/KDE/latte-dock.git
synced 2024-12-23 13: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) {
|
if (isOnAllActivities() || m_corona->layoutsManager()->memoryUsage() == MemoryUsage::SingleLayout) {
|
||||||
return QStringList(Data::Layout::ALLACTIVITIESID);
|
return QStringList(Data::Layout::ALLACTIVITIESID);
|
||||||
} else if (isForFreeActivities()) {
|
} else if (isForFreeActivities()) {
|
||||||
return m_corona->layoutsManager()->synchronizer()->freeActivities();
|
return m_corona->layoutsManager()->synchronizer()->freeRunningActivities();
|
||||||
} else {
|
} else {
|
||||||
return m_activities;
|
return m_activities;
|
||||||
}
|
}
|
||||||
|
@ -164,12 +164,23 @@ QStringList Synchronizer::activities()
|
|||||||
return m_manager->corona()->activitiesConsumer()->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()
|
QStringList Synchronizer::runningActivities()
|
||||||
{
|
{
|
||||||
return m_manager->corona()->activitiesConsumer()->runningActivities();
|
return m_manager->corona()->activitiesConsumer()->runningActivities();
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList Synchronizer::freeActivities()
|
QStringList Synchronizer::freeRunningActivities()
|
||||||
{
|
{
|
||||||
QStringList fActivities;
|
QStringList fActivities;
|
||||||
|
|
||||||
|
@ -95,8 +95,9 @@ public:
|
|||||||
void setMenuLayouts(QStringList layouts);
|
void setMenuLayouts(QStringList layouts);
|
||||||
|
|
||||||
QStringList activities();
|
QStringList activities();
|
||||||
|
QStringList freeActivities();
|
||||||
QStringList runningActivities();
|
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(Plasma::Containment *containment);
|
||||||
Latte::View *viewForContainment(uint id);
|
Latte::View *viewForContainment(uint id);
|
||||||
|
@ -166,15 +166,6 @@ bool Layouts::hasSelectedLayout() const
|
|||||||
return (selectedRow >= 0);
|
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 Layouts::colorPath(const QString color) const
|
||||||
{
|
{
|
||||||
QString path = m_iconsPath + color + "print.jpg";
|
QString path = m_iconsPath + color + "print.jpg";
|
||||||
|
@ -71,7 +71,6 @@ public:
|
|||||||
void sortByColumn(int column, Qt::SortOrder order);
|
void sortByColumn(int column, Qt::SortOrder order);
|
||||||
|
|
||||||
bool hasSelectedLayout() const;
|
bool hasSelectedLayout() const;
|
||||||
bool selectedLayoutIsCurrentActive() const;
|
|
||||||
const Latte::Data::Layout selectedLayoutCurrentData() const;
|
const Latte::Data::Layout selectedLayoutCurrentData() const;
|
||||||
const Latte::Data::Layout selectedLayoutOriginalData() const;
|
const Latte::Data::Layout selectedLayoutOriginalData() const;
|
||||||
|
|
||||||
|
@ -315,7 +315,47 @@ void TabLayouts::switchLayout()
|
|||||||
return;
|
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();
|
updatePerLayoutButtonsState();
|
||||||
}
|
}
|
||||||
@ -356,7 +396,7 @@ void TabLayouts::updatePerLayoutButtonsState()
|
|||||||
Latte::Data::Layout selectedLayout = m_layoutsController->selectedLayoutCurrentData();
|
Latte::Data::Layout selectedLayout = m_layoutsController->selectedLayoutCurrentData();
|
||||||
|
|
||||||
//! Switch Button
|
//! Switch Button
|
||||||
if (m_layoutsController->selectedLayoutIsCurrentActive()) {
|
if (m_layoutsController->inMultipleMode() && selectedLayout.activities.isEmpty()) {
|
||||||
setTwinProperty(m_switchLayoutAction, TWINENABLED, false);
|
setTwinProperty(m_switchLayoutAction, TWINENABLED, false);
|
||||||
} else {
|
} else {
|
||||||
setTwinProperty(m_switchLayoutAction, TWINENABLED, true);
|
setTwinProperty(m_switchLayoutAction, TWINENABLED, true);
|
||||||
@ -364,8 +404,7 @@ void TabLayouts::updatePerLayoutButtonsState()
|
|||||||
|
|
||||||
//! Pause Button - enabled
|
//! Pause Button - enabled
|
||||||
if (m_layoutsController->inMultipleMode()) {
|
if (m_layoutsController->inMultipleMode()) {
|
||||||
if (selectedLayout.isActive
|
if (selectedLayout.isActive && !selectedLayout.isForFreeActivities()) {
|
||||||
&& !selectedLayout.isForFreeActivities()) {
|
|
||||||
setTwinProperty(m_pauseLayoutAction, TWINENABLED, true);
|
setTwinProperty(m_pauseLayoutAction, TWINENABLED, true);
|
||||||
} else {
|
} else {
|
||||||
setTwinProperty(m_pauseLayoutAction, TWINENABLED, false);
|
setTwinProperty(m_pauseLayoutAction, TWINENABLED, false);
|
||||||
|
Loading…
Reference in New Issue
Block a user