1
0
mirror of https://github.com/KDE/latte-dock.git synced 2024-12-25 19:21:41 +03:00

move docksCount from corona to layout

This commit is contained in:
Michail Vourlakos 2018-01-31 20:45:55 +02:00
parent c95169ff67
commit c436d4f201
5 changed files with 62 additions and 107 deletions

View File

@ -580,61 +580,6 @@ int DockCorona::primaryScreenId() const
return m_screenPool->id(qGuiApp->primaryScreen()->name());
}
int DockCorona::docksCount(int screen) const
{
QScreen *scr = m_screenPool->screenForId(screen);
QHash<const Plasma::Containment *, DockView *> *views = m_layoutManager->currentDockViews();
int docks{0};
if (views) {
for (const auto &view : *views) {
if (view && view->screen() == scr && !view->containment()->destroyed()) {
++docks;
}
}
}
// qDebug() << docks << "docks on screen:" << screen;
return docks;
}
int DockCorona::docksCount() const
{
int docks{0};
QHash<const Plasma::Containment *, DockView *> *views = m_layoutManager->currentDockViews();
if (views) {
for (const auto &view : *views) {
if (view && view->containment() && !view->containment()->destroyed()) {
++docks;
}
}
}
// qDebug() << docks << "docks on screen:" << screen;
return docks;
}
int DockCorona::docksCount(QScreen *screen) const
{
int docks{0};
QHash<const Plasma::Containment *, DockView *> *views = m_layoutManager->currentDockViews();
if (views) {
for (const auto &view : *views) {
if (view && view->screen() == screen && !view->containment()->destroyed()) {
++docks;
}
}
}
// qDebug() << docks << "docks on screen:" << screen;
return docks;
}
void DockCorona::closeApplication()
{
qGuiApp->quit();
@ -655,46 +600,6 @@ void DockCorona::aboutApplication()
aboutDialog->show();
}
/*QList<Plasma::Types::Location> DockCorona::freeEdges(QScreen *screen) const
{
using Plasma::Types;
QList<Types::Location> edges{Types::BottomEdge, Types::LeftEdge,
Types::TopEdge, Types::RightEdge};
QHash<const Plasma::Containment *, DockView *> *views = m_layoutManager->currentDockViews();
if (views) {
for (auto *view : *views) {
if (view && view->currentScreen() == screen->name()) {
edges.removeOne(view->location());
}
}
}
return edges;
}
QList<Plasma::Types::Location> DockCorona::freeEdges(int screen) const
{
using Plasma::Types;
QList<Types::Location> edges{Types::BottomEdge, Types::LeftEdge,
Types::TopEdge, Types::RightEdge};
QScreen *scr = m_screenPool->screenForId(screen);
QHash<const Plasma::Containment *, DockView *> *views = m_layoutManager->currentDockViews();
if (views) {
for (auto *view : *views) {
if (view && scr && view->currentScreen() == scr->name()) {
edges.removeOne(view->location());
}
}
}
return edges;
}*/
int DockCorona::screenForContainment(const Plasma::Containment *containment) const
{
//FIXME: indexOf is not a proper way to support multi-screen

View File

@ -82,10 +82,6 @@ public:
QRegion availableScreenRegionWithCriteria(int id, QString forLayout = QString()) const;
int docksCount() const;
int docksCount(int screen) const;
int docksCount(QScreen *screen) const;
int screenForContainment(const Plasma::Containment *containment) const override;
void recreateDock(Plasma::Containment *containment);

View File

@ -1060,22 +1060,20 @@ void DockView::setNormalThickness(int thickness)
int DockView::docksCount() const
{
auto dockCorona = qobject_cast<DockCorona *>(corona());
if (!dockCorona)
if (!m_managedLayout) {
return 0;
}
return dockCorona->docksCount(screen());
return m_managedLayout->docksCount(screen());
}
int DockView::totalDocksCount() const
{
auto dockCorona = qobject_cast<DockCorona *>(corona());
if (!dockCorona)
if (!m_managedLayout) {
return 0;
}
return dockCorona->docksCount();
return m_managedLayout->docksCount();
}
int DockView::docksWithTasks()

View File

@ -1442,4 +1442,57 @@ int Layout::noDocksWithTasks() const
return result;
}
int Layout::docksCount(int screen) const
{
if (!m_corona) {
return 0;
}
QScreen *scr = m_corona->screenPool()->screenForId(screen);
int docks{0};
foreach (auto view, m_dockViews) {
if (view && view->screen() == scr && !view->containment()->destroyed()) {
++docks;
}
}
return docks;
}
int Layout::docksCount() const
{
if (!m_corona) {
return 0;
}
int docks{0};
foreach (auto view, m_dockViews) {
if (view && view->containment() && !view->containment()->destroyed()) {
++docks;
}
}
return docks;
}
int Layout::docksCount(QScreen *screen) const
{
if (!m_corona) {
return 0;
}
int docks{0};
foreach (auto view, m_dockViews) {
if (view && view->screen() == screen && !view->containment()->destroyed()) {
++docks;
}
}
return docks;
}
}

View File

@ -115,6 +115,9 @@ public:
QList<Plasma::Types::Location> freeEdges(int screen) const;
int noDocksWithTasks() const;
int docksCount() const;
int docksCount(int screen) const;
int docksCount(QScreen *screen) const;
signals:
void activitiesChanged();