1 /* 2 SPDX-FileCopyrightText: 2016 Smith AR <audoban@openmailbox.org> 3 SPDX-FileCopyrightText: 2016 Michail Vourlakos <mvourlakos@gmail.com> 4 SPDX-License-Identifier: GPL-2.0-or-later 5 */ 6 7 #ifndef PRIMARYCONFIGVIEW_H 8 #define PRIMARYCONFIGVIEW_H 9 10 // local 11 #include <coretypes.h> 12 #include "subconfigview.h" 13 #include "../../wm/windowinfowrap.h" 14 15 //Qt 16 #include <QObject> 17 #include <QPointer> 18 #include <QQuickView> 19 #include <QTimer> 20 #include <QWindow> 21 22 // Plasma 23 #include <plasma/package.h> 24 #include <Plasma/FrameSvg> 25 26 namespace Plasma { 27 class Applet; 28 class Containment; 29 class FrameSvg; 30 class Types; 31 } 32 33 namespace KWayland { 34 namespace Client { 35 class PlasmaShellSurface; 36 } 37 } 38 39 namespace Latte { 40 class Corona; 41 class View; 42 } 43 44 namespace Latte { 45 namespace ViewPart { 46 class CanvasConfigView; 47 class SecondaryConfigView; 48 49 namespace Config{ 50 class IndicatorUiManager; 51 } 52 } 53 } 54 55 namespace Latte { 56 namespace ViewPart { 57 58 class PrimaryConfigView : public SubConfigView 59 { 60 Q_OBJECT 61 //! used when the secondary config window can not be shown 62 Q_PROPERTY(bool showInlineProperties READ showInlineProperties NOTIFY showInlinePropertiesChanged) 63 Q_PROPERTY(bool isReady READ isReady NOTIFY isReadyChanged) 64 65 Q_PROPERTY(int x READ x NOTIFY xChanged) 66 Q_PROPERTY(int y READ y NOTIFY yChanged) 67 68 Q_PROPERTY(QRect availableScreenGeometry READ availableScreenGeometry NOTIFY availableScreenGeometryChanged) 69 70 Q_PROPERTY(Latte::ViewPart::Config::IndicatorUiManager *indicatorUiManager READ indicatorUiManager NOTIFY indicatorUiManagerChanged) 71 72 public: 73 enum ConfigViewType 74 { 75 PrimaryConfig = 0, 76 SecondaryConfig 77 }; 78 79 PrimaryConfigView(Latte::View *view); 80 ~PrimaryConfigView() override; 81 82 bool hasFocus() const; 83 84 bool isReady() const; 85 86 bool showInlineProperties() const; 87 bool sticker() const; 88 89 QRect availableScreenGeometry() const; 90 QRect geometryWhenVisible() const; 91 92 Config::IndicatorUiManager *indicatorUiManager(); 93 94 void setParentView(Latte::View *view, const bool &immediate = false) override; 95 void setOnActivities(QStringList activities); 96 97 void showConfigWindow(); 98 99 void requestActivate() override; 100 101 public slots: 102 Q_INVOKABLE void syncGeometry() override; 103 Q_INVOKABLE void hideConfigWindow(); 104 Q_INVOKABLE void setSticker(bool blockFocusLost); 105 Q_INVOKABLE void updateEffects(); 106 107 signals: 108 void availableScreenGeometryChanged(); 109 void indicatorUiManagerChanged(); 110 void isReadyChanged(); 111 void raiseDocksTemporaryChanged(); 112 void showInlinePropertiesChanged(); 113 void showSignal(); 114 void xChanged(); 115 void yChanged(); 116 117 protected: 118 void showEvent(QShowEvent *ev) override; 119 void hideEvent(QHideEvent *ev) override; 120 void focusOutEvent(QFocusEvent *ev) override; 121 122 void init() override; 123 void initParentView(Latte::View *view) override; 124 void updateEnabledBorders() override; 125 126 private slots: 127 void immutabilityChanged(Plasma::Types::ImmutabilityType type); 128 void updateAvailableScreenGeometry(View *origin = nullptr); 129 void updateShowInlineProperties(); 130 131 void showSecondaryWindow(); 132 void hideSecondaryWindow(); 133 134 void showCanvasWindow(); 135 void hideCanvasWindow(); 136 137 void setShowInlineProperties(bool show); 138 139 140 private: 141 void setIsReady(bool ready); 142 void instantUpdateAvailableScreenGeometry(); 143 144 bool inAdvancedMode() const; 145 146 private: 147 bool m_blockFocusLost{false}; 148 bool m_blockFocusLostOnStartup{true}; 149 bool m_originalByPassWM{false}; 150 bool m_inReverse{false}; //! it is used by the borders 151 bool m_isReady{false}; 152 bool m_showInlineProperties{false}; 153 154 Latte::Types::Visibility m_originalMode{Latte::Types::DodgeActive}; 155 156 QTimer m_availableScreemGeometryTimer; 157 158 QRect m_availableScreenGeometry; 159 QRect m_geometryWhenVisible; 160 161 QPointer<SecondaryConfigView> m_secConfigView; 162 QPointer<CanvasConfigView> m_canvasConfigView; 163 164 Config::IndicatorUiManager *m_indicatorUiManager{nullptr}; 165 166 //only for the mask on disabled compositing, not to actually paint 167 Plasma::FrameSvg *m_background{nullptr}; 168 }; 169 170 } 171 } 172 #endif //PRIMARYCONFIGVIEW_H 173 174