/* * Copyright 2020 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 LAYOUTSSTORAGE_H #define LAYOUTSSTORAGE_H // local #include "../data/appletdata.h" // Qt #include // KDE #include // Plasma #include #include namespace Latte { namespace Layout { class GenericLayout; struct ViewData; } } namespace Latte { namespace Layouts { struct SubContaimentIdentityData { QString cfgGroup; QString cfgProperty; }; struct ViewDelayedCreationData { Plasma::Containment *containment{nullptr}; bool forceOnPrimary{false}; int explicitScreen{-1}; bool reactToScreenChange{false}; }; class Storage { public: static Storage *self(); ~Storage(); static const int IDNULL; static const int IDBASE; bool isWritable(const Layout::GenericLayout *layout) const; bool isLatteContainment(Plasma::Containment *containment) const; bool isLatteContainment(const KConfigGroup &group) const; bool isBroken(const Layout::GenericLayout *layout, QStringList &errors) const; bool isSubContainment(const Layout::GenericLayout *layout, const Plasma::Applet *applet) const; int subContainmentId(const KConfigGroup &appletGroup) const; Plasma::Containment *subContainmentOf(const Layout::GenericLayout *layout, const Plasma::Applet *applet); void lock(const Layout::GenericLayout *layout); //! make it only read-only void unlock(const Layout::GenericLayout *layout); //! make it writable which it should be the default void importToCorona(const Layout::GenericLayout *layout); void syncToLayoutFile(const Layout::GenericLayout *layout, bool removeLayoutId); ViewDelayedCreationData copyView(const Layout::GenericLayout *layout, Plasma::Containment *containment); /// STATIC //! Check if an applet config group is valid or belongs to removed applet static bool appletGroupIsValid(const KConfigGroup &appletGroup); static bool isValid(const int &id); //! AppletsData Information Data::Applet metadata(const QString &pluginId); Data::AppletsTable plugins(const Layout::GenericLayout *layout, const int containmentid = IDNULL); Data::AppletsTable plugins(const QString &layoutfile, const int containmentid = IDNULL); //! Functions used from Layout Reports //! [containment id, list], list, list[subcontainment ids] void subContainmentsInfo(const QString &file, QHash> &subContainments, QList &assignedSubContainments, QList &orphanSubContainments); //! list QList viewsScreens(const QString &file); //! list QList viewsData(const QString &file, const QHash> &subContainments); private: Storage(); bool isSubContainment(const KConfigGroup &appletGroup) const; int subIdentityIndex(const KConfigGroup &appletGroup) const; //! STORAGE !//// QString availableId(QStringList all, QStringList assigned, int base); //! provides a new file path based the provided file. The new file //! has updated ids for containments and applets based on the corona //! loaded ones QString newUniqueIdsLayoutFromFile(const Layout::GenericLayout *layout, QString file); //! imports a layout file and returns the containments for the docks QList importLayoutFile(const Layout::GenericLayout *layout, QString file); private: QTemporaryDir m_storageTmpDir; QList m_subIdentities; }; } } #endif