Changeset 130bc0e


Ignore:
Timestamp:
07/08/14 13:54:56 (14 months ago)
Author:
Ken Moore <ken@…>
Branches:
master, enter/10, releng/10.0.3, releng/10.1, releng/10.1.1, releng/10.1.2, releng/10.2, stable/10
Children:
59fa950
Parents:
ac10f15
Message:

Get the Lumina Desktop Plugin system working completely. It is still a bit ugly and needs a visual update to the "unlocked" plugin container, but at least it works fine right now.

Location:
lumina/lumina-desktop
Files:
1 added
7 edited

Legend:

Unmodified
Added
Removed
  • lumina/lumina-desktop/LDesktop.cpp

    r64bfe71 r130bc0e  
    1313  desktop = new QDesktopWidget(); 
    1414  defaultdesktop = (deskNum== desktop->primaryScreen()); 
     15  desktoplocked = true; 
    1516  xoffset = 0; 
    1617  for(int i=0; i<desktopnumber; i++){ 
     
    4142        bgWindow->setGeometry(xoffset,0,desktop->screenGeometry().width(), desktop->screenGeometry().height()); 
    4243        connect(bgWindow, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(ShowMenu()) ); 
     44  bgDesktop = new QMdiArea(bgWindow); 
     45        //Make sure the desktop area is transparent to show the background 
     46        bgDesktop->setBackground( QBrush(Qt::NoBrush) ); 
     47        //bgDesktop->setVisible(false); 
    4348   
    4449  //Start the update processes 
     
    7176    QProcess::startDetached("lumina-open \""+act->whatsThis()+"\""); 
    7277  } 
     78} 
     79 
     80void LDesktop::CreateDesktopPluginContainer(LDPlugin *plug){ 
     81  LDPluginContainer *win = new LDPluginContainer(plug, desktoplocked); 
     82  if(desktoplocked){ bgDesktop->addSubWindow(win, Qt::FramelessWindowHint); } 
     83  else{ bgDesktop->addSubWindow(win, Qt::WindowTitleHint); } 
     84  win->loadInitialPosition(); 
     85  win->show(); 
    7386} 
    7487 
     
    117130  //Now add the system quit options 
    118131  deskMenu->addSeparator(); 
     132  if(!desktoplocked){ deskMenu->addAction(LXDG::findIcon("document-encrypt",""),tr("Lock Desktop"), this, SLOT(ToggleDesktopLock()) ); } 
     133  else{ deskMenu->addAction(LXDG::findIcon("document-decrypt",""),tr("Unlock Desktop"), this, SLOT(ToggleDesktopLock()) ); } 
    119134  deskMenu->addAction(LXDG::findIcon("system-log-out",""), tr("Log Out"), this, SLOT(SystemLogout()) ); 
    120135} 
     
    124139  QStringList plugins = settings->value(DPREFIX+"pluginlist", QStringList()).toStringList(); 
    125140  if(defaultdesktop && plugins.isEmpty()){ 
    126     //plugins << "sample"; 
     141    plugins << "sample"; 
    127142  } 
    128143  for(int i=0; i<plugins.length(); i++){ 
     
    141156      if(plug != 0){  
    142157        qDebug() << " -- Show Plugin"; 
    143         PLUGINS << plug; 
    144         plug->showPlugin(); 
     158        PLUGINS << plug; 
     159        CreateDesktopPluginContainer(plug); 
    145160      } 
    146161    } 
    147     //Update the plugin geometry 
    148     /*if(plug!=0){ 
    149       QString geom = settings->value(DPREFIX+plugins[i]+"/geometry", "").toString(); 
    150       if(geom.isEmpty()){ 
    151         if(plugins.length()==1 && plugins[i]=="desktopview"){  
    152           geom = "0,0,"+QString::number(desktop->availableGeometry().width())+","+QString::number(desktop->availableGeometry().height()); 
    153         }else{ 
    154           geom = QString::number(i*200)+",0,200,"+QString::number(desktop->availableGeometry().height()); 
    155         } 
    156       } 
    157       plug->setGeometry(geom.section(",",0,0).toInt(),geom.section(",",1,1).toInt(), geom.section(",",2,2).toInt(), geom.section(",",3,3).toInt() ); 
    158       plug->show(); //make sure it is visible 
    159     }*/ 
    160   } 
    161    
     162  
     163  } 
     164} 
     165 
     166void LDesktop::ToggleDesktopLock(){ 
     167  desktoplocked = !desktoplocked; //flip to other value 
     168  //Remove all the current containers 
     169  QList<QMdiSubWindow*> wins = bgDesktop->subWindowList(); 
     170  for(int i=0; i<wins.length(); i++){ 
     171    bgDesktop->removeSubWindow(wins[i]->widget()); //unhook plugin from container 
     172    bgDesktop->removeSubWindow(wins[i]); //remove container from screen 
     173    delete wins[i]; //delete old container 
     174  } 
     175  //Now recreate all the containers on the screen 
     176  for(int i=0; i<PLUGINS.length(); i++){ 
     177    CreateDesktopPluginContainer(PLUGINS[i]); 
     178  } 
     179  UpdateMenu(false);  
    162180} 
    163181 
     
    181199        qDebug() << " -- Update panel "<< i; 
    182200        //panel already exists - just update it 
    183         QTimer::singleShot(1, PANELS[i], SLOT(UpdatePanel()) );       
     201        QTimer::singleShot(0, PANELS[i], SLOT(UpdatePanel()) ); 
    184202      } 
    185203    } 
     
    190208    } 
    191209  } 
    192    
    193    
    194 } 
    195  
     210  //Give it a 1/2 second before ensuring that the visible desktop area is correct 
     211  QTimer::singleShot(500, this, SLOT(UpdateDesktopPluginArea()) ); 
     212} 
     213 
     214void LDesktop::UpdateDesktopPluginArea(){ 
     215  QRegion visReg( bgWindow->geometry() ); //visible region (not hidden behind a panel) 
     216  for(int i=0; i<PANELS.length(); i++){ 
     217    visReg = visReg.subtracted( QRegion(PANELS[i]->geometry()) ); 
     218  } 
     219  //Now make sure the desktop plugin area is only the visible area 
     220  bgDesktop->setGeometry( visReg.boundingRect() ); 
     221  bgDesktop->setBackground( QBrush(Qt::NoBrush) ); 
     222  bgDesktop->update(); 
     223} 
     224  
    196225void LDesktop::UpdateBackground(){ 
    197226  //Get the current Background 
     
    215244  //Save this file as the current background 
    216245  CBG = bgFile; 
    217   qDebug() << " - Set Background to:" << CBG << index << bgL; 
     246  //qDebug() << " - Set Background to:" << CBG << index << bgL; 
    218247  if( (bgFile.toLower()=="default")){ bgFile = "/usr/local/share/Lumina-DE/desktop-background.jpg"; } 
    219248  //Now set this file as the current background 
  • lumina/lumina-desktop/LDesktop.h

    r164b720 r130bc0e  
    1919#include <QLabel> 
    2020#include <QWidgetAction> 
     21#include <QMdiArea> 
     22#include <QMdiSubWindow> 
    2123 
    2224 
     
    2729#include "LSession.h" 
    2830#include "desktop-plugins/LDPlugin.h" 
     31#include "desktop-plugins/LDPluginContainer.h" 
    2932#include "desktop-plugins/NewDP.h" 
    3033 
     
    4851        int desktopnumber; 
    4952        int xoffset; 
    50         bool defaultdesktop; 
     53        bool defaultdesktop, desktoplocked; 
    5154        QList<LPanel*> PANELS; 
    52         QWidget *bgWindow; 
     55        QMdiArea *bgDesktop; //desktop widget area 
     56        QWidget *bgWindow; //full screen background 
    5357        QMenu *deskMenu; 
    5458        AppMenu *appmenu; 
     
    5963        QString CBG; //current background 
    6064         
     65        void CreateDesktopPluginContainer(LDPlugin*); 
     66 
    6167private slots: 
    6268        void SettingsChanged(); 
     
    6874         
    6975        void UpdateDesktop(); 
     76        void ToggleDesktopLock(); 
    7077         
    7178        void UpdatePanels(); 
     79         
     80        void UpdateDesktopPluginArea(); 
    7281 
    7382        void UpdateBackground(); 
  • lumina/lumina-desktop/LSession.cpp

    r5b447eb r130bc0e  
    6363void LSession::launchStartupApps(){ 
    6464  QString startfile = QDir::homePath()+"/.lumina/startapps"; 
     65  if(!QFile::exists(startfile)){ startfile = "/usr/local/share/Lumina-DE/startapps"; } 
    6566  if(!QFile::exists(startfile)){ return; } 
    6667  qDebug() << "Launching startup applications"; 
  • lumina/lumina-desktop/desktop-plugins/LDPlugin.h

    r64bfe71 r130bc0e  
    1313 
    1414#include <QObject> 
    15 #include <QGroupBox> 
     15#include <QMdiSubWindow> 
    1616#include <QString> 
    1717#include <QRect> 
     
    2222#include <QResizeEvent> 
    2323 
    24 class LDPlugin : public QGroupBox{ 
     24class LDPlugin : public QWidget{ 
    2525        Q_OBJECT 
    2626         
     
    2828        QString plugintype; 
    2929        QRect validRect; 
    30         bool isMoving; 
    3130         
    3231public: 
    3332        QSettings *settings; 
    3433 
    35         LDPlugin(QWidget *parent = 0, QRect rect = QRect(), QString ptype="unknown") : QGroupBox(parent){ 
     34        LDPlugin(QWidget *parent = 0, QRect rect = QRect(), QString ptype="unknown") : QWidget(parent){ 
    3635          plugintype=ptype; 
    3736          validRect = rect; 
    3837          settings = new QSettings("desktop-plugins",ptype); 
    39                 this->setMouseTracking(true); 
    40           setMovable(true); 
    4138        } 
    4239         
    4340        ~LDPlugin(){ 
    44           //delete mvtimer; 
    4541          delete settings; 
    4642        } 
     
    5349          validRect = rect; 
    5450          QTimer::singleShot(0, this, SLOT(validateGeometry()) ); 
    55         } 
    56          
    57         void setMovable(bool movable){ 
    58           isMoving = movable; 
    59           this->setFlat(movable); 
    60           if(movable){  
    61             this->setTitle(plugintype); 
    62             this->setStyleSheet( "LDPlugin{ background-color: transparent; }" ); 
    63           }else{  
    64             this->setTitle("");  
    65             this->setStyleSheet( "LDPlugin{ background-color: rgb(255,255,255); }" ); 
    66           } 
    6751        } 
    6852         
     
    8064          } 
    8165        } 
    82  
    83         void showPlugin(){ 
    84           validateGeometry(false); 
    85           this->setGeometry( settings->value("location/x",0).toInt(), settings->value("location/y",0).toInt(), settings->value("location/width",this->sizeHint().width()).toInt(), settings->value("location/height",this->sizeHint().height()).toInt() ); 
    86           this->show(); 
    87         } 
    8866         
    8967        virtual void LocaleChange(){ 
     
    9573            //This is where all the visuals are set if using Theme-dependant icons. 
    9674        } 
    97  
     75/* 
    9876protected: 
    9977        virtual void MoveEvent(QMoveEvent *event){ 
     
    10987          settings->setValue("location/height", event->size().height()); 
    11088        } 
    111          
    112         virtual void MousePressEvent(QMouseEvent *event){ 
    113           qDebug() << "Mouse Down"; 
    114                 event->ignore(); 
    115         } 
    116          
    117         virtual void MouseReleaseEvent(QMouseEvent *event){ 
    118           qDebug() << "Mouse Up"; 
    119                 event->ignore(); 
    120         } 
    121          
    122         virtual void MouseMoveEvent(QMouseEvent *event){ 
    123           if(isMoving && event->buttons()!=Qt::NoButton){ 
    124             qDebug() << "Moving Plugin:"; 
    125             this->move( event->globalX() - event->pos().x(), event->globalY() - event->pos().y()); 
    126             event->accept(); 
    127           }else if(isMoving){ 
    128             qDebug() << "Move: No Buttons Pressed"; 
    129           } 
    130         } 
     89*/       
    13190}; 
    13291 
  • lumina/lumina-desktop/desktop-plugins/SamplePlugin.h

    r64bfe71 r130bc0e  
    2323          this->layout()->addWidget(button); 
    2424                connect(button, SIGNAL(clicked()), this, SLOT(showMessage()) ); 
    25           this->move(100,100); 
    2625        } 
    2726         
  • lumina/lumina-desktop/lumina-desktop.pro

    r64bfe71 r130bc0e  
    4242        panel-plugins/LTBWidget.h \ 
    4343        desktop-plugins/LDPlugin.h \ 
     44        desktop-plugins/LDPluginContainer.h \ 
    4445        desktop-plugins/NewDP.h \ 
    4546        panel-plugins/userbutton/LUserButton.h \ 
  • lumina/lumina-desktop/main.cpp

    rf71b232 r130bc0e  
    7474    WMProcess WM; 
    7575    WM.startWM(); 
    76     QObject::connect(&WM, SIGNAL(WMShutdown()), &a, SLOT(exit()) ); 
     76    //QObject::connect(&WM, SIGNAL(WMShutdown()), &a, SLOT(exit()) ); 
    7777    //Load the initial translations 
    7878    QTranslator translator; 
Note: See TracChangeset for help on using the changeset viewer.