Warning, file /plasma/latte-dock/app/layouts/manager.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /*
0002     SPDX-FileCopyrightText: 2017 Smith AR <audoban@openmailbox.org>
0003     SPDX-FileCopyrightText: 2017 Michail Vourlakos <mvourlakos@gmail.com>
0004 
0005     SPDX-License-Identifier: GPL-2.0-or-later
0006 */
0007 
0008 #ifndef LAYOUTSMANAGER_H
0009 #define LAYOUTSMANAGER_H
0010 
0011 // local
0012 #include "syncedlaunchers.h"
0013 #include "synchronizer.h"
0014 #include "../apptypes.h"
0015 #include "../data/layoutdata.h"
0016 #include "../data/layouticondata.h"
0017 #include "../settings/settingsdialog/settingsdialog.h"
0018 
0019 // Qt
0020 #include <QAction>
0021 #include <QObject>
0022 #include <QPointer>
0023 
0024 // KDE
0025 #include <KLocalizedString>
0026 
0027 namespace Plasma {
0028 class Containment;
0029 class Types;
0030 }
0031 
0032 namespace Latte {
0033 class Corona;
0034 class CentralLayout;
0035 namespace Layouts {
0036 class Importer;
0037 class SyncedLaunchers;
0038 class Synchronizer;
0039 }
0040 }
0041 
0042 namespace Latte {
0043 namespace Layouts {
0044 
0045 //! Layouts::Manager is a very IMPORTANT class which is responsible to
0046 //! to provide the qml accessible Layouts manipulation API and at the
0047 //! same time to interact with Latte::Corona in order
0048 //! to update correctly the underlying Layouts files by using also
0049 //! its Importer object
0050 //!
0051 //! This class is responsible both for ACTIVE/PASSIVE Layouts.
0052 //!
0053 //! ACTIVE Layout is consider one layout that is loaded and active in memory
0054 //! PASSIVE Layouts is consider one layout that is not loaded/active in memory
0055 //! and its properties are just stored in the filesystem
0056 //!
0057 
0058 class Manager : public QObject
0059 {
0060     Q_OBJECT
0061     Q_PROPERTY(SyncedLaunchers *syncedLaunchers READ syncedLaunchers NOTIFY syncedLaunchersChanged)
0062 
0063 public:
0064     Manager(QObject *parent = nullptr);
0065     ~Manager() override;
0066 
0067     Latte::Corona *corona();
0068     Importer *importer();
0069 
0070     void init();
0071     void loadLayoutOnStartup(QString layoutName);
0072     void setOnAllActivities(QString layoutName);
0073     void setOnActivities(QString layoutName, QStringList activities);
0074     void showInfoWindow(QString info, int duration, QStringList activities = {"0"});
0075     void unload();
0076 
0077     QStringList currentLayoutsNames() const;
0078 
0079     Latte::Data::LayoutIcon iconForLayout(const QString &storedLayoutName) const;
0080     Latte::Data::LayoutIcon iconForLayout(const Data::Layout &layout) const;
0081 
0082     MemoryUsage::LayoutsMemory memoryUsage() const;
0083     void setMemoryUsage(MemoryUsage::LayoutsMemory memoryUsage);
0084 
0085     //! switch to specified layout, default previousMemoryUsage means that it didn't change
0086     bool switchToLayout(QString layoutName,  MemoryUsage::LayoutsMemory newMemoryUsage = MemoryUsage::Current);
0087 
0088     //! returns the current and central layout based on activities and user preferences
0089     QList<CentralLayout *>currentLayouts() const;
0090     SyncedLaunchers *syncedLaunchers() const;
0091     Synchronizer *synchronizer() const;
0092 
0093     void moveView(QString originLayoutName, uint originViewId, QString destinationLayoutName);
0094 
0095 public slots:
0096     void showAboutDialog();
0097 
0098     void hideLatteSettingsDialog();
0099     Q_INVOKABLE void showLatteSettingsDialog(int firstPage = Settings::Dialog::LayoutPage, bool toggleCurrentPage = false);
0100     Q_INVOKABLE QStringList centralLayoutsNames();
0101     Q_INVOKABLE QStringList viewTemplateNames() const;
0102     Q_INVOKABLE QStringList viewTemplateIds() const;
0103 
0104 signals:
0105     void centralLayoutsChanged();
0106     void syncedLaunchersChanged();
0107     void viewTemplatesChanged();
0108 
0109     void currentLayoutIsSwitching(QString layoutName);
0110 
0111     //! used from ConfigView(s) in order to be informed which is one should be shown
0112     void lastConfigViewChangedFrom(Latte::View *view);
0113 
0114 private:
0115     void cleanupOnStartup(QString path); //!remove deprecated or oldstyle config options
0116     void clearUnloadedContainmentsFromLinkedFile(QStringList containmentsIds, bool bypassChecks = false);
0117 
0118     void loadLatteLayout(QString layoutPath);
0119 
0120     void setMenuLayouts(QStringList layouts);
0121 
0122 private:
0123     QPointer<Latte::Settings::Dialog::SettingsDialog> m_latteSettingsDialog;
0124 
0125     Latte::Corona *m_corona{nullptr};
0126     Importer *m_importer{nullptr};
0127     SyncedLaunchers *m_syncedLaunchers{nullptr};
0128     Synchronizer *m_synchronizer{nullptr};
0129 
0130     friend class Latte::Settings::Dialog::SettingsDialog;
0131     friend class Synchronizer;
0132 };
0133 
0134 }
0135 }
0136 
0137 #endif // LAYOUTSMANAGER_H