2016-12-30 16:22:28 -05: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-30 16:22:28 -05:00
2018-12-06 12:15:58 +02:00
# include "view.h"
2018-02-03 11:34:13 +02:00
2018-12-02 02:05:52 +02:00
// local
2018-12-02 00:53:40 +02:00
# include "contextmenu.h"
2018-11-30 21:33:46 +02:00
# include "effects.h"
2018-11-29 21:30:00 +02:00
# include "positioner.h"
2017-03-18 13:21:17 +02:00
# include "visibilitymanager.h"
2018-12-09 00:06:14 +02:00
# include "settings/primaryconfigview.h"
2019-04-01 23:50:25 +03:00
# include "settings/secondaryconfigview.h"
2020-04-24 12:31:03 +03:00
# include "../apptypes.h"
2018-12-06 14:35:34 +02:00
# include "../lattecorona.h"
2020-05-12 14:45:31 +03:00
# include "../declarativeimports/interfaces.h"
2020-04-24 12:31:03 +03:00
# include "../indicator/factory.h"
2019-04-06 02:00:37 +03:00
# include "../layout/genericlayout.h"
2019-05-09 17:12:57 +03:00
# include "../layouts/manager.h"
2018-12-13 20:03:14 +02:00
# include "../plasma/extended/theme.h"
2018-02-03 11:34:13 +02:00
# include "../screenpool.h"
2018-12-02 01:21:34 +02:00
# include "../settings/universalsettings.h"
2019-02-03 00:10:07 +02:00
# include "../shortcuts/globalshortcuts.h"
# include "../shortcuts/shortcutstracker.h"
2016-12-30 16:22:28 -05:00
2018-12-02 02:05:52 +02:00
// Qt
2016-12-30 16:22:28 -05:00
# include <QAction>
2019-04-14 13:25:16 +03:00
# include <QMouseEvent>
2016-12-30 16:22:28 -05:00
# include <QQmlContext>
# include <QQmlEngine>
# include <QQmlProperty>
# include <QQuickItem>
2017-01-03 15:33:30 +02:00
# include <QMenu>
2016-12-30 16:22:28 -05:00
2018-12-02 02:05:52 +02:00
// KDe
2016-12-30 16:22:28 -05:00
# include <KActionCollection>
2018-01-14 09:39:31 +02:00
# include <KActivities/Consumer>
2018-12-02 02:05:52 +02:00
# include <KWayland/Client/plasmashell.h>
# include <KWayland/Client/surface.h>
2018-12-01 15:46:49 +02:00
# include <KWindowSystem>
2018-12-02 02:05:52 +02:00
// Plasma
2017-01-03 15:33:30 +02:00
# include <Plasma/Containment>
# include <Plasma/ContainmentActions>
# include <PlasmaQuick/AppletQuickItem>
2016-12-30 16:22:28 -05:00
2020-04-05 14:40:32 +03:00
# define BLOCKHIDINGDRAGTYPE "View::ContainsDrag()"
# define BLOCKHIDINGNEEDSATTENTIONTYPE "View::Containment::NeedsAttentionState()"
# define BLOCKHIDINGREQUESTSINPUTTYPE "View::Containment::RequestsInputState()"
2016-12-30 16:22:28 -05:00
namespace Latte {
2018-12-06 15:34:04 +02:00
//! both alwaysVisible and byPassWM are passed through corona because
//! during the view window creation containment hasn't been set, but these variables
2017-03-18 23:32:27 +02:00
//! are needed in order for window flags to be set correctly
2018-12-06 15:34:04 +02:00
View : : View ( Plasma : : Corona * corona , QScreen * targetScreen , bool byPassWM )
2017-01-03 15:33:30 +02:00
: PlasmaQuick : : ContainmentView ( corona ) ,
2018-12-06 11:37:14 +02:00
m_contextMenu ( new ViewPart : : ContextMenu ( this ) ) ,
2019-12-21 18:53:02 +02:00
m_effects ( new ViewPart : : Effects ( this ) ) ,
m_interface ( new ViewPart : : ContainmentInterface ( this ) )
2019-07-13 14:51:26 +03:00
{
2019-07-15 14:53:40 +03:00
//! needs to be created after Effects because it catches some of its signals
//! and avoid a crash from View::winId() at the same time
m_positioner = new ViewPart : : Positioner ( this ) ;
2020-03-07 18:30:22 +02:00
// setTitle(corona->kPackage().metadata().name());
2017-03-11 20:36:43 +02:00
setIcon ( qGuiApp - > windowIcon ( ) ) ;
2016-12-30 16:22:28 -05:00
setResizeMode ( QuickViewSharedEngine : : SizeRootObjectToView ) ;
2017-03-12 20:18:18 +02:00
setColor ( QColor ( Qt : : transparent ) ) ;
2019-07-16 14:06:26 +03:00
setDefaultAlphaBuffer ( true ) ;
2016-12-30 16:22:28 -05:00
setClearBeforeRendering ( true ) ;
2017-03-08 21:00:09 +02:00
2017-04-09 13:42:39 -05:00
const auto flags = Qt : : FramelessWindowHint
2019-03-23 17:49:09 +02:00
| Qt : : NoDropShadowWindowHint
| Qt : : WindowDoesNotAcceptFocus ;
2017-04-09 13:42:39 -05:00
2018-12-06 15:34:04 +02:00
if ( byPassWM ) {
2017-04-09 13:42:39 -05:00
setFlags ( flags | Qt : : BypassWindowManagerHint ) ;
2018-12-06 15:34:04 +02:00
} else {
setFlags ( flags ) ;
2017-03-08 21:00:09 +02:00
}
2017-01-16 14:07:49 -05:00
2016-12-30 16:22:28 -05:00
if ( targetScreen )
2018-11-29 21:30:00 +02:00
m_positioner - > setScreenToFollow ( targetScreen ) ;
2016-12-30 16:22:28 -05:00
else
2018-11-29 21:30:00 +02:00
m_positioner - > setScreenToFollow ( qGuiApp - > primaryScreen ( ) ) ;
2017-01-16 14:07:49 -05:00
2019-08-26 01:22:22 +03:00
m_releaseGrabTimer . setInterval ( 400 ) ;
m_releaseGrabTimer . setSingleShot ( true ) ;
connect ( & m_releaseGrabTimer , & QTimer : : timeout , this , & View : : releaseGrab ) ;
2020-04-05 14:40:32 +03:00
connect ( m_contextMenu , & ViewPart : : ContextMenu : : menuChanged , this , & View : : updateTransientWindowsTracking ) ;
2018-12-06 12:15:58 +02:00
connect ( this , & View : : containmentChanged
2019-03-23 17:49:09 +02:00
, this , [ & , byPassWM ] ( ) {
2017-06-25 16:42:19 +03:00
qDebug ( ) < < " dock view c++ containment changed 1... " ;
2017-02-12 10:02:01 +02:00
if ( ! this - > containment ( ) )
2016-12-30 16:22:28 -05:00
return ;
2017-02-27 00:53:27 +02:00
2017-06-25 16:42:19 +03:00
qDebug ( ) < < " dock view c++ containment changed 2... " ;
2020-03-02 03:10:59 +02:00
setTitle ( validTitle ( ) ) ;
2018-09-04 19:38:54 +03:00
//! First load default values from file
restoreConfig ( ) ;
//! Afterwards override that values in case during creation something different is needed
2018-12-06 15:34:04 +02:00
setByPassWM ( byPassWM ) ;
2017-07-29 23:07:00 +03:00
2018-09-04 19:38:54 +03:00
//! Check the screen assigned to this dock
2017-02-27 00:53:27 +02:00
reconsiderScreen ( ) ;
2017-01-16 14:07:49 -05:00
2019-02-07 20:24:52 +02:00
//! needs to be created before visibility creation because visibility uses it
if ( ! m_windowsTracker ) {
m_windowsTracker = new ViewPart : : WindowsTracker ( this ) ;
2019-03-23 17:49:09 +02:00
emit windowsTrackerChanged ( ) ;
2019-02-07 20:24:52 +02:00
}
2016-12-30 16:22:28 -05:00
if ( ! m_visibility ) {
2018-12-09 00:29:35 +02:00
m_visibility = new ViewPart : : VisibilityManager ( this ) ;
2018-02-25 20:00:23 +02:00
2018-12-09 00:29:35 +02:00
connect ( m_visibility , & ViewPart : : VisibilityManager : : isHiddenChanged , this , [ & ] ( ) {
2018-02-25 20:00:23 +02:00
if ( m_visibility - > isHidden ( ) ) {
2020-04-08 14:39:12 +03:00
m_interface - > deactivateApplets ( ) ;
2018-02-25 20:00:23 +02:00
}
} ) ;
2019-03-23 17:49:09 +02:00
2020-04-05 14:40:32 +03:00
connect ( m_visibility , & ViewPart : : VisibilityManager : : containsMouseChanged ,
this , & View : : updateTransientWindowsTracking ) ;
2020-05-12 14:45:31 +03:00
connect ( m_visibility , & ViewPart : : VisibilityManager : : frameExtentsCleared , this , [ & ] ( ) {
if ( behaveAsPlasmaPanel ( ) ) {
//! recreate view because otherwise compositor frame extents implementation
//! is triggering a crazy behavior of moving/hiding the view and freezing Latte
//! in some cases.
reloadSource ( ) ;
}
} ) ;
2019-03-23 17:49:09 +02:00
emit visibilityChanged ( ) ;
}
if ( ! m_indicator ) {
m_indicator = new ViewPart : : Indicator ( this ) ;
emit indicatorChanged ( ) ;
2016-12-30 16:22:28 -05:00
}
2017-01-16 14:07:49 -05:00
2017-02-12 10:02:01 +02:00
connect ( this - > containment ( ) , SIGNAL ( statusChanged ( Plasma : : Types : : ItemStatus ) ) , SLOT ( statusChanged ( Plasma : : Types : : ItemStatus ) ) ) ;
2016-12-30 16:22:28 -05:00
} , Qt : : DirectConnection ) ;
2018-01-10 19:48:23 +02:00
2019-04-12 18:55:45 +03:00
m_corona = qobject_cast < Latte : : Corona * > ( this - > corona ( ) ) ;
2017-01-16 14:07:49 -05:00
2019-04-12 18:55:45 +03:00
if ( m_corona ) {
connect ( m_corona , & Latte : : Corona : : viewLocationChanged , this , & View : : dockLocationChanged ) ;
2017-01-22 13:29:40 +02:00
}
2016-12-30 16:22:28 -05:00
}
2018-12-06 12:15:58 +02:00
View : : ~ View ( )
2016-12-30 16:22:28 -05:00
{
2017-06-21 23:34:40 +03:00
m_inDelete = true ;
2018-03-01 01:31:17 +02:00
2019-05-08 23:42:06 +03:00
//! clear Layout connections
2019-05-07 22:06:00 +03:00
m_visibleHackTimer1 . stop ( ) ;
m_visibleHackTimer2 . stop ( ) ;
2019-05-08 23:42:06 +03:00
for ( auto & c : connectionsLayout ) {
2019-05-07 22:06:00 +03:00
disconnect ( c ) ;
}
//! unload indicators
2019-04-05 17:16:40 +03:00
if ( m_indicator ) {
m_indicator - > unloadIndicators ( ) ;
}
2019-12-28 13:59:36 +02:00
disconnectSensitiveSignals ( ) ;
2017-06-21 23:34:40 +03:00
disconnect ( containment ( ) , SIGNAL ( statusChanged ( Plasma : : Types : : ItemStatus ) ) , this , SLOT ( statusChanged ( Plasma : : Types : : ItemStatus ) ) ) ;
2017-06-21 22:42:09 +03:00
2017-01-05 17:48:27 +02:00
qDebug ( ) < < " dock view deleting... " ;
2017-01-16 14:07:49 -05:00
2017-03-13 20:58:31 +02:00
//! this disconnect does not free up connections correctly when
2018-12-06 12:15:58 +02:00
//! latteView is deleted. A crash for this example is the following:
2017-03-13 20:58:31 +02:00
//! switch to Alternative Session and disable compositing,
//! the signal creating the crash was probably from deleted
//! windows.
//! this->disconnect();
2017-01-17 20:09:43 +02:00
2018-01-18 21:21:32 +02:00
if ( m_configView ) {
2020-04-20 10:38:01 +03:00
delete m_configView ;
2018-01-18 21:21:32 +02:00
}
2018-12-02 00:53:40 +02:00
if ( m_contextMenu ) {
delete m_contextMenu ;
2018-02-03 15:00:44 +02:00
}
2019-01-01 11:19:44 +02:00
//needs to be deleted before Effects because it catches some of its signals
2018-11-29 21:30:00 +02:00
if ( m_positioner ) {
delete m_positioner ;
}
2018-11-30 21:33:46 +02:00
if ( m_effects ) {
delete m_effects ;
}
2019-04-05 17:16:40 +03:00
if ( m_indicator ) {
delete m_indicator ;
}
2019-12-21 18:53:02 +02:00
if ( m_interface ) {
delete m_interface ;
}
2019-02-07 19:15:25 +02:00
if ( m_visibility ) {
2018-11-30 21:33:46 +02:00
delete m_visibility ;
2019-02-07 19:15:25 +02:00
}
2019-02-07 20:24:52 +02:00
if ( m_windowsTracker ) {
delete m_windowsTracker ;
}
2016-12-30 16:22:28 -05:00
}
2020-05-02 13:23:37 +03:00
void View : : init ( Plasma : : Containment * plasma_containment )
2016-12-30 16:22:28 -05:00
{
2018-12-06 12:15:58 +02:00
connect ( this , & QQuickWindow : : xChanged , this , & View : : xChanged ) ;
2019-04-23 10:41:35 +03:00
connect ( this , & QQuickWindow : : xChanged , this , & View : : updateAbsoluteGeometry ) ;
2018-12-06 12:15:58 +02:00
connect ( this , & QQuickWindow : : yChanged , this , & View : : yChanged ) ;
2019-04-23 10:41:35 +03:00
connect ( this , & QQuickWindow : : yChanged , this , & View : : updateAbsoluteGeometry ) ;
2018-12-06 12:15:58 +02:00
connect ( this , & QQuickWindow : : widthChanged , this , & View : : widthChanged ) ;
2019-04-23 10:41:35 +03:00
connect ( this , & QQuickWindow : : widthChanged , this , & View : : updateAbsoluteGeometry ) ;
2018-12-06 12:15:58 +02:00
connect ( this , & QQuickWindow : : heightChanged , this , & View : : heightChanged ) ;
2019-04-23 10:41:35 +03:00
connect ( this , & QQuickWindow : : heightChanged , this , & View : : updateAbsoluteGeometry ) ;
2017-06-21 22:42:09 +03:00
2020-03-21 12:44:52 +02:00
connect ( this , & View : : activitiesChanged , this , & View : : applyActivitiesToWindows ) ;
2020-03-19 15:32:36 +02:00
connect ( this , & View : : localGeometryChanged , this , [ & ] ( ) {
updateAbsoluteGeometry ( ) ;
} ) ;
connect ( this , & View : : screenEdgeMarginEnabledChanged , this , [ & ] ( ) {
updateAbsoluteGeometry ( ) ;
} ) ;
2019-12-27 19:14:31 +02:00
//! used in order to disconnect it when it should NOT be called because it creates crashes
2019-12-28 13:59:36 +02:00
connect ( this , & View : : availableScreenRectChangedFrom , m_corona , & Latte : : Corona : : availableScreenRectChangedFrom ) ;
2019-12-27 19:14:31 +02:00
connect ( this , & View : : availableScreenRegionChangedFrom , m_corona , & Latte : : Corona : : availableScreenRegionChangedFrom ) ;
2020-01-04 19:35:57 +02:00
connect ( m_corona , & Latte : : Corona : : availableScreenRectChangedFrom , this , & View : : availableScreenRectChangedFromSlot ) ;
2020-05-09 12:26:33 +03:00
connect ( m_corona , & Latte : : Corona : : verticalUnityViewHasFocus , this , & View : : topViewAlwaysOnTop ) ;
2017-06-21 22:42:09 +03:00
2018-12-06 15:34:04 +02:00
connect ( this , & View : : byPassWMChanged , this , & View : : saveConfig ) ;
2018-12-06 12:15:58 +02:00
connect ( this , & View : : isPreferredForShortcutsChanged , this , & View : : saveConfig ) ;
2019-02-11 16:49:10 +02:00
connect ( this , & View : : onPrimaryChanged , this , & View : : saveConfig ) ;
connect ( this , & View : : typeChanged , this , & View : : saveConfig ) ;
2018-01-04 21:27:55 +02:00
2019-04-12 18:55:45 +03:00
connect ( this , & View : : normalThicknessChanged , this , [ & ] ( ) {
2019-12-28 13:59:36 +02:00
emit availableScreenRectChangedFrom ( this ) ;
2019-04-12 18:55:45 +03:00
} ) ;
2017-12-10 19:54:13 +02:00
2019-04-12 18:55:45 +03:00
connect ( m_effects , & ViewPart : : Effects : : innerShadowChanged , this , [ & ] ( ) {
2019-12-28 13:59:36 +02:00
emit availableScreenRectChangedFrom ( this ) ;
2019-04-12 18:55:45 +03:00
} ) ;
2018-12-06 12:15:58 +02:00
connect ( m_positioner , & ViewPart : : Positioner : : onHideWindowsForSlidingOut , this , & View : : hideWindowsForSlidingOut ) ;
connect ( m_positioner , & ViewPart : : Positioner : : screenGeometryChanged , this , & View : : screenGeometryChanged ) ;
2019-04-12 18:55:45 +03:00
connect ( m_positioner , & ViewPart : : Positioner : : windowSizeChanged , this , [ & ] ( ) {
2019-12-28 13:59:36 +02:00
emit availableScreenRectChangedFrom ( this ) ;
2019-04-12 18:55:45 +03:00
} ) ;
2018-12-06 12:15:58 +02:00
connect ( m_contextMenu , & ViewPart : : ContextMenu : : menuChanged , this , & View : : contextMenuIsShownChanged ) ;
2018-02-03 15:00:44 +02:00
2020-05-09 12:26:33 +03:00
connect ( m_interface , & ViewPart : : ContainmentInterface : : hasExpandedAppletChanged , this , & View : : verticalUnityViewHasFocus ) ;
2019-06-20 17:42:49 +03:00
//! View sends this signal in order to avoid crashes from ViewPart::Indicator when the view is recreated
2019-12-31 15:49:53 +02:00
connect ( m_corona - > indicatorFactory ( ) , & Latte : : Indicator : : Factory : : indicatorChanged , this , [ & ] ( const QString & indicatorId ) {
emit indicatorPluginChanged ( indicatorId ) ;
} ) ;
connect ( this , & View : : indicatorPluginChanged , this , [ & ] ( const QString & indicatorId ) {
2020-04-15 12:50:36 +03:00
if ( m_indicator & & m_indicator - > isCustomIndicator ( ) & & m_indicator - > type ( ) = = indicatorId ) {
2019-12-31 15:49:53 +02:00
reloadSource ( ) ;
}
} ) ;
connect ( m_corona - > indicatorFactory ( ) , & Latte : : Indicator : : Factory : : indicatorRemoved , this , & View : : indicatorPluginRemoved ) ;
2020-05-16 10:02:23 +03:00
connect ( m_corona - > universalSettings ( ) , & Latte : : UniversalSettings : : hiddenConfigurationWindowsAreDeletedChanged ,
this , & View : : hiddenConfigurationWindowsAreDeletedChanged ) ;
2019-12-31 15:49:53 +02:00
2020-05-02 13:23:37 +03:00
//! Assign app interfaces in be accessible through containment graphic item
QQuickItem * containmentGraphicItem = qobject_cast < QQuickItem * > ( plasma_containment - > property ( " _plasma_graphicObject " ) . value < QObject * > ( ) ) ;
2017-03-18 13:21:17 +02:00
2020-05-02 13:23:37 +03:00
if ( containmentGraphicItem ) {
containmentGraphicItem - > setProperty ( " _latte_globalShortcuts_object " , QVariant : : fromValue ( m_corona - > globalShortcuts ( ) - > shortcutsTracker ( ) ) ) ;
containmentGraphicItem - > setProperty ( " _latte_layoutsManager_object " , QVariant : : fromValue ( m_corona - > layoutsManager ( ) ) ) ;
containmentGraphicItem - > setProperty ( " _latte_themeExtended_object " , QVariant : : fromValue ( m_corona - > themeExtended ( ) ) ) ;
containmentGraphicItem - > setProperty ( " _latte_universalSettings_object " , QVariant : : fromValue ( m_corona - > universalSettings ( ) ) ) ;
containmentGraphicItem - > setProperty ( " _latte_view_object " , QVariant : : fromValue ( this ) ) ;
2020-05-12 14:45:31 +03:00
Latte : : Interfaces * ifacesGraphicObject = qobject_cast < Latte : : Interfaces * > ( containmentGraphicItem - > property ( " _latte_view_interfacesobject " ) . value < QObject * > ( ) ) ;
if ( ifacesGraphicObject ) {
ifacesGraphicObject - > updateView ( ) ;
setInterfacesGraphicObj ( ifacesGraphicObject ) ;
}
2017-03-18 13:21:17 +02:00
}
2016-12-30 16:25:27 -05:00
setSource ( corona ( ) - > kPackage ( ) . filePath ( " lattedockui " ) ) ;
2020-05-02 13:23:37 +03:00
2018-11-29 21:30:00 +02:00
m_positioner - > syncGeometry ( ) ;
2017-06-20 23:13:38 +03:00
2017-01-12 20:04:27 +02:00
qDebug ( ) < < " SOURCE: " < < source ( ) ;
2016-12-30 16:22:28 -05:00
}
2019-06-20 17:42:49 +03:00
void View : : reloadSource ( )
{
if ( m_layout & & containment ( ) ) {
if ( settingsWindowIsShown ( ) ) {
m_configView - > deleteLater ( ) ;
}
engine ( ) - > clearComponentCache ( ) ;
m_layout - > recreateView ( containment ( ) , settingsWindowIsShown ( ) ) ;
}
}
2020-05-16 10:02:23 +03:00
bool View : : hiddenConfigurationWindowsAreDeleted ( ) const
2020-05-15 12:56:57 +03:00
{
2020-05-16 10:02:23 +03:00
return m_corona - > universalSettings ( ) - > hiddenConfigurationWindowsAreDeleted ( ) ;
2020-05-15 12:56:57 +03:00
}
2019-06-20 17:42:49 +03:00
2018-12-06 12:15:58 +02:00
bool View : : inDelete ( ) const
2018-01-21 11:34:18 +02:00
{
2018-11-29 21:30:00 +02:00
return m_inDelete ;
2018-01-04 21:27:55 +02:00
}
2020-05-08 10:16:26 +03:00
bool View : : inReadyState ( ) const
{
return ( m_layout ! = nullptr ) ;
}
2017-12-10 19:54:13 +02:00
2018-12-06 12:15:58 +02:00
void View : : disconnectSensitiveSignals ( )
2018-01-11 21:11:46 +02:00
{
2020-03-07 18:30:22 +02:00
m_initLayoutTimer . stop ( ) ;
2019-12-28 13:59:36 +02:00
disconnect ( this , & View : : availableScreenRectChangedFrom , m_corona , & Latte : : Corona : : availableScreenRectChangedFrom ) ;
2019-12-27 19:14:31 +02:00
disconnect ( this , & View : : availableScreenRegionChangedFrom , m_corona , & Latte : : Corona : : availableScreenRegionChangedFrom ) ;
2019-12-28 13:59:36 +02:00
disconnect ( m_corona , & Latte : : Corona : : availableScreenRectChangedFrom , this , & View : : availableScreenRectChangedFromSlot ) ;
2020-05-09 12:26:33 +03:00
disconnect ( m_corona , & Latte : : Corona : : verticalUnityViewHasFocus , this , & View : : topViewAlwaysOnTop ) ;
2019-12-28 13:59:36 +02:00
2019-05-08 23:42:06 +03:00
setLayout ( nullptr ) ;
2018-01-11 21:11:46 +02:00
}
2019-12-28 13:59:36 +02:00
void View : : availableScreenRectChangedFromSlot ( View * origin )
2017-06-21 22:42:09 +03:00
{
2019-04-12 18:55:45 +03:00
if ( m_inDelete | | origin = = this )
2017-06-21 23:34:40 +03:00
return ;
2018-11-29 21:30:00 +02:00
if ( formFactor ( ) = = Plasma : : Types : : Vertical ) {
m_positioner - > syncGeometry ( ) ;
}
2019-04-12 18:55:45 +03:00
2017-06-21 22:42:09 +03:00
}
2018-12-06 12:15:58 +02:00
void View : : setupWaylandIntegration ( )
2017-04-25 19:18:49 +03:00
{
2017-06-15 16:56:55 -05:00
if ( m_shellSurface )
2017-04-25 19:18:49 +03:00
return ;
2018-12-06 14:35:34 +02:00
if ( Latte : : Corona * c = qobject_cast < Latte : : Corona * > ( corona ( ) ) ) {
2018-03-01 00:52:05 +02:00
using namespace KWayland : : Client ;
2018-12-06 14:35:34 +02:00
PlasmaShell * interface { c - > waylandCoronaInterface ( ) } ;
2017-04-25 19:18:49 +03:00
2017-06-15 16:56:55 -05:00
if ( ! interface )
2017-04-25 19:18:49 +03:00
return ;
2017-06-15 16:56:55 -05:00
Surface * s { Surface : : fromWindow ( this ) } ;
2017-04-25 19:18:49 +03:00
2017-06-15 16:56:55 -05:00
if ( ! s )
2017-04-25 19:18:49 +03:00
return ;
m_shellSurface = interface - > createSurface ( s , this ) ;
2018-03-01 01:31:17 +02:00
qDebug ( ) < < " WAYLAND dock window surface was created... " ;
2019-12-26 22:24:04 +02:00
if ( m_visibility ) {
m_visibility - > initViewFlags ( ) ;
}
2017-04-25 19:18:49 +03:00
}
}
2018-12-06 12:15:58 +02:00
KWayland : : Client : : PlasmaShellSurface * View : : surface ( )
2018-03-28 20:39:52 +03:00
{
return m_shellSurface ;
}
2017-03-02 18:07:29 +02:00
//! the main function which decides if this dock is at the
//! correct screen
2018-12-06 12:15:58 +02:00
void View : : reconsiderScreen ( )
2017-02-26 02:43:41 +02:00
{
2018-11-29 21:30:00 +02:00
m_positioner - > reconsiderScreen ( ) ;
2016-12-30 16:22:28 -05:00
}
2018-12-06 15:57:20 +02:00
void View : : copyView ( )
2017-06-05 23:52:49 +03:00
{
2019-05-08 23:42:06 +03:00
m_layout - > copyView ( containment ( ) ) ;
2017-06-05 23:52:49 +03:00
}
2018-12-06 15:57:20 +02:00
void View : : removeView ( )
2016-12-30 16:22:28 -05:00
{
2019-05-08 23:42:06 +03:00
if ( m_layout & & m_layout - > viewsCount ( ) > 1 ) {
2020-03-24 16:10:12 +02:00
m_inDelete = true ;
2017-02-12 10:02:01 +02:00
QAction * removeAct = this - > containment ( ) - > actions ( ) - > action ( QStringLiteral ( " remove " ) ) ;
2017-01-16 14:07:49 -05:00
2016-12-30 16:22:28 -05:00
if ( removeAct ) {
removeAct - > trigger ( ) ;
}
}
}
2018-12-06 12:15:58 +02:00
bool View : : settingsWindowIsShown ( )
2018-01-18 21:21:32 +02:00
{
2020-05-15 12:56:57 +03:00
auto cview = qobject_cast < ViewPart : : PrimaryConfigView * > ( m_configView ) ;
2020-05-16 10:02:23 +03:00
if ( hiddenConfigurationWindowsAreDeleted ( ) ) {
2020-05-15 12:56:57 +03:00
return ( cview ! = nullptr ) ;
} else if ( cview ) {
return cview - > isVisible ( ) ;
}
2018-01-18 21:21:32 +02:00
2020-05-15 12:56:57 +03:00
return false ;
2018-01-18 21:21:32 +02:00
}
2018-12-06 12:15:58 +02:00
void View : : showSettingsWindow ( )
2017-11-19 14:51:15 +02:00
{
2018-12-26 17:33:59 +02:00
if ( ! settingsWindowIsShown ( ) ) {
emit m_visibility - > mustBeShown ( ) ;
showConfigurationInterface ( containment ( ) ) ;
applyActivitiesToWindows ( ) ;
}
2017-11-19 14:51:15 +02:00
}
2019-03-08 23:43:08 +02:00
PlasmaQuick : : ConfigView * View : : configView ( )
{
return m_configView ;
}
2018-12-06 12:15:58 +02:00
void View : : showConfigurationInterface ( Plasma : : Applet * applet )
2016-12-30 16:22:28 -05:00
{
if ( ! applet | | ! applet - > containment ( ) )
return ;
2017-01-16 14:07:49 -05:00
2016-12-30 16:22:28 -05:00
Plasma : : Containment * c = qobject_cast < Plasma : : Containment * > ( applet ) ;
2017-01-16 14:07:49 -05:00
2018-02-09 19:22:04 +02:00
if ( m_configView & & c & & c - > isContainment ( ) & & c = = this - > containment ( ) ) {
if ( m_configView - > isVisible ( ) ) {
2019-07-15 19:39:21 +03:00
m_configView - > hide ( ) ;
2016-12-30 16:22:28 -05:00
} else {
2019-07-15 19:39:21 +03:00
m_configView - > show ( ) ;
2016-12-30 16:22:28 -05:00
}
2017-01-16 14:07:49 -05:00
2016-12-30 16:22:28 -05:00
return ;
2018-02-09 19:22:04 +02:00
} else if ( m_configView ) {
if ( m_configView - > applet ( ) = = applet ) {
2019-07-15 19:39:21 +03:00
m_configView - > show ( ) ;
2019-07-15 15:48:36 +03:00
2019-03-09 20:19:26 +02:00
if ( KWindowSystem : : isPlatformX11 ( ) ) {
m_configView - > requestActivate ( ) ;
}
2016-12-30 16:22:28 -05:00
return ;
} else {
2019-07-15 19:39:21 +03:00
m_configView - > hide ( ) ;
2016-12-30 16:22:28 -05:00
}
}
2017-01-16 14:07:49 -05:00
2017-01-11 16:29:11 +02:00
bool delayConfigView = false ;
2017-01-16 14:07:49 -05:00
2017-02-12 10:02:01 +02:00
if ( c & & containment ( ) & & c - > isContainment ( ) & & c - > id ( ) = = this - > containment ( ) - > id ( ) ) {
2018-12-09 00:06:14 +02:00
m_configView = new ViewPart : : PrimaryConfigView ( c , this ) ;
2017-01-11 16:29:11 +02:00
delayConfigView = true ;
2016-12-30 16:22:28 -05:00
} else {
2018-02-09 19:22:04 +02:00
m_configView = new PlasmaQuick : : ConfigView ( applet ) ;
2016-12-30 16:22:28 -05:00
}
2017-01-16 14:07:49 -05:00
2018-02-09 19:22:04 +02:00
m_configView . data ( ) - > init ( ) ;
2017-01-16 14:07:49 -05:00
2017-01-11 16:29:11 +02:00
if ( ! delayConfigView ) {
2019-07-15 19:39:21 +03:00
m_configView - > show ( ) ;
2017-01-11 16:29:11 +02:00
} else {
2017-01-11 16:33:10 +02:00
//add a timer for showing the configuration window the first time it is
2019-01-01 11:19:44 +02:00
//created in order to give the containment's layouts the time to
2017-01-11 16:33:10 +02:00
//calculate the window's height
2019-07-15 15:48:36 +03:00
QTimer : : singleShot ( 150 , [ this ] ( ) {
if ( m_configView ) {
2019-07-15 19:39:21 +03:00
m_configView - > show ( ) ;
2019-07-15 15:48:36 +03:00
}
} ) ;
2017-01-11 16:29:11 +02:00
}
2016-12-30 16:22:28 -05:00
}
2018-12-06 12:15:58 +02:00
QRect View : : localGeometry ( ) const
2017-03-09 15:49:24 +02:00
{
return m_localGeometry ;
}
2018-12-06 12:15:58 +02:00
void View : : setLocalGeometry ( const QRect & geometry )
2016-12-30 19:26:48 -05:00
{
2017-03-08 21:00:09 +02:00
if ( m_localGeometry = = geometry ) {
return ;
}
m_localGeometry = geometry ;
2017-03-09 15:49:24 +02:00
emit localGeometryChanged ( ) ;
2016-12-30 19:26:48 -05:00
}
2020-03-02 03:10:59 +02:00
QString View : : validTitle ( ) const
{
if ( ! containment ( ) ) {
return QString ( ) ;
}
return QString ( " #view# " + QString : : number ( containment ( ) - > id ( ) ) ) ;
}
2019-04-23 10:41:35 +03:00
void View : : updateAbsoluteGeometry ( bool bypassChecks )
2016-12-30 19:26:48 -05:00
{
2017-06-20 17:28:55 +03:00
//! there was a -1 in height and width here. The reason of this
//! if I remember correctly was related to multi-screen but I cant
2019-01-01 11:19:44 +02:00
//! remember exactly the reason, something related to right edge in
2017-06-20 17:28:55 +03:00
//! multi screen environment. BUT this was breaking the entire AlwaysVisible
//! experience with struts. Removing them in order to restore correct
//! behavior and keeping this comment in order to check for
//! multi-screen breakage
2020-03-19 12:45:23 +02:00
QRect absGeometry = m_localGeometry ;
absGeometry . moveLeft ( x ( ) + m_localGeometry . x ( ) ) ;
absGeometry . moveTop ( y ( ) + m_localGeometry . y ( ) ) ;
2017-02-10 22:12:17 -05:00
2020-03-19 12:45:23 +02:00
if ( behaveAsPlasmaPanel ( ) ) {
2020-03-19 15:32:36 +02:00
int currentScreenEdgeMargin = m_screenEdgeMarginEnabled ? qMax ( 0 , m_screenEdgeMargin ) : 0 ;
2020-03-19 13:47:04 +02:00
2020-01-22 00:11:37 +02:00
if ( location ( ) = = Plasma : : Types : : BottomEdge ) {
2020-03-19 13:47:04 +02:00
absGeometry . moveTop ( screenGeometry ( ) . bottom ( ) - currentScreenEdgeMargin - m_normalThickness ) ;
2020-01-22 00:11:37 +02:00
} else if ( location ( ) = = Plasma : : Types : : TopEdge ) {
2020-03-19 13:47:04 +02:00
absGeometry . moveTop ( screenGeometry ( ) . top ( ) + currentScreenEdgeMargin ) ;
2020-01-22 00:11:37 +02:00
} else if ( location ( ) = = Plasma : : Types : : LeftEdge ) {
2020-03-19 13:47:04 +02:00
absGeometry . moveLeft ( screenGeometry ( ) . left ( ) + currentScreenEdgeMargin ) ;
2020-01-22 00:11:37 +02:00
} else if ( location ( ) = = Plasma : : Types : : RightEdge ) {
2020-03-19 13:47:04 +02:00
absGeometry . moveLeft ( screenGeometry ( ) . right ( ) - currentScreenEdgeMargin - m_normalThickness ) ;
2020-01-22 00:11:37 +02:00
}
}
2019-04-23 10:41:35 +03:00
if ( m_absoluteGeometry = = absGeometry & & ! bypassChecks ) {
2017-01-12 18:55:43 -05:00
return ;
2019-04-23 10:41:35 +03:00
}
2017-01-16 14:07:49 -05:00
2019-04-23 10:41:35 +03:00
if ( m_absoluteGeometry ! = absGeometry ) {
m_absoluteGeometry = absGeometry ;
emit absoluteGeometryChanged ( m_absoluteGeometry ) ;
}
2017-12-24 20:54:45 +02:00
//! this is needed in order to update correctly the screenGeometries
2018-12-07 18:55:35 +02:00
if ( visibility ( ) & & corona ( ) & & visibility ( ) - > mode ( ) = = Types : : AlwaysVisible ) {
2019-04-23 10:41:35 +03:00
//! main use of BYPASSCKECKS is from Positioner when the view changes screens
2020-01-04 19:35:57 +02:00
2019-12-28 13:59:36 +02:00
emit availableScreenRectChangedFrom ( this ) ;
2019-12-27 19:14:31 +02:00
emit availableScreenRegionChangedFrom ( this ) ;
2017-12-24 20:54:45 +02:00
}
2016-12-30 19:26:48 -05:00
}
2018-12-06 12:15:58 +02:00
void View : : statusChanged ( Plasma : : Types : : ItemStatus status )
2017-01-14 01:59:25 +02:00
{
2020-04-05 14:40:32 +03:00
if ( ! containment ( ) ) {
return ;
}
if ( status = = Plasma : : Types : : NeedsAttentionStatus ) {
m_visibility - > addBlockHidingEvent ( BLOCKHIDINGNEEDSATTENTIONTYPE ) ;
2020-04-05 17:01:10 +03:00
m_visibility - > initViewFlags ( ) ;
2020-04-05 14:40:32 +03:00
} else if ( status = = Plasma : : Types : : AcceptingInputStatus ) {
m_visibility - > removeBlockHidingEvent ( BLOCKHIDINGNEEDSATTENTIONTYPE ) ;
setFlags ( flags ( ) & ~ Qt : : WindowDoesNotAcceptFocus ) ;
KWindowSystem : : forceActiveWindow ( winId ( ) ) ;
} else {
updateTransientWindowsTracking ( ) ;
m_visibility - > removeBlockHidingEvent ( BLOCKHIDINGNEEDSATTENTIONTYPE ) ;
2020-04-05 17:01:10 +03:00
m_visibility - > initViewFlags ( ) ;
}
2020-04-05 14:40:32 +03:00
}
void View : : addTransientWindow ( QWindow * window )
{
2020-05-11 17:44:30 +03:00
if ( ! m_transientWindows . contains ( window ) & & ! window - > title ( ) . startsWith ( " #debugwindow# " ) ) {
2020-04-05 14:40:32 +03:00
m_transientWindows . append ( window ) ;
QString winPtrStr = " 0x " + QString : : number ( ( qulonglong ) window , 16 ) ;
m_visibility - > addBlockHidingEvent ( winPtrStr ) ;
connect ( window , & QWindow : : visibleChanged , this , & View : : removeTransientWindow ) ;
}
}
void View : : removeTransientWindow ( const bool & visible )
{
QWindow * window = static_cast < QWindow * > ( QObject : : sender ( ) ) ;
if ( window & & ! visible ) {
QString winPtrStr = " 0x " + QString : : number ( ( qulonglong ) window , 16 ) ;
m_visibility - > removeBlockHidingEvent ( winPtrStr ) ;
disconnect ( window , & QWindow : : visibleChanged , this , & View : : removeTransientWindow ) ;
m_transientWindows . removeAll ( window ) ;
updateTransientWindowsTracking ( ) ;
}
}
void View : : updateTransientWindowsTracking ( )
{
for ( QWindow * window : qApp - > topLevelWindows ( ) ) {
if ( window - > transientParent ( ) = = this ) {
if ( window - > isVisible ( ) ) {
addTransientWindow ( window ) ;
break ;
}
2017-02-18 10:28:40 +02:00
}
2017-01-14 01:59:25 +02:00
}
}
2019-02-11 16:49:10 +02:00
Types : : ViewType View : : type ( ) const
{
return m_type ;
}
void View : : setType ( Types : : ViewType type )
{
if ( m_type = = type ) {
return ;
}
m_type = type ;
emit typeChanged ( ) ;
}
2018-12-06 12:15:58 +02:00
bool View : : alternativesIsShown ( ) const
2017-08-09 03:33:03 +03:00
{
return m_alternativesIsShown ;
}
2018-12-06 12:15:58 +02:00
void View : : setAlternativesIsShown ( bool show )
2017-08-09 03:33:03 +03:00
{
if ( m_alternativesIsShown = = show ) {
return ;
}
m_alternativesIsShown = show ;
emit alternativesIsShownChanged ( ) ;
}
2019-05-17 21:28:39 +03:00
bool View : : containsDrag ( ) const
{
return m_containsDrag ;
}
void View : : setContainsDrag ( bool contains )
{
if ( m_containsDrag = = contains ) {
return ;
}
m_containsDrag = contains ;
2020-04-05 14:40:32 +03:00
if ( m_containsDrag ) {
m_visibility - > addBlockHidingEvent ( BLOCKHIDINGDRAGTYPE ) ;
} else {
m_visibility - > removeBlockHidingEvent ( BLOCKHIDINGDRAGTYPE ) ;
}
2019-05-17 21:28:39 +03:00
emit containsDragChanged ( ) ;
}
2019-03-08 16:14:34 +02:00
bool View : : containsMouse ( ) const
{
return m_containsMouse ;
}
2018-12-06 12:15:58 +02:00
bool View : : contextMenuIsShown ( ) const
2017-07-27 18:24:31 +03:00
{
2018-12-02 00:53:40 +02:00
if ( ! m_contextMenu ) {
2018-02-03 15:00:44 +02:00
return false ;
}
2018-12-02 00:53:40 +02:00
return m_contextMenu - > menu ( ) ;
2017-07-27 18:24:31 +03:00
}
2018-12-06 12:15:58 +02:00
int View : : currentThickness ( ) const
2016-12-30 16:22:28 -05:00
{
2017-01-12 18:55:43 -05:00
if ( formFactor ( ) = = Plasma : : Types : : Vertical ) {
2018-12-01 00:52:05 +02:00
return m_effects - > mask ( ) . isNull ( ) ? width ( ) : m_effects - > mask ( ) . width ( ) - m_effects - > innerShadow ( ) ;
2016-12-30 16:22:28 -05:00
} else {
2018-12-01 00:52:05 +02:00
return m_effects - > mask ( ) . isNull ( ) ? height ( ) : m_effects - > mask ( ) . height ( ) - m_effects - > innerShadow ( ) ;
2016-12-30 16:22:28 -05:00
}
}
2018-12-06 12:15:58 +02:00
int View : : normalThickness ( ) const
2017-01-27 20:31:41 +02:00
{
return m_normalThickness ;
}
2018-12-06 12:15:58 +02:00
void View : : setNormalThickness ( int thickness )
2017-01-27 20:31:41 +02:00
{
if ( m_normalThickness = = thickness ) {
return ;
}
m_normalThickness = thickness ;
emit normalThicknessChanged ( ) ;
}
2020-05-11 17:31:03 +03:00
int View : : headThicknessGap ( ) const
{
return m_headThicknessGap ;
}
void View : : setHeadThicknessGap ( int thickness )
{
if ( m_headThicknessGap = = thickness ) {
return ;
}
m_headThicknessGap = thickness ;
emit headThicknessGapChanged ( ) ;
}
2018-12-06 15:34:04 +02:00
bool View : : byPassWM ( ) const
2017-03-18 23:32:27 +02:00
{
2018-12-06 15:34:04 +02:00
return m_byPassWM ;
2017-03-18 23:32:27 +02:00
}
2018-12-06 15:34:04 +02:00
void View : : setByPassWM ( bool bypass )
2017-03-18 23:32:27 +02:00
{
2018-12-06 15:34:04 +02:00
if ( m_byPassWM = = bypass ) {
2017-03-18 23:32:27 +02:00
return ;
}
2018-12-06 15:34:04 +02:00
m_byPassWM = bypass ;
emit byPassWMChanged ( ) ;
2017-03-18 23:32:27 +02:00
}
2018-12-06 12:15:58 +02:00
bool View : : behaveAsPlasmaPanel ( ) const
2017-01-31 21:25:00 +02:00
{
2017-05-07 15:06:29 +03:00
return m_behaveAsPlasmaPanel ;
2017-01-31 21:25:00 +02:00
}
2018-12-06 12:15:58 +02:00
void View : : setBehaveAsPlasmaPanel ( bool behavior )
2017-01-31 21:25:00 +02:00
{
2017-05-07 15:06:29 +03:00
if ( m_behaveAsPlasmaPanel = = behavior ) {
2017-01-31 21:25:00 +02:00
return ;
}
2017-05-07 15:06:29 +03:00
m_behaveAsPlasmaPanel = behavior ;
2017-01-31 21:25:00 +02:00
2017-05-07 15:06:29 +03:00
emit behaveAsPlasmaPanelChanged ( ) ;
}
2018-12-06 12:15:58 +02:00
bool View : : inEditMode ( ) const
2018-02-12 16:11:33 +02:00
{
return m_inEditMode ;
}
2018-12-06 12:15:58 +02:00
void View : : setInEditMode ( bool edit )
2018-02-12 16:11:33 +02:00
{
if ( m_inEditMode = = edit ) {
return ;
}
m_inEditMode = edit ;
emit inEditModeChanged ( ) ;
}
2020-01-04 13:52:11 +02:00
bool View : : isFloatingWindow ( ) const
{
return m_behaveAsPlasmaPanel & & m_screenEdgeMarginEnabled & & ( m_screenEdgeMargin > 0 ) ;
}
2018-12-06 12:15:58 +02:00
bool View : : isPreferredForShortcuts ( ) const
2018-09-22 20:21:57 +03:00
{
return m_isPreferredForShortcuts ;
}
2018-12-06 12:15:58 +02:00
void View : : setIsPreferredForShortcuts ( bool preferred )
2018-09-22 20:21:57 +03:00
{
if ( m_isPreferredForShortcuts = = preferred ) {
return ;
}
m_isPreferredForShortcuts = preferred ;
emit isPreferredForShortcutsChanged ( ) ;
2019-05-08 23:42:06 +03:00
if ( m_isPreferredForShortcuts & & m_layout ) {
emit m_layout - > preferredViewForShortcutsChanged ( this ) ;
2018-09-22 20:21:57 +03:00
}
}
2019-03-23 17:49:09 +02:00
bool View : : latteTasksArePresent ( ) const
{
return m_latteTasksArePresent ;
}
void View : : setLatteTasksArePresent ( bool present )
{
if ( m_latteTasksArePresent = = present ) {
return ;
}
m_latteTasksArePresent = present ;
emit latteTasksArePresentChanged ( ) ;
}
2020-04-23 21:57:17 +03:00
bool View : : inSettingsAdvancedMode ( ) const
{
if ( m_configView ) {
auto configView = qobject_cast < ViewPart : : PrimaryConfigView * > ( m_configView ) ;
if ( configView ) {
return configView - > inAdvancedMode ( ) ;
}
}
return false ;
}
2019-08-01 23:56:09 +03:00
bool View : : isTouchingBottomViewAndIsBusy ( ) const
2019-08-01 18:18:40 +03:00
{
2019-08-01 23:56:09 +03:00
return m_isTouchingBottomViewAndIsBusy ;
2019-08-01 18:18:40 +03:00
}
2019-08-01 23:56:09 +03:00
void View : : setIsTouchingBottomViewAndIsBusy ( bool touchAndBusy )
2019-08-01 18:18:40 +03:00
{
2019-08-01 23:56:09 +03:00
if ( m_isTouchingBottomViewAndIsBusy = = touchAndBusy ) {
2019-08-01 18:18:40 +03:00
return ;
}
2019-08-01 23:56:09 +03:00
m_isTouchingBottomViewAndIsBusy = touchAndBusy ;
2019-08-01 18:18:40 +03:00
2019-08-01 23:56:09 +03:00
emit isTouchingBottomViewAndIsBusyChanged ( ) ;
2019-08-01 18:18:40 +03:00
}
2019-08-01 23:56:09 +03:00
bool View : : isTouchingTopViewAndIsBusy ( ) const
2019-08-01 18:18:40 +03:00
{
2019-08-01 23:56:09 +03:00
return m_isTouchingTopViewAndIsBusy ;
2019-08-01 18:18:40 +03:00
}
2019-08-01 23:56:09 +03:00
void View : : setIsTouchingTopViewAndIsBusy ( bool touchAndBusy )
2019-08-01 18:18:40 +03:00
{
2019-08-01 23:56:09 +03:00
if ( m_isTouchingTopViewAndIsBusy = = touchAndBusy ) {
2019-08-01 18:18:40 +03:00
return ;
}
2019-08-01 23:56:09 +03:00
m_isTouchingTopViewAndIsBusy = touchAndBusy ;
emit isTouchingTopViewAndIsBusyChanged ( ) ;
2019-08-01 18:18:40 +03:00
}
2018-12-06 12:15:58 +02:00
void View : : preferredViewForShortcutsChangedSlot ( Latte : : View * view )
2018-09-22 20:21:57 +03:00
{
if ( view ! = this ) {
setIsPreferredForShortcuts ( false ) ;
}
}
2018-02-12 16:11:33 +02:00
2018-12-06 12:15:58 +02:00
bool View : : onPrimary ( ) const
2017-02-27 00:53:27 +02:00
{
return m_onPrimary ;
}
2018-12-06 12:15:58 +02:00
void View : : setOnPrimary ( bool flag )
2017-02-27 00:53:27 +02:00
{
2017-02-27 12:44:51 +02:00
if ( m_onPrimary = = flag ) {
2017-02-27 00:53:27 +02:00
return ;
}
m_onPrimary = flag ;
emit onPrimaryChanged ( ) ;
}
2018-12-06 12:15:58 +02:00
float View : : maxLength ( ) const
2017-01-31 21:25:00 +02:00
{
return m_maxLength ;
}
2018-12-06 12:15:58 +02:00
void View : : setMaxLength ( float length )
2017-01-31 21:25:00 +02:00
{
if ( m_maxLength = = length ) {
return ;
}
m_maxLength = length ;
emit maxLengthChanged ( ) ;
}
2019-03-06 20:10:36 +02:00
int View : : editThickness ( ) const
{
return m_editThickness ;
}
void View : : setEditThickness ( int thickness )
{
if ( m_editThickness = = thickness ) {
return ;
}
m_editThickness = thickness ;
emit editThicknessChanged ( ) ;
}
2018-12-06 12:15:58 +02:00
int View : : maxThickness ( ) const
2016-12-30 16:22:28 -05:00
{
return m_maxThickness ;
}
2018-12-06 12:15:58 +02:00
void View : : setMaxThickness ( int thickness )
2016-12-30 16:22:28 -05:00
{
if ( m_maxThickness = = thickness )
return ;
2017-01-16 14:07:49 -05:00
2016-12-30 16:22:28 -05:00
m_maxThickness = thickness ;
emit maxThicknessChanged ( ) ;
}
2018-12-06 12:15:58 +02:00
int View : : alignment ( ) const
2017-02-04 16:41:12 +02:00
{
2017-02-10 22:12:17 -05:00
return m_alignment ;
2017-02-04 16:41:12 +02:00
}
2018-12-06 12:15:58 +02:00
void View : : setAlignment ( int alignment )
2017-02-04 16:41:12 +02:00
{
2018-12-07 18:55:35 +02:00
Types : : Alignment align = static_cast < Types : : Alignment > ( alignment ) ;
2017-02-04 16:41:12 +02:00
2017-02-10 22:12:17 -05:00
if ( m_alignment = = alignment ) {
2017-02-04 16:41:12 +02:00
return ;
}
m_alignment = align ;
emit alignmentChanged ( ) ;
}
2019-04-23 10:41:35 +03:00
QRect View : : absoluteGeometry ( ) const
2017-02-10 22:12:17 -05:00
{
2019-04-23 10:41:35 +03:00
return m_absoluteGeometry ;
2017-02-10 22:12:17 -05:00
}
2018-12-06 12:15:58 +02:00
QRect View : : screenGeometry ( ) const
2017-02-26 15:49:50 +02:00
{
if ( this - > screen ( ) ) {
QRect geom = this - > screen ( ) - > geometry ( ) ;
return geom ;
}
return QRect ( ) ;
}
2020-04-29 09:54:16 +03:00
float View : : offset ( ) const
2017-04-09 01:06:48 +03:00
{
return m_offset ;
}
2020-04-29 09:54:16 +03:00
void View : : setOffset ( float offset )
2017-04-09 01:06:48 +03:00
{
if ( m_offset = = offset ) {
return ;
}
m_offset = offset ;
emit offsetChanged ( ) ;
}
2019-12-24 12:35:28 +02:00
bool View : : screenEdgeMarginEnabled ( ) const
{
2019-12-29 14:08:07 +02:00
return m_screenEdgeMarginEnabled ;
}
void View : : setScreenEdgeMarginEnabled ( bool enabled )
{
if ( m_screenEdgeMarginEnabled = = enabled ) {
return ;
}
m_screenEdgeMarginEnabled = enabled ;
emit screenEdgeMarginEnabledChanged ( ) ;
2019-12-24 12:35:28 +02:00
}
int View : : screenEdgeMargin ( ) const
{
return m_screenEdgeMargin ;
}
void View : : setScreenEdgeMargin ( int margin )
{
if ( m_screenEdgeMargin = = margin ) {
return ;
}
m_screenEdgeMargin = margin ;
emit screenEdgeMarginChanged ( ) ;
}
2018-12-06 12:15:58 +02:00
int View : : fontPixelSize ( ) const
2018-02-17 19:02:06 +02:00
{
return m_fontPixelSize ;
}
2018-12-06 12:15:58 +02:00
void View : : setFontPixelSize ( int size )
2018-02-17 19:02:06 +02:00
{
if ( m_fontPixelSize = = size ) {
return ;
}
m_fontPixelSize = size ;
emit fontPixelSizeChanged ( ) ;
}
2019-06-08 01:38:27 +03:00
bool View : : isOnAllActivities ( ) const
{
return m_activities . isEmpty ( ) | | m_activities [ 0 ] = = " 0 " ;
}
bool View : : isOnActivity ( const QString & activity ) const
{
return isOnAllActivities ( ) | | m_activities . contains ( activity ) ;
}
QStringList View : : activities ( ) const
{
2020-03-16 21:03:14 +02:00
QStringList running ;
QStringList runningAll = m_corona - > activitiesConsumer ( ) - > runningActivities ( ) ;
for ( int i = 0 ; i < m_activities . count ( ) ; + + i ) {
if ( runningAll . contains ( m_activities [ i ] ) ) {
running < < m_activities [ i ] ;
}
}
return running ;
2019-06-08 01:38:27 +03:00
}
2020-03-21 12:44:52 +02:00
void View : : setActivities ( const QStringList & ids )
{
if ( m_activities = = ids ) {
return ;
}
m_activities = ids ;
emit activitiesChanged ( ) ;
}
2018-12-06 12:15:58 +02:00
void View : : applyActivitiesToWindows ( )
2018-01-21 11:53:15 +02:00
{
2019-05-08 23:42:06 +03:00
if ( m_visibility & & m_layout ) {
2020-03-16 21:03:14 +02:00
QStringList runningActivities = activities ( ) ;
m_windowsTracker - > setWindowOnActivities ( * this , runningActivities ) ;
2018-01-21 11:53:15 +02:00
2020-05-11 23:04:44 +03:00
//! config windows
2018-01-21 11:53:15 +02:00
if ( m_configView ) {
2020-03-16 21:03:14 +02:00
m_windowsTracker - > setWindowOnActivities ( * m_configView , runningActivities ) ;
2018-01-21 11:53:15 +02:00
2018-12-09 00:06:14 +02:00
auto configView = qobject_cast < ViewPart : : PrimaryConfigView * > ( m_configView ) ;
2018-02-09 19:22:04 +02:00
if ( configView & & configView - > secondaryWindow ( ) ) {
2020-03-16 21:03:14 +02:00
m_windowsTracker - > setWindowOnActivities ( * configView - > secondaryWindow ( ) , runningActivities ) ;
2018-02-09 19:22:04 +02:00
}
2018-01-21 11:53:15 +02:00
}
2018-03-28 20:39:52 +03:00
2020-05-11 23:04:44 +03:00
//! hidden windows
2018-03-28 20:39:52 +03:00
if ( m_visibility - > supportsKWinEdges ( ) ) {
2020-03-16 21:03:14 +02:00
m_visibility - > applyActivitiesToHiddenWindows ( runningActivities ) ;
2018-03-28 20:39:52 +03:00
}
2018-01-21 11:53:15 +02:00
}
}
2020-05-11 23:04:44 +03:00
void View : : showHiddenViewFromActivityStopping ( )
{
if ( m_layout & & m_visibility & & ! inDelete ( ) & & ! isVisible ( ) & & ! m_visibility - > isHidden ( ) ) {
show ( ) ;
if ( m_effects ) {
m_effects - > updateEnabledBorders ( ) ;
}
//qDebug() << "View:: Enforce reshow from timer 1...";
emit forcedShown ( ) ;
} else if ( m_layout & & isVisible ( ) ) {
m_inDelete = false ;
//qDebug() << "View:: No needed reshow from timer 1...";
}
}
2019-05-08 23:42:06 +03:00
Layout : : GenericLayout * View : : layout ( ) const
2018-01-10 22:55:19 +02:00
{
2019-05-08 23:42:06 +03:00
return m_layout ;
2018-01-10 22:55:19 +02:00
}
2019-05-08 23:42:06 +03:00
void View : : setLayout ( Layout : : GenericLayout * layout )
2018-01-10 22:55:19 +02:00
{
2019-05-08 23:42:06 +03:00
if ( m_layout = = layout ) {
2018-01-10 22:55:19 +02:00
return ;
}
2018-01-20 00:34:55 +02:00
// clear mode
2019-05-08 23:42:06 +03:00
for ( auto & c : connectionsLayout ) {
2018-01-20 00:34:55 +02:00
disconnect ( c ) ;
}
2019-05-08 23:42:06 +03:00
m_layout = layout ;
2018-01-13 12:55:13 +02:00
2019-05-08 23:42:06 +03:00
if ( m_layout ) {
2019-05-09 23:45:52 +03:00
connectionsLayout < < connect ( containment ( ) , & Plasma : : Applet : : destroyedChanged , m_layout , & Layout : : GenericLayout : : destroyedChanged ) ;
connectionsLayout < < connect ( containment ( ) , & Plasma : : Applet : : locationChanged , m_corona , & Latte : : Corona : : viewLocationChanged ) ;
connectionsLayout < < connect ( containment ( ) , & Plasma : : Containment : : appletAlternativesRequested , m_corona , & Latte : : Corona : : showAlternativesForApplet , Qt : : QueuedConnection ) ;
2020-04-24 12:31:03 +03:00
if ( m_corona - > layoutsManager ( ) - > memoryUsage ( ) = = MemoryUsage : : MultipleLayouts ) {
2019-05-09 23:45:52 +03:00
connectionsLayout < < connect ( containment ( ) , & Plasma : : Containment : : appletCreated , m_layout , & Layout : : GenericLayout : : appletCreated ) ;
}
connectionsLayout < < connect ( m_positioner , & Latte : : ViewPart : : Positioner : : edgeChanged , m_layout , & Layout : : GenericLayout : : viewEdgeChanged ) ;
2018-01-14 17:30:29 +02:00
//! Sometimes the activity isnt completely ready, by adding a delay
//! we try to catch up
2020-03-07 18:30:22 +02:00
m_initLayoutTimer . setInterval ( 100 ) ;
m_initLayoutTimer . setSingleShot ( true ) ;
connectionsLayout < < connect ( & m_initLayoutTimer , & QTimer : : timeout , this , [ & ] ( ) {
2019-05-08 23:42:06 +03:00
if ( m_layout & & m_visibility ) {
2020-03-21 12:44:52 +02:00
setActivities ( m_layout - > appliedActivities ( ) ) ;
2019-06-08 01:38:27 +03:00
qDebug ( ) < < " DOCK VIEW FROM LAYOUT ::: " < < m_layout - > name ( ) < < " - activities: " < < m_activities ;
2018-01-14 17:30:29 +02:00
}
} ) ;
2020-03-07 18:30:22 +02:00
m_initLayoutTimer . start ( ) ;
2018-09-22 20:21:57 +03:00
2019-05-09 23:45:52 +03:00
connectionsLayout < < connect ( m_layout , & Layout : : GenericLayout : : preferredViewForShortcutsChanged , this , & View : : preferredViewForShortcutsChangedSlot ) ;
2020-05-15 12:56:57 +03:00
connectionsLayout < < connect ( m_layout , & Layout : : GenericLayout : : lastConfigViewForChanged , this , & View : : configViewShownFor ) ;
2018-01-14 09:39:31 +02:00
2019-04-08 18:57:32 +03:00
Latte : : Corona * latteCorona = qobject_cast < Latte : : Corona * > ( this - > corona ( ) ) ;
2018-01-14 09:39:31 +02:00
2020-03-21 12:44:52 +02:00
connectionsLayout < < connect ( latteCorona - > activitiesConsumer ( ) , & KActivities : : Consumer : : currentActivityChanged , this , [ & ] ( ) {
if ( m_layout & & m_visibility ) {
setActivities ( m_layout - > appliedActivities ( ) ) ;
applyActivitiesToWindows ( ) ;
2020-05-11 23:04:44 +03:00
showHiddenViewFromActivityStopping ( ) ;
2020-03-21 12:44:52 +02:00
qDebug ( ) < < " DOCK VIEW FROM LAYOUT (currentActivityChanged) ::: " < < m_layout - > name ( ) < < " - activities: " < < m_activities ;
}
} ) ;
2020-04-24 12:31:03 +03:00
if ( latteCorona - > layoutsManager ( ) - > memoryUsage ( ) = = MemoryUsage : : MultipleLayouts ) {
2019-05-09 23:45:52 +03:00
connectionsLayout < < connect ( latteCorona - > activitiesConsumer ( ) , & KActivities : : Consumer : : runningActivitiesChanged , this , [ & ] ( ) {
2019-05-08 23:42:06 +03:00
if ( m_layout & & m_visibility ) {
2020-03-21 12:44:52 +02:00
setActivities ( m_layout - > appliedActivities ( ) ) ;
2019-05-08 23:42:06 +03:00
qDebug ( ) < < " DOCK VIEW FROM LAYOUT (runningActivitiesChanged) ::: " < < m_layout - > name ( )
2019-06-08 01:38:27 +03:00
< < " - activities: " < < m_activities ;
2019-04-08 18:57:32 +03:00
}
} ) ;
2018-01-14 09:39:31 +02:00
2019-05-09 23:45:52 +03:00
connectionsLayout < < connect ( m_layout , & Layout : : GenericLayout : : activitiesChanged , this , [ & ] ( ) {
2019-05-08 23:42:06 +03:00
if ( m_layout ) {
2020-03-21 12:44:52 +02:00
setActivities ( m_layout - > appliedActivities ( ) ) ;
2019-04-08 18:57:32 +03:00
}
} ) ;
2018-01-14 12:22:45 +02:00
2019-05-09 23:45:52 +03:00
connectionsLayout < < connect ( latteCorona - > layoutsManager ( ) , & Layouts : : Manager : : layoutsChanged , this , [ & ] ( ) {
2019-05-08 23:42:06 +03:00
if ( m_layout ) {
2020-03-21 12:44:52 +02:00
setActivities ( m_layout - > appliedActivities ( ) ) ;
2019-04-08 18:57:32 +03:00
}
} ) ;
2018-01-15 19:44:00 +02:00
2019-05-07 22:06:00 +03:00
//! BEGIN OF KWIN HACK
//! IMPORTANT ::: Fixing KWin Faulty Behavior that KWin hides ALL Views when an Activity stops
//! with no reason!!
2019-05-14 17:12:36 +03:00
m_visibleHackTimer1 . setInterval ( 400 ) ;
m_visibleHackTimer2 . setInterval ( 2500 ) ;
2019-05-07 22:06:00 +03:00
m_visibleHackTimer1 . setSingleShot ( true ) ;
m_visibleHackTimer2 . setSingleShot ( true ) ;
2019-05-09 23:45:52 +03:00
connectionsLayout < < connect ( this , & QWindow : : visibleChanged , this , [ & ] ( ) {
2019-05-08 23:42:06 +03:00
if ( m_layout & & ! inDelete ( ) & ! isVisible ( ) ) {
2019-05-07 22:06:00 +03:00
m_visibleHackTimer1 . start ( ) ;
m_visibleHackTimer2 . start ( ) ;
2019-04-08 18:57:32 +03:00
}
} ) ;
2019-05-07 22:06:00 +03:00
2020-03-07 18:30:22 +02:00
connectionsLayout < < connect ( & m_visibleHackTimer1 , & QTimer : : timeout , this , [ & ] ( ) {
2020-01-04 19:57:54 +02:00
applyActivitiesToWindows ( ) ;
2020-05-11 23:04:44 +03:00
showHiddenViewFromActivityStopping ( ) ;
2020-01-04 19:57:54 +02:00
emit activitiesChanged ( ) ;
2019-05-07 22:06:00 +03:00
} ) ;
2019-05-09 23:45:52 +03:00
connectionsLayout < < connect ( & m_visibleHackTimer2 , & QTimer : : timeout , this , [ & ] ( ) {
2020-01-04 19:57:54 +02:00
applyActivitiesToWindows ( ) ;
2020-05-11 23:04:44 +03:00
showHiddenViewFromActivityStopping ( ) ;
2020-01-04 19:57:54 +02:00
emit activitiesChanged ( ) ;
2019-05-07 22:06:00 +03:00
} ) ;
//! END OF KWIN HACK
2019-04-08 18:57:32 +03:00
}
2018-01-13 12:55:13 +02:00
2019-05-08 23:42:06 +03:00
emit layoutChanged ( ) ;
2019-06-08 01:38:27 +03:00
} else {
m_activities . clear ( ) ;
2019-04-08 18:57:32 +03:00
}
2018-01-10 22:55:19 +02:00
}
2018-12-06 12:15:58 +02:00
void View : : moveToLayout ( QString layoutName )
2018-01-21 11:34:18 +02:00
{
2019-05-08 23:42:06 +03:00
if ( ! m_layout ) {
2018-01-21 11:34:18 +02:00
return ;
}
2019-05-08 23:42:06 +03:00
QList < Plasma : : Containment * > containments = m_layout - > unassignFromLayout ( this ) ;
2018-01-21 11:34:18 +02:00
2018-12-06 14:35:34 +02:00
Latte : : Corona * latteCorona = qobject_cast < Latte : : Corona * > ( this - > corona ( ) ) ;
2018-01-21 11:34:18 +02:00
2018-12-06 14:35:34 +02:00
if ( latteCorona & & containments . size ( ) > 0 ) {
2019-05-11 09:23:14 +03:00
Layout : : GenericLayout * newLayout = latteCorona - > layoutsManager ( ) - > synchronizer ( ) - > layout ( layoutName ) ;
2018-01-21 11:34:18 +02:00
if ( newLayout ) {
newLayout - > assignToLayout ( this , containments ) ;
}
}
}
2020-05-15 12:56:57 +03:00
void View : : configViewShownFor ( Latte : : View * view )
2019-03-09 14:24:52 +02:00
{
2019-05-25 17:40:29 +03:00
if ( view ! = this & & m_configView ) {
2019-03-09 14:24:52 +02:00
//! for each layout only one dock should show its configuration windows
//! otherwise we could reach a point that because a settings window
//! is below another Latte View its options are not reachable
2019-03-09 19:56:57 +02:00
auto configDialog = qobject_cast < ViewPart : : PrimaryConfigView * > ( m_configView ) ;
if ( configDialog ) {
2020-05-16 10:02:23 +03:00
if ( hiddenConfigurationWindowsAreDeleted ( ) ) {
2020-05-15 12:56:57 +03:00
configDialog - > deleteLater ( ) ;
} else if ( configDialog - > isVisible ( ) ) {
configDialog - > hideConfigWindow ( ) ;
}
2019-03-09 19:56:57 +02:00
}
2019-03-09 14:24:52 +02:00
}
}
2018-12-06 12:15:58 +02:00
void View : : hideWindowsForSlidingOut ( )
2018-12-01 00:13:11 +02:00
{
if ( m_configView ) {
2018-12-09 00:06:14 +02:00
auto configDialog = qobject_cast < ViewPart : : PrimaryConfigView * > ( m_configView ) ;
2018-12-01 00:13:11 +02:00
if ( configDialog ) {
configDialog - > hideConfigWindow ( ) ;
}
}
}
2017-04-11 12:10:54 +03:00
//! remove latte tasks plasmoid
2018-12-06 12:15:58 +02:00
void View : : removeTasksPlasmoid ( )
2017-04-11 12:10:54 +03:00
{
if ( ! tasksPresent ( ) | | ! containment ( ) ) {
return ;
}
2019-04-04 23:55:44 +03:00
for ( const Plasma : : Applet * applet : containment ( ) - > applets ( ) ) {
2017-04-11 12:10:54 +03:00
KPluginMetaData meta = applet - > kPackage ( ) . metadata ( ) ;
if ( meta . pluginId ( ) = = " org.kde.latte.plasmoid " ) {
QAction * closeApplet = applet - > actions ( ) - > action ( QStringLiteral ( " remove " ) ) ;
if ( closeApplet ) {
closeApplet - > trigger ( ) ;
//! remove only the first found
return ;
}
}
}
}
2017-03-02 18:07:29 +02:00
//! check if the tasks plasmoid exist in the dock
2018-12-06 12:15:58 +02:00
bool View : : tasksPresent ( )
2017-01-02 22:26:10 +02:00
{
2017-03-05 16:30:50 +02:00
if ( ! this - > containment ( ) ) {
return false ;
}
2019-04-04 23:55:44 +03:00
for ( const Plasma : : Applet * applet : this - > containment ( ) - > applets ( ) ) {
2017-07-28 17:04:09 +03:00
const auto & provides = KPluginMetaData : : readStringList ( applet - > pluginMetaData ( ) . rawData ( ) , QStringLiteral ( " X-Plasma-Provides " ) ) ;
2017-01-16 14:07:49 -05:00
2017-07-28 17:04:09 +03:00
if ( provides . contains ( QLatin1String ( " org.kde.plasma.multitasking " ) ) ) {
2017-01-02 22:26:10 +02:00
return true ;
2017-07-28 17:04:09 +03:00
}
2017-01-02 22:26:10 +02:00
}
2017-01-16 14:07:49 -05:00
2017-01-02 22:26:10 +02:00
return false ;
}
2017-06-11 18:06:03 +03:00
//!check if the plasmoid with _name_ exists in the midedata
2018-12-06 12:15:58 +02:00
bool View : : mimeContainsPlasmoid ( QMimeData * mimeData , QString name )
2017-06-11 18:06:03 +03:00
{
if ( ! mimeData ) {
return false ;
}
if ( mimeData - > hasFormat ( QStringLiteral ( " text/x-plasmoidservicename " ) ) ) {
QString data = mimeData - > data ( QStringLiteral ( " text/x-plasmoidservicename " ) ) ;
const QStringList appletNames = data . split ( ' \n ' , QString : : SkipEmptyParts ) ;
2019-04-04 23:55:44 +03:00
for ( const QString & appletName : appletNames ) {
2017-06-11 18:06:03 +03:00
if ( appletName = = name )
return true ;
}
}
return false ;
}
2018-12-06 12:15:58 +02:00
ViewPart : : Effects * View : : effects ( ) const
2018-11-30 21:33:46 +02:00
{
return m_effects ;
}
2019-03-23 17:49:09 +02:00
ViewPart : : Indicator * View : : indicator ( ) const
{
return m_indicator ;
}
2020-04-08 14:34:05 +03:00
ViewPart : : ContainmentInterface * View : : extendedInterface ( ) const
2019-12-21 18:53:02 +02:00
{
return m_interface ;
}
2018-12-06 12:15:58 +02:00
ViewPart : : Positioner * View : : positioner ( ) const
2018-11-29 21:30:00 +02:00
{
return m_positioner ;
}
2017-06-11 18:06:03 +03:00
2018-12-09 00:29:35 +02:00
ViewPart : : VisibilityManager * View : : visibility ( ) const
2016-12-30 16:22:28 -05:00
{
return m_visibility ;
}
2019-02-07 19:15:25 +02:00
ViewPart : : WindowsTracker * View : : windowsTracker ( ) const
{
return m_windowsTracker ;
}
2020-05-12 14:45:31 +03:00
Latte : : Interfaces * View : : interfacesGraphicObj ( ) const
{
return m_interfacesGraphicObj ;
}
void View : : setInterfacesGraphicObj ( Latte : : Interfaces * ifaces )
{
if ( m_interfacesGraphicObj = = ifaces ) {
return ;
}
m_interfacesGraphicObj = ifaces ;
if ( containment ( ) ) {
QQuickItem * containmentGraphicItem = qobject_cast < QQuickItem * > ( containment ( ) - > property ( " _plasma_graphicObject " ) . value < QObject * > ( ) ) ;
if ( containmentGraphicItem ) {
containmentGraphicItem - > setProperty ( " _latte_view_interfacesobject " , QVariant : : fromValue ( m_interfacesGraphicObj ) ) ;
}
}
emit interfacesGraphicObjChanged ( ) ;
}
2018-12-06 12:15:58 +02:00
bool View : : event ( QEvent * e )
2019-04-14 13:25:16 +03:00
{
2017-06-21 23:34:40 +03:00
if ( ! m_inDelete ) {
emit eventTriggered ( e ) ;
2017-01-31 21:25:00 +02:00
2017-06-21 23:34:40 +03:00
switch ( e - > type ( ) ) {
2019-03-23 17:49:09 +02:00
case QEvent : : Enter :
m_containsMouse = true ;
2019-03-09 23:08:24 +02:00
2019-04-01 23:50:25 +03:00
if ( m_configView ) {
2019-03-23 17:49:09 +02:00
ViewPart : : PrimaryConfigView * primaryConfigView = qobject_cast < ViewPart : : PrimaryConfigView * > ( m_configView ) ;
2019-03-09 23:08:24 +02:00
2019-03-23 17:49:09 +02:00
if ( primaryConfigView ) {
if ( primaryConfigView - > secondaryWindow ( ) ) {
2019-04-01 23:50:25 +03:00
ViewPart : : SecondaryConfigView * secConfigView = qobject_cast < ViewPart : : SecondaryConfigView * > ( primaryConfigView - > secondaryWindow ( ) ) ;
if ( secConfigView ) {
secConfigView - > requestActivate ( ) ;
}
2019-03-09 23:08:24 +02:00
}
2019-03-23 17:49:09 +02:00
primaryConfigView - > requestActivate ( ) ;
2019-03-09 00:11:39 +02:00
}
2019-03-23 17:49:09 +02:00
}
break ;
case QEvent : : Leave :
m_containsMouse = false ;
2019-05-17 21:49:31 +03:00
setContainsDrag ( false ) ;
2019-03-23 17:49:09 +02:00
engine ( ) - > trimComponentCache ( ) ;
break ;
2019-05-17 21:28:39 +03:00
case QEvent : : DragEnter :
setContainsDrag ( true ) ;
break ;
case QEvent : : DragLeave :
2019-05-25 14:46:19 +03:00
case QEvent : : Drop :
2019-05-17 21:28:39 +03:00
setContainsDrag ( false ) ;
break ;
2019-04-14 13:25:16 +03:00
case QEvent : : MouseButtonPress :
if ( auto mouseEvent = dynamic_cast < QMouseEvent * > ( e ) ) {
2019-04-17 20:17:28 +03:00
emit mousePressed ( mouseEvent - > pos ( ) , mouseEvent - > button ( ) ) ;
2019-04-14 13:25:16 +03:00
}
break ;
case QEvent : : MouseButtonRelease :
if ( auto mouseEvent = dynamic_cast < QMouseEvent * > ( e ) ) {
2019-04-17 20:17:28 +03:00
emit mouseReleased ( mouseEvent - > pos ( ) , mouseEvent - > button ( ) ) ;
2019-04-14 13:25:16 +03:00
}
break ;
2020-03-07 18:30:22 +02:00
/* case QEvent::DragMove:
2019-05-16 23:20:51 +03:00
qDebug ( ) < < " DRAG MOVING>>>>>> " ;
break ; */
2019-03-23 17:49:09 +02:00
case QEvent : : PlatformSurface :
if ( auto pe = dynamic_cast < QPlatformSurfaceEvent * > ( e ) ) {
switch ( pe - > surfaceEventType ( ) ) {
case QPlatformSurfaceEvent : : SurfaceCreated :
setupWaylandIntegration ( ) ;
if ( m_shellSurface ) {
m_positioner - > syncGeometry ( ) ;
m_effects - > updateShadows ( ) ;
2017-06-21 23:34:40 +03:00
}
2019-03-23 17:49:09 +02:00
break ;
case QPlatformSurfaceEvent : : SurfaceAboutToBeDestroyed :
if ( m_shellSurface ) {
delete m_shellSurface ;
m_shellSurface = nullptr ;
qDebug ( ) < < " WAYLAND dock window surface was deleted... " ;
m_effects - > clearShadows ( ) ;
}
break ;
2017-04-25 19:18:49 +03:00
}
2019-03-23 17:49:09 +02:00
}
2017-04-25 19:18:49 +03:00
2019-03-23 17:49:09 +02:00
break ;
2017-04-25 19:18:49 +03:00
2019-05-11 16:06:53 +03:00
case QEvent : : Show :
2019-12-26 21:58:21 +02:00
if ( m_visibility ) {
m_visibility - > initViewFlags ( ) ;
}
2019-05-11 16:06:53 +03:00
break ;
2020-01-31 17:59:08 +02:00
case QEvent : : Wheel :
if ( auto wheelEvent = dynamic_cast < QWheelEvent * > ( e ) ) {
2020-02-01 17:56:53 +02:00
# if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
2020-02-01 17:46:08 +02:00
QPoint position = QPoint ( wheelEvent - > x ( ) , wheelEvent - > y ( ) ) ;
# else
QPoint position = wheelEvent - > position ( ) . toPoint ( ) ;
# endif
emit wheelScrolled ( position , wheelEvent - > angleDelta ( ) , wheelEvent - > buttons ( ) ) ;
2020-01-31 17:59:08 +02:00
}
break ;
2019-03-23 17:49:09 +02:00
default :
break ;
2017-06-21 23:34:40 +03:00
}
2017-04-25 19:18:49 +03:00
}
2019-05-01 17:39:52 +03:00
return ContainmentView : : event ( e ) ;
2016-12-30 16:22:28 -05:00
}
2019-08-26 01:22:22 +03:00
//! release grab and restore mouse state
void View : : unblockMouse ( int x , int y )
{
setMouseGrabEnabled ( false ) ;
m_releaseGrab_x = x ;
m_releaseGrab_y = y ;
m_releaseGrabTimer . start ( ) ;
}
void View : : releaseGrab ( )
{
//! ungrab mouse
if ( mouseGrabberItem ( ) ) {
mouseGrabberItem ( ) - > ungrabMouse ( ) ;
}
//! properly release grabbed mouse in order to inform all views
setMouseGrabEnabled ( true ) ;
setMouseGrabEnabled ( false ) ;
//! Send a fake QEvent::Leave to inform applets for mouse leaving the view
QHoverEvent e ( QEvent : : Leave , QPoint ( - 5 , - 5 ) , QPoint ( m_releaseGrab_x , m_releaseGrab_y ) ) ;
QCoreApplication : : instance ( ) - > sendEvent ( this , & e ) ;
}
2018-12-06 12:15:58 +02:00
QVariantList View : : containmentActions ( )
2017-01-02 12:02:35 +02:00
{
QVariantList actions ;
/*if (containment()->corona()->immutability() != Plasma::Types::Mutable) {
return actions ;
} */
//FIXME: the trigger string it should be better to be supported this way
//const QString trigger = Plasma::ContainmentActions::eventToString(event);
const QString trigger = " RightButton;NoModifier " ;
2017-02-12 10:02:01 +02:00
Plasma : : ContainmentActions * plugin = this - > containment ( ) - > containmentActions ( ) . value ( trigger ) ;
2017-01-16 14:07:49 -05:00
2017-01-02 12:02:35 +02:00
if ( ! plugin ) {
return actions ;
}
2017-01-16 14:07:49 -05:00
2017-02-12 10:02:01 +02:00
if ( plugin - > containment ( ) ! = this - > containment ( ) ) {
plugin - > setContainment ( this - > containment ( ) ) ;
2017-01-02 12:02:35 +02:00
// now configure it
2017-02-12 10:02:01 +02:00
KConfigGroup cfg ( this - > containment ( ) - > corona ( ) - > config ( ) , " ActionPlugins " ) ;
cfg = KConfigGroup ( & cfg , QString : : number ( this - > containment ( ) - > containmentType ( ) ) ) ;
2017-01-02 12:02:35 +02:00
KConfigGroup pluginConfig = KConfigGroup ( & cfg , trigger ) ;
plugin - > restore ( pluginConfig ) ;
}
2017-01-16 14:07:49 -05:00
2019-04-04 23:55:44 +03:00
for ( QAction * ac : plugin - > contextualActions ( ) ) {
2017-01-02 12:02:35 +02:00
actions < < QVariant : : fromValue < QAction * > ( ac ) ;
}
2017-01-16 14:07:49 -05:00
2017-01-02 12:02:35 +02:00
return actions ;
}
2017-01-12 18:55:43 -05:00
2019-02-06 18:15:59 +02:00
bool View : : isHighestPriorityView ( ) {
2019-05-08 23:42:06 +03:00
if ( m_layout ) {
return this = = m_layout - > highestPriorityView ( ) ;
2019-02-06 18:15:59 +02:00
}
2019-02-07 09:38:01 +02:00
2019-02-06 18:15:59 +02:00
return false ;
}
2020-05-09 12:26:33 +03:00
//! BEGIN: WORKAROUND order to force top panels always on top and above left/right panels
void View : : topViewAlwaysOnTop ( )
{
if ( ! m_visibility ) {
return ;
}
if ( location ( ) = = Plasma : : Types : : TopEdge
& & m_visibility - > mode ( ) ! = Latte : : Types : : WindowsCanCover
& & m_visibility - > mode ( ) ! = Latte : : Types : : WindowsAlwaysCover ) {
//! this is needed in order to preserve that the top dock will be above others.
//! Unity layout paradigm is a good example for this. The top panel shadow
//! should be always on top compared to left panel
m_visibility - > setViewOnFrontLayer ( ) ;
}
}
void View : : verticalUnityViewHasFocus ( )
{
if ( formFactor ( ) = = Plasma : : Types : : Vertical
& & ( y ( ) ! = screenGeometry ( ) . y ( ) )
& & ( ( m_alignment = = Latte : : Types : : Justify & & m_maxLength = = 1.0 )
| | ( m_alignment = = Latte : : Types : : Top & & m_offset = = 0.0 ) ) ) {
emit m_corona - > verticalUnityViewHasFocus ( ) ;
}
}
//! END: WORKAROUND
2017-01-03 15:33:30 +02:00
//!BEGIN overriding context menus behavior
2018-12-06 12:15:58 +02:00
void View : : mousePressEvent ( QMouseEvent * event )
2017-01-03 15:33:30 +02:00
{
2018-12-02 00:53:40 +02:00
bool result = m_contextMenu - > mousePressEvent ( event ) ;
2018-01-17 16:45:29 +02:00
2018-02-03 15:00:44 +02:00
if ( result ) {
PlasmaQuick : : ContainmentView : : mousePressEvent ( event ) ;
2020-04-05 14:40:32 +03:00
updateTransientWindowsTracking ( ) ;
2017-01-27 20:03:24 +02:00
}
2020-05-09 12:26:33 +03:00
verticalUnityViewHasFocus ( ) ;
2017-01-27 20:03:24 +02:00
}
2017-01-03 15:33:30 +02:00
//!END overriding context menus behavior
2017-01-02 12:02:35 +02:00
2017-02-27 00:53:27 +02:00
//!BEGIN configuration functions
2018-12-06 12:15:58 +02:00
void View : : saveConfig ( )
2017-02-27 00:53:27 +02:00
{
if ( ! this - > containment ( ) )
return ;
auto config = this - > containment ( ) - > config ( ) ;
2018-09-04 19:38:54 +03:00
config . writeEntry ( " onPrimary " , onPrimary ( ) ) ;
2018-12-06 15:34:04 +02:00
config . writeEntry ( " byPassWM " , byPassWM ( ) ) ;
2018-09-22 20:21:57 +03:00
config . writeEntry ( " isPreferredForShortcuts " , isPreferredForShortcuts ( ) ) ;
2019-02-11 16:49:10 +02:00
config . writeEntry ( " viewType " , ( int ) m_type ) ;
2017-02-27 00:53:27 +02:00
}
2018-12-06 12:15:58 +02:00
void View : : restoreConfig ( )
2017-02-27 00:53:27 +02:00
{
if ( ! this - > containment ( ) )
return ;
auto config = this - > containment ( ) - > config ( ) ;
2018-09-04 19:38:54 +03:00
m_onPrimary = config . readEntry ( " onPrimary " , true ) ;
2018-12-06 15:34:04 +02:00
m_byPassWM = config . readEntry ( " byPassWM " , false ) ;
2018-09-22 20:21:57 +03:00
m_isPreferredForShortcuts = config . readEntry ( " isPreferredForShortcuts " , false ) ;
2018-09-04 19:38:54 +03:00
//! Send changed signals at the end in order to be sure that saveConfig
//! wont rewrite default/invalid values
emit onPrimaryChanged ( ) ;
2018-12-06 15:34:04 +02:00
emit byPassWMChanged ( ) ;
2017-02-27 00:53:27 +02:00
}
//!END configuration functions
2016-12-30 16:22:28 -05:00
}
//!END namespace