multiple fixes for single layout case

pull/11/head
Michail Vourlakos 5 years ago
parent 748ca87bb8
commit ba94546cb4

@ -289,16 +289,10 @@ const QStringList CentralLayout::appliedActivities()
return {};
}
if (m_corona->layoutsManager()->memoryUsage() == Types::SingleLayout) {
return {"0"};
} else if (m_corona->layoutsManager()->memoryUsage() == Types::MultipleLayouts) {
if (m_activities.isEmpty()) {
return m_corona->layoutsManager()->synchronizer()->freeActivities();
} else {
return m_activities;
}
if (m_activities.isEmpty()) {
return m_corona->layoutsManager()->synchronizer()->freeActivities();
} else {
return {"0"};
return m_activities;
}
}

@ -969,8 +969,7 @@ void GenericLayout::updateLastUsedActivity()
QStringList appliedActivitiesIds = appliedActivities();
if (m_lastUsedActivity != currentId
&& (appliedActivitiesIds.contains(currentId)
|| m_corona->layoutsManager()->memoryUsage() == Types::SingleLayout)) {
&& appliedActivitiesIds.contains(currentId)) {
m_lastUsedActivity = currentId;
emit lastUsedActivityChanged();

@ -205,7 +205,7 @@ QStringList Synchronizer::freeActivities()
QStringList fActivities;
for (const auto &activity : activities()) {
if (m_assignedLayouts[activity].isEmpty()) {
if (!m_assignedLayouts.contains(activity)) {
fActivities.append(activity);
}
}
@ -267,7 +267,8 @@ QString Synchronizer::shouldSwitchToLayout(QString activityId)
{
if (m_assignedLayouts.contains(activityId) && m_assignedLayouts[activityId] != currentLayoutName()) {
return m_assignedLayouts[activityId];
} else if (!m_assignedLayouts.contains(activityId) && !m_manager->corona()->universalSettings()->lastNonAssignedLayoutName().isEmpty()
} else if (!m_assignedLayouts.contains(activityId)
&& !m_manager->corona()->universalSettings()->lastNonAssignedLayoutName().isEmpty()
&& m_manager->corona()->universalSettings()->lastNonAssignedLayoutName() != currentLayoutName()) {
return m_manager->corona()->universalSettings()->lastNonAssignedLayoutName();
}
@ -447,9 +448,9 @@ void Synchronizer::confirmDynamicSwitch()
void Synchronizer::currentActivityChanged(const QString &id)
{
if (m_manager->memoryUsage() == Types::SingleLayout) {
qDebug() << "activity changed :: " << id;
m_shouldSwitchToLayout = shouldSwitchToLayout(id);
qDebug() << "activity changed :: " << id;
qDebug() << "should switch to layout :: " << m_shouldSwitchToLayout;
m_dynamicSwitchTimer.start();
} else if (m_manager->memoryUsage() == Types::MultipleLayouts) {

@ -553,6 +553,7 @@ void Layouts::copySelectedLayout()
}
CentralLayout *settings = new CentralLayout(this, copied.id);
settings->clearLastUsedActivity();
m_layouts[copied.id] = settings;
m_model->appendLayout(copied);

@ -85,8 +85,6 @@ SettingsDialog::SettingsDialog(QWidget *parent, Latte::Corona *corona)
if (KWindowSystem::isPlatformWayland()) {
m_inMemoryButtons->button(Latte::Types::MultipleLayouts)->setEnabled(false);
} else {
KWindowSystem::setOnActivities(winId(), QStringList());
}
m_mouseSensitivityButtons = new QButtonGroup(this);
@ -214,7 +212,10 @@ SettingsDialog::SettingsDialog(QWidget *parent, Latte::Corona *corona)
connect(infoLayoutAction, &QAction::triggered, this, &SettingsDialog::showLayoutInformation);
connect(screensAction, &QAction::triggered, this, &SettingsDialog::showScreensInformation);
blockDeleteOnActivityStopped();
m_activitiesTimer.setSingleShot(true);
m_activitiesTimer.setInterval(750);
connect(&m_activitiesTimer, &QTimer::timeout, this, &SettingsDialog::updateWindowActivities);
m_activitiesTimer.start();
}
SettingsDialog::~SettingsDialog()
@ -224,28 +225,13 @@ SettingsDialog::~SettingsDialog()
m_corona->universalSettings()->setLayoutsWindowSize(size());
}
void SettingsDialog::blockDeleteOnActivityStopped()
{
connect(m_corona->activitiesConsumer(), &KActivities::Consumer::runningActivitiesChanged,
this, [&]() {
m_blockDeleteOnReject = true;
m_activityClosedTimer.start();
});
m_activityClosedTimer.setSingleShot(true);
m_activityClosedTimer.setInterval(500);
connect(&m_activityClosedTimer, &QTimer::timeout, this, [&]() {
m_blockDeleteOnReject = false;
});
}
void SettingsDialog::toggleCurrentPage()
{
if (ui->tabWidget->currentIndex() == 0) {
ui->tabWidget->setCurrentIndex(1);
} else {
ui->tabWidget->setCurrentIndex(0);
}
}
}
void SettingsDialog::setCurrentPage(int page)
@ -538,7 +524,7 @@ void SettingsDialog::requestImagesDialog(int row)
QStringList files = dialog.selectedFiles();
if (files.count() > 0) {
// m_model->setData(m_model->index(row, COLORCOLUMN), files[0], Qt::BackgroundRole);
// m_model->setData(m_model->index(row, COLORCOLUMN), files[0], Qt::BackgroundRole);
}
}
}
@ -796,7 +782,7 @@ void SettingsDialog::updatePerLayoutButtonsState()
void SettingsDialog::showLayoutInformation()
{
/* int currentRow = ui->layoutsView->currentIndex().row();
/* int currentRow = ui->layoutsView->currentIndex().row();
QString id = m_model->data(m_model->index(currentRow, IDCOLUMN), Qt::DisplayRole).toString();
QString name = m_model->data(m_model->index(currentRow, NAMECOLUMN), Qt::DisplayRole).toString();
@ -813,7 +799,7 @@ void SettingsDialog::showLayoutInformation()
void SettingsDialog::showScreensInformation()
{
/* QList<int> assignedScreens;
/* QList<int> assignedScreens;
for (int i = 0; i < m_model->rowCount(); ++i) {
QString id = m_model->data(m_model->index(i, IDCOLUMN), Qt::DisplayRole).toString();
@ -838,6 +824,13 @@ void SettingsDialog::showScreensInformation()
msg->open();*/
}
void SettingsDialog::updateWindowActivities()
{
if (KWindowSystem::isPlatformX11()) {
KWindowSystem::setOnActivities(winId(), QStringList());
}
}
void SettingsDialog::saveAllChanges()
{
//! Update universal settings

@ -87,12 +87,9 @@ private slots:
void showScreensInformation();
void updateApplyButtonsState();
void updatePerLayoutButtonsState();
void updateWindowActivities();
private:
//! When an activity is closed for some reason the window manager hides and reshows
//! the windows. This function prevents this because we don't want to delete the window
//! on reject in such case.
void blockDeleteOnActivityStopped();
void loadSettings();
void saveAllChanges();
@ -112,10 +109,8 @@ private:
KHelpMenu *m_helpMenu{nullptr};
//! workaround to avoid dialog closing when kwin decides faulty to close it
//! because of Activities changes
QTimer m_activityClosedTimer;
bool m_blockDeleteOnReject{false};
//! workaround to assign ALLACTIVITIES during startup
QTimer m_activitiesTimer;
//! original data
QList<int> o_settingsOriginalData;

Loading…
Cancel
Save