2016-12-25 10:25:27 +03:00
/*
2017-01-03 01:05:30 +03: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 10:25:27 +03: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 16:33:30 +03:00
# include <QMenu>
2016-12-25 10:25:27 +03:00
# include <QScreen>
# include <QPointer>
# include <QTimer>
namespace Plasma {
class Types ;
class Corona ;
class Containment ;
}
2016-12-30 10:20:06 +03:00
namespace Latte {
2016-12-31 00:25:27 +03:00
class DockView : public PlasmaQuick : : ContainmentView {
2016-12-25 10:25:27 +03:00
Q_OBJECT
2017-01-16 22:07:49 +03:00
2017-01-05 01:28:25 +03:00
Q_PROPERTY ( int docksCount READ docksCount NOTIFY docksCountChanged )
2017-01-13 02:54:23 +03:00
Q_PROPERTY ( int width READ width NOTIFY widthChanged )
2016-12-25 10:25:27 +03:00
Q_PROPERTY ( int height READ height NOTIFY heightChanged )
Q_PROPERTY ( int maxThickness READ maxThickness WRITE setMaxThickness NOTIFY maxThicknessChanged )
2017-01-27 21:31:41 +03:00
Q_PROPERTY ( int normalThickness READ normalThickness WRITE setNormalThickness NOTIFY normalThicknessChanged )
2017-01-13 17:51:56 +03:00
Q_PROPERTY ( int shadow READ shadow WRITE setShadow NOTIFY shadowChanged )
2017-02-01 22:19:50 +03:00
Q_PROPERTY ( QStringList debugFlags READ debugFlags NOTIFY debugFlagsChanged )
2017-01-16 22:07:49 +03:00
2016-12-25 10:25:27 +03: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 22:07:49 +03:00
2016-12-25 10:25:27 +03:00
public :
2016-12-31 00:25:27 +03:00
DockView ( Plasma : : Corona * corona , QScreen * targetScreen = nullptr ) ;
virtual ~ DockView ( ) ;
2017-01-16 22:07:49 +03:00
2016-12-25 10:25:27 +03:00
void init ( ) ;
2017-01-16 22:07:49 +03:00
2017-01-13 02:54:23 +03:00
void adaptToScreen ( QScreen * screen ) ;
2017-01-16 22:07:49 +03:00
2017-01-13 02:54:23 +03:00
void resizeWindow ( ) ;
void syncGeometry ( ) ;
2017-01-16 22:07:49 +03:00
2017-01-13 02:54:23 +03:00
int currentThickness ( ) const ;
void updateAbsDockGeometry ( ) ;
2017-01-16 22:07:49 +03:00
2017-01-13 02:54:23 +03:00
int docksCount ( ) const ;
2017-01-16 22:07:49 +03:00
2017-01-13 02:54:23 +03:00
int maxThickness ( ) const ;
void setMaxThickness ( int thickness ) ;
2017-01-16 22:07:49 +03:00
2017-01-27 21:31:41 +03:00
int normalThickness ( ) const ;
void setNormalThickness ( int thickness ) ;
2017-01-13 17:51:56 +03:00
int shadow ( ) const ;
void setShadow ( int shadow ) ;
2017-01-16 22:07:49 +03:00
2017-01-13 02:54:23 +03:00
QRect maskArea ( ) const ;
void setMaskArea ( QRect area ) ;
2017-01-16 22:07:49 +03:00
2017-02-01 22:19:50 +03:00
QStringList debugFlags ( ) const ;
2017-01-13 02:54:23 +03:00
VisibilityManager * visibility ( ) ;
2017-01-16 22:07:49 +03:00
2016-12-25 10:25:27 +03:00
QQmlListProperty < QScreen > screens ( ) ;
static int countScreens ( QQmlListProperty < QScreen > * property ) ;
static QScreen * atScreens ( QQmlListProperty < QScreen > * property , int index ) ;
2017-01-16 22:07:49 +03:00
2016-12-25 10:25:27 +03:00
public slots :
Q_INVOKABLE void addNewDock ( ) ;
2016-12-25 17:18:31 +03:00
Q_INVOKABLE void removeDock ( ) ;
2017-01-16 22:07:49 +03:00
2017-01-13 02:54:23 +03:00
Q_INVOKABLE QList < int > freeEdges ( ) const ;
Q_INVOKABLE QVariantList containmentActions ( ) ;
2016-12-31 03:26:48 +03:00
Q_INVOKABLE void setLocalDockGeometry ( const QRect & geometry ) ;
2017-01-02 23:26:10 +03:00
Q_INVOKABLE bool tasksPresent ( ) ;
2017-01-16 22:07:49 +03:00
2017-01-05 01:28:25 +03:00
Q_INVOKABLE void closeApplication ( ) ;
2017-01-16 22:07:49 +03:00
2016-12-25 10:25:27 +03:00
protected slots :
void showConfigurationInterface ( Plasma : : Applet * applet ) override ;
2017-01-16 22:07:49 +03:00
2016-12-25 10:25:27 +03:00
protected :
bool event ( QEvent * ev ) override ;
2017-01-03 16:33:30 +03:00
void mousePressEvent ( QMouseEvent * event ) override ;
void mouseReleaseEvent ( QMouseEvent * event ) override ;
2017-01-16 22:07:49 +03:00
2016-12-25 10:25:27 +03:00
signals :
2016-12-29 16:41:00 +03:00
void addInternalViewSplitter ( ) ;
2017-01-13 02:54:23 +03:00
void removeInternalViewSplitter ( ) ;
2016-12-30 14:46:56 +03:00
void eventTriggered ( QEvent * ev ) ;
2017-01-16 22:07:49 +03:00
2017-02-01 22:19:50 +03:00
void debugFlagsChanged ( ) ;
2017-01-22 14:29:40 +03:00
void dockLocationChanged ( ) ;
2017-01-13 02:54:23 +03:00
void docksCountChanged ( ) ;
void widthChanged ( ) ;
2016-12-25 10:25:27 +03:00
void heightChanged ( ) ;
void maxThicknessChanged ( ) ;
2017-01-27 21:31:41 +03:00
void normalThicknessChanged ( ) ;
2016-12-25 10:25:27 +03:00
void visibilityChanged ( ) ;
2017-01-13 02:54:23 +03:00
void maskAreaChanged ( ) ;
2017-01-13 17:51:56 +03:00
void shadowChanged ( ) ;
2017-01-16 22:07:49 +03:00
2017-01-13 02:54:23 +03:00
void localDockGeometryChanged ( ) ;
2017-01-16 22:07:49 +03:00
2017-01-13 18:15:53 +03:00
private slots :
void menuAboutToHide ( ) ;
2017-01-14 02:59:25 +03:00
void statusChanged ( Plasma : : Types : : ItemStatus ) ;
2017-01-16 22:07:49 +03:00
2017-01-13 02:54:23 +03:00
private :
void initWindow ( ) ;
2017-01-16 22:07:49 +03:00
2017-01-13 02:54:23 +03:00
void addAppletActions ( QMenu * desktopMenu , Plasma : : Applet * applet , QEvent * event ) ;
void addContainmentActions ( QMenu * desktopMenu , QEvent * event ) ;
void updatePosition ( ) ;
void updateFormFactor ( ) ;
2017-01-16 22:07:49 +03:00
2016-12-25 10:25:27 +03:00
private :
2017-01-27 21:03:24 +03:00
Plasma : : Containment * containmentById ( int id ) ;
2017-01-13 02:54:23 +03:00
int m_maxThickness { 24 } ;
2017-01-27 21:31:41 +03:00
int m_normalThickness { 24 } ;
2017-01-13 17:51:56 +03:00
int m_shadow { 0 } ;
2017-01-16 22:07:49 +03:00
2016-12-30 21:24:21 +03:00
QRect m_localDockGeometry ;
2016-12-25 10:25:27 +03:00
QRect m_maskArea ;
2017-01-03 16:33:30 +03:00
QMenu * m_contextMenu ;
2017-01-13 02:54:23 +03:00
QPointer < PlasmaQuick : : ConfigView > m_configView ;
2016-12-25 10:25:27 +03:00
QPointer < VisibilityManager > m_visibility ;
} ;
2016-12-30 10:20:06 +03:00
}
2016-12-25 10:25:27 +03:00
# endif