Changeset f912f51


Ignore:
Timestamp:
07/10/14 12:20:50 (9 months ago)
Author:
Ken Moore <ken@…>
Branches:
master, releng/10.0.3, releng/10.1, releng/10.1.1
Children:
c78ef7c
Parents:
a65200d
Message:

Update the panel plugin system with some of the changes recently made for the desktop plugins.
1) This allows multiple instances of the same plugin on the same toolbar
2) This allows for both horizontal *or* vertical toolbars (left/right/top/bottom)

Note: Menu's seem to be having issues displaying properly for vertical toolbars. Not sure yet if this is related to something in Lumina or Fluxbox - but they appear to be getting drawn off-screen.

3) While here, fix the sizing issue for the system tray plugin (now it should only use the minimum space it needs).

Location:
lumina/lumina-desktop
Files:
18 edited

Legend:

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

    r736a2c8 rf912f51  
    1616  if(settings->value("defaultpanel",QString::number(screen->primaryScreen())+".0").toString()==QString::number(screennum)+"."+QString::number(num) ){ defaultpanel=true;} 
    1717  else{defaultpanel=false; } 
     18  horizontal=true; //use this by default initially 
    1819  //Setup the panel 
    1920  qDebug() << " -- Setup Panel"; 
     
    2829  //LX11::SetAsPanel(this->winId()); //set proper type of window for a panel since Qt can't do it 
    2930  LX11::SetAsSticky(this->winId()); 
    30   layout = new QHBoxLayout(this); 
     31  layout = new QBoxLayout(QBoxLayout::LeftToRight, this); 
    3132    layout->setContentsMargins(0,0,0,0); 
    32     layout->setAlignment(Qt::AlignLeft); 
    3333    layout->setSpacing(1); 
    3434    //layout->setSizeConstraint(QLayout::SetFixedSize); 
     
    5252  QString loc = settings->value(PPREFIX+"location","").toString(); 
    5353  if(loc.isEmpty() && defaultpanel){ loc="top"; } 
    54   int ht = settings->value(PPREFIX+"height", 22).toInt(); 
     54  if(loc=="top" || loc=="bottom"){  
     55    horizontal=true;  
     56    layout->setAlignment(Qt::AlignLeft);  
     57    layout->setDirection(QBoxLayout::LeftToRight); 
     58  }else{ 
     59    horizontal=false; 
     60    layout->setAlignment(Qt::AlignTop); 
     61    layout->setDirection(QBoxLayout::TopToBottom); 
     62  } 
     63  int ht = settings->value(PPREFIX+"height", 22).toInt(); //this is technically the distance into the screen from the edge 
    5564  int xoffset=0; 
    5665  for(int i=0; i<screennum; i++){ 
     
    6069  int xwid = screen->screenGeometry(screennum).width(); 
    6170  int xhi = screen->screenGeometry(screennum).height(); 
    62   if(loc=="top"){ 
     71  if(loc=="top"){ //top of screen 
    6372    QSize sz = QSize(xwid, ht); 
    6473    this->setMinimumSize(sz); 
     
    6675    this->setGeometry(xoffset,0,xwid, ht ); 
    6776    LX11::ReservePanelLocation(this->winId(), xoffset, 0, this->width(), ht); 
    68   }else{ 
     77  }else if(loc=="bottom"){ //bottom of screen 
    6978    QSize sz = QSize(xwid, ht); 
    7079    this->setMinimumSize(sz); 
     
    7281    this->setGeometry(xoffset,xhi-ht,xwid, ht ); 
    7382    LX11::ReservePanelLocation(this->winId(), xoffset, xhi-ht, this->width(), ht); 
     83  }else if(loc=="left"){ //left side of screen 
     84    QSize sz = QSize(ht, xhi); 
     85    this->setMinimumSize(sz); 
     86    this->setMaximumSize(sz); 
     87    this->setGeometry(xoffset,0, ht, xhi); 
     88    LX11::ReservePanelLocation(this->winId(), xoffset, 0, ht, xhi); 
     89  }else{ //right side of screen 
     90    QSize sz = QSize(ht, xhi); 
     91    this->setMinimumSize(sz); 
     92    this->setMaximumSize(sz); 
     93    this->setGeometry(xoffset+xwid-ht,0,ht, xhi); 
     94    LX11::ReservePanelLocation(this->winId(), xoffset+xwid-ht, 0, ht, xhi);        
    7495  } 
    7596  //Now update the appearance of the toolbar 
     
    88109  qDebug() << " - Initialize Plugins: " << plugins; 
    89110  for(int i=0; i<plugins.length(); i++){ 
     111    //Ensure this plugin has a unique ID (NOTE: this numbering does not persist between sessions) 
     112    if(!plugins[i].contains("---")){ 
     113      int num=1; 
     114      while( plugins.contains(plugins[i]+"---"+QString::number(this->number())+"."+QString::number(num)) ){ 
     115        num++; 
     116      } 
     117      plugins[i] = plugins[i]+"---"+QString::number(this->number())+"."+QString::number(num); 
     118    } 
    90119    //See if this plugin is already there or in a different spot 
    91120    bool found = false; 
     
    93122      if(PLUGINS[p]->type()==plugins[i]){ 
    94123        found = true; //already exists 
     124        //Make sure the plugin layout has the correct orientation 
     125        if(horizontal){PLUGINS[p]->layout()->setDirection(QBoxLayout::LeftToRight); } 
     126        else{ PLUGINS[p]->layout()->setDirection(QBoxLayout::TopToBottom); } 
     127        //Now check the location of the plugin in the panel 
    95128        if(p!=i){ //wrong place in the panel 
    96129          layout->takeAt(p); //remove the item from the current location 
     
    104137      //New Plugin 
    105138      qDebug() << " -- New Plugin:" << plugins[i]; 
    106       LPPlugin *plug = NewPP::createPlugin(plugins[i]); 
     139      LPPlugin *plug = NewPP::createPlugin(plugins[i], this, horizontal); 
    107140      if(plug != 0){  
    108141        PLUGINS.insert(i, plug); 
  • lumina/lumina-desktop/LPanel.h

    rb6c1838 rf912f51  
    1212 
    1313#include <QWidget> 
    14 #include <QHBoxLayout> 
     14#include <QBoxLayout> 
    1515#include <QSettings> 
    1616#include <QString> 
     
    2828        Q_OBJECT 
    2929private: 
    30         QHBoxLayout *layout; 
     30        QBoxLayout *layout; 
    3131        QSettings *settings; 
    3232        QString PPREFIX; //internal prefix for all settings 
    3333        QDesktopWidget *screen; 
    34         bool defaultpanel; 
     34        bool defaultpanel, horizontal; 
    3535        int screennum; 
    3636        QList<LPPlugin*> PLUGINS; 
  • lumina/lumina-desktop/panel-plugins/LPPlugin.h

    rb6c1838 rf912f51  
    1515#include <QWidget> 
    1616#include <QString> 
    17 #include <QHBoxLayout> 
     17#include <QBoxLayout> 
    1818 
    1919class LPPlugin : public QWidget{ 
     
    2121         
    2222private: 
    23         QHBoxLayout *LY; 
     23        QBoxLayout *LY; 
    2424        QString plugintype; 
    2525 
    2626public: 
    27         LPPlugin(QWidget *parent = 0, QString ptype="unknown") : QWidget(parent){ 
     27        LPPlugin(QWidget *parent = 0, QString ptype="unknown", bool horizontal = true) : QWidget(parent){ 
    2828          plugintype=ptype; 
    2929          this->setContentsMargins(0,0,0,0); 
    3030          this->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); 
    31           LY = new QHBoxLayout(this); 
     31          if(horizontal){LY = new QBoxLayout(QBoxLayout::LeftToRight, this); } 
     32          else{ LY = new QBoxLayout(QBoxLayout::TopToBottom, this); } 
    3233          LY->setContentsMargins(0,0,0,0); 
    3334          LY->setSpacing(1); 
     
    3839        } 
    3940         
    40         QHBoxLayout* layout(){ 
     41        QBoxLayout* layout(){ 
    4142          return LY; 
    4243        } 
  • lumina/lumina-desktop/panel-plugins/NewPP.h

    rb6c1838 rf912f51  
    2525class NewPP{ 
    2626public: 
    27         static LPPlugin* createPlugin(QString plugin, QWidget* parent = 0){ 
     27        static LPPlugin* createPlugin(QString plugin, QWidget* parent = 0, bool horizontal = true){ 
    2828          LPPlugin *plug = 0; 
    29           if(plugin=="userbutton"){ 
    30             plug = new LUserButtonPlugin(parent); 
    31           }else if(plugin=="desktopbar"){ 
    32             plug = new LDeskBarPlugin(parent); 
    33           }else if(plugin=="spacer"){ 
    34             plug = new LSpacerPlugin(parent); 
    35           }else if(plugin=="taskmanager"){ 
    36             plug = new LTaskManagerPlugin(parent); 
    37           }else if(plugin=="systemtray"){ 
    38             plug = new LSysTray(parent); 
    39           }else if(plugin=="desktopswitcher"){ 
    40             plug = new LDesktopSwitcher(parent); 
    41           }else if(plugin=="battery"){ 
    42             plug = new LBattery(parent); 
    43           }else if(plugin=="clock"){ 
    44             plug = new LClock(parent); 
     29          if(plugin.startsWith("userbutton---")){ 
     30            plug = new LUserButtonPlugin(parent, plugin, horizontal); 
     31          }else if(plugin.startsWith("desktopbar---")){ 
     32            plug = new LDeskBarPlugin(parent, plugin, horizontal); 
     33          }else if(plugin.startsWith("spacer---")){ 
     34            plug = new LSpacerPlugin(parent, plugin, horizontal); 
     35          }else if(plugin.startsWith("taskmanager---")){ 
     36            plug = new LTaskManagerPlugin(parent, plugin, horizontal); 
     37          }else if(plugin.startsWith("systemtray---")){ 
     38            plug = new LSysTray(parent, plugin, horizontal); 
     39          }else if(plugin.startsWith("desktopswitcher---")){ 
     40            plug = new LDesktopSwitcher(parent, plugin, horizontal); 
     41          }else if(plugin.startsWith("battery---")){ 
     42            plug = new LBattery(parent, plugin, horizontal); 
     43          }else if(plugin.startsWith("clock---")){ 
     44            plug = new LClock(parent, plugin, horizontal); 
    4545          }else{ 
    4646            qWarning() << "Invalid Panel Plugin:"<<plugin << " -- Ignored"; 
  • lumina/lumina-desktop/panel-plugins/battery/LBattery.cpp

    r5f42f3f rf912f51  
    77#include "LBattery.h" 
    88 
    9 LBattery::LBattery(QWidget *parent) : LPPlugin(parent, "battery"){ 
     9LBattery::LBattery(QWidget *parent, QString id, bool horizontal) : LPPlugin(parent, id, horizontal){ 
    1010  iconOld = -1; 
    1111  //Setup the widget 
  • lumina/lumina-desktop/panel-plugins/battery/LBattery.h

    r5f42f3f rf912f51  
    2323        Q_OBJECT 
    2424public: 
    25         LBattery(QWidget *parent = 0); 
     25        LBattery(QWidget *parent = 0, QString id = "battery", bool horizontal=true); 
    2626        ~LBattery(); 
    2727         
  • lumina/lumina-desktop/panel-plugins/clock/LClock.cpp

    r7dfbedf rf912f51  
    77#include "LClock.h" 
    88 
    9 LClock::LClock(QWidget *parent) : LPPlugin(parent, "clock"){ 
     9LClock::LClock(QWidget *parent, QString id, bool horizontal) : LPPlugin(parent, id, horizontal){ 
    1010  //Setup the widget 
    1111  label = new QLabel(this); 
  • lumina/lumina-desktop/panel-plugins/clock/LClock.h

    r7dfbedf rf912f51  
    2020        Q_OBJECT 
    2121public: 
    22         LClock(QWidget *parent = 0); 
     22        LClock(QWidget *parent = 0, QString id = "clock", bool horizontal=true); 
    2323        ~LClock(); 
    2424         
  • lumina/lumina-desktop/panel-plugins/desktopbar/LDeskBar.cpp

    rad79832 rf912f51  
    77#include "LDeskBar.h" 
    88 
    9 LDeskBarPlugin::LDeskBarPlugin(QWidget *parent) : LPPlugin(parent, "desktopbar"){ 
     9LDeskBarPlugin::LDeskBarPlugin(QWidget *parent, QString id, bool horizontal) : LPPlugin(parent, id, horizontal){ 
    1010  //Find the path to the desktop folder 
    1111  if(QFile::exists(QDir::homePath()+"/Desktop")){ desktopPath = QDir::homePath()+"/Desktop"; } 
  • lumina/lumina-desktop/panel-plugins/desktopbar/LDeskBar.h

    r64ba4c0 rf912f51  
    3434        Q_OBJECT 
    3535public: 
    36         LDeskBarPlugin(QWidget* parent=0); 
     36        LDeskBarPlugin(QWidget* parent=0, QString id = "desktopbar", bool horizontal=true); 
    3737        ~LDeskBarPlugin(); 
    3838         
  • lumina/lumina-desktop/panel-plugins/desktopswitcher/LDesktopSwitcher.cpp

    r92c8291 rf912f51  
    77#include "LDesktopSwitcher.h" 
    88 
    9 LDesktopSwitcher::LDesktopSwitcher(QWidget *parent) : LPPlugin(parent, "desktopswitcher") { 
     9LDesktopSwitcher::LDesktopSwitcher(QWidget *parent, QString id, bool horizontal) : LPPlugin(parent, id, horizontal) { 
    1010  iconOld = -1; 
    1111 
  • lumina/lumina-desktop/panel-plugins/desktopswitcher/LDesktopSwitcher.h

    r5f42f3f rf912f51  
    2828        Q_OBJECT 
    2929public: 
    30         LDesktopSwitcher(QWidget *parent = 0); 
     30        LDesktopSwitcher(QWidget *parent = 0, QString id = "desktopswitcher", bool horizontal=true); 
    3131        ~LDesktopSwitcher(); 
    3232         
  • lumina/lumina-desktop/panel-plugins/spacer/LSpacer.h

    r214f3d5 rf912f51  
    1515        Q_OBJECT 
    1616public: 
    17         LSpacerPlugin(QWidget *parent=0) : LPPlugin(parent, "spacer"){ 
    18           this->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); 
     17        LSpacerPlugin(QWidget *parent=0, QString id="spacer", bool horizontal=true) : LPPlugin(parent, id, horizontal){ 
     18          if(horizontal){ this->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); } 
     19          else{ this->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); } 
    1920        } 
    2021        ~LSpacerPlugin(){} 
  • lumina/lumina-desktop/panel-plugins/systemtray/LSysTray.cpp

    rbc4f0662 rf912f51  
    77#include "LSysTray.h" 
    88 
    9 LSysTray::LSysTray(QWidget *parent) : LPPlugin(parent, "systemtray"){ 
    10   this->layout()->setAlignment(Qt::AlignRight | Qt::AlignVCenter); 
     9LSysTray::LSysTray(QWidget *parent, QString id, bool horizontal) : LPPlugin(parent, id, horizontal){ 
     10  //if(horizontal){ this->layout()->setAlignment(Qt::AlignRight | Qt::AlignVCenter); } 
     11  //else{ this->layout()->setAlignment(Qt::AlignHCenter | Qt::AlignTop); } 
     12  this->layout()->setAlignment(Qt::AlignCenter); 
     13  this->setStyleSheet("LPPlugin{ background: black; border: 1px solid grey; border-radius: 3px; }"); 
     14  this->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); 
    1115  this->layout()->setSpacing(0); 
    1216  isRunning = false; 
     
    6064      trayIcons << cont; 
    6165      this->layout()->addWidget(cont); 
    62       cont->setSizeSquare(this->height()); //assuming horizontal tray 
     66      if(this->layout()->direction()==QBoxLayout::LeftToRight){ 
     67        cont->setSizeSquare(this->height()); //horizontal tray 
     68        this->setMaximumSize( trayIcons.length()*this->height(), 10000); 
     69      }else{ 
     70        cont->setSizeSquare(this->width()); //vertical tray 
     71        this->setMaximumSize(10000, trayIcons.length()*this->width()); 
     72      } 
    6373      cont->attachApp(win); 
    6474    //this->layout()->update(); //make sure there is no blank space 
     
    8191    } 
    8292  } 
     93  //Re-adjust the maximum widget size 
     94  if(this->layout()->direction()==QBoxLayout::LeftToRight){ 
     95    this->setMaximumSize( trayIcons.length()*this->height(), 10000); 
     96  }else{ 
     97    this->setMaximumSize(10000, trayIcons.length()*this->width()); 
     98  } 
    8399  this->layout()->update(); //update the layout (no gaps) 
    84100  this->update();        
  • lumina/lumina-desktop/panel-plugins/systemtray/LSysTray.h

    rbc4f0662 rf912f51  
    2323        Q_OBJECT 
    2424public: 
    25         LSysTray(QWidget *parent = 0); 
     25        LSysTray(QWidget *parent = 0, QString id="systemtray", bool horizontal=true); 
    2626        ~LSysTray(); 
    2727 
  • lumina/lumina-desktop/panel-plugins/taskmanager/LTaskManagerPlugin.cpp

    re6e5ccdf rf912f51  
    77#include "LTaskManagerPlugin.h" 
    88 
    9 LTaskManagerPlugin::LTaskManagerPlugin(QWidget *parent) : LPPlugin(parent, "taskmanager"){ 
     9LTaskManagerPlugin::LTaskManagerPlugin(QWidget *parent, QString id, bool horizontal) : LPPlugin(parent, id, horizontal){ 
    1010  updating=false; 
    1111  timer = new QTimer(this); 
  • lumina/lumina-desktop/panel-plugins/taskmanager/LTaskManagerPlugin.h

    r214f3d5 rf912f51  
    2828        Q_OBJECT 
    2929public: 
    30         LTaskManagerPlugin(QWidget *parent=0); 
     30        LTaskManagerPlugin(QWidget *parent=0, QString id="taskmanager", bool horizontal=true); 
    3131        ~LTaskManagerPlugin(); 
    3232 
  • lumina/lumina-desktop/panel-plugins/userbutton/LUserButton.h

    r307712c rf912f51  
    4545        void buttonClicked(){ 
    4646          UpdateMenu(); 
    47           mainMenu->popup(this->mapToGlobal(QPoint(0,this->height())) ); 
     47          mainMenu->popup(this->mapToGlobal( QPoint(0,this->height()) ) ); 
    4848        } 
    4949         
     
    6767 
    6868public: 
    69         LUserButtonPlugin(QWidget *parent = 0) : LPPlugin(parent, "userbutton"){ 
     69        LUserButtonPlugin(QWidget *parent = 0, QString id = "userbutton", bool horizontal=true) : LPPlugin(parent, id, horizontal){ 
    7070          button = new LUserButton(parent); 
    7171          this->layout()->addWidget(button); 
Note: See TracChangeset for help on using the changeset viewer.