From 2287ab5e5edad3e843c4dac1c10ed6f43bc9f32d Mon Sep 17 00:00:00 2001 From: ZackaryWelch Date: Tue, 2 Jan 2018 15:09:49 -0500 Subject: Started a framework for desktop plugins and modified the screensaver plugins to inherit from a base plugin system --- .../core/lumina-desktop-unified/src-screensaver/SSBaseWidget.cpp | 7 +++++-- src-qt5/core/lumina-desktop-unified/src-screensaver/SSBaseWidget.h | 5 +++-- 2 files changed, 8 insertions(+), 4 deletions(-) (limited to 'src-qt5/core/lumina-desktop-unified') diff --git a/src-qt5/core/lumina-desktop-unified/src-screensaver/SSBaseWidget.cpp b/src-qt5/core/lumina-desktop-unified/src-screensaver/SSBaseWidget.cpp index 7c098887..aa3214a2 100644 --- a/src-qt5/core/lumina-desktop-unified/src-screensaver/SSBaseWidget.cpp +++ b/src-qt5/core/lumina-desktop-unified/src-screensaver/SSBaseWidget.cpp @@ -7,6 +7,9 @@ #include "SSBaseWidget.h" +//Relative directory to search along the XDG paths for screensavers +#define REL_DIR QString("/lumina-desktop/screensavers") + #define DEBUG 0 // ======== @@ -39,10 +42,10 @@ void SSBaseWidget::startPainting(){ stopPainting(); //If a random plugin - grab one of the known plugins if(plugType=="random"){ - QList valid = SSPluginSystem::findAllPlugins(); + QList valid = PluginSystem::findAllPlugins(REL_DIR); if(!valid.isEmpty()){ cplug = valid[ qrand()%valid.length() ]; } //grab a random plugin }else if(plugType!="none"){ - cplug = SSPluginSystem::findPlugin(plugType); + cplug = PluginSystem::findPlugin(plugType, REL_DIR); } if(DEBUG){ qDebug() << " - Screen Saver:" << plugType << cplug.scriptURL() << cplug.isValid(); } if(cplug.isValid()){ diff --git a/src-qt5/core/lumina-desktop-unified/src-screensaver/SSBaseWidget.h b/src-qt5/core/lumina-desktop-unified/src-screensaver/SSBaseWidget.h index 72e02702..e0a03d17 100644 --- a/src-qt5/core/lumina-desktop-unified/src-screensaver/SSBaseWidget.h +++ b/src-qt5/core/lumina-desktop-unified/src-screensaver/SSBaseWidget.h @@ -10,6 +10,7 @@ #define _LUMINA_DESKTOP_SCREEN_SAVER_BASE_WIDGET_H #include "global-includes.h" +#include #include class SSBaseWidget : public QQuickView{ @@ -25,8 +26,8 @@ public slots: void stopPainting(); private: - QString plugType; - SSPlugin cplug; + QString plugType; + SSPlugin cplug; QTimer *restartTimer; private slots: -- cgit From ba2374687bf3e1919d039ca38c52aac681a9d048 Mon Sep 17 00:00:00 2001 From: ZackaryWelch Date: Tue, 2 Jan 2018 15:12:20 -0500 Subject: Updated project files for plugin system --- src-qt5/core/lumina-desktop-unified/lumina-desktop.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src-qt5/core/lumina-desktop-unified') diff --git a/src-qt5/core/lumina-desktop-unified/lumina-desktop.pro b/src-qt5/core/lumina-desktop-unified/lumina-desktop.pro index ebc13b6f..bb987e25 100644 --- a/src-qt5/core/lumina-desktop-unified/lumina-desktop.pro +++ b/src-qt5/core/lumina-desktop-unified/lumina-desktop.pro @@ -24,7 +24,7 @@ include(../libLumina/ExternalProcess.pri) include(../../src-cpp/NativeWindow.pri) include(../libLumina/XDGMime.pri) -include(../../src-cpp/plugins-screensaver.pri) +include(../../src-cpp/plugins-base.pri) #include all the main individual source groups include(src-screensaver/screensaver.pri) -- cgit From 6cbd6541d5536f59973ba625b267eb8ad64d747b Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Tue, 2 Jan 2018 15:57:56 -0500 Subject: Add the new "DesktopManager" class into lumina2 sources. This is the class that watches for settings file changes and/or converts settings into interface object values. --- src-qt5/core/lumina-desktop-unified/LSession.cpp | 17 ++- .../core/lumina-desktop-unified/global-objects.h | 9 +- src-qt5/core/lumina-desktop-unified/main.cpp | 6 +- .../src-desktop/DesktopManager.cpp | 139 +++++++++++++++++++++ .../src-desktop/DesktopManager.h | 44 +++++++ .../lumina-desktop-unified/src-desktop/desktop.pri | 6 +- .../src-desktop/src-cpp/RootDesktopObject.cpp | 8 ++ .../src-desktop/src-cpp/RootDesktopObject.h | 1 + 8 files changed, 215 insertions(+), 15 deletions(-) create mode 100644 src-qt5/core/lumina-desktop-unified/src-desktop/DesktopManager.cpp create mode 100644 src-qt5/core/lumina-desktop-unified/src-desktop/DesktopManager.h (limited to 'src-qt5/core/lumina-desktop-unified') diff --git a/src-qt5/core/lumina-desktop-unified/LSession.cpp b/src-qt5/core/lumina-desktop-unified/LSession.cpp index e1251c01..ed4d644b 100644 --- a/src-qt5/core/lumina-desktop-unified/LSession.cpp +++ b/src-qt5/core/lumina-desktop-unified/LSession.cpp @@ -22,6 +22,7 @@ QThread* Lumina::EVThread = 0; RootWindow* Lumina::ROOTWIN = 0; XDGDesktopList* Lumina::APPLIST = 0; LShortcutEvents* Lumina::SHORTCUTS = 0; +DesktopManager* Lumina::DESKMAN = 0; LSession::LSession(int &argc, char ** argv) : LSingleApplication(argc, argv, "lumina-desktop-unified"){ //Initialize the global objects to null pointers @@ -49,10 +50,11 @@ LSession::LSession(int &argc, char ** argv) : LSingleApplication(argc, argv, "lu Lumina::NEF = new NativeEventFilter(); Lumina::NWS = new NativeWindowSystem(); Lumina::SS = new LScreenSaver(); + Lumina::DESKMAN = new DesktopManager(); //Now put the Native Window System into it's own thread to keep things snappy Lumina::EVThread = new QThread(); - //Lumina::NWS->moveToThread(Lumina::EVThread); - //Lumina::EVThread->start(); + Lumina::DESKMAN->moveToThread(Lumina::EVThread); + Lumina::EVThread->start(); Lumina::APPLIST = XDGDesktopList::instance(); Lumina::ROOTWIN = new RootWindow(); Lumina::SHORTCUTS = new LShortcutEvents(); //this can be moved to it's own thread eventually as well @@ -73,6 +75,7 @@ LSession::~LSession(){ if(DesktopSettings::instance()!=0){ DesktopSettings::instance()->deleteLater(); } if(Lumina::ROOTWIN!=0){ Lumina::ROOTWIN->deleteLater(); } if(Lumina::APPLIST!=0){ Lumina::APPLIST->deleteLater(); } + if(Lumina::DESKMAN!=0){ Lumina::DESKMAN->deleteLater(); } } void LSession::setupSession(){ @@ -104,6 +107,10 @@ void LSession::setupSession(){ splash.showScreen("user"); if(DEBUG){ qDebug() << " - Init User Files:" << timer->elapsed();} //checkUserFiles(); //adds these files to the watcher as well + Lumina::NWS->setRoot_numberOfWorkspaces(QStringList() << "one" << "two"); + Lumina::NWS->setRoot_currentWorkspace(0); + + Lumina::DESKMAN->start(); Lumina::ROOTWIN->start(); //Initialize the internal variables //DESKTOPS.clear(); @@ -124,14 +131,12 @@ void LSession::setupSession(){ //Initialize the desktops splash.showScreen("desktop"); - if(DEBUG){ qDebug() << " - Init Desktops:" << timer->elapsed(); } + /*if(DEBUG){ qDebug() << " - Init Desktops:" << timer->elapsed(); } QList scrns= QApplication::screens(); for(int i=0; iname(); RootDesktopObject::instance()->ChangeWallpaper(scrns[i]->name(),QUrl::fromLocalFile(LOS::LuminaShare()+"desktop-background.jpg").toString() ); - } - Lumina::NWS->setRoot_numberOfWorkspaces(QStringList() << "one" << "two"); - Lumina::NWS->setRoot_currentWorkspace(0); + }*/ if(DEBUG){ qDebug() << " - Create Desktop Context Menu"; } diff --git a/src-qt5/core/lumina-desktop-unified/global-objects.h b/src-qt5/core/lumina-desktop-unified/global-objects.h index c204587f..4cea60c2 100644 --- a/src-qt5/core/lumina-desktop-unified/global-objects.h +++ b/src-qt5/core/lumina-desktop-unified/global-objects.h @@ -22,9 +22,10 @@ //#include "src-events/LXcbEventFilter.h" //#endif #include "src-events/LShortcutEvents.h" - +#include "src-desktop/DesktopManager.h" #include "src-screensaver/LScreenSaver.h" //#include "src-WM/LWindowManager.h" + #include #include "LSession.h" @@ -43,13 +44,13 @@ namespace Lumina{ //extern EventFilter *EFILTER; //Native Event Watcher extern LShortcutEvents *SHORTCUTS; //Keyboard/mouse shortcut events - //extern DesktopSettings *SETTINGS; //All Settings files + //ScreenSaver extern LScreenSaver *SS; //Root Window extern RootWindow *ROOTWIN; - //Window Manager - //LWindowManager *WM; + //Desktop Manager + extern DesktopManager *DESKMAN; //Application List extern XDGDesktopList *APPLIST; diff --git a/src-qt5/core/lumina-desktop-unified/main.cpp b/src-qt5/core/lumina-desktop-unified/main.cpp index ed2b9b4c..3cf35e50 100644 --- a/src-qt5/core/lumina-desktop-unified/main.cpp +++ b/src-qt5/core/lumina-desktop-unified/main.cpp @@ -39,11 +39,11 @@ int main(int argc, char ** argv) QTime *timer=0; if(DEBUG){ timer = new QTime(); timer->start(); } if(DEBUG){ qDebug() << "Theme Init:" << timer->elapsed(); } - LuminaThemeEngine theme(&a); - QObject::connect(&theme, SIGNAL(updateIcons()), &a, SLOT(reloadIconTheme()) ); + /*LuminaThemeEngine theme(&a); + QObject::connect(&theme, SIGNAL(updateIcons()), &a, SLOT(reloadIconTheme()) );*/ if(DEBUG){ qDebug() << "Session Setup:" << timer->elapsed(); } QTimer::singleShot(0, &a, SLOT(setupSession()) ); - theme.refresh(); + //theme.refresh(); if(DEBUG){ qDebug() << "Exec Time:" << timer->elapsed(); delete timer;} int retCode = a.exec(); qDebug() << "Finished Closing Down Unified Lumina"; diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/DesktopManager.cpp b/src-qt5/core/lumina-desktop-unified/src-desktop/DesktopManager.cpp new file mode 100644 index 00000000..d6d06be9 --- /dev/null +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/DesktopManager.cpp @@ -0,0 +1,139 @@ +//=========================================== +// Lumina-desktop source code +// Copyright (c) 2017-2018, Ken Moore +// Available under the 3-clause BSD license +// See the LICENSE file for full details +//=========================================== +#include "DesktopManager.h" + +#include "global-objects.h" + +// === PUBLIC === +DesktopManager::DesktopManager(){ + +} + +DesktopManager::~DesktopManager(){ + +} + +void DesktopManager::start(){ + connect(DesktopSettings::instance(), SIGNAL(FileModified(DesktopSettings::File)), this, SLOT(settingsChanged(DesktopSettings::File)) ); + //Perform the initial load of the settings files + QTimer::singleShot(0, this, SLOT(updateDesktopSettings()) ); + QTimer::singleShot(0, this, SLOT(updatePanelSettings()) ); + QTimer::singleShot(0, this, SLOT(updatePluginSettings()) ); + QTimer::singleShot(0, this, SLOT(updateMenuSettings()) ); + QTimer::singleShot(0, this, SLOT(updateAnimationSettings()) ); +} + +void DesktopManager::stop(){ + disconnect(DesktopSettings::instance(), SIGNAL(FileModified(DesktopSettings::File)), this, SLOT(settingsChanged(DesktopSettings::File)) ); +} + +// === PRIVATE === +void DesktopManager::updateWallpaper(QString screen_id, int wkspace){ + QString current = RootDesktopObject::instance()->CurrentWallpaper(screen_id); + if(!current.isEmpty()){ current = QUrl(current).toLocalFile(); } //convert it back to the normal file syntax + //First find the list of options from the settings + //First look for a list that matches this exact screen/workspace combo + QStringList wpaperList = DesktopSettings::instance()->value(DesktopSettings::Desktop, "wallpapers/"+screen_id+"_wk_"+QString::number(wkspace), QStringList()).toStringList(); + //Next look for a list that matches this exact workspace + if(wpaperList.isEmpty()){ wpaperList= DesktopSettings::instance()->value(DesktopSettings::Desktop, "wallpapers/default_wk_"+QString::number(wkspace), QStringList()).toStringList(); } + //Next look for a list that matches this exact screen + if(wpaperList.isEmpty()){ wpaperList= DesktopSettings::instance()->value(DesktopSettings::Desktop, "wallpapers/"+screen_id, QStringList()).toStringList(); } + //Now look for a list that matches any screen/workspace + if(wpaperList.isEmpty()){ wpaperList= DesktopSettings::instance()->value(DesktopSettings::Desktop, "wallpapers/default", QStringList()).toStringList(); } + //Now use the failover wallpaper directory + if(wpaperList.isEmpty()){ wpaperList << LOS::LuminaShare()+"../wallpapers/lumina-nature"; } + //Wallpaper selection/randomization + if(wpaperList.count()==1 && wpaperList.first()==current){ return; } //nothing to do - just the same image + QString wpaper; + QStringList bgL = wpaperList; //need a copy at the moment - could change the entire list in a second (opening a dir for instance) + while(wpaper.isEmpty() || QFileInfo(wpaper).isDir()){ + QString prefix; + if(!wpaper.isEmpty()){ + //Got a directory - update the list of files and re-randomize the selection + QStringList imgs = LUtils::imageExtensions(true); + QDir tdir(wpaper); + prefix=wpaper+"/"; + bgL = tdir.entryList(imgs, QDir::Files | QDir::NoDotAndDotDot, QDir::Name); + //If directory no longer has any valid images - remove it from list and try again + if(bgL.isEmpty()){ + wpaperList.removeAll(wpaper); //invalid directory - remove it from the list for the moment + bgL = wpaperList; //reset the list back to the original list (not within a directory) + } + } + //Verify that there are files in the list - otherwise use the default + if(bgL.isEmpty()){ wpaper="default"; break; } + int index = ( qrand() % bgL.length() ); + if(index== bgL.indexOf(current)){ //if the current wallpaper was selected by the randomization again + //Go to the next in the list + if(index < 0 || index >= bgL.length()-1){ index = 0; } //if invalid or last item in the list - go to first + else{ index++; } //go to next + } + wpaper = prefix+bgL[index]; + } + //Now go ahead and set the wallpaper in the screen object + if(wpaper.isEmpty() || wpaper=="default"){ wpaper = LOS::LuminaShare()+"desktop-background.jpg"; } //failover image + qDebug() << "Updating Wallpaper:" << screen_id << wpaper; + RootDesktopObject::instance()->ChangeWallpaper(screen_id,QUrl::fromLocalFile(wpaper).toString() ); +} + +void DesktopManager::updatePanels(QString panel_id){ + +} + +void DesktopManager::updatePlugins(QString plugin_id){ + +} + +// === PUBLIC SLOTS === +void DesktopManager::workspaceChanged(int wknum){ + qDebug() << "Got Workspace Changed:" << wknum; + +} + +void DesktopManager::settingsChanged(DesktopSettings::File type){ + switch(type){ + case DesktopSettings::Desktop: + QTimer::singleShot(0, this, SLOT(updateDesktopSettings()) ); + case DesktopSettings::Panels: + QTimer::singleShot(0, this, SLOT(updatePanelSettings()) ); + case DesktopSettings::Plugins: + QTimer::singleShot(0, this, SLOT(updatePluginSettings()) ); + case DesktopSettings::ContextMenu: + QTimer::singleShot(0, this, SLOT(updateMenuSettings()) ); + case DesktopSettings::Animation: + QTimer::singleShot(0, this, SLOT(updateAnimationSettings()) ); + default: + break; + //Do nothing - not a settings change we care about here + } +} + +// === PRIVATE SLOTS === +void DesktopManager::updateDesktopSettings(){ + qDebug() << "Update Desktop Settings..."; + QList scrns= QApplication::screens(); + int wkspace = Lumina::NWS->currentWorkspace(); + for(int i=0; iname(), wkspace); } + +} + +void DesktopManager::updatePanelSettings(){ + +} + +void DesktopManager::updatePluginSettings(){ + +} + +void DesktopManager::updateMenuSettings(){ + +} + +void DesktopManager::updateAnimationSettings(){ + +} + diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/DesktopManager.h b/src-qt5/core/lumina-desktop-unified/src-desktop/DesktopManager.h new file mode 100644 index 00000000..df681afa --- /dev/null +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/DesktopManager.h @@ -0,0 +1,44 @@ +//=========================================== +// Lumina-desktop source code +// Copyright (c) 2017-2018, Ken Moore +// Available under the 3-clause BSD license +// See the LICENSE file for full details +//=========================================== +// This is the main class that updates the interface objects +// on-demand as settings files and other stuff changes +//=========================================== +#ifndef _LUMINA_DESKTOP_OBJECT_MANAGER_H +#define _LUMINA_DESKTOP_OBJECT_MANAGER_H + +#include + +class DesktopManager : public QObject { + Q_OBJECT +public: + DesktopManager(); + ~DesktopManager(); + + void start(); + void stop(); + +private: + void updateWallpaper(QString screen_id, int wkspace); + void updatePanels(QString panel_id); + void updatePlugins(QString plugin_id); + +public slots: + void workspaceChanged(int); + void settingsChanged(DesktopSettings::File); + +private slots: + void updateDesktopSettings(); + void updatePanelSettings(); + void updatePluginSettings(); + void updateMenuSettings(); + void updateAnimationSettings(); + +signals: + void PanelLocationsChanged(); //reserved screen space changed +}; + +#endif diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/desktop.pri b/src-qt5/core/lumina-desktop-unified/src-desktop/desktop.pri index e4c4faeb..f4a6882d 100644 --- a/src-qt5/core/lumina-desktop-unified/src-desktop/desktop.pri +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/desktop.pri @@ -1,8 +1,10 @@ QT *= gui widgets qml quick -SOURCES *= $${PWD}/RootWindow.cpp +SOURCES *= $${PWD}/RootWindow.cpp \ + $${PWD}/Desktopmanager.cpp -HEADERS *= $${PWD}/RootWindow.h +HEADERS *= $${PWD}/RootWindow.h \ + $${PWD}/DesktopManager.h #update the includepath so we can just #include as needed without paths INCLUDEPATH *= $${PWD} diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/RootDesktopObject.cpp b/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/RootDesktopObject.cpp index 5750ac2d..4b01fa0d 100644 --- a/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/RootDesktopObject.cpp +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/RootDesktopObject.cpp @@ -129,5 +129,13 @@ void RootDesktopObject::ChangeWallpaper(QString screen, QString value){ } } +QString RootDesktopObject::CurrentWallpaper(QString screen){ + for(int i=0; iname()==screen){ return s_objects[i]->background();} + } + return ""; //unknown +} + + // === PRIVATE === diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/RootDesktopObject.h b/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/RootDesktopObject.h index 838b5f7d..7d5182c4 100644 --- a/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/RootDesktopObject.h +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/RootDesktopObject.h @@ -55,6 +55,7 @@ private: public slots: void updateScreens(); //rescan/update screen objects void ChangeWallpaper(QString screen, QString); + QString CurrentWallpaper(QString screen); private slots: -- cgit