1
0
mirror of https://github.com/KDE/latte-dock.git synced 2024-12-23 01:33:50 +03:00

move layout connections in the view

--any view and view::containment() signals that
are related to layout are now moved in the
View::setLayout() in order to be reinitialized
properly when the view changes to another
layout
This commit is contained in:
Michail Vourlakos 2019-05-09 23:45:52 +03:00
parent 6248a0ccae
commit c6cd3f4685
6 changed files with 37 additions and 23 deletions

View File

@ -735,7 +735,6 @@ void GenericLayout::addView(Plasma::Containment *containment, bool forceOnPrimar
latteView->init();
latteView->setContainment(containment);
latteView->setLayout(this);
//! force this special dock case to become primary
//! even though it isnt
@ -744,15 +743,7 @@ void GenericLayout::addView(Plasma::Containment *containment, bool forceOnPrimar
latteView->setOnPrimary(true);
}
// connect(containment, &QObject::destroyed, this, &GenericLayout::containmentDestroyed);
connect(containment, &Plasma::Applet::destroyedChanged, this, &GenericLayout::destroyedChanged);
connect(containment, &Plasma::Applet::locationChanged, m_corona, &Latte::Corona::viewLocationChanged);
connect(containment, &Plasma::Containment::appletAlternativesRequested
, m_corona, &Latte::Corona::showAlternativesForApplet, Qt::QueuedConnection);
if (m_corona->layoutsManager()->memoryUsage() == Types::MultipleLayouts) {
connect(containment, &Plasma::Containment::appletCreated, this, &GenericLayout::appletCreated);
}
latteView->setLayout(this);
//! Qt 5.9 creates a crash for this in wayland, that is why the check is used
//! but on the other hand we need this for copy to work correctly and show
@ -842,9 +833,13 @@ void GenericLayout::assignToLayout(Latte::View *latteView, QList<Plasma::Contain
for (const auto containment : containments) {
containment->config().writeEntry("layoutId", name());
connect(containment, &QObject::destroyed, this, &GenericLayout::containmentDestroyed);
connect(containment, &Plasma::Applet::destroyedChanged, this, &GenericLayout::destroyedChanged);
connect(containment, &Plasma::Containment::appletCreated, this, &GenericLayout::appletCreated);
if (latteView->containment() != containment) {
//! assign signals only to systrays
//! the View::setLayout() is responsible for the View::Containment signals
connect(containment, &QObject::destroyed, this, &GenericLayout::containmentDestroyed);
connect(containment, &Plasma::Applet::destroyedChanged, this, &GenericLayout::destroyedChanged);
connect(containment, &Plasma::Containment::appletCreated, this, &GenericLayout::appletCreated);
}
}
latteView->setLayout(this);
@ -874,6 +869,8 @@ QList<Plasma::Containment *> GenericLayout::unassignFromLayout(Latte::View *latt
//! add systrays from that latteView
if (parentApplet && parentApplet->containment() && parentApplet->containment() == latteView->containment()) {
containments << containment;
//! unassign signals only to systrays
//! the View::setLayout() is responsible for the View::Containment signals
disconnect(containment, &QObject::destroyed, this, &GenericLayout::containmentDestroyed);
disconnect(containment, &Plasma::Applet::destroyedChanged, this, &GenericLayout::destroyedChanged);
disconnect(containment, &Plasma::Containment::appletCreated, this, &GenericLayout::appletCreated);

View File

@ -132,8 +132,8 @@ public slots:
signals:
void activitiesChanged(); // to move at an interface
void viewsCountChanged();
void viewEdgeChanged();
//! used from ConfigView(s) in order to be informed which is one should be shown
void configViewCreated(QQuickView *configView);
@ -181,6 +181,7 @@ private:
QPointer<Storage> m_storage;
friend class Storage;
friend class Latte::View;
};
}

View File

@ -567,6 +567,8 @@ void Positioner::initSignalingForLocationChangeSliding()
//! view must be deleted
m_view->layout()->syncLatteViewsToScreens();
}
emit edgeChanged();
});
}
});
@ -587,6 +589,8 @@ void Positioner::initSignalingForLocationChangeSliding()
//! view must be deleted
m_view->layout()->syncLatteViewsToScreens();
}
emit edgeChanged();
});
}
});
@ -601,6 +605,7 @@ void Positioner::initSignalingForLocationChangeSliding()
m_view->effects()->setAnimationsBlocked(false);
emit showDockAfterMovingToLayoutFinished();
m_view->showSettingsWindow();
emit edgeChanged();
});
}
});

View File

@ -69,6 +69,7 @@ public slots:
signals:
void currentScreenChanged();
void edgeChanged();
void screenGeometryChanged();
void windowSizeChanged();

View File

@ -802,6 +802,16 @@ void View::setLayout(Layout::GenericLayout *layout)
m_layout = layout;
if (m_layout) {
connectionsLayout << connect(containment(), &Plasma::Applet::destroyedChanged, m_layout, &Layout::GenericLayout::destroyedChanged);
connectionsLayout << connect(containment(), &Plasma::Applet::locationChanged, m_corona, &Latte::Corona::viewLocationChanged);
connectionsLayout << connect(containment(), &Plasma::Containment::appletAlternativesRequested, m_corona, &Latte::Corona::showAlternativesForApplet, Qt::QueuedConnection);
if (m_corona->layoutsManager()->memoryUsage() == Types::MultipleLayouts) {
connectionsLayout << connect(containment(), &Plasma::Containment::appletCreated, m_layout, &Layout::GenericLayout::appletCreated);
}
connectionsLayout << connect(m_positioner, &Latte::ViewPart::Positioner::edgeChanged, m_layout, &Layout::GenericLayout::viewEdgeChanged);
//! Sometimes the activity isnt completely ready, by adding a delay
//! we try to catch up
QTimer::singleShot(100, [this]() {
@ -812,13 +822,13 @@ void View::setLayout(Layout::GenericLayout *layout)
}
});
connectionsLayout[0] = connect(m_layout, &Layout::GenericLayout::preferredViewForShortcutsChanged, this, &View::preferredViewForShortcutsChangedSlot);
connectionsLayout[1] = connect(m_layout, &Layout::GenericLayout::configViewCreated, this, &View::configViewCreated);
connectionsLayout << connect(m_layout, &Layout::GenericLayout::preferredViewForShortcutsChanged, this, &View::preferredViewForShortcutsChangedSlot);
connectionsLayout << connect(m_layout, &Layout::GenericLayout::configViewCreated, this, &View::configViewCreated);
Latte::Corona *latteCorona = qobject_cast<Latte::Corona *>(this->corona());
if (latteCorona->layoutsManager()->memoryUsage() == Types::MultipleLayouts) {
connectionsLayout[2] = connect(latteCorona->activitiesConsumer(), &KActivities::Consumer::runningActivitiesChanged, this, [&]() {
connectionsLayout << connect(latteCorona->activitiesConsumer(), &KActivities::Consumer::runningActivitiesChanged, this, [&]() {
if (m_layout && m_visibility) {
qDebug() << "DOCK VIEW FROM LAYOUT (runningActivitiesChanged) ::: " << m_layout->name()
<< " - activities: " << m_layout->appliedActivities();
@ -827,14 +837,14 @@ void View::setLayout(Layout::GenericLayout *layout)
}
});
connectionsLayout[3] = connect(m_layout, &Layout::GenericLayout::activitiesChanged, this, [&]() {
connectionsLayout << connect(m_layout, &Layout::GenericLayout::activitiesChanged, this, [&]() {
if (m_layout) {
applyActivitiesToWindows();
emit activitiesChanged();
}
});
connectionsLayout[4] = connect(latteCorona->layoutsManager(), &Layouts::Manager::layoutsChanged, this, [&]() {
connectionsLayout << connect(latteCorona->layoutsManager(), &Layouts::Manager::layoutsChanged, this, [&]() {
if (m_layout) {
applyActivitiesToWindows();
emit activitiesChanged();
@ -850,14 +860,14 @@ void View::setLayout(Layout::GenericLayout *layout)
m_visibleHackTimer1.setSingleShot(true);
m_visibleHackTimer2.setSingleShot(true);
connectionsLayout[5] = connect(this, &QWindow::visibleChanged, this, [&]() {
connectionsLayout << connect(this, &QWindow::visibleChanged, this, [&]() {
if (m_layout && !inDelete() & !isVisible()) {
m_visibleHackTimer1.start();
m_visibleHackTimer2.start();
}
});
connectionsLayout[6] = connect(&m_visibleHackTimer1, &QTimer::timeout, this, [&]() {
connectionsLayout << connect(&m_visibleHackTimer1, &QTimer::timeout, this, [&]() {
if (m_layout && !inDelete() & !isVisible()) {
setVisible(true);
applyActivitiesToWindows();
@ -865,7 +875,7 @@ void View::setLayout(Layout::GenericLayout *layout)
}
});
connectionsLayout[7] = connect(&m_visibleHackTimer2, &QTimer::timeout, this, [&]() {
connectionsLayout << connect(&m_visibleHackTimer2, &QTimer::timeout, this, [&]() {
if (m_layout && !inDelete() && !isVisible()) {
setVisible(true);
applyActivitiesToWindows();

View File

@ -323,7 +323,7 @@ private:
QPointer<ViewPart::WindowsTracker> m_windowsTracker;
//! Connections to release and bound for the assigned layout
std::array<QMetaObject::Connection, 8> connectionsLayout;
QList<QMetaObject::Connection> connectionsLayout;
QPointer<Latte::Corona> m_corona;