2016-12-25 10:25:27 +03:00
/*
2021-05-27 18:01:00 +03:00
SPDX - FileCopyrightText : 2016 Smith AR < audoban @ openmaibox . org >
SPDX - FileCopyrightText : 2016 Michail Vourlakos < mvourlakos @ gmail . com >
SPDX - License - Identifier : GPL - 2.0 - or - later
2017-01-03 01:05:30 +03:00
*/
2016-12-25 10:25:27 +03:00
2018-12-06 15:35:34 +03:00
# include "lattecorona.h"
2018-02-03 12:34:13 +03:00
2018-12-02 03:05:52 +03:00
// local
2020-04-24 14:52:16 +03:00
# include <coretypes.h>
2017-02-15 07:54:41 +03:00
# include "alternativeshelper.h"
2020-04-24 10:08:13 +03:00
# include "apptypes.h"
2018-12-02 03:05:52 +03:00
# include "lattedockadaptor.h"
2017-02-24 21:58:21 +03:00
# include "screenpool.h"
2021-03-01 20:04:21 +03:00
# include "data/generictable.h"
2021-05-15 13:31:56 +03:00
# include "data/layouticondata.h"
2020-05-02 13:23:37 +03:00
# include "declarativeimports/interfaces.h"
2022-05-22 17:12:42 +03:00
# include "declarativeimports/contextmenulayerquickitem.h"
2019-03-23 18:49:09 +03:00
# include "indicator/factory.h"
2020-08-13 21:28:52 +03:00
# include "layout/abstractlayout.h"
2019-05-03 17:01:48 +03:00
# include "layout/centrallayout.h"
2019-04-08 18:57:32 +03:00
# include "layout/genericlayout.h"
2019-05-09 17:57:12 +03:00
# include "layouts/importer.h"
2019-05-09 17:12:57 +03:00
# include "layouts/manager.h"
2019-05-11 09:23:14 +03:00
# include "layouts/synchronizer.h"
2019-02-02 18:46:35 +03:00
# include "shortcuts/globalshortcuts.h"
2018-12-13 22:01:51 +03:00
# include "package/lattepackage.h"
2020-04-24 17:30:30 +03:00
# include "plasma/extended/backgroundcache.h"
# include "plasma/extended/backgroundtracker.h"
2020-02-22 15:30:02 +03:00
# include "plasma/extended/screengeometries.h"
2018-12-13 21:55:03 +03:00
# include "plasma/extended/screenpool.h"
2018-12-13 21:03:14 +03:00
# include "plasma/extended/theme.h"
2018-12-02 02:21:34 +03:00
# include "settings/universalsettings.h"
2020-08-12 12:02:46 +03:00
# include "templates/templatesmanager.h"
2021-12-11 18:39:44 +03:00
# include "view/originalview.h"
2018-12-06 13:15:58 +03:00
# include "view/view.h"
2020-06-21 13:42:20 +03:00
# include "view/settings/viewsettingsfactory.h"
2019-06-08 18:11:02 +03:00
# include "view/windowstracker/windowstracker.h"
# include "view/windowstracker/allscreenstracker.h"
# include "view/windowstracker/currentscreentracker.h"
2018-12-02 02:29:18 +03:00
# include "wm/abstractwindowinterface.h"
2019-05-12 13:57:45 +03:00
# include "wm/schemecolors.h"
2018-12-02 02:29:18 +03:00
# include "wm/waylandinterface.h"
# include "wm/xwindowinterface.h"
2019-05-31 19:12:34 +03:00
# include "wm/tracker/lastactivewindow.h"
2019-05-31 14:52:16 +03:00
# include "wm/tracker/schemes.h"
2019-07-16 20:58:48 +03:00
# include "wm/tracker/windowstracker.h"
2018-02-03 12:34:13 +03:00
2018-12-02 03:05:52 +03:00
// Qt
2016-12-25 10:25:27 +03:00
# include <QAction>
2017-02-26 03:43:41 +03:00
# include <QApplication>
2016-12-25 10:25:27 +03:00
# include <QScreen>
2017-03-11 11:06:10 +03:00
# include <QDBusConnection>
2016-12-25 10:25:27 +03:00
# include <QDebug>
2017-02-26 03:43:41 +03:00
# include <QDesktopWidget>
2017-07-25 00:01:41 +03:00
# include <QFile>
2017-04-21 16:59:58 +03:00
# include <QFontDatabase>
2017-02-15 07:54:41 +03:00
# include <QQmlContext>
2020-03-18 14:33:28 +03:00
# include <QProcess>
2016-12-25 10:25:27 +03:00
2018-12-02 03:05:52 +03:00
// Plasma
2016-12-25 10:25:27 +03:00
# include <Plasma>
# include <Plasma/Corona>
# include <Plasma/Containment>
2018-02-03 23:19:35 +03:00
# include <PlasmaQuick/ConfigView>
2018-12-02 03:05:52 +03:00
// KDE
2016-12-31 00:25:27 +03:00
# include <KActionCollection>
# include <KPluginMetaData>
2017-04-06 20:00:48 +03:00
# include <KGlobalAccel>
2016-12-25 10:25:27 +03:00
# include <KLocalizedString>
# include <KPackage/Package>
# include <KPackage/PackageLoader>
2017-01-29 08:16:28 +03:00
# include <KAboutData>
2017-02-15 07:54:41 +03:00
# include <KActivities/Consumer>
2019-02-18 18:46:53 +03:00
# include <KDeclarative/QmlObjectSharedEngine>
2017-04-25 19:18:49 +03:00
# include <KWindowSystem>
# include <KWayland/Client/connection_thread.h>
# include <KWayland/Client/registry.h>
# include <KWayland/Client/plasmashell.h>
2018-03-02 00:53:28 +03:00
# include <KWayland/Client/plasmawindowmanagement.h>
2017-04-25 19:18:49 +03:00
2016-12-30 10:20:06 +03:00
namespace Latte {
2021-12-06 20:26:34 +03:00
Corona : : Corona ( bool defaultLayoutOnStartup , QString layoutNameOnStartUp , QString addViewTemplateName , int userSetMemoryUsage , QObject * parent )
2017-01-07 16:27:26 +03:00
: Plasma : : Corona ( parent ) ,
2017-12-17 18:42:49 +03:00
m_defaultLayoutOnStartup ( defaultLayoutOnStartup ) ,
2021-12-06 20:26:34 +03:00
m_startupAddViewTemplateName ( addViewTemplateName ) ,
2018-01-31 16:27:58 +03:00
m_userSetMemoryUsage ( userSetMemoryUsage ) ,
2017-12-17 19:34:50 +03:00
m_layoutNameOnStartUp ( layoutNameOnStartUp ) ,
2020-03-18 18:39:19 +03:00
m_activitiesConsumer ( new KActivities : : Consumer ( this ) ) ,
2017-02-24 21:58:21 +03:00
m_screenPool ( new ScreenPool ( KSharedConfig : : openConfig ( ) , this ) ) ,
2019-03-23 18:49:09 +03:00
m_indicatorFactory ( new Indicator : : Factory ( this ) ) ,
2017-07-02 16:12:58 +03:00
m_universalSettings ( new UniversalSettings ( KSharedConfig : : openConfig ( ) , this ) ) ,
2019-02-10 03:39:09 +03:00
m_globalShortcuts ( new GlobalShortcuts ( this ) ) ,
2018-12-13 21:55:03 +03:00
m_plasmaScreenPool ( new PlasmaExtended : : ScreenPool ( this ) ) ,
2019-05-11 03:46:06 +03:00
m_themeExtended ( new PlasmaExtended : : Theme ( KSharedConfig : : openConfig ( ) , this ) ) ,
2020-06-21 13:42:20 +03:00
m_viewSettingsFactory ( new ViewSettingsFactory ( this ) ) ,
2020-08-12 12:02:46 +03:00
m_templatesManager ( new Templates : : Manager ( this ) ) ,
2020-01-13 00:51:46 +03:00
m_layoutsManager ( new Layouts : : Manager ( this ) ) ,
2020-02-22 15:30:02 +03:00
m_plasmaGeometries ( new PlasmaExtended : : ScreenGeometries ( this ) ) ,
2020-01-13 00:51:46 +03:00
m_dialogShadows ( new PanelShadows ( this , QStringLiteral ( " dialogs/background " ) ) )
2016-12-25 10:25:27 +03:00
{
2021-04-24 12:33:40 +03:00
connect ( qApp , & QApplication : : aboutToQuit , this , & Corona : : onAboutToQuit ) ;
2018-03-02 00:53:28 +03:00
2021-04-24 12:33:40 +03:00
//! create the window manager
2018-03-02 00:53:28 +03:00
if ( KWindowSystem : : isPlatformWayland ( ) ) {
2019-05-11 15:43:10 +03:00
m_wm = new WindowSystem : : WaylandInterface ( this ) ;
2018-03-02 00:53:28 +03:00
} else {
2019-05-11 15:43:10 +03:00
m_wm = new WindowSystem : : XWindowInterface ( this ) ;
2018-03-02 00:53:28 +03:00
}
2017-04-25 19:18:49 +03:00
setupWaylandIntegration ( ) ;
2018-12-06 14:32:21 +03:00
KPackage : : Package package ( new Latte : : Package ( this ) ) ;
2018-10-27 00:59:36 +03:00
2017-02-26 21:06:31 +03:00
m_screenPool - > load ( ) ;
2017-01-16 22:07:49 +03:00
2016-12-25 10:25:27 +03:00
if ( ! package . isValid ( ) ) {
qWarning ( ) < < staticMetaObject . className ( )
< < " the package " < < package . metadata ( ) . rawData ( ) < < " is invalid! " ;
return ;
} else {
qDebug ( ) < < staticMetaObject . className ( )
< < " the package " < < package . metadata ( ) . rawData ( ) < < " is valid! " ;
}
2017-01-16 22:07:49 +03:00
2016-12-25 10:25:27 +03:00
setKPackage ( package ) ;
2018-10-27 00:59:36 +03:00
//! universal settings / extendedtheme must be loaded after the package has been set
2017-07-03 10:41:59 +03:00
m_universalSettings - > load ( ) ;
2018-10-27 00:59:36 +03:00
m_themeExtended - > load ( ) ;
2017-04-23 22:34:29 +03:00
2016-12-25 10:25:27 +03:00
qmlRegisterTypes ( ) ;
2017-04-21 16:59:58 +03:00
2020-03-18 18:39:19 +03:00
if ( m_activitiesConsumer & & ( m_activitiesConsumer - > serviceStatus ( ) = = KActivities : : Consumer : : Running ) ) {
2017-01-24 21:32:22 +03:00
load ( ) ;
}
2020-03-18 18:39:19 +03:00
connect ( m_activitiesConsumer , & KActivities : : Consumer : : serviceStatusChanged , this , & Corona : : load ) ;
2017-03-01 21:49:21 +03:00
2018-12-06 16:57:20 +03:00
m_viewsScreenSyncTimer . setSingleShot ( true ) ;
m_viewsScreenSyncTimer . setInterval ( m_universalSettings - > screenTrackerInterval ( ) ) ;
connect ( & m_viewsScreenSyncTimer , & QTimer : : timeout , this , & Corona : : syncLatteViewsToScreens ) ;
2018-04-01 15:04:52 +03:00
connect ( m_universalSettings , & UniversalSettings : : screenTrackerIntervalChanged , this , [ this ] ( ) {
2018-12-06 16:57:20 +03:00
m_viewsScreenSyncTimer . setInterval ( m_universalSettings - > screenTrackerInterval ( ) ) ;
2018-04-01 15:04:52 +03:00
} ) ;
2017-03-11 11:06:10 +03:00
//! Dbus adaptor initialization
new LatteDockAdaptor ( this ) ;
QDBusConnection dbus = QDBusConnection : : sessionBus ( ) ;
dbus . registerObject ( QStringLiteral ( " /Latte " ) , this ) ;
2016-12-25 10:25:27 +03:00
}
2018-12-06 15:35:34 +03:00
Corona : : ~ Corona ( )
2016-12-25 10:25:27 +03:00
{
2021-04-24 12:33:40 +03:00
/*m_inQuit = true;
2020-07-04 14:44:27 +03:00
2018-12-06 16:57:20 +03:00
//! BEGIN: Give the time to slide-out views when closing
2019-05-11 09:23:14 +03:00
m_layoutsManager - > synchronizer ( ) - > hideAllViews ( ) ;
2020-08-03 17:33:52 +03:00
m_viewSettingsFactory - > deleteLater ( ) ;
2018-02-03 16:44:37 +03:00
2018-12-06 16:57:20 +03:00
m_viewsScreenSyncTimer . stop ( ) ;
2018-01-14 18:30:29 +03:00
2020-04-24 12:31:03 +03:00
if ( m_layoutsManager - > memoryUsage ( ) = = MemoryUsage : : SingleLayout ) {
2018-01-14 18:30:29 +03:00
cleanConfig ( ) ;
}
2017-01-21 21:08:47 +03:00
2018-01-10 20:48:23 +03:00
qDebug ( ) < < " Latte Corona - unload: containments ... " ;
2021-04-24 12:33:40 +03:00
m_layoutsManager - > unload ( ) ; */
2021-04-22 13:44:22 +03:00
2020-02-22 15:30:02 +03:00
m_plasmaGeometries - > deleteLater ( ) ;
2018-03-02 00:53:28 +03:00
m_wm - > deleteLater ( ) ;
2020-01-13 00:51:46 +03:00
m_dialogShadows - > deleteLater ( ) ;
2017-06-04 01:58:03 +03:00
m_globalShortcuts - > deleteLater ( ) ;
2019-05-09 17:12:57 +03:00
m_layoutsManager - > deleteLater ( ) ;
2018-01-08 20:21:34 +03:00
m_screenPool - > deleteLater ( ) ;
2017-07-02 15:02:07 +03:00
m_universalSettings - > deleteLater ( ) ;
2018-12-13 21:55:03 +03:00
m_plasmaScreenPool - > deleteLater ( ) ;
2018-10-26 23:36:40 +03:00
m_themeExtended - > deleteLater ( ) ;
2019-03-23 18:49:09 +03:00
m_indicatorFactory - > deleteLater ( ) ;
2017-06-04 01:58:03 +03:00
2020-03-18 18:39:19 +03:00
disconnect ( m_activitiesConsumer , & KActivities : : Consumer : : serviceStatusChanged , this , & Corona : : load ) ;
delete m_activitiesConsumer ;
2017-06-26 22:16:42 +03:00
2018-01-13 13:00:47 +03:00
qDebug ( ) < < " Latte Corona - deleted... " ;
2020-03-18 14:33:28 +03:00
if ( ! m_importFullConfigurationFile . isEmpty ( ) ) {
//!NOTE: Restart latte to import the new configuration
QString importCommand = " latte-dock --import-full \" " + m_importFullConfigurationFile + " \" " ;
qDebug ( ) < < " Executing Import Full Configuration command : " < < importCommand ;
QProcess : : startDetached ( importCommand ) ;
}
2016-12-25 10:25:27 +03:00
}
2021-04-24 12:33:40 +03:00
void Corona : : onAboutToQuit ( )
{
m_inQuit = true ;
//! BEGIN: Give the time to slide-out views when closing
m_layoutsManager - > synchronizer ( ) - > hideAllViews ( ) ;
m_viewSettingsFactory - > deleteLater ( ) ;
m_viewsScreenSyncTimer . stop ( ) ;
if ( m_layoutsManager - > memoryUsage ( ) = = MemoryUsage : : SingleLayout ) {
cleanConfig ( ) ;
}
2021-11-20 12:57:14 +03:00
if ( m_layoutsManager - > memoryUsage ( ) = = Latte : : MemoryUsage : : MultipleLayouts ) {
m_layoutsManager - > importer ( ) - > setMultipleLayoutsStatus ( Latte : : MultipleLayouts : : Paused ) ;
}
2021-04-24 12:33:40 +03:00
qDebug ( ) < < " Latte Corona - unload: containments ... " ;
m_layoutsManager - > unload ( ) ;
}
2018-12-06 15:35:34 +03:00
void Corona : : load ( )
2017-01-07 16:27:26 +03:00
{
2020-03-18 18:39:19 +03:00
if ( m_activitiesConsumer & & ( m_activitiesConsumer - > serviceStatus ( ) = = KActivities : : Consumer : : Running ) & & m_activitiesStarting ) {
2019-05-11 03:11:50 +03:00
m_activitiesStarting = false ;
2020-03-18 18:39:19 +03:00
disconnect ( m_activitiesConsumer , & KActivities : : Consumer : : serviceStatusChanged , this , & Corona : : load ) ;
2017-02-24 21:58:21 +03:00
2020-08-12 12:02:46 +03:00
m_templatesManager - > init ( ) ;
2020-08-29 20:42:15 +03:00
m_layoutsManager - > init ( ) ;
2017-03-01 17:59:04 +03:00
2022-05-08 13:52:55 +03:00
connect ( this , & Corona : : availableScreenRectChangedFrom , this , & Plasma : : Corona : : availableScreenRectChanged , Qt : : UniqueConnection ) ;
connect ( this , & Corona : : availableScreenRegionChangedFrom , this , & Plasma : : Corona : : availableScreenRegionChanged , Qt : : UniqueConnection ) ;
connect ( m_screenPool , & ScreenPool : : primaryScreenChanged , this , & Corona : : onScreenCountChanged , Qt : : UniqueConnection ) ;
2017-02-24 21:58:21 +03:00
2017-12-17 18:01:30 +03:00
QString loadLayoutName = " " ;
2020-08-25 18:07:24 +03:00
if ( m_userSetMemoryUsage ! = - 1 ) {
MemoryUsage : : LayoutsMemory usage = static_cast < MemoryUsage : : LayoutsMemory > ( m_userSetMemoryUsage ) ;
m_universalSettings - > setLayoutsMemoryUsage ( usage ) ;
}
2017-12-17 19:34:50 +03:00
if ( ! m_defaultLayoutOnStartup & & m_layoutNameOnStartUp . isEmpty ( ) ) {
2020-08-25 18:07:24 +03:00
if ( m_universalSettings - > layoutsMemoryUsage ( ) = = MemoryUsage : : MultipleLayouts ) {
loadLayoutName = " " ;
2017-12-17 18:42:49 +03:00
} else {
2020-08-28 19:03:23 +03:00
loadLayoutName = m_universalSettings - > singleModeLayoutName ( ) ;
2017-12-17 18:01:30 +03:00
2020-08-25 18:07:24 +03:00
if ( ! m_layoutsManager - > synchronizer ( ) - > layoutExists ( loadLayoutName ) ) {
//! If chosen layout does not exist, force Default layout loading
QString defaultLayoutTemplateName = i18n ( Templates : : DEFAULTLAYOUTTEMPLATENAME ) ;
loadLayoutName = defaultLayoutTemplateName ;
2020-08-13 21:28:52 +03:00
2020-08-25 18:07:24 +03:00
if ( ! m_layoutsManager - > synchronizer ( ) - > layoutExists ( defaultLayoutTemplateName ) ) {
//! If Default layout does not exist at all, create it
2020-08-28 19:03:23 +03:00
QString path = m_templatesManager - > newLayout ( " " , defaultLayoutTemplateName ) ;
m_layoutsManager - > setOnAllActivities ( Layout : : AbstractLayout : : layoutName ( path ) ) ;
2020-08-25 18:07:24 +03:00
}
2020-08-13 21:28:52 +03:00
}
2017-12-17 18:42:49 +03:00
}
2017-12-17 19:34:50 +03:00
} else if ( m_defaultLayoutOnStartup ) {
2020-08-13 21:28:52 +03:00
//! force loading a NEW default layout even though a default layout may already exists
QString newDefaultLayoutPath = m_templatesManager - > newLayout ( " " , i18n ( Templates : : DEFAULTLAYOUTTEMPLATENAME ) ) ;
loadLayoutName = Layout : : AbstractLayout : : layoutName ( newDefaultLayoutPath ) ;
2020-08-25 18:07:24 +03:00
m_universalSettings - > setLayoutsMemoryUsage ( MemoryUsage : : SingleLayout ) ;
2017-12-17 19:34:50 +03:00
} else {
loadLayoutName = m_layoutNameOnStartUp ;
2020-08-25 18:07:24 +03:00
m_universalSettings - > setLayoutsMemoryUsage ( MemoryUsage : : SingleLayout ) ;
2018-01-31 16:27:58 +03:00
}
2019-05-09 17:12:57 +03:00
m_layoutsManager - > loadLayoutOnStartup ( loadLayoutName ) ;
2018-11-23 17:57:33 +03:00
//! load screens signals such screenGeometryChanged in order to support
//! plasmoid.screenGeometry properly
for ( QScreen * screen : qGuiApp - > screens ( ) ) {
2022-05-08 13:52:55 +03:00
onScreenAdded ( screen ) ;
2018-11-23 17:57:33 +03:00
}
2021-12-06 20:26:34 +03:00
connect ( m_layoutsManager - > synchronizer ( ) , & Layouts : : Synchronizer : : initializationFinished , [ this ] ( ) {
if ( ! m_startupAddViewTemplateName . isEmpty ( ) ) {
//! user requested through cmd startup to add view from specific view template and we can add it after the startup
//! sequence has loaded all required layouts properly
addView ( 0 , m_startupAddViewTemplateName ) ;
m_startupAddViewTemplateName = " " ;
}
} ) ;
2021-08-08 14:26:04 +03:00
m_inStartup = false ;
2022-05-08 13:52:55 +03:00
connect ( qGuiApp , & QGuiApplication : : screenAdded , this , & Corona : : onScreenAdded , Qt : : UniqueConnection ) ;
connect ( qGuiApp , & QGuiApplication : : screenRemoved , this , & Corona : : onScreenRemoved , Qt : : UniqueConnection ) ;
2017-01-24 21:32:22 +03:00
}
2017-01-07 16:27:26 +03:00
}
2018-12-06 15:35:34 +03:00
void Corona : : unload ( )
2017-06-26 22:16:42 +03:00
{
2018-01-08 20:21:34 +03:00
qDebug ( ) < < " unload: removing containments... " ;
2017-06-26 22:16:42 +03:00
while ( ! containments ( ) . isEmpty ( ) ) {
//deleting a containment will remove it from the list due to QObject::destroyed connect in Corona
//this form doesn't crash, while qDeleteAll(containments()) does
delete containments ( ) . first ( ) ;
}
}
2018-12-06 15:35:34 +03:00
void Corona : : setupWaylandIntegration ( )
2017-04-25 19:18:49 +03:00
{
if ( ! KWindowSystem : : isPlatformWayland ( ) ) {
return ;
}
2018-03-01 01:52:05 +03:00
using namespace KWayland : : Client ;
2017-06-24 00:27:58 +03:00
auto connection = ConnectionThread : : fromApplication ( this ) ;
2017-04-25 19:18:49 +03:00
2018-03-01 01:52:05 +03:00
if ( ! connection ) {
2017-04-25 19:18:49 +03:00
return ;
2018-03-01 01:52:05 +03:00
}
2017-04-25 19:18:49 +03:00
2017-06-16 00:56:55 +03:00
Registry * registry { new Registry ( this ) } ;
2017-04-25 19:18:49 +03:00
registry - > create ( connection ) ;
2017-06-16 00:56:55 +03:00
connect ( registry , & Registry : : plasmaShellAnnounced , this
2019-04-07 19:35:55 +03:00
, [ this , registry ] ( quint32 name , quint32 version ) {
2018-12-06 15:35:34 +03:00
m_waylandCorona = registry - > createPlasmaShell ( name , version , this ) ;
2017-06-16 00:56:55 +03:00
} ) ;
2018-03-02 00:53:28 +03:00
QObject : : connect ( registry , & KWayland : : Client : : Registry : : plasmaWindowManagementAnnounced ,
2019-04-07 19:35:55 +03:00
[ this , registry ] ( quint32 name , quint32 version ) {
2018-03-02 00:53:28 +03:00
KWayland : : Client : : PlasmaWindowManagement * pwm = registry - > createPlasmaWindowManagement ( name , version , this ) ;
2019-05-11 15:43:10 +03:00
WindowSystem : : WaylandInterface * wI = qobject_cast < WindowSystem : : WaylandInterface * > ( m_wm ) ;
2018-03-02 00:53:28 +03:00
if ( wI ) {
wI - > initWindowManagement ( pwm ) ;
}
} ) ;
2022-01-08 20:31:41 +03:00
2019-05-26 00:58:42 +03:00
QObject : : connect ( registry , & KWayland : : Client : : Registry : : plasmaVirtualDesktopManagementAnnounced ,
[ this , registry ] ( quint32 name , quint32 version ) {
KWayland : : Client : : PlasmaVirtualDesktopManagement * vdm = registry - > createPlasmaVirtualDesktopManagement ( name , version , this ) ;
WindowSystem : : WaylandInterface * wI = qobject_cast < WindowSystem : : WaylandInterface * > ( m_wm ) ;
if ( wI ) {
wI - > initVirtualDesktopManagement ( vdm ) ;
}
} ) ;
2022-01-08 20:31:41 +03:00
2019-05-26 00:58:42 +03:00
2017-04-25 19:18:49 +03:00
registry - > setup ( ) ;
2018-03-01 01:52:05 +03:00
connection - > roundtrip ( ) ;
2017-04-25 19:18:49 +03:00
}
2018-12-06 15:35:34 +03:00
KWayland : : Client : : PlasmaShell * Corona : : waylandCoronaInterface ( ) const
2017-04-25 19:18:49 +03:00
{
2018-12-06 15:35:34 +03:00
return m_waylandCorona ;
2017-04-25 19:18:49 +03:00
}
2018-12-06 15:35:34 +03:00
void Corona : : cleanConfig ( )
2017-01-21 21:08:47 +03:00
{
auto containmentsEntries = config ( ) - > group ( " Containments " ) ;
bool changed = false ;
2019-04-04 23:55:44 +03:00
for ( const auto & cId : containmentsEntries . groupList ( ) ) {
2017-02-06 04:55:41 +03:00
if ( ! containmentExists ( cId . toUInt ( ) ) ) {
2017-01-22 02:28:39 +03:00
//cleanup obsolete containments
containmentsEntries . group ( cId ) . deleteGroup ( ) ;
2017-01-21 21:08:47 +03:00
changed = true ;
2017-01-22 02:28:39 +03:00
qDebug ( ) < < " obsolete containment configuration deleted: " < < cId ;
} else {
//cleanup obsolete applets of running containments
auto appletsEntries = containmentsEntries . group ( cId ) . group ( " Applets " ) ;
2019-04-04 23:55:44 +03:00
for ( const auto & appletId : appletsEntries . groupList ( ) ) {
2017-02-06 04:55:41 +03:00
if ( ! appletExists ( cId . toUInt ( ) , appletId . toUInt ( ) ) ) {
2017-01-22 02:28:39 +03:00
appletsEntries . group ( appletId ) . deleteGroup ( ) ;
changed = true ;
qDebug ( ) < < " obsolete applet configuration deleted: " < < appletId ;
}
}
2017-01-21 21:08:47 +03:00
}
}
if ( changed ) {
config ( ) - > sync ( ) ;
qDebug ( ) < < " configuration file cleaned... " ;
}
}
2018-12-06 15:35:34 +03:00
bool Corona : : containmentExists ( uint id ) const
2017-01-21 21:08:47 +03:00
{
2019-04-04 23:55:44 +03:00
for ( const auto containment : containments ( ) ) {
2017-01-21 21:08:47 +03:00
if ( id = = containment - > id ( ) ) {
return true ;
}
}
return false ;
}
2018-12-06 15:35:34 +03:00
bool Corona : : appletExists ( uint containmentId , uint appletId ) const
2017-01-22 02:28:39 +03:00
{
Plasma : : Containment * containment = nullptr ;
2019-04-04 23:55:44 +03:00
for ( const auto cont : containments ( ) ) {
2017-01-22 02:28:39 +03:00
if ( containmentId = = cont - > id ( ) ) {
containment = cont ;
break ;
}
}
if ( ! containment ) {
return false ;
}
2019-04-04 23:55:44 +03:00
for ( const auto applet : containment - > applets ( ) ) {
2017-01-22 02:28:39 +03:00
if ( applet - > id ( ) = = appletId ) {
return true ;
}
}
return false ;
}
2020-07-04 14:44:27 +03:00
bool Corona : : inQuit ( ) const
{
return m_inQuit ;
}
2018-12-06 15:35:34 +03:00
KActivities : : Consumer * Corona : : activitiesConsumer ( ) const
2018-01-13 20:27:32 +03:00
{
2020-03-18 18:39:19 +03:00
return m_activitiesConsumer ;
2018-01-13 20:27:32 +03:00
}
2020-01-13 00:51:46 +03:00
PanelShadows * Corona : : dialogShadows ( ) const
{
return m_dialogShadows ;
}
2019-02-03 01:10:07 +03:00
GlobalShortcuts * Corona : : globalShortcuts ( ) const
{
return m_globalShortcuts ;
}
2018-12-06 15:35:34 +03:00
ScreenPool * Corona : : screenPool ( ) const
2017-02-24 21:58:21 +03:00
{
return m_screenPool ;
}
2018-12-06 15:35:34 +03:00
UniversalSettings * Corona : : universalSettings ( ) const
2017-07-02 16:12:58 +03:00
{
return m_universalSettings ;
}
2020-06-21 13:42:20 +03:00
ViewSettingsFactory * Corona : : viewSettingsFactory ( ) const
{
return m_viewSettingsFactory ;
}
2019-05-11 15:43:10 +03:00
WindowSystem : : AbstractWindowInterface * Corona : : wm ( ) const
2018-03-02 00:53:28 +03:00
{
return m_wm ;
}
2019-03-23 18:49:09 +03:00
Indicator : : Factory * Corona : : indicatorFactory ( ) const
{
return m_indicatorFactory ;
}
2019-05-09 17:12:57 +03:00
Layouts : : Manager * Corona : : layoutsManager ( ) const
{
return m_layoutsManager ;
}
2020-08-12 12:02:46 +03:00
Templates : : Manager * Corona : : templatesManager ( ) const
{
return m_templatesManager ;
}
2018-12-13 21:55:03 +03:00
PlasmaExtended : : ScreenPool * Corona : : plasmaScreenPool ( ) const
{
return m_plasmaScreenPool ;
}
2018-12-13 21:03:14 +03:00
PlasmaExtended : : Theme * Corona : : themeExtended ( ) const
2018-10-26 23:36:40 +03:00
{
return m_themeExtended ;
}
2018-12-06 15:35:34 +03:00
int Corona : : numScreens ( ) const
2016-12-25 10:25:27 +03:00
{
return qGuiApp - > screens ( ) . count ( ) ;
}
2018-12-06 15:35:34 +03:00
QRect Corona : : screenGeometry ( int id ) const
2016-12-25 10:25:27 +03:00
{
const auto screens = qGuiApp - > screens ( ) ;
2022-05-08 13:52:55 +03:00
const QScreen * screen { m_screenPool - > primaryScreen ( ) } ;
2017-04-04 14:39:17 +03:00
QString screenName ;
2021-02-17 13:24:36 +03:00
if ( m_screenPool - > hasScreenId ( id ) ) {
2017-04-04 14:39:17 +03:00
screenName = m_screenPool - > connector ( id ) ;
2019-05-01 18:52:03 +03:00
}
2017-01-16 22:07:49 +03:00
2019-04-04 23:55:44 +03:00
for ( const auto scr : screens ) {
2017-04-04 14:39:17 +03:00
if ( scr - > name ( ) = = screenName ) {
screen = scr ;
break ;
}
2016-12-25 10:25:27 +03:00
}
2017-01-16 22:07:49 +03:00
2017-04-04 14:39:17 +03:00
return screen - > geometry ( ) ;
2016-12-25 10:25:27 +03:00
}
2020-01-04 20:21:10 +03:00
CentralLayout * Corona : : centralLayout ( QString name ) const
2016-12-25 10:25:27 +03:00
{
2020-01-04 20:21:10 +03:00
CentralLayout * result { nullptr } ;
2018-01-13 22:10:58 +03:00
2020-08-25 19:30:33 +03:00
if ( ! name . isEmpty ( ) ) {
result = m_layoutsManager - > synchronizer ( ) - > centralLayout ( name ) ;
2020-01-04 20:21:10 +03:00
}
return result ;
}
2019-04-08 20:16:29 +03:00
2020-03-01 18:19:24 +03:00
Layout : : GenericLayout * Corona : : layout ( QString name ) const
{
Layout : : GenericLayout * result { nullptr } ;
2020-08-25 19:30:33 +03:00
if ( ! name . isEmpty ( ) ) {
2020-03-01 18:19:24 +03:00
result = m_layoutsManager - > synchronizer ( ) - > layout ( name ) ;
}
return result ;
}
2020-01-04 20:21:10 +03:00
QRegion Corona : : availableScreenRegion ( int id ) const
2021-07-09 10:20:36 +03:00
{
//! ignore modes are added in order for notifications to be placed
//! in better positioning and not overlap with sidebars or usually hidden views
QList < Types : : Visibility > ignoremodes ( { Latte : : Types : : AutoHide ,
Latte : : Types : : SidebarOnDemand ,
Latte : : Types : : SidebarAutoHide } ) ;
return availableScreenRegionWithCriteria ( id ,
QString ( ) ,
ignoremodes ) ;
2020-01-04 20:21:10 +03:00
}
QRegion Corona : : availableScreenRegionWithCriteria ( int id ,
2020-08-25 22:15:39 +03:00
QString activityid ,
2020-03-07 16:36:39 +03:00
QList < Types : : Visibility > ignoreModes ,
QList < Plasma : : Types : : Location > ignoreEdges ,
2020-04-12 13:41:49 +03:00
bool ignoreExternalPanels ,
bool desktopUse ) const
2020-01-04 20:21:10 +03:00
{
const QScreen * screen = m_screenPool - > screenForId ( id ) ;
2020-08-25 22:15:39 +03:00
bool inCurrentActivity { activityid . isEmpty ( ) } ;
2020-01-04 20:21:10 +03:00
if ( ! screen ) {
return { } ;
2018-01-13 22:10:58 +03:00
}
2018-01-08 20:21:34 +03:00
2020-03-07 19:58:05 +03:00
QRegion available = ignoreExternalPanels ? screen - > geometry ( ) : screen - > availableGeometry ( ) ;
2017-03-02 23:10:26 +03:00
2020-08-25 22:15:39 +03:00
QList < Latte : : View * > views ;
if ( inCurrentActivity ) {
views = m_layoutsManager - > synchronizer ( ) - > viewsBasedOnActivityId ( m_activitiesConsumer - > currentActivity ( ) ) ;
} else {
views = m_layoutsManager - > synchronizer ( ) - > viewsBasedOnActivityId ( activityid ) ;
}
if ( views . isEmpty ( ) ) {
2020-01-04 20:21:10 +03:00
return available ;
}
2020-03-07 19:58:05 +03:00
//! blacklist irrelevant visibility modes
if ( ! ignoreModes . contains ( Latte : : Types : : None ) ) {
ignoreModes < < Latte : : Types : : None ;
}
if ( ! ignoreModes . contains ( Latte : : Types : : NormalWindow ) ) {
ignoreModes < < Latte : : Types : : NormalWindow ;
}
2020-03-07 16:36:39 +03:00
bool allEdges = ignoreEdges . isEmpty ( ) ;
2020-01-04 20:21:10 +03:00
2019-04-07 19:35:55 +03:00
for ( const auto * view : views ) {
2021-12-27 23:46:01 +03:00
bool inDesktopOffScreenStartup = desktopUse & & view & & view - > positioner ( ) & & view - > positioner ( ) - > isOffScreen ( ) ;
if ( view & & view - > containment ( ) & & view - > screen ( ) = = screen & & ! inDesktopOffScreenStartup
2020-03-07 16:36:39 +03:00
& & ( ( allEdges | | ! ignoreEdges . contains ( view - > location ( ) ) )
2020-03-07 19:58:05 +03:00
& & ( view - > visibility ( ) & & ! ignoreModes . contains ( view - > visibility ( ) - > mode ( ) ) ) ) ) {
2019-05-01 23:14:38 +03:00
int realThickness = view - > normalThickness ( ) ;
2019-04-07 19:35:55 +03:00
2020-05-11 11:27:22 +03:00
int x = 0 ; int y = 0 ; int w = 0 ; int h = 0 ;
2020-04-12 13:41:49 +03:00
2020-05-11 11:27:22 +03:00
switch ( view - > formFactor ( ) ) {
case Plasma : : Types : : Horizontal :
if ( view - > behaveAsPlasmaPanel ( ) ) {
w = view - > width ( ) ;
x = view - > x ( ) ;
2019-04-07 19:35:55 +03:00
} else {
2020-05-11 11:27:22 +03:00
w = view - > maxLength ( ) * view - > width ( ) ;
int offsetW = view - > offset ( ) * view - > width ( ) ;
2019-04-07 19:35:55 +03:00
switch ( view - > alignment ( ) ) {
case Latte : : Types : : Left :
2020-05-11 11:27:22 +03:00
x = view - > x ( ) + offsetW ;
2019-04-07 19:35:55 +03:00
break ;
2017-07-03 10:41:59 +03:00
2019-04-07 19:35:55 +03:00
case Latte : : Types : : Center :
case Latte : : Types : : Justify :
2021-12-27 23:46:01 +03:00
x = ( view - > geometry ( ) . center ( ) . x ( ) - w / 2 ) + 1 + offsetW ;
2018-01-14 18:30:29 +03:00
break ;
2019-04-07 19:35:55 +03:00
case Latte : : Types : : Right :
2022-01-16 03:27:40 +03:00
x = view - > geometry ( ) . right ( ) + 1 - w - offsetW ;
2019-04-07 19:35:55 +03:00
break ;
}
}
break ;
2020-05-11 11:27:22 +03:00
case Plasma : : Types : : Vertical :
2019-04-07 19:35:55 +03:00
if ( view - > behaveAsPlasmaPanel ( ) ) {
2020-05-11 11:27:22 +03:00
h = view - > height ( ) ;
y = view - > y ( ) ;
2019-04-07 19:35:55 +03:00
} else {
2020-05-11 11:27:22 +03:00
h = view - > maxLength ( ) * view - > height ( ) ;
int offsetH = view - > offset ( ) * view - > height ( ) ;
2019-04-07 19:35:55 +03:00
switch ( view - > alignment ( ) ) {
2020-05-11 11:27:22 +03:00
case Latte : : Types : : Top :
y = view - > y ( ) + offsetH ;
2019-04-07 19:35:55 +03:00
break ;
2017-07-03 10:41:59 +03:00
2019-04-07 19:35:55 +03:00
case Latte : : Types : : Center :
case Latte : : Types : : Justify :
2021-12-27 23:46:01 +03:00
y = ( view - > geometry ( ) . center ( ) . y ( ) - h / 2 ) + 1 + offsetH ;
2018-01-14 18:30:29 +03:00
break ;
2017-03-02 23:10:26 +03:00
2020-05-11 11:27:22 +03:00
case Latte : : Types : : Bottom :
y = view - > geometry ( ) . bottom ( ) - h - offsetH ;
2018-01-14 18:30:29 +03:00
break ;
2019-04-07 19:35:55 +03:00
}
2018-01-14 18:30:29 +03:00
}
2019-04-07 19:35:55 +03:00
break ;
2020-05-11 11:27:22 +03:00
}
2019-04-07 19:35:55 +03:00
2020-05-11 11:27:22 +03:00
// Usually availableScreenRect is used by the desktop,
// but Latte don't have desktop, then here just
// need calculate available space for top and bottom location,
// because the left and right are those who dodge others views
switch ( view - > location ( ) ) {
case Plasma : : Types : : TopEdge :
2020-01-22 22:36:30 +03:00
if ( view - > behaveAsPlasmaPanel ( ) ) {
2020-04-12 13:41:49 +03:00
QRect viewGeometry = view - > geometry ( ) ;
if ( desktopUse ) {
//! ignore any real window slide outs in all cases
2020-05-11 11:27:22 +03:00
viewGeometry . moveTop ( view - > screen ( ) - > geometry ( ) . top ( ) + view - > screenEdgeMargin ( ) ) ;
2020-04-12 13:41:49 +03:00
}
available - = viewGeometry ;
2020-05-11 11:27:22 +03:00
} else {
y = view - > y ( ) ;
available - = QRect ( x , y , w , realThickness ) ;
}
2020-01-22 22:36:30 +03:00
2020-05-11 11:27:22 +03:00
break ;
2020-01-22 22:36:30 +03:00
2020-05-11 11:27:22 +03:00
case Plasma : : Types : : BottomEdge :
if ( view - > behaveAsPlasmaPanel ( ) ) {
QRect viewGeometry = view - > geometry ( ) ;
2020-01-22 22:36:30 +03:00
2020-05-11 11:27:22 +03:00
if ( desktopUse ) {
//! ignore any real window slide outs in all cases
viewGeometry . moveTop ( view - > screen ( ) - > geometry ( ) . bottom ( ) - view - > screenEdgeMargin ( ) - viewGeometry . height ( ) ) ;
2020-01-22 22:36:30 +03:00
}
2020-05-11 11:27:22 +03:00
available - = viewGeometry ;
} else {
y = view - > geometry ( ) . bottom ( ) - realThickness + 1 ;
available - = QRect ( x , y , w , realThickness ) ;
2020-01-22 22:36:30 +03:00
}
break ;
2020-05-11 11:27:22 +03:00
case Plasma : : Types : : LeftEdge :
2020-01-22 22:36:30 +03:00
if ( view - > behaveAsPlasmaPanel ( ) ) {
2020-04-12 13:41:49 +03:00
QRect viewGeometry = view - > geometry ( ) ;
if ( desktopUse ) {
//! ignore any real window slide outs in all cases
2020-05-11 11:27:22 +03:00
viewGeometry . moveLeft ( view - > screen ( ) - > geometry ( ) . left ( ) + view - > screenEdgeMargin ( ) ) ;
2020-04-12 13:41:49 +03:00
}
available - = viewGeometry ;
2020-01-22 22:36:30 +03:00
} else {
2020-05-11 11:27:22 +03:00
x = view - > x ( ) ;
available - = QRect ( x , y , realThickness , h ) ;
}
2020-01-22 22:36:30 +03:00
2020-05-11 11:27:22 +03:00
break ;
2020-01-22 22:36:30 +03:00
2020-05-11 11:27:22 +03:00
case Plasma : : Types : : RightEdge :
if ( view - > behaveAsPlasmaPanel ( ) ) {
QRect viewGeometry = view - > geometry ( ) ;
2020-01-22 22:36:30 +03:00
2020-05-11 11:27:22 +03:00
if ( desktopUse ) {
//! ignore any real window slide outs in all cases
viewGeometry . moveLeft ( view - > screen ( ) - > geometry ( ) . right ( ) - view - > screenEdgeMargin ( ) - viewGeometry . width ( ) ) ;
2020-01-22 22:36:30 +03:00
}
2020-05-11 11:27:22 +03:00
available - = viewGeometry ;
} else {
x = view - > geometry ( ) . right ( ) - realThickness + 1 ;
available - = QRect ( x , y , realThickness , h ) ;
2020-01-22 22:36:30 +03:00
}
break ;
2019-04-07 19:35:55 +03:00
default :
//! bypass clang warnings
break ;
2017-03-02 23:10:26 +03:00
}
}
}
/*qDebug() << "::::: FREE AREAS :::::";
2017-03-04 16:29:56 +03:00
2017-03-02 23:10:26 +03:00
for ( int i = 0 ; i < available . rectCount ( ) ; + + i ) {
qDebug ( ) < < available . rects ( ) . at ( i ) ;
}
2017-03-04 16:29:56 +03:00
2017-03-02 23:10:26 +03:00
qDebug ( ) < < " ::::: END OF FREE AREAS ::::: " ; */
return available ;
2016-12-25 10:25:27 +03:00
}
2018-12-06 15:35:34 +03:00
QRect Corona : : availableScreenRect ( int id ) const
2017-12-24 21:54:45 +03:00
{
2021-07-09 10:20:36 +03:00
//! ignore modes are added in order for notifications to be placed
//! in better positioning and not overlap with sidebars or usually hidden views
QList < Types : : Visibility > ignoremodes ( { Latte : : Types : : AutoHide ,
Latte : : Types : : SidebarOnDemand ,
Latte : : Types : : SidebarAutoHide } ) ;
return availableScreenRectWithCriteria ( id ,
QString ( ) ,
ignoremodes ) ;
2017-12-24 21:54:45 +03:00
}
2020-01-04 20:21:10 +03:00
QRect Corona : : availableScreenRectWithCriteria ( int id ,
2020-08-25 22:15:39 +03:00
QString activityid ,
2020-03-07 16:36:39 +03:00
QList < Types : : Visibility > ignoreModes ,
QList < Plasma : : Types : : Location > ignoreEdges ,
2020-04-12 13:41:49 +03:00
bool ignoreExternalPanels ,
bool desktopUse ) const
2016-12-25 10:25:27 +03:00
{
2020-01-04 20:21:10 +03:00
const QScreen * screen = m_screenPool - > screenForId ( id ) ;
2020-08-25 22:15:39 +03:00
bool inCurrentActivity { activityid . isEmpty ( ) } ;
2017-02-10 02:11:34 +03:00
2020-01-02 11:32:31 +03:00
if ( ! screen ) {
2017-02-11 06:12:17 +03:00
return { } ;
2020-01-02 11:32:31 +03:00
}
2017-01-16 22:07:49 +03:00
2020-03-07 19:58:05 +03:00
QRect available = ignoreExternalPanels ? screen - > geometry ( ) : screen - > availableGeometry ( ) ;
2019-02-07 10:38:01 +03:00
2020-08-25 22:15:39 +03:00
QList < Latte : : View * > views ;
if ( inCurrentActivity ) {
views = m_layoutsManager - > synchronizer ( ) - > viewsBasedOnActivityId ( m_activitiesConsumer - > currentActivity ( ) ) ;
} else {
views = m_layoutsManager - > synchronizer ( ) - > viewsBasedOnActivityId ( activityid ) ;
}
if ( views . isEmpty ( ) ) {
2020-01-04 20:21:10 +03:00
return available ;
2019-02-07 10:38:01 +03:00
}
2018-01-08 20:21:34 +03:00
2020-03-07 19:58:05 +03:00
//! blacklist irrelevant visibility modes
if ( ! ignoreModes . contains ( Latte : : Types : : None ) ) {
ignoreModes < < Latte : : Types : : None ;
}
if ( ! ignoreModes . contains ( Latte : : Types : : NormalWindow ) ) {
ignoreModes < < Latte : : Types : : NormalWindow ;
}
2020-03-07 16:36:39 +03:00
bool allEdges = ignoreEdges . isEmpty ( ) ;
2020-01-04 20:21:10 +03:00
2019-04-07 19:35:55 +03:00
for ( const auto * view : views ) {
2021-12-27 23:46:01 +03:00
bool inDesktopOffScreenStartup = desktopUse & & view & & view - > positioner ( ) & & view - > positioner ( ) - > isOffScreen ( ) ;
if ( view & & view - > containment ( ) & & view - > screen ( ) = = screen & & ! inDesktopOffScreenStartup
2020-03-07 16:36:39 +03:00
& & ( ( allEdges | | ! ignoreEdges . contains ( view - > location ( ) ) )
2020-03-07 19:58:05 +03:00
& & ( view - > visibility ( ) & & ! ignoreModes . contains ( view - > visibility ( ) - > mode ( ) ) ) ) ) {
2017-12-24 21:54:45 +03:00
2020-04-12 13:41:49 +03:00
int appliedThickness = view - > behaveAsPlasmaPanel ( ) ? view - > screenEdgeMargin ( ) + view - > normalThickness ( ) : view - > normalThickness ( ) ;
2019-04-07 19:35:55 +03:00
// Usually availableScreenRect is used by the desktop,
// but Latte don't have desktop, then here just
// need calculate available space for top and bottom location,
// because the left and right are those who dodge others docks
switch ( view - > location ( ) ) {
case Plasma : : Types : : TopEdge :
2020-04-12 13:41:49 +03:00
if ( view - > behaveAsPlasmaPanel ( ) & & desktopUse ) {
//! ignore any real window slide outs in all cases
available . setTop ( qMax ( available . top ( ) , view - > screen ( ) - > geometry ( ) . top ( ) + appliedThickness ) ) ;
} else {
available . setTop ( qMax ( available . top ( ) , view - > y ( ) + appliedThickness ) ) ;
}
2019-04-07 19:35:55 +03:00
break ;
2017-02-12 02:59:09 +03:00
2019-04-07 19:35:55 +03:00
case Plasma : : Types : : BottomEdge :
2020-04-12 13:41:49 +03:00
if ( view - > behaveAsPlasmaPanel ( ) & & desktopUse ) {
//! ignore any real window slide outs in all cases
available . setBottom ( qMin ( available . bottom ( ) , view - > screen ( ) - > geometry ( ) . bottom ( ) - appliedThickness ) ) ;
} else {
available . setBottom ( qMin ( available . bottom ( ) , view - > y ( ) + view - > height ( ) - appliedThickness ) ) ;
}
2019-04-07 19:35:55 +03:00
break ;
2017-12-24 21:54:45 +03:00
2019-04-07 19:35:55 +03:00
case Plasma : : Types : : LeftEdge :
2020-04-12 13:41:49 +03:00
if ( view - > behaveAsPlasmaPanel ( ) & & desktopUse ) {
//! ignore any real window slide outs in all cases
2020-04-19 00:59:15 +03:00
available . setLeft ( qMax ( available . left ( ) , view - > screen ( ) - > geometry ( ) . left ( ) + appliedThickness ) ) ;
2020-04-12 13:41:49 +03:00
} else {
available . setLeft ( qMax ( available . left ( ) , view - > x ( ) + appliedThickness ) ) ;
}
2019-04-07 19:35:55 +03:00
break ;
2017-12-24 21:54:45 +03:00
2019-04-07 19:35:55 +03:00
case Plasma : : Types : : RightEdge :
2020-04-12 13:41:49 +03:00
if ( view - > behaveAsPlasmaPanel ( ) & & desktopUse ) {
//! ignore any real window slide outs in all cases
available . setRight ( qMin ( available . right ( ) , view - > screen ( ) - > geometry ( ) . right ( ) - appliedThickness ) ) ;
} else {
available . setRight ( qMin ( available . right ( ) , view - > x ( ) + view - > width ( ) - appliedThickness ) ) ;
}
2019-04-07 19:35:55 +03:00
break ;
2017-10-21 10:21:40 +03:00
2019-04-07 19:35:55 +03:00
default :
//! bypass clang warnings
break ;
2017-02-10 02:11:34 +03:00
}
}
}
2017-02-11 06:12:17 +03:00
return available ;
2016-12-25 10:25:27 +03:00
}
2022-05-08 13:52:55 +03:00
void Corona : : onScreenAdded ( QScreen * screen )
2017-02-24 21:58:21 +03:00
{
Q_ASSERT ( screen ) ;
2017-02-26 03:43:41 +03:00
2017-02-26 21:06:31 +03:00
int id = m_screenPool - > id ( screen - > name ( ) ) ;
2017-02-27 20:46:10 +03:00
if ( id = = - 1 ) {
2021-02-17 15:20:44 +03:00
m_screenPool - > insertScreenMapping ( screen - > name ( ) ) ;
2017-02-26 21:06:31 +03:00
}
2018-11-23 17:57:33 +03:00
2022-05-08 13:52:55 +03:00
connect ( screen , & QScreen : : geometryChanged , this , & Corona : : onScreenGeometryChanged ) ;
2018-11-23 17:57:33 +03:00
emit availableScreenRectChanged ( ) ;
emit screenAdded ( m_screenPool - > id ( screen - > name ( ) ) ) ;
2019-09-08 00:16:32 +03:00
2022-05-08 13:52:55 +03:00
onScreenCountChanged ( ) ;
2017-02-24 21:58:21 +03:00
}
2022-05-08 13:52:55 +03:00
void Corona : : onScreenRemoved ( QScreen * screen )
2017-02-24 21:58:21 +03:00
{
2022-05-08 13:52:55 +03:00
disconnect ( screen , & QScreen : : geometryChanged , this , & Corona : : onScreenGeometryChanged ) ;
onScreenCountChanged ( ) ;
2017-02-24 21:58:21 +03:00
}
2022-05-08 13:52:55 +03:00
void Corona : : onScreenCountChanged ( )
2017-02-24 21:58:21 +03:00
{
2022-05-08 13:52:55 +03:00
m_viewsScreenSyncTimer . start ( ) ;
2017-02-26 03:43:41 +03:00
}
2022-05-08 13:52:55 +03:00
void Corona : : onScreenGeometryChanged ( const QRect & geometry )
2017-02-26 03:43:41 +03:00
{
2022-05-08 13:52:55 +03:00
Q_UNUSED ( geometry ) ;
QScreen * screen = qobject_cast < QScreen * > ( sender ( ) ) ;
if ( ! screen ) {
return ;
}
const int id = m_screenPool - > id ( screen - > name ( ) ) ;
if ( id > = 0 ) {
emit screenGeometryChanged ( id ) ;
emit availableScreenRegionChanged ( ) ;
emit availableScreenRectChanged ( ) ;
}
2017-02-26 03:43:41 +03:00
}
2018-12-06 13:51:15 +03:00
//! the central functions that updates loading/unloading latteviews
2017-03-02 19:07:29 +03:00
//! concerning screen changed (for multi-screen setups mainly)
2018-12-06 15:35:34 +03:00
void Corona : : syncLatteViewsToScreens ( )
2017-02-26 03:43:41 +03:00
{
2019-05-11 09:23:14 +03:00
m_layoutsManager - > synchronizer ( ) - > syncLatteViewsToScreens ( ) ;
2017-02-24 21:58:21 +03:00
}
2018-12-06 15:35:34 +03:00
int Corona : : primaryScreenId ( ) const
2016-12-30 17:51:44 +03:00
{
2022-05-08 13:52:55 +03:00
return m_screenPool - > primaryScreenId ( ) ;
2016-12-30 17:51:44 +03:00
}
2020-03-05 21:09:22 +03:00
void Corona : : quitApplication ( )
2017-01-05 01:28:25 +03:00
{
2020-07-04 14:44:27 +03:00
m_inQuit = true ;
2018-03-26 20:31:17 +03:00
//! this code must be called asynchronously because it is called
//! also from qml (Settings window).
2019-05-26 00:58:42 +03:00
QTimer : : singleShot ( 300 , [ this ] ( ) {
2019-05-09 17:12:57 +03:00
m_layoutsManager - > hideLatteSettingsDialog ( ) ;
2019-05-11 09:23:14 +03:00
m_layoutsManager - > synchronizer ( ) - > hideAllViews ( ) ;
2018-03-26 20:31:17 +03:00
} ) ;
2018-12-06 16:57:20 +03:00
//! give the time for the views to hide themselves
2019-05-26 00:58:42 +03:00
QTimer : : singleShot ( 800 , [ this ] ( ) {
2018-02-24 11:54:35 +03:00
qGuiApp - > quit ( ) ;
} ) ;
2017-01-05 01:28:25 +03:00
}
2018-12-06 15:35:34 +03:00
void Corona : : aboutApplication ( )
2017-01-29 08:16:28 +03:00
{
if ( aboutDialog ) {
aboutDialog - > hide ( ) ;
aboutDialog - > deleteLater ( ) ;
}
aboutDialog = new KAboutApplicationDialog ( KAboutData : : applicationData ( ) ) ;
connect ( aboutDialog . data ( ) , & QDialog : : finished , aboutDialog . data ( ) , & QObject : : deleteLater ) ;
2018-03-02 00:53:28 +03:00
m_wm - > skipTaskBar ( * aboutDialog ) ;
2019-12-26 22:10:11 +03:00
m_wm - > setKeepAbove ( aboutDialog - > winId ( ) , true ) ;
2017-01-29 08:16:28 +03:00
aboutDialog - > show ( ) ;
}
2021-02-06 01:14:11 +03:00
void Corona : : loadDefaultLayout ( )
{
//disabled
}
2018-12-06 15:35:34 +03:00
int Corona : : screenForContainment ( const Plasma : : Containment * containment ) const
2016-12-25 10:25:27 +03:00
{
2017-02-12 16:58:39 +03:00
//FIXME: indexOf is not a proper way to support multi-screen
// as for environment to environment the indexes change
// also there is the following issue triggered
2018-12-06 13:51:15 +03:00
// from latteView adaptToScreen()
2017-02-12 16:58:39 +03:00
//
// in a multi-screen environment that
// primary screen is not set to 0 it was
// created an endless showing loop at
// startup (catch-up race) between
// screen:0 and primaryScreen
2017-02-24 21:58:21 +03:00
//case in which this containment is child of an applet, hello systray :)
if ( Plasma : : Applet * parentApplet = qobject_cast < Plasma : : Applet * > ( containment - > parent ( ) ) ) {
if ( Plasma : : Containment * cont = parentApplet - > containment ( ) ) {
return screenForContainment ( cont ) ;
} else {
return - 1 ;
}
}
2019-06-15 21:38:07 +03:00
Plasma : : Containment * c = const_cast < Plasma : : Containment * > ( containment ) ;
2021-04-13 10:56:15 +03:00
int scrId = m_layoutsManager - > synchronizer ( ) - > screenForContainment ( c ) ;
2017-02-24 21:58:21 +03:00
2021-04-13 10:56:15 +03:00
if ( scrId > = 0 ) {
return scrId ;
2017-02-24 21:58:21 +03:00
}
2021-04-13 10:56:15 +03:00
return containment - > lastScreen ( ) ;
2016-12-25 10:25:27 +03:00
}
2018-12-06 15:35:34 +03:00
void Corona : : showAlternativesForApplet ( Plasma : : Applet * applet )
2017-02-15 07:54:41 +03:00
{
const QString alternativesQML = kPackage ( ) . filePath ( " appletalternativesui " ) ;
2017-02-24 21:58:21 +03:00
2017-02-15 07:54:41 +03:00
if ( alternativesQML . isEmpty ( ) ) {
return ;
}
2019-06-15 21:38:07 +03:00
Latte : : View * latteView = m_layoutsManager - > synchronizer ( ) - > viewForContainment ( applet - > containment ( ) ) ;
2017-08-09 04:52:42 +03:00
2019-02-18 18:46:53 +03:00
KDeclarative : : QmlObjectSharedEngine * qmlObj { nullptr } ;
2017-08-09 04:52:42 +03:00
2018-12-06 13:51:15 +03:00
if ( latteView ) {
latteView - > setAlternativesIsShown ( true ) ;
2019-02-18 18:46:53 +03:00
qmlObj = new KDeclarative : : QmlObjectSharedEngine ( latteView ) ;
2017-08-09 04:52:42 +03:00
} else {
2019-02-18 18:46:53 +03:00
qmlObj = new KDeclarative : : QmlObjectSharedEngine ( this ) ;
2017-08-09 04:52:42 +03:00
}
2017-02-15 07:54:41 +03:00
qmlObj - > setInitializationDelayed ( true ) ;
qmlObj - > setSource ( QUrl : : fromLocalFile ( alternativesQML ) ) ;
AlternativesHelper * helper = new AlternativesHelper ( applet , qmlObj ) ;
qmlObj - > rootContext ( ) - > setContextProperty ( QStringLiteral ( " alternativesHelper " ) , helper ) ;
m_alternativesObjects < < qmlObj ;
qmlObj - > completeInitialization ( ) ;
2017-08-09 03:33:03 +03:00
2017-08-09 04:52:42 +03:00
//! Alternative dialog signals
2018-12-06 13:51:15 +03:00
connect ( helper , & QObject : : destroyed , this , [ latteView ] ( ) {
latteView - > setAlternativesIsShown ( false ) ;
2017-08-09 03:33:03 +03:00
} ) ;
2017-02-15 07:54:41 +03:00
connect ( qmlObj - > rootObject ( ) , SIGNAL ( visibleChanged ( bool ) ) ,
this , SLOT ( alternativesVisibilityChanged ( bool ) ) ) ;
2017-02-24 21:58:21 +03:00
connect ( applet , & Plasma : : Applet : : destroyedChanged , this , [ this , qmlObj ] ( bool destroyed ) {
2017-02-15 07:54:41 +03:00
if ( ! destroyed ) {
return ;
}
2017-02-24 21:58:21 +03:00
2019-02-18 18:46:53 +03:00
QMutableListIterator < KDeclarative : : QmlObjectSharedEngine * > it ( m_alternativesObjects ) ;
2017-02-24 21:58:21 +03:00
2017-02-15 07:54:41 +03:00
while ( it . hasNext ( ) ) {
2019-02-18 18:46:53 +03:00
KDeclarative : : QmlObjectSharedEngine * obj = it . next ( ) ;
2017-02-24 21:58:21 +03:00
2017-02-15 07:54:41 +03:00
if ( obj = = qmlObj ) {
it . remove ( ) ;
obj - > deleteLater ( ) ;
}
}
} ) ;
}
2018-12-06 15:35:34 +03:00
void Corona : : alternativesVisibilityChanged ( bool visible )
2017-02-15 07:54:41 +03:00
{
if ( visible ) {
return ;
}
QObject * root = sender ( ) ;
2019-02-18 18:46:53 +03:00
QMutableListIterator < KDeclarative : : QmlObjectSharedEngine * > it ( m_alternativesObjects ) ;
2017-02-24 21:58:21 +03:00
2017-02-15 07:54:41 +03:00
while ( it . hasNext ( ) ) {
2019-02-18 18:46:53 +03:00
KDeclarative : : QmlObjectSharedEngine * obj = it . next ( ) ;
2017-02-24 21:58:21 +03:00
2017-02-15 07:54:41 +03:00
if ( obj - > rootObject ( ) = = root ) {
it . remove ( ) ;
obj - > deleteLater ( ) ;
}
}
}
2018-12-06 15:35:34 +03:00
QStringList Corona : : containmentsIds ( )
2017-07-25 00:01:41 +03:00
{
2018-01-14 18:30:29 +03:00
QStringList ids ;
2017-07-25 00:01:41 +03:00
2019-04-04 23:55:44 +03:00
for ( const auto containment : containments ( ) ) {
2018-01-14 18:30:29 +03:00
ids < < QString : : number ( containment - > id ( ) ) ;
}
return ids ;
2017-07-25 00:01:41 +03:00
}
2018-12-06 15:35:34 +03:00
QStringList Corona : : appletsIds ( )
2017-07-25 00:01:41 +03:00
{
QStringList ids ;
2019-04-04 23:55:44 +03:00
for ( const auto containment : containments ( ) ) {
2018-07-11 20:17:06 +03:00
auto applets = containment - > config ( ) . group ( " Applets " ) ;
ids < < applets . groupList ( ) ;
2017-07-25 00:01:41 +03:00
}
return ids ;
}
2017-03-11 11:06:10 +03:00
//! Activate launcher menu through dbus interface
2018-12-06 15:35:34 +03:00
void Corona : : activateLauncherMenu ( )
2017-03-11 11:06:10 +03:00
{
2017-06-04 01:58:03 +03:00
m_globalShortcuts - > activateLauncherMenu ( ) ;
2017-03-11 11:06:10 +03:00
}
2018-12-06 15:35:34 +03:00
void Corona : : windowColorScheme ( QString windowIdAndScheme )
2018-10-14 13:54:09 +03:00
{
int firstSlash = windowIdAndScheme . indexOf ( " - " ) ;
2018-10-26 23:36:40 +03:00
QString windowIdStr = windowIdAndScheme . mid ( 0 , firstSlash ) ;
QString schemeStr = windowIdAndScheme . mid ( firstSlash + 1 ) ;
2018-10-14 13:54:09 +03:00
2019-02-16 14:16:17 +03:00
if ( KWindowSystem : : isPlatformWayland ( ) ) {
QTimer : : singleShot ( 200 , [ this , schemeStr ] ( ) {
//! [Wayland Case] - give the time to be informed correctly for the active window id
//! otherwise the active window id may not be the same with the one trigerred
//! the color scheme dbus signal
QString windowIdStr = m_wm - > activeWindow ( ) . toString ( ) ;
2019-05-12 02:17:22 +03:00
m_wm - > schemesTracker ( ) - > setColorSchemeForWindow ( windowIdStr . toUInt ( ) , schemeStr ) ;
2019-02-16 14:16:17 +03:00
} ) ;
} else {
2019-05-12 02:17:22 +03:00
m_wm - > schemesTracker ( ) - > setColorSchemeForWindow ( windowIdStr . toUInt ( ) , schemeStr ) ;
2019-02-16 14:16:17 +03:00
}
2018-10-14 13:54:09 +03:00
}
2018-12-06 16:57:20 +03:00
//! update badge for specific view item
2018-12-06 15:35:34 +03:00
void Corona : : updateDockItemBadge ( QString identifier , QString value )
2017-04-11 20:23:43 +03:00
{
2019-02-02 19:01:52 +03:00
m_globalShortcuts - > updateViewItemBadge ( identifier , value ) ;
2017-04-11 20:23:43 +03:00
}
2021-11-30 21:29:23 +03:00
void Corona : : setAutostart ( const bool & enabled )
{
m_universalSettings - > setAutostart ( enabled ) ;
}
2018-02-07 00:14:44 +03:00
2018-12-06 15:35:34 +03:00
void Corona : : switchToLayout ( QString layout )
2018-02-07 00:14:44 +03:00
{
2019-10-23 17:04:45 +03:00
if ( ( layout . startsWith ( " file:/ " ) | | layout . startsWith ( " / " ) ) & & layout . endsWith ( " .layout.latte " ) ) {
2021-11-30 21:29:23 +03:00
importLayoutFile ( layout ) ;
} else {
m_layoutsManager - > switchToLayout ( layout ) ;
}
}
void Corona : : importLayoutFile ( const QString & filepath , const QString & suggestedLayoutName )
{
bool isFilepathValid = ( filepath . startsWith ( " file:/ " ) | | filepath . startsWith ( " / " ) ) & & filepath . endsWith ( " .layout.latte " ) ;
2019-10-23 17:04:45 +03:00
2021-11-30 21:29:23 +03:00
if ( ! isFilepathValid ) {
qDebug ( ) < < i18n ( " The layout cannot be imported from file :: " ) < < filepath ;
return ;
}
2019-10-23 17:04:45 +03:00
2021-11-30 21:29:23 +03:00
//! Import and load runtime a layout through dbus interface
//! It can be used from external programs that want to update runtime
//! the Latte shown layout
QString layoutPath = filepath ;
2019-10-23 17:04:45 +03:00
2021-11-30 21:29:23 +03:00
//! cleanup layout path
if ( layoutPath . startsWith ( " file:/// " ) ) {
layoutPath = layoutPath . remove ( " file:// " ) ;
} else if ( layoutPath . startsWith ( " file:// " ) ) {
layoutPath = layoutPath . remove ( " file:/ " ) ;
}
//! check out layoutpath existence
if ( QFileInfo ( layoutPath ) . exists ( ) ) {
qDebug ( ) < < " Layout is going to be imported and loaded from file :: " < < layoutPath < < " with suggested name :: " < < suggestedLayoutName ;
QString importedLayout = m_layoutsManager - > importer ( ) - > importLayout ( layoutPath , suggestedLayoutName ) ;
if ( importedLayout . isEmpty ( ) ) {
qDebug ( ) < < i18n ( " The layout cannot be imported from file :: " ) < < layoutPath ;
2019-10-23 17:04:45 +03:00
} else {
2021-11-30 21:29:23 +03:00
m_layoutsManager - > switchToLayout ( importedLayout , MemoryUsage : : SingleLayout ) ;
2019-10-23 17:04:45 +03:00
}
} else {
2021-11-30 21:29:23 +03:00
qDebug ( ) < < " Layout from missing file can not be imported and loaded :: " < < layoutPath ;
2019-10-23 17:04:45 +03:00
}
2018-02-07 00:14:44 +03:00
}
2018-12-06 15:35:34 +03:00
void Corona : : showSettingsWindow ( int page )
2018-02-07 00:14:44 +03:00
{
2021-08-08 14:26:04 +03:00
if ( m_inStartup ) {
return ;
}
2020-04-18 16:12:29 +03:00
Settings : : Dialog : : ConfigurationPage p = Settings : : Dialog : : LayoutPage ;
2018-02-07 00:14:44 +03:00
2020-04-18 16:12:29 +03:00
if ( page > = Settings : : Dialog : : LayoutPage & & page < = Settings : : Dialog : : PreferencesPage ) {
p = static_cast < Settings : : Dialog : : ConfigurationPage > ( page ) ;
2018-02-07 00:14:44 +03:00
}
2019-05-09 17:12:57 +03:00
m_layoutsManager - > showLatteSettingsDialog ( p ) ;
2018-02-07 00:14:44 +03:00
}
2021-03-01 17:18:43 +03:00
QStringList Corona : : contextMenuData ( const uint & containmentId )
2018-02-07 00:39:45 +03:00
{
QStringList data ;
2019-02-12 21:53:14 +03:00
Types : : ViewType viewType { Types : : DockView } ;
2021-03-01 17:18:43 +03:00
auto view = m_layoutsManager - > synchronizer ( ) - > viewForContainment ( containmentId ) ;
2018-02-07 00:39:45 +03:00
2020-08-25 19:30:33 +03:00
if ( view ) {
viewType = view - > type ( ) ;
2019-02-12 22:21:11 +03:00
}
2021-03-01 17:18:43 +03:00
data < < QString : : number ( ( int ) m_layoutsManager - > memoryUsage ( ) ) ; // Memory Usage
data < < m_layoutsManager - > centralLayoutsNames ( ) . join ( " ;; " ) ; // All Active layouts
data < < m_layoutsManager - > synchronizer ( ) - > currentLayoutsNames ( ) . join ( " ;; " ) ; // All Current layouts
2021-06-08 20:02:15 +03:00
data < < m_universalSettings - > contextMenuActionsAlwaysShown ( ) . join ( " ;; " ) ;
2021-03-01 17:18:43 +03:00
QStringList layoutsmenu ;
2018-02-07 00:39:45 +03:00
2020-08-29 20:42:15 +03:00
for ( const auto & layoutName : m_layoutsManager - > synchronizer ( ) - > menuLayouts ( ) ) {
2021-03-01 17:18:43 +03:00
if ( m_layoutsManager - > synchronizer ( ) - > centralLayout ( layoutName )
| | m_layoutsManager - > memoryUsage ( ) = = Latte : : MemoryUsage : : SingleLayout ) {
2021-05-15 13:31:56 +03:00
QStringList layoutdata ;
Data : : LayoutIcon layouticon = m_layoutsManager - > iconForLayout ( layoutName ) ;
layoutdata < < layoutName ;
layoutdata < < QString : : number ( layouticon . isBackgroundFile ) ;
layoutdata < < layouticon . name ;
layoutsmenu < < layoutdata . join ( " ** " ) ;
2018-02-07 00:39:45 +03:00
}
}
2021-03-01 17:18:43 +03:00
data < < layoutsmenu . join ( " ;; " ) ;
data < < ( view ? view - > layout ( ) - > name ( ) : QString ( ) ) ; //Selected View layout*/
2021-12-11 18:39:44 +03:00
QStringList viewtype ;
viewtype < < QString : : number ( ( int ) viewType ) ; //Selected View type
if ( view & & view - > isOriginal ( ) ) { /*View*/
auto originalview = qobject_cast < Latte : : OriginalView * > ( view ) ;
viewtype < < " 0 " ; //original view
viewtype < < QString : : number ( originalview - > clonesCount ( ) ) ;
} else if ( view & & view - > isCloned ( ) ) {
viewtype < < " 1 " ; //cloned view
viewtype < < " 0 " ; //has no clones
} else {
viewtype < < " 0 " ; //original view
viewtype < < " 0 " ; //has no clones
}
data < < viewtype . join ( " ;; " ) ;
2018-02-07 00:39:45 +03:00
return data ;
}
2021-03-01 20:04:21 +03:00
QStringList Corona : : viewTemplatesData ( )
{
QStringList data ;
Latte : : Data : : GenericTable < Data : : Generic > viewtemplates = m_templatesManager - > viewTemplates ( ) ;
for ( int i = 0 ; i < viewtemplates . rowCount ( ) ; + + i ) {
data < < viewtemplates [ i ] . name ;
data < < viewtemplates [ i ] . id ;
}
return data ;
}
void Corona : : addView ( const uint & containmentId , const QString & templateId )
{
2021-06-28 17:07:53 +03:00
if ( containmentId < = 0 ) {
auto currentlayouts = m_layoutsManager - > currentLayouts ( ) ;
if ( currentlayouts . count ( ) > 0 ) {
currentlayouts [ 0 ] - > newView ( templateId ) ;
}
} else {
auto view = m_layoutsManager - > synchronizer ( ) - > viewForContainment ( ( int ) containmentId ) ;
if ( view ) {
view - > newView ( templateId ) ;
}
2021-03-01 20:04:21 +03:00
}
}
2021-02-28 18:27:04 +03:00
void Corona : : duplicateView ( const uint & containmentId )
{
auto view = m_layoutsManager - > synchronizer ( ) - > viewForContainment ( ( int ) containmentId ) ;
if ( view ) {
view - > duplicateView ( ) ;
}
}
2021-02-28 18:35:59 +03:00
void Corona : : exportViewTemplate ( const uint & containmentId )
{
auto view = m_layoutsManager - > synchronizer ( ) - > viewForContainment ( ( int ) containmentId ) ;
if ( view ) {
view - > exportTemplate ( ) ;
}
}
2021-03-01 18:15:12 +03:00
void Corona : : moveViewToLayout ( const uint & containmentId , const QString & layoutName )
{
auto view = m_layoutsManager - > synchronizer ( ) - > viewForContainment ( ( int ) containmentId ) ;
if ( view & & ! layoutName . isEmpty ( ) & & view - > layout ( ) - > name ( ) ! = layoutName ) {
2021-12-11 18:39:44 +03:00
Latte : : Types : : ScreensGroup screensgroup { Latte : : Types : : SingleScreenGroup } ;
if ( view - > isOriginal ( ) ) {
auto originalview = qobject_cast < Latte : : OriginalView * > ( view ) ;
screensgroup = originalview - > screensGroup ( ) ;
}
view - > positioner ( ) - > setNextLocation ( layoutName , screensgroup , " " , Plasma : : Types : : Floating , Latte : : Types : : NoneAlignment ) ;
2021-03-01 18:15:12 +03:00
}
}
2021-02-28 12:56:09 +03:00
void Corona : : removeView ( const uint & containmentId )
{
auto view = m_layoutsManager - > synchronizer ( ) - > viewForContainment ( ( int ) containmentId ) ;
if ( view ) {
view - > removeView ( ) ;
}
}
2019-02-18 18:46:53 +03:00
void Corona : : setBackgroundFromBroadcast ( QString activity , QString screenName , QString filename )
{
if ( filename . startsWith ( " file:// " ) ) {
filename = filename . remove ( 0 , 7 ) ;
}
2020-04-24 17:30:30 +03:00
PlasmaExtended : : BackgroundCache : : self ( ) - > setBackgroundFromBroadcast ( activity , screenName , filename ) ;
2019-02-18 18:46:53 +03:00
}
void Corona : : setBroadcastedBackgroundsEnabled ( QString activity , QString screenName , bool enabled )
{
2020-04-24 17:30:30 +03:00
PlasmaExtended : : BackgroundCache : : self ( ) - > setBroadcastedBackgroundsEnabled ( activity , screenName , enabled ) ;
2019-02-18 18:46:53 +03:00
}
2021-05-03 23:49:39 +03:00
void Corona : : toggleHiddenState ( QString layoutName , QString viewName , QString screenName , int screenEdge )
2020-03-01 18:19:24 +03:00
{
2020-08-25 19:30:33 +03:00
if ( layoutName . isEmpty ( ) ) {
for ( auto layout : m_layoutsManager - > currentLayouts ( ) ) {
2021-05-03 23:49:39 +03:00
layout - > toggleHiddenState ( viewName , screenName , ( Plasma : : Types : : Location ) screenEdge ) ;
2020-08-25 19:30:33 +03:00
}
} else {
Layout : : GenericLayout * gLayout = layout ( layoutName ) ;
2020-03-01 18:19:24 +03:00
2020-08-25 19:30:33 +03:00
if ( gLayout ) {
2021-05-03 23:49:39 +03:00
gLayout - > toggleHiddenState ( viewName , screenName , ( Plasma : : Types : : Location ) screenEdge ) ;
2020-08-25 19:30:33 +03:00
}
2020-03-01 18:19:24 +03:00
}
}
2020-03-18 14:33:28 +03:00
void Corona : : importFullConfiguration ( const QString & file )
{
m_importFullConfigurationFile = file ;
quitApplication ( ) ;
}
2018-12-06 15:35:34 +03:00
inline void Corona : : qmlRegisterTypes ( ) const
2020-04-24 14:52:16 +03:00
{
2020-04-24 10:08:13 +03:00
qmlRegisterUncreatableMetaObject ( Latte : : Settings : : staticMetaObject ,
" org.kde.latte.private.app " , // import statement
2020-04-24 12:31:03 +03:00
0 , 1 , // major and minor version of the import
" Settings " , // name in QML
2020-04-24 10:08:13 +03:00
" Error: only enums of latte app settings " ) ;
2020-04-24 17:30:30 +03:00
qmlRegisterType < Latte : : BackgroundTracker > ( " org.kde.latte.private.app " , 0 , 1 , " BackgroundTracker " ) ;
2020-05-02 13:23:37 +03:00
qmlRegisterType < Latte : : Interfaces > ( " org.kde.latte.private.app " , 0 , 1 , " Interfaces " ) ;
2022-05-22 17:12:42 +03:00
qmlRegisterType < Latte : : ContextMenuLayerQuickItem > ( " org.kde.latte.private.app " , 0 , 1 , " ContextMenuLayer " ) ;
2019-12-05 00:01:44 +03:00
qmlRegisterAnonymousType < QScreen > ( " latte-dock " , 1 ) ;
qmlRegisterAnonymousType < Latte : : View > ( " latte-dock " , 1 ) ;
qmlRegisterAnonymousType < Latte : : ViewPart : : WindowsTracker > ( " latte-dock " , 1 ) ;
qmlRegisterAnonymousType < Latte : : ViewPart : : TrackerPart : : CurrentScreenTracker > ( " latte-dock " , 1 ) ;
qmlRegisterAnonymousType < Latte : : ViewPart : : TrackerPart : : AllScreensTracker > ( " latte-dock " , 1 ) ;
qmlRegisterAnonymousType < Latte : : WindowSystem : : SchemeColors > ( " latte-dock " , 1 ) ;
qmlRegisterAnonymousType < Latte : : WindowSystem : : Tracker : : LastActiveWindow > ( " latte-dock " , 1 ) ;
2020-04-24 14:52:16 +03:00
qmlRegisterAnonymousType < Latte : : Types > ( " latte-dock " , 1 ) ;
2022-03-01 07:47:12 +03:00
2016-12-25 10:25:27 +03:00
}
2016-12-30 10:20:06 +03:00
}