File indexing completed on 2024-04-14 15:37:13

0001 /*
0002 *  Copyright 2019  Michail Vourlakos <mvourlakos@gmail.com>
0003 *
0004 *  This file is part of Latte-Dock
0005 *
0006 *  Latte-Dock is free software; you can redistribute it and/or
0007 *  modify it under the terms of the GNU General Public License as
0008 *  published by the Free Software Foundation; either version 2 of
0009 *  the License, or (at your option) any later version.
0010 *
0011 *  Latte-Dock is distributed in the hope that it will be useful,
0012 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
0013 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0014 *  GNU General Public License for more details.
0015 *
0016 *  You should have received a copy of the GNU General Public License
0017 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
0018 */
0019 
0020 #ifndef SHAREDLAYOUT_H
0021 #define SHAREDLAYOUT_H
0022 
0023 // local
0024 #include "genericlayout.h"
0025 
0026 // Qt
0027 #include <QObject>
0028 
0029 namespace Latte {
0030 class CentralLayout;
0031 }
0032 
0033 
0034 namespace Latte {
0035 
0036 //! SharedLayout is a layout that exists only as long as it belongs to one or
0037 //! more CentralLayout(s). It is a layer above a central or more layouts and can
0038 //! be used from CentralLayouts to share Latte:View(s) . Much of its functionality
0039 //! is provided by the CentralLayouts it belongs to. For example the activities
0040 //! that its views should be shown is identified only from the central layouts
0041 //! it belongs to
0042 
0043 class SharedLayout : public Layout::GenericLayout
0044 {
0045     Q_OBJECT
0046 
0047 public:
0048     SharedLayout(CentralLayout *assigned, QObject *parent, QString layoutFile, QString layoutName = QString());
0049     ~SharedLayout() override;
0050 
0051     const QStringList appliedActivities();
0052     CentralLayout *currentCentralLayout() const;
0053 
0054     //! OVERRIDE GeneralLayout implementations
0055     bool isCurrent() const override;
0056 
0057     int viewsCount(int screen) const override;
0058     int viewsCount(QScreen *screen) const override;
0059     int viewsCount() const override;
0060 
0061     Layout::Type type() const override;
0062 
0063     void setLastConfigViewFor(Latte::View *view) override;
0064     Latte::View *lastConfigViewFor() override;
0065 
0066     //! Available edges for specific view in that screen
0067     QList<Plasma::Types::Location> availableEdgesForView(QScreen *scr, Latte::View *forView) const override;
0068     //! All free edges in that screen
0069     QList<Plasma::Types::Location> freeEdges(QScreen *scr) const override;
0070     QList<Plasma::Types::Location> freeEdges(int screen) const override;
0071 
0072     QList<Latte::View *> sortedLatteViews(QList<Latte::View *> views = QList<Latte::View *>()) override;
0073 
0074 public slots:
0075     void addCentralLayout(CentralLayout *layout);
0076     void removeCentralLayout(CentralLayout *layout);
0077 
0078 signals:
0079     void layoutDestroyed(SharedLayout *layout);
0080 
0081 private slots:
0082     void updateLastUsedCentralLayout();
0083 
0084 private:
0085     QString m_lastUsedCentralLayout;
0086 
0087     QList<CentralLayout *> m_centralLayouts;
0088 
0089 };
0090 
0091 }
0092 
0093 #endif //SHAREDLAYOUT_H