File indexing completed on 2024-12-01 13:37:58

0001 /*
0002 *  Copyright 2018  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 SECONDARYCONFIGVIEW_H
0021 #define SECONDARYCONFIGVIEW_H
0022 
0023 // local
0024 #include "../../wm/windowinfowrap.h"
0025 #include "../../../liblatte2/types.h"
0026 
0027 //Qt
0028 #include <QObject>
0029 #include <QQuickView>
0030 #include <QPointer>
0031 #include <QTimer>
0032 
0033 // Plasma
0034 #include <plasma/package.h>
0035 #include <Plasma/FrameSvg>
0036 
0037 namespace Plasma {
0038 class Applet;
0039 class Containment;
0040 class FrameSvg;
0041 class Types;
0042 }
0043 
0044 namespace KWayland {
0045 namespace Client {
0046 class PlasmaShellSurface;
0047 }
0048 }
0049 
0050 namespace Latte {
0051 class Corona;
0052 class View;
0053 }
0054 
0055 namespace Latte {
0056 namespace ViewPart {
0057 class PrimaryConfigView;
0058 }
0059 }
0060 
0061 namespace Latte {
0062 namespace ViewPart {
0063 
0064 class SecondaryConfigView : public QQuickView
0065 {
0066     Q_OBJECT
0067 
0068     Q_PROPERTY(Plasma::FrameSvg::EnabledBorders enabledBorders READ enabledBorders NOTIFY enabledBordersChanged)
0069 
0070 public:
0071     SecondaryConfigView(Latte::View *view, QWindow *parent);
0072     ~SecondaryConfigView() override;
0073 
0074     void init();
0075     void requestActivate();
0076     Qt::WindowFlags wFlags() const;
0077 
0078     QRect geometryWhenVisible() const;
0079 
0080     Plasma::FrameSvg::EnabledBorders enabledBorders() const;
0081 
0082 public slots:
0083     Q_INVOKABLE void hideConfigWindow();
0084     Q_INVOKABLE void syncGeometry();
0085     Q_INVOKABLE void updateEffects();
0086 
0087 signals:
0088     void enabledBordersChanged();
0089     void showSignal();
0090 
0091 protected:
0092     void showEvent(QShowEvent *ev) override;
0093     void focusOutEvent(QFocusEvent *ev) override;
0094     bool event(QEvent *e) override;
0095 
0096     void syncSlideEffect();
0097 
0098 private slots:
0099     void updateEnabledBorders();
0100 
0101 private:
0102     void setupWaylandIntegration();
0103 
0104     QRect m_geometryWhenVisible;
0105 
0106     QPointer<Latte::View> m_latteView;
0107     QPointer<PrimaryConfigView> m_parent;
0108     QTimer m_screenSyncTimer;
0109     QTimer m_thicknessSyncTimer;
0110     QList<QMetaObject::Connection> connections;
0111 
0112     Plasma::FrameSvg::EnabledBorders m_enabledBorders{Plasma::FrameSvg::AllBorders};
0113     //only for the mask on disabled compositing, not to actually paint
0114     Plasma::FrameSvg *m_background{nullptr};
0115 
0116     Latte::Corona *m_corona{nullptr};
0117     Latte::WindowSystem::WindowId m_waylandWindowId;
0118     KWayland::Client::PlasmaShellSurface *m_shellSurface{nullptr};
0119 };
0120 
0121 }
0122 }
0123 #endif //SECONDARYCONFIGVIEW_H
0124