File indexing completed on 2024-06-16 05:07:09

0001 /*
0002     SPDX-FileCopyrightText: 2016 Smith AR <audoban@openmailbox.org>
0003     SPDX-FileCopyrightText: 2016 Michail Vourlakos <mvourlakos@gmail.com>
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #ifndef PRIMARYCONFIGVIEW_H
0008 #define PRIMARYCONFIGVIEW_H
0009 
0010 // local
0011 #include <coretypes.h>
0012 #include "subconfigview.h"
0013 #include "../../wm/windowinfowrap.h"
0014 
0015 //Qt
0016 #include <QObject>
0017 #include <QPointer>
0018 #include <QQuickView>
0019 #include <QTimer>
0020 #include <QWindow>
0021 
0022 // Plasma
0023 #include <plasma/package.h>
0024 #include <Plasma/FrameSvg>
0025 
0026 namespace Plasma {
0027 class Applet;
0028 class Containment;
0029 class FrameSvg;
0030 class Types;
0031 }
0032 
0033 namespace KWayland {
0034 namespace Client {
0035 class PlasmaShellSurface;
0036 }
0037 }
0038 
0039 namespace Latte {
0040 class Corona;
0041 class View;
0042 }
0043 
0044 namespace Latte {
0045 namespace ViewPart {
0046 class CanvasConfigView;
0047 class SecondaryConfigView;
0048 
0049 namespace Config{
0050 class IndicatorUiManager;
0051 }
0052 }
0053 }
0054 
0055 namespace Latte {
0056 namespace ViewPart {
0057 
0058 class PrimaryConfigView : public SubConfigView
0059 {
0060     Q_OBJECT
0061     //! used when the secondary config window can not be shown
0062     Q_PROPERTY(bool showInlineProperties READ showInlineProperties NOTIFY showInlinePropertiesChanged)
0063     Q_PROPERTY(bool isReady READ isReady NOTIFY isReadyChanged)
0064 
0065     Q_PROPERTY(int x READ x NOTIFY xChanged)
0066     Q_PROPERTY(int y READ y NOTIFY yChanged)
0067 
0068     Q_PROPERTY(QRect availableScreenGeometry READ availableScreenGeometry NOTIFY availableScreenGeometryChanged)
0069 
0070     Q_PROPERTY(Latte::ViewPart::Config::IndicatorUiManager *indicatorUiManager READ indicatorUiManager NOTIFY indicatorUiManagerChanged)
0071 
0072 public:
0073     enum ConfigViewType
0074     {
0075         PrimaryConfig = 0,
0076         SecondaryConfig
0077     };
0078 
0079     PrimaryConfigView(Latte::View *view);
0080     ~PrimaryConfigView() override;
0081 
0082     bool hasFocus() const;
0083 
0084     bool isReady() const;
0085 
0086     bool showInlineProperties() const;
0087     bool sticker() const;
0088 
0089     QRect availableScreenGeometry() const;
0090     QRect geometryWhenVisible() const;
0091 
0092     Config::IndicatorUiManager *indicatorUiManager();
0093 
0094     void setParentView(Latte::View *view, const bool &immediate = false) override;
0095     void setOnActivities(QStringList activities);
0096 
0097     void showConfigWindow();
0098 
0099     void requestActivate() override;
0100 
0101 public slots:
0102     Q_INVOKABLE void syncGeometry() override;
0103     Q_INVOKABLE void hideConfigWindow();
0104     Q_INVOKABLE void setSticker(bool blockFocusLost);    
0105     Q_INVOKABLE void updateEffects();
0106 
0107 signals:
0108     void availableScreenGeometryChanged();
0109     void indicatorUiManagerChanged();
0110     void isReadyChanged();
0111     void raiseDocksTemporaryChanged();
0112     void showInlinePropertiesChanged();
0113     void showSignal();
0114     void xChanged();
0115     void yChanged();
0116 
0117 protected:
0118     void showEvent(QShowEvent *ev) override;
0119     void hideEvent(QHideEvent *ev) override;
0120     void focusOutEvent(QFocusEvent *ev) override;
0121 
0122     void init() override;
0123     void initParentView(Latte::View *view) override;
0124     void updateEnabledBorders() override;
0125 
0126 private slots:
0127     void immutabilityChanged(Plasma::Types::ImmutabilityType type);
0128     void updateAvailableScreenGeometry(View *origin = nullptr);
0129     void updateShowInlineProperties();
0130 
0131     void showSecondaryWindow();
0132     void hideSecondaryWindow();
0133 
0134     void showCanvasWindow();
0135     void hideCanvasWindow();
0136 
0137     void setShowInlineProperties(bool show);
0138 
0139 
0140 private:
0141     void setIsReady(bool ready);
0142     void instantUpdateAvailableScreenGeometry();
0143 
0144     bool inAdvancedMode() const;
0145 
0146 private:
0147     bool m_blockFocusLost{false};
0148     bool m_blockFocusLostOnStartup{true};
0149     bool m_originalByPassWM{false};
0150     bool m_inReverse{false};    //! it is used by the borders
0151     bool m_isReady{false};
0152     bool m_showInlineProperties{false};
0153 
0154     Latte::Types::Visibility m_originalMode{Latte::Types::DodgeActive};
0155 
0156     QTimer m_availableScreemGeometryTimer;
0157 
0158     QRect m_availableScreenGeometry;
0159     QRect m_geometryWhenVisible;
0160 
0161     QPointer<SecondaryConfigView> m_secConfigView;
0162     QPointer<CanvasConfigView> m_canvasConfigView;
0163 
0164     Config::IndicatorUiManager *m_indicatorUiManager{nullptr};
0165 
0166     //only for the mask on disabled compositing, not to actually paint
0167     Plasma::FrameSvg *m_background{nullptr};
0168 };
0169 
0170 }
0171 }
0172 #endif //PRIMARYCONFIGVIEW_H
0173