2018-11-29 22:30:00 +03:00
/*
* Copyright 2018 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/>.
*/
# ifndef POSITIONER_H
# define POSITIONER_H
2018-12-02 03:05:52 +03:00
// Qt
2018-11-29 22:30:00 +03:00
# include <QObject>
# include <QPointer>
# include <QScreen>
# include <QTimer>
2018-12-02 03:05:52 +03:00
// Plasma
2018-11-29 22:30:00 +03:00
# include <Plasma/Containment>
namespace Plasma {
class Types ;
}
namespace Latte {
2018-12-06 13:15:58 +03:00
class View ;
2018-11-29 22:30:00 +03:00
}
namespace Latte {
2018-12-06 12:37:14 +03:00
namespace ViewPart {
2018-11-29 22:30:00 +03:00
class Positioner : public QObject
{
Q_OBJECT
2018-12-01 17:13:35 +03:00
Q_PROPERTY ( int currentScreenId READ currentScreenId NOTIFY currentScreenChanged )
2018-12-01 16:22:33 +03:00
Q_PROPERTY ( QString currentScreenName READ currentScreenName NOTIFY currentScreenChanged )
2018-11-29 22:30:00 +03:00
public :
2018-12-06 13:15:58 +03:00
Positioner ( Latte : : View * parent ) ;
2018-11-29 22:30:00 +03:00
virtual ~ Positioner ( ) ;
2018-12-01 17:13:35 +03:00
int currentScreenId ( ) const ;
QString currentScreenName ( ) const ;
2018-11-29 22:30:00 +03:00
bool inLocationChangeAnimation ( ) ;
void setScreenToFollow ( QScreen * scr , bool updateScreenId = true ) ;
2018-12-01 17:13:35 +03:00
void reconsiderScreen ( ) ;
2018-11-29 22:30:00 +03:00
public slots :
Q_INVOKABLE void hideDockDuringLocationChange ( int goToLocation ) ;
Q_INVOKABLE void hideDockDuringMovingToLayout ( QString layoutName ) ;
Q_INVOKABLE bool setCurrentScreen ( const QString id ) ;
void syncGeometry ( ) ;
signals :
void currentScreenChanged ( ) ;
void screenGeometryChanged ( ) ;
2019-04-12 18:55:45 +03:00
void windowSizeChanged ( ) ;
2018-11-29 22:30:00 +03:00
//! these two signals are used from config ui and containment ui
//! in order to orchestrate an animated hiding/showing of dock
//! during changing location
void hideDockDuringLocationChangeStarted ( ) ;
void hideDockDuringLocationChangeFinished ( ) ;
void hideDockDuringScreenChangeStarted ( ) ;
void hideDockDuringScreenChangeFinished ( ) ;
void hideDockDuringMovingToLayoutStarted ( ) ;
void hideDockDuringMovingToLayoutFinished ( ) ;
2018-12-01 01:13:11 +03:00
void onHideWindowsForSlidingOut ( ) ;
2018-11-29 22:30:00 +03:00
void showDockAfterLocationChangeFinished ( ) ;
void showDockAfterScreenChangeFinished ( ) ;
void showDockAfterMovingToLayoutFinished ( ) ;
private slots :
void screenChanged ( QScreen * screen ) ;
void validateDockGeometry ( ) ;
private :
void init ( ) ;
void initSignalingForLocationChangeSliding ( ) ;
void resizeWindow ( QRect availableScreenRect = QRect ( ) ) ;
2018-12-01 01:13:11 +03:00
void updateFormFactor ( ) ;
2018-11-29 22:30:00 +03:00
void updatePosition ( QRect availableScreenRect = QRect ( ) ) ;
QRect maximumNormalGeometry ( ) ;
private :
bool m_inDelete { false } ;
//! it is used in order to enforce X11 to never miss window geometry
QRect m_validGeometry ;
2018-12-06 13:15:58 +03:00
QPointer < Latte : : View > m_view ;
2018-11-29 22:30:00 +03:00
QString m_screenToFollowId ;
QPointer < QScreen > m_screenToFollow ;
QTimer m_screenSyncTimer ;
QTimer m_validateGeometryTimer ;
//!used at sliding out/in animation
QString m_moveToLayout ;
Plasma : : Types : : Location m_goToLocation { Plasma : : Types : : Floating } ;
QScreen * m_goToScreen { nullptr } ;
} ;
2018-12-01 01:13:11 +03:00
}
2018-11-29 22:30:00 +03:00
}
# endif