diff options
author | Ken Moore <ken@ixsystems.com> | 2018-01-30 05:49:30 -0500 |
---|---|---|
committer | Ken Moore <ken@ixsystems.com> | 2018-01-30 05:49:30 -0500 |
commit | fc138f1492c0275215327cfe698587916107b69f (patch) | |
tree | f1db15573ee9e8ecf7618214cf28f381ba6c0632 /src-qt5 | |
parent | Merge branch 'master' of github.com:trueos/lumina (diff) | |
download | lumina-fc138f1492c0275215327cfe698587916107b69f.tar.gz lumina-fc138f1492c0275215327cfe698587916107b69f.tar.bz2 lumina-fc138f1492c0275215327cfe698587916107b69f.zip |
A few couple other attempts at the layering issue.
Tie-in the new OSInterface class to the QML data store (RootObject).
This will allow the new system status functions to be accessible to the QML interface.
Diffstat (limited to 'src-qt5')
10 files changed, 41 insertions, 8 deletions
diff --git a/src-qt5/core/lumina-desktop-unified/LSession.cpp b/src-qt5/core/lumina-desktop-unified/LSession.cpp index 69c42c73..dcd1688f 100644 --- a/src-qt5/core/lumina-desktop-unified/LSession.cpp +++ b/src-qt5/core/lumina-desktop-unified/LSession.cpp @@ -31,6 +31,7 @@ LSession::LSession(int &argc, char ** argv) : LSingleApplication(argc, argv, "lu qRegisterMetaType< NativeWindowSystem::MouseButton >("NativeWindowSystem::MouseButton"); mediaObj = 0; //private object used for playing login/logout chimes + OSThread = 0; if(this->isPrimaryProcess()){ //Setup the global registrations qsrand(QDateTime::currentMSecsSinceEpoch()); @@ -57,7 +58,9 @@ LSession::LSession(int &argc, char ** argv) : LSingleApplication(argc, argv, "lu Lumina::APPLIST = XDGDesktopList::instance(); Lumina::ROOTWIN = new RootWindow(); Lumina::SHORTCUTS = new LShortcutEvents(); //this can be moved to it's own thread eventually as well - + OSThread = new QThread(); + OSInterface::instance()->moveToThread(OSThread); + OSThread->start(); setupGlobalConnections(); } //end check for primary process } @@ -75,6 +78,12 @@ LSession::~LSession(){ if(Lumina::ROOTWIN!=0){ Lumina::ROOTWIN->deleteLater(); } if(Lumina::APPLIST!=0){ Lumina::APPLIST->deleteLater(); } if(Lumina::DESKMAN!=0){ Lumina::DESKMAN->deleteLater(); } + if(OSInterface::instance()->isRunning()){ OSInterface::instance()->stop(); } + OSInterface::instance()->deleteLater(); + if(OSThread!=0){ + if(OSThread->isRunning()){ OSThread->quit(); } + OSThread->deleteLater(); + } } void LSession::setupSession(){ @@ -108,6 +117,7 @@ void LSession::setupSession(){ //checkUserFiles(); //adds these files to the watcher as well Lumina::NWS->setRoot_numberOfWorkspaces(QStringList() << "one" << "two"); Lumina::NWS->setRoot_currentWorkspace(0); + if(!OSInterface::instance()->isRunning()){ OSInterface::instance()->start(); } Lumina::DESKMAN->start(); Lumina::ROOTWIN->start(); diff --git a/src-qt5/core/lumina-desktop-unified/LSession.h b/src-qt5/core/lumina-desktop-unified/LSession.h index 61da559b..2735502d 100644 --- a/src-qt5/core/lumina-desktop-unified/LSession.h +++ b/src-qt5/core/lumina-desktop-unified/LSession.h @@ -28,6 +28,9 @@ private: QTranslator *currTranslator; + //Extra background threads for individual objects + QThread *OSThread; //OSInterface thread + public slots: void setupSession(); //called during startup only diff --git a/src-qt5/core/lumina-desktop-unified/global-includes.h b/src-qt5/core/lumina-desktop-unified/global-includes.h index 2ca8af15..6a82775b 100644 --- a/src-qt5/core/lumina-desktop-unified/global-includes.h +++ b/src-qt5/core/lumina-desktop-unified/global-includes.h @@ -72,6 +72,7 @@ #include <XDGMime.h> #include <LIconCache.h> #include <LFileInfo.h> +#include <framework-OSInterface.h> // C++ Backend classes for QML interface #include <NativeWindowObject.h> diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/RootWindow.cpp b/src-qt5/core/lumina-desktop-unified/src-desktop/RootWindow.cpp index 2ceff4a0..83c15601 100644 --- a/src-qt5/core/lumina-desktop-unified/src-desktop/RootWindow.cpp +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/RootWindow.cpp @@ -9,8 +9,8 @@ #include <QQmlImageProviderBase> RootWindow::RootWindow() : QObject(){ - root_win = QWindow::fromWinId( QX11Info::appRootWindow() ); // - root_view = new QQuickView(root_win); //make it a child of the root window + root_win = QWindow::fromWinId( QX11Info::appRootWindow() ); + root_view = new QQuickView(new QWindow()); //make it a child of the root window root_obj = RootDesktopObject::instance(); syncRootSize(); connect(root_win, SIGNAL(widthChanged(int)), this, SLOT(syncRootSize()) ); @@ -31,6 +31,7 @@ RootWindow::~RootWindow(){ void RootWindow::start(){ root_view->setSource(QUrl("qrc:///qml/RootDesktop.qml")); root_win->show(); + root_view->parent()->show(); root_view->show(); } @@ -40,6 +41,7 @@ void RootWindow::syncRootSize(){ QRect unif; for(int i=0; i<screens.length(); i++){ unif = unif.united(screens[i]->geometry()); } if(unif.width() != root_view->width() || unif.height() != root_view->height()){ + root_view->parent()->setGeometry(0,0,unif.width(), unif.height()); root_view->setGeometry(0, 0, unif.width(), unif.height() ); emit RootResized(root_view->geometry()); } diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/RootWindow.h b/src-qt5/core/lumina-desktop-unified/src-desktop/RootWindow.h index 97b57a65..0e48c000 100644 --- a/src-qt5/core/lumina-desktop-unified/src-desktop/RootWindow.h +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/RootWindow.h @@ -22,7 +22,7 @@ public: void start(); - WId viewID(){ return root_view->winId(); } + WId viewID(){ return root_view->parent()->winId(); } public slots: void syncRootSize(); 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 523fa09f..e1960ba0 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 @@ -30,6 +30,7 @@ void RootDesktopObject::RegisterType(){ //Also register any types that are needed by this class ScreenObject::RegisterType(); NativeWindowObject::RegisterType(); + OSInterface::RegisterType(); } RootDesktopObject* RootDesktopObject::instance(){ @@ -84,6 +85,10 @@ NativeWindowObject* RootDesktopObject::window(QString id){ return 0; } +OSInterface* RootDesktopObject::os_interface(){ + return OSInterface::instance(); +} + void RootDesktopObject::setPanels(QList<PanelObject*> list){ panel_objects = list; emit panelsChanged(); 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 cc70f813..f9852e11 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 @@ -37,6 +37,9 @@ public: Q_INVOKABLE QStringList windows(); Q_INVOKABLE NativeWindowObject* window(QString id); + //QML Globals Access + Q_INVOKABLE OSInterface* os_interface(); + //QML Access Functions Q_INVOKABLE void logout(); Q_INVOKABLE void lockscreen(); diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/RootDesktop.qml b/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/RootDesktop.qml index f48f7751..ddb2a490 100644 --- a/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/RootDesktop.qml +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-qml/RootDesktop.qml @@ -34,9 +34,9 @@ Rectangle { anchors.fill: rootCanvas acceptedButtons: Qt.RightButton onClicked: { - /*contextMenu.x = mouseX - contextMenu.y = mouseY - contextMenu.open() */ + //contextMenu.x = mouseX + //contextMenu.y = mouseY + //contextMenu.open() contextMenu.popup() } onPositionChanged: { diff --git a/src-qt5/src-cpp/framework-OSInterface.h b/src-qt5/src-cpp/framework-OSInterface.h index f8345bac..88f4d10a 100644 --- a/src-qt5/src-cpp/framework-OSInterface.h +++ b/src-qt5/src-cpp/framework-OSInterface.h @@ -243,6 +243,6 @@ public: ~OSInterface(); static OSInterface* instance(); //Get the currently-active instance of this class (or make a new one) - + static void RegisterType(); //Register this object for QML access }; #endif diff --git a/src-qt5/src-cpp/framework-OSInterface_private.cpp b/src-qt5/src-cpp/framework-OSInterface_private.cpp index d633fe9a..66ac7d8e 100644 --- a/src-qt5/src-cpp/framework-OSInterface_private.cpp +++ b/src-qt5/src-cpp/framework-OSInterface_private.cpp @@ -9,6 +9,8 @@ #include <framework-OSInterface.h> #include <QtConcurrent> +#include <QQmlEngine> + OSInterface::OSInterface(QObject *parent) : QObject(parent){ watcher = 0; iodevice = 0; @@ -38,6 +40,13 @@ OSInterface* OSInterface::instance(){ return m_os_object; } +void OSInterface::RegisterType(){ + static bool done = false; + if(done){ return; } + done=true; + qmlRegisterType<OSInterface>("Lumina.Backend.OSInterface", 2, 0, "OSInterface"); +} + //Start/stop interface systems void OSInterface::start(){ if(!mediaDirectories().isEmpty()){ setupMediaWatcher(); }//will create/connect the filesystem watcher automatically |