diff options
author | Ken Moore <moorekou@gmail.com> | 2015-07-08 15:28:18 -0400 |
---|---|---|
committer | Ken Moore <moorekou@gmail.com> | 2015-07-08 15:28:18 -0400 |
commit | 2d62234be74338e6d0d78b7eeb4d28541903ecb4 (patch) | |
tree | a170707d97a29392e4313075917f12b31a4842b8 /lumina-desktop/desktop-plugins | |
parent | Update the gitignore to avoid some other binaries/libraries (diff) | |
download | lumina-2d62234be74338e6d0d78b7eeb4d28541903ecb4.tar.gz lumina-2d62234be74338e6d0d78b7eeb4d28541903ecb4.tar.bz2 lumina-2d62234be74338e6d0d78b7eeb4d28541903ecb4.zip |
Fix up the clipping/sizing issues with the applauncher desktop icons.
Diffstat (limited to 'lumina-desktop/desktop-plugins')
5 files changed, 51 insertions, 18 deletions
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(); |