File indexing completed on 2024-04-14 05:24:41

0001 /*
0002     SPDX-FileCopyrightText: 2020 Michail Vourlakos <mvourlakos@gmail.com>
0003     SPDX-License-Identifier: GPL-2.0-or-later
0004 */
0005 
0006 #ifndef SUBCONFIGVIEW_H
0007 #define SUBCONFIGVIEW_H
0008 
0009 // local
0010 #include <coretypes.h>
0011 #include "../../wm/windowinfowrap.h"
0012 
0013 //Qt
0014 #include <QObject>
0015 #include <QPointer>
0016 #include <QQuickView>
0017 #include <QTimer>
0018 
0019 // Plasma
0020 #include <Plasma/FrameSvg>
0021 
0022 namespace KWayland {
0023 namespace Client {
0024 class PlasmaShellSurface;
0025 }
0026 }
0027 
0028 namespace Latte {
0029 class Corona;
0030 class View;
0031 }
0032 
0033 
0034 namespace Latte {
0035 namespace ViewPart {
0036 
0037 class SubConfigView : public QQuickView
0038 {
0039     Q_OBJECT
0040     Q_PROPERTY(Plasma::FrameSvg::EnabledBorders enabledBorders READ enabledBorders NOTIFY enabledBordersChanged)
0041 
0042 public:
0043     SubConfigView(Latte::View *view, const QString &title, const bool &isNormalWindow = true);
0044     ~SubConfigView() override;
0045 
0046     virtual void requestActivate();
0047 
0048     QString validTitle() const;
0049 
0050     Plasma::FrameSvg::EnabledBorders enabledBorders() const;
0051 
0052     Latte::Corona *corona() const;
0053     Latte::View *parentView() const;
0054     virtual void setParentView(Latte::View *view, const bool &immediate = false);
0055     virtual void showAfter(int msecs = 0);
0056 
0057     Latte::WindowSystem::WindowId trackedWindowId();
0058     KWayland::Client::PlasmaShellSurface *surface();
0059 
0060 public slots:
0061     virtual void syncGeometry() = 0;
0062 
0063 signals:
0064     void enabledBordersChanged();
0065 
0066 protected:
0067     virtual void syncSlideEffect();
0068 
0069     virtual void init();
0070     virtual void initParentView(Latte::View *view);
0071     virtual void updateEnabledBorders() = 0;
0072 
0073     void showEvent(QShowEvent *ev) override;
0074     bool event(QEvent *e) override;
0075 
0076     virtual Qt::WindowFlags wFlags() const;
0077 
0078 protected:
0079     bool m_isNormalWindow{true};
0080     QTimer m_screenSyncTimer;
0081 
0082     QPointer<Latte::View> m_latteView;
0083 
0084     QList<QMetaObject::Connection> connections;
0085     QList<QMetaObject::Connection> viewconnections;
0086 
0087     Plasma::FrameSvg::EnabledBorders m_enabledBorders{Plasma::FrameSvg::AllBorders};
0088 
0089     Latte::Corona *m_corona{nullptr};
0090     KWayland::Client::PlasmaShellSurface *m_shellSurface{nullptr};
0091 
0092 private slots:
0093     void updateWaylandId();
0094 
0095 private:
0096     void setupWaylandIntegration();
0097 
0098 private:
0099     QString m_validTitle;
0100 
0101     QTimer m_showTimer;
0102 
0103     Latte::WindowSystem::WindowId m_waylandWindowId;
0104 };
0105 
0106 }
0107 }
0108 #endif //SUBCONFIGVIEW_H
0109