1
0
mirror of https://github.com/KDE/latte-dock.git synced 2024-12-25 09:33:51 +03:00

a way to not delete hidden config windows

This commit is contained in:
Michail Vourlakos 2020-05-15 12:56:57 +03:00
parent 20994f9bdf
commit 1dcf799d42
4 changed files with 66 additions and 38 deletions

View File

@ -124,10 +124,6 @@ PrimaryConfigView::PrimaryConfigView(Plasma::Containment *containment, Latte::Vi
connections << connect(m_corona, &Latte::Corona::raiseViewsTemporaryChanged, this, &PrimaryConfigView::raiseDocksTemporaryChanged);
connections << connect(m_corona, &Latte::Corona::availableScreenRectChangedFrom, this, &PrimaryConfigView::updateAvailableScreenGeometry);
}
if (m_latteView->layout()) {
emit m_latteView->layout()->setLastConfigViewFor(m_latteView);
}
}
PrimaryConfigView::~PrimaryConfigView()
@ -143,7 +139,9 @@ PrimaryConfigView::~PrimaryConfigView()
m_corona->wm()->unregisterIgnoredWindow(KWindowSystem::isPlatformX11() ? winId() : m_waylandWindowId);
deleteSecondaryWindow();
if (m_secConfigView) {
m_secConfigView->deleteLater();
}
for (const auto &var : connections) {
QObject::disconnect(var);
@ -210,22 +208,26 @@ QQuickView *PrimaryConfigView::secondaryWindow()
return m_secConfigView;
}
void PrimaryConfigView::createSecondaryWindow()
void PrimaryConfigView::showSecondaryWindow()
{
if (m_secConfigView) {
return;
if (!m_secConfigView) {
m_secConfigView = new SecondaryConfigView(m_latteView, this);
m_secConfigView->init();
} else if (m_secConfigView && !m_latteView->hiddenConfigWindowsAreDeleted() && !m_secConfigView->isVisible()){
m_secConfigView->show();
}
m_secConfigView = new SecondaryConfigView(m_latteView, this);
m_secConfigView->init();
}
void PrimaryConfigView::deleteSecondaryWindow()
void PrimaryConfigView::hideSecondaryWindow()
{
if (m_secConfigView) {
auto secWindow = m_secConfigView;
m_secConfigView = nullptr;
secWindow->deleteLater();
if (m_latteView->hiddenConfigWindowsAreDeleted()) {
auto secWindow = m_secConfigView;
m_secConfigView = nullptr;
secWindow->deleteLater();
} else {
m_secConfigView->hide();
}
if (KWindowSystem::isPlatformX11() && m_latteView->effects()) {
//! this is needed in order for subtracked mask of secondary window to
@ -341,7 +343,7 @@ void PrimaryConfigView::syncGeometry()
m_shellSurface->setPosition(position);
}
updateShowInlineProperties();
// updateShowInlineProperties();
emit m_latteView->configWindowGeometryChanged();
}
@ -393,20 +395,31 @@ void PrimaryConfigView::showEvent(QShowEvent *ev)
syncGeometry();
syncSlideEffect();
if (m_latteView && m_latteView->containment())
if (m_latteView && m_latteView->containment()) {
m_latteView->containment()->setUserConfiguring(true);
}
m_screenSyncTimer.start();
QTimer::singleShot(400, this, &PrimaryConfigView::syncGeometry);
updateShowInlineProperties();
emit showSignal();
if (m_latteView && m_latteView->layout()) {
m_latteView->layout()->setLastConfigViewFor(m_latteView);
}
if (m_shellSurface) {
//! readd shadows after hiding because the window shadows are not shown again after first showing
m_corona->dialogShadows()->addWindow(this, m_enabledBorders);
}
}
void PrimaryConfigView::hideEvent(QHideEvent *ev)
{
if (!m_latteView) {
deleteLater();
//QQuickWindow::hideEvent(ev);
return;
}
@ -414,8 +427,6 @@ void PrimaryConfigView::hideEvent(QHideEvent *ev)
m_latteView->containment()->setUserConfiguring(false);
}
// QQuickWindow::hideEvent(ev);
const auto mode = m_latteView->visibility()->mode();
if ((mode == Types::AlwaysVisible || mode == Types::WindowsGoBelow)
@ -429,7 +440,11 @@ void PrimaryConfigView::hideEvent(QHideEvent *ev)
m_latteView->layout()->recreateView(m_latteView->containment());
}
deleteLater();
if (m_latteView->hiddenConfigWindowsAreDeleted()) {
deleteLater();
} else {
setVisible(false);
}
}
void PrimaryConfigView::focusOutEvent(QFocusEvent *ev)
@ -559,9 +574,7 @@ void PrimaryConfigView::updateShowInlineProperties()
}
//! consider screen geometry for showing or not the secondary window
if (!geometryWhenVisible().isNull()) {
createSecondaryWindow();
if (showSecWindow && !geometryWhenVisible().isNull()) {
if (m_secConfigView->geometryWhenVisible().intersects(geometryWhenVisible())) {
showSecWindow = false;
} else if (advancedApprovedSecWindow) {
@ -570,14 +583,12 @@ void PrimaryConfigView::updateShowInlineProperties()
}
if (showSecWindow) {
if (!m_secConfigView) {
createSecondaryWindow();
}
showSecondaryWindow();
QTimer::singleShot(150, m_secConfigView, SLOT(show()));
// QTimer::singleShot(150, m_secConfigView, SLOT(show()));
setShowInlineProperties(false);
} else {
deleteSecondaryWindow();
hideSecondaryWindow();
setShowInlineProperties(true);
}
@ -621,6 +632,8 @@ void PrimaryConfigView::hideConfigWindow()
} else {
hide();
}
hideSecondaryWindow();
}
void PrimaryConfigView::updateLaunchersForGroup(int groupInt)

View File

@ -134,8 +134,8 @@ private slots:
void updateShowInlineProperties();
void updateWaylandId();
void createSecondaryWindow();
void deleteSecondaryWindow();
void showSecondaryWindow();
void hideSecondaryWindow();
void setShowInlineProperties(bool show);

View File

@ -332,6 +332,10 @@ void View::reloadSource()
}
}
bool View::hiddenConfigWindowsAreDeleted() const
{
return false;
}
bool View::inDelete() const
{
@ -423,9 +427,15 @@ void View::removeView()
bool View::settingsWindowIsShown()
{
auto configView = qobject_cast<ViewPart::PrimaryConfigView *>(m_configView);
auto cview = qobject_cast<ViewPart::PrimaryConfigView *>(m_configView);
return (configView != nullptr);
if (hiddenConfigWindowsAreDeleted()) {
return (cview != nullptr);
} else if (cview) {
return cview->isVisible();
}
return false;
}
void View::showSettingsWindow()
@ -1138,7 +1148,7 @@ void View::setLayout(Layout::GenericLayout *layout)
m_initLayoutTimer.start();
connectionsLayout << connect(m_layout, &Layout::GenericLayout::preferredViewForShortcutsChanged, this, &View::preferredViewForShortcutsChangedSlot);
connectionsLayout << connect(m_layout, &Layout::GenericLayout::lastConfigViewForChanged, this, &View::configViewCreatedFor);
connectionsLayout << connect(m_layout, &Layout::GenericLayout::lastConfigViewForChanged, this, &View::configViewShownFor);
Latte::Corona *latteCorona = qobject_cast<Latte::Corona *>(this->corona());
@ -1228,7 +1238,7 @@ void View::moveToLayout(QString layoutName)
}
}
void View::configViewCreatedFor(Latte::View *view)
void View::configViewShownFor(Latte::View *view)
{
if (view!=this && m_configView) {
//! for each layout only one dock should show its configuration windows
@ -1237,7 +1247,11 @@ void View::configViewCreatedFor(Latte::View *view)
auto configDialog = qobject_cast<ViewPart::PrimaryConfigView *>(m_configView);
if (configDialog) {
configDialog->hideConfigWindow();
if (hiddenConfigWindowsAreDeleted()) {
configDialog->deleteLater();
} else if (configDialog->isVisible()) {
configDialog->hideConfigWindow();
}
}
}
}

View File

@ -145,6 +145,7 @@ public:
bool inDelete() const;
bool inReadyState() const;
bool hiddenConfigWindowsAreDeleted() const;
bool onPrimary() const;
void setOnPrimary(bool flag);
@ -339,7 +340,7 @@ signals:
private slots:
void applyActivitiesToWindows();
void availableScreenRectChangedFromSlot(View *origin);
void configViewCreatedFor(Latte::View *view);
void configViewShownFor(Latte::View *view);
void hideWindowsForSlidingOut();
void preferredViewForShortcutsChangedSlot(Latte::View *view);
void releaseGrab();