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/applauncher | |
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/applauncher')
-rw-r--r-- | lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.cpp | 21 | ||||
-rw-r--r-- | lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.h | 2 |
2 files changed, 15 insertions, 8 deletions
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(); |