Changeset 64bfe71


Ignore:
Timestamp:
07/07/14 13:05:19 (10 months ago)
Author:
Ken Moore <ken@…>
Branches:
master, releng/10.0.3, releng/10.1, releng/10.1.1, releng/10.1.2
Children:
ac10f15
Parents:
8817aad
Message:

Add a bunch of work on the desktop plugin system. It is not ready yet: but it can at least display the plugins now. Just trying to get the mouse tracking so that move/resize can be performed on the plugins too.

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

Legend:

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

    rcb6781b r64bfe71  
    123123  qDebug() << " - Update Desktop:" << desktopnumber; 
    124124  QStringList plugins = settings->value(DPREFIX+"pluginlist", QStringList()).toStringList(); 
    125   /*if(defaultdesktop && plugins.isEmpty()){ 
    126     plugins << "desktopview"; 
    127   }*/ 
     125  if(defaultdesktop && plugins.isEmpty()){ 
     126    //plugins << "sample"; 
     127  } 
    128128  for(int i=0; i<plugins.length(); i++){ 
    129129    //See if this plugin is already there 
     
    138138      //New Plugin 
    139139      qDebug() << " -- New Plugin:" << plugins[i]; 
    140       plug = NewDP::createPlugin(plugins[i], bgWindow); 
     140      plug = NewDP::createPlugin(plugins[i], bgWindow, bgWindow->geometry()); 
    141141      if(plug != 0){  
     142        qDebug() << " -- Show Plugin"; 
    142143        PLUGINS << plug; 
     144        plug->showPlugin(); 
    143145      } 
    144146    } 
    145147    //Update the plugin geometry 
    146     if(plug!=0){ 
     148    /*if(plug!=0){ 
    147149      QString geom = settings->value(DPREFIX+plugins[i]+"/geometry", "").toString(); 
    148150      if(geom.isEmpty()){ 
     
    155157      plug->setGeometry(geom.section(",",0,0).toInt(),geom.section(",",1,1).toInt(), geom.section(",",2,2).toInt(), geom.section(",",3,3).toInt() ); 
    156158      plug->show(); //make sure it is visible 
    157     } 
     159    }*/ 
    158160  } 
    159161   
  • lumina/lumina-desktop/desktop-plugins/LDPlugin.h

    r214f3d5 r64bfe71  
    1313 
    1414#include <QObject> 
    15 #include <QWidget> 
     15#include <QGroupBox> 
    1616#include <QString> 
     17#include <QRect> 
     18#include <QDebug> 
     19#include <QSettings> 
     20#include <QTimer> 
     21#include <QMoveEvent> 
     22#include <QResizeEvent> 
    1723 
    18 class LDPlugin : public QWidget{ 
     24class LDPlugin : public QGroupBox{ 
    1925        Q_OBJECT 
    2026         
    2127private: 
    2228        QString plugintype; 
     29        QRect validRect; 
     30        bool isMoving; 
     31         
     32public: 
     33        QSettings *settings; 
    2334 
    24 public: 
    25         LDPlugin(QWidget *parent = 0, QString ptype="unknown") : QWidget(parent){ 
     35        LDPlugin(QWidget *parent = 0, QRect rect = QRect(), QString ptype="unknown") : QGroupBox(parent){ 
    2636          plugintype=ptype; 
    27           this->setStyleSheet( "LDPlugin{ background-color: transparent; }" ); 
     37          validRect = rect; 
     38          settings = new QSettings("desktop-plugins",ptype); 
     39                this->setMouseTracking(true); 
     40          setMovable(true); 
    2841        } 
    2942         
    3043        ~LDPlugin(){ 
     44          //delete mvtimer; 
     45          delete settings; 
    3146        } 
    3247         
     
    3550        } 
    3651         
     52        void updateValidRect(QRect rect){ 
     53          validRect = rect; 
     54          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          } 
     67        } 
     68         
    3769public slots: 
    38         void LocaleChange(){ 
     70        void validateGeometry(bool canmove = true){ 
     71          //This checks the current location of the widget against the valid area 
     72          qDebug() << "DP geom:" << this->rect().x() << this->rect().y() << this->rect().width() << this->rect().height(); 
     73          if(!validRect.contains(this->rect())){ 
     74            qDebug() << "Invalid Geometry:" << this->rect().x() << this->rect().y() << this->rect().width() << this->rect().height(); 
     75            qDebug() << " - Valid:" << validRect.x() << validRect.y() << validRect.width() << validRect.height(); 
     76            //Move to just within the valid region 
     77            if(canmove){ 
     78                     
     79            } 
     80          } 
     81        } 
     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        } 
     88         
     89        virtual void LocaleChange(){ 
    3990          //This needs to be re-implemented in the subclassed plugin 
    4091            //This is where all text is set/translated 
    4192        } 
    42         void ThemeChange(){ 
    43           //This needs to be re-implemented in the subclasses plugin 
     93        virtual void ThemeChange(){ 
     94          //This needs to be re-implemented in the subclassed plugin 
    4495            //This is where all the visuals are set if using Theme-dependant icons. 
    4596        } 
     97 
     98protected: 
     99        virtual void MoveEvent(QMoveEvent *event){ 
     100          //Save this location to the settings 
     101          qDebug() << "DP Move:" << event->pos().x() << event->pos().y(); 
     102          settings->setValue("location/x", event->pos().x()); 
     103          settings->setValue("location/y", event->pos().y()); 
     104        } 
     105        virtual void ResizeEvent(QResizeEvent *event){ 
     106          //Save this size info to the settings 
     107          qDebug() << "DP Resize:" << event->size().width() << event->size().height(); 
     108          settings->setValue("location/width", event->size().width()); 
     109          settings->setValue("location/height", event->size().height()); 
     110        } 
    46111         
     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        } 
    47131}; 
    48132 
  • lumina/lumina-desktop/desktop-plugins/NewDP.h

    r214f3d5 r64bfe71  
    1414//List all the individual plugin includes here 
    1515#include "LDPlugin.h" 
    16 #include "desktopview/DesktopViewPlugin.h" 
     16#include "SamplePlugin.h" 
    1717 
    1818 
    1919class NewDP{ 
    2020public: 
    21         static LDPlugin* createPlugin(QString plugin, QWidget* parent=0){ 
     21        static LDPlugin* createPlugin(QString plugin, QWidget* parent=0, QRect rect = QRect()){ 
    2222          LDPlugin *plug = 0; 
    23           if(plugin=="desktopview"){ 
    24             plug = new DesktopViewPlugin(parent); 
     23          if(plugin=="sample"){ 
     24            plug = new SamplePlugin(parent, rect); 
    2525          }else{ 
    2626            qWarning() << "Invalid Desktop Plugin:"<<plugin << " -- Ignored"; 
  • lumina/lumina-desktop/lumina-desktop.pro

    rbc4f0662 r64bfe71  
    2424        panel-plugins/clock/LClock.cpp \ 
    2525        panel-plugins/battery/LBattery.cpp \ 
    26         panel-plugins/desktopswitcher/LDesktopSwitcher.cpp \ 
    27         desktop-plugins/desktopview/DesktopViewPlugin.cpp \ 
    28         desktop-plugins/desktopview/DeskItem.cpp 
     26        panel-plugins/desktopswitcher/LDesktopSwitcher.cpp 
     27#       desktop-plugins/desktopview/DesktopViewPlugin.cpp \ 
     28#       desktop-plugins/desktopview/DeskItem.cpp 
    2929 
    3030 
     
    5454        panel-plugins/taskmanager/LTaskManagerPlugin.h \ 
    5555        panel-plugins/taskmanager/LTaskButton.h \ 
    56         desktop-plugins/desktopview/DesktopViewPlugin.h \ 
    57         desktop-plugins/desktopview/DeskItem.h 
     56        desktop-plugins/SamplePlugin.h 
     57#       desktop-plugins/desktopview/DesktopViewPlugin.h \ 
     58#       desktop-plugins/desktopview/DeskItem.h 
    5859 
    5960FORMS    += SystemWindow.ui 
Note: See TracChangeset for help on using the changeset viewer.