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
2016-12-30 16:25:27 -05:00
# include "dockview.h"
2018-02-03 11:34:13 +02:00
2016-12-30 16:25:27 -05:00
# include "dockconfigview.h"
2018-02-03 15:00:44 +02:00
# include "dockmenumanager.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-02-03 11:34:13 +02:00
# include "../dockcorona.h"
# include "../layout.h"
# include "../layoutmanager.h"
# include "../screenpool.h"
2018-10-26 23:36:40 +03:00
# include "../plasmathemeextended.h"
2018-02-03 11:34:13 +02:00
# include "../universalsettings.h"
# include "../../liblattedock/extras.h"
2016-12-30 16:22:28 -05:00
# include <QAction>
# 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
# include <KActionCollection>
2018-01-14 09:39:31 +02:00
# include <KActivities/Consumer>
2018-12-01 15:46:49 +02:00
# include <KWindowSystem>
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
2017-04-25 19:18:49 +03:00
# include <KWayland/Client/plasmashell.h>
# include <KWayland/Client/surface.h>
2016-12-30 16:22:28 -05:00
namespace Latte {
2017-03-18 23:32:27 +02:00
//! both alwaysVisible and dockWinBehavior are passed through corona because
2018-08-30 08:47:53 +03:00
//! during the dock 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
2017-04-09 13:42:39 -05:00
DockView : : DockView ( Plasma : : Corona * corona , QScreen * targetScreen , bool dockWindowBehavior )
2017-01-03 15:33:30 +02:00
: PlasmaQuick : : ContainmentView ( corona ) ,
2018-11-29 21:30:00 +02:00
m_menuManager ( new DockMenuManager ( this ) ) ,
2018-11-30 21:33:46 +02:00
m_effects ( new View : : Effects ( this ) ) ,
2018-12-01 00:13:11 +02:00
m_positioner ( new View : : Positioner ( this ) ) //needs to be created after Effects becuase it catches some of its signals
2017-02-27 02:36:30 -05:00
{
2016-12-30 16:22:28 -05: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 ) ) ;
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
2017-04-11 12:10:54 +03:00
| Qt : : WindowStaysOnTopHint
| Qt : : NoDropShadowWindowHint
| Qt : : WindowDoesNotAcceptFocus ;
2017-04-09 13:42:39 -05:00
if ( dockWindowBehavior ) {
setFlags ( flags ) ;
2017-03-08 21:00:09 +02:00
} else {
2017-04-09 13:42:39 -05:00
setFlags ( flags | Qt : : BypassWindowManagerHint ) ;
2017-03-08 21:00:09 +02:00
}
2017-01-16 14:07:49 -05:00
2017-03-29 14:32:32 +03:00
KWindowSystem : : setOnAllDesktops ( winId ( ) , true ) ;
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
2016-12-30 16:25:27 -05:00
connect ( this , & DockView : : containmentChanged
2017-07-29 23:07:00 +03:00
, this , [ & , dockWindowBehavior ] ( ) {
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... " ;
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
2017-07-29 23:07:00 +03:00
setDockWinBehavior ( dockWindowBehavior ) ;
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
2016-12-30 16:22:28 -05:00
if ( ! m_visibility ) {
m_visibility = new VisibilityManager ( this ) ;
2018-02-25 20:00:23 +02:00
connect ( m_visibility , & VisibilityManager : : isHiddenChanged , this , [ & ] ( ) {
if ( m_visibility - > isHidden ( ) ) {
deactivateApplets ( ) ;
}
} ) ;
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
2017-01-16 13:24:46 -05:00
auto * dockCorona = qobject_cast < DockCorona * > ( this - > corona ( ) ) ;
2017-01-16 14:07:49 -05:00
2017-01-22 13:29:40 +02:00
if ( dockCorona ) {
connect ( dockCorona , & DockCorona : : dockLocationChanged , this , & DockView : : dockLocationChanged ) ;
}
2016-12-30 16:22:28 -05:00
}
2016-12-30 16:25:27 -05:00
DockView : : ~ DockView ( )
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
2017-06-21 22:42:09 +03:00
disconnect ( corona ( ) , & Plasma : : Corona : : availableScreenRectChanged , this , & DockView : : availableScreenRectChanged ) ;
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-22 00:40:16 +02:00
rootContext ( ) - > setContextProperty ( QStringLiteral ( " dock " ) , nullptr ) ;
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
//! dockView is deleted. A crash for this example is the following:
//! 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 ) {
2017-06-21 17:14:13 +03:00
m_configView - > setVisible ( false ) ; //hide();
2018-01-18 21:21:32 +02:00
}
2018-02-03 15:00:44 +02:00
if ( m_menuManager ) {
2018-11-30 21:33:46 +02:00
delete m_menuManager ;
2018-02-03 15:00:44 +02:00
}
2018-11-30 21:33:46 +02:00
//needs to be deleted before Effects becuase 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 ;
}
if ( m_visibility )
delete m_visibility ;
2016-12-30 16:22:28 -05:00
}
2016-12-30 16:25:27 -05:00
void DockView : : init ( )
2016-12-30 16:22:28 -05:00
{
2017-02-26 15:49:50 +02:00
connect ( this , & QQuickWindow : : xChanged , this , & DockView : : xChanged ) ;
2017-03-08 21:00:09 +02:00
connect ( this , & QQuickWindow : : xChanged , this , & DockView : : updateAbsDockGeometry ) ;
2017-02-26 15:49:50 +02:00
connect ( this , & QQuickWindow : : yChanged , this , & DockView : : yChanged ) ;
2017-03-08 21:00:09 +02:00
connect ( this , & QQuickWindow : : yChanged , this , & DockView : : updateAbsDockGeometry ) ;
2017-01-12 18:55:43 -05:00
connect ( this , & QQuickWindow : : widthChanged , this , & DockView : : widthChanged ) ;
2017-03-08 21:00:09 +02:00
connect ( this , & QQuickWindow : : widthChanged , this , & DockView : : updateAbsDockGeometry ) ;
2017-01-12 18:55:43 -05:00
connect ( this , & QQuickWindow : : heightChanged , this , & DockView : : heightChanged ) ;
2017-03-08 21:00:09 +02:00
connect ( this , & QQuickWindow : : heightChanged , this , & DockView : : updateAbsDockGeometry ) ;
2017-06-21 22:42:09 +03:00
connect ( corona ( ) , & Plasma : : Corona : : availableScreenRectChanged , this , & DockView : : availableScreenRectChanged ) ;
2018-12-01 00:13:11 +02:00
connect ( m_positioner , & View : : Positioner : : onHideWindowsForSlidingOut , this , & DockView : : hideWindowsForSlidingOut ) ;
connect ( m_positioner , & View : : Positioner : : screenGeometryChanged , this , & DockView : : screenGeometryChanged ) ;
2018-11-29 21:30:00 +02:00
2017-03-18 23:32:27 +02:00
connect ( this , & DockView : : dockWinBehaviorChanged , this , & DockView : : saveConfig ) ;
2017-02-27 00:53:27 +02:00
connect ( this , & DockView : : onPrimaryChanged , this , & DockView : : saveConfig ) ;
2018-09-22 20:21:57 +03:00
connect ( this , & DockView : : isPreferredForShortcutsChanged , this , & DockView : : saveConfig ) ;
2018-01-04 21:27:55 +02:00
2017-03-05 16:38:17 +02:00
connect ( this , SIGNAL ( normalThicknessChanged ( ) ) , corona ( ) , SIGNAL ( availableScreenRectChanged ( ) ) ) ;
2017-12-10 19:54:13 +02:00
2018-02-03 15:00:44 +02:00
connect ( m_menuManager , & DockMenuManager : : contextMenuChanged , this , & DockView : : contextMenuIsShownChanged ) ;
2017-12-10 19:54:13 +02:00
///!!!!!
2017-01-12 18:55:43 -05:00
rootContext ( ) - > setContextProperty ( QStringLiteral ( " dock " ) , this ) ;
2017-03-18 13:21:17 +02:00
auto * dockCorona = qobject_cast < DockCorona * > ( this - > corona ( ) ) ;
if ( dockCorona ) {
2017-07-03 19:04:37 +03:00
rootContext ( ) - > setContextProperty ( QStringLiteral ( " universalSettings " ) , dockCorona - > universalSettings ( ) ) ;
rootContext ( ) - > setContextProperty ( QStringLiteral ( " layoutManager " ) , dockCorona - > layoutManager ( ) ) ;
2018-10-26 23:36:40 +03:00
rootContext ( ) - > setContextProperty ( QStringLiteral ( " themeExtended " ) , dockCorona - > themeExtended ( ) ) ;
2017-03-18 13:21:17 +02:00
}
2016-12-30 16:25:27 -05:00
setSource ( corona ( ) - > kPackage ( ) . filePath ( " lattedockui " ) ) ;
2017-06-20 23:13:38 +03:00
// setVisible(true);
2018-11-29 21:30:00 +02:00
m_positioner - > syncGeometry ( ) ;
2017-06-20 23:13:38 +03:00
if ( ! KWindowSystem : : isPlatformWayland ( ) ) {
setVisible ( true ) ;
}
2017-01-12 20:04:27 +02:00
qDebug ( ) < < " SOURCE: " < < source ( ) ;
2016-12-30 16:22:28 -05:00
}
2018-11-29 21:30:00 +02:00
bool DockView : : 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
}
2017-12-10 19:54:13 +02:00
2018-01-11 21:11:46 +02:00
void DockView : : disconnectSensitiveSignals ( )
{
disconnect ( corona ( ) , & Plasma : : Corona : : availableScreenRectChanged , this , & DockView : : availableScreenRectChanged ) ;
2018-01-14 09:39:31 +02:00
setManagedLayout ( nullptr ) ;
2018-01-11 21:11:46 +02:00
if ( visibility ( ) ) {
visibility ( ) - > setEnabledDynamicBackground ( false ) ;
}
}
2017-06-21 22:42:09 +03:00
void DockView : : availableScreenRectChanged ( )
{
2017-06-21 23:34:40 +03:00
if ( m_inDelete )
return ;
2018-11-29 21:30:00 +02:00
if ( formFactor ( ) = = Plasma : : Types : : Vertical ) {
m_positioner - > syncGeometry ( ) ;
}
2017-06-21 22:42:09 +03:00
}
2017-04-25 19:18:49 +03:00
void DockView : : setupWaylandIntegration ( )
{
2017-06-15 16:56:55 -05:00
if ( m_shellSurface )
2017-04-25 19:18:49 +03:00
return ;
if ( DockCorona * c = qobject_cast < DockCorona * > ( corona ( ) ) ) {
2018-03-01 00:52:05 +02:00
using namespace KWayland : : Client ;
2018-07-03 22:15:45 +03:00
PlasmaShell * interface { c - > waylandDockCoronaInterface ( ) } ;
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... " ;
2017-04-26 17:46:04 +03:00
m_shellSurface - > setSkipTaskbar ( true ) ;
2017-06-29 17:00:55 -05:00
m_shellSurface - > setRole ( PlasmaShellSurface : : Role : : Panel ) ;
2017-06-20 16:58:25 -05:00
m_shellSurface - > setPanelBehavior ( PlasmaShellSurface : : PanelBehavior : : WindowsGoBelow ) ;
2017-04-25 19:18:49 +03:00
}
}
2018-03-28 20:39:52 +03:00
KWayland : : Client : : PlasmaShellSurface * DockView : : surface ( )
{
return m_shellSurface ;
}
2017-03-02 18:07:29 +02:00
//! the main function which decides if this dock is at the
//! correct screen
2017-02-26 02:43:41 +02:00
void DockView : : reconsiderScreen ( )
{
2018-11-29 21:30:00 +02:00
m_positioner - > reconsiderScreen ( ) ;
2017-02-25 15:29:05 +02:00
}
2016-12-30 16:25:27 -05:00
void DockView : : addNewDock ( )
2016-12-30 16:22:28 -05:00
{
2017-01-16 13:24:46 -05:00
auto * dockCorona = qobject_cast < DockCorona * > ( this - > corona ( ) ) ;
2017-01-16 14:07:49 -05:00
2017-01-16 13:24:46 -05:00
if ( dockCorona ) {
dockCorona - > loadDefaultLayout ( ) ;
2016-12-30 16:22:28 -05:00
}
}
2017-06-05 23:52:49 +03:00
void DockView : : copyDock ( )
{
2018-01-11 20:34:16 +02:00
m_managedLayout - > copyDock ( containment ( ) ) ;
2017-06-05 23:52:49 +03:00
}
2016-12-30 16:25:27 -05:00
void DockView : : removeDock ( )
2016-12-30 16:22:28 -05:00
{
2018-12-01 17:29:17 +02:00
if ( m_managedLayout & & m_managedLayout - > viewsCount ( ) > 1 ) {
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-02-09 19:22:04 +02:00
bool DockView : : settingsWindowIsShown ( )
2018-01-18 21:21:32 +02:00
{
2018-02-09 19:22:04 +02:00
auto configView = qobject_cast < DockConfigView * > ( m_configView ) ;
2018-01-18 21:21:32 +02:00
2018-02-09 19:22:04 +02:00
return ( configView ! = nullptr ) ;
2018-01-18 21:21:32 +02:00
}
2017-11-19 14:51:15 +02:00
void DockView : : showSettingsWindow ( )
{
showConfigurationInterface ( containment ( ) ) ;
2018-02-19 18:10:54 +02:00
applyActivitiesToWindows ( ) ;
2017-11-19 14:51:15 +02:00
}
2016-12-30 16:25:27 -05:00
void DockView : : 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 ( ) ) {
m_configView - > setVisible ( false ) ;
//m_configView->hide();
2016-12-30 16:22:28 -05:00
} else {
2018-02-09 19:22:04 +02:00
m_configView - > setVisible ( true ) ;
//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 ) {
m_configView - > setVisible ( true ) ;
//m_configView->show();
m_configView - > requestActivate ( ) ;
2016-12-30 16:22:28 -05:00
return ;
} else {
2018-02-09 19:22:04 +02:00
m_configView - > setVisible ( false ) ;
//m_configView->hide();
m_configView - > deleteLater ( ) ;
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-02-09 19:22:04 +02:00
m_configView = new DockConfigView ( 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 ) {
2018-02-09 19:22:04 +02:00
m_configView - > setVisible ( true ) ;
2017-06-21 17:14:13 +03:00
//m_configView.data()->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
//created in order to give the containmnent's layouts the time to
//calculate the window's height
2017-06-21 17:14:13 +03:00
if ( ! KWindowSystem : : isPlatformWayland ( ) ) {
2018-02-09 19:22:04 +02:00
QTimer : : singleShot ( 150 , m_configView , SLOT ( show ( ) ) ) ;
2017-06-21 17:14:13 +03:00
} else {
2018-02-09 19:22:04 +02:00
QTimer : : singleShot ( 150 , [ this ] ( ) {
m_configView - > setVisible ( true ) ;
2017-06-21 17:14:13 +03:00
} ) ;
}
2017-01-11 16:29:11 +02:00
}
2016-12-30 16:22:28 -05:00
}
2017-03-09 15:49:24 +02:00
QRect DockView : : localGeometry ( ) const
{
return m_localGeometry ;
}
void DockView : : 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 ( ) ;
2017-03-08 21:00:09 +02:00
updateAbsDockGeometry ( ) ;
2016-12-30 19:26:48 -05:00
}
2017-04-29 19:42:26 +03:00
void DockView : : updateAbsDockGeometry ( 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
//! remember exactly the reason, something related to rigth edge in
//! 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
2017-03-08 21:00:09 +02:00
QRect absGeometry { x ( ) + m_localGeometry . x ( ) , y ( ) + m_localGeometry . y ( )
2017-06-20 17:28:55 +03:00
, m_localGeometry . width ( ) , m_localGeometry . height ( ) } ;
2017-02-10 22:12:17 -05:00
2017-04-29 19:42:26 +03:00
if ( m_absGeometry = = absGeometry & & ! bypassChecks )
2017-01-12 18:55:43 -05:00
return ;
2017-01-16 14:07:49 -05:00
2017-02-10 22:12:17 -05:00
m_absGeometry = absGeometry ;
emit absGeometryChanged ( m_absGeometry ) ;
2017-12-24 20:54:45 +02:00
//! this is needed in order to update correctly the screenGeometries
if ( visibility ( ) & & corona ( ) & & visibility ( ) - > mode ( ) = = Dock : : AlwaysVisible ) {
emit corona ( ) - > availableScreenRectChanged ( ) ;
emit corona ( ) - > availableScreenRegionChanged ( ) ;
}
2016-12-30 19:26:48 -05:00
}
2017-01-14 01:59:25 +02:00
void DockView : : statusChanged ( Plasma : : Types : : ItemStatus status )
{
2017-02-18 10:28:40 +02:00
if ( containment ( ) ) {
if ( containment ( ) - > status ( ) > = Plasma : : Types : : NeedsAttentionStatus & &
2017-02-27 12:44:51 +02:00
containment ( ) - > status ( ) ! = Plasma : : Types : : HiddenStatus ) {
2017-08-09 03:41:45 +03:00
setBlockHiding ( true ) ;
2017-02-18 10:28:40 +02:00
} else {
2017-08-09 03:41:45 +03:00
setBlockHiding ( false ) ;
2017-02-18 10:28:40 +02:00
}
2017-01-14 01:59:25 +02:00
}
}
2017-08-09 03:33:03 +03:00
bool DockView : : alternativesIsShown ( ) const
{
return m_alternativesIsShown ;
}
void DockView : : setAlternativesIsShown ( bool show )
{
if ( m_alternativesIsShown = = show ) {
return ;
}
m_alternativesIsShown = show ;
setBlockHiding ( show ) ;
emit alternativesIsShownChanged ( ) ;
}
2017-07-27 18:24:31 +03:00
bool DockView : : contextMenuIsShown ( ) const
{
2018-02-03 15:00:44 +02:00
if ( ! m_menuManager ) {
return false ;
}
return m_menuManager - > contextMenu ( ) ;
2017-07-27 18:24:31 +03:00
}
2016-12-30 16:25:27 -05:00
int DockView : : 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
}
}
2017-01-27 20:31:41 +02:00
int DockView : : normalThickness ( ) const
{
return m_normalThickness ;
}
void DockView : : setNormalThickness ( int thickness )
{
if ( m_normalThickness = = thickness ) {
return ;
}
m_normalThickness = thickness ;
emit normalThicknessChanged ( ) ;
}
2017-03-03 17:23:37 +02:00
int DockView : : docksWithTasks ( )
{
2018-01-31 20:28:42 +02:00
if ( ! m_managedLayout )
2017-03-03 17:23:37 +02:00
return 0 ;
2018-01-31 20:17:50 +02:00
return m_managedLayout - > noDocksWithTasks ( ) ;
2017-01-05 00:28:25 +02:00
}
2017-03-18 23:32:27 +02:00
bool DockView : : dockWinBehavior ( ) const
{
return m_dockWinBehavior ;
}
void DockView : : setDockWinBehavior ( bool dock )
{
if ( m_dockWinBehavior = = dock ) {
return ;
}
m_dockWinBehavior = dock ;
emit dockWinBehaviorChanged ( ) ;
}
2017-05-07 15:06:29 +03:00
bool DockView : : 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
}
2017-05-07 15:06:29 +03:00
void DockView : : 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-02-12 16:11:33 +02:00
bool DockView : : inEditMode ( ) const
{
return m_inEditMode ;
}
void DockView : : setInEditMode ( bool edit )
{
if ( m_inEditMode = = edit ) {
return ;
}
m_inEditMode = edit ;
emit inEditModeChanged ( ) ;
}
2018-09-22 20:21:57 +03:00
bool DockView : : isPreferredForShortcuts ( ) const
{
return m_isPreferredForShortcuts ;
}
void DockView : : setIsPreferredForShortcuts ( bool preferred )
{
if ( m_isPreferredForShortcuts = = preferred ) {
return ;
}
m_isPreferredForShortcuts = preferred ;
emit isPreferredForShortcutsChanged ( ) ;
if ( m_isPreferredForShortcuts & & m_managedLayout ) {
emit m_managedLayout - > preferredViewForShortcutsChanged ( this ) ;
}
}
void DockView : : preferredViewForShortcutsChangedSlot ( DockView * view )
{
if ( view ! = this ) {
setIsPreferredForShortcuts ( false ) ;
}
}
2018-02-12 16:11:33 +02:00
2017-02-27 00:53:27 +02:00
bool DockView : : onPrimary ( ) const
{
return m_onPrimary ;
}
void DockView : : setOnPrimary ( bool flag )
{
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 ( ) ;
}
2017-01-31 21:25:00 +02:00
float DockView : : maxLength ( ) const
{
return m_maxLength ;
}
void DockView : : setMaxLength ( float length )
{
if ( m_maxLength = = length ) {
return ;
}
m_maxLength = length ;
emit maxLengthChanged ( ) ;
}
2016-12-30 16:25:27 -05:00
int DockView : : maxThickness ( ) const
2016-12-30 16:22:28 -05:00
{
return m_maxThickness ;
}
2016-12-30 16:25:27 -05:00
void DockView : : 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 ( ) ;
}
2017-02-04 16:41:12 +02:00
int DockView : : alignment ( ) const
{
2017-02-10 22:12:17 -05:00
return m_alignment ;
2017-02-04 16:41:12 +02:00
}
void DockView : : setAlignment ( int alignment )
{
2017-02-10 22:12:17 -05:00
Dock : : Alignment align = static_cast < Dock : : 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 ( ) ;
}
2017-02-10 22:12:17 -05:00
QRect DockView : : absGeometry ( ) const
{
return m_absGeometry ;
}
2017-02-26 15:49:50 +02:00
QRect DockView : : screenGeometry ( ) const
{
if ( this - > screen ( ) ) {
QRect geom = this - > screen ( ) - > geometry ( ) ;
return geom ;
}
return QRect ( ) ;
}
2017-04-09 01:06:48 +03:00
int DockView : : offset ( ) const
{
return m_offset ;
}
void DockView : : setOffset ( int offset )
{
if ( m_offset = = offset ) {
return ;
}
m_offset = offset ;
emit offsetChanged ( ) ;
}
2018-02-17 19:02:06 +02:00
int DockView : : fontPixelSize ( ) const
{
return m_fontPixelSize ;
}
void DockView : : setFontPixelSize ( int size )
{
if ( m_fontPixelSize = = size ) {
return ;
}
m_fontPixelSize = size ;
emit fontPixelSizeChanged ( ) ;
}
2018-01-21 11:53:15 +02:00
void DockView : : applyActivitiesToWindows ( )
{
if ( m_visibility ) {
QStringList activities = m_managedLayout - > appliedActivities ( ) ;
m_visibility - > setWindowOnActivities ( * this , activities ) ;
if ( m_configView ) {
m_visibility - > setWindowOnActivities ( * m_configView , activities ) ;
2018-02-09 19:22:04 +02:00
auto configView = qobject_cast < DockConfigView * > ( m_configView ) ;
if ( configView & & configView - > secondaryWindow ( ) ) {
m_visibility - > setWindowOnActivities ( * configView - > secondaryWindow ( ) , activities ) ;
}
2018-01-21 11:53:15 +02:00
}
2018-03-28 20:39:52 +03:00
if ( m_visibility - > supportsKWinEdges ( ) ) {
m_visibility - > applyActivitiesToHiddenWindows ( activities ) ;
}
2018-01-21 11:53:15 +02:00
}
}
2018-01-10 22:55:19 +02:00
Layout * DockView : : managedLayout ( ) const
{
return m_managedLayout ;
}
void DockView : : setManagedLayout ( Layout * layout )
{
if ( m_managedLayout = = layout ) {
return ;
}
2018-01-20 00:34:55 +02:00
// clear mode
for ( auto & c : connectionsManagedLayout ) {
disconnect ( c ) ;
}
2018-01-10 22:55:19 +02:00
m_managedLayout = layout ;
2018-01-13 12:55:13 +02:00
2018-01-14 09:39:31 +02:00
if ( m_managedLayout ) {
2018-01-14 17:30:29 +02:00
//! Sometimes the activity isnt completely ready, by adding a delay
//! we try to catch up
QTimer : : singleShot ( 100 , [ this ] ( ) {
2018-07-24 22:25:19 +03:00
if ( m_managedLayout & & m_visibility ) {
2018-01-14 17:30:29 +02:00
qDebug ( ) < < " DOCK VIEW FROM LAYOUT ::: " < < m_managedLayout - > name ( ) < < " - activities: " < < m_managedLayout - > appliedActivities ( ) ;
2018-01-21 11:53:15 +02:00
applyActivitiesToWindows ( ) ;
2018-01-14 17:30:29 +02:00
emit activitiesChanged ( ) ;
}
} ) ;
2018-09-22 20:21:57 +03:00
connectionsManagedLayout [ 0 ] = connect ( m_managedLayout , & Layout : : preferredViewForShortcutsChanged , this , & DockView : : preferredViewForShortcutsChangedSlot ) ;
2018-01-14 09:39:31 +02:00
}
DockCorona * dockCorona = qobject_cast < DockCorona * > ( this - > corona ( ) ) ;
if ( dockCorona - > layoutManager ( ) - > memoryUsage ( ) = = Dock : : MultipleLayouts ) {
2018-09-22 20:21:57 +03:00
connectionsManagedLayout [ 1 ] = connect ( dockCorona - > activitiesConsumer ( ) , & KActivities : : Consumer : : runningActivitiesChanged , this , [ & ] ( ) {
2018-07-24 22:25:19 +03:00
if ( m_managedLayout & & m_visibility ) {
2018-01-14 17:30:29 +02:00
qDebug ( ) < < " DOCK VIEW FROM LAYOUT (runningActivitiesChanged) ::: " < < m_managedLayout - > name ( )
< < " - activities: " < < m_managedLayout - > appliedActivities ( ) ;
2018-01-21 11:53:15 +02:00
applyActivitiesToWindows ( ) ;
2018-01-14 13:21:11 +02:00
emit activitiesChanged ( ) ;
2018-01-14 09:39:31 +02:00
}
} ) ;
2018-09-22 20:21:57 +03:00
connectionsManagedLayout [ 2 ] = connect ( m_managedLayout , & Layout : : activitiesChanged , this , [ & ] ( ) {
2018-01-14 13:21:11 +02:00
if ( m_managedLayout ) {
2018-01-21 11:53:15 +02:00
applyActivitiesToWindows ( ) ;
2018-01-14 13:21:11 +02:00
emit activitiesChanged ( ) ;
}
} ) ;
2018-01-14 12:22:45 +02:00
2018-09-22 20:21:57 +03:00
connectionsManagedLayout [ 3 ] = connect ( dockCorona - > layoutManager ( ) , & LayoutManager : : layoutsChanged , this , [ & ] ( ) {
2018-01-15 19:44:00 +02:00
if ( m_managedLayout ) {
2018-01-21 11:53:15 +02:00
applyActivitiesToWindows ( ) ;
2018-01-15 19:44:00 +02:00
emit activitiesChanged ( ) ;
}
} ) ;
2018-01-14 09:39:31 +02:00
//!IMPORTANT!!! ::: This fixes a bug when closing an Activity all docks from all Activities are
//! disappearing! With this they reappear!!!
2018-09-22 20:21:57 +03:00
connectionsManagedLayout [ 4 ] = connect ( this , & QWindow : : visibleChanged , this , [ & ] ( ) {
2018-01-14 09:39:31 +02:00
if ( ! isVisible ( ) & & m_managedLayout ) {
2018-01-14 17:30:29 +02:00
QTimer : : singleShot ( 100 , [ this ] ( ) {
2018-01-15 00:34:44 +02:00
if ( m_managedLayout & & containment ( ) & & ! containment ( ) - > destroyed ( ) ) {
2018-01-14 12:22:45 +02:00
setVisible ( true ) ;
2018-01-21 11:53:15 +02:00
applyActivitiesToWindows ( ) ;
2018-01-15 00:34:44 +02:00
emit activitiesChanged ( ) ;
2018-01-14 09:39:31 +02:00
}
} ) ;
2018-01-14 17:30:29 +02:00
QTimer : : singleShot ( 1500 , [ this ] ( ) {
2018-01-15 00:34:44 +02:00
if ( m_managedLayout & & containment ( ) & & ! containment ( ) - > destroyed ( ) ) {
2018-01-14 17:30:29 +02:00
setVisible ( true ) ;
2018-01-21 11:53:15 +02:00
applyActivitiesToWindows ( ) ;
2018-01-15 00:34:44 +02:00
emit activitiesChanged ( ) ;
2018-01-14 17:30:29 +02:00
}
} ) ;
2018-01-14 09:39:31 +02:00
}
} ) ;
}
2018-01-13 12:55:13 +02:00
2018-01-10 22:55:19 +02:00
emit managedLayoutChanged ( ) ;
}
2018-01-21 11:34:18 +02:00
void DockView : : moveToLayout ( QString layoutName )
{
if ( ! m_managedLayout ) {
return ;
}
QList < Plasma : : Containment * > containments = m_managedLayout - > unassignFromLayout ( this ) ;
DockCorona * dockCorona = qobject_cast < DockCorona * > ( this - > corona ( ) ) ;
if ( dockCorona & & containments . size ( ) > 0 ) {
Layout * newLayout = dockCorona - > layoutManager ( ) - > activeLayout ( layoutName ) ;
if ( newLayout ) {
newLayout - > assignToLayout ( this , containments ) ;
}
}
}
2017-08-09 03:33:03 +03:00
void DockView : : setBlockHiding ( bool block )
{
if ( ! block ) {
auto * configView = qobject_cast < DockConfigView * > ( m_configView ) ;
2017-08-09 14:48:54 +03:00
if ( m_alternativesIsShown | | ( configView & & configView - > sticker ( ) & & configView - > isVisible ( ) ) ) {
2017-08-09 03:33:03 +03:00
return ;
}
2017-08-09 04:52:42 +03:00
if ( m_visibility ) {
m_visibility - > setBlockHiding ( false ) ;
}
2017-08-09 03:33:03 +03:00
} else {
2017-08-09 04:52:42 +03:00
if ( m_visibility ) {
m_visibility - > setBlockHiding ( true ) ;
}
2017-08-09 03:33:03 +03:00
}
}
2018-12-01 00:13:11 +02:00
void DockView : : hideWindowsForSlidingOut ( )
{
setBlockHiding ( false ) ;
if ( m_configView ) {
auto configDialog = qobject_cast < DockConfigView * > ( m_configView ) ;
if ( configDialog ) {
configDialog - > hideConfigWindow ( ) ;
}
}
}
2017-04-11 12:10:54 +03:00
//! remove latte tasks plasmoid
void DockView : : removeTasksPlasmoid ( )
{
if ( ! tasksPresent ( ) | | ! containment ( ) ) {
return ;
}
foreach ( Plasma : : Applet * applet , containment ( ) - > applets ( ) ) {
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
2017-01-02 22:26:10 +02:00
bool DockView : : tasksPresent ( )
{
2017-03-05 16:30:50 +02:00
if ( ! this - > containment ( ) ) {
return false ;
}
2017-02-12 10:02:01 +02:00
foreach ( 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-07-28 17:08:55 +03:00
//! check if the tasks plasmoid exist in the dock
bool DockView : : latteTasksPresent ( )
{
if ( ! this - > containment ( ) ) {
return false ;
}
foreach ( Plasma : : Applet * applet , this - > containment ( ) - > applets ( ) ) {
KPluginMetaData metadata = applet - > pluginMetaData ( ) ;
if ( metadata . pluginId ( ) = = " org.kde.latte.plasmoid " ) {
return true ;
}
}
return false ;
}
2017-06-11 18:06:03 +03:00
//!check if the plasmoid with _name_ exists in the midedata
bool DockView : : mimeContainsPlasmoid ( QMimeData * mimeData , QString name )
{
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 ) ;
foreach ( const QString & appletName , appletNames ) {
if ( appletName = = name )
return true ;
}
}
return false ;
}
2018-11-30 21:33:46 +02:00
View : : Effects * DockView : : effects ( ) const
{
return m_effects ;
}
2018-12-01 00:13:11 +02:00
View : : Positioner * DockView : : positioner ( ) const
2018-11-29 21:30:00 +02:00
{
return m_positioner ;
}
2017-06-11 18:06:03 +03:00
2017-02-12 01:59:09 +02:00
VisibilityManager * DockView : : visibility ( ) const
2016-12-30 16:22:28 -05:00
{
return m_visibility ;
}
2016-12-30 16:25:27 -05:00
bool DockView : : event ( QEvent * e )
2016-12-30 16:22:28 -05: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 ( ) ) {
2018-01-28 12:49:35 +02:00
case QEvent : : Leave :
engine ( ) - > trimComponentCache ( ) ;
break ;
2017-06-21 23:34:40 +03:00
case QEvent : : PlatformSurface :
if ( auto pe = dynamic_cast < QPlatformSurfaceEvent * > ( e ) ) {
switch ( pe - > surfaceEventType ( ) ) {
case QPlatformSurfaceEvent : : SurfaceCreated :
setupWaylandIntegration ( ) ;
2017-04-25 19:18:49 +03:00
2017-06-21 23:34:40 +03:00
if ( m_shellSurface ) {
2018-11-29 21:30:00 +02:00
m_positioner - > syncGeometry ( ) ;
2018-12-01 10:18:56 +02:00
m_effects - > updateShadows ( ) ;
2017-04-25 19:18:49 +03:00
}
2017-06-21 23:34:40 +03:00
break ;
2017-04-25 19:18:49 +03:00
2017-06-21 23:34:40 +03:00
case QPlatformSurfaceEvent : : SurfaceAboutToBeDestroyed :
2017-06-22 02:26:08 +03:00
if ( m_shellSurface ) {
delete m_shellSurface ;
m_shellSurface = nullptr ;
2018-03-01 01:31:17 +02:00
qDebug ( ) < < " WAYLAND dock window surface was deleted... " ;
2018-12-01 10:18:56 +02:00
m_effects - > clearShadows ( ) ;
2017-06-22 02:26:08 +03:00
}
2017-06-21 23:34:40 +03:00
break ;
}
2017-04-25 19:18:49 +03:00
}
2017-06-21 23:34:40 +03:00
break ;
2017-04-25 19:18:49 +03:00
2017-06-21 23:34:40 +03:00
default :
break ;
}
2017-04-25 19:18:49 +03:00
}
2018-04-03 23:53:49 +03:00
return ContainmentView : : event ( e ) ; ;
2016-12-30 16:22:28 -05:00
}
2017-03-20 20:40:27 +02:00
void DockView : : deactivateApplets ( )
{
if ( ! containment ( ) ) {
return ;
}
foreach ( auto applet , containment ( ) - > applets ( ) ) {
PlasmaQuick : : AppletQuickItem * ai = applet - > property ( " _plasma_graphicObject " ) . value < PlasmaQuick : : AppletQuickItem * > ( ) ;
if ( ai ) {
ai - > setExpanded ( false ) ;
}
}
}
2017-05-16 23:08:13 +03:00
void DockView : : toggleAppletExpanded ( const int id )
{
if ( ! containment ( ) ) {
return ;
}
foreach ( auto applet , containment ( ) - > applets ( ) ) {
if ( applet - > id ( ) = = id ) {
PlasmaQuick : : AppletQuickItem * ai = applet - > property ( " _plasma_graphicObject " ) . value < PlasmaQuick : : AppletQuickItem * > ( ) ;
if ( ai ) {
2017-12-02 19:52:43 +02:00
if ( ! ai - > isActivationTogglesExpanded ( ) ) {
ai - > setActivationTogglesExpanded ( true ) ;
}
emit applet - > activated ( ) ;
2017-05-16 23:08:13 +03:00
}
}
}
}
2017-01-02 12:02:35 +02:00
QVariantList DockView : : containmentActions ( )
{
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
2017-01-02 12:02:35 +02:00
foreach ( QAction * ac , plugin - > contextualActions ( ) ) {
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
2018-10-27 20:50:49 +03:00
void DockView : : disableGrabItemBehavior ( )
{
setMouseGrabEnabled ( false ) ;
}
void DockView : : restoreGrabItemBehavior ( )
{
setMouseGrabEnabled ( true ) ;
if ( mouseGrabberItem ( ) ) {
mouseGrabberItem ( ) - > ungrabMouse ( ) ;
}
}
2017-01-12 18:55:43 -05:00
2017-01-03 15:33:30 +02:00
//!BEGIN overriding context menus behavior
void DockView : : mousePressEvent ( QMouseEvent * event )
{
2018-02-03 15:00:44 +02:00
bool result = m_menuManager - > mousePressEvent ( event ) ;
2017-07-27 18:24:31 +03:00
emit contextMenuIsShownChanged ( ) ;
2018-01-17 16:45:29 +02:00
2018-02-03 15:00:44 +02:00
if ( result ) {
PlasmaQuick : : ContainmentView : : mousePressEvent ( event ) ;
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
void DockView : : saveConfig ( )
{
if ( ! this - > containment ( ) )
return ;
auto config = this - > containment ( ) - > config ( ) ;
2018-09-04 19:38:54 +03:00
config . writeEntry ( " onPrimary " , onPrimary ( ) ) ;
config . writeEntry ( " dockWindowBehavior " , dockWinBehavior ( ) ) ;
2018-09-22 20:21:57 +03:00
config . writeEntry ( " isPreferredForShortcuts " , isPreferredForShortcuts ( ) ) ;
2017-07-29 23:07:00 +03:00
config . sync ( ) ;
2017-02-27 00:53:27 +02:00
}
void DockView : : restoreConfig ( )
{
if ( ! this - > containment ( ) )
return ;
auto config = this - > containment ( ) - > config ( ) ;
2018-09-04 19:38:54 +03:00
m_onPrimary = config . readEntry ( " onPrimary " , true ) ;
m_dockWinBehavior = config . readEntry ( " dockWindowBehavior " , true ) ;
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 ( ) ;
emit dockWinBehaviorChanged ( ) ;
2017-02-27 00:53:27 +02:00
}
//!END configuration functions
2016-12-30 16:22:28 -05:00
}
//!END namespace