diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index a37da1182..26917f6d4 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -10,7 +10,9 @@ set(lattedock-app_SRCS schemecolors.cpp screenpool.cpp indicator/factory.cpp - layout/layout.cpp + layout/abstractlayout.cpp + layout/activelayout.cpp + layout/genericlayout.cpp package/lattepackage.cpp plasma/extended/screenpool.cpp plasma/extended/theme.cpp diff --git a/app/importer.cpp b/app/importer.cpp index 5c47eef43..0ce6c2004 100644 --- a/app/importer.cpp +++ b/app/importer.cpp @@ -24,7 +24,7 @@ #include "lattecorona.h" #include "layoutmanager.h" #include "screenpool.h" -#include "layout/layout.h" +#include "layout/activelayout.h" #include "settings/universalsettings.h" #include "../liblatte2/types.h" @@ -169,7 +169,7 @@ bool Importer::importOldLayout(QString oldAppletsPath, QString newName, bool alt } //! update also the layout settings correctly - Layout newLayout(this, newLayoutPath, newName); + Latte::ActiveLayout newLayout(this, newLayoutPath, newName); newLayout.setVersion(2); newLayout.setLaunchers(layoutLaunchers); @@ -513,7 +513,7 @@ QString Importer::importLayoutHelper(QString fileName) return QString(); } - QString newLayoutName = Layout::layoutName(fileName); + QString newLayoutName = Latte::ActiveLayout::layoutName(fileName); newLayoutName = uniqueLayoutName(newLayoutName); QString newPath = QDir::homePath() + "/.config/latte/" + newLayoutName + ".layout.latte"; @@ -539,7 +539,7 @@ QStringList Importer::availableLayouts() QStringList layoutNames; for(const auto &file : files) { - layoutNames.append(Layout::layoutName(file)); + layoutNames.append(ActiveLayout::layoutName(file)); } return layoutNames; @@ -591,7 +591,7 @@ QString Importer::uniqueLayoutName(QString name) QStringList Importer::checkRepairMultipleLayoutsLinkedFile() { - QString linkedFilePath = QDir::homePath() + "/.config/latte/" + Layout::MultipleLayoutsName + ".layout.latte"; + QString linkedFilePath = QDir::homePath() + "/.config/latte/" + ActiveLayout::MultipleLayoutsName + ".layout.latte"; KSharedConfigPtr filePtr = KSharedConfig::openConfig(linkedFilePath); KConfigGroup linkedContainments = KConfigGroup(filePtr, "Containments"); @@ -611,7 +611,7 @@ QStringList Importer::checkRepairMultipleLayoutsLinkedFile() QStringList updatedLayouts; for(const auto &layoutName : linkedLayoutContainmentGroups.uniqueKeys()) { - if (layoutName != Layout::MultipleLayoutsName && layoutExists(layoutName)) { + if (layoutName != ActiveLayout::MultipleLayoutsName && layoutExists(layoutName)) { updatedLayouts << layoutName; KSharedConfigPtr layoutFilePtr = KSharedConfig::openConfig(layoutFilePath(layoutName)); KConfigGroup origLayoutContainments = KConfigGroup(layoutFilePtr, "Containments"); diff --git a/app/lattecorona.cpp b/app/lattecorona.cpp index 58f1f0302..565bfce3e 100644 --- a/app/lattecorona.cpp +++ b/app/lattecorona.cpp @@ -28,6 +28,7 @@ #include "layoutmanager.h" #include "screenpool.h" #include "indicator/factory.h" +#include "layout/activelayout.h" #include "shortcuts/globalshortcuts.h" #include "package/lattepackage.h" #include "plasma/extended/screenpool.h" @@ -463,10 +464,10 @@ QRegion Corona::availableScreenRegionWithCriteria(int id, QString forLayout) con QHash *views; if (forLayout.isEmpty()) { - Layout *currentLayout = m_layoutManager->currentLayout(); + Latte::ActiveLayout *currentLayout = m_layoutManager->currentLayout(); views = currentLayout ? currentLayout->latteViews() : nullptr; } else { - Layout *activeLayout = m_layoutManager->activeLayout(forLayout); + Latte::ActiveLayout *activeLayout = m_layoutManager->activeLayout(forLayout); views = activeLayout ? activeLayout->latteViews() : nullptr; } @@ -593,7 +594,7 @@ QRect Corona::availableScreenRectWithCriteria(int id, QList m auto available = screen->geometry(); - Layout *currentLayout = m_layoutManager->currentLayout(); + Latte::ActiveLayout *currentLayout = m_layoutManager->currentLayout(); QHash *views; if (currentLayout) { @@ -743,7 +744,7 @@ int Corona::screenForContainment(const Plasma::Containment *containment) const } } - Layout *currentLayout = m_layoutManager->currentLayout(); + Latte::ActiveLayout *currentLayout = m_layoutManager->currentLayout(); QHash *views; if (currentLayout) { @@ -785,7 +786,7 @@ void Corona::showAlternativesForApplet(Plasma::Applet *applet) return; } - Layout *currentLayout = m_layoutManager->currentLayout(); + Latte::ActiveLayout *currentLayout = m_layoutManager->currentLayout(); QHash *views; if (currentLayout) { @@ -880,7 +881,7 @@ void Corona::loadDefaultLayout() QList edges{Types::BottomEdge, Types::LeftEdge, Types::TopEdge, Types::RightEdge}; - Layout *currentLayout = m_layoutManager->activeLayout(m_layoutManager->currentLayoutName()); + Latte::ActiveLayout *currentLayout = m_layoutManager->activeLayout(m_layoutManager->currentLayoutName()); if (currentLayout) { edges = currentLayout->freeEdges(defaultContainment->screen()); @@ -991,7 +992,7 @@ QStringList Corona::contextMenuData() QStringList data; Types::ViewType viewType{Types::DockView}; - Layout *currentLayout = m_layoutManager->currentLayout(); + Latte::ActiveLayout *currentLayout = m_layoutManager->currentLayout(); if (currentLayout) { viewType = currentLayout->latteViewType(m_contextMenuViewId); diff --git a/app/lattecorona.h b/app/lattecorona.h index 328fa85e8..add35a3a3 100644 --- a/app/lattecorona.h +++ b/app/lattecorona.h @@ -202,7 +202,7 @@ private: KWayland::Client::PlasmaShell *m_waylandCorona{nullptr}; friend class GlobalShortcuts; - friend class Layout; + friend class ActiveLayout; friend class LayoutManager; friend class LaunchersSignals; }; diff --git a/app/launcherssignals.cpp b/app/launcherssignals.cpp index 28970dde8..a7394589f 100644 --- a/app/launcherssignals.cpp +++ b/app/launcherssignals.cpp @@ -23,7 +23,7 @@ // local #include "lattecorona.h" #include "layoutmanager.h" -#include "layout/layout.h" +#include "layout/activelayout.h" // Qt #include @@ -48,7 +48,7 @@ QList LaunchersSignals::lattePlasmoids(QString layoutName) { QList applets; - Layout *layout = m_manager->activeLayout(layoutName); + ActiveLayout *layout = m_manager->activeLayout(layoutName); QList containments; if (layoutName.isEmpty()) { diff --git a/app/layout/abstractlayout.cpp b/app/layout/abstractlayout.cpp new file mode 100644 index 000000000..473c9db5d --- /dev/null +++ b/app/layout/abstractlayout.cpp @@ -0,0 +1,36 @@ +/* +* Copyright 2019 Michail Vourlakos +* +* This file is part of Latte-Dock +* +* Latte-Dock is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License as +* published by the Free Software Foundation; either version 2 of +* the License, or (at your option) any later version. +* +* Latte-Dock is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*/ + +#include "abstractlayout.h" + + +namespace Latte { +namespace Layout { + +AbstractLayout::AbstractLayout(QObject *parent) : + QObject(parent) +{ +} + +AbstractLayout::~AbstractLayout() +{ +} + +} +} diff --git a/app/layout/abstractlayout.h b/app/layout/abstractlayout.h new file mode 100644 index 000000000..7db23ab11 --- /dev/null +++ b/app/layout/abstractlayout.h @@ -0,0 +1,43 @@ +/* +* Copyright 2019 Michail Vourlakos +* +* This file is part of Latte-Dock +* +* Latte-Dock is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License as +* published by the Free Software Foundation; either version 2 of +* the License, or (at your option) any later version. +* +* Latte-Dock is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*/ + +#ifndef ABSTRACTLAYOUT_H +#define ABSTRACTLAYOUT_H + +// Qt +#include + +namespace Latte { +namespace Layout { + +class AbstractLayout : public QObject +{ + Q_OBJECT + +public: + AbstractLayout(QObject *parent); + ~AbstractLayout() override; + +protected: +}; + +} +} + +#endif diff --git a/app/layout/layout.cpp b/app/layout/activelayout.cpp similarity index 89% rename from app/layout/layout.cpp rename to app/layout/activelayout.cpp index 7a79f3ec7..25ce6631c 100644 --- a/app/layout/layout.cpp +++ b/app/layout/activelayout.cpp @@ -18,7 +18,7 @@ * along with this program. If not, see . */ -#include "layout.h" +#include "activelayout.h" // local #include "../importer.h" @@ -47,10 +47,10 @@ namespace Latte { -const QString Layout::MultipleLayoutsName = ".multiple-layouts_hidden"; +const QString ActiveLayout::MultipleLayoutsName = ".multiple-layouts_hidden"; -Layout::Layout(QObject *parent, QString layoutFile, QString assignedName) - : QObject(parent) +ActiveLayout::ActiveLayout(QObject *parent, QString layoutFile, QString assignedName) + : Layout::GenericLayout(parent) { qDebug() << "Layout file to create object: " << layoutFile << " with name: " << assignedName; @@ -67,14 +67,14 @@ Layout::Layout(QObject *parent, QString layoutFile, QString assignedName) } } -Layout::~Layout() +ActiveLayout::~ActiveLayout() { if (!m_layoutFile.isEmpty()) { m_layoutGroup.sync(); } } -void Layout::syncToLayoutFile(bool removeLayoutId) +void ActiveLayout::syncToLayoutFile(bool removeLayoutId) { if (!m_corona || !isWritable()) { return; @@ -105,15 +105,15 @@ void Layout::syncToLayoutFile(bool removeLayoutId) oldContainments.sync(); } -void Layout::unloadContainments() +void ActiveLayout::unloadContainments() { if (!m_corona) { return; } //!disconnect signals in order to avoid crashes when the layout is unloading - disconnect(this, &Layout::viewsCountChanged, m_corona, &Plasma::Corona::availableScreenRectChanged); - disconnect(this, &Layout::viewsCountChanged, m_corona, &Plasma::Corona::availableScreenRegionChanged); + disconnect(this, &ActiveLayout::viewsCountChanged, m_corona, &Plasma::Corona::availableScreenRectChanged); + disconnect(this, &ActiveLayout::viewsCountChanged, m_corona, &Plasma::Corona::availableScreenRegionChanged); qDebug() << "Layout - " + name() + " unload: containments ... size ::: " << m_containments.size() << " ,latteViews in memory ::: " << m_latteViews.size() @@ -154,7 +154,7 @@ void Layout::unloadContainments() } } -void Layout::unloadLatteViews() +void ActiveLayout::unloadLatteViews() { if (!m_corona) { return; @@ -168,21 +168,21 @@ void Layout::unloadLatteViews() m_waitingLatteViews.clear(); } -void Layout::init() +void ActiveLayout::init() { - connect(this, &Layout::activitiesChanged, this, &Layout::saveConfig); - connect(this, &Layout::backgroundChanged, this, &Layout::saveConfig); - connect(this, &Layout::versionChanged, this, &Layout::saveConfig); - connect(this, &Layout::colorChanged, this, &Layout::textColorChanged); - connect(this, &Layout::disableBordersForMaximizedWindowsChanged, this, &Layout::saveConfig); - connect(this, &Layout::showInMenuChanged, this, &Layout::saveConfig); - connect(this, &Layout::textColorChanged, this, &Layout::saveConfig); - connect(this, &Layout::launchersChanged, this, &Layout::saveConfig); - connect(this, &Layout::lastUsedActivityChanged, this, &Layout::saveConfig); - connect(this, &Layout::preferredForShortcutsTouchedChanged, this, &Layout::saveConfig); + connect(this, &ActiveLayout::activitiesChanged, this, &ActiveLayout::saveConfig); + connect(this, &ActiveLayout::backgroundChanged, this, &ActiveLayout::saveConfig); + connect(this, &ActiveLayout::versionChanged, this, &ActiveLayout::saveConfig); + connect(this, &ActiveLayout::colorChanged, this, &ActiveLayout::textColorChanged); + connect(this, &ActiveLayout::disableBordersForMaximizedWindowsChanged, this, &ActiveLayout::saveConfig); + connect(this, &ActiveLayout::showInMenuChanged, this, &ActiveLayout::saveConfig); + connect(this, &ActiveLayout::textColorChanged, this, &ActiveLayout::saveConfig); + connect(this, &ActiveLayout::launchersChanged, this, &ActiveLayout::saveConfig); + connect(this, &ActiveLayout::lastUsedActivityChanged, this, &ActiveLayout::saveConfig); + connect(this, &ActiveLayout::preferredForShortcutsTouchedChanged, this, &ActiveLayout::saveConfig); } -void Layout::initToCorona(Latte::Corona *corona) +void ActiveLayout::initToCorona(Latte::Corona *corona) { if (m_corona) { return; @@ -228,24 +228,24 @@ void Layout::initToCorona(Latte::Corona *corona) updateLastUsedActivity(); } - connect(m_corona, &Plasma::Corona::containmentAdded, this, &Layout::addContainment); + connect(m_corona, &Plasma::Corona::containmentAdded, this, &ActiveLayout::addContainment); connect(m_corona->m_activityConsumer, &KActivities::Consumer::currentActivityChanged, - this, &Layout::updateLastUsedActivity); + this, &ActiveLayout::updateLastUsedActivity); //!connect signals after adding the containment - connect(this, &Layout::viewsCountChanged, m_corona, &Plasma::Corona::availableScreenRectChanged); - connect(this, &Layout::viewsCountChanged, m_corona, &Plasma::Corona::availableScreenRegionChanged); + connect(this, &ActiveLayout::viewsCountChanged, m_corona, &Plasma::Corona::availableScreenRectChanged); + connect(this, &ActiveLayout::viewsCountChanged, m_corona, &Plasma::Corona::availableScreenRegionChanged); emit viewsCountChanged(); } -int Layout::version() const +int ActiveLayout::version() const { return m_version; } -void Layout::setVersion(int ver) +void ActiveLayout::setVersion(int ver) { if (m_version == ver) { return; @@ -256,12 +256,12 @@ void Layout::setVersion(int ver) emit versionChanged(); } -bool Layout::blockAutomaticLatteViewCreation() const +bool ActiveLayout::blockAutomaticLatteViewCreation() const { return m_blockAutomaticLatteViewCreation; } -void Layout::setBlockAutomaticLatteViewCreation(bool block) +void ActiveLayout::setBlockAutomaticLatteViewCreation(bool block) { if (m_blockAutomaticLatteViewCreation == block) { return; @@ -270,12 +270,12 @@ void Layout::setBlockAutomaticLatteViewCreation(bool block) m_blockAutomaticLatteViewCreation = block; } -bool Layout::disableBordersForMaximizedWindows() const +bool ActiveLayout::disableBordersForMaximizedWindows() const { return m_disableBordersForMaximizedWindows; } -void Layout::setDisableBordersForMaximizedWindows(bool disable) +void ActiveLayout::setDisableBordersForMaximizedWindows(bool disable) { if (m_disableBordersForMaximizedWindows == disable) { return; @@ -287,7 +287,7 @@ void Layout::setDisableBordersForMaximizedWindows(bool disable) emit disableBordersForMaximizedWindowsChanged(); } -bool Layout::kwin_disabledMaximizedBorders() const +bool ActiveLayout::kwin_disabledMaximizedBorders() const { //! Identify Plasma Desktop version QProcess process; @@ -300,7 +300,7 @@ bool Layout::kwin_disabledMaximizedBorders() const return (output == "true"); } -void Layout::kwin_setDisabledMaximizedBorders(bool disable) +void ActiveLayout::kwin_setDisabledMaximizedBorders(bool disable) { if (kwin_disabledMaximizedBorders() == disable) { return; @@ -321,12 +321,12 @@ void Layout::kwin_setDisabledMaximizedBorders(bool disable) } -bool Layout::showInMenu() const +bool ActiveLayout::showInMenu() const { return m_showInMenu; } -void Layout::setShowInMenu(bool show) +void ActiveLayout::setShowInMenu(bool show) { if (m_showInMenu == show) { return; @@ -336,7 +336,7 @@ void Layout::setShowInMenu(bool show) emit showInMenuChanged(); } -bool Layout::isWritable() const +bool ActiveLayout::isWritable() const { QFileInfo layoutFileInfo(m_layoutFile); @@ -347,7 +347,7 @@ bool Layout::isWritable() const } } -void Layout::lock() +void ActiveLayout::lock() { QFileInfo layoutFileInfo(m_layoutFile); @@ -356,7 +356,7 @@ void Layout::lock() } } -void Layout::unlock() +void ActiveLayout::unlock() { QFileInfo layoutFileInfo(m_layoutFile); @@ -365,12 +365,12 @@ void Layout::unlock() } } -QString Layout::background() const +QString ActiveLayout::background() const { return m_background; } -void Layout::setBackground(QString path) +void ActiveLayout::setBackground(QString path) { if (path == m_background) { return; @@ -390,12 +390,12 @@ void Layout::setBackground(QString path) emit backgroundChanged(); } -QString Layout::name() const +QString ActiveLayout::name() const { return m_layoutName; } -void Layout::setName(QString name) +void ActiveLayout::setName(QString name) { if (m_layoutName == name) { return; @@ -408,7 +408,7 @@ void Layout::setName(QString name) emit nameChanged(); } -void Layout::renameLayout(QString newName) +void ActiveLayout::renameLayout(QString newName) { if (m_layoutFile != Importer::layoutFilePath(newName)) { setFile(Importer::layoutFilePath(newName)); @@ -426,12 +426,12 @@ void Layout::renameLayout(QString newName) } } -QString Layout::color() const +QString ActiveLayout::color() const { return m_color; } -void Layout::setColor(QString color) +void ActiveLayout::setColor(QString color) { if (m_color == color) { return; @@ -441,7 +441,7 @@ void Layout::setColor(QString color) emit colorChanged(); } -QString Layout::textColor() const +QString ActiveLayout::textColor() const { //! the user is in default layout theme if (m_background.isEmpty()) { @@ -475,7 +475,7 @@ QString Layout::textColor() const return "#" + m_textColor; } -void Layout::setTextColor(QString color) +void ActiveLayout::setTextColor(QString color) { //! remove # if someone is trying to set it this way if (color.startsWith("#")) { @@ -490,12 +490,12 @@ void Layout::setTextColor(QString color) emit textColorChanged(); } -QString Layout::file() const +QString ActiveLayout::file() const { return m_layoutFile; } -void Layout::setFile(QString file) +void ActiveLayout::setFile(QString file) { if (m_layoutFile == file) { return; @@ -511,12 +511,12 @@ void Layout::setFile(QString file) emit fileChanged(); } -QStringList Layout::launchers() const +QStringList ActiveLayout::launchers() const { return m_launchers; } -void Layout::setLaunchers(QStringList launcherList) +void ActiveLayout::setLaunchers(QStringList launcherList) { if (m_launchers == launcherList) return; @@ -526,12 +526,12 @@ void Layout::setLaunchers(QStringList launcherList) emit launchersChanged(); } -QStringList Layout::activities() const +QStringList ActiveLayout::activities() const { return m_activities; } -void Layout::setActivities(QStringList activities) +void ActiveLayout::setActivities(QStringList activities) { if (m_activities == activities) { return; @@ -542,12 +542,12 @@ void Layout::setActivities(QStringList activities) emit activitiesChanged(); } -bool Layout::preferredForShortcutsTouched() const +bool ActiveLayout::preferredForShortcutsTouched() const { return m_preferredForShortcutsTouched; } -void Layout::setPreferredForShortcutsTouched(bool touched) +void ActiveLayout::setPreferredForShortcutsTouched(bool touched) { if (m_preferredForShortcutsTouched == touched) { return; @@ -557,18 +557,18 @@ void Layout::setPreferredForShortcutsTouched(bool touched) emit preferredForShortcutsTouchedChanged(); } -QStringList Layout::unloadedContainmentsIds() +QStringList ActiveLayout::unloadedContainmentsIds() { return m_unloadedContainmentsIds; } -bool Layout::isActiveLayout() const +bool ActiveLayout::isActiveLayout() const { if (!m_corona) { return false; } - Layout *activeLayout = m_corona->layoutManager()->activeLayout(m_layoutName); + ActiveLayout *activeLayout = m_corona->layoutManager()->activeLayout(m_layoutName); if (activeLayout) { return true; @@ -577,12 +577,12 @@ bool Layout::isActiveLayout() const } } -bool Layout::isOriginalLayout() const +bool ActiveLayout::isOriginalLayout() const { return m_layoutName != MultipleLayoutsName; } -bool Layout::appletGroupIsValid(KConfigGroup appletGroup) const +bool ActiveLayout::appletGroupIsValid(KConfigGroup appletGroup) const { return !( appletGroup.keyList().count() == 0 && appletGroup.groupList().count() == 1 @@ -591,7 +591,7 @@ bool Layout::appletGroupIsValid(KConfigGroup appletGroup) const && appletGroup.group("Configuration").hasKey("PreloadWeight") ); } -bool Layout::layoutIsBroken() const +bool ActiveLayout::layoutIsBroken() const { if (m_layoutFile.isEmpty() || !QFile(m_layoutFile).exists()) { return false; @@ -663,7 +663,7 @@ bool Layout::layoutIsBroken() const qDebug() << " --- file : " << m_layoutFile; } else { if (m_corona->layoutManager()->memoryUsage() == Types::MultipleLayouts) { - qDebug() << " --- in multiple layouts hidden file : " << Importer::layoutFilePath(Layout::MultipleLayoutsName); + qDebug() << " --- in multiple layouts hidden file : " << Importer::layoutFilePath(ActiveLayout::MultipleLayoutsName); } else { qDebug() << " --- in layout file : " << m_layoutFile; } @@ -715,7 +715,7 @@ bool Layout::layoutIsBroken() const } -QString Layout::layoutName(const QString &fileName) +QString ActiveLayout::layoutName(const QString &fileName) { int lastSlash = fileName.lastIndexOf("/"); QString tempLayoutFile = fileName; @@ -727,7 +727,7 @@ QString Layout::layoutName(const QString &fileName) return layoutName; } -void Layout::loadConfig() +void ActiveLayout::loadConfig() { m_version = m_layoutGroup.readEntry("version", 2); m_color = m_layoutGroup.readEntry("color", QString("blue")); @@ -752,7 +752,7 @@ void Layout::loadConfig() emit activitiesChanged(); } -void Layout::saveConfig() +void ActiveLayout::saveConfig() { qDebug() << "layout is saving... for layout:" << m_layoutName; m_layoutGroup.writeEntry("version", m_version); @@ -771,7 +771,7 @@ void Layout::saveConfig() //! Containments Actions -void Layout::addContainment(Plasma::Containment *containment) +void ActiveLayout::addContainment(Plasma::Containment *containment) { if (!containment || m_containments.contains(containment)) { return; @@ -798,16 +798,16 @@ void Layout::addContainment(Plasma::Containment *containment) qDebug() << "delaying LatteView creation for containment :: " << containment->id(); } - connect(containment, &QObject::destroyed, this, &Layout::containmentDestroyed); + connect(containment, &QObject::destroyed, this, &ActiveLayout::containmentDestroyed); } } -QHash *Layout::latteViews() +QHash *ActiveLayout::latteViews() { return &m_latteViews; } -Types::ViewType Layout::latteViewType(int containmentId) const +Types::ViewType ActiveLayout::latteViewType(int containmentId) const { for (const auto view : m_latteViews) { if (view->containment() && view->containment()->id() == containmentId) { @@ -818,14 +818,14 @@ Types::ViewType Layout::latteViewType(int containmentId) const return Types::DockView; } -Latte::View *Layout::highestPriorityView() +Latte::View *ActiveLayout::highestPriorityView() { QList views = sortedLatteViews(); return views.count() > 0 ? views[0] : nullptr; } -QList Layout::sortedLatteViews() +QList ActiveLayout::sortedLatteViews() { QList sortedViews; @@ -879,7 +879,7 @@ QList Layout::sortedLatteViews() return sortedViews; } -bool Layout::viewAtLowerScreenPriority(Latte::View *test, Latte::View *base) +bool ActiveLayout::viewAtLowerScreenPriority(Latte::View *test, Latte::View *base) { if (!base || ! test) { return true; @@ -917,7 +917,7 @@ bool Layout::viewAtLowerScreenPriority(Latte::View *test, Latte::View *base) return false; } -bool Layout::viewAtLowerEdgePriority(Latte::View *test, Latte::View *base) +bool ActiveLayout::viewAtLowerEdgePriority(Latte::View *test, Latte::View *base) { if (!base || ! test) { return true; @@ -945,12 +945,12 @@ bool Layout::viewAtLowerEdgePriority(Latte::View *test, Latte::View *base) return false; } -QList *Layout::containments() +QList *ActiveLayout::containments() { return &m_containments; } -QList Layout::viewsWithPlasmaShortcuts() +QList ActiveLayout::viewsWithPlasmaShortcuts() { QList views; @@ -982,7 +982,7 @@ QList Layout::viewsWithPlasmaShortcuts() return views; } -const QStringList Layout::appliedActivities() +const QStringList ActiveLayout::appliedActivities() { if (!m_corona) { return {}; @@ -1001,18 +1001,18 @@ const QStringList Layout::appliedActivities() } } -QString Layout::lastUsedActivity() +QString ActiveLayout::lastUsedActivity() { return m_lastUsedActivity; } -void Layout::clearLastUsedActivity() +void ActiveLayout::clearLastUsedActivity() { m_lastUsedActivity = ""; emit lastUsedActivityChanged(); } -void Layout::updateLastUsedActivity() +void ActiveLayout::updateLastUsedActivity() { if (!m_corona) { return; @@ -1035,7 +1035,7 @@ void Layout::updateLastUsedActivity() } } -void Layout::destroyedChanged(bool destroyed) +void ActiveLayout::destroyedChanged(bool destroyed) { if (!m_corona) { return; @@ -1057,7 +1057,7 @@ void Layout::destroyedChanged(bool destroyed) emit viewsCountChanged(); } -void Layout::containmentDestroyed(QObject *cont) +void ActiveLayout::containmentDestroyed(QObject *cont) { if (!m_corona) { return; @@ -1089,7 +1089,7 @@ void Layout::containmentDestroyed(QObject *cont) } } -void Layout::addView(Plasma::Containment *containment, bool forceOnPrimary, int explicitScreen) +void ActiveLayout::addView(Plasma::Containment *containment, bool forceOnPrimary, int explicitScreen) { qDebug() << "Layout :::: " << m_layoutName << " ::: addView was called... m_containments :: " << m_containments.size(); @@ -1217,14 +1217,14 @@ void Layout::addView(Plasma::Containment *containment, bool forceOnPrimary, int latteView->setOnPrimary(true); } - // connect(containment, &QObject::destroyed, this, &Layout::containmentDestroyed); - connect(containment, &Plasma::Applet::destroyedChanged, this, &Layout::destroyedChanged); + // connect(containment, &QObject::destroyed, this, &ActiveLayout::containmentDestroyed); + connect(containment, &Plasma::Applet::destroyedChanged, this, &ActiveLayout::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->layoutManager()->memoryUsage() == Types::MultipleLayouts) { - connect(containment, &Plasma::Containment::appletCreated, this, &Layout::appletCreated); + connect(containment, &Plasma::Containment::appletCreated, this, &ActiveLayout::appletCreated); } //! Qt 5.9 creates a crash for this in wayland, that is why the check is used @@ -1239,7 +1239,7 @@ void Layout::addView(Plasma::Containment *containment, bool forceOnPrimary, int emit viewsCountChanged(); } -void Layout::addNewView() +void ActiveLayout::addNewView() { if (!m_corona) { return; @@ -1248,7 +1248,7 @@ void Layout::addNewView() m_corona->loadDefaultLayout(); } -void Layout::copyView(Plasma::Containment *containment) +void ActiveLayout::copyView(Plasma::Containment *containment) { if (!containment || !m_corona) return; @@ -1400,7 +1400,7 @@ void Layout::copyView(Plasma::Containment *containment) setBlockAutomaticLatteViewCreation(false); } -void Layout::appletCreated(Plasma::Applet *applet) +void ActiveLayout::appletCreated(Plasma::Applet *applet) { //! In Multiple Layout the orphaned systrays must be assigned to layouts //! when the user adds them @@ -1421,7 +1421,7 @@ void Layout::appletCreated(Plasma::Applet *applet) } } -void Layout::importToCorona() +void ActiveLayout::importToCorona() { if (!m_corona) { return; @@ -1468,7 +1468,7 @@ void Layout::importToCorona() importLayoutFile(temp2File); } -QString Layout::availableId(QStringList all, QStringList assigned, int base) +QString ActiveLayout::availableId(QStringList all, QStringList assigned, int base) { bool found = false; @@ -1487,7 +1487,7 @@ QString Layout::availableId(QStringList all, QStringList assigned, int base) return QString(""); } -QString Layout::newUniqueIdsLayoutFromFile(QString file) +QString ActiveLayout::newUniqueIdsLayoutFromFile(QString file) { if (!m_corona) { return QString(); @@ -1659,7 +1659,7 @@ QString Layout::newUniqueIdsLayoutFromFile(QString file) return tempFile; } -QList Layout::importLayoutFile(QString file) +QList ActiveLayout::importLayoutFile(QString file) { KSharedConfigPtr filePtr = KSharedConfig::openConfig(file); auto newContainments = m_corona->importLayout(KConfigGroup(filePtr, "")); @@ -1697,7 +1697,7 @@ QList Layout::importLayoutFile(QString file) return importedDocks; } -void Layout::recreateView(Plasma::Containment *containment) +void ActiveLayout::recreateView(Plasma::Containment *containment) { if (!m_corona) { return; @@ -1728,7 +1728,7 @@ void Layout::recreateView(Plasma::Containment *containment) //! the central functions that updates loading/unloading latteviews //! concerning screen changed (for multi-screen setups mainly) -void Layout::syncLatteViewsToScreens() +void ActiveLayout::syncLatteViewsToScreens() { if (!m_corona) { return; @@ -1856,7 +1856,7 @@ void Layout::syncLatteViewsToScreens() qDebug() << "end of, syncLatteViewsToScreens ...."; } -void Layout::assignToLayout(Latte::View *latteView, QList containments) +void ActiveLayout::assignToLayout(Latte::View *latteView, QList containments) { if (!m_corona) { return; @@ -1869,9 +1869,9 @@ void Layout::assignToLayout(Latte::View *latteView, QList for (const auto containment : containments) { containment->config().writeEntry("layoutId", name()); - connect(containment, &QObject::destroyed, this, &Layout::containmentDestroyed); - connect(containment, &Plasma::Applet::destroyedChanged, this, &Layout::destroyedChanged); - connect(containment, &Plasma::Containment::appletCreated, this, &Layout::appletCreated); + connect(containment, &QObject::destroyed, this, &ActiveLayout::containmentDestroyed); + connect(containment, &Plasma::Applet::destroyedChanged, this, &ActiveLayout::destroyedChanged); + connect(containment, &Plasma::Containment::appletCreated, this, &ActiveLayout::appletCreated); } latteView->setManagedLayout(this); @@ -1885,7 +1885,7 @@ void Layout::assignToLayout(Latte::View *latteView, QList } } -QList Layout::unassignFromLayout(Latte::View *latteView) +QList ActiveLayout::unassignFromLayout(Latte::View *latteView) { QList containments; @@ -1901,9 +1901,9 @@ QList Layout::unassignFromLayout(Latte::View *latteView) //! add systrays from that latteView if (parentApplet && parentApplet->containment() && parentApplet->containment() == latteView->containment()) { containments << containment; - disconnect(containment, &QObject::destroyed, this, &Layout::containmentDestroyed); - disconnect(containment, &Plasma::Applet::destroyedChanged, this, &Layout::destroyedChanged); - disconnect(containment, &Plasma::Containment::appletCreated, this, &Layout::appletCreated); + disconnect(containment, &QObject::destroyed, this, &ActiveLayout::containmentDestroyed); + disconnect(containment, &Plasma::Applet::destroyedChanged, this, &ActiveLayout::destroyedChanged); + disconnect(containment, &Plasma::Containment::appletCreated, this, &ActiveLayout::appletCreated); } } @@ -1923,7 +1923,7 @@ QList Layout::unassignFromLayout(Latte::View *latteView) return containments; } -bool Layout::latteViewExists(Plasma::Containment *containment) +bool ActiveLayout::latteViewExists(Plasma::Containment *containment) { if (!m_corona) { return false; @@ -1932,7 +1932,7 @@ bool Layout::latteViewExists(Plasma::Containment *containment) return m_latteViews.keys().contains(containment); } -QList Layout::availableEdgesForView(QScreen *scr, Latte::View *forView) const +QList ActiveLayout::availableEdgesForView(QScreen *scr, Latte::View *forView) const { using Plasma::Types; QList edges{Types::BottomEdge, Types::LeftEdge, @@ -1953,7 +1953,7 @@ QList Layout::availableEdgesForView(QScreen *scr, Latte return edges; } -QList Layout::qmlFreeEdges(int screen) const +QList ActiveLayout::qmlFreeEdges(int screen) const { if (!m_corona) { const QList emptyEdges; @@ -1970,7 +1970,7 @@ QList Layout::qmlFreeEdges(int screen) const return edgesInt; } -QList Layout::freeEdges(QScreen *scr) const +QList ActiveLayout::freeEdges(QScreen *scr) const { using Plasma::Types; QList edges{Types::BottomEdge, Types::LeftEdge, @@ -1989,7 +1989,7 @@ QList Layout::freeEdges(QScreen *scr) const return edges; } -QList Layout::freeEdges(int screen) const +QList ActiveLayout::freeEdges(int screen) const { using Plasma::Types; QList edges{Types::BottomEdge, Types::LeftEdge, @@ -2010,7 +2010,7 @@ QList Layout::freeEdges(int screen) const return edges; } -bool Layout::explicitDockOccupyEdge(int screen, Plasma::Types::Location location) const +bool ActiveLayout::explicitDockOccupyEdge(int screen, Plasma::Types::Location location) const { if (!m_corona) { return false; @@ -2031,7 +2031,7 @@ bool Layout::explicitDockOccupyEdge(int screen, Plasma::Types::Location location return false; } -bool Layout::primaryDockOccupyEdge(Plasma::Types::Location location) const +bool ActiveLayout::primaryDockOccupyEdge(Plasma::Types::Location location) const { if (!m_corona) { return false; @@ -2051,7 +2051,7 @@ bool Layout::primaryDockOccupyEdge(Plasma::Types::Location location) const return false; } -bool Layout::isLatteContainment(Plasma::Containment *containment) const +bool ActiveLayout::isLatteContainment(Plasma::Containment *containment) const { if (!containment) { return false; @@ -2064,7 +2064,7 @@ bool Layout::isLatteContainment(Plasma::Containment *containment) const return false; } -int Layout::viewsWithTasks() const +int ActiveLayout::viewsWithTasks() const { if (!m_corona) { return 0; @@ -2081,7 +2081,7 @@ int Layout::viewsWithTasks() const return result; } -int Layout::viewsCount(int screen) const +int ActiveLayout::viewsCount(int screen) const { if (!m_corona) { return 0; @@ -2100,7 +2100,7 @@ int Layout::viewsCount(int screen) const return docks; } -int Layout::viewsCount(QScreen *screen) const +int ActiveLayout::viewsCount(QScreen *screen) const { if (!m_corona) { return 0; @@ -2117,7 +2117,7 @@ int Layout::viewsCount(QScreen *screen) const return docks; } -int Layout::viewsCount() const +int ActiveLayout::viewsCount() const { if (!m_corona) { return 0; diff --git a/app/layout/layout.h b/app/layout/activelayout.h similarity index 97% rename from app/layout/layout.h rename to app/layout/activelayout.h index 8bf43df06..2ca3401f3 100644 --- a/app/layout/layout.h +++ b/app/layout/activelayout.h @@ -18,10 +18,11 @@ * along with this program. If not, see . */ -#ifndef LAYOUT_H -#define LAYOUT_H +#ifndef ACTIVELAYOUT_H +#define ACTIVELAYOUT_H // local +#include "genericlayout.h" #include "../../liblatte2/types.h" // Qt @@ -53,7 +54,7 @@ namespace Latte { //! This class is responsible to hold the settings for a specific layout. //! It also updates always the relevant layout configuration concerning //! its general settings (no the containments) -class Layout : public QObject +class ActiveLayout : public Layout::GenericLayout { Q_OBJECT Q_PROPERTY(bool showInMenu READ showInMenu WRITE setShowInMenu NOTIFY showInMenuChanged) @@ -71,8 +72,8 @@ class Layout : public QObject Q_PROPERTY(bool preferredForShortcutsTouched READ preferredForShortcutsTouched WRITE setPreferredForShortcutsTouched NOTIFY preferredForShortcutsTouchedChanged) public: - Layout(QObject *parent, QString layoutFile, QString layoutName = QString()); - ~Layout() override; + ActiveLayout(QObject *parent, QString layoutFile, QString layoutName = QString()); + ~ActiveLayout() override; static const QString MultipleLayoutsName; @@ -280,4 +281,4 @@ private: } -#endif // LAYOUT_H +#endif //ACTIVELAYOUT_H diff --git a/app/layout/genericlayout.cpp b/app/layout/genericlayout.cpp new file mode 100644 index 000000000..8f4882793 --- /dev/null +++ b/app/layout/genericlayout.cpp @@ -0,0 +1,35 @@ +/* +* Copyright 2019 Michail Vourlakos +* +* This file is part of Latte-Dock +* +* Latte-Dock is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License as +* published by the Free Software Foundation; either version 2 of +* the License, or (at your option) any later version. +* +* Latte-Dock is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*/ + +#include "genericlayout.h" + +namespace Latte { +namespace Layout { + +GenericLayout::GenericLayout(QObject *parent) : + AbstractLayout (parent) +{ +} + +GenericLayout::~GenericLayout() +{ +} + +} +} diff --git a/app/layout/genericlayout.h b/app/layout/genericlayout.h new file mode 100644 index 000000000..206f1a39e --- /dev/null +++ b/app/layout/genericlayout.h @@ -0,0 +1,44 @@ +/* +* Copyright 2019 Michail Vourlakos +* +* This file is part of Latte-Dock +* +* Latte-Dock is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License as +* published by the Free Software Foundation; either version 2 of +* the License, or (at your option) any later version. +* +* Latte-Dock is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*/ + +#ifndef GENERICLAYOUT_H +#define GENERICLAYOUT_H + +// local +#include "abstractlayout.h" + +// Qt +#include + +namespace Latte { +namespace Layout { + +class GenericLayout : public AbstractLayout +{ + Q_OBJECT + +public: + GenericLayout(QObject *parent); + ~GenericLayout() override; +}; + +} +} + +#endif diff --git a/app/layoutmanager.cpp b/app/layoutmanager.cpp index 606be6ccf..4e4a36392 100644 --- a/app/layoutmanager.cpp +++ b/app/layoutmanager.cpp @@ -25,7 +25,7 @@ #include "infoview.h" #include "launcherssignals.h" #include "screenpool.h" -#include "layout/layout.h" +#include "layout/activelayout.h" #include "settings/settingsdialog.h" #include "settings/universalsettings.h" #include "view/view.h" @@ -71,7 +71,7 @@ LayoutManager::~LayoutManager() m_launchersSignals->deleteLater(); while (!m_activeLayouts.isEmpty()) { - Layout *layout = m_activeLayouts.at(0); + ActiveLayout *layout = m_activeLayouts.at(0); m_activeLayouts.removeFirst(); layout->unloadContainments(); layout->unloadLatteViews(); @@ -105,7 +105,7 @@ void LayoutManager::load() } //! Check if the multiple-layouts hidden file is present, add it if it isnt - if (!QFile(QDir::homePath() + "/.config/latte/" + Layout::MultipleLayoutsName + ".layout.latte").exists()) { + if (!QFile(QDir::homePath() + "/.config/latte/" + ActiveLayout::MultipleLayoutsName + ".layout.latte").exists()) { importPreset(MultipleLayoutsPresetId, false); } @@ -194,7 +194,7 @@ QString LayoutManager::defaultLayoutName() const { QByteArray presetNameOrig = QString("preset" + QString::number(1)).toUtf8(); QString presetPath = m_corona->kPackage().filePath(presetNameOrig); - QString presetName = Layout::layoutName(presetPath); + QString presetName = ActiveLayout::layoutName(presetPath); QByteArray presetNameChars = presetName.toUtf8(); presetName = i18n(presetNameChars); @@ -315,7 +315,7 @@ QStringList LayoutManager::activeLayoutsNames() names << currentLayoutName(); } else { for (int i = 0; i < m_activeLayouts.size(); ++i) { - Layout *layout = m_activeLayouts.at(i); + ActiveLayout *layout = m_activeLayouts.at(i); if (layout->isOriginalLayout()) { names << layout->name(); @@ -328,10 +328,10 @@ QStringList LayoutManager::activeLayoutsNames() } -Layout *LayoutManager::activeLayout(QString id) const +ActiveLayout *LayoutManager::activeLayout(QString id) const { for (int i = 0; i < m_activeLayouts.size(); ++i) { - Layout *layout = m_activeLayouts.at(i); + ActiveLayout *layout = m_activeLayouts.at(i); if (layout->name() == id) { @@ -345,7 +345,7 @@ Layout *LayoutManager::activeLayout(QString id) const int LayoutManager::activeLayoutPos(QString id) const { for (int i = 0; i < m_activeLayouts.size(); ++i) { - Layout *layout = m_activeLayouts.at(i); + ActiveLayout *layout = m_activeLayouts.at(i); if (layout->name() == id) { @@ -356,7 +356,7 @@ int LayoutManager::activeLayoutPos(QString id) const return -1; } -Layout *LayoutManager::currentLayout() const +ActiveLayout *LayoutManager::currentLayout() const { if (memoryUsage() == Types::SingleLayout) { return m_activeLayouts.at(0); @@ -368,7 +368,7 @@ Layout *LayoutManager::currentLayout() const } for (auto layout : m_activeLayouts) { - if ((layout->name() != Layout::MultipleLayoutsName) && (layout->activities().isEmpty())) { + if ((layout->name() != ActiveLayout::MultipleLayoutsName) && (layout->activities().isEmpty())) { return layout; } } @@ -469,7 +469,7 @@ void LayoutManager::loadLayouts() QStringList files = layoutDir.entryList(filter, QDir::Files | QDir::NoSymLinks); for (const auto &layout : files) { - Layout layoutSets(this, layoutDir.absolutePath() + "/" + layout); + ActiveLayout layoutSets(this, layoutDir.absolutePath() + "/" + layout); QStringList validActivityIds = validActivities(layoutSets.activities()); layoutSets.setActivities(validActivityIds); @@ -619,7 +619,7 @@ void LayoutManager::hideAllViews() } } -void LayoutManager::addLayout(Layout *layout) +void LayoutManager::addLayout(ActiveLayout *layout) { if (!m_activeLayouts.contains(layout)) { m_activeLayouts.append(layout); @@ -635,7 +635,7 @@ bool LayoutManager::switchToLayout(QString layoutName, int previousMemoryUsage) //! First Check If that Layout is already present if (memoryUsage() == Types::MultipleLayouts && previousMemoryUsage == -1) { - Layout *layout = activeLayout(layoutName); + ActiveLayout *layout = activeLayout(layoutName); if (layout) { @@ -670,12 +670,12 @@ bool LayoutManager::switchToLayout(QString layoutName, int previousMemoryUsage) if (!lPath.isEmpty()) { if (memoryUsage() == Types::SingleLayout) { emit currentLayoutIsSwitching(currentLayoutName()); - } else if (memoryUsage() == Types::MultipleLayouts && layoutName != Layout::MultipleLayoutsName) { - Layout toLayout(this, lPath); + } else if (memoryUsage() == Types::MultipleLayouts && layoutName != ActiveLayout::MultipleLayoutsName) { + ActiveLayout toLayout(this, lPath); QStringList toActivities = toLayout.activities(); - Layout *activeForOrphans{nullptr}; + ActiveLayout *activeForOrphans{nullptr}; for (const auto fromLayout : m_activeLayouts) { if (fromLayout->isOriginalLayout() && fromLayout->activities().isEmpty()) { @@ -701,13 +701,13 @@ bool LayoutManager::switchToLayout(QString layoutName, int previousMemoryUsage) bool initializingMultipleLayouts{false}; - if (memoryUsage() == Types::MultipleLayouts && !activeLayout(Layout::MultipleLayoutsName)) { + if (memoryUsage() == Types::MultipleLayouts && !activeLayout(ActiveLayout::MultipleLayoutsName)) { initializingMultipleLayouts = true; } if (memoryUsage() == Types::SingleLayout || initializingMultipleLayouts || previousMemoryUsage == Types::MultipleLayouts) { while (!m_activeLayouts.isEmpty()) { - Layout *layout = m_activeLayouts.at(0); + ActiveLayout *layout = m_activeLayouts.at(0); m_activeLayouts.removeFirst(); if (layout->isOriginalLayout() && previousMemoryUsage == Types::MultipleLayouts) { @@ -725,11 +725,11 @@ bool LayoutManager::switchToLayout(QString layoutName, int previousMemoryUsage) } if (initializingMultipleLayouts) { - fixedLayoutName = QString(Layout::MultipleLayoutsName); + fixedLayoutName = QString(ActiveLayout::MultipleLayoutsName); fixedLPath = layoutPath(fixedLayoutName); } - Layout *newLayout = new Layout(this, fixedLPath, fixedLayoutName); + ActiveLayout *newLayout = new ActiveLayout(this, fixedLPath, fixedLayoutName); addLayout(newLayout); loadLatteLayout(fixedLPath); @@ -742,7 +742,7 @@ bool LayoutManager::switchToLayout(QString layoutName, int previousMemoryUsage) //! a Layout that is assigned to specific activities but this //! layout isnt loaded (this means neither of its activities are running) //! is such case we just activate these Activities - Layout layout(this, Importer::layoutFilePath(layoutName)); + ActiveLayout layout(this, Importer::layoutFilePath(layoutName)); int i = 0; bool lastUsedActivityFound{false}; @@ -820,7 +820,7 @@ void LayoutManager::syncMultipleLayoutsToActivities(QString layoutForOrphans) QStringList layoutsToUnload; QStringList layoutsToLoad; - layoutsToLoad << Layout::MultipleLayoutsName; + layoutsToLoad << ActiveLayout::MultipleLayoutsName; bool allRunningActivitiesWillBeReserved{true}; @@ -855,8 +855,8 @@ void LayoutManager::syncMultipleLayoutsToActivities(QString layoutForOrphans) //! Unload no needed Layouts for (const auto &layoutName : layoutsToUnload) { - if (layoutName != Layout::MultipleLayoutsName) { - Layout *layout = activeLayout(layoutName); + if (layoutName != ActiveLayout::MultipleLayoutsName) { + ActiveLayout *layout = activeLayout(layoutName); int posLayout = activeLayoutPos(layoutName); if (posLayout >= 0) { @@ -878,7 +878,7 @@ void LayoutManager::syncMultipleLayoutsToActivities(QString layoutForOrphans) //! Add Layout for orphan activities if (!allRunningActivitiesWillBeReserved) { if (!activeLayout(layoutForOrphans)) { - Layout *newLayout = new Layout(this, layoutPath(layoutForOrphans), layoutForOrphans); + ActiveLayout *newLayout = new ActiveLayout(this, layoutPath(layoutForOrphans), layoutForOrphans); if (newLayout) { qDebug() << "ACTIVATING ORPHANED LAYOUT ::::: " << layoutForOrphans; @@ -891,7 +891,7 @@ void LayoutManager::syncMultipleLayoutsToActivities(QString layoutForOrphans) //! Add needed Layouts based on Activities for (const auto &layoutName : layoutsToLoad) { if (!activeLayout(layoutName)) { - Layout *newLayout = new Layout(this, QString(layoutPath(layoutName)), layoutName); + ActiveLayout *newLayout = new ActiveLayout(this, QString(layoutPath(layoutName)), layoutName); if (newLayout) { qDebug() << "ACTIVATING LAYOUT ::::: " << layoutName; @@ -912,7 +912,7 @@ void LayoutManager::syncMultipleLayoutsToActivities(QString layoutForOrphans) void LayoutManager::pauseLayout(QString layoutName) { if (memoryUsage() == Types::MultipleLayouts) { - Layout *layout = activeLayout(layoutName); + ActiveLayout *layout = activeLayout(layoutName); if (layout && !layout->activities().isEmpty()) { int i = 0; @@ -1074,7 +1074,7 @@ void LayoutManager::importPreset(int presetNo, bool newInstanceIfPresent) QByteArray presetNameOrig = QString("preset" + QString::number(presetNo)).toUtf8(); QString presetPath = m_corona->kPackage().filePath(presetNameOrig); - QString presetName = Layout::layoutName(presetPath); + QString presetName = ActiveLayout::layoutName(presetPath); QByteArray presetNameChars = presetName.toUtf8(); presetName = i18n(presetNameChars); diff --git a/app/layoutmanager.h b/app/layoutmanager.h index ae208ae0e..8e9f00a71 100644 --- a/app/layoutmanager.h +++ b/app/layoutmanager.h @@ -45,7 +45,7 @@ class Controller; namespace Latte { class Corona; class Importer; -class Layout; +class ActiveLayout; class LaunchersSignals; class View; } @@ -97,11 +97,11 @@ public: //! returns an active layout with that #id (name), it returns null if such //! layout cant be found - Layout *activeLayout(QString id) const; + ActiveLayout *activeLayout(QString id) const; int activeLayoutPos(QString id) const; //! returns the current and active layout based on activities and user preferences - Layout *currentLayout() const; + ActiveLayout *currentLayout() const; LaunchersSignals *launchersSignals(); @@ -144,7 +144,7 @@ private slots: void syncMultipleLayoutsToActivities(QString layoutForOrphans = QString()); private: - void addLayout(Layout *layout); + void addLayout(ActiveLayout *layout); void cleanupOnStartup(QString path); //!remove deprecated or oldstyle config options void clearUnloadedContainmentsFromLinkedFile(QStringList containmentsIds, bool bypassChecks = false); void confirmDynamicSwitch(); @@ -187,7 +187,7 @@ private: Importer *m_importer{nullptr}; LaunchersSignals *m_launchersSignals{nullptr}; - QList m_activeLayouts; + QList m_activeLayouts; KActivities::Controller *m_activitiesController; diff --git a/app/settings/settingsdialog.cpp b/app/settings/settingsdialog.cpp index 13da25136..080ba0977 100644 --- a/app/settings/settingsdialog.cpp +++ b/app/settings/settingsdialog.cpp @@ -27,7 +27,7 @@ #include "universalsettings.h" #include "ui_settingsdialog.h" #include "../lattecorona.h" -#include "../layout/layout.h" +#include "../layout/activelayout.h" #include "../liblatte2/types.h" #include "../plasma/extended/theme.h" #include "delegates/checkboxdelegate.h" @@ -298,7 +298,7 @@ void SettingsDialog::on_newButton_clicked() //! find Default preset path for (const auto &preset : m_corona->layoutManager()->presetsPaths()) { - QString presetName = Layout::layoutName(preset); + QString presetName = ActiveLayout::layoutName(preset); if (presetName == "Default") { QByteArray presetNameChars = presetName.toUtf8(); @@ -326,7 +326,7 @@ void SettingsDialog::on_copyButton_clicked() QString lName = (m_model->data(m_model->index(row, NAMECOLUMN), Qt::DisplayRole)).toString(); if (Importer::layoutExists(lName)) { - Layout *layout = m_corona->layoutManager()->activeLayout(lName); + ActiveLayout *layout = m_corona->layoutManager()->activeLayout(lName); if (layout && layout->isOriginalLayout()) { layout->syncToLayoutFile(); @@ -352,7 +352,7 @@ void SettingsDialog::on_copyButton_clicked() QFile(copiedId).setPermissions(QFileDevice::ReadUser | QFileDevice::WriteUser | QFileDevice::ReadGroup | QFileDevice::ReadOther); } - Layout *settings = new Layout(this, copiedId); + ActiveLayout *settings = new ActiveLayout(this, copiedId); m_layouts[copiedId] = settings; insertLayoutInfoAtRow(row + 1, copiedId, color, textColor, layoutName, menu, disabledBorders, QStringList(), false); @@ -621,7 +621,7 @@ void SettingsDialog::on_exportButton_clicked() QFile(file).setPermissions(QFileDevice::ReadUser | QFileDevice::WriteUser | QFileDevice::ReadGroup | QFileDevice::ReadOther); } - Layout layoutS(this, file); + ActiveLayout layoutS(this, file); layoutS.setActivities(QStringList()); layoutS.clearLastUsedActivity(); @@ -740,7 +740,7 @@ void SettingsDialog::restoreDefaults() if (ui->tabWidget->currentIndex() == 0) { //! Default layouts missing from layouts list for (const auto &preset : m_corona->layoutManager()->presetsPaths()) { - QString presetName = Layout::layoutName(preset); + QString presetName = ActiveLayout::layoutName(preset); QByteArray presetNameChars = presetName.toUtf8(); const char *prset_str = presetNameChars.data(); presetName = i18n(prset_str); @@ -765,7 +765,7 @@ void SettingsDialog::restoreDefaults() void SettingsDialog::addLayoutForFile(QString file, QString layoutName, bool newTempDirectory, bool showNotification) { if (layoutName.isEmpty()) { - layoutName = Layout::layoutName(file); + layoutName = ActiveLayout::layoutName(file); } QString copiedId; @@ -785,11 +785,11 @@ void SettingsDialog::addLayoutForFile(QString file, QString layoutName, bool new } if (m_layouts.contains(copiedId)) { - Layout *oldSettings = m_layouts.take(copiedId); + ActiveLayout *oldSettings = m_layouts.take(copiedId); delete oldSettings; } - Layout *settings = new Layout(this, copiedId); + ActiveLayout *settings = new ActiveLayout(this, copiedId); m_layouts[copiedId] = settings; QString id = copiedId; @@ -836,7 +836,7 @@ void SettingsDialog::loadSettings() QString layoutPath = QDir::homePath() + "/.config/latte/" + layout + ".layout.latte"; m_initLayoutPaths.append(layoutPath); - Layout *layoutSets = new Layout(this, layoutPath); + ActiveLayout *layoutSets = new ActiveLayout(this, layoutPath); m_layouts[layoutPath] = layoutSets; QString background = layoutSets->background(); @@ -859,7 +859,7 @@ void SettingsDialog::loadSettings() ui->layoutsView->selectRow(i - 1); } - Layout *activeLayout = m_corona->layoutManager()->activeLayout(layoutSets->name()); + ActiveLayout *activeLayout = m_corona->layoutManager()->activeLayout(layoutSets->name()); if ((activeLayout && activeLayout->layoutIsBroken()) || (!activeLayout && layoutSets->layoutIsBroken())) { brokenLayouts.append(layoutSets->name()); @@ -1105,7 +1105,7 @@ void SettingsDialog::on_pauseButton_clicked() ui->pauseButton->setEnabled(false); QString id = m_model->data(m_model->index(ui->layoutsView->currentIndex().row(), IDCOLUMN), Qt::DisplayRole).toString(); - Layout *layout = m_layouts[id]; + ActiveLayout *layout = m_layouts[id]; if (layout) { m_corona->layoutManager()->pauseLayout(layout->name()); @@ -1126,7 +1126,7 @@ void SettingsDialog::layoutsChanged() font.setBold(true); // ui->layoutsView->selectRow(i); } else { - Layout *layout = m_corona->layoutManager()->activeLayout(name); + ActiveLayout *layout = m_corona->layoutManager()->activeLayout(name); if (layout && (m_corona->layoutManager()->memoryUsage() == Types::MultipleLayouts)) { font.setBold(true); @@ -1191,7 +1191,7 @@ void SettingsDialog::updateApplyButtonsState() bool layoutMissing{false}; for (const auto &preset : m_corona->layoutManager()->presetsPaths()) { - QString presetName = Layout::layoutName(preset); + QString presetName = ActiveLayout::layoutName(preset); QByteArray presetNameChars = presetName.toUtf8(); const char *prset_str = presetNameChars.data(); presetName = i18n(prset_str); @@ -1249,7 +1249,7 @@ void SettingsDialog::updatePerLayoutButtonsState() QStringList lActivities = m_model->data(m_model->index(currentRow, ACTIVITYCOLUMN), Qt::UserRole).toStringList(); - Layout *layout = m_layouts[id]; + Latte::ActiveLayout *layout = m_layouts[id]; if (!lActivities.isEmpty() && layout && m_corona->layoutManager()->activeLayout(layout->name())) { ui->pauseButton->setEnabled(true); @@ -1365,7 +1365,7 @@ bool SettingsDialog::saveAllChanges() QString switchToLayout; - QHash activeLayoutsToRename; + QHash activeLayoutsToRename; //! remove layouts that have been removed from the user for (const auto &initLayout : m_initLayoutPaths) { @@ -1373,7 +1373,7 @@ bool SettingsDialog::saveAllChanges() QFile(initLayout).remove(); if (m_layouts.contains(initLayout)) { - Layout *removedLayout = m_layouts.take(initLayout); + ActiveLayout *removedLayout = m_layouts.take(initLayout); delete removedLayout; } } @@ -1399,9 +1399,9 @@ bool SettingsDialog::saveAllChanges() } //qDebug() << i << ". " << id << " - " << color << " - " << name << " - " << menu << " - " << lActivities; - Layout *activeLayout = m_corona->layoutManager()->activeLayout(m_layouts[id]->name()); + ActiveLayout *activeLayout = m_corona->layoutManager()->activeLayout(m_layouts[id]->name()); - Layout *layout = activeLayout ? activeLayout : m_layouts[id]; + ActiveLayout *layout = activeLayout ? activeLayout : m_layouts[id]; //! unlock read-only layout if (!layout->isWritable()) { @@ -1470,7 +1470,7 @@ bool SettingsDialog::saveAllChanges() QString newFile = QDir::homePath() + "/.config/latte/" + toRenameNames[i] + ".layout.latte"; QFile(toRenamePaths[i]).rename(newFile); - Layout *nLayout = new Layout(this, newFile); + ActiveLayout *nLayout = new ActiveLayout(this, newFile); m_layouts[newFile] = nLayout; for (int j = 0; j < m_model->rowCount(); ++j) { @@ -1493,7 +1493,7 @@ bool SettingsDialog::saveAllChanges() if (m_corona->layoutManager()->memoryUsage() == Types::MultipleLayouts) { for (const auto &newLayoutName : activeLayoutsToRename.keys()) { qDebug() << " Active Layout Is Renamed From : " << activeLayoutsToRename[newLayoutName]->name() << " TO :: " << newLayoutName; - Layout *layout = activeLayoutsToRename[newLayoutName]; + ActiveLayout *layout = activeLayoutsToRename[newLayoutName]; layout->renameLayout(newLayoutName); //! that means it is an active layout for orphaned Activities @@ -1509,8 +1509,8 @@ bool SettingsDialog::saveAllChanges() QString name = m_model->data(m_model->index(i, NAMECOLUMN), Qt::DisplayRole).toString(); bool locked = m_model->data(m_model->index(i, NAMECOLUMN), Qt::UserRole).toBool(); - Layout *activeLayout = m_corona->layoutManager()->activeLayout(m_layouts[id]->name()); - Layout *layout = activeLayout ? activeLayout : m_layouts[id]; + ActiveLayout *activeLayout = m_corona->layoutManager()->activeLayout(m_layouts[id]->name()); + ActiveLayout *layout = activeLayout ? activeLayout : m_layouts[id]; if (layout && locked && layout->isWritable()) { layout->lock(); diff --git a/app/settings/settingsdialog.h b/app/settings/settingsdialog.h index 3b07694c9..791fa8b6a 100644 --- a/app/settings/settingsdialog.h +++ b/app/settings/settingsdialog.h @@ -43,7 +43,7 @@ class Controller; namespace Latte { class Corona; -class Layout; +class ActiveLayout; } namespace Latte { @@ -127,7 +127,7 @@ private: QStandardItemModel *m_model{nullptr}; Ui::SettingsDialog *ui; - QHash m_layouts; + QHash m_layouts; QList o_settings; QStringList o_settingsLayouts; diff --git a/app/shortcuts/globalshortcuts.cpp b/app/shortcuts/globalshortcuts.cpp index 1acd9eee5..d3d34173c 100644 --- a/app/shortcuts/globalshortcuts.cpp +++ b/app/shortcuts/globalshortcuts.cpp @@ -25,7 +25,7 @@ #include "shortcutstracker.h" #include "../lattecorona.h" #include "../layoutmanager.h" -#include "../layout/layout.h" +#include "../layout/activelayout.h" #include "../settings/universalsettings.h" #include "../view/view.h" @@ -223,7 +223,7 @@ void GlobalShortcuts::activateLauncherMenu() } QList sortedViews; - Layout *currentLayout = m_corona->layoutManager()->currentLayout(); + ActiveLayout *currentLayout = m_corona->layoutManager()->currentLayout(); if (currentLayout) { sortedViews = currentLayout->sortedLatteViews(); @@ -387,7 +387,7 @@ void GlobalShortcuts::activateEntry(int index, Qt::Key modifier) m_lastInvokedAction = dynamic_cast(sender()); QList sortedViews; - Layout *currentLayout = m_corona->layoutManager()->currentLayout(); + ActiveLayout *currentLayout = m_corona->layoutManager()->currentLayout(); if (currentLayout) { sortedViews = currentLayout->sortedLatteViews(); @@ -461,7 +461,7 @@ void GlobalShortcuts::updateViewItemBadge(QString identifier, QString value) }; QHash *views; - Layout *currentLayout = m_corona->layoutManager()->currentLayout(); + ActiveLayout *currentLayout = m_corona->layoutManager()->currentLayout(); if (currentLayout) { views = currentLayout->latteViews(); @@ -618,7 +618,7 @@ void GlobalShortcuts::showViews() }; QList sortedViews; - Layout *currentLayout = m_corona->layoutManager()->currentLayout(); + ActiveLayout *currentLayout = m_corona->layoutManager()->currentLayout(); if (currentLayout) { sortedViews = currentLayout->sortedLatteViews(); @@ -722,7 +722,7 @@ bool GlobalShortcuts::viewsToHideAreValid() void GlobalShortcuts::showSettings() { QList sortedViews; - Layout *currentLayout = m_corona->layoutManager()->currentLayout(); + ActiveLayout *currentLayout = m_corona->layoutManager()->currentLayout(); if (currentLayout) { sortedViews = currentLayout->sortedLatteViews(); diff --git a/app/view/settings/primaryconfigview.cpp b/app/view/settings/primaryconfigview.cpp index d36484a32..74f6ada26 100644 --- a/app/view/settings/primaryconfigview.cpp +++ b/app/view/settings/primaryconfigview.cpp @@ -26,7 +26,7 @@ #include "../view.h" #include "../../lattecorona.h" #include "../../layoutmanager.h" -#include "../../layout/layout.h" +#include "../../layout/activelayout.h" #include "../../settings/universalsettings.h" #include "../../shortcuts/globalshortcuts.h" #include "../../shortcuts/shortcutstracker.h" diff --git a/app/view/view.cpp b/app/view/view.cpp index 74929d54a..d3c6d7e23 100644 --- a/app/view/view.cpp +++ b/app/view/view.cpp @@ -29,7 +29,7 @@ #include "settings/secondaryconfigview.h" #include "../lattecorona.h" #include "../layoutmanager.h" -#include "../layout/layout.h" +#include "../layout/activelayout.h" #include "../plasma/extended/theme.h" #include "../screenpool.h" #include "../settings/universalsettings.h" @@ -762,12 +762,12 @@ void View::applyActivitiesToWindows() } } -Layout *View::managedLayout() const +Latte::ActiveLayout *View::managedLayout() const { return m_managedLayout; } -void View::setManagedLayout(Layout *layout) +void View::setManagedLayout(Latte::ActiveLayout *layout) { if (m_managedLayout == layout) { return; @@ -791,8 +791,8 @@ void View::setManagedLayout(Layout *layout) } }); - connectionsManagedLayout[0] = connect(m_managedLayout, &Layout::preferredViewForShortcutsChanged, this, &View::preferredViewForShortcutsChangedSlot); - connectionsManagedLayout[1] = connect(m_managedLayout, &Latte::Layout::configViewCreated, this, &View::configViewCreated); + connectionsManagedLayout[0] = connect(m_managedLayout, &Latte::ActiveLayout::preferredViewForShortcutsChanged, this, &View::preferredViewForShortcutsChangedSlot); + connectionsManagedLayout[1] = connect(m_managedLayout, &Latte::ActiveLayout::configViewCreated, this, &View::configViewCreated); } Latte::Corona *latteCorona = qobject_cast(this->corona()); @@ -807,7 +807,7 @@ void View::setManagedLayout(Layout *layout) } }); - connectionsManagedLayout[3] = connect(m_managedLayout, &Layout::activitiesChanged, this, [&]() { + connectionsManagedLayout[3] = connect(m_managedLayout, &ActiveLayout::activitiesChanged, this, [&]() { if (m_managedLayout) { applyActivitiesToWindows(); emit activitiesChanged(); @@ -858,7 +858,7 @@ void View::moveToLayout(QString layoutName) Latte::Corona *latteCorona = qobject_cast(this->corona()); if (latteCorona && containments.size() > 0) { - Layout *newLayout = latteCorona->layoutManager()->activeLayout(layoutName); + ActiveLayout *newLayout = latteCorona->layoutManager()->activeLayout(layoutName); if (newLayout) { newLayout->assignToLayout(this, containments); diff --git a/app/view/view.h b/app/view/view.h index 767100fe8..9821fd652 100644 --- a/app/view/view.h +++ b/app/view/view.h @@ -29,7 +29,7 @@ #include "windowstracker.h" #include "settings/primaryconfigview.h" #include "../shortcuts/globalshortcuts.h" -#include "../layout/layout.h" +#include "../layout/activelayout.h" #include "../plasma/quick/containmentview.h" #include "../plasma/quick/configview.h" #include "../../liblatte2/types.h" @@ -58,7 +58,7 @@ class PlasmaShellSurface; } namespace Latte { -class Layout; +class ActiveLayout; namespace ViewPart { class ContextMenu; @@ -97,7 +97,7 @@ class View : public PlasmaQuick::ContainmentView Q_PROPERTY(float maxLength READ maxLength WRITE setMaxLength NOTIFY maxLengthChanged) - Q_PROPERTY(Layout *managedLayout READ managedLayout WRITE setManagedLayout NOTIFY managedLayoutChanged) + Q_PROPERTY(Latte::ActiveLayout *managedLayout READ managedLayout WRITE setManagedLayout NOTIFY managedLayoutChanged) Q_PROPERTY(Latte::ViewPart::Effects *effects READ effects NOTIFY effectsChanged) Q_PROPERTY(Latte::ViewPart::Indicator *indicator READ indicator NOTIFY indicatorChanged) Q_PROPERTY(Latte::ViewPart::Positioner *positioner READ positioner NOTIFY positionerChanged) @@ -184,8 +184,8 @@ public: ViewPart::VisibilityManager *visibility() const; ViewPart::WindowsTracker *windowsTracker() const; - Layout *managedLayout() const; - void setManagedLayout(Layout *layout); + Latte::ActiveLayout *managedLayout() const; + void setManagedLayout(Latte::ActiveLayout *layout); KWayland::Client::PlasmaShellSurface *surface(); @@ -304,7 +304,7 @@ private: QRect m_localGeometry; QRect m_absGeometry; - Layout *m_managedLayout{nullptr}; + Latte::ActiveLayout *m_managedLayout{nullptr}; QPointer m_configView; QPointer m_contextMenu;