mirror of
https://github.com/KDE/latte-dock.git
synced 2024-12-23 01:33:50 +03:00
viewsdialog:support updating screen
This commit is contained in:
parent
cedcbddd4d
commit
cc4f901cf1
@ -38,6 +38,7 @@ class Screen : public Generic
|
||||
public:
|
||||
static constexpr const char* SERIALIZESPLITTER = ":::";
|
||||
static const int ONPRIMARYID = 0;
|
||||
static constexpr const char* ONPRIMARYNAME = "{primary-screen}";
|
||||
|
||||
Screen();
|
||||
Screen(Screen &&o);
|
||||
|
@ -1488,7 +1488,17 @@ void GenericLayout::updateView(const Latte::Data::View &viewData)
|
||||
|
||||
if (view) {
|
||||
//const QString layoutName, const QString screenId, int edge, int alignment
|
||||
view->positioner()->setNextLocation("", "", viewData.edge, Latte::Types::NoneAlignment);
|
||||
QString scrName = Latte::Data::Screen::ONPRIMARYNAME;
|
||||
|
||||
if (!viewData.onPrimary) {
|
||||
if (m_corona->screenPool()->hasScreenId(viewData.screen)) {
|
||||
scrName = m_corona->screenPool()->connector(viewData.screen);
|
||||
} else {
|
||||
scrName = "";
|
||||
}
|
||||
}
|
||||
|
||||
view->positioner()->setNextLocation("", scrName, viewData.edge, Latte::Types::NoneAlignment);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "visibilitymanager.h"
|
||||
#include "../lattecorona.h"
|
||||
#include "../screenpool.h"
|
||||
#include "../data/screendata.h"
|
||||
#include "../layout/centrallayout.h"
|
||||
#include "../layouts/manager.h"
|
||||
#include "../settings/universalsettings.h"
|
||||
@ -119,12 +120,8 @@ void Positioner::init()
|
||||
connect(this, &Positioner::showingAfterRelocationFinished, this, &Positioner::updateInRelocationAnimation);
|
||||
connect(this, &Positioner::showingAfterRelocationFinished, this, &Positioner::syncLatteViews);
|
||||
|
||||
connect(this, &Positioner::hideDockDuringScreenChangeStarted, this, &Positioner::updateInRelocationAnimation);
|
||||
connect(this, &Positioner::hideDockDuringMovingToLayoutStarted, this, &Positioner::updateInRelocationAnimation);
|
||||
connect(this, &Positioner::showDockAfterScreenChangeFinished, this, &Positioner::updateInRelocationAnimation);
|
||||
connect(this, &Positioner::showDockAfterMovingToLayoutFinished, this, &Positioner::updateInRelocationAnimation);
|
||||
|
||||
connect(this, &Positioner::showDockAfterScreenChangeFinished, this, &Positioner::syncLatteViews);
|
||||
connect(this, &Positioner::showDockAfterMovingToLayoutFinished, this, &Positioner::syncLatteViews);
|
||||
connect(m_view, &Latte::View::onPrimaryChanged, this, &Positioner::syncLatteViews);
|
||||
|
||||
@ -325,34 +322,6 @@ void Positioner::updateContainmentScreen()
|
||||
}
|
||||
}
|
||||
|
||||
bool Positioner::setCurrentScreen(const QString id)
|
||||
{
|
||||
QScreen *nextScreen{qGuiApp->primaryScreen()};
|
||||
|
||||
if (id != "primary") {
|
||||
for (const auto scr : qGuiApp->screens()) {
|
||||
if (scr && scr->name() == id) {
|
||||
nextScreen = scr;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (m_screenToFollow == nextScreen) {
|
||||
updateContainmentScreen();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (nextScreen) {
|
||||
if (m_view->layout()) {
|
||||
m_nextScreen = nextScreen;
|
||||
emit hideDockDuringScreenChangeStarted();
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//! this function updates the dock's associated screen.
|
||||
//! updateScreenId = true, update also the m_screenNameToFollow
|
||||
//! updateScreenId = false, do not update the m_screenNameToFollow
|
||||
@ -894,7 +863,6 @@ void Positioner::initSignalingForLocationChangeSliding()
|
||||
connect(this, &Positioner::hidingForRelocationStarted, this, &Positioner::onHideWindowsForSlidingOut);
|
||||
|
||||
//! signals to handle the sliding-in/out during location changes
|
||||
|
||||
connect(m_view, &View::locationChanged, this, [&]() {
|
||||
if (m_nextScreenEdge != Plasma::Types::Floating) {
|
||||
bool isrelocationlastevent = isLastHidingRelocationEvent();
|
||||
@ -918,18 +886,28 @@ void Positioner::initSignalingForLocationChangeSliding()
|
||||
});
|
||||
|
||||
//! signals to handle the sliding-in/out during screen changes
|
||||
connect(this, &Positioner::hideDockDuringScreenChangeStarted, this, &Positioner::onHideWindowsForSlidingOut);
|
||||
|
||||
connect(m_view, &QQuickView::screenChanged, this, [&]() {
|
||||
if (m_nextScreen
|
||||
&& m_nextScreen == m_view->screen()
|
||||
&& m_nextScreen->geometry().contains(m_view->geometry().center())) {
|
||||
|
||||
bool isrelocationlastevent = isLastHidingRelocationEvent();
|
||||
//! make sure that View has been repositioned properly in next screen and show view afterwards
|
||||
m_nextScreen = nullptr;
|
||||
m_view->effects()->setAnimationsBlocked(false);
|
||||
emit showDockAfterScreenChangeFinished();
|
||||
m_view->showSettingsWindow();
|
||||
emit edgeChanged();
|
||||
m_nextScreenName = "";
|
||||
|
||||
if (isrelocationlastevent) {
|
||||
QTimer::singleShot(100, [this]() {
|
||||
m_view->effects()->setAnimationsBlocked(false);
|
||||
emit showingAfterRelocationFinished();
|
||||
emit edgeChanged();
|
||||
|
||||
if (m_repositionFromViewSettingsWindow) {
|
||||
m_repositionFromViewSettingsWindow = false;
|
||||
m_view->showSettingsWindow();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@ -971,9 +949,28 @@ void Positioner::initSignalingForLocationChangeSliding()
|
||||
connect(this, &Positioner::hidingForRelocationFinished, this, [&]() {
|
||||
m_view->effects()->setAnimationsBlocked(true);
|
||||
|
||||
//! SCREEN_EDGE
|
||||
if (m_nextScreenEdge != Plasma::Types::Floating) {
|
||||
m_view->setLocation(m_nextScreenEdge);
|
||||
}
|
||||
|
||||
//! SCREEN
|
||||
if (!m_nextScreenName.isEmpty()) {
|
||||
bool nextonprimary = (m_nextScreenName == Latte::Data::Screen::ONPRIMARYNAME);
|
||||
m_nextScreen = qGuiApp->primaryScreen();
|
||||
|
||||
if (!nextonprimary) {
|
||||
for (const auto scr : qGuiApp->screens()) {
|
||||
if (scr && scr->name() == m_nextScreenName) {
|
||||
m_nextScreen = scr;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_view->setOnPrimary(nextonprimary);
|
||||
setScreenToFollow(m_nextScreen);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -1057,7 +1054,7 @@ bool Positioner::isLastHidingRelocationEvent() const
|
||||
events++;
|
||||
}
|
||||
|
||||
if (m_nextScreen != nullptr){
|
||||
if (!m_nextScreenName.isEmpty()){
|
||||
events++;
|
||||
}
|
||||
|
||||
@ -1094,20 +1091,46 @@ void Positioner::hideDockDuringMovingToLayout(QString layoutName)
|
||||
}
|
||||
}
|
||||
|
||||
void Positioner::setNextLocation(const QString layoutName, const QString screenId, int edge, int alignment)
|
||||
void Positioner::setNextLocation(const QString layoutName, const QString screenName, int edge, int alignment)
|
||||
{
|
||||
bool animated{false};
|
||||
bool haschanges{false};
|
||||
|
||||
if (edge != m_view->location()) {
|
||||
m_nextScreenEdge = static_cast<Plasma::Types::Location>(edge);
|
||||
animated = true;
|
||||
//! SCREEN_EDGE
|
||||
if (edge != Plasma::Types::Floating) {
|
||||
if (edge != m_view->location()) {
|
||||
m_nextScreenEdge = static_cast<Plasma::Types::Location>(edge);
|
||||
animated = true;
|
||||
haschanges = true;
|
||||
}
|
||||
}
|
||||
|
||||
//! SCREEN
|
||||
if (!screenName.isEmpty()) {
|
||||
bool nextonprimary = (screenName == Latte::Data::Screen::ONPRIMARYNAME);
|
||||
|
||||
if ( (m_view->onPrimary() && !nextonprimary) /*primary -> explicit*/
|
||||
|| (!m_view->onPrimary() && nextonprimary) /*explicit -> primary*/
|
||||
|| (!m_view->onPrimary() && !nextonprimary && screenName != currentScreenName()) ) { /*explicit -> new_explicit*/
|
||||
|
||||
QString nextscreenname = nextonprimary ? qGuiApp->primaryScreen()->name() : screenName;
|
||||
|
||||
if (currentScreenName() == nextscreenname) {
|
||||
m_view->setOnPrimary(nextonprimary);
|
||||
updateContainmentScreen();
|
||||
} else {
|
||||
m_nextScreenName = screenName;
|
||||
animated = true;
|
||||
haschanges = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_repositionFromViewSettingsWindow = m_view->settingsWindowIsShown();
|
||||
|
||||
if (animated) {
|
||||
emit hidingForRelocationStarted();
|
||||
} else {
|
||||
} else if (haschanges){
|
||||
emit hidingForRelocationFinished();
|
||||
}
|
||||
}
|
||||
|
@ -97,7 +97,6 @@ public:
|
||||
|
||||
public slots:
|
||||
Q_INVOKABLE void hideDockDuringMovingToLayout(QString layoutName);
|
||||
Q_INVOKABLE bool setCurrentScreen(const QString id);
|
||||
|
||||
Q_INVOKABLE void setNextLocation(const QString layoutName, const QString screenId, int edge, int alignment);
|
||||
|
||||
@ -126,11 +125,8 @@ signals:
|
||||
void showingAfterRelocationFinished();
|
||||
|
||||
//! Deprecated
|
||||
void hideDockDuringScreenChangeStarted();
|
||||
void hideDockDuringScreenChangeFinished();
|
||||
void hideDockDuringMovingToLayoutStarted();
|
||||
void hideDockDuringMovingToLayoutFinished();
|
||||
void showDockAfterScreenChangeFinished();
|
||||
void showDockAfterMovingToLayoutFinished();
|
||||
|
||||
void onHideWindowsForSlidingOut();
|
||||
@ -196,8 +192,9 @@ private:
|
||||
bool m_repositionFromViewSettingsWindow{false};
|
||||
|
||||
QString m_nextLayout;
|
||||
Plasma::Types::Location m_nextScreenEdge{Plasma::Types::Floating};
|
||||
QString m_nextScreenName;
|
||||
QScreen *m_nextScreen{nullptr};
|
||||
Plasma::Types::Location m_nextScreenEdge{Plasma::Types::Floating};
|
||||
Latte::Types::Alignment m_nextAlignment{Latte::Types::NoneAlignment};
|
||||
|
||||
Latte::WindowSystem::WindowId m_trackedWindowId;
|
||||
|
@ -486,8 +486,6 @@ Item {
|
||||
latteView.positioner.showingAfterRelocationFinished.connect(visibilityManager.slotShowDockAfterLocationChange);
|
||||
|
||||
//! Deprecated
|
||||
latteView.positioner.hideDockDuringScreenChangeStarted.connect(visibilityManager.slotHideDockDuringLocationChange);
|
||||
latteView.positioner.showDockAfterScreenChangeFinished.connect(visibilityManager.slotShowDockAfterLocationChange);
|
||||
latteView.positioner.hideDockDuringMovingToLayoutStarted.connect(visibilityManager.slotHideDockDuringLocationChange);
|
||||
latteView.positioner.showDockAfterMovingToLayoutFinished.connect(visibilityManager.slotShowDockAfterLocationChange);
|
||||
}
|
||||
@ -508,8 +506,6 @@ Item {
|
||||
latteView.positioner.showingAfterRelocationFinished.connect(visibilityManager.slotShowDockAfterLocationChange);
|
||||
|
||||
//! Deprecated
|
||||
latteView.positioner.hideDockDuringScreenChangeStarted.connect(visibilityManager.slotHideDockDuringLocationChange);
|
||||
latteView.positioner.showDockAfterScreenChangeFinished.connect(visibilityManager.slotShowDockAfterLocationChange);
|
||||
latteView.positioner.hideDockDuringMovingToLayoutStarted.connect(visibilityManager.slotHideDockDuringLocationChange);
|
||||
latteView.positioner.showDockAfterMovingToLayoutFinished.connect(visibilityManager.slotShowDockAfterLocationChange);
|
||||
}
|
||||
@ -571,8 +567,6 @@ Item {
|
||||
latteView.positioner.showingAfterRelocationFinished.disconnect(visibilityManager.slotShowDockAfterLocationChange);
|
||||
|
||||
// Deprecated
|
||||
latteView.positioner.hideDockDuringScreenChangeStarted.disconnect(visibilityManager.slotHideDockDuringLocationChange);
|
||||
latteView.positioner.showDockAfterScreenChangeFinished.disconnect(visibilityManager.slotShowDockAfterLocationChange);
|
||||
latteView.positioner.hideDockDuringMovingToLayoutStarted.disconnect(visibilityManager.slotHideDockDuringLocationChange);
|
||||
latteView.positioner.showDockAfterMovingToLayoutFinished.disconnect(visibilityManager.slotShowDockAfterLocationChange);
|
||||
}
|
||||
|
@ -149,33 +149,14 @@ PlasmaComponents.Page {
|
||||
Component.onCompleted: screenRow.updateScreens();
|
||||
|
||||
onActivated: {
|
||||
var succeed = false;
|
||||
|
||||
if (index === 0) {
|
||||
succeed = latteView.positioner.setCurrentScreen("primary");
|
||||
|
||||
if (succeed) {
|
||||
latteView.onPrimary = true;
|
||||
} else if (!latteView.onPrimary){
|
||||
console.log("the edge is already occupied!!!");
|
||||
currentIndex = findScreen(latteView.positioner.currentScreenName);
|
||||
}
|
||||
latteView.positioner.setNextLocation("", "{primary-screen}", PlasmaCore.Types.Floating, LatteCore.Types.NoneAlignment);
|
||||
} else if (index>0 && (index !== findScreen(latteView.positioner.currentScreenName) || latteView.onPrimary)) {
|
||||
console.log("current index changed!!! :"+ index);
|
||||
console.log("screen must be changed...");
|
||||
|
||||
succeed = latteView.positioner.setCurrentScreen(textAt(index));
|
||||
|
||||
if(succeed) {
|
||||
latteView.onPrimary = false;
|
||||
} else {
|
||||
console.log("the edge is already occupied!!!");
|
||||
currentIndex = findScreen(latteView.positioner.currentScreenName);
|
||||
}
|
||||
}
|
||||
latteView.positioner.setNextLocation("", textAt(index), PlasmaCore.Types.Floating, LatteCore.Types.NoneAlignment);
|
||||
}
|
||||
}
|
||||
|
||||
function findScreen(scrName) {
|
||||
function findScreen(scrName) {
|
||||
for(var i=0; i<screensModel.count; ++i) {
|
||||
if (screensModel.get(i).name === scrName) {
|
||||
return i;
|
||||
|
Loading…
Reference in New Issue
Block a user