Changeset View
Changeset View
Standalone View
Standalone View
applets/panelspacer/plugin/panelspacer.h
- This file was added.
1 | /*************************************************************************** | ||||
---|---|---|---|---|---|
2 | * Copyright (C) 2020 Marco Martin <mart@kde.org> * | ||||
3 | * | ||||
4 | * * | ||||
5 | * This program is free software; you can redistribute it and/or modify * | ||||
6 | * it under the terms of the GNU General Public License as published by * | ||||
7 | * the Free Software Foundation; either version 2 of the License, or * | ||||
8 | * (at your option) any later version. * | ||||
9 | * * | ||||
10 | * This program is distributed in the hope that it will be useful, * | ||||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * | ||||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | ||||
13 | * GNU General Public License for more details. * | ||||
14 | * * | ||||
15 | * You should have received a copy of the GNU General Public License * | ||||
16 | * along with this program; if not, write to the * | ||||
17 | * Free Software Foundation, Inc., * | ||||
18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * | ||||
19 | ***************************************************************************/ | ||||
20 | | ||||
21 | #pragma once | ||||
22 | | ||||
23 | | ||||
24 | #include <Plasma/Applet> | ||||
25 | | ||||
26 | namespace PlasmaQuick { | ||||
27 | class AppletQuickItem; | ||||
28 | } | ||||
29 | | ||||
30 | namespace Plasma { | ||||
31 | class Containment; | ||||
32 | } | ||||
33 | | ||||
34 | class PanelSpacer; | ||||
35 | | ||||
36 | class SpacersTracker : public QObject | ||||
37 | { | ||||
38 | Q_OBJECT | ||||
39 | | ||||
40 | public: | ||||
41 | SpacersTracker( QObject *parent = nullptr ); | ||||
42 | ~SpacersTracker() override; | ||||
43 | | ||||
44 | static SpacersTracker *self(); | ||||
45 | | ||||
46 | void insertSpacer(Plasma::Containment *containment, PanelSpacer *spacer); | ||||
47 | void removeSpacer(Plasma::Containment *containment, PanelSpacer *spacer); | ||||
48 | | ||||
49 | private: | ||||
50 | QHash<Plasma::Containment *, QList<PanelSpacer *> > m_spacers; | ||||
51 | }; | ||||
52 | | ||||
53 | class PanelSpacer : public Plasma::Applet | ||||
54 | { | ||||
55 | Q_OBJECT | ||||
56 | Q_PROPERTY(PlasmaQuick::AppletQuickItem *twinSpacer READ twinSpacer NOTIFY twinSpacerChanged) | ||||
57 | Q_PROPERTY(PlasmaQuick::AppletQuickItem *containment READ containmentGraphicObject CONSTANT) | ||||
58 | | ||||
59 | public: | ||||
60 | PanelSpacer( QObject *parent, const QVariantList &args ); | ||||
61 | ~PanelSpacer() override; | ||||
62 | | ||||
63 | void init() override; | ||||
64 | void constraintsEvent(Plasma::Types::Constraints constraints) override; | ||||
65 | | ||||
66 | void setTwinSpacer(PlasmaQuick::AppletQuickItem *spacer); | ||||
67 | PlasmaQuick::AppletQuickItem *twinSpacer() const; | ||||
68 | | ||||
69 | PlasmaQuick::AppletQuickItem *containmentGraphicObject() const; | ||||
70 | | ||||
71 | Q_SIGNALS: | ||||
72 | void twinSpacerChanged(); | ||||
73 | | ||||
74 | private: | ||||
75 | PlasmaQuick::AppletQuickItem *m_twinSpacer; | ||||
76 | }; | ||||
77 | | ||||
78 | |