aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lumina-desktop/LDesktop.cpp36
-rw-r--r--lumina-desktop/desktop-plugins/LDPlugin.cpp7
-rw-r--r--lumina-desktop/desktop-plugins/LDPlugin.h3
-rw-r--r--lumina-desktop/desktop-plugins/LDPluginContainer.h36
-rw-r--r--lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.cpp21
-rw-r--r--lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.h2
6 files changed, 72 insertions, 33 deletions
diff --git a/lumina-desktop/LDesktop.cpp b/lumina-desktop/LDesktop.cpp
index ba188e8b..e244e4b1 100644
--- a/lumina-desktop/LDesktop.cpp
+++ b/lumina-desktop/LDesktop.cpp
@@ -187,9 +187,8 @@ LDPluginContainer* LDesktop::CreateDesktopPluginContainer(LDPlugin *plug){
//Create a new plugin container
LDPluginContainer *win = new LDPluginContainer(plug, desktoplocked);
if(desktoplocked){
- bgDesktop->addSubWindow(win, Qt::FramelessWindowHint);
- }else{ bgDesktop->addSubWindow(win, Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint); }
- //win->adjustSize();
+ bgDesktop->addSubWindow(win, Qt::Tool | Qt::FramelessWindowHint);
+ }else{ bgDesktop->addSubWindow(win, Qt::Tool | Qt::FramelessWindowHint | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint); }
win->loadInitialPosition();
if(DEBUG){
qDebug() << "Initial DP Geom:" << plug->geometry();
@@ -211,19 +210,18 @@ QPoint LDesktop::findNewPluginLocation(QRegion avail, QSize winsize){
// 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);
+ //qDebug() << "Bounds:" << bounds;
QPoint pt = bounds.topLeft(); //start in upper-left corner
bool found = false;
- qDebug() << "Check Availability:" << bounds << winsize;
+ //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;
+ //qDebug() << "Check X:" << pt << winsize;
//Check the horizontal position (incrementing as necessary)
QRect inter = avail.intersected(QRect(pt, winsize)).boundingRect();
- qDebug() << " - Inter:" << inter;
+ //qDebug() << " - Inter:" << inter;
if(inter.size() == winsize && avail.contains(inter) ){ found = true; } //use this point
else{
int dx = winsize.width() - inter.width();
@@ -240,9 +238,10 @@ QPoint LDesktop::findNewPluginLocation(QRegion avail, QSize winsize){
//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;
+ //qDebug() << "Check Y:" << pt << dy;
}
}
+ //qDebug() << "Found Point:" << found << pt;
if(!found){ return QPoint(-1,-1); } //no space found - return an invalid point
else{ return pt; }
}
@@ -416,12 +415,12 @@ void LDesktop::UpdateDesktop(){
//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();
+ //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();
+ //qDebug() << " - after removals:" << avail.boundingRect();
//Now add/update plugins
for(int i=0; i<plugins.length(); i++){
//See if this plugin is already there
@@ -444,15 +443,22 @@ void LDesktop::UpdateDesktop(){
PLUGINS << plug;
QApplication::processEvents(); //need a moment between plugin/container creation
LDPluginContainer *cont = CreateDesktopPluginContainer(plug);
- /*if(!cont->hasFixedPosition()){
+ 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(avail, cont->size());
- if(pt.x()>=0 && pt.y()>=0){ cont->move(pt); }
- }*/
+ if(pt.x()>=0 && pt.y()>=0){
+ cont->saveNewPosition(pt);
+ QTimer::singleShot(1000, 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"; }
+ if(DEBUG){ qDebug() << " --- Done Creating Plugin Container" << cont->geometry(); }
avail = avail.subtracted( QRegion(cont->geometry()) );
+
}
}
QApplication::processEvents(); //need to process events between loading of plugins
diff --git a/lumina-desktop/desktop-plugins/LDPlugin.cpp b/lumina-desktop/desktop-plugins/LDPlugin.cpp
index 84c92530..5db20232 100644
--- a/lumina-desktop/desktop-plugins/LDPlugin.cpp
+++ b/lumina-desktop/desktop-plugins/LDPlugin.cpp
@@ -28,3 +28,10 @@ void LDPlugin::setInitialSize(int width, int height){
settings->sync();
}
}
+
+void LDPlugin::adjustSize(int width, int height){
+ settings->setValue(prefix+"location/width",width);
+ settings->setValue(prefix+"location/height",height);
+ settings->sync();
+ emit PluginResized();
+} \ No newline at end of file
diff --git a/lumina-desktop/desktop-plugins/LDPlugin.h b/lumina-desktop/desktop-plugins/LDPlugin.h
index 232fd564..d49fa40a 100644
--- a/lumina-desktop/desktop-plugins/LDPlugin.h
+++ b/lumina-desktop/desktop-plugins/LDPlugin.h
@@ -41,6 +41,7 @@ public:
}
void setInitialSize(int width, int height);
+ void adjustSize(int width, int height);
void saveSetting(QString var, QVariant val){
//qDebug() << "Saving Setting:" << prefix+var+QString(" = ")+val.toString();
@@ -90,7 +91,7 @@ public slots:
signals:
void OpenDesktopMenu();
-
+ void PluginResized();
};
#endif
diff --git a/lumina-desktop/desktop-plugins/LDPluginContainer.h b/lumina-desktop/desktop-plugins/LDPluginContainer.h
index 8719f525..da8ead6e 100644
--- a/lumina-desktop/desktop-plugins/LDPluginContainer.h
+++ b/lumina-desktop/desktop-plugins/LDPluginContainer.h
@@ -35,10 +35,12 @@ private:
private slots:
void saveGeometry(){
if(PLUG==0){ return; }
- 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());
+ 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());
+ }
}
public:
@@ -47,7 +49,7 @@ public:
setup=true;
PLUG = plugin;
syncTimer = new QTimer(this);
- syncTimer->setInterval(500); //save settings 1 second after it is moved
+ syncTimer->setInterval(500); //save settings 1/2 second after it is moved
syncTimer->setSingleShot(true); //no repeats
connect(syncTimer, SIGNAL(timeout()), this, SLOT(saveGeometry()) );
this->setWhatsThis(plugin->ID());
@@ -63,21 +65,40 @@ public:
this->setWidget(plugin);
}
//qDebug() << "New Container:" << PLUG->size() << PLUG->sizeHint();
+ connect(PLUG, SIGNAL(PluginResized()), this, SLOT(loadInitialPosition()) );
}
~LDPluginContainer(){
}
+
+ void saveNewPosition(QPoint pt){
+ //generally only used while a plugin is locked and does not have an initial position
+ // This works around an issue with QMdiArea moving the new container out of alignment
+ if(PLUG==0){ return; }
+ PLUG->saveSetting("location/x",pt.x());
+ PLUG->saveSetting("location/y", pt.y());
+ }
+
+ bool hasFixedPosition(){
+ return (PLUG->readSetting("location/x",-12345).toInt() != -12345);
+ }
+public slots:
void loadInitialPosition(){
- 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());
+ 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());
}else{
//qDebug() << " - Found Size:" << set;
this->resize(set.width(), set.height());
@@ -86,9 +107,6 @@ public:
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 7d6c3d62..52c82556 100644
--- a/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.cpp
+++ b/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.cpp
@@ -24,12 +24,15 @@ 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((1.2*icosize)+8, icosize+8+qRound(2.3*button->fontMetrics().height()));
+ //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()));
- QTimer::singleShot(1,this, SLOT(loadButton()) );
+ QTimer::singleShot(100,this, SLOT(loadButton()) );
}
-void AppLauncherPlugin::loadButton(){
+void AppLauncherPlugin::loadButton(bool onchange){
QString def = this->ID().section("::",1,50).section("---",0,0).simplified();
QString path = this->readSetting("applicationpath",def).toString(); //use the default if necessary
//qDebug() << "Default Application Launcher:" << def << path;
@@ -72,8 +75,11 @@ void AppLauncherPlugin::loadButton(){
//Now adjust the visible text as necessary based on font/grid sizing
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.
+ 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) > (icosize-2) ){
+ if(button->fontMetrics().width(txt) > (bwid-2) ){
//int dash = this->fontMetrics().width("-");
//Text too long, try to show it on two lines
txt = txt.section(" ",0,2).replace(" ","\n"); //First take care of any natural breaks
@@ -82,11 +88,11 @@ void AppLauncherPlugin::loadButton(){
QStringList txtL = txt.split("\n");
for(int i=0; i<txtL.length(); i++){
if(i>1){ txtL.removeAt(i); i--; } //Only take the first two lines
- else{ txtL[i] = button->fontMetrics().elidedText(txtL[i], Qt::ElideRight, icosize); }
+ else{ txtL[i] = button->fontMetrics().elidedText(txtL[i], Qt::ElideRight, bwid-2); }
}
txt = txtL.join("\n");
}else{
- txt = this->fontMetrics().elidedText(txt,Qt::ElideRight, 2*icosize);
+ txt = this->fontMetrics().elidedText(txt,Qt::ElideRight, 2*bwid -4);
//Now split the line in half for the two lines
txt.insert( (txt.count()/2), "\n");
}
@@ -101,7 +107,6 @@ void AppLauncherPlugin::loadButton(){
menu->addAction(LXDG::findIcon("list-remove",""), tr("Delete File"), this, SLOT(deleteFile()) );
}
- button->setFixedSize(icosize+4, icosize+8+qRound(2.1*button->fontMetrics().height()) ); //make sure to adjust the button on first show.
QTimer::singleShot(100, this, SLOT(update()) ); //Make sure to re-draw the image in a moment
}
@@ -136,6 +141,7 @@ void AppLauncherPlugin::increaseIconSize(){
icosize += 16;
button->setIconSize(QSize(icosize,icosize));
this->saveSetting("iconsize",icosize);
+ this->loadButton(true); //redo size calculations
}
@@ -145,6 +151,7 @@ void AppLauncherPlugin::decreaseIconSize(){
icosize -= 16;
button->setIconSize(QSize(icosize,icosize));
this->saveSetting("iconsize",icosize);
+ this->loadButton(true); //redo size calculations
}
void AppLauncherPlugin::deleteFile(){
diff --git a/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.h b/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.h
index fdb4e8f4..f9f60c0b 100644
--- a/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.h
+++ b/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.h
@@ -35,7 +35,7 @@ private:
QMenu *menu;
private slots:
- void loadButton();
+ void loadButton(bool onchange = false);
void buttonClicked();
void openContextMenu();
bgstack15