From 71737f70949bd25f9aa8bc4e7d03039ba83c6cb1 Mon Sep 17 00:00:00 2001 From: Kris Moore Date: Thu, 4 Sep 2014 11:42:13 -0400 Subject: Initial import of the lumina code from pcbsd git repo --- .../taskmanager/LTaskManagerPlugin.cpp | 101 +++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 lumina-desktop/panel-plugins/taskmanager/LTaskManagerPlugin.cpp (limited to 'lumina-desktop/panel-plugins/taskmanager/LTaskManagerPlugin.cpp') diff --git a/lumina-desktop/panel-plugins/taskmanager/LTaskManagerPlugin.cpp b/lumina-desktop/panel-plugins/taskmanager/LTaskManagerPlugin.cpp new file mode 100644 index 00000000..674c9088 --- /dev/null +++ b/lumina-desktop/panel-plugins/taskmanager/LTaskManagerPlugin.cpp @@ -0,0 +1,101 @@ +//=========================================== +// Lumina-DE source code +// Copyright (c) 2014, Ken Moore +// Available under the 3-clause BSD license +// See the LICENSE file for full details +//=========================================== +#include "LTaskManagerPlugin.h" +#include "../../LSession.h" + +LTaskManagerPlugin::LTaskManagerPlugin(QWidget *parent, QString id, bool horizontal) : LPPlugin(parent, id, horizontal){ + updating=false; + timer = new QTimer(this); + timer->setSingleShot(true); + timer->setInterval(10); // 1/100 second + connect(timer, SIGNAL(timeout()), this, SLOT(UpdateButtons()) ); + connect(LSession::instance(), SIGNAL(WindowListEvent()), this, SLOT(checkWindows()) ); + this->layout()->setContentsMargins(0,0,0,0); + QTimer::singleShot(0,this, SLOT(UpdateButtons()) ); //perform an initial sync + //QTimer::singleShot(100,this, SLOT(OrientationChange()) ); //perform an initial sync +} + +LTaskManagerPlugin::~LTaskManagerPlugin(){ + +} + +//============== +// PRIVATE SLOTS +//============== +void LTaskManagerPlugin::UpdateButtons(){ + if(updating){ timer->start(); return; } //check again in a moment + //Make sure this only runs one at a time + updating=true; + //Get the current window list + QList winlist = LX11::WindowList(); + //qDebug() << "Update Buttons:" << winlist; + //Now go through all the current buttons first + for(int i=0; i WI = BUTTONS[i]->windows(); + bool updated=false; + for(int w=0; wlayout()->takeAt(i); //remove from the layout + delete BUTTONS.takeAt(i); + i--; + updated = true; //prevent updating a removed button + break; //break out of the button->window loop + }else{ + //qDebug() << "Remove Window:" << WI[w].windowID() << "Button:" << w; + BUTTONS[i]->rmWindow(WI[w]); // one of the multiple windows for the button + WI.removeAt(w); //remove this window from the list + w--; + } + updated=true; //button already changed + } + } + if(!updated){ + //qDebug() << "Update Button:" << i; + QTimer::singleShot(1,BUTTONS[i], SLOT(UpdateButton()) ); //keep moving on + } + } + //Now go through the remaining windows + for(int i=0; iclassname()== ctxt){ + found = true; + //qDebug() << "Add Window to Button:" << b; + BUTTONS[b]->addWindow(winlist[i]); + break; + } + } + if(!found){ + //No group, create a new button + //qDebug() << "New Button"; + LTaskButton *but = new LTaskButton(this); + but->addWindow( LWinInfo(winlist[i]) ); + if(this->layout()->direction()==QBoxLayout::LeftToRight){ + but->setIconSize(QSize(this->height(), this->height())); + }else{ + but->setIconSize(QSize(this->width(), this->width())); + } + this->layout()->addWidget(but); + BUTTONS << but; + } + } + updating=false; //flag that we are done updating the buttons +} + +void LTaskManagerPlugin::checkWindows(){ + timer->start(); +} \ No newline at end of file -- cgit