aboutsummaryrefslogtreecommitdiff
path: root/lumina-desktop
diff options
context:
space:
mode:
authorKen Moore <moorekou@gmail.com>2015-07-10 02:35:11 -0400
committerKen Moore <moorekou@gmail.com>2015-07-10 02:35:11 -0400
commitfb8955c15a73911e53fdf1e7a7ada2630272ffd5 (patch)
treee73df3ba004f52539be9f57758123309d1764f3c /lumina-desktop
parentUpdate lumina-config to list all desktop plugins on the screen, and only make... (diff)
downloadlumina-fb8955c15a73911e53fdf1e7a7ada2630272ffd5.tar.gz
lumina-fb8955c15a73911e53fdf1e7a7ada2630272ffd5.tar.bz2
lumina-fb8955c15a73911e53fdf1e7a7ada2630272ffd5.zip
Ok, NOW the desktop plugins layout methodology is consistent/reliable. Had to implement my own tiling algorithm for initial plugin placements (and adjust a lot of the plugins to have better auto-set default sizes depending on font settings)
Diffstat (limited to 'lumina-desktop')
-rw-r--r--lumina-desktop/LDesktop.cpp81
-rw-r--r--lumina-desktop/LDesktop.h3
-rw-r--r--lumina-desktop/desktop-plugins/LDPluginContainer.h33
-rw-r--r--lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.cpp10
-rw-r--r--lumina-desktop/desktop-plugins/audioplayer/PlayerWidget.cpp2
-rw-r--r--lumina-desktop/desktop-plugins/desktopview/DesktopViewPlugin.cpp2
-rw-r--r--lumina-desktop/desktop-plugins/notepad/NotepadPlugin.cpp5
-rw-r--r--lumina-desktop/desktop-plugins/quickcontainer/QuickDPlugin.h1
-rw-r--r--lumina-desktop/desktop-plugins/systemmonitor/MonitorWidget.cpp2
9 files changed, 73 insertions, 66 deletions
diff --git a/lumina-desktop/LDesktop.cpp b/lumina-desktop/LDesktop.cpp
index c9168651..ec56b7b0 100644
--- a/lumina-desktop/LDesktop.cpp
+++ b/lumina-desktop/LDesktop.cpp
@@ -11,7 +11,7 @@
#include <LuminaX11.h>
#include "LWinInfo.h"
-#define DEBUG 1
+#define DEBUG 0
LDesktop::LDesktop(int deskNum, bool setdefault) : QObject(){
@@ -186,19 +186,31 @@ LDPluginContainer* LDesktop::CreateDesktopPluginContainer(LDPlugin *plug){
}
//Create a new plugin container
LDPluginContainer *win = new LDPluginContainer(plug, desktoplocked);
+ win->loadInitialSize(); //Sizing should be done before adding the window to the area
if(desktoplocked){
- bgDesktop->addSubWindow(win, Qt::Tool | Qt::FramelessWindowHint);
- }else{ bgDesktop->addSubWindow(win, Qt::Tool | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint); }
- win->loadInitialPosition();
+ bgDesktop->addSubWindow(win, Qt::Tool | Qt::FramelessWindowHint);
+ }else{
+ bgDesktop->addSubWindow(win, Qt::Tool | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint);
+ }
+ if( !win->hasFixedPosition() ){
+ //NOTE: This section *only* runs for new plugins - it does not run for re-creations of old plugins
+ //Need to determine the location of the plugin (leave size alone)
+ if(DEBUG){ qDebug() << " --- Floating Plugin - find a spot for it"; }
+ QPoint pt = findNewPluginLocation(availDPArea, win->size());
+ if(pt.x()>=0 && pt.y()>=0){
+ win->saveNewPosition(pt);
+ win->move(pt);
+ if(DEBUG){ qDebug() << " --- Moving to point:" << pt; }
+ }
+ //Make sure to remove this plugin from the availability region
+ availDPArea = availDPArea.subtracted( QRegion(win->geometry()) );
+ }
+ QApplication::processEvents();
+ QTimer::singleShot(300+(5*PLUGINS.length()), win, SLOT(loadInitialPosition()) ); //Now load the position (if one is saved)
if(DEBUG){
qDebug() << "Initial DP Geom:" << plug->geometry();
qDebug() << " - Container Geom:" << win->geometry();
}
- win->show();
- plug->update();
- win->update();
- bgDesktop->update();
- QApplication::processEvents();
QApplication::processEvents();
connect(win, SIGNAL(PluginRemoved(QString)), this, SLOT(DesktopPluginRemoved(QString)) );
@@ -210,7 +222,7 @@ QPoint LDesktop::findNewPluginLocation(QRegion avail, QSize winsize){
// will fit without overlapping anything else (scanning left->right, top->bottom)
//return QPoint(-1,-1); //just for testing
QRect bounds = avail.boundingRect();
- qDebug() << "Bounds:" << bounds;
+ //qDebug() << "Bounds:" << bounds;
if(bounds.width()<winsize.width() || bounds.height()<winsize.height()){ return QPoint(-1,-1); }
QPoint pt = bounds.topLeft(); //start in upper-left corner
@@ -220,16 +232,18 @@ QPoint LDesktop::findNewPluginLocation(QRegion avail, QSize winsize){
int dy = winsize.height()/2;
while(pt.x()+winsize.width() < bounds.right() && !found){
//Check the horizontal position (incrementing as necessary)
- QRect inter = avail.intersected(QRect(pt, winsize)).boundingRect();
- if(DEBUG){ qDebug() << "Check X:" << pt << " - Inter:" << inter; }
- if(inter.size() == winsize && avail.contains(inter) ){ found = true; } //use this point
+ QRegion intersect = avail.intersected(QRect(pt, winsize)); // full intersection
+ if(DEBUG){ qDebug() << "Check X:" << pt << " - Inter:" << intersect.boundingRect(); }
+ if(intersect.boundingRect().size()==winsize && intersect.rects().length()==1 ){ found = true; } //use this point
else{
+ QRect inter = avail.intersected(QRect(pt, QSize(winsize.width(),1))).boundingRect(); //1D intersection in X-dir
int dx = winsize.width() - inter.width();
if(dx>0 && inter.left() > pt.x()){ pt.setX( inter.left() ); }
else if(inter.width()==0){ pt.setX( pt.x()+winsize.width() ); }
else{ pt.setX( pt.x()+inter.width() ); }
//Also adjust the dy value to the smallest amount
- int ddy = inter.height() - winsize.height();
+ inter = avail.intersected(QRect(pt, QSize(1,winsize.height()))).boundingRect(); //1D intersection in X-dir
+ int ddy = inter.y()-pt.y();
if(ddy < dy && ddy>0){ dy = ddy; }
}
@@ -404,7 +418,6 @@ void LDesktop::UpdateDesktop(){
}
}
//Go through the plugins and remove any existing ones that do not show up on the current list
-
for(int i=0; i<PLUGINS.length(); i++){
if(!plugins.contains(PLUGINS[i]->ID())){
//Remove this plugin (with settings) - is not currently listed
@@ -412,18 +425,18 @@ void LDesktop::UpdateDesktop(){
i--;
}
}
- //Now get an accounting of all the available/used space
- QRegion avail;//Note that this is child-geometry space
- if(!bgDesktop->isVisible()){ avail = QRegion( QRect(QPoint(0,0),desktop->screenGeometry(desktopnumber).size()) ); }
- else{ avail = QRegion(QRect(QPoint(0,0),bgDesktop->size()) ); qDebug() << "Desktop size:" << bgDesktop->size(); }
+ //Now get an accounting of all the available/used space (overwriting the private variable)
+ QSize ssize = desktop->screenGeometry(desktopnumber).size();
+ //qDebug() << "Screen Size:" << ssize << desktopnumber;
+ if(bgDesktop->isVisible() && ( (bgDesktop->size().height() <= ssize.height()) && (bgDesktop->size().width() <= ssize.width()) )){ ssize = bgDesktop->size(); qDebug() << " - Adjusted:" << ssize; }
+ availDPArea = QRegion(QRect(QPoint(0,0), ssize)); //Note that this is child-geometry space
+ //Remove all the space currently occupied
//qDebug() << "Available Screen Geom:" << avail.boundingRect();
- //avail = avail.subtracted( bgDesktop->childrenRegion() ); //
- /*QList<QMdiSubWindow*> wins = bgDesktop->subWindowList();
- for(int i=0; i<wins.length(); i++){
- QRect geom = wins[i]->geometry()
- if(avail.contains(wins[i]->geometry())){ avail = avail.subtracted( QRegion(wins[i]->geometry()) ); }
- }*/
- //qDebug() << " - after removals:" << avail.boundingRect();
+ QList<QMdiSubWindow*> wins = bgDesktop->subWindowList();
+ for(int i=0; i<wins.length(); i++){
+ qDebug() << "Subtracting Geom:" << wins[i]->geometry();
+ availDPArea = availDPArea.subtracted( QRegion(wins[i]->geometry()) );
+ }
//Now add/update plugins
for(int i=0; i<plugins.length(); i++){
//See if this plugin is already there
@@ -445,24 +458,10 @@ void LDesktop::UpdateDesktop(){
if(DEBUG){ qDebug() << " --- Show Plugin"; }
PLUGINS << plug;
QApplication::processEvents(); //need a moment between plugin/container creation
- QRegion tmpavail = avail - bgDesktop->childrenRegion(); //currently available space right now
LDPluginContainer *cont = CreateDesktopPluginContainer(plug);
- cont->show();
- QApplication::processEvents();
- if(!cont->hasFixedPosition()){
- //Need to arrange the location of the plugin (leave size alone)
- if(DEBUG){ qDebug() << " --- Floating Plugin - find a spot for it"; }
- QPoint pt = findNewPluginLocation(tmpavail, cont->size());
- if(pt.x()>=0 && pt.y()>=0){
- cont->saveNewPosition(pt);
- QTimer::singleShot(500, cont, SLOT(loadInitialPosition()) ); //re-load geometry in a moment
- if(DEBUG){ qDebug() << " --- Moving to point:" << pt; }
- }
- }
//Done with this plugin - removed it's area from the available space
if(DEBUG){ qDebug() << " --- Done Creating Plugin Container" << cont->geometry(); }
- //avail = avail.subtracted( QRegion(cont->geometry()) );
-
+ //avail = avail.subtracted( QRegion(cont->geometry()) ); //remove this space from the available region as well
}
}
QApplication::processEvents(); //need to process events between loading of plugins
diff --git a/lumina-desktop/LDesktop.h b/lumina-desktop/LDesktop.h
index 482f1401..e454d03b 100644
--- a/lumina-desktop/LDesktop.h
+++ b/lumina-desktop/LDesktop.h
@@ -20,6 +20,7 @@
#include <QWidgetAction>
#include <QMdiArea>
#include <QMdiSubWindow>
+#include <QRegion>
#include <LuminaXDG.h>
@@ -59,7 +60,7 @@ private:
QDesktopWidget *desktop;
QString DPREFIX;
int desktopnumber;
- //int xoffset;
+ QRegion availDPArea;
bool defaultdesktop, desktoplocked, issyncing, usewinmenu, bgupdating;
QStringList oldBGL;
QList<LPanel*> PANELS;
diff --git a/lumina-desktop/desktop-plugins/LDPluginContainer.h b/lumina-desktop/desktop-plugins/LDPluginContainer.h
index 0bf40873..e7388a80 100644
--- a/lumina-desktop/desktop-plugins/LDPluginContainer.h
+++ b/lumina-desktop/desktop-plugins/LDPluginContainer.h
@@ -35,12 +35,12 @@ private:
private slots:
void saveGeometry(){
if(PLUG==0){ return; }
- if(!locked && !setup){
+ //if(!locked && !setup){
PLUG->saveSetting("location/x", this->pos().x());
PLUG->saveSetting("location/y", this->pos().y());
- PLUG->saveSetting("location/width", this->size().width());
- PLUG->saveSetting("location/height", this->size().height());
- }
+ PLUG->saveSetting("location/width", this->width()-4);
+ PLUG->saveSetting("location/height", this->height()-4);
+ //}
}
public:
@@ -84,25 +84,27 @@ public:
}
public slots:
+ void loadInitialSize(){
+ if(PLUG==0){ return; }
+ QSize sz(PLUG->readSetting("location/width",100).toInt(), PLUG->readSetting("location/height",100).toInt());
+ this->resize(sz);
+ }
+
void loadInitialPosition(){
QRect set(PLUG->readSetting("location/x",-12345).toInt(), PLUG->readSetting("location/y",-12345).toInt(), PLUG->readSetting("location/width",PLUG->size().width()).toInt() +4, PLUG->readSetting("location/height",PLUG->size().height()).toInt()+4);
//qDebug() << "Initial Plugin Location:" << set.x() << set.y() << set.width() << set.height();
if(set.height() < 10){ set.setHeight(10); } //to prevent foot-shooting
if(set.width() < 10){ set.setWidth(10); } //to prevent foot-shooting
- /*if(!locked){
- //adjust the size to account for the container borders/frame
-
- }*/
if(set.x()!=-12345 && set.y()!=-12345){
- //custom location specified
- //qDebug() << " - Found Geom:" << set;
- this->setGeometry(set);
//this->move(set.x(), set.y());
- //PLUG->resize(set.width(), set.height());
+ this->setGeometry(set);
}else{
- //qDebug() << " - Found Size:" << set;
+ qDebug() << " - Found Size:" << set;
this->resize(set.width(), set.height());
+ qDebug() << " - Assigning location:" << this->pos();
+ saveNewPosition(this->pos());
}
+ this->show();
QApplication::processEvents();
setup=false; //done with setup
}
@@ -113,8 +115,9 @@ signals:
protected:
void moveEvent(QMoveEvent *event){
+ //qDebug() << "Move Event: " << PLUG->ID() << setup;
//Save this location to the settings
- if(!locked && !setup){
+ if( !setup ){
if(syncTimer->isActive()){ syncTimer->stop(); }
syncTimer->start();
//qDebug() << "DP Move:" << event->pos().x() << event->pos().y();
@@ -124,7 +127,7 @@ protected:
void resizeEvent(QResizeEvent *event){
//Save this size info to the settings
- if(!locked && !setup){
+ if(!setup){
//qDebug() << "DP Resize:" << event->size().width() << event->size().height();
if(syncTimer->isActive()){ syncTimer->stop(); }
syncTimer->start();
diff --git a/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.cpp b/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.cpp
index 52c82556..ea42f151 100644
--- a/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.cpp
+++ b/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.cpp
@@ -8,7 +8,7 @@ AppLauncherPlugin::AppLauncherPlugin(QWidget* parent, QString ID) : LDPlugin(par
button = new QToolButton(this);
button->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
button->setAutoRaise(true);
- button->setText("..."); //Need to set something here so that initial sizing works properly
+ button->setText("...\n..."); //Need to set something here so that initial sizing works properly
lay->addWidget(button, 0, Qt::AlignCenter);
connect(button, SIGNAL(clicked()), this, SLOT(buttonClicked()) );
@@ -27,8 +27,9 @@ AppLauncherPlugin::AppLauncherPlugin(QWidget* parent, QString ID) : LDPlugin(par
//qDebug() << "Button Size:" << button->size();
//qDebug() << "Calculated:" << icosize+4 << icosize+8+qRound(2.15*button->fontMetrics().height());
//qDebug() << "Preferred Size:" << button->sizeHint();
- this->setInitialSize(qRound(1.1*icosize)+4, icosize+8+qRound(2.5*button->fontMetrics().height()));
-
+ QSize sz(qRound(1.1*icosize), icosize+qRound(2.7*button->fontMetrics().height()) );
+ button->setFixedSize(sz); //make sure to adjust the button on first show.
+ this->setInitialSize(this->sizeHint().width()+2, this->sizeHint().height()+2); //give the container a bit of a buffer
QTimer::singleShot(100,this, SLOT(loadButton()) );
}
@@ -76,7 +77,7 @@ void AppLauncherPlugin::loadButton(bool onchange){
button->setToolTip(txt);
int icosize = this->readSetting("iconsize",64).toInt();
int bwid = qRound(1.1*icosize);
- button->setFixedSize(bwid, icosize+qRound(2.5*button->fontMetrics().height()) ); //make sure to adjust the button on first show.
+ this->setFixedSize(bwid, icosize+qRound(2.5*button->fontMetrics().height()) ); //make sure to adjust the button on first show.
if(onchange){ this->adjustSize( bwid+4, icosize+8+qRound(2.5*button->fontMetrics().height())); }
//qDebug() << "Initial Button Text:" << txt << icosize;
if(button->fontMetrics().width(txt) > (bwid-2) ){
@@ -97,6 +98,7 @@ void AppLauncherPlugin::loadButton(bool onchange){
txt.insert( (txt.count()/2), "\n");
}
}
+ if(!txt.contains("\n")){ txt.append("\n "); } //always use two lines
//qDebug() << " - Setting Button Text:" << txt;
button->setText(txt);
//Now setup the menu again
diff --git a/lumina-desktop/desktop-plugins/audioplayer/PlayerWidget.cpp b/lumina-desktop/desktop-plugins/audioplayer/PlayerWidget.cpp
index cc1136f1..459e4610 100644
--- a/lumina-desktop/desktop-plugins/audioplayer/PlayerWidget.cpp
+++ b/lumina-desktop/desktop-plugins/audioplayer/PlayerWidget.cpp
@@ -262,7 +262,7 @@ AudioPlayerPlugin::AudioPlayerPlugin(QWidget *parent, QString ID) : LDPlugin(par
this->layout()->setContentsMargins(0,0,0,0);
this->layout()->addWidget(player);
- this->setInitialSize(300,75);
+ this->setInitialSize(this->sizeHint().width(), this->sizeHint().height());
}
AudioPlayerPlugin::~AudioPlayerPlugin(){
diff --git a/lumina-desktop/desktop-plugins/desktopview/DesktopViewPlugin.cpp b/lumina-desktop/desktop-plugins/desktopview/DesktopViewPlugin.cpp
index 5fdd1ba0..c3d2cc8b 100644
--- a/lumina-desktop/desktop-plugins/desktopview/DesktopViewPlugin.cpp
+++ b/lumina-desktop/desktop-plugins/desktopview/DesktopViewPlugin.cpp
@@ -40,7 +40,7 @@ DesktopViewPlugin::DesktopViewPlugin(QWidget* parent, QString ID) : LDPlugin(par
menu->addAction( LXDG::findIcon("system-search",""), tr("Properties"), this, SLOT(displayProperties()) );
}
this->layout()->addWidget(list);
- this->setInitialSize(600,600);
+ this->setInitialSize(300,300);
connect(QApplication::instance(), SIGNAL(DesktopFilesChanged()), this, SLOT(updateContents()) );
connect(list, SIGNAL(itemActivated(QListWidgetItem*)), this, SLOT(runItems()) );
diff --git a/lumina-desktop/desktop-plugins/notepad/NotepadPlugin.cpp b/lumina-desktop/desktop-plugins/notepad/NotepadPlugin.cpp
index 7d9076c7..f66cb53e 100644
--- a/lumina-desktop/desktop-plugins/notepad/NotepadPlugin.cpp
+++ b/lumina-desktop/desktop-plugins/notepad/NotepadPlugin.cpp
@@ -59,11 +59,12 @@ NotePadPlugin::NotePadPlugin(QWidget* parent, QString ID) : LDPlugin(parent, ID)
//qDebug() << "Saving a new setting";
this->saveSetting("customFile",""); //always clear this when the plugin is initialized (only maintained per-session)
//qDebug() << "Loading Notes Dir";
- notesDirChanged();
+ QTimer::singleShot(2000, this, SLOT(notesDirChanged()));
//qDebug() << "Set Sizing";
//Now setup the initial values for the plugin
- this->setInitialSize(200,300);
+ qDebug() << "New Notepad:" << this->sizeHint() << this->size();
+ this->setInitialSize(this->sizeHint().width(),this->sizeHint().height());
//qDebug() << "Connect Signals/slots";
//Setup the button connections
connect(open, SIGNAL(clicked()), this, SLOT(openNote()) );
diff --git a/lumina-desktop/desktop-plugins/quickcontainer/QuickDPlugin.h b/lumina-desktop/desktop-plugins/quickcontainer/QuickDPlugin.h
index 2bde5d54..3a14b26c 100644
--- a/lumina-desktop/desktop-plugins/quickcontainer/QuickDPlugin.h
+++ b/lumina-desktop/desktop-plugins/quickcontainer/QuickDPlugin.h
@@ -25,6 +25,7 @@ public:
container->setResizeMode(QQuickWidget::SizeRootObjectToView);
this->layout()->addWidget(container);
container->setSource(QUrl::fromLocalFile( LUtils::findQuickPluginFile(ID.section("---",0,0)) ));
+ this->setInitialSize(container->initialSize().width(), container->initialSize().height());
}
~QuickDPlugin(){}
diff --git a/lumina-desktop/desktop-plugins/systemmonitor/MonitorWidget.cpp b/lumina-desktop/desktop-plugins/systemmonitor/MonitorWidget.cpp
index 981e411d..6a300b6c 100644
--- a/lumina-desktop/desktop-plugins/systemmonitor/MonitorWidget.cpp
+++ b/lumina-desktop/desktop-plugins/systemmonitor/MonitorWidget.cpp
@@ -55,7 +55,7 @@ SysMonitorPlugin::SysMonitorPlugin(QWidget *parent, QString ID) : LDPlugin(paren
this->layout()->setContentsMargins(0,0,0,0);
this->layout()->addWidget(monitor);
- this->setInitialSize(monitor->width(),monitor->height());
+ this->setInitialSize(monitor->sizeHint().width(),monitor->sizeHint().height());
}
SysMonitorPlugin::~SysMonitorPlugin(){
bgstack15