diff options
Diffstat (limited to 'lumina-desktop')
-rw-r--r-- | lumina-desktop/LDesktop.cpp | 77 | ||||
-rw-r--r-- | lumina-desktop/LDesktop.h | 4 | ||||
-rw-r--r-- | lumina-desktop/desktop-plugins/LDPlugin.cpp | 3 | ||||
-rw-r--r-- | lumina-desktop/desktop-plugins/LDPlugin.h | 1 | ||||
-rw-r--r-- | lumina-desktop/desktop-plugins/LDPluginContainer.h | 12 | ||||
-rw-r--r-- | lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.cpp | 3 | ||||
-rw-r--r-- | lumina-desktop/desktop-plugins/desktopview/DesktopViewPlugin.cpp | 16 | ||||
-rw-r--r-- | lumina-desktop/panel-plugins/userbutton/UserItemWidget.cpp | 2 |
8 files changed, 99 insertions, 19 deletions
diff --git a/lumina-desktop/LDesktop.cpp b/lumina-desktop/LDesktop.cpp index 76130b00..ba188e8b 100644 --- a/lumina-desktop/LDesktop.cpp +++ b/lumina-desktop/LDesktop.cpp @@ -178,11 +178,11 @@ void LDesktop::checkResolution(){ issyncing = false; } -void LDesktop::CreateDesktopPluginContainer(LDPlugin *plug){ +LDPluginContainer* LDesktop::CreateDesktopPluginContainer(LDPlugin *plug){ //Verify that a container does not already exist for this plugin QList<QMdiSubWindow*> wins = bgDesktop->subWindowList(); for(int i=0; i<wins.length(); i++){ - if(wins[i]->whatsThis()==plug->ID()){ return; } + if(wins[i]->whatsThis()==plug->ID()){ return 0; } } //Create a new plugin container LDPluginContainer *win = new LDPluginContainer(plug, desktoplocked); @@ -191,11 +191,60 @@ void LDesktop::CreateDesktopPluginContainer(LDPlugin *plug){ }else{ bgDesktop->addSubWindow(win, Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint); } //win->adjustSize(); win->loadInitialPosition(); + if(DEBUG){ + qDebug() << "Initial DP Geom:" << plug->geometry(); + qDebug() << " - Container Geom:" << win->geometry(); + } win->show(); + plug->update(); win->update(); + QApplication::processEvents(); bgDesktop->update(); QApplication::processEvents(); + connect(win, SIGNAL(PluginRemoved(QString)), this, SLOT(DesktopPluginRemoved(QString)) ); + return win; +} + +QPoint LDesktop::findNewPluginLocation(QRegion avail, QSize winsize){ + //This just searches through the region of available space until it find the first location where it + // will fit without overlapping anything else (scanning left->right, top->bottom) + QRect bounds = avail.boundingRect(); + if(bounds.width()<winsize.width() || bounds.height()<winsize.height()){ return QPoint(-1,-1); } + qDebug() << "Bounds:" << bounds; + //return QPoint(-1,-1); + + QPoint pt = bounds.topLeft(); //start in upper-left corner + bool found = false; + qDebug() << "Check Availability:" << bounds << winsize; + while(pt.y()+winsize.height() < bounds.bottom() && !found){ + int dy = winsize.height()/2; + while(pt.x()+winsize.width() < bounds.right() && !found){ + qDebug() << "Check X:" << pt << winsize; + //Check the horizontal position (incrementing as necessary) + QRect inter = avail.intersected(QRect(pt, winsize)).boundingRect(); + qDebug() << " - Inter:" << inter; + if(inter.size() == winsize && avail.contains(inter) ){ found = true; } //use this point + else{ + 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(); + if(ddy < dy && ddy>0){ dy = ddy; } + } + + } + if(!found){ + //Nothing in the horizontal direction - increment the vertical dimension + pt.setX( bounds.left() ); //reset back to the left-most edge + pt.setY( pt.y()+dy ); + qDebug() << "Check Y:" << pt << dy; + } + } + if(!found){ return QPoint(-1,-1); } //no space found - return an invalid point + else{ return pt; } } // ===================== @@ -356,6 +405,7 @@ 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 @@ -363,6 +413,15 @@ void LDesktop::UpdateDesktop(){ i--; } } + //Now get an accounting of all the available/used space + QRegion avail(this->availableScreenGeom()); + if(avail.isEmpty()){ avail = QRegion( QRect(QPoint(0,0),desktop->screenGeometry(desktopnumber).size()) ); } + qDebug() << "Available Screen Geom:" << avail.boundingRect(); + QList<QMdiSubWindow*> wins = bgDesktop->subWindowList(); + for(int i=0; i<wins.length(); i++){ + if(avail.contains(wins[i]->geometry())){ avail = avail.subtracted( QRegion(wins[i]->geometry()) ); } + } + qDebug() << " - after removals:" << avail.boundingRect(); //Now add/update plugins for(int i=0; i<plugins.length(); i++){ //See if this plugin is already there @@ -381,11 +440,19 @@ void LDesktop::UpdateDesktop(){ plug = NewDP::createPlugin(plugins[i], bgDesktop); if(plug != 0){ connect(plug, SIGNAL(OpenDesktopMenu()), this, SLOT(ShowMenu()) ); - if(DEBUG){ qDebug() << " -- Show Plugin"; } + if(DEBUG){ qDebug() << " --- Show Plugin"; } PLUGINS << plug; QApplication::processEvents(); //need a moment between plugin/container creation - CreateDesktopPluginContainer(plug); - if(DEBUG){ qDebug() << " -- Done Creating Plugin Container"; } + LDPluginContainer *cont = CreateDesktopPluginContainer(plug); + /*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(avail, cont->size()); + if(pt.x()>=0 && pt.y()>=0){ cont->move(pt); } + }*/ + //Done with this plugin - removed it's area from the available space + if(DEBUG){ qDebug() << " --- Done Creating Plugin Container"; } + avail = avail.subtracted( QRegion(cont->geometry()) ); } } QApplication::processEvents(); //need to process events between loading of plugins diff --git a/lumina-desktop/LDesktop.h b/lumina-desktop/LDesktop.h index f949d861..482f1401 100644 --- a/lumina-desktop/LDesktop.h +++ b/lumina-desktop/LDesktop.h @@ -72,8 +72,10 @@ private: QList<LDPlugin*> PLUGINS; QString CBG; //current background QRect globalWorkRect; - void CreateDesktopPluginContainer(LDPlugin*); + LDPluginContainer* CreateDesktopPluginContainer(LDPlugin*); + QPoint findNewPluginLocation(QRegion avail, QSize winsize); + private slots: void InitDesktop(); void SettingsChanged(); diff --git a/lumina-desktop/desktop-plugins/LDPlugin.cpp b/lumina-desktop/desktop-plugins/LDPlugin.cpp index 9e9cfeba..84c92530 100644 --- a/lumina-desktop/desktop-plugins/LDPlugin.cpp +++ b/lumina-desktop/desktop-plugins/LDPlugin.cpp @@ -11,7 +11,7 @@ LDPlugin::LDPlugin(QWidget *parent, QString id) : QFrame(parent){ PLUGID=id; prefix = id.replace("/","_")+"/"; - qDebug() << "ID:" << PLUGID << prefix; + //qDebug() << "ID:" << PLUGID << prefix; settings = LSession::handle()->DesktopPluginSettings(); //Use plugin-specific values for stylesheet control (applauncher, desktopview, etc...) this->setObjectName(id.section("---",0,0).section("::",0,0)); @@ -22,6 +22,7 @@ void LDPlugin::setInitialSize(int width, int height){ // if the plugin is completely new (first time used), it will be this size if(settings->allKeys().filter(prefix+"location").isEmpty()){ //Brand new plugin: set initial size + qDebug() << "Setting Initial Size:" << PLUGID << width << height; settings->setValue(prefix+"location/width",width); settings->setValue(prefix+"location/height",height); settings->sync(); diff --git a/lumina-desktop/desktop-plugins/LDPlugin.h b/lumina-desktop/desktop-plugins/LDPlugin.h index a69ca9c2..232fd564 100644 --- a/lumina-desktop/desktop-plugins/LDPlugin.h +++ b/lumina-desktop/desktop-plugins/LDPlugin.h @@ -43,6 +43,7 @@ public: void setInitialSize(int width, int height); void saveSetting(QString var, QVariant val){ + //qDebug() << "Saving Setting:" << prefix+var+QString(" = ")+val.toString(); settings->setValue(prefix+var, val); settings->sync(); } diff --git a/lumina-desktop/desktop-plugins/LDPluginContainer.h b/lumina-desktop/desktop-plugins/LDPluginContainer.h index c4d4c9fc..8719f525 100644 --- a/lumina-desktop/desktop-plugins/LDPluginContainer.h +++ b/lumina-desktop/desktop-plugins/LDPluginContainer.h @@ -12,6 +12,7 @@ #include <QObject> #include <QMdiSubWindow> +#include <QApplication> #include <QSettings> #include <QMoveEvent> #include <QResizeEvent> @@ -52,7 +53,7 @@ public: this->setWhatsThis(plugin->ID()); this->setContentsMargins(0,0,0,0); if(!locked){ - this->setStyleSheet("LDPluginContainer{ border-size: 1px;}"); + //this->setStyleSheet("LDPluginContainer{ border-width: 1px;}"); this->setWindowTitle( plugin->ID().replace("---"," - ") ); //this->setWidget( new QWidget() ); this->setWidget( plugin ); @@ -68,8 +69,8 @@ public: } void loadInitialPosition(){ - QRect set(PLUG->readSetting("location/x",-12345).toInt(), PLUG->readSetting("location/y",-12345).toInt(), PLUG->readSetting("location/width",this->widget()->size().width()).toInt(), PLUG->readSetting("location/height",this->widget()->size().height()).toInt()); - //qDebug() << "Initial Plugin Location:" << set.x() << set.y() << set.width() << set.height(); + QRect set(PLUG->readSetting("location/x",-12345).toInt(), PLUG->readSetting("location/y",-12345).toInt(), PLUG->readSetting("location/width",PLUG->size().width()).toInt(), PLUG->readSetting("location/height",PLUG->size().height()).toInt()); + 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(set.x()!=-12345 && set.y()!=-12345){ @@ -81,8 +82,13 @@ public: //qDebug() << " - Found Size:" << set; this->resize(set.width(), set.height()); } + QApplication::processEvents(); setup=false; //done with setup } + + bool hasFixedPosition(){ + return (PLUG->readSetting("location/x",-12345).toInt() != -12345); + } signals: void PluginRemoved(QString); diff --git a/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.cpp b/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.cpp index 447f959b..7d6c3d62 100644 --- a/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.cpp +++ b/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.cpp @@ -24,7 +24,7 @@ AppLauncherPlugin::AppLauncherPlugin(QWidget* parent, QString ID) : LDPlugin(par watcher = new QFileSystemWatcher(this); connect(watcher, SIGNAL(fileChanged(QString)), this, SLOT( loadButton()) ); //Calculate the initial size of the button - this->setInitialSize(icosize+8, icosize+8+qRound(2.2*button->fontMetrics().height())); + this->setInitialSize((1.2*icosize)+8, icosize+8+qRound(2.3*button->fontMetrics().height())); QTimer::singleShot(1,this, SLOT(loadButton()) ); } @@ -102,7 +102,6 @@ void AppLauncherPlugin::loadButton(){ } button->setFixedSize(icosize+4, icosize+8+qRound(2.1*button->fontMetrics().height()) ); //make sure to adjust the button on first show. - //this->setInitialSize(button->width()+4, button->height()+4); QTimer::singleShot(100, this, SLOT(update()) ); //Make sure to re-draw the image in a moment } diff --git a/lumina-desktop/desktop-plugins/desktopview/DesktopViewPlugin.cpp b/lumina-desktop/desktop-plugins/desktopview/DesktopViewPlugin.cpp index 81f1281b..5fdd1ba0 100644 --- a/lumina-desktop/desktop-plugins/desktopview/DesktopViewPlugin.cpp +++ b/lumina-desktop/desktop-plugins/desktopview/DesktopViewPlugin.cpp @@ -16,14 +16,13 @@ DesktopViewPlugin::DesktopViewPlugin(QWidget* parent, QString ID) : LDPlugin(par list = new QListWidget(this); //list->setUniformItemSizes(true); list->setViewMode(QListView::IconMode); - list->setLayoutMode(QListView::Batched); - list->setBatchSize(10); //keep it snappy + //list->setLayoutMode(QListView::Batched); + list->setFlow(QListWidget::TopToBottom); //Qt bug workaround - need the opposite flow in the widget constructor + list->setWrapping(true); + //list->setBatchSize(10); //keep it snappy list->setSpacing(2); list->setSelectionBehavior(QAbstractItemView::SelectItems); list->setSelectionMode(QAbstractItemView::ExtendedSelection); - //int icosize = this->readSetting("IconSize",64).toInt(); - //list->setIconSize(QSize(icosize,icosize)); - //list->setUniformItemSizes(true); list->setContextMenuPolicy(Qt::CustomContextMenu); menu = new QMenu(this); @@ -46,7 +45,7 @@ DesktopViewPlugin::DesktopViewPlugin(QWidget* parent, QString ID) : LDPlugin(par connect(QApplication::instance(), SIGNAL(DesktopFilesChanged()), this, SLOT(updateContents()) ); connect(list, SIGNAL(itemActivated(QListWidgetItem*)), this, SLOT(runItems()) ); connect(list, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(showMenu(const QPoint&)) ); - QTimer::singleShot(0,this, SLOT(updateContents()) ); + QTimer::singleShot(1000,this, SLOT(updateContents()) ); //wait a second before loading contents } DesktopViewPlugin::~DesktopViewPlugin(){ @@ -184,16 +183,21 @@ void DesktopViewPlugin::updateContents(){ QStringList txtL = txt.split("\n"); for(int i=0; i<txtL.length(); i++){ txtL[i] = this->fontMetrics().elidedText(txtL[i], Qt::ElideRight, gridSZ.width()); } txt = txtL.join("\n"); + if(txtL.length()>2){ txt = txt.section("\n",0,1); } //only keep the first two lines }else{ txt = this->fontMetrics().elidedText(txt,Qt::ElideRight, 2*gridSZ.width()); //Now split the line in half for the two lines txt.insert( (txt.count()/2), "\n"); } + }else{ + txt.append("\n "); //ensure two lines (2nd one invisible) - keeps formatting sane } it->setText(txt); list->addItem(it); QApplication::processEvents(); //keep the UI snappy } + list->setFlow(QListWidget::LeftToRight); //To ensure this is consistent - issues with putting it in the constructor + list->update(); //Re-paint the widget after all items are added } void DesktopViewPlugin::displayProperties(){ diff --git a/lumina-desktop/panel-plugins/userbutton/UserItemWidget.cpp b/lumina-desktop/panel-plugins/userbutton/UserItemWidget.cpp index fccb518f..689bd8eb 100644 --- a/lumina-desktop/panel-plugins/userbutton/UserItemWidget.cpp +++ b/lumina-desktop/panel-plugins/userbutton/UserItemWidget.cpp @@ -103,7 +103,7 @@ void UserItemWidget::createWidget(){ } void UserItemWidget::setupButton(bool disable){ - if(isDirectory){ qDebug() << "Directory Entry:" << isShortcut << linkPath << icon->whatsThis(); } + //if(isDirectory){ qDebug() << "Directory Entry:" << isShortcut << linkPath << icon->whatsThis(); } if(disable){ button->setVisible(false); |