refactor:move currentScreen to View::Positioner

--rename also currentScreen to currentScreenName
for better semantic representation
pull/3/head
Michail Vourlakos 6 years ago
parent 186a641444
commit 642b524cc7

@ -185,7 +185,6 @@ void DockView::init()
connect(corona(), &Plasma::Corona::availableScreenRectChanged, this, &DockView::availableScreenRectChanged); connect(corona(), &Plasma::Corona::availableScreenRectChanged, this, &DockView::availableScreenRectChanged);
connect(m_positioner, &View::Positioner::currentScreenChanged, this, &DockView::currentScreenChanged);
connect(m_positioner, &View::Positioner::onHideWindowsForSlidingOut, this, &DockView::hideWindowsForSlidingOut); connect(m_positioner, &View::Positioner::onHideWindowsForSlidingOut, this, &DockView::hideWindowsForSlidingOut);
connect(m_positioner, &View::Positioner::screenGeometryChanged, this, &DockView::screenGeometryChanged); connect(m_positioner, &View::Positioner::screenGeometryChanged, this, &DockView::screenGeometryChanged);
@ -324,11 +323,6 @@ QScreen *DockView::atScreens(QQmlListProperty<QScreen> *property, int index)
return qGuiApp->screens().at(index); return qGuiApp->screens().at(index);
} }
QString DockView::currentScreen() const
{
return m_positioner->currentScreenName();
}
bool DockView::settingsWindowIsShown() bool DockView::settingsWindowIsShown()
{ {
auto configView = qobject_cast<DockConfigView *>(m_configView); auto configView = qobject_cast<DockConfigView *>(m_configView);

@ -84,8 +84,6 @@ class DockView : public PlasmaQuick::ContainmentView
Q_PROPERTY(int normalThickness READ normalThickness WRITE setNormalThickness NOTIFY normalThicknessChanged) Q_PROPERTY(int normalThickness READ normalThickness WRITE setNormalThickness NOTIFY normalThicknessChanged)
Q_PROPERTY(int offset READ offset WRITE setOffset NOTIFY offsetChanged) Q_PROPERTY(int offset READ offset WRITE setOffset NOTIFY offsetChanged)
Q_PROPERTY(QString currentScreen READ currentScreen NOTIFY currentScreenChanged)
Q_PROPERTY(float maxLength READ maxLength WRITE setMaxLength NOTIFY maxLengthChanged) Q_PROPERTY(float maxLength READ maxLength WRITE setMaxLength NOTIFY maxLengthChanged)
Q_PROPERTY(Latte::View::Effects *effects READ effects NOTIFY effectsChanged) Q_PROPERTY(Latte::View::Effects *effects READ effects NOTIFY effectsChanged)
@ -153,8 +151,6 @@ public:
QRect absGeometry() const; QRect absGeometry() const;
QRect screenGeometry() const; QRect screenGeometry() const;
QString currentScreen() const;
QRect localGeometry() const; QRect localGeometry() const;
void setLocalGeometry(const QRect &geometry); void setLocalGeometry(const QRect &geometry);
@ -223,7 +219,6 @@ signals:
void alignmentChanged(); void alignmentChanged();
void behaveAsPlasmaPanelChanged(); void behaveAsPlasmaPanelChanged();
void contextMenuIsShownChanged(); void contextMenuIsShownChanged();
void currentScreenChanged();
void dockLocationChanged(); void dockLocationChanged();
void docksCountChanged(); void docksCountChanged();
void dockWinBehaviorChanged(); void dockWinBehaviorChanged();

@ -586,7 +586,7 @@ void Positioner::initSignalingForLocationChangeSliding()
//! signals to handle the sliding-in/out during screen changes //! signals to handle the sliding-in/out during screen changes
connect(this, &Positioner::hideDockDuringScreenChangeStarted, this, &Positioner::onHideWindowsForSlidingOut); connect(this, &Positioner::hideDockDuringScreenChangeStarted, this, &Positioner::onHideWindowsForSlidingOut);
connect(m_view, &DockView::currentScreenChanged, this, [&]() { connect(this, &Positioner::currentScreenChanged, this, [&]() {
if (m_goToScreen) { if (m_goToScreen) {
m_goToScreen = nullptr; m_goToScreen = nullptr;
QTimer::singleShot(100, [this]() { QTimer::singleShot(100, [this]() {

@ -42,6 +42,8 @@ class Positioner: public QObject
{ {
Q_OBJECT Q_OBJECT
Q_PROPERTY(QString currentScreenName READ currentScreenName NOTIFY currentScreenChanged)
public: public:
Positioner(DockView *parent); Positioner(DockView *parent);
virtual ~Positioner(); virtual ~Positioner();

@ -800,7 +800,7 @@ void VisibilityManagerPrivate::updateAvailableScreenGeometry()
return; return;
} }
int currentScrId = dockCorona->screenPool()->id(dockView->currentScreen()); int currentScrId = dockCorona->screenPool()->id(dockView->positioner()->currentScreenName());
QRect tempAvailableScreenGeometry = dockCorona->availableScreenRectWithCriteria(currentScrId, {Dock::AlwaysVisible}, {}); QRect tempAvailableScreenGeometry = dockCorona->availableScreenRectWithCriteria(currentScrId, {Dock::AlwaysVisible}, {});
if (tempAvailableScreenGeometry != availableScreenGeometry) { if (tempAvailableScreenGeometry != availableScreenGeometry) {

@ -26,6 +26,7 @@
#include "screenpool.h" #include "screenpool.h"
#include "universalsettings.h" #include "universalsettings.h"
#include "dock/dockview.h" #include "dock/dockview.h"
#include "dock/positioner.h"
#include <QDir> #include <QDir>
#include <QFile> #include <QFile>
@ -1106,7 +1107,7 @@ void Layout::copyDock(Plasma::Containment *containment)
int copyScrId = -1; int copyScrId = -1;
if (dock) { if (dock) {
dockScrId = m_corona->screenPool()->id(dock->currentScreen()); dockScrId = m_corona->screenPool()->id(dock->positioner()->currentScreenName());
qDebug() << "COPY DOCK SCREEN ::: " << dockScrId; qDebug() << "COPY DOCK SCREEN ::: " << dockScrId;
if (dockScrId != -1 && screens.count() > 1) { if (dockScrId != -1 && screens.count() > 1) {
@ -1563,7 +1564,7 @@ void Layout::syncDockViewsToScreens()
//! remove views //! remove views
foreach (auto view, m_dockViews) { foreach (auto view, m_dockViews) {
if (view->containment() && !futureShownViews.contains(view->containment()->id())) { if (view->containment() && !futureShownViews.contains(view->containment()->id())) {
qDebug() << "syncDockViewsToScreens: view must be deleted... for containment:" << view->containment()->id() << " at screen:" << view->currentScreen(); qDebug() << "syncDockViewsToScreens: view must be deleted... for containment:" << view->containment()->id() << " at screen:" << view->positioner()->currentScreenName();
auto viewToDelete = m_dockViews.take(view->containment()); auto viewToDelete = m_dockViews.take(view->containment());
viewToDelete->disconnectSensitiveSignals(); viewToDelete->disconnectSensitiveSignals();
viewToDelete->deleteLater(); viewToDelete->deleteLater();
@ -1782,7 +1783,7 @@ QList<Plasma::Types::Location> Layout::availableEdgesForView(QScreen *scr, DockV
foreach (auto view, m_dockViews) { foreach (auto view, m_dockViews) {
//! make sure that availabe edges takes into account only views that should be excluded, //! make sure that availabe edges takes into account only views that should be excluded,
//! this is why the forView should not be excluded //! this is why the forView should not be excluded
if (view && view != forView && view->currentScreen() == scr->name()) { if (view && view != forView && view->positioner()->currentScreenName() == scr->name()) {
edges.removeOne(view->location()); edges.removeOne(view->location());
} }
} }
@ -1801,7 +1802,7 @@ QList<Plasma::Types::Location> Layout::freeEdges(QScreen *scr) const
} }
foreach (auto view, m_dockViews) { foreach (auto view, m_dockViews) {
if (view && view->currentScreen() == scr->name()) { if (view && view->positioner()->currentScreenName() == scr->name()) {
edges.removeOne(view->location()); edges.removeOne(view->location());
} }
} }
@ -1822,7 +1823,7 @@ QList<Plasma::Types::Location> Layout::freeEdges(int screen) const
QScreen *scr = m_corona->screenPool()->screenForId(screen); QScreen *scr = m_corona->screenPool()->screenForId(screen);
foreach (auto view, m_dockViews) { foreach (auto view, m_dockViews) {
if (view && scr && view->currentScreen() == scr->name()) { if (view && scr && view->positioner()->currentScreenName() == scr->name()) {
edges.removeOne(view->location()); edges.removeOne(view->location());
} }
} }

@ -51,7 +51,7 @@ Window{
} }
Text{ Text{
text: dock && dock.currentScreen ? dock.currentScreen : "___" text: dock && dock.positioner ? dock.positioner.currentScreenName : "___"
} }
Text{ Text{

@ -100,12 +100,12 @@ PlasmaComponents.Page {
//to has always a dock with tasks shown //to has always a dock with tasks shown
var screenExists = false var screenExists = false
for (var i = 0; i < dock.screens.length; i++) { for (var i = 0; i < dock.screens.length; i++) {
if (dock.screens[i].name === dock.currentScreen) if (dock.screens[i].name === dock.positioner.currentScreenName)
screenExists = true; screenExists = true;
} }
if (!screenExists && !dock.onPrimary) if (!screenExists && !dock.onPrimary)
screens.push(rtlSpace + dock.currentScreen); screens.push(rtlSpace + dock.positioner.currentScreenName);
for (var i = 0; i < dock.screens.length; i++) { for (var i = 0; i < dock.screens.length; i++) {
screens.push(rtlSpace + dock.screens[i].name) screens.push(rtlSpace + dock.screens[i].name)
@ -116,10 +116,10 @@ PlasmaComponents.Page {
if (dock.onPrimary) { if (dock.onPrimary) {
screenCmb.currentIndex = 0; screenCmb.currentIndex = 0;
} else { } else {
screenCmb.currentIndex = screenCmb.find(dock.currentScreen); screenCmb.currentIndex = screenCmb.find(dock.positioner.currentScreenName);
} }
console.log(dock.currentScreen); console.log(dock.positioner.currentScreenName);
} }
Connections{ Connections{
@ -158,7 +158,7 @@ PlasmaComponents.Page {
dock.onPrimary = true; dock.onPrimary = true;
acceptedIndex = true; acceptedIndex = true;
} else if (index>0 && (index !== find(dock.currentScreen) || dock.onPrimary)) { } else if (index>0 && (index !== find(dock.positioner.currentScreenName) || dock.onPrimary)) {
console.log("current index changed!!! :"+ index); console.log("current index changed!!! :"+ index);
console.log("screen must be changed..."); console.log("screen must be changed...");

Loading…
Cancel
Save