2016-12-25 09:25:27 +02:00
/*
2017-01-02 17:05:30 -05:00
* Copyright 2016 Smith AR < audoban @ openmailbox . org >
* Michail Vourlakos < mvourlakos @ gmail . com >
*
* This file is part of Latte - Dock
*
* Latte - Dock is free software ; you can redistribute it and / or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation ; either version 2 of
* the License , or ( at your option ) any later version .
*
* Latte - Dock is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
* along with this program . If not , see < http : //www.gnu.org/licenses/>.
*/
2016-12-25 09:25:27 +02:00
2018-12-06 12:15:58 +02:00
# ifndef VIEW_H
# define VIEW_H
2016-12-25 09:25:27 +02:00
2018-12-02 02:05:52 +02:00
// local
2018-11-30 21:33:46 +02:00
# include "effects.h"
2018-12-01 00:13:11 +02:00
# include "positioner.h"
2018-02-03 11:34:13 +02:00
# include "visibilitymanager.h"
2019-02-07 19:15:25 +02:00
# include "windowstracker.h"
2018-12-09 00:06:14 +02:00
# include "settings/primaryconfigview.h"
2019-02-06 18:15:59 +02:00
# include "../shortcuts/globalshortcuts.h"
2019-01-22 18:17:55 +02:00
# include "../layout/layout.h"
2018-12-13 19:51:22 +02:00
# include "../plasma/quick/containmentview.h"
# include "../plasma/quick/configview.h"
2018-12-07 18:55:35 +02:00
# include "../../liblatte2/types.h"
2016-12-25 09:25:27 +02:00
2018-12-02 02:05:52 +02:00
// C++
2018-08-01 13:38:16 +02:00
# include <array>
2018-12-02 02:05:52 +02:00
// Qt
2016-12-25 09:25:27 +02:00
# include <QQuickView>
2017-01-03 15:33:30 +02:00
# include <QMenu>
2017-06-11 18:06:03 +03:00
# include <QMimeData>
2016-12-25 09:25:27 +02:00
# include <QScreen>
# include <QPointer>
# include <QTimer>
namespace Plasma {
class Types ;
class Corona ;
class Containment ;
}
2017-04-25 19:18:49 +03:00
namespace KWayland {
namespace Client {
class PlasmaShellSurface ;
}
}
2016-12-30 02:20:06 -05:00
namespace Latte {
2018-01-10 22:55:19 +02:00
class Layout ;
2018-12-02 00:53:40 +02:00
2018-12-06 11:37:14 +02:00
namespace ViewPart {
2018-12-02 00:53:40 +02:00
class ContextMenu ;
}
2018-02-03 11:34:13 +02:00
}
namespace Latte {
2018-01-10 22:55:19 +02:00
2018-12-06 12:15:58 +02:00
class View : public PlasmaQuick : : ContainmentView
2018-07-03 22:15:45 +03:00
{
2016-12-25 09:25:27 +02:00
Q_OBJECT
2019-02-11 16:49:10 +02:00
Q_PROPERTY ( Latte : : Types : : ViewType type READ type WRITE setType NOTIFY typeChanged )
2017-08-09 03:33:03 +03:00
Q_PROPERTY ( bool alternativesIsShown READ alternativesIsShown NOTIFY alternativesIsShownChanged )
2017-05-07 15:06:29 +03:00
Q_PROPERTY ( bool behaveAsPlasmaPanel READ behaveAsPlasmaPanel WRITE setBehaveAsPlasmaPanel NOTIFY behaveAsPlasmaPanelChanged )
2018-12-06 15:34:04 +02:00
Q_PROPERTY ( bool byPassWM READ byPassWM WRITE setByPassWM NOTIFY byPassWMChanged )
2017-07-27 18:24:31 +03:00
Q_PROPERTY ( bool contextMenuIsShown READ contextMenuIsShown NOTIFY contextMenuIsShownChanged )
2018-02-12 16:11:33 +02:00
//! Because Latte uses animations, changing to edit mode it may be different than
//! when the isUserConfiguring changes value
Q_PROPERTY ( bool inEditMode READ inEditMode WRITE setInEditMode NOTIFY inEditModeChanged )
2018-09-22 20:21:57 +03:00
Q_PROPERTY ( bool isPreferredForShortcuts READ isPreferredForShortcuts WRITE setIsPreferredForShortcuts NOTIFY isPreferredForShortcutsChanged )
2017-02-27 00:53:27 +02:00
Q_PROPERTY ( bool onPrimary READ onPrimary WRITE setOnPrimary NOTIFY onPrimaryChanged )
2017-01-16 14:07:49 -05:00
2017-02-04 16:41:12 +02:00
Q_PROPERTY ( int alignment READ alignment WRITE setAlignment NOTIFY alignmentChanged )
2018-02-17 19:02:06 +02:00
Q_PROPERTY ( int fontPixelSize READ fontPixelSize WRITE setFontPixelSize NOTIFY fontPixelSizeChanged )
2017-02-26 15:49:50 +02:00
Q_PROPERTY ( int x READ x NOTIFY xChanged )
Q_PROPERTY ( int y READ y NOTIFY yChanged )
2017-01-12 18:54:23 -05:00
Q_PROPERTY ( int width READ width NOTIFY widthChanged )
2016-12-25 09:25:27 +02:00
Q_PROPERTY ( int height READ height NOTIFY heightChanged )
2019-03-06 20:10:36 +02:00
Q_PROPERTY ( int editThickness READ editThickness WRITE setEditThickness NOTIFY editThicknessChanged )
2016-12-25 09:25:27 +02:00
Q_PROPERTY ( int maxThickness READ maxThickness WRITE setMaxThickness NOTIFY maxThicknessChanged )
2017-01-27 20:31:41 +02:00
Q_PROPERTY ( int normalThickness READ normalThickness WRITE setNormalThickness NOTIFY normalThicknessChanged )
2017-04-09 01:06:48 +03:00
Q_PROPERTY ( int offset READ offset WRITE setOffset NOTIFY offsetChanged )
2017-01-16 14:07:49 -05:00
2017-01-31 21:25:00 +02:00
Q_PROPERTY ( float maxLength READ maxLength WRITE setMaxLength NOTIFY maxLengthChanged )
2018-12-06 11:37:14 +02:00
Q_PROPERTY ( Latte : : ViewPart : : Effects * effects READ effects NOTIFY effectsChanged )
2018-01-10 22:55:19 +02:00
Q_PROPERTY ( Layout * managedLayout READ managedLayout WRITE setManagedLayout NOTIFY managedLayoutChanged )
2018-12-06 11:37:14 +02:00
Q_PROPERTY ( Latte : : ViewPart : : Positioner * positioner READ positioner NOTIFY positionerChanged )
2018-12-09 00:29:35 +02:00
Q_PROPERTY ( Latte : : ViewPart : : VisibilityManager * visibility READ visibility NOTIFY visibilityChanged )
2019-02-07 19:15:25 +02:00
Q_PROPERTY ( Latte : : ViewPart : : WindowsTracker * windowsTracker READ windowsTracker NOTIFY windowsTrackerChanged )
2018-11-30 21:33:46 +02:00
2018-04-01 01:04:23 +03:00
Q_PROPERTY ( QRect absoluteGeometry READ absGeometry NOTIFY absGeometryChanged )
2017-03-09 15:49:24 +02:00
Q_PROPERTY ( QRect localGeometry READ localGeometry WRITE setLocalGeometry NOTIFY localGeometryChanged )
2017-02-26 15:49:50 +02:00
Q_PROPERTY ( QRect screenGeometry READ screenGeometry NOTIFY screenGeometryChanged )
2016-12-25 09:25:27 +02:00
public :
2018-12-06 15:34:04 +02:00
View ( Plasma : : Corona * corona , QScreen * targetScreen = nullptr , bool byPassWM = false ) ;
2018-12-06 12:15:58 +02:00
virtual ~ View ( ) ;
2017-01-16 14:07:49 -05:00
2016-12-25 09:25:27 +02:00
void init ( ) ;
2017-01-16 14:07:49 -05:00
2019-02-11 16:49:10 +02:00
Types : : ViewType type ( ) const ;
void setType ( Types : : ViewType type ) ;
2017-08-09 03:33:03 +03:00
bool alternativesIsShown ( ) const ;
void setAlternativesIsShown ( bool show ) ;
2018-11-29 21:30:00 +02:00
bool inDelete ( ) const ;
2017-02-27 00:53:27 +02:00
bool onPrimary ( ) const ;
void setOnPrimary ( bool flag ) ;
2017-01-12 18:54:23 -05:00
int currentThickness ( ) const ;
2017-01-16 14:07:49 -05:00
2017-05-07 15:06:29 +03:00
bool behaveAsPlasmaPanel ( ) const ;
void setBehaveAsPlasmaPanel ( bool behavior ) ;
2019-03-08 16:14:34 +02:00
bool containsMouse ( ) const ;
2017-07-27 18:24:31 +03:00
bool contextMenuIsShown ( ) const ;
2018-12-06 15:34:04 +02:00
bool byPassWM ( ) const ;
void setByPassWM ( bool bypass ) ;
2017-03-18 23:32:27 +02:00
2018-02-12 16:11:33 +02:00
bool inEditMode ( ) const ;
void setInEditMode ( bool edit ) ;
2018-09-22 20:21:57 +03:00
bool isPreferredForShortcuts ( ) const ;
void setIsPreferredForShortcuts ( bool preferred ) ;
2017-01-31 21:25:00 +02:00
float maxLength ( ) const ;
void setMaxLength ( float length ) ;
2018-02-17 19:02:06 +02:00
int fontPixelSize ( ) const ;
void setFontPixelSize ( int size ) ;
2019-03-06 20:10:36 +02:00
int editThickness ( ) const ;
void setEditThickness ( int thickness ) ;
2017-01-12 18:54:23 -05:00
int maxThickness ( ) const ;
void setMaxThickness ( int thickness ) ;
2017-01-16 14:07:49 -05:00
2017-01-27 20:31:41 +02:00
int normalThickness ( ) const ;
void setNormalThickness ( int thickness ) ;
2017-04-09 01:06:48 +03:00
int offset ( ) const ;
void setOffset ( int offset ) ;
2017-02-04 16:41:12 +02:00
int alignment ( ) const ;
void setAlignment ( int alignment ) ;
2017-03-17 16:58:57 +02:00
QRect absGeometry ( ) const ;
2017-02-26 15:49:50 +02:00
QRect screenGeometry ( ) const ;
2017-03-09 15:49:24 +02:00
QRect localGeometry ( ) const ;
void setLocalGeometry ( const QRect & geometry ) ;
2018-02-09 19:22:04 +02:00
bool settingsWindowIsShown ( ) ;
2017-11-19 14:51:15 +02:00
void showSettingsWindow ( ) ;
2019-03-08 23:43:08 +02:00
PlasmaQuick : : ConfigView * configView ( ) ;
2018-12-06 11:37:14 +02:00
ViewPart : : Effects * effects ( ) const ;
ViewPart : : Positioner * positioner ( ) const ;
2018-12-09 00:29:35 +02:00
ViewPart : : VisibilityManager * visibility ( ) const ;
2019-02-07 19:15:25 +02:00
ViewPart : : WindowsTracker * windowsTracker ( ) const ;
2017-01-16 14:07:49 -05:00
2018-01-10 22:55:19 +02:00
Layout * managedLayout ( ) const ;
void setManagedLayout ( Layout * layout ) ;
2018-03-28 20:39:52 +03:00
KWayland : : Client : : PlasmaShellSurface * surface ( ) ;
2018-11-29 21:30:00 +02:00
void reconsiderScreen ( ) ;
2017-01-16 14:07:49 -05:00
2018-01-11 21:11:46 +02:00
//! these are signals that create crashes, such a example is the availableScreenRectChanged from corona
//! when its containment is destroyed
void disconnectSensitiveSignals ( ) ;
2016-12-25 09:25:27 +02:00
public slots :
2018-12-06 15:57:20 +02:00
Q_INVOKABLE void copyView ( ) ;
Q_INVOKABLE void removeView ( ) ;
2017-01-16 14:07:49 -05:00
2017-01-12 18:54:23 -05:00
Q_INVOKABLE QVariantList containmentActions ( ) ;
2017-06-11 18:06:03 +03:00
2017-04-23 02:43:24 +03:00
Q_INVOKABLE void deactivateApplets ( ) ;
2018-01-21 11:34:18 +02:00
Q_INVOKABLE void moveToLayout ( QString layoutName ) ;
2017-04-11 12:10:54 +03:00
Q_INVOKABLE void removeTasksPlasmoid ( ) ;
2017-08-09 03:33:03 +03:00
Q_INVOKABLE void setBlockHiding ( bool block ) ;
2017-05-16 23:08:13 +03:00
Q_INVOKABLE void toggleAppletExpanded ( const int id ) ;
2017-01-16 14:07:49 -05:00
2017-06-11 18:06:03 +03:00
Q_INVOKABLE bool mimeContainsPlasmoid ( QMimeData * mimeData , QString name ) ;
Q_INVOKABLE bool tasksPresent ( ) ;
2017-07-28 17:08:55 +03:00
Q_INVOKABLE bool latteTasksPresent ( ) ;
2017-06-11 18:06:03 +03:00
2017-04-29 19:42:26 +03:00
void updateAbsDockGeometry ( bool bypassChecks = false ) ;
2017-03-08 21:00:09 +02:00
2018-10-27 20:50:49 +03:00
Q_INVOKABLE void disableGrabItemBehavior ( ) ;
Q_INVOKABLE void restoreGrabItemBehavior ( ) ;
2019-02-06 18:15:59 +02:00
Q_INVOKABLE bool isHighestPriorityView ( ) ;
2016-12-25 09:25:27 +02:00
protected slots :
void showConfigurationInterface ( Plasma : : Applet * applet ) override ;
2017-01-16 14:07:49 -05:00
2016-12-25 09:25:27 +02:00
protected :
bool event ( QEvent * ev ) override ;
2017-01-03 15:33:30 +02:00
void mousePressEvent ( QMouseEvent * event ) override ;
2017-01-16 14:07:49 -05:00
2016-12-25 09:25:27 +02:00
signals :
2016-12-29 15:41:00 +02:00
void addInternalViewSplitter ( ) ;
2017-01-12 18:54:23 -05:00
void removeInternalViewSplitter ( ) ;
2016-12-30 13:46:56 +02:00
void eventTriggered ( QEvent * ev ) ;
2017-01-16 14:07:49 -05:00
2018-01-14 13:21:11 +02:00
void activitiesChanged ( ) ;
2017-08-09 03:33:03 +03:00
void alternativesIsShownChanged ( ) ;
2017-02-04 16:41:12 +02:00
void alignmentChanged ( ) ;
2017-05-07 15:06:29 +03:00
void behaveAsPlasmaPanelChanged ( ) ;
2018-12-06 15:34:04 +02:00
void byPassWMChanged ( ) ;
2019-03-08 23:43:08 +02:00
void configWindowGeometryChanged ( ) ; // is called from config windows
2017-07-27 18:24:31 +03:00
void contextMenuIsShownChanged ( ) ;
2017-01-22 13:29:40 +02:00
void dockLocationChanged ( ) ;
2019-03-06 20:10:36 +02:00
void editThicknessChanged ( ) ;
2018-11-30 21:33:46 +02:00
void effectsChanged ( ) ;
2018-02-17 19:02:06 +02:00
void fontPixelSizeChanged ( ) ;
2017-01-12 18:54:23 -05:00
void widthChanged ( ) ;
2016-12-25 09:25:27 +02:00
void heightChanged ( ) ;
2018-02-12 16:11:33 +02:00
void inEditModeChanged ( ) ;
2018-09-22 20:21:57 +03:00
void isPreferredForShortcutsChanged ( ) ;
2017-03-09 15:49:24 +02:00
void localGeometryChanged ( ) ;
2018-01-10 22:55:19 +02:00
void managedLayoutChanged ( ) ;
2017-01-31 21:25:00 +02:00
void maxLengthChanged ( ) ;
2016-12-25 09:25:27 +02:00
void maxThicknessChanged ( ) ;
2017-01-27 20:31:41 +02:00
void normalThicknessChanged ( ) ;
2017-04-09 01:06:48 +03:00
void offsetChanged ( ) ;
2017-02-27 00:53:27 +02:00
void onPrimaryChanged ( ) ;
2018-11-29 21:30:00 +02:00
void positionerChanged ( ) ;
2017-02-26 15:49:50 +02:00
void screenGeometryChanged ( ) ;
2019-02-11 16:49:10 +02:00
void typeChanged ( ) ;
2019-02-07 19:15:25 +02:00
void visibilityChanged ( ) ;
void windowsTrackerChanged ( ) ;
2017-02-26 15:49:50 +02:00
void xChanged ( ) ;
void yChanged ( ) ;
2017-01-16 14:07:49 -05:00
2017-02-10 22:12:17 -05:00
void absGeometryChanged ( const QRect & geometry ) ;
2017-01-16 14:07:49 -05:00
2017-01-13 17:15:53 +02:00
private slots :
2017-06-21 22:42:09 +03:00
void availableScreenRectChanged ( ) ;
2019-03-09 14:24:52 +02:00
void configViewCreated ( QQuickView * configView ) ;
2018-12-01 00:13:11 +02:00
void hideWindowsForSlidingOut ( ) ;
2018-12-06 12:15:58 +02:00
void preferredViewForShortcutsChangedSlot ( Latte : : View * view ) ;
2017-01-14 01:59:25 +02:00
void statusChanged ( Plasma : : Types : : ItemStatus ) ;
2017-01-16 14:07:49 -05:00
2017-02-27 00:53:27 +02:00
void restoreConfig ( ) ;
void saveConfig ( ) ;
2017-01-12 18:54:23 -05:00
private :
2018-01-21 11:53:15 +02:00
void applyActivitiesToWindows ( ) ;
2017-12-10 19:54:13 +02:00
void initSignalingForLocationChangeSliding ( ) ;
2017-04-25 19:18:49 +03:00
void setupWaylandIntegration ( ) ;
2017-04-23 02:31:36 +03:00
void updateAppletContainsMethod ( ) ;
2017-01-16 14:07:49 -05:00
2016-12-25 09:25:27 +02:00
private :
2017-02-05 20:55:41 -05:00
Plasma : : Containment * containmentById ( uint id ) ;
2017-01-27 20:03:24 +02:00
2017-08-09 03:33:03 +03:00
bool m_alternativesIsShown { false } ;
2017-05-07 15:06:29 +03:00
bool m_behaveAsPlasmaPanel { false } ;
2018-12-06 15:34:04 +02:00
bool m_byPassWM { true } ;
2019-03-08 16:14:34 +02:00
bool m_containsMouse { false } ;
2017-06-21 22:42:09 +03:00
bool m_inDelete { false } ;
2018-02-12 16:11:33 +02:00
bool m_inEditMode { false } ;
2018-09-22 20:21:57 +03:00
bool m_isPreferredForShortcuts { false } ;
2017-02-27 00:53:27 +02:00
bool m_onPrimary { true } ;
2018-03-06 22:54:37 +02:00
int m_fontPixelSize { - 1 } ;
2019-03-06 20:10:36 +02:00
int m_editThickness { 24 } ;
2017-01-12 18:54:23 -05:00
int m_maxThickness { 24 } ;
2017-01-27 20:31:41 +02:00
int m_normalThickness { 24 } ;
2017-04-09 01:06:48 +03:00
int m_offset { 0 } ;
2017-01-31 21:25:00 +02:00
float m_maxLength { 1 } ;
2017-01-16 14:07:49 -05:00
2018-12-07 18:55:35 +02:00
Types : : Alignment m_alignment { Types : : Center } ;
2019-02-11 16:49:10 +02:00
Types : : ViewType m_type { Types : : DockView } ;
2017-02-04 16:41:12 +02:00
2017-03-08 21:00:09 +02:00
QRect m_localGeometry ;
2017-02-10 22:12:17 -05:00
QRect m_absGeometry ;
2018-04-05 10:09:04 +03:00
2018-01-13 19:27:32 +02:00
Layout * m_managedLayout { nullptr } ;
2017-01-12 18:54:23 -05:00
QPointer < PlasmaQuick : : ConfigView > m_configView ;
2018-01-18 21:21:32 +02:00
2018-12-06 11:37:14 +02:00
QPointer < ViewPart : : ContextMenu > m_contextMenu ;
QPointer < ViewPart : : Effects > m_effects ;
QPointer < ViewPart : : Positioner > m_positioner ;
2018-12-09 00:29:35 +02:00
QPointer < ViewPart : : VisibilityManager > m_visibility ;
2019-02-07 19:15:25 +02:00
QPointer < ViewPart : : WindowsTracker > m_windowsTracker ;
2017-02-26 19:15:20 +02:00
2018-01-20 00:34:55 +02:00
//! Connections to release and bound for the managed layout
2019-03-09 14:24:52 +02:00
std : : array < QMetaObject : : Connection , 6 > connectionsManagedLayout ;
2018-01-20 00:34:55 +02:00
2017-04-25 19:18:49 +03:00
KWayland : : Client : : PlasmaShellSurface * m_shellSurface { nullptr } ;
2016-12-25 09:25:27 +02:00
} ;
2016-12-30 02:20:06 -05:00
}
2016-12-25 09:25:27 +02:00
# endif