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
# ifndef NOWDOCKVIEW_H
# define NOWDOCKVIEW_H
# include "plasmaquick/configview.h"
# include "plasmaquick/containmentview.h"
# include "visibilitymanager.h"
# include <QQuickView>
# include <QQmlListProperty>
2017-01-03 15:33:30 +02:00
# include <QMenu>
2016-12-25 09:25:27 +02:00
# include <QScreen>
# include <QPointer>
# include <QTimer>
2017-01-03 15:33:30 +02:00
# include <PlasmaQuick/AppletQuickItem>
2016-12-25 09:25:27 +02:00
namespace Plasma {
class Types ;
class Corona ;
class Containment ;
}
2016-12-30 02:20:06 -05:00
namespace Latte {
2016-12-30 16:25:27 -05:00
class DockView : public PlasmaQuick : : ContainmentView {
2016-12-25 09:25:27 +02:00
Q_OBJECT
2017-01-16 13:24:46 -05:00
2017-01-05 00:28:25 +02:00
Q_PROPERTY ( int docksCount READ docksCount NOTIFY docksCountChanged )
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 )
Q_PROPERTY ( int maxLength READ maxLength WRITE setMaxLength NOTIFY maxLengthChanged )
Q_PROPERTY ( int maxThickness READ maxThickness WRITE setMaxThickness NOTIFY maxThicknessChanged )
2017-01-13 16:51:56 +02:00
Q_PROPERTY ( int shadow READ shadow WRITE setShadow NOTIFY shadowChanged )
2017-01-16 13:24:46 -05:00
2016-12-25 09:25:27 +02:00
Q_PROPERTY ( QRect maskArea READ maskArea WRITE setMaskArea NOTIFY maskAreaChanged )
Q_PROPERTY ( VisibilityManager * visibility READ visibility NOTIFY visibilityChanged )
Q_PROPERTY ( QQmlListProperty < QScreen > screens READ screens )
2017-01-16 13:24:46 -05:00
2016-12-25 09:25:27 +02:00
public :
2016-12-30 16:25:27 -05:00
DockView ( Plasma : : Corona * corona , QScreen * targetScreen = nullptr ) ;
virtual ~ DockView ( ) ;
2017-01-16 13:24:46 -05:00
2016-12-25 09:25:27 +02:00
void init ( ) ;
2017-01-16 13:24:46 -05:00
2017-01-12 18:54:23 -05:00
void adaptToScreen ( QScreen * screen ) ;
2017-01-16 13:24:46 -05:00
2017-01-12 18:54:23 -05:00
void resizeWindow ( ) ;
void syncGeometry ( ) ;
2017-01-16 13:24:46 -05:00
2017-01-12 18:54:23 -05:00
int currentThickness ( ) const ;
void updateAbsDockGeometry ( ) ;
2017-01-16 13:24:46 -05:00
2017-01-12 18:54:23 -05:00
int docksCount ( ) const ;
2017-01-16 13:24:46 -05:00
2016-12-25 09:25:27 +02:00
int maxLength ( ) const ;
void setMaxLength ( int maxLength ) ;
2017-01-16 13:24:46 -05:00
2017-01-12 18:54:23 -05:00
int maxThickness ( ) const ;
void setMaxThickness ( int thickness ) ;
2017-01-16 13:24:46 -05:00
2017-01-13 16:51:56 +02:00
int shadow ( ) const ;
void setShadow ( int shadow ) ;
2017-01-16 13:24:46 -05:00
2017-01-12 18:54:23 -05:00
QRect maskArea ( ) const ;
void setMaskArea ( QRect area ) ;
2017-01-16 13:24:46 -05:00
2017-01-12 18:54:23 -05:00
VisibilityManager * visibility ( ) ;
2017-01-16 13:24:46 -05:00
2016-12-25 09:25:27 +02:00
QQmlListProperty < QScreen > screens ( ) ;
static int countScreens ( QQmlListProperty < QScreen > * property ) ;
static QScreen * atScreens ( QQmlListProperty < QScreen > * property , int index ) ;
2017-01-16 13:24:46 -05:00
2016-12-25 09:25:27 +02:00
public slots :
2017-01-03 15:33:30 +02:00
Q_INVOKABLE void addAppletItem ( QObject * item ) ;
Q_INVOKABLE void removeAppletItem ( QObject * item ) ;
2017-01-16 13:24:46 -05:00
2016-12-25 09:25:27 +02:00
Q_INVOKABLE void addNewDock ( ) ;
2016-12-25 16:18:31 +02:00
Q_INVOKABLE void removeDock ( ) ;
2017-01-16 13:24:46 -05:00
2017-01-12 18:54:23 -05:00
Q_INVOKABLE QList < int > freeEdges ( ) const ;
Q_INVOKABLE QVariantList containmentActions ( ) ;
2016-12-30 19:26:48 -05:00
Q_INVOKABLE void setLocalDockGeometry ( const QRect & geometry ) ;
2017-01-02 22:26:10 +02:00
Q_INVOKABLE bool tasksPresent ( ) ;
2017-01-16 13:24:46 -05:00
2017-01-05 00:28:25 +02:00
Q_INVOKABLE void closeApplication ( ) ;
2017-01-16 13:24:46 -05:00
2016-12-25 09:25:27 +02:00
protected slots :
void showConfigurationInterface ( Plasma : : Applet * applet ) override ;
2017-01-16 13:24:46 -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 ;
void mouseReleaseEvent ( QMouseEvent * event ) override ;
2017-01-16 13:24:46 -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 13:24:46 -05:00
2017-01-12 18:54:23 -05:00
void docksCountChanged ( ) ;
void widthChanged ( ) ;
2016-12-25 09:25:27 +02:00
void heightChanged ( ) ;
void maxLengthChanged ( ) ;
void maxThicknessChanged ( ) ;
void visibilityChanged ( ) ;
2017-01-12 18:54:23 -05:00
void maskAreaChanged ( ) ;
2017-01-13 16:51:56 +02:00
void shadowChanged ( ) ;
2017-01-16 13:24:46 -05:00
2017-01-12 18:54:23 -05:00
void localDockGeometryChanged ( ) ;
2017-01-16 13:24:46 -05:00
2017-01-13 17:15:53 +02:00
private slots :
void menuAboutToHide ( ) ;
2017-01-14 01:59:25 +02:00
void statusChanged ( Plasma : : Types : : ItemStatus ) ;
2017-01-16 13:24:46 -05:00
2017-01-12 18:54:23 -05:00
private :
void initWindow ( ) ;
2017-01-16 13:24:46 -05:00
2017-01-12 18:54:23 -05:00
void addAppletActions ( QMenu * desktopMenu , Plasma : : Applet * applet , QEvent * event ) ;
void addContainmentActions ( QMenu * desktopMenu , QEvent * event ) ;
void updatePosition ( ) ;
void updateFormFactor ( ) ;
2017-01-16 13:24:46 -05:00
2016-12-25 09:25:27 +02:00
private :
int m_maxLength { INT_MAX } ;
2017-01-12 18:54:23 -05:00
int m_maxThickness { 24 } ;
2017-01-13 16:51:56 +02:00
int m_shadow { 0 } ;
2017-01-16 13:24:46 -05:00
2016-12-30 20:24:21 +02:00
QRect m_localDockGeometry ;
2016-12-25 09:25:27 +02:00
QRect m_maskArea ;
2017-01-03 15:33:30 +02:00
QMenu * m_contextMenu ;
2017-01-12 18:54:23 -05:00
QPointer < PlasmaQuick : : ConfigView > m_configView ;
2016-12-25 09:25:27 +02:00
QPointer < VisibilityManager > m_visibility ;
2017-01-12 18:54:23 -05:00
QList < PlasmaQuick : : AppletQuickItem * > m_appletItems ;
2017-01-05 17:48:27 +02:00
QList < QMetaObject : : Connection > connections ;
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